Skip to content

fix(json-ld): a scoped term takes the vocabulary, and a keyword names no node - #2400

Merged
bplatz merged 10 commits into
nextfrom
fix/jsonld-scoped-vocab-keyword-keys
Nov 16, 2026
Merged

bplatz merged 10 commits into
nextfrom
fix/jsonld-scoped-vocab-keyword-keys

Conversation

@bplatz

@bplatz bplatz commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Two places where a JSON-LD document asks for an IRI and doesn't get one.

  • A scoped context's term takes the vocabulary in effect. A property- or type-scoped context is parsed when its term is defined, before any enclosing context is in view. So a term it defines with no @id became a plain name even under an enclosing @vocab: bar inside foo was stored as bar, not http://example.org/bar. apply_scoped_context already re-expands a scoped term's compact IRI against the active context. It now also resolves what the scoped context left relative:

    • A term with no @id, and an @id, @reverse or @type datatype with no :, joins the vocabulary in effect there.
    • The scoped context's own @vocab expands where the context applies, by the rule a top-level one follows since fix(json-ld): an explicit @vocab is taken as written #2397: a relative one joins the enclosing vocabulary, and a compact IRI expands over the enclosing prefixes. Joined once at parse and again on apply, a relative one used to come out as rel/rel/bar.
    • A scoped "@vocab": null clears the vocabulary, so its terms and every other key under it are plain names. The parsed context now records the null, which it could not tell from no @vocab; before this, keys the scoped context did not define kept the enclosing vocabulary.

    With no vocabulary in effect, a term stays a plain name, which is a documented choice. A JSON-LD query already read the term through the enclosing @vocab, so it missed what such an insert stored; the two now match.

  • A keyword-form string that names a node is refused. This covers an @id, a value coerced by @type: @id or @type: @vocab, a value object typed @id, and a node's @type. Such a string, like "@ignoreMe", used to be stored as an IRI. It is now refused, as the same key on a node already is, with an error that says it has the form of a keyword and to write an IRI. The check is in the expander, so transactions, bulk import and rdf::parse all get it. A value object's datatype is not a node and is unaffected.

  • Bulk import refuses a key starting with @ inside @reverse. The transaction parser already refused it; the JSON-LD adapter wrote it as a predicate.

Breaking. A document that relied on either behavior now writes a different IRI or is refused. compatibility.md has a breaking-change entry, and its deviation list says where keyword-form strings are refused. The entry says what data an earlier release wrote does now: a query under the context never found a plain-name property, while a delete now half-applies and an upsert adds a second value. Data stored under a keyword-form IRI still answers a query but can't be named by a write. The section on earlier data has the repairs: a rename for the properties, a retype for the datatypes, and two updates that move a keyword-form node and the references to it. Tests run each against data in the shape an earlier release stored.

