Skip to content

refactor(api): drop parseLit() on typed-literal SPARQL bindings - #622

Merged
lucksus merged 1 commit into
refactor/typed-rdf-literals-and-fn-cleanup-nico-refactorfrom
refactor/typed-literal-cleanup-in-api
Aug 17, 2026
Merged

lucksus merged 1 commit into
refactor/typed-rdf-literals-and-fn-cleanup-nico-refactorfrom
refactor/typed-literal-cleanup-in-api

Conversation

@marvin-bot-coasys

Copy link
Copy Markdown
Contributor

Follow-up to #621 — fixes the failing parseLit.test.ts and simplifies every hard-coded SPARQL call site whose target has flipped from envelope URI to typed XSD literal.

Background

With coasys/ad4m#874 (typed RDF literals refactor), scalar @Property fields with no resolveLanguage are stored as deterministic typed XSD literals rather than literal:string:… envelopes. Oxigraph returns their lexical form directly in SPARQL bindings — parseLit() on those values is a no-op that only happens to still work because Literal.fromUrl("plain string").get() throws and the helper falls through to the raw value.

Also: parseLit in ad4m core (commit 3a96f73a) dropped the result.data extraction branch because signed-envelope literals no longer exist for new property writes.

Changes

packages/api/src/utils/parseLit.test.ts

  • Fixes the failing case (extracts .data from JSON literal objects). The new behaviour is to JSON-stringify the whole object (matches ad4m core parseLit). Renamed the test accordingly and documented the new contract.

Removed parseLit() wrappers on typed-literal bindings:

  • channel/index.ts — body, title, taskName, transcriptStart in allItems() / unprocessedItems(); isConv in recentConversations()
  • conversation-subgroup/index.ts — topicNameRaw, body, title, taskName, transcriptStart, relevanceRaw in topics() / itemsData() / topicsWithRelevance()
  • conversation/index.ts — topicNameRaw, nameRaw, summaryRaw, transcriptStart in topics() / subgroupsData()
  • topic/index.ts — relevance, channelName in linkedConversations() / linkedSubgroups()
  • semantic-relationship/index.ts — channelName in allConversationEmbeddings() / allSubgroupEmbeddings() / allItemEmbeddings() / allItemEmbeddingsByType()

Removed now-unused parseLit imports from all five files.

Left untouched (correct as-is)

  • Post.image, Community.name/icon — resolveLanguage: FILE_STORAGE_LANGUAGE, still expression URIs resolved via getExpression()
  • Channel.pinnedConversations() SPARQL — already uses <ad4m://fn/parse_literal> server-side, correct for typed literals
  • binding.embedding in semantic-relationship — expression URI on the embedding language, resolved via getExpression()

Not touched here

Broader Flux code (Kanban/Table/Graph views, packages/utils, WebRTC, ProfileView) still uses Literal.fromUrl(...).get() on values that come from generic/user data where the storage mode isn't fixed by our model definitions. Those need per-case treatment and are out of scope for this CI-unblock work; happy to follow up in a separate PR.

Verification

Local reproduction of CI (ad4m core built from refactor/drop-resolve-literal-flag, which branches off this PR's ad4m target):

  • pnpm --filter @coasys/flux-api test: 7 files, 112 tests green (was 1 failing, 111 passing)
  • No new TypeScript errors introduced (the one pre-existing PerspectiveProxy mock-shape error in channel-rename.test.ts is unrelated)
  • The stderr "SPARQL error" lines in test output are from tests that deliberately mock querySparql to throw and assert graceful handling — those tests pass.

Diff

6 files changed, +61 / −40

The typed-RDF-literals refactor in coasys/ad4m#874 stores scalar model
properties as deterministic typed XSD literals rather than URL-encoded
`literal:string:` envelopes. SPARQL bindings for those properties now
return the lexical form directly \u2014 the parseLit() decode step is a
no-op that only survives by falling through on the throw path.

Removes parseLit() from every hard-coded SPARQL call site whose target
predicate is a bare @Property (`flux://body`, `flux://title`,
`flux://name`, `flux://transcript_started_at`, `flux://has_name`,
`flux://has_summary`, `flux://topic`, `flux://has_relevance`,
`flux://has_channel_name`, `flux://is_pinned`, `flux://is_conversation`)
across Channel, Conversation, ConversationSubgroup, Topic, and
SemanticRelationship.

Bindings that are already correctly handled are untouched:
- Post.image / Community.name+icon (resolveLanguage: FILE_STORAGE_LANGUAGE)
  still resolve as expression URIs via getExpression()
- Channel.pinnedConversations() SPARQL FILTER already uses
  <ad4m://fn/parse_literal> on the server side
- Channel.recentConversations() now checks r.isConv === 'true' directly

Also fixes the failing parseLit.test.ts case: ".data" extraction was
dropped from ad4m core's parseLit (see coasys/ad4m@3a96f73a) because
signed-envelope literals no longer exist for new property writes; JSON
objects returned by Literal.fromUrl() are now JSON-stringified for
display. Updated the test expectation to match.

The deprecated `packages/api/src/utils/parseLit.ts` re-export is kept
for now as a soft-deprecation shim \u2014 callers that still import it
(none in this package after this change; the flag was removed from the
grep, one comment references it) will keep working, and its test
suite documents the new behaviour.

Verified:
- packages/api pnpm test: 112 tests / 7 files green (local ad4m HEAD)
- No new TS errors; the one pre-existing PerspectiveProxy mock-shape
  error in channel-rename.test.ts is unrelated to this change.
@coderabbitai

coderabbitai Bot commented Aug 17, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b211ad81-12e7-4c29-abb0-73bf9eed2be4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@lucksus
lucksus merged commit 0f2a2f3 into refactor/typed-rdf-literals-and-fn-cleanup-nico-refactor Aug 17, 2026
1 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants