fix(paired): bound arbiter interventions to stop infinite arbiter loop
The owner↔reviewer↔arbiter loop could repeat forever: when the arbiter ruled PROCEED/REVISE/RESET it reset round_trip_count to 0, and nothing tracked how many times the arbiter had already intervened. A re-deadlock re-invoked the arbiter without bound. Add a persistent arbiter_intervention_count (new column + migration 020) that survives the round-trip reset, and a configurable cap ARBITER_MAX_INTERVENTIONS (default 1). Once the arbiter has intervened that many times and the loop still deadlocks, requestArbiterOrEscalate escalates straight to the user instead of re-invoking the arbiter. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -67,6 +67,7 @@ export function handleFailedOwnerExecution(args: {
|
||||
currentStatus: task.status,
|
||||
expectedUpdatedAt: task.updated_at,
|
||||
now,
|
||||
arbiterInterventionCount: task.arbiter_intervention_count ?? 0,
|
||||
arbiterLogMessage:
|
||||
'Owner Codex unavailable repeatedly — requesting arbiter',
|
||||
escalateLogMessage:
|
||||
@@ -140,6 +141,7 @@ export function handleFailedOwnerExecution(args: {
|
||||
currentStatus: task.status,
|
||||
expectedUpdatedAt: task.updated_at,
|
||||
now,
|
||||
arbiterInterventionCount: task.arbiter_intervention_count ?? 0,
|
||||
arbiterLogMessage:
|
||||
'Owner failed repeatedly without a visible verdict — requesting arbiter',
|
||||
escalateLogMessage:
|
||||
@@ -237,6 +239,7 @@ function handleOwnerFinalizeCompletion(args: {
|
||||
currentStatus: task.status,
|
||||
expectedUpdatedAt: task.updated_at,
|
||||
now,
|
||||
arbiterInterventionCount: task.arbiter_intervention_count ?? 0,
|
||||
arbiterLogMessage,
|
||||
escalateLogMessage,
|
||||
logContext: {
|
||||
@@ -266,6 +269,7 @@ function handleOwnerFinalizeCompletion(args: {
|
||||
currentStatus: task.status,
|
||||
expectedUpdatedAt: task.updated_at,
|
||||
now,
|
||||
arbiterInterventionCount: task.arbiter_intervention_count ?? 0,
|
||||
arbiterLogMessage:
|
||||
'Owner repeated STEP_DONE during finalize without code changes — requesting arbiter',
|
||||
escalateLogMessage:
|
||||
@@ -464,6 +468,7 @@ export function handleOwnerCompletion(args: {
|
||||
currentStatus: task.status,
|
||||
expectedUpdatedAt: task.updated_at,
|
||||
now,
|
||||
arbiterInterventionCount: task.arbiter_intervention_count ?? 0,
|
||||
arbiterLogMessage: 'Owner blocked/needs_context — requesting arbiter',
|
||||
escalateLogMessage: 'Owner blocked/needs_context — escalating to user',
|
||||
logContext: {
|
||||
@@ -490,6 +495,7 @@ export function handleOwnerCompletion(args: {
|
||||
currentStatus: task.status,
|
||||
expectedUpdatedAt: task.updated_at,
|
||||
now,
|
||||
arbiterInterventionCount: task.arbiter_intervention_count ?? 0,
|
||||
arbiterLogMessage:
|
||||
'Owner repeated STEP_DONE without code changes — requesting arbiter',
|
||||
escalateLogMessage:
|
||||
|
||||
Reference in New Issue
Block a user