fix: keep supervisor reviews running until completion
Remove elapsed execution-budget pauses from extraction and navigation so long reviews no longer require repeated manual continuation. Remove the pause-duration setting and update activity copy and design documentation. Preserve explicit pause, saved batches, model timeouts and concurrency limits. Validation: recorded 13 focused tests, typecheck and targeted ESLint passed; staged diff check passed. Tests were not rerun for this commit. Release note: 监督回顾现在持续分批处理至完成,不再每隔固定时长自动暂停;仍可主动暂停并从已保存进度继续。
This commit is contained in:
@@ -86,18 +86,31 @@ it('reopens saved batches after failure, resumes exact Unicode offsets and only
|
||||
expect(f.summarize).toHaveBeenCalledTimes(calls)
|
||||
})
|
||||
|
||||
it('soft budget pauses without checkpointing and freezes configuration across continuation', async () => {
|
||||
it('continues extraction and navigation beyond the saved execution budget', async () => {
|
||||
const f = await fixture([['x'.repeat(2500)]], { concurrency: 1, executionSeconds: 30 })
|
||||
const clock = vi.spyOn(Date, 'now').mockReturnValue(time)
|
||||
f.summarize.mockImplementationOnce(async () => { clock.mockReturnValue(time + 31000); return empty })
|
||||
const result = await f.service().run(request)
|
||||
expect(result.status).toBe('completed')
|
||||
expect(result.coverage).toMatchObject({ batches: 3, remainingSources: 0, complete: true })
|
||||
expect(f.summarize).toHaveBeenCalledTimes(5)
|
||||
expect(f.db.supervisionReviewStore().batches(result.runId!, 100).flatMap(row => row.evidence).map(row => row.content.length)).toEqual([1000, 1000, 500])
|
||||
clock.mockRestore()
|
||||
})
|
||||
|
||||
it('still pauses on user request and resumes saved batches without changing batch settings', async () => {
|
||||
const f = await fixture([['x'.repeat(2500)]], { concurrency: 1 })
|
||||
const service = f.service()
|
||||
f.summarize.mockImplementationOnce(async () => empty).mockImplementationOnce(async () => {
|
||||
service.pause(f.db.listSupervisionActivity()[0]!.id)
|
||||
return empty
|
||||
})
|
||||
const result = await service.run(request)
|
||||
expect(result.status).toBe('paused')
|
||||
expect(result.coverage).toMatchObject({ batches: 1, remainingSources: 1, complete: false })
|
||||
f.config.batchCharacters = 16000
|
||||
const resumed = await f.service().resume(result.runId!)
|
||||
expect(resumed.status).toBe('completed')
|
||||
expect((await f.service().resume(result.runId!)).status).toBe('completed')
|
||||
expect(f.db.supervisionReviewStore().batches(result.runId!, 100).flatMap(row => row.evidence).map(row => row.content.length)).toEqual([1000, 1000, 500])
|
||||
clock.mockRestore()
|
||||
})
|
||||
|
||||
it('rejects changed source versions and rolls back offsets when batch persistence fails', async () => {
|
||||
|
||||
@@ -264,10 +264,9 @@ export class SupervisorService {
|
||||
this.controllers.set(runId, controller)
|
||||
const activity = { inFlight: 0 }
|
||||
this.activity.set(runId, activity)
|
||||
const deadline = Date.now() + config.executionSeconds * 1000
|
||||
const empty: SupervisionSummaryOutput = { summary: 'No new evidence', changeDigest: '', openItems: [], events: [], entities: [], entityChanges: [], relations: [] }
|
||||
const paused = () => {
|
||||
db.pause(runId, controller.signal.aborted ? 'Review paused by user' : 'Execution budget reached; continue to review remaining sources')
|
||||
db.pause(runId, 'Review paused by user')
|
||||
return { runId, request, evidence: [], output: empty, status: 'paused' as const, coverage: db.progress(runId) }
|
||||
}
|
||||
try {
|
||||
@@ -300,7 +299,6 @@ export class SupervisorService {
|
||||
if (controller.signal.aborted) return paused()
|
||||
const groups = db.groups(runId, config.concurrency)
|
||||
if (!groups.length) break
|
||||
if (Date.now() >= deadline) return paused()
|
||||
const results = await Promise.allSettled(groups.map(async group => {
|
||||
controller.signal.throwIfAborted()
|
||||
const evidence = db.chunk(runId, group.projectId, group.conversationId, config)
|
||||
@@ -324,7 +322,6 @@ export class SupervisorService {
|
||||
const id = createHash('sha256').update(JSON.stringify([left.id, right.id])).digest('hex')
|
||||
const cached = db.navigation(runId, id)
|
||||
if (cached) return { id, output: cached }
|
||||
if (Date.now() >= deadline) throw new Error('REVIEW_SOFT_BUDGET')
|
||||
const evidence = [left, right].map(card => ({ id: card.id, sourceType: 'note' as const, sourceId: card.id,
|
||||
title: 'Retained review navigation', content: card.output.summary, occurredAt: request.timeRange.to }))
|
||||
const output = await summarize(evidence, true)
|
||||
@@ -378,7 +375,7 @@ export class SupervisorService {
|
||||
await this.store.save(result)
|
||||
return result
|
||||
} catch (error) {
|
||||
if (controller.signal.aborted || (error instanceof Error && error.message === 'REVIEW_SOFT_BUDGET')) return paused()
|
||||
if (controller.signal.aborted) return paused()
|
||||
this.store.fail?.(runId, error instanceof Error ? error.message : 'Review failed')
|
||||
throw error
|
||||
} finally { this.controllers.delete(runId); this.activity.delete(runId) }
|
||||
|
||||
Reference in New Issue
Block a user