fix: harden coordinator prompt against context compression - #54
Conversation
Restructure coordinator.md to survive DCP context compression: - Add identity-first opening embedding key constraints (NEVER reserve files) - Create dedicated Critical Constraints section before Protocol - Add explicit forge_review BEFORE forge_complete ordering - Use uppercase MUST/NEVER keywords for compression-resistant severity signaling - Convert flat rules list to numbered 8-step Protocol Add TestCoordinatorPrompt_StructuralResilience verifying 7 properties: frontmatter, identity paragraph, section ordering, behavioral rule markers, per-line RFC 2119 keywords, ordering semantics, and compression resilience (first 50% of lines contain all critical constraints). Fixes unbound-force#46 Assisted-by: claude-opus-4 Generated with AI assistance (claude-opus-4)
sonupreetam
left a comment
There was a problem hiding this comment.
Review Council
Ran the review council (6 Divisor agents). Overall well-executed — the restructuring is sound, the test is thorough, and the OpenSpec artifacts are exemplary. One intent drift finding and minor notes below.
Merge note: This PR, #57, and #58 all insert test functions at line 152 of agentkit_test.go. Suggest merging this one first, then rebasing #57 and #58.
| - Check inbox regularly for blocked workers (`comms_inbox`) | ||
| - Use `forge_broadcast` to share context updates with all workers | ||
| - NEVER reserve files — workers reserve their own | ||
| - NEVER edit code directly — workers handle all code changes |
There was a problem hiding this comment.
[HIGH] Intent drift: net-new constraint
NEVER edit code directly is a 7th constraint not present in the original coordinator.md. The design doc says "no new rules, no removed rules" and FR-006 lists exactly 6 behavioral rule markers — none for "edit code." The test at line 300 codifies this with a 'edit code' assertion.
The constraint is arguably a good addition, but it should be acknowledged as new. Update the design Non-Goals and spec FR-006 to reflect 7 rules, or remove it if true parity with the original 6 is the intent.
| } | ||
| } | ||
|
|
||
| func TestCoordinatorPrompt_StructuralResilience(t *testing.T) { |
There was a problem hiding this comment.
[MEDIUM] Consider t.Run() sub-tests
This test is ~147 lines covering many distinct properties (frontmatter, identity opening, section ordering, rule markers, keyword casing, compression resilience). Using t.Run("YAML frontmatter", ...), t.Run("Identity-first opening", ...), etc. would improve failure isolation and readability. SHOULD-level per CS-010.
Summary
Fixes #46 — the coordinator agent prompt (
internal/agentkit/content/agents/coordinator.md) was compression-fragile. Its 6 behavioral constraints were expressed as unordered bullet points in a single "Rules" section, where critical constraints like "Never reserve files" and "Review every worker completion" would be lost under DCP context compression.This restructures the prompt using patterns proven in the project's other agent files and the forge coordination skill:
forge_review→forge_completeorderingTestCoordinatorPrompt_StructuralResilience) verifying 7 compression-resilience propertiesHow to Test
The structural test verifies:
How to Demo
Read the restructured
internal/agentkit/content/agents/coordinator.md— the identity-first opening, Critical Constraints section, and numbered Protocol are self-evident. Compare against the previous version (flat bullet list) to see the structural improvement.Key Files Changed
internal/agentkit/content/agents/coordinator.mdinternal/agentkit/agentkit_test.goTestCoordinatorPrompt_StructuralResilience(151 lines)openspec/changes/coordinator-prompt-hardening/This PR was generated by /uf.finale (AI-assisted).