Commit Graph

27 Commits

Author SHA1 Message Date
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
c984d972e1 paired: resync reviewer workspace to owner path 2026-04-11 20:12:53 +09:00
ejclaw
fe9d265c66 paired: repair safe owner workspace branch mismatches 2026-04-11 08:45:47 +09:00
ejclaw
81cb9bda01 Fix paired finalize re-review reentry 2026-04-07 07:06:34 +09:00
ejclaw
10e10b499c Complete paired-room SSOT cleanup and logger singleton 2026-04-07 05:12:22 +09:00
ejclaw
d75d26c23d Stabilize paired reviewer recovery and owner follow-up 2026-04-06 07:49:26 +09:00
ejclaw
446b194e2c Automate worktree dependency installs 2026-04-05 22:34:16 +09:00
Eyejoker
54abb5bb4e Apply formatter after local memory refactor 2026-04-04 03:52:28 +09:00
Eyejoker
3dd772c229 Refactor local memory and role-fixed runtime routing 2026-04-04 03:50:28 +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
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
5221fb8b33 style: fix prettier drift after merge 2026-03-30 03:44:58 +09:00
Eyejoker
e863db61a8 refactor: remove dead output suppression path 2026-03-30 03:22:08 +09:00
Eyejoker
6edf5aebbd refactor: remove explicit paired review command path 2026-03-30 01:43:48 +09:00
Eyejoker
9e0de1297c fix: /clear now resets both owner and reviewer sessions in paired rooms 2026-03-29 19:00:42 +09:00
Eyejoker
a1e5418a2f feat: auto-trigger reviewer after owner completion with round trip limit
- Owner finishes → auto mark review_ready → reviewer executes
- Reviewer finishes → task back to active → owner can respond
- Automatic ping-pong until consensus or round trip limit
- PAIRED_MAX_ROUND_TRIPS env var (default 10, 0 = unlimited)
- round_trip_count tracked per task in DB
2026-03-29 18:57:16 +09:00
Eyejoker
d01f98bd61 feat: unify 3 bot services into single process
- Add UNIFIED_MODE flag (default on, disable with UNIFIED_MODE=0)
- Register all 3 Discord bots in one process (claude, codex, review)
- Load all registered groups regardless of agent_type (codex/owner priority)
- Start credential proxy and container cleanup at unified startup
- shouldServiceProcessChat returns true in unified mode
- Add findChannelByName for role-based response routing
- Backward compatible: UNIFIED_MODE=0 restores per-service behavior
2026-03-29 18:37:17 +09:00
Eyejoker
fc9f2867b9 refactor: simplify paired review system and add reviewer container isolation
Phase 1 — Strip over-engineering (-3,665 lines):
- DB tables: 7 → 3 (remove executions, approvals, artifacts, events)
- Task statuses: 11 → 5 (active, review_ready, in_review, merge_ready, completed)
- Remove plan governance, event sourcing, gate/verdict, freshness guards
- paired-execution-context: 980 → 299 lines
- Session commands: remove /risk, /plan, /approve-plan, /request-plan-changes

Phase 2 — Container isolation for reviewers:
- Add container-runtime.ts (Docker abstraction)
- Add credential-proxy.ts (API key injection without container exposure)
- Add container-runner.ts (reviewer-specific read-only mount + tmpfs)
- Add container/Dockerfile + agent-runner (Chromium, Claude Code, Codex)
- agent-runner.ts: auto-route reviewer execution to container mode
2026-03-29 18:24:56 +09:00
Eyejoker
b536c90716 feat: add high-risk paired plan gate 2026-03-29 02:13:57 +09:00
Eyejoker
c76ed1d10a fix: reconcile governance scaffold follow-up 2026-03-29 01:38:30 +09:00
Eyejoker
dc8dd98e84 feat: scaffold paired governance state 2026-03-29 01:35:57 +09:00
Eyejoker
b0c833fd70 fix: keep review requests pending without owner workspace 2026-03-29 00:21:29 +09:00
Eyejoker
29053d3273 feat: formalize paired review command flow 2026-03-28 23:36:46 +09:00
Eyejoker
9006b92648 style: sync paired workspace sparse formatting 2026-03-28 21:34:25 +09:00
Eyejoker
eee09e8b7c fix: clean reviewer snapshots and scope git guard 2026-03-28 21:34:06 +09:00
Eyejoker
06b6326a9d style: sync paired workspace formatting fallout 2026-03-28 21:15:16 +09:00
Eyejoker
e7f49d77da feat: add paired review workspace flow 2026-03-28 21:14:25 +09:00