Repository navigation
feat: reference sources and the template gate's @responseRef reply check, all six ports - #648
Merged
Merged
Conversation
A prompt's reply type owned by another generator run could not be used: the reply types loaded in a separate tree so @responseRef did not resolve, merging them in generated every reply type a second time, and the template gate never read @responseRef. - A `sources` entry may carry `"reference": true` (Maven: `<loader><referenceSources>`). Its files load into the same tree, so every reference resolves; a node declared only there is a reference node and no generator emits it. A local prompt's parser, fragment and extractor still emit and name the reply type as usual. A template declared only in a reference source is refused (ERR_REFERENCE_SOURCE_TEMPLATE). - The template gate reports ERR_RESPONSE_UNRESOLVED (error) for a reply with no readable field and ERR_RESPONSE_TAG_UNDECLARED (warning) for an xml prompt's @requiredTags tag the reply type does not declare. TypeScript (reference), Java, Kotlin, C#, Python and Rust (loader, config and codegen selection; Rust ships no template gate). New corpora fixtures/reference-source-conformance/ and fixtures/response-verify-conformance/, plus two source-resolution cases.
…lify fixes - Rust gains `verify --templates` (and runs it in a bare `verify`): the engine-level Mustache verify (all 45 verify-conformance cases), the CLI gate over every template body, and the @responseRef reply check (response-verify-conformance, 7 cases). - Java: a pom <referenceSources> is kept when the pom names no ordinary sources; the reference-only template refusal runs inside the load, so every Java entry point refuses it; the neutral collection resolves once per run. - TS: name reference sources, not `scope`, when they leave nothing to generate. - Python counts checked templates the way TypeScript does. - Docs: a reference source is a codegen setting; the node stays in the expected schema and the requirement ledger. - Rust reuses its shared constants and helpers, computes the reference set once at load, and probes each template body once.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Changed
sourcesentry may carry"reference": true(Maven:<loader><referenceSources>); its files load into the same root so@responseRefand other references resolve, and a top-level node declared only in reference files becomes a reference node that no generator emits — excluded at the codegen selection choke point in TypeScript, C#, Java/Kotlin and Python, while a local prompt keeps its parser, output-format fragment and extractor. Atemplate.*declared only in reference sources is refused withERR_REFERENCE_SOURCE_TEMPLATE(at load time in Java). Pinned by the newfixtures/reference-source-conformance/corpus (6 cases) plus 2 newsource-resolution-conformancecases (now 30).@responseRef(all ports):ERR_RESPONSE_UNRESOLVED(error) when a responding prompt's reply type resolves to no value shape with a readable field, andERR_RESPONSE_TAG_UNDECLARED(warning) when an xml prompt's@requiredTagsentry names neither the reply type's short name nor any field in its tree; attributes are read through the resolving accessors (ADR-0039). Pinned by the newfixtures/response-verify-conformance/corpus (7 cases).cargo meta verify --templatesnow exists — a Mustache body verify inmetaobjects-render(verifymodule, held to all 45verify-conformancecases), bodies underprompts/(--prompts <dir>), a bareverifyrunning the codegen, template and rules gates, and a Jinja body refused withERR_TEMPLATE_ENGINE_UNSUPPORTED; ADR-0065 Amendment 6 records it. Docs updated to 48 shared corpora (AGENTS.md,docs/CONFORMANCE.md, showcase payload), and the three changelog entries live inchangelog.d/fragments.Validation
Risk Assessment
verifythat now fails on a template project with no prompts directory), and I did not run any tests.Testing
Broad regression came from the configured command
scripts/ci-local.sh --affected --strict-toolchains, which ran green at the target commit; this turn changed no source or test files, so it was not re-run. On top of that I drove three scenarios against the real products: the TypeScriptmeta gen/meta verify --templatesCLI (dist build) and the Rustcargo-metabinary, each in a disposable fixture project under a temporary.mo-scenario/directory in the worktree (deleted afterwards; worktree clean). The reference-source scenario reproduced the adopter's measured blocker first (load refusal ERR_INVALID_TEMPLATE without the flag), then showed the fix end-to-end: @responseRef resolves, the reply types emit no code, and the local prompt's parser still names them; the ERR_REFERENCE_SOURCE_TEMPLATE guard refused a prompt declared only in a reference source. The TS and Rust verify runs confirmed the reply gate's error/warning severities and, in Rust, the new gate itself plus the Jinja refusal and a bare verify running the gate. All passed. No UI surface exists in this change, so evidence is CLI transcripts (4 log files in the evidence directory). Nothing was left running.reference: truesource: the prompt's @responseRef resolves against the reply types another run owns, no code is emitted for those reference nodes, the local prompt s…Evidence: S1 — meta gen reference sources: control refusal, reference happy path (parser names reply type, no reference-node files), ERR_REFERENCE_SOURCE_TEMPLATE guard
meta: failed to load metadata: ERR_INVALID_TEMPLATE: template "SupportAnswerPrompt" @responseRef "acme::support::SupportAnswer" does not resolve … generated/SupportAnswerPrompt.response.ts generated/SupportRequest.ts import type { SupportAnswer } from "./SupportAnswer.js"; meta: failed to load metadata: ERR_REFERENCE_SOURCE_TEMPLATE: template "acme::support::SupportAnswerPrompt" is declared only in a reference source …Evidence: S2 — meta verify --templates reply gate (TS): clean / ERR_RESPONSE_UNRESOLVED error / ERR_RESPONSE_TAG_UNDECLARED warnings
meta: [SupportAnswerPrompt] (reply) ERR_RESPONSE_UNRESOLVED: acme::support::EmptyAnswer meta: meta verify — 1 drift error(s) across 1 template(s). meta: [SupportAnswerPrompt] (reply) ERR_RESPONSE_TAG_UNDECLARED: answer meta: [SupportAnswerPrompt] (reply) ERR_RESPONSE_TAG_UNDECLARED: confidence meta: meta verify — 1 template(s) clean (2 warning(s)).Evidence: S2 clean rerun — xml reply with tags naming the reply and nested source.url, exit 0
Evidence: S3 — Rust cargo-meta verify --templates: clean, Jinja refusal, ERR_RESPONSE_UNRESOLVED, bare verify runs the gate
cargo meta verify — 1 template(s) clean. error: [AnswerPrompt] (prompt) ERR_TEMPLATE_ENGINE_UNSUPPORTED: support/answer is a Jinja template; the Rust port checks Mustache only error: [AnswerPrompt] (reply) ERR_RESPONSE_UNRESOLVED: acme::support::EmptyAnswerPipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
server/python/src/metaobjects/cli.py:612- Python_load_collection_result: the newreference_nodesassignment had been inserted between the ADR-0058 naming comment andresult.root.naming, so that comment described the wrong lines. Moved the reference block above the comment and gave it its own one-line comment. No behaviour change.✅ **Test** - passed
✅ No issues found.
reference: truesource: the prompt's @responseRef resolves against the reply types another run owns, no code is emitted for those reference nodes, the local prompt s…scripts/ci-local.sh --affected --strict-toolchainsscripts/ci-local.sh --affected --strict-toolchains— configured broad regression, already ran green at the target commit (baseline); no re-run needed since this turn changed no filesScenario 1 (live):bun server/typescript/packages/cli/dist/bin/meta.js genin a disposable fixture — control withoutreference: truerefused with ERR_INVALID_TEMPLATE; with{ "path": "metaobjects/replies", "reference": true }gen wrote onlySupportRequest.ts+SupportAnswerPrompt.response.ts(parser imports./SupportAnswer.js, the file the owning run generates); guard run with the prompt declared only in the reference source refused with ERR_REFERENCE_SOURCE_TEMPLATEScenario 2 (live):bun …/dist/bin/meta.js verify --templatesin a disposable fixture — clean xml reply with tags naming the reply and nestedsource.urlexits 0 clean;@responseRefpointed at a fieldlessEmptyAnswerexits 1 with[SupportAnswerPrompt] (reply) ERR_RESPONSE_UNRESOLVED;@requiredTagsnaminganswer/confidenceprints bothERR_RESPONSE_TAG_UNDECLAREDwarnings and exits 0Scenario 3 (live):server/rust/target/debug/cargo-meta meta verify --templatesin a disposable fixture — clean Mustache prompt with @responseRef exits 0Scenario 3 adversarial (live): a.jinjabody refused with ERR_TEMPLATE_ENGINE_UNSUPPORTED (exit 1);@responseRefat a fieldless reply type reports[AnswerPrompt] (reply) ERR_RESPONSE_UNRESOLVED(exit 1); barecargo-meta meta verifyruns the template gate beside the codegen gate (cargo meta verify — 1 template(s) clean.alongside the codegen-drift errors of a never-generated fixture)cargo build -p metaobjects-cliinserver/rust— rebuilt the CLI binary before driving it (finished, incremental, warm from the baseline run)🔧 **Document** - 1 issue found → auto-fixed ✅
docs/features/migrations-and-drift.md:767- Out-of-scope follow-up: the per-port verify table in migrations-and-drift.md ("Drift verify commands per port") and the "Port status (staged per ADR-0021)" paragraph in docs/features/cli.md enumerate the ports' verify gates but omit Rust entirely, and the migrations-and-drift.md prose claims a bare verify runs "the same default gate set in every port" including the requirement ledger — Rust has no requirement gate (docs/ports/rust.md says so). This incompleteness predates the branch, but the branch gave Rustverify --templates, making the two stale-by-omission spots more visible. Adding a Rust row to the table and qualifying the "every port" sentence is a small follow-up I left undone to avoid expanding unrelated sections.🔧 Fix applied.
✅ Re-checked - no issues remain.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.
Validation: one no-mistakes run (review, test, document, lint), with one Document-step fix: Rust was added to the per-port verify docs.