formats: JSON Schema dynamic references and the 2020-12 meta-schemas in std/json-schema (step 2b of #80) #567
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
Step 2b of the epic #80. Step 2a (#553) landed the static references;
$dynamicRef,$dynamicAnchor,$vocabularyand a$refto a meta-schema are still refused with aJsonSchemaErrorthat names them. The 2020-12 meta-schemas are written with$dynamicRef, so the dynamic scope comes first and the bundled meta-schemas second. Needed by OpenAPI (#76) and by schema validation of schemas themselves.Goal
std/json-schemaevaluates$dynamicRef/$dynamicAnchorwith the dynamic scope of 2020-12 (section 8.2.3.2 of the specification), reads$vocabularyfrom a meta-schema, and bundles the 2020-12 meta-schemas so that a$ref/$schemato them resolves without fetching.Source
std/json-schemafrom #434 and #553 (src/reference.trb,src/validate.trb,tests/suite.test.trbwith itsexclusionsandfileExclusions).Acceptance criteria
$dynamicAnchoris collected like$anchorand$dynamicRefresolves through the dynamic scope (outermost schema resource with a matching$dynamicAnchorwins; a plain$anchortarget is a static$ref), with the cycle guard of 2a applied.$vocabularyis read and kept on the model (required vs optional vocabularies); a required vocabulary the package does not know is refused with an error naming it.https://json-schema.org/draft/2020-12/...ids in every default registry;$schemaof 2020-12 and$refto them no longer error. The metaschema keywordunevaluatedis stored but not yet evaluated (step 3).dynamicRefandvocabularyare insuite-cases.trband pass; the sevenmeta-schemaexclusions of 2a (anchor,defs,idx3,refx2) are removed fromexclusions()and their cases pass. TheunevaluatedPropertiesexclusions stay (step 3), anddynamicRefcases that needunevaluated*are named exclusions with that reason.docs/standard-library/json-schema.mddocuments the dynamic scope and the bundled meta-schemas and drops them from the "later step" list.sh tools/gates.sh agreen in forge CI, docs checks andskills/regeneration done.Design record point
ROADMAP "Which versions a format supports"; ENCODING.md section 9. Decided by the loop: the meta-schemas are stored as
JsonValuetext constants in a generated or hand-embeddedsrc/metaschema.trb(vendored from the specification's published JSON, notice included) and pre-registered, so nothing is fetched; the evaluation state carries a stack of schema resources for the dynamic scope.Seed impact
None: the compiler does not import
std/json-schemaand no std name is looked up by string.Size
One PR, two Conventional Commits: (1)
feat(std/json-schema): evaluate $dynamicRef and $dynamicAnchorwith$vocabulary, thedynamicRef/vocabularysuite files and tests; (2)feat(std/json-schema): bundle the 2020-12 meta-schemaswith the removed exclusions, docs and skill regeneration.Dependencies
Needs #553 (landed). Part of #80; unblocks step 3 (
unevaluated*) and #76.[loop:torbscript] claim implement by session:loop-torbscript-20261029 until 2026-10-29T12:46Z
[loop:torbscript] checkpoint: worktree code/wt/torbscript-language-567, branch loop/567-dynamic-ref (nothing pushed yet). Read the package and the suite files; design: scope stack of resource keys on Frame, dynamicAnchors in Index, meta-schemas parsed lazily per validate (only when a reference names them), $vocabulary restricts the root $schema keyword sets. Next: code, local VM test of one file, push, PR, CI.
[loop:torbscript] checkpoint: PR #574 open (2 commits), review requested from argus, waiting for CI.
[loop:torbscript] release implement: worker session ended after 1 h with PR #574 open (review requested from argus), next: waiting (forge CI and merge gate on #574)
[loop:torbscript] claim fix by session:loop-torbscript-20261029 until 2026-10-29T14:25Z
[loop:torbscript] review: forge CI of
fd671bd0was red intier A (linux-x64)only on three docs gates (docs check,docs index --check,docs declarations --check): thestd/json-schemasummary was 289 characters (limit 240), the standard-library index did not carry the new summary, and theJsonSchemadeclaration block lackeddynamicAnchor,dynamicReferenceandvocabulary. Fixed in4c5f052f(docs(std/json-schema): shorten the summary, regenerate the index and declarations, docs and skills copies, normal push, no rebase needed, check-commits clean). Forge CI on4c5f052fis queued behind a congested runner pool (16 jobs pending after ~85 min, none started yet), next: waiting (forge CI and merge gate); review from argus is requested once CI is green. Worker usage: about 90k tokens (sonnet).[loop:torbscript] claim fix by session:loop-torbscript-20261029 until 2026-10-29T17:26Z
std/json-schema(step 3 of #80) #690