Repository navigation
fix: do not compact JSON-LD @id node identifiers against @vocab - #1284
Merged
Merged
Conversation
Per JSON-LD 1.1, @vocab governs only property names, @type values, and @type:@vocab term values. It must not shorten node identifiers. The result formatters were compacting @id positions through the @vocab path, so with a query @context of {"@vocab": "http://example.org/lists/"} an @id of http://example.org/lists/summer was emitted as the bare term "summer" — which a conformant processor re-resolves against @base, not @vocab. Add IriCompactor::compact_id_sid (decode then @ID-Position compaction: @base and explicit prefixes only, never @vocab) and route every @id / node-reference output site through the compact_id_* path: - hydration.rs: root @id, expand_ref bare-@id fallback, nested-ref @id, reverse-value @id, and the defensive Ref-in-literal @id fallbacks - jsonld.rs: flat-select Binding::Sid / IriMatch - typed.rs: Binding::Sid / IriMatch - sparql.rs: SPARQL JSON uri value (a uri is a node identifier too) Predicate keys, @type values, datatype @type, and reverse-predicate keys keep the @vocab path. construct.rs was already correct; agent_json.rs inherits the fix via its jsonld delegation. Note: compact_vocab intentionally keeps @base as a fallback vocabulary so a bare @type/predicate in an @base-only context round-trips; that behavior is unchanged. @vocab:"" still maps the vocabulary to @base. Add unit tests (iri/jsonld/typed) and an integration suite covering the hydration root and nested @id, flat-select references, combined @base+@vocab separation, and the @vocab:"" -> @base round-trip. Document the @vocab/@base compaction rules in docs/concepts/iri-and-context.md.
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
Per JSON-LD 1.1,
@vocabgoverns only property names,@typevalues, and@type: @vocabterm values — it must not shorten node identifiers. The result formatters were compacting@idpositions through the@vocabpath, so with a query@contextof{"@vocab": "http://example.org/lists/"}an@idofhttp://example.org/lists/summerwas emitted as the bare term"summer", which a conformant processor re-resolves against@base, not@vocab.Changes
IriCompactor::compact_id_sid(decode then@id-position compaction:@base+ explicit prefixes only, never@vocab).@id/ node-reference output site through thecompact_id_*path:hydration.rs: root@id,expand_refbare-@idfallback, nested-ref@id, reverse-value@id, and the defensive Ref-in-literal@idfallbacksjsonld.rs: flat-selectBinding::Sid/IriMatchtyped.rs:Binding::Sid/IriMatchsparql.rs: SPARQL JSONurivalue (auriis a node identifier too)@typevalues, datatype@type, and reverse-predicate keys keep the@vocabpath.construct.rswas already correct;agent_json.rsinherits the fix via itsjsonlddelegation.Behavior preserved
compact_vocabintentionally keeps@baseas a fallback vocabulary so a bare@type/predicate in an@base-only context round-trips — unchanged.@vocab: ""still maps the vocabulary to@base.Tests & docs
iri/jsonld/typed) plus an integration suite covering the hydration root and nested@id, flat-select references, combined@base+@vocabseparation, and the@vocab: ""→@baseround-trip.@vocab/@basecompaction rules indocs/concepts/iri-and-context.md.Closes: #1280