Skip to content

Commit a2d34a5

Browse files
dmealingclaude
andcommitted
feat(verify): output-tag preservation (@requiredTags) + render maxChars budget [FR-004]
First slice of the prompt-pillar verify extensions. Adds a cross-language, conformance-gated static check that a template's text (body + provider-resolved partials) contains each declared output tag as both an opening `<tag` (prefix, attributes allowed) and a closing `</tag>`. A miss yields the new stable code ERR_OUTPUT_TAG_MISSING (path = tag name). Reference-first: TS defines behavior via the shared fixtures/verify-conformance corpus; C# and Python match it. Contract decisions, pinned in fixtures: - open tag = `<tag` followed by `>` or XML whitespace (space/tab/CR/LF) — so `<answer foo="1">` counts but `<answers>` does not over-match `answer`; - close tag = exact literal `</tag>`; self-closing `<tag/>` never satisfies; - tag text is sourced from the body + partials resolved during the single existing verify walk (no double resolution). Also: render() gains an optional maxChars budget (runtime-only throw; rendered length is data-dependent, so NOT conformance-scoped). @maxtokens stays out of scope. New @requiredTags template attr (string[]) on template.prompt AND template.output, wired through `meta verify` (TS + C#). Java deferred (no verify tier yet). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 73b9f3a commit a2d34a5

50 files changed

Lines changed: 636 additions & 34 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

fixtures/conformance/ERROR-CODES.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"ERR_VAR_NOT_ON_PAYLOAD": "Build-time verify: a template variable references a field the (contextual) payload view-object does not declare.",
2626
"ERR_PARTIAL_UNRESOLVED": "Build-time verify: a template partial ({{> group/source}}) does not resolve in the configured provider.",
2727
"ERR_REQUIRED_SLOT_UNUSED": "Build-time verify (warning): a template's declared @requiredSlots slot is never referenced by the template text.",
28+
"ERR_OUTPUT_TAG_MISSING": "Build-time verify: a template declares @requiredTags but its text (including provider-resolved partials) omits a required output tag's opening (<tag) or closing (</tag>) form. path = the tag name.",
2829
"ERR_BAD_ATTR_FILTER": "A dataGrid @filter references a non-filterable field or uses an op disallowed for the field's subtype.",
2930
"ERR_STORAGE_FLATTENED_ARRAY": "@storage \"flattened\" cannot be combined with isArray=true.",
3031
"ERR_STORAGE_WITHOUT_OBJECT_REF": "@storage was set on a field that has no @objectRef.",
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{ "requiredTags": ["answer"] }
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<answer>{{content}}</answer>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[
2+
{ "name": "content" }
3+
]
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Please respond.
2+
{{> partials/answer}}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[
2+
{ "code": "ERR_OUTPUT_TAG_MISSING", "path": "answer" }
3+
]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{ "requiredTags": ["answer"] }
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[
2+
{ "name": "content" }
3+
]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<answer>{{content}}

0 commit comments

Comments
 (0)