Repository navigation
Description
Summary
Make metadata validation data, not per-port code: declare each check as data on the type's registration, and give each port one generic interpreter per rule-shape. A rule is then authored once (not re-coded in TS/Java/C#/Python/Kotlin), and a downstream provider's new type validates itself with zero new validation code in any port.
Design doc: docs/superpowers/specs/2026-06-21-config-driven-validation-design.md.
Sibling to #23 (FR-033, "Provider definitions as declarative data") — same philosophy; if provider definitions become declarative data, validation rules are just more fields in that data.
Why
Validation today is split across three mechanisms, inconsistently:
- Reference descriptors (
objectRef/references) — declarative data, but constructed in code per port (same rule written 5×). - ~20 free-floating imperative passes — hand-coded per port.
- A
validatehook on the TypeDefinition — invoked in all ports but registered by no core type (an extension point core doesn't use itself).
Net: every rule is implemented N=5 times, and a downstream provider must write validators in every language it targets — contrary to the metadata-is-the-spine thesis and ADR-0023 (providers add types via registered data).
The four closed rule-shapes
| Shape | Covers today |
|---|---|
reference |
objectRef, references, payloadRef/responseRef existence |
allowedValues |
@format, @kind, @promptStyle (closed sets) |
requires |
email needs subjectRef+htmlBodyRef; document needs textRef |
fieldPathRef |
requiredSlots are fields on the payloadRef target |
These cover the entire current reference + template corpus. Anything that fits no shape falls back to the validate hook (rare escape hatch). No speculative shapes — a fifth requires a real rule + the ADR-0023 can't-be-computed justification.
Phasing (earn it; conformance-gated; behavior-neutral)
- Phase 0 — cleanup: align all ports' reference validation (revert the TS payloadRef descriptor split).
done,— that commit never reached599a4aedmain(see Status correction below). - Phase 1 — proof slice: move the
referenceshape from per-port code into shared JSON; one generic interpreter per port; conformance unchanged. De-risks "is config-driven byte-identical across 5 ports" before extending. - Phase 2 —
allowedValues(format/kind/promptStyle). - Phase 3 —
requires+fieldPathRef; delete the bespoke template pass in all ports. - Phase 4 — opportunistically migrate remaining datafiable passes; keep the
validatehook for the rest.
Risks
- 4 interpreters × 5 ports (bounded, fixed-size — not proportional to type count).
- FR5d resolved-source envelope fidelity (template fixtures gate it).
- ADR-0023 strict provenance: rule data is provider data; spec readers must tolerate the new
reference/rulesfields (guard first).
Open questions
rulesinline-on-type vs a siblingvalidationblock (lean inline for locality).- Does FR-033 — Provider definitions as declarative data + metamodel docs for LLMs #23 subsume the "data in JSON, reader lowers it" mechanism? Coordinate.
- Kotlin (shared JVM metadata) likely gets the interpreters for free — confirm in Phase 1.
Status correction (2026-08-24) — Phase 0 was checked off but never landed
Found while sweeping for unfinished work after a session ended abruptly. The commit this issue
credits Phase 0 to, 599a4aed, is not on main — it lived only on an unmerged local branch,
proto/validation-registry (20 commits, 2026-06-21). The design doc landed; the code did not. The
checkbox has been cleared so the next person does not start from a false baseline.
The prototype is preserved at archive/validation-registry-proto (e19937c3a) — an
archive ref, not a merge candidate. It is worth reading before starting Phase 1: it already carried
the registry-derived mechanism through all five ports, which is exactly the risk Phase 1 exists
to de-risk ("is config-driven byte-identical across 5 ports").
What has landed independently since
- Reference enforcement —
ERR_INVALID_REFERENCE,ERR_UNRESOLVED_OBJECT_REF,
ERR_OBJECT_FIELD_WITHOUT_OBJECT_REF,ERR_STORAGE_WITHOUT_OBJECT_REFare all onmain, so the
branch's08c090edis superseded by a different implementation. - The FR-024 friction fixes the branch carried alongside the prototype —
validate-max-occurs.ts,
the singleton identity default-name, and theerror-identity-name-requiredfixture — are all on
mainin their own form.
What is still open
- The
#51core. Onmain,rules?: stringonTypeDefinitionis a prose documentation
field — precisely the thing this issue proposes replacing with executable data. The mechanism has
not landed in any port. - Java collect-all — "a load reports every error, not the first" (
1e512ea1,1fab2c98). This is
separable from the config-driven mechanism and independently valuable; it could ship on its own.
Do not try to rebase the archive branch
Measured: it conflicts on commit 1 of 20, nine files, including an add/add on
validate-max-occurs.ts because main now owns its own copy. Roughly two months and ~2000 commits
sit in between — ADR-0040/0044/0050/0051, FR-036, FR-038, the ADR-0052/0053 template-direction split,
and 0.24.0's five vocabulary retirements all moved the surfaces the prototype patches. Phase 1 should
be written fresh against current main, using the archive as a reference for the shape that worked.
Activity
feat(validation): metadata reference enforcement + validation on the …
docs(validation): document the NodeValidator hook as an intentional e…
dmealing commentedon Jun 21, 2026
Phase 1 implementation map (parked — for whenever this is picked up)
Survey of the FR-033 spec-reader pipeline + current reference-validation sites, so Phase 1 (move the
referenceshape into shared JSON) can start without re-deriving.Key architectural finding — two reader shapes: only TS lowers the full attr schema from
spec/metamodel/*.json(provider-data.tstoAttrSchema). Java/C#/Python readers are doc/extends overlay only — they do NOT build the attr schema from JSON (it's hand-coded), so Phase 1 must add a new "applyreferencerules from spec" path in those three, not just extend an existing lowering. Kotlin inherits the Java module for free (resolves the issue's open question). Also: there is noReferenceDescriptortype yet — today the reference rule is hand-registered attrs + imperative passes; Phase 1 introduces the descriptor as JSON data + one generic interpreter per port.No tolerance guard needed — every reader (
.get()/TryGetProperty/Gson) already silently ignores unknown attr keys;allowedValuesis the live optional-field precedent. The issue's "guard first" risk is satisfied structurally.(a) Add the
referenceblock as a sibling key on the attr object (likeallowedValues):spec/metamodel/relationship.json—@objectRefrepeated on base/association/aggregation/compositionspec/metamodel/identity.json— subtypereference,@references(line ~28)spec/metamodel/field.json—field.object@objectRef(decide if in scope or stays a field-object pass)(b) Reader hook points: TS
provider-data.tstoAttrSchema(~410-432, after theallowedValuesspread) + regen embedded viascripts/generate-embedded-metamodel.ts. JavaSpecMetamodelReader.parseAttrChildren(~273-294) + new apply path byMetaDataRegistry.applySpecDescriptions(JSON auto-copied to classpath via maven-resources). C#SpecMetamodelReader.ParseAttrChildren(~322-368) + manualcptoserver/csharp/MetaObjects/SpecMetamodel/. Pythonspec_metamodel/__init__.py._parse_attr_children(~228-253) + manualcp.(c) Hand-construction to remove: Java
MetaRelationship.registerTypes/ReferenceIdentity+ concrete subtypes; C#RelationshipSchema/IdentitySchema(ReferenceIdentityAttrs); Pythoncore_types.py_RELATIONSHIP_ATTRS/identity.reference; TS imperative passes invalidation-passes.ts(objectRef ~494-507, M:N ~1169-1250).(d) Gates:
fixtures/registry-conformance/expected-registry.json, byte-identical 5 ports) — DECISION POINT: the manifest emitter projects onlyname/valueType/isArray/required/description/rules?/...; it'll drop a newreferenceblock unless extended. Either don't surfacereferencein the manifest (truly behavior-neutral) OR surface + regenerate the canonical in lockstep (TS-advances-first per the README).IdentityReferenceTests, JavaMetaRelationshipTest/Fr5dReferenceResolutionTest, Pythontest_fr5d_reference_resolution, + FR5d resolved-envelope shape, + M:N + persistence/api-contract corpora.Recommendation when resumed: keep
referenceOUT of the registry manifest for Phase 1 (so it stays byte-neutral), prove the JSON-driven interpreter cross-port, then decide on manifest surfacing in a later phase.