Fix #11: a rewrite prompt keeps its FAIL issues under hook header lines
The rewrite marker was only recognised as the first thing in the prompt. pipeline-guard put header lines above it, so the router started the agent as a new brief: header lines and a bare marker, no issues (EV-13 T9). - [router-rewrite Tn] is recognised at the start of any line (also after > - *). - Lines above it stay on top, once (lines the stored prompt has are dropped); the stored prompt with the issues follows; text after it is guidance. - The rewrite keeps its task number and tier. 2 tests; 5 mutations, all caught. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MdqPWvuDpbpRvDEdURoAwo
This commit is contained in:
@@ -5,10 +5,12 @@ import {
|
||||
decide,
|
||||
heuristic,
|
||||
taskText,
|
||||
rewritePrompt,
|
||||
onFail,
|
||||
parseBrief,
|
||||
parseVerdict,
|
||||
rewriteTier,
|
||||
REWRITE_MARK,
|
||||
skipReason,
|
||||
validTimeout,
|
||||
verifierFor,
|
||||
@@ -1386,3 +1388,43 @@ test('#10: a new file created while round 1 is verified counts as new in round 2
|
||||
expect(w.verifierPrompts[1]).toContain('new file: tests/test_named_absence.py')
|
||||
expect(w.verifierPrompts[1]).not.toContain('new file: old_notes.md')
|
||||
})
|
||||
|
||||
// ---------- #11: the rewrite prompt keeps its issues under hook header lines ----------
|
||||
|
||||
const GUARD_HEADER = 'Pipeline-Role: dev\nPipeline-Guard: v3 (EV-13)\n'
|
||||
|
||||
test('#11: a rewrite marker under guard header lines starts the stored rewrite, issues and all (EV-13 T9)', async ($, on) => {
|
||||
const w = fresh()
|
||||
w.diffs = ['d1', 'd2']
|
||||
w.verdicts = [
|
||||
'{"verdict":"FAIL","issues":["P1/P2 not in the N2 check"]}',
|
||||
'{"verdict":"FAIL","issues":["P4 arm-at-send assert","R1 kill not shown"]}',
|
||||
]
|
||||
const clock = world(on, w)
|
||||
const r = await $.agent.spawn({ prompt: devBrief(), description: 'ev13' } as never)
|
||||
await finish($, clock, r.agentId as string)
|
||||
await finish($, clock, r.agentId as string)
|
||||
expect(w.told[1]).toContain('[router-rewrite T1]')
|
||||
|
||||
await $.agent.spawn({ prompt: `${GUARD_HEADER}[router-rewrite T1]`, description: 'rewrite' } as never)
|
||||
const p = w.spawned[1]?.prompt ?? ''
|
||||
expect(p).toContain('- P4 arm-at-send assert')
|
||||
expect(p).toContain('- R1 kill not shown')
|
||||
expect(p).toContain(`Their work is in the clone ${DEV}`)
|
||||
expect(p.startsWith('Pipeline-Role: dev\nPipeline-Guard: v3 (EV-13)')).toBe(true)
|
||||
expect(w.spawned[1]?.model).toBe('opus') // the rewrite's tier, not a fresh routing
|
||||
const log = (await $.command.run({ command: 'router', args: '' } as never)).text ?? ''
|
||||
expect(log).not.toContain('T2') // the same task, no new number
|
||||
})
|
||||
|
||||
test('#11: header lines are not doubled, text after the marker is guidance, mid-line mentions are no marker', async () => {
|
||||
const stored = 'Pipeline-Role: dev\nClone: /x/clones/EV-13-dev\nDo it.\n\n## Previous attempts rejected\nIssues:\n- a'
|
||||
const p = rewritePrompt('Pipeline-Role: dev\nPipeline-Guard: v3\n\n[router-rewrite T9]\nKeep the P4 test.', stored)
|
||||
expect(p.split('Pipeline-Role: dev').length).toBe(2) // once
|
||||
expect(p.startsWith('Pipeline-Guard: v3\n\nPipeline-Role: dev')).toBe(true)
|
||||
expect(p).toContain('- a')
|
||||
expect(p.endsWith('Additional guidance from the orchestrator:\nKeep the P4 test.')).toBe(true)
|
||||
expect(rewritePrompt('[router-rewrite T9]', stored)).toBe(stored)
|
||||
expect('Call Agent with prompt [router-rewrite T9] now'.match(REWRITE_MARK)).toBe(null)
|
||||
expect('> [router-rewrite T9]'.match(REWRITE_MARK)?.[1]).toBe('T9')
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user