Repository navigation
refactor(api): drop parseLit() on typed-literal SPARQL bindings - #622
Merged
lucksus merged 1 commit intoAug 17, 2026
Conversation
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.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
lucksus
merged commit Aug 17, 2026
0f2a2f3
into
refactor/typed-rdf-literals-and-fn-cleanup-nico-refactor
1 of 4 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #621 — fixes the failing
parseLit.test.tsand 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
@Propertyfields with noresolveLanguageare stored as deterministic typed XSD literals rather thanliteral: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 becauseLiteral.fromUrl("plain string").get()throws and the helper falls through to the raw value.Also:
parseLitin ad4m core (commit 3a96f73a) dropped theresult.dataextraction branch because signed-envelope literals no longer exist for new property writes.Changes
packages/api/src/utils/parseLit.test.tsextracts .data from JSON literal objects). The new behaviour is to JSON-stringify the whole object (matches ad4m coreparseLit). Renamed the test accordingly and documented the new contract.Removed
parseLit()wrappers on typed-literal bindings:channel/index.ts—body,title,taskName,transcriptStartinallItems()/unprocessedItems();isConvinrecentConversations()conversation-subgroup/index.ts—topicNameRaw,body,title,taskName,transcriptStart,relevanceRawintopics()/itemsData()/topicsWithRelevance()conversation/index.ts—topicNameRaw,nameRaw,summaryRaw,transcriptStartintopics()/subgroupsData()topic/index.ts—relevance,channelNameinlinkedConversations()/linkedSubgroups()semantic-relationship/index.ts—channelNameinallConversationEmbeddings()/allSubgroupEmbeddings()/allItemEmbeddings()/allItemEmbeddingsByType()Removed now-unused
parseLitimports from all five files.Left untouched (correct as-is)
Post.image,Community.name/icon—resolveLanguage: FILE_STORAGE_LANGUAGE, still expression URIs resolved viagetExpression()Channel.pinnedConversations()SPARQL — already uses<ad4m://fn/parse_literal>server-side, correct for typed literalsbinding.embeddinginsemantic-relationship— expression URI on the embedding language, resolved viagetExpression()Not touched here
Broader Flux code (Kanban/Table/Graph views,
packages/utils, WebRTC, ProfileView) still usesLiteral.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)PerspectiveProxymock-shape error inchannel-rename.test.tsis unrelated)stderr"SPARQL error" lines in test output are from tests that deliberately mockquerySparqlto throw and assert graceful handling — those tests pass.Diff
6 files changed, +61 / −40