The W3C register (#2396). These registered tests now pass, in both expand and toRdf, and their 16 entries are removed: tc002, tc003, tc004, tc007, tc012, tc019, tc026, tpr22. tpr22 is registered under @protected, but it failed on the scoped term. The register's notes for t0122/te122 now say that @ignoreMe as an @id is refused.

The JSON-LD query parser does not apply property- or type-scoped contexts at all. That is why its read already used the enclosing @vocab. This PR doesn't change that.

Partially addresses #2395: the scoped-term part of its "Scoped contexts and keywords" item. A type-scoped null context and @base, keyword aliases, @none and the @nest cases remain.

… no node

A term a scoped context defined with no @id became a plain name even under an
enclosing @vocab, because the scoped context is parsed before any outer
context is in view. It now joins the vocabulary in effect where the context
applies, as a term of the enclosing context does.

A keyword-form string where an @id goes ("@ignoreme") was stored as that
IRI; it is refused, as such a key on a node is. Bulk import refuses a key
starting with @ inside @reverse, as a transaction already did.
@bplatz bplatz added bug Something isn't working as expected breaking-change Backwards-incompatible change; drives the Breaking Changes release-notes section labels Nov 14, 2026
@bplatz
bplatz requested a review from a team November 14, 2026 16:02

@aaj3f aaj3f left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bplatz both fixes look right to me, and the scoped-term one closes a quiet gap where a query can't find what the same context's insert wrote. One small must below: a relative scoped @vocab is now joined twice.

On the release line, that's your call, but two things I'd weigh. I can't find a blocking reason this needs next: a pick onto main conflicts only on a neighbouring match arm and two lists. And 4.2.x is writing scoped-term data its own queries can't reach today, so there's real value in at least the scoped-term half reaching main; the keyword refusal may sit better in 5.0, since it turns a working transaction into an error.

My reading is that refusing a keyword-form @id like "@alice" turns a working transaction into an error, where JSON-LD drops it with a warning. I think that's right for a database, but I'd like your confirmation it's the intended decision.

Full review below:


✅ Approving to unblock: please get the relative-@vocab fix and the entry's repair recipes in before merging. This is a careful pair of fixes with tests that actually bite (each one goes red under its own mutation), and the musts are a line of code and two paragraphs of docs.

Before merging:

  1. fluree-graph-json-ld/src/expand.rs:699: join the enclosing vocabulary only when the scoped context has no @vocab of its own.
  2. docs/reference/compatibility.md:407-409: add the repair recipes; say a delete half-applies and an upsert adds a second value.

Notes:

  • This is the second patch to a scoped context that's parsed in isolation and fixed up field by field when it applies: 57d373ebf did compact IRIs over an outer prefix, this does @vocab, and the review turned up three more of the same shape (a scoped @vocab: null, a relative scoped @vocab, a scoped alias of an outer term, which now writes http://ex/name where the top-level path writes the outer term's IRI) beside #2395's tc014/tc015. The class fix would be processing a scoped context against the active context where it applies, memoized per active context, which deletes resolve. Not this PR: the point fixes are right here.
  • Performance: Claude timed expand of 20,000 nodes at the merge-base and this head on a quiet box. Documents this doesn't change are flat (−1.8% to +2.6%). Type-scoped terms with no @id, the ones it fixes, expand 7.0% to 11.9% slower: about 3 points is the longer, correct IRIs, and 4.1% to 7.4% is re-joining the vocabulary each time the type's context applies to a node. Property-scoped terms with no @id are +0.1% to +4.2%. I don't think that's worth holding for, since the slower documents are exactly the ones that wrote the wrong IRI, and the class fix above would remove it along with the per-node context clone that's already there.
  • Merge order: #2393 merges cleanly either way (Claude read the merged parse_value_object, and it composes). With #2396 and #2397 the only conflict is compatibility.md, as the body says. #2227 gets no conflict from this beyond what it already has with next. If this lands on main, #2396's 16 register entries come out in the next main-to-next merge. If it stays on next, I'd land #2396 first (Claude merged this onto it on a box: exactly the 16 entries in the body flip, and nothing that passed starts failing), so this rebases, drops them and refreshes the te120/te121 "kept" comment, and then needs a fresh CI run, since next has no required checks.
  • The same shape turned up on #2397: a relative @vocab resolved twice on one path (there, the transaction parser applying the document's top-level @context twice). The direction is one parse per context, which is also where the scoped-context class fix above lands; the point fixes are right in each PR.
  • The read side still applies no scoped context, so a scoped term with an explicit @id still reads differently from how it writes. The body says so; noting it only because this PR is where the two sides now agree for terms without one.
Adherence: Patterns ✔ · Performance ⚠️ · Deployment targets ✔ · Testing ✔ · Conventions ⚠️ · verification
  • Patterns/abstractions: ✔ extends apply_scoped_context's existing resolve rather than adding a parallel path, and puts the keyword refusal in one chokepoint every JSON-LD writer reaches; a node's @type stays outside it (optional above).
  • Performance (speed first, memory second): ⚠️ no regression on documents the PR doesn't change; type-scoped terms with no @id expand 7.0% to 11.9% slower, 4.1 to 7.4 points of it a per-node vocabulary join (measured; not blocking).
  • Deployment targets: ✔ n/a: host-neutral string work in fluree-graph-json-ld, reached by embedded, server and wasm32 alike, with no thread, filesystem, clock or process-lifetime state; wasm32 and wasm-smoke green on the head.
  • Testing: ✔ unit tests in the crate plus an integration file wired into grp_transact, all run by CI on this head; each goes red under its own mutation. The relative-@vocab fix needs its own case.
  • Conventions: ⚠️ multi-line commit and a Behavior-changes entry are there; the entry lacks the repair recipe and mis-states what reaches old data (must 2).

