You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#44 (ADR 0006) was the first code in the repo to serialize a frame from the reference contextgraph-types type and validate that JSON against schema/contextgraph-envelope.schema.json. It immediately failed: the schema listed provenance and relations as globally required on a ContextFrame, but the reference serializer omits both when empty (#[serde(skip_serializing_if = "Vec::is_empty")]), and no frame-validity check (SPEC §6, F1–F5) requires either. A frame with no graph edges — every ingest frame — was therefore un-representable in conformant JSON.
Fixed in #44 for the frame (required is now exactly what the serializer always emits: id, kind, title, score, token_cost). But the class of bug is unaddressed: the schema's required lists were never checked against the reference serializer's actual output, because schema validation only ran over hand-authored example transcripts (schema/validate-examples.py over examples/*), never over Rust-serialized values.
The systemic fix
Audit every $defs.*.required in the schema against its Rust type. Any field that is skip_serializing_if = "Vec::is_empty" / Option::is_none and is required by no conformance check must not be globally required. Candidates to check: ContextQueryResult, Provenance, ContentRef, Capabilities, DataFlow, VerifyResponse, the envelope variants.
Add a serialize-and-validate conformance test that constructs a reference value of each wire envelope/type — including the minimal form (empty vecs, None options) — serializes it, and validates against the schema. This catches the whole class going forward, not just the frame. The lightweight required-key guard added in contextgraph-conformance/tests/ingest_conformance.rs is the seed; generalize it (ideally with real JSON-Schema validation, mirroring validate-examples.py, so type/pattern/allOf are covered too, not just required-keys).
This is squarely "conformance that actually catches things" (#33): the schema, the examples, and the reference types describe one wire — a test should prove they agree on serialized reference output, not only on curated fixtures. Related: #48 (extensibility/unknown-field rules), #2 (CI schema validation).
What surfaced this
#44 (ADR 0006) was the first code in the repo to serialize a frame from the reference
contextgraph-typestype and validate that JSON againstschema/contextgraph-envelope.schema.json. It immediately failed: the schema listedprovenanceandrelationsas globallyrequiredon aContextFrame, but the reference serializer omits both when empty (#[serde(skip_serializing_if = "Vec::is_empty")]), and no frame-validity check (SPEC §6, F1–F5) requires either. A frame with no graph edges — every ingest frame — was therefore un-representable in conformant JSON.Fixed in #44 for the frame (
requiredis now exactly what the serializer always emits:id,kind,title,score,token_cost). But the class of bug is unaddressed: the schema'srequiredlists were never checked against the reference serializer's actual output, because schema validation only ran over hand-authored example transcripts (schema/validate-examples.pyoverexamples/*), never over Rust-serialized values.The systemic fix
$defs.*.requiredin the schema against its Rust type. Any field that isskip_serializing_if = "Vec::is_empty"/Option::is_noneand is required by no conformance check must not be globallyrequired. Candidates to check:ContextQueryResult,Provenance,ContentRef,Capabilities,DataFlow,VerifyResponse, the envelope variants.Noneoptions) — serializes it, and validates against the schema. This catches the whole class going forward, not just the frame. The lightweight required-key guard added incontextgraph-conformance/tests/ingest_conformance.rsis the seed; generalize it (ideally with real JSON-Schema validation, mirroringvalidate-examples.py, sotype/pattern/allOfare covered too, not just required-keys).This is squarely "conformance that actually catches things" (#33): the schema, the examples, and the reference types describe one wire — a test should prove they agree on serialized reference output, not only on curated fixtures. Related: #48 (extensibility/unknown-field rules), #2 (CI schema validation).