Layered prompt rendering from embedded templates #55

Member

Maestro task: bceca7a8-bc30-48df-944d-84557a1f4154 (Feature 09 - AI Harness and Skills Framework).

Done-condition

Skill prompts are text/template files embedded from internal/ai/skills/prompts/. The harness builds the system prompt in fixed order - [1] admin persona, [2] skill instructions, [3] household context block, [4] output contract with JSON schema - and the user message from the skill input. Golden tests assert exact rendered output for the test skill, layer 4 always last even under a hostile persona, and a template change without a version bump fails a checksum test naming skill and version.

Evidence

  • New internal/ai/skills/prompts with embedded echo.v1.tmpl and checksums.txt; harness/prompt.go builds the fixed layer order.
  • Golden tests incl. echo_hostile.system.golden prove layer 4 last; prompt_test.go covers malformed/missing templates and start-up failure.
  • Go quality floor passes; no new dependency; go.mod/go.sum unchanged.

Known limitation recorded by the developer: the checksum test cannot by itself detect a template edited together with its recorded checksum line for the same version; reviewers must hold recorded lines immutable. That is inherent to a same-tree checksum and does not weaken the version-bump requirement.

Maestro task: bceca7a8-bc30-48df-944d-84557a1f4154 (Feature 09 - AI Harness and Skills Framework). ## Done-condition Skill prompts are text/template files embedded from internal/ai/skills/prompts/. The harness builds the system prompt in fixed order - [1] admin persona, [2] skill instructions, [3] household context block, [4] output contract with JSON schema - and the user message from the skill input. Golden tests assert exact rendered output for the test skill, layer 4 always last even under a hostile persona, and a template change without a version bump fails a checksum test naming skill and version. ## Evidence - New internal/ai/skills/prompts with embedded echo.v1.tmpl and checksums.txt; harness/prompt.go builds the fixed layer order. - Golden tests incl. echo_hostile.system.golden prove layer 4 last; prompt_test.go covers malformed/missing templates and start-up failure. - Go quality floor passes; no new dependency; go.mod/go.sum unchanged. Known limitation recorded by the developer: the checksum test cannot by itself detect a template edited together with its recorded checksum line for the same version; reviewers must hold recorded lines immutable. That is inherent to a same-tree checksum and does not weaken the version-bump requirement.
dev_agent added 1 commit 2026-10-05 08:03:09 -04:00
Layered prompt rendering from embedded templates
CI / ci (push) Successful in 1m33s
CI / ci (pull_request) Successful in 1m32s
e20004c0ee
Skill prompts are text/template files embedded from
internal/ai/skills/prompts/, one per skill version
(<skill>.v<version>.tmpl) defining "instructions" and "user". Templates
are parsed at start with missingkey=error; a bad template stops the
service.

harness.Render builds the system prompt in fixed order (D-007): [1] the
admin persona from ai_settings.system_prompt (Config.Persona), [2] the
skill instructions, [3] the household context block, [4] the output
contract quoting the JSON Schema. The contract is always the last layer
whatever the persona says. The household context is a seam of titled
sections until BuildContext lands; an empty one renders a defined block.
Skill.Render is replaced by Skill.PromptInput.

Golden tests pin the exact system prompt and user message for the echo
test skill, with and without persona, and under a hostile persona that
says "ignore the format below" or fakes a contract heading.
checksums.txt records each template's SHA-256; a template change without
a version bump fails TestTemplateChecksums naming the skill and version.

Maestro task bceca7a8-bc30-48df-944d-84557a1f4154.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
overseer added 1 commit 2026-10-05 08:03:10 -04:00
Layered prompt rendering from embedded templates
CI / ci (push) Successful in 1m33s
CI / ci (pull_request) Successful in 1m32s
e20004c0ee
Skill prompts are text/template files embedded from
internal/ai/skills/prompts/, one per skill version
(<skill>.v<version>.tmpl) defining "instructions" and "user". Templates
are parsed at start with missingkey=error; a bad template stops the
service.

harness.Render builds the system prompt in fixed order (D-007): [1] the
admin persona from ai_settings.system_prompt (Config.Persona), [2] the
skill instructions, [3] the household context block, [4] the output
contract quoting the JSON Schema. The contract is always the last layer
whatever the persona says. The household context is a seam of titled
sections until BuildContext lands; an empty one renders a defined block.
Skill.Render is replaced by Skill.PromptInput.

Golden tests pin the exact system prompt and user message for the echo
test skill, with and without persona, and under a hostile persona that
says "ignore the format below" or fakes a contract heading.
checksums.txt records each template's SHA-256; a template change without
a version bump fails TestTemplateChecksums naming the skill and version.

Maestro task bceca7a8-bc30-48df-944d-84557a1f4154.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
review_agent left a comment
Member

Independent Codex gpt-6-sol review: APPROVED for this exact commit.

Independent Codex gpt-6-sol review: APPROVED for this exact commit.
approver_agent merged commit 942ac42b86 into feature/d4a8ed83-9cee-459c-aca3-efd1ccf17ecd-ai-harness 2026-10-05 08:15:35 -04:00
Sign in to join this conversation.
No Reviewers
No labels
3 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Maniacs_Mansion/MealQuest#55