Verified at f4e9b7d7a5: CI test green with all five new tests run by name (17514 passed); the PR's integration tests fail at the merge-base and pass here; a 36-case expansion matrix at both; four mutation checks, each red on its own test and restored clean; a ledger written at the merge-base read and repaired here; the one-line fix applied and reverted; an expansion timing A/B with controls; git merge-tree against #2393, #2396, #2397, #2227 and a pick onto main. The W3C expand and toRdf suites with this merged onto #2396 flip exactly the 16 registered entries the body names, with no new failures.

Approving so you can merge once those three are in; the optional ones are small, and I'd rather see them folded in now than lost in the backlog.

Comment thread fluree-graph-json-ld/src/expand.rs Outdated
/// compact string, or to a plain name under a context that declares a
/// vocabulary.
fn apply_scoped_context(active: &mut ParsedContext, scoped: &ParsedContext) {
let vocab = scoped.vocab.as_deref().or(active.vocab.as_deref());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking: a scoped context with a relative @vocab of its own now has it joined twice.

When the scoped context has its own @vocab, parse_context_map already joined it onto every term with no @id while parsing the scoped context. An absolute vocabulary leaves a : in the id, so resolve skips it. A relative one doesn't, so the new arm joins vocab, which is that same scoped vocabulary, a second time.

Claude reproduced it on a box: under {"@vocab": "http://ex/", "foo": {"@context": {"@vocab": "rel/", "bar": {"@type": "@id"}}}}, the document {"foo": {"bar": "http://o/1"}} writes the property rel/rel/bar at this head, where the merge-base wrote rel/bar. #2397 doesn't change this: a scoped context is still parsed with no vocabulary in view, so its relative @vocab stays relative.

Only a scoped context without a @vocab of its own needs the enclosing one joined here. Claude applied this on the box: the case writes rel/bar again, the other 35 expansion cases Claude ran come out unchanged, and the crate's 184 lib tests pass. A case in a_scoped_term_takes_the_vocabulary_in_effect would pin it.

Suggested change
let vocab = scoped.vocab.as_deref().or(active.vocab.as_deref());
// A scoped context with its own `@vocab` joined its terms to it when it
// was parsed; only one without takes the enclosing vocabulary here.
let vocab = if scoped.vocab.is_some() { None } else { active.vocab.as_deref() };

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 6e9e4b2. Rather than the one-liner, which restores rel/bar, a scoped @vocab now resolves where the context applies, as a top-level one does since #2397, so this case writes http://ex/rel/bar.

Comment thread docs/reference/compatibility.md Outdated

A term that a property- or type-scoped context defines with no `@id`, or with one that has no `:`, is now the vocabulary in effect joined to the term, as a term of the enclosing context is: the scoped context's own `@vocab`, else the enclosing one. It used to be the term itself, a plain name. Under `{"@vocab": "http://example.org/", "foo": {"@context": {"bar": {"@type": "@id"}}}}`, `bar` inside `foo` wrote the property `bar`. It now writes `http://example.org/bar`. A JSON-LD query under the same context already read `bar` through the enclosing `@vocab`, so it did not find what such an insert stored; now it does. With no vocabulary in effect, the term is still a plain name.

Data an earlier release wrote this way keeps the plain name, so a `where` pattern, a delete or an upsert under the same context no longer reaches it. Nothing reports an error.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking: the entry needs the repair recipe we asked of these fixes on #2283, and its account of old data is a bit off.

Per #2283, a data-changing JSON-LD fix carries a recipe for the data an earlier release wrote. This paragraph says "a where pattern, a delete or an upsert under the same context no longer reaches it". A where never reached it, though: the query parser applies no scoped context, so at the merge-base an update whose where uses the insert's own context matches nothing (that's the bug this fixes). What changes is the write side, and it doesn't quite "not reach".

Claude wrote a ledger at the merge-base and read it at this head. Under the same context, a query returns nothing, and a delete of {"@id": "ex:s", "foo": {"@id": "ex:n", "bar": "ex:o"}} removes ex:s foo ex:n and silently leaves ex:n bar ex:o, so it half-applies. On the same data written at this head under a context with no vocabulary, an upsert under the original context writes http://example.org/bar beside the old bar: two values for one property.

This update renames it, with no @context so bar reads as the stored plain name. Claude ran it on that ledger, and on the same data written at this head under a context with no vocabulary, where a query under the original context then finds the value:

{
  "where":  {"@id": "?n", "bar": "?o"},
  "delete": {"@id": "?n", "bar": "?o"},
  "insert": {"@id": "?n", "http://example.org/bar": "?o"}
}

So maybe something like: queries and where patterns under that context never found such data; a delete under it now leaves the plain-name statement while deleting the rest of what it names, and an upsert writes a second value beside it; rename the property once per such term, with an update like the one above.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 98e56f7

Comment thread docs/reference/compatibility.md Outdated

Data an earlier release wrote this way keeps the plain name, so a `where` pattern, a delete or an upsert under the same context no longer reaches it. Nothing reports an error.

A string in keyword form where an `@id` goes is now refused, in a transaction and in a bulk import alike: `{"@id": "@ignoreMe"}`, or `"@ignoreMe"` under a term typed `@id`. It used to be stored as the IRI `@ignoreMe`. A bulk import and `rdf::parse` also refuse a key starting with `@` inside `@reverse`, as a transaction already did; they used to write it as a predicate.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking: data already stored under a keyword-form @id needs its way out in the entry too.

A ledger an earlier release wrote with {"@id": "@alice"} (Claude wrote one at the merge-base) still answers a query that names it: {"@id": "@alice", "ex:name": "?n"} returns its name at this head. But a delete or an upsert naming @alice is now refused, and so is re-importing the ledger's own JSON-LD export, which writes "@id": "@alice".

The way out is a filter and variables. Claude ran these two on that ledger, and they move @alice's statements, and the references to it, onto ex:alice:

{"@context": {"ex": "http://example.org/"},
 "where": [{"@id": "?s", "?p": "?o"}, ["filter", "(= (str ?s) \"@alice\")"]],
 "delete": {"@id": "?s", "?p": "?o"},
 "insert": {"@id": "ex:alice", "?p": "?o"}}
{"@context": {"ex": "http://example.org/"},
 "where": [{"@id": "?x", "?p": "?s"}, ["filter", "(= (str ?s) \"@alice\")"]],
 "delete": {"@id": "?x", "?p": "?s"},
 "insert": {"@id": "?x", "?p": {"@id": "ex:alice"}}}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in e2b8d75

Comment thread fluree-graph-json-ld/src/expand.rs Outdated
(!prefix_iri.starts_with('@')).then(|| format!("{prefix_iri}{suffix}"))
}
None if !iri.starts_with('@') && !iri::any_iri(iri) => {
vocab.map(|vocab| format!("{vocab}{iri}"))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional. This is more of a question than a suggestion: should a scoped "@vocab": null stop the join? ParsedContext.vocab is None both for "no @vocab" and for an explicit null, so scoped.vocab falls back to the enclosing vocabulary, and {"@vocab": "http://ex/", "foo": {"@context": {"@vocab": null, "bar": {"@type": "@id"}}}} now writes http://ex/bar (Claude's box run; the merge-base wrote bar). That reads against the entry's "with no vocabulary in effect, the term is still a plain name", and JSON-LD makes such a term an invalid IRI mapping.

Your code didn't introduce the root of it: a scoped @vocab: null never cleared the vocabulary for keys the scoped context doesn't define either (baz beside bar is http://ex/baz at both the merge-base and this head). Recording an explicit null on ParsedContext (a flag set where parse_context_map reads @vocab), and having apply_scoped_context clear active.vocab and skip this arm when it's set, would fix both. I recognize this is minor and non-blocking, but if you agree it's right, I'd rather see it folded in now than lost in the backlog.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in c6a14ff

/// keyword form (`"@ignoreMe"`) names none: JSON-LD drops it, and Fluree
/// refuses it, as it refuses such a key on a node.
fn node_reference(s: &str, ctx: &ParsedContext, strict: bool) -> Result<String> {
if crate::is_keyword_form(s) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional. expand.rs:208-212 (type_iri): a node's @type is the one keyword-form position still outside node_reference. {"@id": "ex:s", "@type": "@ignoreMe"} still writes rdf:type <@ignoreMe> at this head (Claude's box run), and IRI Expansion's step 2, the rule this refusal answers, drops a keyword-form @type value like any other.

A class names a node too, so it seems the same refusal belongs there. type_iri only serves a node's @type (parse_type), so value-object datatypes like @json or @vector aren't on its path. Minor and non-blocking, but if you agree, I'd rather see it folded in now, with a word in the entry, than lost in the backlog.

Commenting here because type_iri (expand.rs:208) is not in this diff.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 0a3efc5

Comment thread docs/reference/compatibility.md Outdated

#### A JSON-LD scoped context's term takes the vocabulary in effect (breaking)

A term that a property- or type-scoped context defines with no `@id`, or with one that has no `:`, is now the vocabulary in effect joined to the term, as a term of the enclosing context is: the scoped context's own `@vocab`, else the enclosing one. It used to be the term itself, a plain name. Under `{"@vocab": "http://example.org/", "foo": {"@context": {"bar": {"@type": "@id"}}}}`, `bar` inside `foo` wrote the property `bar`. It now writes `http://example.org/bar`. A JSON-LD query under the same context already read `bar` through the enclosing `@vocab`, so it did not find what such an insert stored; now it does. With no vocabulary in effect, the term is still a plain name.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional. The entry talks about the term's @id, but the same resolve runs on a scoped term's @reverse and its @type datatype (expand.rs:720-727), so those change too: "bar": {"@type": "myType"} now types a value http://ex/myType (was myType), and "bar": {"@reverse": "rel"} writes the reverse property http://ex/rel (was rel), per Claude's base-vs-head run. And for {"@id": "baz"} it's the vocabulary joined to baz, not to the term. Maybe one more sentence here. Minor, but I'd rather see it in this PR than lost in the backlog.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 7f4c493. The section on earlier data also gets a retype for a datatype stored as the plain name.

Comment thread fluree-graph-json-ld/src/error.rs Outdated
#[error("Invalid IRI: {iri}")]
InvalidIri { iri: String },

#[error("JSON-LD keyword {value:?} is not supported as a node reference")]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional. This is so minor, but "@alice" isn't a keyword, and someone whose ids are handles will read "JSON-LD keyword "@alice" is not supported" as us misreading their data. Perhaps something closer to what to do about it (it_jsonld_scoped_term_vocab's refusal test matches on the current text, so it would move with it):

Suggested change
#[error("JSON-LD keyword {value:?} is not supported as a node reference")]
#[error("{value:?} has the form of a JSON-LD keyword, so it names no node; write it as an IRI (a compact IRI like \"ex:{value}\", for example)")]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in d21cd1d, without the ex:{value} example, which renders as ex:@alice.

])]
);

