fix: harden coordinator prompt against context compression - #54
Conversation
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.
Update spec artifacts to reflect that the "NEVER edit code directly" constraint codifies existing implicit coordinator behavior rather than introducing a new rule. Update FR-006 marker table (6→7), FR-007 count, and verification scenarios accordingly. Addresses PR unbound-force#54 review feedback from @sonupreetam. Signed-off-by: Joel Flowers <joel@unboundforce.com> Assisted-by: claude-opus
Break TestCoordinatorPrompt_StructuralResilience into 7 focused sub-tests for improved failure isolation: YAML_frontmatter, identity_first_opening, section_ordering, behavioral_rule_markers, uppercase_RFC2119_keywords, review_before_complete_ordering, and compression_resilience. Also updates the behavioral rule marker count from 6 to 7 and adds the "edit code" marker to match the spec update. Addresses PR unbound-force#54 review feedback from @sonupreetam. Signed-off-by: Joel Flowers <joel@unboundforce.com> Assisted-by: claude-opus
There was a problem hiding this comment.
Approval: PR #54 — fix: harden coordinator prompt against context compression
Testing Methodology
Reviewed using /uf.review-pr 54 with a custom-built UF binary (latest changes merged into main) after running /uf.init to scaffold the agent kit. The review command executed all steps of the automated review pipeline:
- CI Status: Build and Test — PASS
- Local Pre-flight:
make check(go vet + go test with race detector) — PASS - Spec Alignment: All 8 functional requirements (FR-001 through FR-008) verified against the OpenSpec artifacts
- Constitution Compliance: No violations (Principles I, III, IV assessed as PASS; Principle II N/A)
- Prior Review Feedback: Both findings from the review council (@sonupreetam) confirmed addressed in follow-up commits (cc016c8, e65479c)
Local Verification
Completed manual local verification:
- Checked out PR branch and ran
make check— all tests pass - Reviewed restructured
coordinator.mdand confirmed all 6 original rules preserved with behavioral parity - Ran
TestCoordinatorPrompt_StructuralResilience— all 7 sub-tests pass - Reviewed OpenSpec artifacts (proposal, design, specs, tasks) — complete and consistent
- Confirmed
.gitignoreaddition (.uf/feedback/) is benign (merged from main)
Findings
Two LOW-severity observations, neither blocking:
- LOW —
.gitignore:9:.uf/feedback/addition is unrelated to PR scope; entered via merge from main. Informational only. - LOW —
agentkit_test.go:321-336:compression_resiliencesub-test uses a 50% line-count heuristic as a compression proxy. Acknowledged in spec as a conservative structural heuristic. The test guards against constraint drift toward the end of the file, which is the intended value.
Additional findings from doing a deeper dive
MEDIUM: Off-by-one in frontmatter/body splitting
internal/agentkit/agentkit_test.go:175
body := text[4+endIdx+4:] // skip past "\n---\n"The comment says it skips "\n---\n" (5 chars) but the code advances only 4 chars, leaving a stray leading \n in body. Tests tolerate this because strings.Split(body, "\n\n") produces an empty leading element that gets filtered out, and the extra line in bodyLines doesn't shift halfLen enough to matter for the current 31-line file. Still, the comment is factually wrong and body contains content the code didn't intend.
Fix: text[4+endIdx+5:] or update the comment to // skip past "\n---".
LOW : Defensive t.Skip branches unreachable with current embedded content
internal/agentkit/agentkit_test.go:263-264, 287-288
The constraintsSection == "" guards can never fire because coordinator.md contains both ## Critical Constraints and ## Protocol. These are reasonable defensive guards for future-proofing, but have zero test coverage themselves.
Verdict
APPROVE — Well-scoped change with complete spec-first workflow, comprehensive structural tests, and all prior review feedback addressed. No blocking findings.
Manual Testing SummaryPR #54 hardens Testing AttemptedManual testing of the forge workflow was performed during PR #55 review (same underlying mechanism). Two tasks were run via
In both cases, the agent bypassed the forge workflow entirely — no What could not be verified
What the automated tests verify
ConclusionManual verification was not achievable — the coordinator subagent is only loaded during forge worker orchestration, which agents declined to use. The automated structural tests are the primary verification for this PR's claims. |
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)
Update spec artifacts to reflect that the "NEVER edit code directly" constraint codifies existing implicit coordinator behavior rather than introducing a new rule. Update FR-006 marker table (6→7), FR-007 count, and verification scenarios accordingly. Addresses PR unbound-force#54 review feedback from @sonupreetam. Signed-off-by: Joel Flowers <joel@unboundforce.com> Assisted-by: claude-opus
Break TestCoordinatorPrompt_StructuralResilience into 7 focused sub-tests for improved failure isolation: YAML_frontmatter, identity_first_opening, section_ordering, behavioral_rule_markers, uppercase_RFC2119_keywords, review_before_complete_ordering, and compression_resilience. Also updates the behavioral rule marker count from 6 to 7 and adds the "edit code" marker to match the spec update. Addresses PR unbound-force#54 review feedback from @sonupreetam. Signed-off-by: Joel Flowers <joel@unboundforce.com> Assisted-by: claude-opus
c22aaaa to
7237bdc
Compare
Update spec artifacts to reflect that the "NEVER edit code directly" constraint codifies existing implicit coordinator behavior rather than introducing a new rule. Update FR-006 marker table (6→7), FR-007 count, and verification scenarios accordingly. Addresses PR #54 review feedback from @sonupreetam. Signed-off-by: Joel Flowers <joel@unboundforce.com> Assisted-by: claude-opus
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).