refactor: write literal property values directly + decode both old and new shapes#604
Draft
HexaField wants to merge 4 commits into
Draft
refactor: write literal property values directly + decode both old and new shapes#604HexaField wants to merge 4 commits into
HexaField wants to merge 4 commits into
Conversation
After the ad4m executor stops emitting signed-expression envelopes for literal-language property writes, link targets storing string/number/ boolean values come back from Literal.fromUrl().get() as the raw value rather than as an envelope object with a .data field. Existing .get().data sites would start returning undefined. Introduce unwrapLiteralValue in flux-utils which decodes literal: URLs and returns the inner value for both plain and signed-envelope shapes. Update the five sites in flux-utils + flux-api that previously assumed the envelope shape.
✅ Deploy Preview for fluxsocial-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Cross-repo branch linking means flux CI runs the same-name ad4m branch of @coasys/ad4m, which drops the .data extraction from parseLit. Caller- visible behaviour: literal:json: objects round-trip as JSON.stringify, leaving envelope-vs-plain shape decisions to unwrapLiteralValue.
createNeighbourhoodMeta, createLiteralLinks, and createLiteralObject previously routed property values through client.expression.create(value, 'literal'), which signs the value into a literal:json:<envelope> URI on the executor — embedding author/timestamp/proof in the target IRI and duplicating provenance that already lives on the link reifier. Encode the value client-side with Literal.from(value).toUrl() instead. Targets become deterministic plain literal URIs; the reifier remains the single source of truth for who wrote the link and when. createLiteralObject now uses the deterministic parent URL as a stable entity identity — two calls with the same parent.target value resolve to the same parent IRI, which is the intended semantics for value-keyed entities like web links.
11 tasks
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.
Summary
Companion to coasys/ad4m#837. After that PR lands, the ad4m executor stops embedding signed-expression envelopes (
{author, timestamp, data, proof}) in link targets when properties are written through the literal language — per-link author/timestamp/proof lives only on the RDF reifier going forward. This PR brings flux into line on both sides of that contract: the write helpers that put the envelope into the target in the first place, and the read sites that pulled values out of the envelope shape via.get().data.Writes — stop embedding provenance in targets
Five flux call sites previously routed property values through
client.expression.create(value, 'literal'). The executor's literal language signs the value into aliteral:json:<envelope>URL, so the target carried{author, timestamp, data, proof}duplicating provenance the reifier already holds. After this PR every property target is encoded client-side as a deterministic plainliteral:string:/:number:/:boolean:/:json:URL viaLiteral.from(value).toUrl(). No round-trip to the executor, no embedded provenance, no envelope.packages/utils/src/createNeighbourhoodMeta.tsname,createdAt,descriptionpackages/utils/src/linkHelpers.ts(createLiteralLinks)createProfile,updateProfilepackages/utils/src/linkHelpers.ts(createLiteralObject)createAgentWebLinkcreateLiteralObjectgains a useful side effect: the deterministic parent URL doubles as a stable entity identity, so two calls with the sameparent.targetvalue resolve to the same IRI — which is what callers likecreateAgentWebLinkactually want (same URL → same WebLink entity).grep -rn "expression\.create\([^)]*['\"]literal['\"]\)"againstpackages/returns no hits after this PR. The only remainingexpression.create("…", "literal")callers across the ecosystem are dapp entanglement proofs and agent expressions in the ad4m repo, both of which intentionally produce addressable signed expressions (a separate concern from link-property storage).Reads — handle both old and new target shapes
New
unwrapLiteralValue(target)helper in@coasys/flux-utilsthat decodesliteral:URLs and returns the inner value:expression.create(value, "literal")URL that callers feed in) → returns the inner.data.undefined; call sites substitute the raw target.Updated four reader sites that previously assumed the envelope shape:
packages/utils/src/linkHelpers.ts(mapLiteralLinks).get().dataon the json: branchpackages/utils/src/getNeighbourhoodMeta.ts(getMetaFromLinks).get().dataon NAME / DESCRIPTION / CREATED_AT predicatespackages/utils/src/prologHelpers.ts(resolveExpinside model property resolution).get().dataon literal: URLspackages/api/src/getAgentWebLinks.ts.get().dataon weblink parent targetPlus
packages/api/src/utils/parseLit.test.tsflipped from asserting.dataextraction to assertingJSON.stringify(obj)to matchparseLit's new behaviour in ad4m#837 (envelope semantics live inunwrapLiteralValuenow, not inparseLit).Test plan
pnpm exec vitest run packages/api/src/utils/—unwrapLiteralValue(7/7) +parseLit(6/7 locally against the published ad4m, 7/7 expected in CI against the linked branch)pnpm exec tsc --noEmit -p packages/utils/tsconfig.jsonclean for changed filespnpm exec tsc --noEmit -p packages/api/tsconfig.jsonclean for changed filescreateNeighbourhoodMeta+getMetaFromLinksCross-repo coupling
Flux CI resolves the same-name
refactor/literal-channel-v-separationbranch of@coasys/ad4mand tests against that build, not the currently-published version. The two PRs ship as one logical change.