// A query under the same context reads `bar` through the outer

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice: this pins the read/write agreement, not just the stored IRI. Claude copied this file to the merge-base and both tests fail there. At this head, dropping the vocabulary join, or node_reference's check, turns exactly the matching test red (and the same for the unit tests and the adapter's).

…ab-keyword-keys

# Conflicts:
#	docs/reference/compatibility.md
#	fluree-graph-json-ld/src/expand.rs
A scoped context is parsed on its own, so a relative @vocab in it stayed
relative, and parsing joined its terms to it as written. Applying the scoped
context then joined those terms to the same vocabulary again: under an
enclosing "http://ex/", a scoped "@vocab": "rel/" wrote the property
rel/rel/bar.

A scoped @vocab now resolves where the context applies, by the rule a
top-level one follows: a relative one joins the enclosing vocabulary, a
compact IRI expands over the enclosing prefixes. Its terms, and keys under it
that the scoped context does not define, take the result, so the example
writes http://ex/rel/bar. A term only joins the enclosing vocabulary when the
scoped context has none of its own.
…applies

A parsed context's vocab is None both with no @vocab and with an explicit
null, so a scoped context that set "@vocab": null left the enclosing
vocabulary in effect: its terms with no @id joined it, and so did keys under
it that the scoped context did not define.

