@@ -369,3 +369,89 @@ git rev-parse HEAD
369369<AssertEquals actual={continued.calls.every(call => call.sourceValue.clean && call.sourceValue.head === manifest.assignment.revision)} expected={true} />
370370</TempDir >
371371</Test >
372+
373+ <Test name =" accepted plan survives distinct implementation handoffs and retained correction " timeout =" 90s " >
374+ <TempDir >
375+ <Fixture.Repository as="fixture" />
376+ <Dir path ={fixture.repository} >
377+ <File path =" api.sh " >format() { printf '%s' "$1"; }
378+ </File >
379+ ``` bash exec as="base"
380+ git add api.sh
381+ git commit -qm ' existing API'
382+ git rev-parse HEAD
383+ ```
384+ <If condition={base.exitCode !== 0}><Fail message ={base.stderr} /></If >
385+ </Dir >
386+ <Let as="reference" value={fixture.root + "/accepted.md"} />
387+ <Dir path ={fixture.root} ><File path =" accepted.md " >Accepted plan retention contract.</File ></Dir >
388+ <Let as =" impact " value ={{...assessment,architecture:true,evidence:[reference]}} />
389+ <Let as="manifest" value={{schema:"ticket-workflow.v2",work:"handoff",directory: fixture .directory,maxCorrections:3,maxApiRepairs:3,maxResponseCorrections:0,roles:{architect:{session:"original-architect",provider:"codex",initialized: false },planner:{session:"original-planner",provider:"codex",initialized: false },implementor:{session:"original-implementor",provider:"codex",initialized: false }},acceptedInputs:[ {path: reference ,content:"Accepted plan retention contract."}] ,assignment:{phase:"discovery",work:"handoff",repository: fixture .repository,revision: base .stdout.trim(),priorRevision: null ,request:"handoff-retention",assessment: impact ,changedPaths:[ ] ,artifacts:[ ] ,evidence:[ ] ,findings:[ ] ,recipient:"planner",continuation:{phase:"implementation",role:"implementor"}}}} />
390+ <Fixture.Entry entry="planning-case" value={manifest} repository={fixture.repository} command={runner} root={root} as="child" />
391+ <If condition={child.exitCode !== 0}><Fail message={child.stderr || child.stdout} /></If >
392+ <Parse schema={{type:"object"}} as="planned">{child.stdout}</Parse >
393+ <AssertEquals actual ={planned.calls[0].status} expected =" accepted " />
394+ <Let as =" planPath " value ={planned.calls[0].resultValue.handoffInputs[0]} />
395+ <Let as =" plan " value ={planned.documents[planPath]} />
396+ <AssertEquals actual ={plan.content} expected =" Use the existing format API for the remaining consumer. Remove legacy.fixture, run bash consumer.sh, and return its signed feedback commit. " />
397+ <Fixture.Entry entry="continue" value={planned} repository={fixture.repository} steps={3} command={runner} root={root} as="child" />
398+ <If condition={child.exitCode !== 0}><Fail message={child.stderr || child.stdout} /></If >
399+ <Parse schema={{type:"object"}} as="correcting">{child.stdout}</Parse >
400+ <AssertEquals actual ={correcting.calls.slice(0,1)} expected ={planned.calls} />
401+ <If condition={correcting.calls.length !== 4 || correcting.calls.some(call => call.resultValue === undefined)}><Fail message ={JSON.stringify(correcting)} /></If >
402+ <AssertEquals actual={correcting.calls.map(call => [ call.role,call.resultValue?.outcome] )} expected={[[ "planner","complete"] ,[ "implementor","complete"] ,[ "architect","pass"] ,[ "planner","changes_required"]] } />
403+ <Let as =" implementationPath " value ={correcting.calls[1].resultValue.handoffInputs[0]} />
404+ <Let as =" implementation " value ={correcting.documents[implementationPath]} />
405+ <AssertEquals actual ={implementation.content} expected =" Initial implementation evidence: bash consumer.sh passed. " />
406+ <AssertEquals actual ={correcting.calls[1].resultValue.handoffInputs} expected ={[implementationPath]} />
407+ <AssertEquals actual={implementationPath === planPath} expected={false} />
408+ <Each in ={correcting.calls.slice(2)} let =" review " >
409+ <Ticket.Text path={review.attempt + "/called.json"} as="text" />
410+ <Parse schema={{type:"object"}} as="invoked">{text}</Parse >
411+ <AssertEquals actual ={invoked.inputs} expected ={review.inputs} />
412+ <AssertEquals actual={invoked.inputs.filter(input => input.path === planPath)} expected={[ plan] } />
413+ <AssertEquals actual={invoked.inputs.filter(input => input.path === implementationPath)} expected={[ implementation] } />
414+ </Each >
415+ <AssertEquals actual={{status: correcting .status,gate: correcting .gate,round: correcting .round,dispatchable: correcting .dispatchable,hold: correcting .hold}} expected={{status:"paused",gate:"implementation",round:3,dispatchable: true ,hold: null }} />
416+ <Let as =" correctionPath " value ={correcting.calls[3].resultValue.handoffInputs[0]} />
417+ <AssertEquals actual ={correcting.assignment.handoffInputs} expected ={[correctionPath]} />
418+ <Let as="quotedPlan" value={"'" + planPath.replaceAll("'","'\" '\" '") + "'"} />
419+ ``` bash exec as="mutated"
420+ printf ' %s' ' Mutable plan file changed after capture.' > {quotedPlan}
421+ ```
422+ <If condition={mutated.exitCode !== 0}><Fail message ={mutated.stderr} /></If >
423+ <Fixture.Entry entry="continue" value={correcting} repository={fixture.repository} steps={1} command={runner} root={root} as="child" />
424+ <If condition={child.exitCode !== 0}><Fail message={child.stderr || child.stdout} /></If >
425+ <Parse schema={{type:"object"}} as="corrected">{child.stdout}</Parse >
426+ <AssertEquals actual ={corrected.calls.slice(0,4)} expected ={correcting.calls} />
427+ <Let as =" correctedPath " value ={corrected.calls[4].resultValue.handoffInputs[0]} />
428+ <AssertEquals actual ={corrected.calls[4].resultValue.handoffInputs} expected ={[correctedPath,correctionPath]} />
429+ <AssertEquals actual ={corrected.documents[correctedPath].content} expected =" Corrected implementation evidence: bash consumer.sh passed. " />
430+ <AssertEquals actual ={corrected.feedbackInputs} expected ={[planPath,implementationPath,correctionPath,correctedPath]} />
431+ <Fixture.Entry entry="continue" value={corrected} repository={fixture.repository} steps={2} command={runner} root={root} as="child" />
432+ <If condition={child.exitCode !== 0}><Fail message={child.stderr || child.stdout} /></If >
433+ <Parse schema={{type:"object"}} as="finished">{child.stdout}</Parse >
434+ <AssertEquals actual ={finished.calls.slice(0,5)} expected ={corrected.calls} />
435+ <AssertEquals actual ={finished.status} expected =" feedback_ready " />
436+ <AssertEquals actual ={finished.round} expected ={3} />
437+ <AssertEquals actual ={finished.manifest} expected ={manifest} />
438+ <AssertEquals actual={finished.calls.map(call => call.initialize)} expected={[ true,true,true,false,false,false,false] } />
439+ <AssertEquals actual={finished.calls.map(call => call.session)} expected={[ "original-planner","original-implementor","original-architect","original-planner","original-implementor","original-architect","original-planner"] } />
440+ <AssertEquals actual ={finished.reviews} expected ={{architect:finished.revision,planner:finished.revision}} />
441+ <AssertEquals actual ={finished.documents[planPath]} expected ={plan} />
442+ <Each in={[ "architect","planner"] } let="role">
443+ <Let as="received" value={finished.calls.filter(call => call.role === role).flatMap(call => call.inputs)} />
444+ <AssertEquals actual={received.filter(input => input.path === planPath)} expected={[ plan] } />
445+ <AssertEquals actual={received.filter(input => input.path === implementationPath)} expected={[ implementation] } />
446+ <AssertEquals actual={received.filter(input => input.path === correctedPath)} expected={[ finished.documents[ correctedPath]] } />
447+ </Each >
448+ <Each in ={finished.calls.slice(5)} let =" review " >
449+ <Ticket.Text path={review.attempt + "/called.json"} as="text" />
450+ <Parse schema={{type:"object"}} as="invoked">{text}</Parse >
451+ <AssertEquals actual ={invoked.inputs} expected ={review.inputs} />
452+ <AssertEquals actual ={review.assignment.handoffInputs.includes(planPath)} expected ={true} />
453+ <AssertEquals actual={new Set(review.assignment.handoffInputs).size} expected={review.assignment.handoffInputs.length} />
454+ <AssertEquals actual={invoked.inputs.filter(input => input.path === planPath)} expected={[ ] } />
455+ </Each >
456+ </TempDir >
457+ </Test >
0 commit comments