Commit Graph

88 Commits

Author SHA1 Message Date
Codex
de54f13469 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>
2026-06-09 02:15:21 +09:00
Eyejoker
ac0cd3e41d fix: preserve owner retry failure counts 2026-06-04 22:25:00 +08:00
Eyejoker
0cbb7e3b9c fix: preserve paired completion errors without leases (#217) 2026-06-03 08:59:51 +08:00
ejclaw
03d4c81192 fix: recover Codex rotation auth failures
- mark Codex bearer/refresh failures as terminal auth-expired states

- sync refreshed session auth back to rotation slots and revive refreshed dead_auth slots

- stop paired arbiter retry loops when Codex accounts are unavailable

- add regression coverage for rotation leases, follow-up suppression, and arbiter closure
2026-06-02 00:21:53 +09:00
Eyejoker
239c7ff1e6 fix: make paired evidence loss visible (#202) 2026-05-31 16:20:09 +09:00
ejclaw
4dcd4037f1 chore: clear low-risk lint warnings 2026-04-29 13:31:11 +09:00
ejclaw
b774dcaae5 Extract paired task status helpers 2026-04-29 10:44:28 +09:00
ejclaw
34b0ee8f4c Extract paired arbiter request helper 2026-04-29 10:32:36 +09:00
ejclaw
247a710ae7 Extract paired source ref helpers 2026-04-29 10:22:33 +09:00
Eyejoker
a74ea4bad0 fix: preserve paired owner workspace branch invariant
Safely re-anchor drifted paired owner workspaces, guard owner completion handling, and tighten generated attachment temp-dir allowlisting.
2026-04-25 12:02:02 +09:00
ejclaw
9ef79e3828 Add STEP_DONE guards, verdict storage, and stale delivery suppression 2026-04-23 15:28:42 +09:00
ejclaw
1122ace363 paired: disable latest owner final carry-forward by default 2026-04-22 05:51:43 +09:00
ejclaw
be7383d68c style: format paired execution carry-forward changes 2026-04-20 08:20:17 +09:00
ejclaw
b6a24ad9fb paired: carry forward latest owner final across superseded tasks 2026-04-20 08:19:31 +09:00
ejclaw
a59813dee6 feat: support room-level reviewer and arbiter agent selection 2026-04-15 23:47:46 +09:00
ejclaw
1846d59d2f Format owner failure recovery changes 2026-04-15 03:11:47 +09:00
ejclaw
2ab3bddc0e Recover Codex compaction failures in paired owner flow 2026-04-15 03:11:14 +09:00
ejclaw
533d0fbd18 Format supersession follow-up changes 2026-04-15 01:22:20 +09:00
ejclaw
0a6782f5c2 Fix merge-ready task supersession handling 2026-04-15 01:21:00 +09:00
ejclaw
fe9d265c66 paired: repair safe owner workspace branch mismatches 2026-04-11 08:45:47 +09:00
ejclaw
2b8f55deb6 runtime: centralize unsafe paired mode checks 2026-04-11 08:20:05 +09:00
ejclaw
f5c3393c32 runners: share protocol and reviewer policy 2026-04-11 05:07:05 +09:00
ejclaw
4e05f60400 refactor: land approved runtime cleanup and room binding cutover 2026-04-10 21:04:23 +09:00
ejclaw
2e62e125ae Audit outbound delivery and fix reviewer turn routing 2026-04-10 15:22:45 +09:00
ejclaw
0f994ab2ce fix: harden paired runtime turn coordination 2026-04-09 13:52:42 +09:00
ejclaw
10e10b499c Complete paired-room SSOT cleanup and logger singleton 2026-04-07 05:12:22 +09:00
ejclaw
b8e8c9dabf Unify paired status transitions and retry handling 2026-04-07 02:49:02 +09:00
ejclaw
cbb6bc97c7 Refactor paired execution flow boundaries 2026-04-07 00:45:17 +09:00
ejclaw
5b832042da Format files touched by executor refactor 2026-04-06 19:40:36 +09:00
ejclaw
24ffa3d2f1 Refactor paired turn transitions and scheduling 2026-04-06 19:32:36 +09:00
ejclaw
d75d26c23d Stabilize paired reviewer recovery and owner follow-up 2026-04-06 07:49:26 +09:00
ejclaw
994e957767 Enable unsafe host paired runtime 2026-04-06 02:40:15 +09:00
ejclaw
2983e0501c Serialize merge-ready owner finalize handoff 2026-04-05 20:11:14 +09:00
Eyejoker
bf3ed696fe Preserve paired review state after infra failures 2026-04-05 07:43:40 +09:00
Eyejoker
3dd772c229 Refactor local memory and role-fixed runtime routing 2026-04-04 03:50:28 +09:00
Eyejoker
60f360b5ea fix: preserve handoff roles during failover 2026-04-01 02:54:35 +09:00
Eyejoker
757e33c58e fix: prevent DONE↔DONE infinite loop and add AGENT_LANGUAGE setting
- Fix source_ref mismatch: update to workspace HEAD on first owner run
  so change detection compares against the correct repo
- Treat hasNewChanges === null as "no changes" at finalize to prevent
  infinite re-review when source_ref is unresolvable
- Add AGENT_LANGUAGE env var: when set, appends language instruction to
  all paired room prompts (owner, reviewer, arbiter)
2026-03-31 13:55:41 +09:00
Eyejoker
dd28ac6223 fix: fallback to proceed on unrecognized arbiter verdict
Previously unknown verdicts caused arbiter_escalated (task terminated).
Now falls back to proceed so the loop continues — a parse failure
should not kill the task.
2026-03-31 09:03:20 +09:00
Eyejoker
94184c137d fix: parse arbiter verdict with optional VERDICT: prefix
Codex arbiter sometimes outputs "VERDICT: PROCEED" instead of
"PROCEED". The regex now handles optional "VERDICT:" prefix,
preventing unknown verdict → false arbiter_escalated.
2026-03-31 08:51:01 +09:00
Eyejoker
196c453ccf fix: skip enqueueMessageCheck when task is already completed (ESCALATE/done) 2026-03-31 04:59:27 +09:00
Eyejoker
636c54702a fix: prevent ESCALATE → new task loop (only create tasks on human messages) 2026-03-31 04:58:26 +09:00
Eyejoker
2753849343 chore: update Claude Agent SDK 0.2.87, Codex SDK 0.117.0 2026-03-31 04:47:42 +09:00
Eyejoker
d0416489c5 fix: escalate finalize blockers without reviewer bounce 2026-03-31 04:32:10 +09:00
Eyejoker
af550a2aab fix: prevent infinite loops in paired review (merge_ready oscillation, arbiter re-invocation)
- Owner finalize with concerns now checks deadlock threshold before
  looping back — prevents merge_ready ↔ active infinite oscillation
- Arbiter verdict resets round_trip to threshold-1 instead of 0,
  giving agents one round before re-triggering arbiter
2026-03-31 04:13:26 +09:00
Eyejoker
e1b9501e87 feat: add completion_reason to paired_tasks (done/escalated/stopped/arbiter_escalated)
- owner can summon arbiter via BLOCKED/NEEDS_CONTEXT verdict
- completion_reason tracks why task ended: done (success), escalated
  (reviewer gave up), stopped (/stop), arbiter_escalated
2026-03-31 04:10:33 +09:00
Eyejoker
b02c509eb8 feat: owner can also summon arbiter via BLOCKED/NEEDS_CONTEXT verdict 2026-03-31 04:05:26 +09:00
Eyejoker
25cec18ce8 fix: clear arbiter session on each invocation to prevent verdict bias 2026-03-30 22:30:42 +09:00
Eyejoker
45fe80f5f5 fix: route BLOCKED/NEEDS_CONTEXT through arbiter before escalating
BLOCKED and NEEDS_CONTEXT verdicts went straight to completed,
bypassing the arbiter entirely. Now when arbiter is enabled, these
verdicts trigger arbiter intervention first — the arbiter may
resolve the block or decide to escalate to the user (ESCALATE).
2026-03-30 22:26:51 +09:00
Eyejoker
a043f2b79a feat: implement MAGI 3-agent arbiter system for deadlock resolution
Introduces a third agent role (arbiter) that is summoned on-demand
when owner and reviewer reach a deadlock (same verdict 3+ rounds).

Architecture:
- 3 Discord bots: owner (codex), reviewer (claude), arbiter (claude/codex)
- Arbiter is NOT always-on — only invoked when deadlock detected
- Arbiter renders binding verdict: PROCEED/REVISE/RESET/ESCALATE
- Non-escalate verdicts reset round_trip_count and resume ping-pong
- Backward compatible: ARBITER_AGENT_TYPE unset = existing 2-agent mode

Changes across 13 source files + 7 test files:
- types.ts: PairedRoomRole += 'arbiter', new statuses, ArbiterVerdict type
- config.ts: ARBITER_AGENT_TYPE, ARBITER_SERVICE_ID, ARBITER_DEADLOCK_THRESHOLD
- db.ts: schema migration (arbiter columns in channel_owner + paired_tasks)
- service-routing.ts: arbiter_service_id in lease
- room-role-context.ts: arbiter role detection
- paired-execution-context.ts: deadlock->arbiter, verdict handling
- message-runtime.ts: arbiter turn routing, cursor, sender labeling
- message-agent-executor.ts: arbiter mode, failover
- agent-runner.ts + environment.ts: arbiter container mode
- platform-prompts.ts: arbiter prompt loading

New files:
- prompts/arbiter-paired-room.md: arbiter system prompt
- src/arbiter-context.ts: builds conversation context for arbiter judgment
2026-03-30 22:20:42 +09:00
Eyejoker
7ee915bbeb fix: only reset round_trip_count on human messages
The counter was being reset to 0 on every owner turn, including
bot-only ping-pong turns. This prevented the 3-round-trip echo
loop breaker from ever triggering. Now only human messages reset
the counter.
2026-03-30 21:09:41 +09:00