From 3200f0f605fa1a47b8d19db4fbe58c84dbd577e9 Mon Sep 17 00:00:00 2001 From: Zbigniew Sobiecki Date: Sat, 7 Mar 2026 08:17:01 +0000 Subject: [PATCH] fix(backlog-manager): post comment before moving card to TODO The backlog manager posted its selection comment after moving the card, which meant downstream automation (pm:status-changed triggers) could fire before the rationale was visible. Swap steps 5 and 6 so the comment is posted first, then the card is moved. Co-Authored-By: Claude Opus 4.6 --- src/agents/prompts/templates/backlog-manager.eta | 6 +++--- tests/unit/agents/prompts.test.ts | 11 +++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/agents/prompts/templates/backlog-manager.eta b/src/agents/prompts/templates/backlog-manager.eta index 91b38417..3b92f404 100644 --- a/src/agents/prompts/templates/backlog-manager.eta +++ b/src/agents/prompts/templates/backlog-manager.eta @@ -55,8 +55,8 @@ When the active pipeline is empty: - Smaller, self-contained <%= it.workItemNounPlural || 'cards' %> are preferred - <%= it.workItemNounPluralCap || 'Cards' %> with clear acceptance criteria - <%= it.workItemNounPluralCap || 'Cards' %> that don't reference incomplete work -5. **Move the selected <%= it.workItemNoun || 'card' %>** using `UpdateWorkItem` to change its status to TODO -6. **Post a comment** on the moved <%= it.workItemNoun || 'card' %> explaining the selection +5. **Post a comment** on the selected <%= it.workItemNoun || 'card' %> explaining the selection +6. **Move the selected <%= it.workItemNoun || 'card' %>** using `UpdateWorkItem` to change its status to TODO ## Comment Format @@ -97,6 +97,6 @@ Manual intervention may be needed to unblock the backlog. - EXIT SILENTLY if pipeline is not empty - do not post comments - ALWAYS read <%= it.workItemNoun || 'card' %> contents before making a selection decision - ALWAYS move exactly ONE <%= it.workItemNoun || 'card' %> per run -- ALWAYS post a comment on the moved <%= it.workItemNoun || 'card' %> explaining why it was selected +- ALWAYS post a comment BEFORE moving the <%= it.workItemNoun || 'card' %> — comment first, then move to TODO - BE CONSERVATIVE with dependency detection - when unsure, treat as blocked - LOOK FOR dependency keywords: "blocked by", "depends on", "waiting for", "after", "requires" diff --git a/tests/unit/agents/prompts.test.ts b/tests/unit/agents/prompts.test.ts index 1d828fe9..f7a3ba49 100644 --- a/tests/unit/agents/prompts.test.ts +++ b/tests/unit/agents/prompts.test.ts @@ -190,6 +190,17 @@ describe('system prompts content', () => { expect(prompt).toContain('card'); }); + it('backlog-manager prompt posts comment before moving card', () => { + const prompt = getSystemPrompt('backlog-manager'); + const commentStepIdx = prompt.indexOf('5. **Post a comment**'); + const moveStepIdx = prompt.indexOf('6. **Move the selected'); + expect(commentStepIdx).toBeGreaterThan(-1); + expect(moveStepIdx).toBeGreaterThan(-1); + expect(commentStepIdx).toBeLessThan(moveStepIdx); + // Rule reinforces the ordering + expect(prompt).toContain('comment BEFORE moving'); + }); + it('backlog-manager prompt renders custom PM terminology', () => { const prompt = getSystemPrompt('backlog-manager', { workItemNoun: 'issue',