Skip to content

Commit a89dd11

Browse files
committed
Reject retries after answer context changes
1 parent 8b5b48b commit a89dd11

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

‎docs/implementation/read-only-review.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,4 @@ The documentation-only review after adding `AGENTS.md` exposed one more concrete
109109

110110
The follow-up review exposed the same active-job marker missing from the initial review response. Reloading during provider settlement could therefore expose Retry and stop polling. Initial loads and action responses now include the marker used by question polling; the browser regression reloads during settlement and confirms Retry remains hidden until the invocation finishes.
111111

112-
The next review made assignment drift concrete for item-level answers without snippet references. Each answer now records a hash of the changed segments supplied for its item. Moving code into or out of that item preserves the answer but labels it as earlier review context; a regression assigns new code without changing the snapshot or plan revision and checks the historical marker.
112+
The next review made assignment drift concrete for item-level answers without snippet references. Each answer now records a hash of the changed segments supplied for its item. Moving code into or out of that item preserves the answer but labels it as earlier review context and rejects retrying the old question; a regression assigns new code without changing the snapshot or plan revision, checks the historical marker, and proves no second agent invocation starts.

‎runner/questions.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class Questions {
2828
if (this.running.has(id)) throw new Error('Agent is already answering this question.');
2929
const note = view.notes.find(n=>n.id===id && n.kind==='question');
3030
if (!note) throw new Error('Question not found.');
31-
if (note.outdated || note.snapshotId!==view.snapshot.id || note.revision!==view.plan.revision) throw new Error('This question belongs to an older review. Ask again against the current code.');
31+
if (note.outdated || note.answerOutdated || note.snapshotId!==view.snapshot.id || note.revision!==view.plan.revision) throw new Error('This question belongs to an older review. Ask again against the current code.');
3232
const provider=this.service.store.questionProvider();
3333
const agent=this.agent ?? (provider ? cliQuestionAgent(provider) : undefined);
3434
const attempt=randomUUID(), controller=new AbortController();

‎test/questions.test.ts‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,14 @@ it('rejects questions whose snippet was reassigned without changing the snapshot
9595
const agent=vi.fn(async()=>'Should not run');const manager=new Questions(service,agent);managers.push(manager);
9696
expect(()=>manager.start(note.id,moved)).toThrow(/older review|outdated/);expect(agent).not.toHaveBeenCalled();
9797
});
98-
it('marks an item-level answer historical when assigned code changes',async()=>{
98+
it('marks an item-level attempt historical and rejects retry when assigned code changes',async()=>{
9999
const service=fixture(),initial=service.load(),foreign=initial.segments.find(s=>s.row==='Unplanned')!;
100100
const asked=service.act({action:'note',item:'P1',kind:'question',text:'Is this item complete?',token:initial.token});
101-
const manager=new Questions(service,async()=>'It is complete for the supplied changes.');managers.push(manager);
102-
manager.start(asked.createdNoteId!,asked);await vi.waitFor(()=>expect(service.store.getReviewNotes(service.config.identity)[0]?.answer?.status).toBe('complete'));
101+
const agent=vi.fn(async()=>{throw new Error('Provider failed');}),manager=new Questions(service,agent);managers.push(manager);
102+
manager.start(asked.createdNoteId!,asked);await vi.waitFor(()=>expect(service.store.getReviewNotes(service.config.identity)[0]?.answer?.status).toBe('failed'));
103103
const index=initial.segments.findIndex(segment=>segment.key===foreign.key);
104104
service.store.saveReview(service.config.identity,asked.expected,[],[{action:'assign',item:'P1',key:choiceKeys(initial.segments,service.config.identity)[index]!}]);
105105
const changed=service.load(),note=changed.notes.find(note=>note.id===asked.createdNoteId)!;
106-
expect(changed.snapshot.id).toBe(asked.snapshot.id);expect(note.answer?.text).toContain('complete');expect(note.answerOutdated).toBe(true);
106+
expect(changed.snapshot.id).toBe(asked.snapshot.id);expect(note.answerOutdated).toBe(true);
107+
expect(()=>manager.start(note.id,changed)).toThrow(/older review/);expect(agent).toHaveBeenCalledTimes(1);
107108
});

0 commit comments

Comments
 (0)