Resolve remote JSON-LD contexts from project RDF
Why
Project data can reference remote JSON-LD contexts, but sparqld currently supports only bundled and project-local contexts. Let an explicit project pipeline supply downloaded bodies, then describe their locations in RDF.
Prerequisite: structured missing-context errors in the RDF file catalog. That is separate, planned work.
What
Recognize ordinary project RDF declaring a context URI as jsonld:Context with a schema:contentUrl pointing to its local body:
"@context":
- https://json-ld.org/contexts/dollar-convenience.jsonld
- jsonld: http://www.w3.org/ns/json-ld#
contentUrl:
"@id": https://schema.org/contentUrl
"@type": "@id"
$id: https://example.org/context
$type: jsonld:Context
contentUrl: ./example-body.jsonld
- Query the existing RDF graph directly when the JSON-LD loader requests a context. Do not introduce a separate URI-to-file index.
- Allow declarations anywhere among included project sources. Give
.contexts/no special meaning. - Support arbitrary absolute context URIs, including HTTP, IPFS, IPNS, DID, and NI identifiers.
- Use
contentUrlas the sole new body mechanism. Support JSON bodies in.jsonand.jsonld, and YAML-LD bodies in.yamlld. - Resolve relative file references using the declaration document’s existing base rules. Keep referenced files inside the served project, including through symlinks.
- Preserve the requested context URI as the loaded body’s logical document URL. Resolve nested context references against that URI, then use the same RDF lookup.
- Preserve existing bundled dollar-context and direct local-context support.
Loading and reloads
- Parse currently resolvable sources into RDF.
- Use the structured RDF errors to identify sources blocked by missing context registrations.
- Retry them as new declarations become available.
- Stop when all sources finish or a round makes no progress. Keep unresolved dependencies visible in the error catalog.
Let the existing JSON-LD processor handle context arrays, scoped contexts, @import, and recursion limits.
Preserve incremental reloads. Track dependencies on body files and all sources contributing registration triples. Resolve against staged contributions plus unaffected published RDF, excluding replaced sources’ old graphs. Propagate changes and deletions transitively.
Identical declarations may coexist. Different targets for one context URI must fail startup or reject a reload batch before publication. Preserve existing per-source handling for ordinary parsing failures.
Acceptance
- Load a source that sorts before its declaration, including declaration chains.
- Resolve nested contexts using their remote logical base rather than the local body directory.
- Cover arbitrary URI schemes, JSON/YAML bodies, and bodies excluded from ordinary RDF ingestion.
- Report missing registrations, bootstrap cycles, malformed bodies, ambiguous targets, and path escapes.
- Recover after adding or repairing a declaration or body.
- Reload consumers after declaration/body edits or deletions; preserve unrelated sources.
- Test declaration triples split across source graphs and identical declarations in several sources.
- Keep existing bundled and local context tests passing.
- Document runnable YAML-LD examples from dedicated files and verify their rendered documentation through Playwright.
Downloading and updating artifacts remain explicit pipeline operations, for example through Make, DVC, or Vitrify.