The parsed context now records the null (vocab_null, which to_json writes
back as "@vocab": null). Applying a scoped context that sets it clears the
active vocabulary, and its terms with no @id stay plain names.
…id is

"@type": "@ignoreme" on a node was stored as rdf:type <@ignoreme>, though a
class names a node and the same string as an @id is refused. The refusal now
sits in vocab_value_iri, which resolves both a node's @type and a string a
"@type": "@vocab" term coerces, so a term that maps to a keyword-form string
is refused in either place. A value object's datatype takes another path and
is unaffected.
"@alice" is not a keyword, so "JSON-LD keyword "@alice" is not supported"
read as a misreading of an id written as a handle. The refusal now says the
string has the form of a keyword, so names no node, and to write it as an
IRI.
…ame it

The entry said a where pattern, a delete or an upsert under the context no
longer reaches a plain name an earlier release wrote. A query never found it,
since a query reads the term through the enclosing @vocab; what changes is
writes. A delete under the context now removes the rest of what it names and
leaves the plain-name statement, and an upsert writes a second value beside
it.

The entry now says so and links to the section on earlier data, which gains
the rename: an update with no @context, so the key reads as the stored plain
name. A test runs it against data in the shape an earlier release stored.
An earlier release stored {"@id": "@alice"} as the IRI @alice. A query
that names it still reads it, but a JSON-LD write that names it is now
refused, so a delete, an upsert or a re-import of the ledger's own export
cannot reach it.

