feat(sdd): inject canonical language contract into rendered sub-agent prompts - #1749
feat(sdd): inject canonical language contract into rendered sub-agent prompts#1749pablontiv wants to merge 3 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughGenerated artifact prompts now receive a canonical language contract across native Markdown and OpenCode SDD sub-agent flows. Tests cover idempotency and exclusions, rendered character thresholds are updated, and local CodeGraph artifacts are ignored. ChangesLanguage contract injection
CodeGraph repository policy
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Inject
participant OpenCodeOverlay
participant LanguageContractInjector
participant GeneratedPrompt
Inject->>LanguageContractInjector: inject contract into Markdown sub-agent prompt
OpenCodeOverlay->>LanguageContractInjector: inject contract into eligible sub-agent prompt
LanguageContractInjector->>GeneratedPrompt: produce managed prompt content
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR addresses #1702 (defect 4) by introducing a single canonical “Artifact Language Contract” asset and injecting it at render time into SDD sub-agent prompts (including OpenCode’s JSON-embedded subagent prompts), avoiding per-agent duplication and keeping re-renders idempotent via filemerge.InjectMarkdownSection.
Changes:
- Added a canonical language-contract markdown asset and injected it into rendered sub-agent prompts via marker-bound sections.
- Wired language-contract injection into the SDD render loop and OpenCode agent-map prompt inlining.
- Added focused unit tests and updated goldens / prompt-cost expectations to reflect the injected section.
Reviewed changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
internal/assets/generic/agent-language-contract.md |
New canonical Artifact Language Contract content (single source of truth). |
internal/components/sdd/prompts.go |
Adds contract accessor + injection helpers for markdown prompts and OpenCode embedded prompts. |
internal/components/sdd/inject.go |
Wires contract injection into the markdown render loop and OpenCode agents-map processing. |
internal/components/sdd/language_contract_injection_test.go |
New tests for canonical block presence, idempotence, and OpenCode skip semantics. |
internal/components/sdd/review_ledger_contract_test.go |
Updates deterministic rendered-character budgets to account for the new injected content. |
testdata/golden/sdd-opencode-multi-settings.golden |
Updates OpenCode rendered settings golden to include the managed contract section for inlined subagents. |
testdata/golden/sdd-kiro-agent-sdd-apply.golden |
Updates Kiro rendered agent golden to include the managed contract section. |
testdata/golden/sdd-kiro-agent-sdd-archive.golden |
Updates Kiro rendered agent golden to include the managed contract section. |
testdata/golden/sdd-kiro-agent-sdd-design.golden |
Updates Kiro rendered agent golden to include the managed contract section. |
testdata/golden/sdd-kiro-agent-sdd-explore.golden |
Updates Kiro rendered agent golden to include the managed contract section. |
testdata/golden/sdd-kiro-agent-sdd-init.golden |
Updates Kiro rendered agent golden to include the managed contract section. |
testdata/golden/sdd-kiro-agent-sdd-onboard.golden |
Updates Kiro rendered agent golden to include the managed contract section. |
testdata/golden/sdd-kiro-agent-sdd-propose.golden |
Updates Kiro rendered agent golden to include the managed contract section. |
testdata/golden/sdd-kiro-agent-sdd-spec.golden |
Updates Kiro rendered agent golden to include the managed contract section. |
testdata/golden/sdd-kiro-agent-sdd-tasks.golden |
Updates Kiro rendered agent golden to include the managed contract section. |
testdata/golden/sdd-kiro-agent-sdd-verify.golden |
Updates Kiro rendered agent golden to include the managed contract section. |
testdata/golden/sdd-claude-agent-sdd-apply.golden |
Updates Claude rendered agent golden to include the managed contract section. |
testdata/golden/sdd-claude-agent-sdd-archive.golden |
Updates Claude rendered agent golden to include the managed contract section. |
testdata/golden/sdd-claude-agent-sdd-design.golden |
Updates Claude rendered agent golden to include the managed contract section. |
testdata/golden/sdd-claude-agent-sdd-explore.golden |
Updates Claude rendered agent golden to include the managed contract section. |
testdata/golden/sdd-claude-agent-sdd-propose.golden |
Updates Claude rendered agent golden to include the managed contract section. |
testdata/golden/sdd-claude-agent-sdd-spec.golden |
Updates Claude rendered agent golden to include the managed contract section. |
testdata/golden/sdd-claude-agent-sdd-tasks.golden |
Updates Claude rendered agent golden to include the managed contract section. |
testdata/golden/sdd-claude-agent-sdd-verify.golden |
Updates Claude rendered agent golden to include the managed contract section. |
.codegraph/.gitignore |
Prevents accidental commits of local CodeGraph transient data. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/components/sdd/inject.go`:
- Line 725: Update the SDD user-config write flow around
injectLanguageContractIntoPrompt to journal or back up the original files before
calling filemerge.WriteFileAtomic or mergeJSONFile. Use the existing
restore-compatible backup mechanism so both config changes can be rolled back,
preserving the original contents and handling files that did not previously
exist.
In `@internal/components/sdd/language_contract_injection_test.go`:
- Around line 11-24: Add an assertion in
TestInjectLanguageContractIntoPromptAppendsCanonicalBlock that the injected
prompt contains the explicit requirement to use neutral, professional Spanish
when Spanish is explicitly requested. Keep the existing English-default,
dialect-prohibition, and marker assertions unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: c380779d-bfcc-4995-befe-63ea0b1e1a0a
⛔ Files ignored due to path filters (19)
testdata/golden/sdd-claude-agent-sdd-apply.goldenis excluded by!testdata/**testdata/golden/sdd-claude-agent-sdd-archive.goldenis excluded by!testdata/**testdata/golden/sdd-claude-agent-sdd-design.goldenis excluded by!testdata/**testdata/golden/sdd-claude-agent-sdd-explore.goldenis excluded by!testdata/**testdata/golden/sdd-claude-agent-sdd-propose.goldenis excluded by!testdata/**testdata/golden/sdd-claude-agent-sdd-spec.goldenis excluded by!testdata/**testdata/golden/sdd-claude-agent-sdd-tasks.goldenis excluded by!testdata/**testdata/golden/sdd-claude-agent-sdd-verify.goldenis excluded by!testdata/**testdata/golden/sdd-kiro-agent-sdd-apply.goldenis excluded by!testdata/**testdata/golden/sdd-kiro-agent-sdd-archive.goldenis excluded by!testdata/**testdata/golden/sdd-kiro-agent-sdd-design.goldenis excluded by!testdata/**testdata/golden/sdd-kiro-agent-sdd-explore.goldenis excluded by!testdata/**testdata/golden/sdd-kiro-agent-sdd-init.goldenis excluded by!testdata/**testdata/golden/sdd-kiro-agent-sdd-onboard.goldenis excluded by!testdata/**testdata/golden/sdd-kiro-agent-sdd-propose.goldenis excluded by!testdata/**testdata/golden/sdd-kiro-agent-sdd-spec.goldenis excluded by!testdata/**testdata/golden/sdd-kiro-agent-sdd-tasks.goldenis excluded by!testdata/**testdata/golden/sdd-kiro-agent-sdd-verify.goldenis excluded by!testdata/**testdata/golden/sdd-opencode-multi-settings.goldenis excluded by!testdata/**
📒 Files selected for processing (6)
.codegraph/.gitignoreinternal/assets/generic/agent-language-contract.mdinternal/components/sdd/inject.gointernal/components/sdd/language_contract_injection_test.gointernal/components/sdd/prompts.gointernal/components/sdd/review_ledger_contract_test.go
cb74125 to
8c33db7
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/components/sdd/inject.go`:
- Line 946: Update WriteSharedPromptFiles to inject the agent-language-contract
into shared SDD prompt contents before writing the referenced files, ensuring
OpenCode multi-mode agents receive it through {file:...} prompts. Preserve the
existing codegraph guidance and non-file prompt injection behavior without
duplicating the contract.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: f8483a87-3e04-44c7-91c5-7031b982fa7e
⛔ Files ignored due to path filters (19)
testdata/golden/sdd-claude-agent-sdd-apply.goldenis excluded by!testdata/**testdata/golden/sdd-claude-agent-sdd-archive.goldenis excluded by!testdata/**testdata/golden/sdd-claude-agent-sdd-design.goldenis excluded by!testdata/**testdata/golden/sdd-claude-agent-sdd-explore.goldenis excluded by!testdata/**testdata/golden/sdd-claude-agent-sdd-propose.goldenis excluded by!testdata/**testdata/golden/sdd-claude-agent-sdd-spec.goldenis excluded by!testdata/**testdata/golden/sdd-claude-agent-sdd-tasks.goldenis excluded by!testdata/**testdata/golden/sdd-claude-agent-sdd-verify.goldenis excluded by!testdata/**testdata/golden/sdd-kiro-agent-sdd-apply.goldenis excluded by!testdata/**testdata/golden/sdd-kiro-agent-sdd-archive.goldenis excluded by!testdata/**testdata/golden/sdd-kiro-agent-sdd-design.goldenis excluded by!testdata/**testdata/golden/sdd-kiro-agent-sdd-explore.goldenis excluded by!testdata/**testdata/golden/sdd-kiro-agent-sdd-init.goldenis excluded by!testdata/**testdata/golden/sdd-kiro-agent-sdd-onboard.goldenis excluded by!testdata/**testdata/golden/sdd-kiro-agent-sdd-propose.goldenis excluded by!testdata/**testdata/golden/sdd-kiro-agent-sdd-spec.goldenis excluded by!testdata/**testdata/golden/sdd-kiro-agent-sdd-tasks.goldenis excluded by!testdata/**testdata/golden/sdd-kiro-agent-sdd-verify.goldenis excluded by!testdata/**testdata/golden/sdd-opencode-multi-settings.goldenis excluded by!testdata/**
📒 Files selected for processing (6)
.codegraph/.gitignoreinternal/assets/generic/agent-language-contract.mdinternal/components/sdd/inject.gointernal/components/sdd/language_contract_injection_test.gointernal/components/sdd/prompts.gointernal/components/sdd/review_ledger_contract_test.go
…nd assert the canonical block
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 25 out of 25 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
internal/components/sdd/prompts.go:223
- OpenCode multi-mode SDD agents use
{file:...}prompt indirections (see updated goldentestdata/golden/sdd-opencode-multi-settings.goldenwheresdd-applyetc point to./prompts/sdd/*.md). This function skips{file:...}prompts, butWriteSharedPromptFiles()currently only injects CodeGraph guidance, not the language contract. Result: the canonical Artifact Language Contract is still missing from the SDD executor prompt files in multi-mode, so defect #1702/4 remains for those executors.
}
if mode, _ := agent["mode"].(string); mode == "primary" {
continue
🔗 Linked Issue
Closes #1702
🏷️ PR Type
type:feature— New feature (non-breaking change that adds functionality)📝 Summary
Fixes defect 4 of #1702: executor sub-agents carried no artifact-language contract, so an executor spawned inside a Spanish conversation mimicked its dialect (voseo included) when writing specs, comments, UI copy, memory entries, and reports.
Instead of duplicating a block into the 66 static agent assets, this follows the repo's reuse pattern (engram's canonical
protocol.md, the CodeGraph guidance injection): ONE canonical asset, injected at render time into every installed sub-agent prompt.internal/assets/generic/agent-language-contract.md— single source of truth: artifacts default to English; explicitly-requested Spanish artifacts use neutral/professional Spanish; never regional slang or dialect regardless of conversation language.injectLanguageContractIntoPrompt— marker-bound (filemerge.InjectMarkdownSection, sectionagent-language-contract), so re-renders are idempotent; wired into the step-3c render loop next to the CodeGraph guidance injection. Covers the claude/cursor/kimi/kiro markdown agents; a NEW agent asset inherits the contract structurally, with no per-file lint needed.injectLanguageContractIntoOpenCodeSubagentPromptsmirrors the CodeGraph OpenCode variant — JSON-embedded sub-agent prompts get the same contract; primary-mode (persona) agents and{file:...}indirections are skipped.📂 Changes
internal/assets/generic/agent-language-contract.mdinternal/components/sdd/prompts.goagentLanguageContract(),injectLanguageContractIntoPrompt(),injectLanguageContractIntoOpenCodeSubagentPrompts()internal/components/sdd/inject.gointernal/components/sdd/language_contract_injection_test.gotestdata/golden/sdd-{claude,kiro}-agent-*.golden,sdd-opencode-*-settings.golden🧪 Test Plan
Unit Tests
go test ./...Go Format
E2E Tests (Docker required)
go test ./internal/components/... ./internal/assets/; full suite except./internal/cli, which has 3 machine-local pre-existing failures documented in fix(persona): remap gentleman-neutral-artifacts alias to neutral #1712 — deferring the authoritative verdict to CI)go run ./internal/gofmtcheck)✅ Contributor Checklist
status:needs-review; awaiting maintainerstatus:approvedtype:*label — no triage rights from fork; maintainer:type:featureCo-Authored-Bytrailers💬 Notes for Reviewers
Cursor/kimi have no rendered-agent goldens (verified — only claude/kiro do), which is why the golden diff covers claude+kiro+opencode only; the injection itself runs for every adapter in the loop. Primary-mode OpenCode agents are deliberately excluded: the persona channel owns conversation-tone rules, and the executor contract is artifact-scoped (PR4 hardens the persona channels themselves).
Summary by CodeRabbit