Skip to content

feat(templates): add example inputs, render-all validation, and template render -d - #56

Merged
ghchinoy merged 1 commit into
GoogleCloudPlatform:mainfrom
ghchinoy:feat/template-examples-render-all
Nov 9, 2026
Merged

ghchinoy merged 1 commit into
GoogleCloudPlatform:mainfrom
ghchinoy:feat/template-examples-render-all

Conversation

@ghchinoy

@ghchinoy ghchinoy commented Nov 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds synthetic example inputs and end-to-end schema validation across all 43 shipped .json.tmpl policy templates, fixes dgem template render -d, and aligns the gateway template catalog (GET /api/templates):

  1. Per-template example suites (templates/**/*.examples.json) & minimal-input defaults:
    • Adds companion <name>.examples.json files (typical, edge, and minimal synthetic inputs, plus unambiguous expected_answers where deterministic) for every templates/**/*.json.tmpl policy.
    • Adds non-empty minimal fallbacks to parameterized templates (intent_banking77, intent_clinc150, intent_tiebreak, tn_disambiguation, jevbench_generic) so rendering with {} produces a valid schema without changing behavior when caller options/levels are supplied.
  2. Render-all & schema contract validator (pkg/template/examples.go, pkg/template/examples_test.go):
    • Implements LoadExamplesFile, SampleVarsFromExamples, CoerceJSONVariableStrings, and ValidateRenderedPayload checking ParseStructuredPayload, valid JSON schema/state objects, unique non-empty question IDs, non-empty instructions, valid question types, <= 26 choice options (unless labels is az_aa/az_lower or allow_wide_choices is set), acyclic depends_on/ask_if references, and expected_answers domain membership.
    • TestAllShippedTemplatesRenderAndValidate walks templates/ and validates every .json.tmpl across typical, edge, minimal, and stringified sample_vars round-trips.
  3. CLI & gateway template catalog fixes (cmd/template.go, cmd/serve.go):
    • Wires -d / --data in dgem template render (with -v overrides on top) and adds cmd/template_render_test.go.
    • Fixes extractTemplateVars in cmd/serve.go to ignore string literals with escaped quotes and $-prefixed range variables, honors multimodal overrides from .examples.json (multimodal/call_quality_audio -> false), populates examples and sample_vars on GET /api/templates, fills defaultSampleVars gaps, and coerces JSON-array strings in POST /api/decide.

Verification

  • go build -o bin/dgem . && go vet ./... && env -u DGEM_VERTEX_URL go test ./...
  • go -C examples vet ./... && go -C examples test ./...
  • python3 -m unittest scripts/matrix/test_matrix.py
  • python3 scripts/docs_sync_check.py && python3 scripts/docs_link_check.py

Closes #55

@ghchinoy
ghchinoy merged commit 73af58c into GoogleCloudPlatform:main Nov 9, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(templates): add per-template example inputs, render-all validation test, and template render -d

1 participant