The entry says so and links to the section on earlier data, which gains two
updates that match the node by a filter instead of naming it: one moves its
statements to an IRI, the other the references to it. A test runs both
against data stored under @alice.
…cabulary entry

The vocabulary join a scoped term now gets runs on its @reverse and its
@type datatype too, and a relative @id joins the vocabulary to that @id, not
to the term. The entry spoke only of the term, so it now gives an example of
each.

The section on earlier data covers them as well: a property named by an @id
or @reverse renames by the same update as the term, and a datatype stored as
the plain name is retyped by a SPARQL update. Tests pin the expansion of each
and run the retype against data in the shape an earlier release stored.
@bplatz

bplatz commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

On the release line, that's your call

Keeping it on next. It now builds on #2396's @type resolution and register, and the keyword refusal is breaking, which suits 5.0.

I'd land #2396 first [...] so this rebases, drops them and refreshes the te120/te121 "kept" comment

Addressed in a15cabb: next merged in and the 16 entries removed. te120 already read "refused", and te121 fails on @ inside @reverse; the t0122/te122 notes now say @ignoreMe as an @id is refused.

The two musts are answered on their threads.

@bplatz

bplatz commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

refusing a keyword-form @id like "@alice" turns a working transaction into an error, where JSON-LD drops it with a warning [...] I'd like your confirmation it's the intended decision.

Confirmed, it's intended. Dropping the @id would turn {"@id": "@alice", "name": "Alice"} into a blank node holding the name, and each later write naming @alice would add another, with nothing reported. Storing it as written keeps a value that is not an IRI. The refusal names the value, and compatibility.md gives the way out for data already stored that way.

…goes

The keyword-form refusal for a node's @type also caught a value object
written where a node goes, such as an insert clause holding
{"@type": "@JSON", "@value": 1, "@annotation": {...}}: node expansion read
its @type as a class, and "@JSON" is in keyword form. The document was still
refused, but by an error about a class, before the check that refuses an
annotation on it.

A map holding @value keeps its @type as a datatype, so the refusal applies
only to a class and to a string a "@type": "@vocab" term coerces, and such a
map is refused as before.
@bplatz
bplatz merged commit 5c2e9d0 into next Nov 16, 2026
21 checks passed
@bplatz
bplatz deleted the fix/jsonld-scoped-vocab-keyword-keys branch November 16, 2026 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change Backwards-incompatible change; drives the Breaking Changes release-notes section bug Something isn't working as expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants