ADR-0020: Validation in Code¶
Note
The shell checks a parsed TDL file in its own schema package, in code, as it builds the typed tree. It does not run the jsonschema library at run time. If editor tools want JSON Schema files later, the shell emits them as plain JSON from the same declarations, with no validator library. Accepted by the maintainer in chat on 2026-11-03 ("Lets go with your recommendation").
Context¶
ADR-0011 JSON Schema for Shell Files (accepted 2026-10-27, for YAML) had the shell validate each file against JSON Schema files generated from the block and module declarations, using jsonschema at load and on hot reload. The shell's files are now TDL (ADR-0014 Shell File Language), and:
- the editor use of the schemas was dropped (no language server in v1, D12), so run-time validation was the schemas' only use;
- the
schemapackage has to check keys and types in code anyway, to build the typed tree for the binder, reportfile:line:column, and suggest the nearest key names (M1 Brief, T5); - a 2026-10-27 spike found that
jsonschemareports a choice between branches (oneOf) as one vague error andbest_matchpicked an unrelated one, so the schema had to be hand-shaped around the library, and it gives paths, not positions; jsonschemabringsattrs,referencing,jsonschema-specificationsand the compiledrpds-py, and about 43 ms of import time, which the shell worked around with a lazy import and a cache (JSON Schema and Editor Support > ThejsonschemaDependency: Runtime, Not Only Development);- ADR-0019 Dependency Policy asks for a library only where building the same would be a project of its own, and these checks are not.
The maintainer asked whether there is any reason for jsonschema to run at run time; none was found.
Options¶
Option A — Validate in Code; Emit JSON Schema Later as Plain JSON (Chosen)¶
- For: one pass builds the typed tree and the errors with their positions; messages are ours; four fewer packages and no compiled one; no 43 ms import; no cache; module
Paramsbecome validators built from the module's declarations. - Against: we write and test the checks (they are table-driven, and the declarations are the same ones the Block Reference test compares).
Option B — Keep jsonschema at Run Time (ADR-0011 as it stood)¶
- Against: the costs above, for a use that code does anyway.
Decision¶
Accepted 2026-11-03 by the maintainer in chat: Option A.
Consequences¶
- Shell Package Layout drops
jsonschema. Thetesserae-shell schemacommand, if wanted, writes JSON Schema as plain JSON from the declarations; it needs no validator library. - The
Validation.Enabledsetting stays. The validation cache is no longer needed: in-code checks take microseconds to milliseconds (Settings File). A cache returns only if a measurement shows a need. - ADR-0011 JSON Schema for Shell Files carries a dated update: run-time validation by
jsonschemais replaced by this ADR; the other parts (schemas generated from declarations, if produced) stand. - Validation and Errors stage 4 is "the
schemapackage checks in code". The error record, positions and nearest-name hints are unchanged. - Risk Register R-13 no longer lists
jsonschema. - The code session writes the checks as part of M1 T5; the tests compare the declarations with Block Reference.