Commit Graph

78 Commits

Author SHA1 Message Date
Codex
c858b6e446 feat: scope paired owner/reviewer sessions to one paired task
Each paired room used to resume one owner (and one reviewer) session for
weeks, so every call re-read a huge unrelated history (median ~260k input
tokens). A stored session is now resumed only while it belongs to the
running paired task; the first turn of a new task starts fresh and the new
session is bound to that task (router_state paired_session_task:<folder>,
survives restarts). Later turns of the same task (revisions, follow-up
human messages while the task is open) keep resuming it. Arbiter was
already fresh per call; single rooms are unchanged.

The previous task's final answer still reaches the new session through the
carried-forward turn-0 output, so PAIRED_CARRY_FORWARD_LATEST_OWNER_FINAL
now defaults to true.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-01 20:25:35 +09:00
Codex
8c68577a24 refactor: replace the Claude→Codex failover with a usage-limit notice
When Claude hit a limit the run was handed to a Codex service
(codex-main/codex-review) through service_handoffs and a global owner
failover. That service does not exist in this deployment, so handoffs
stayed pending forever (2 rows since May) and the user got no answer.

Removed:
- handoff creation (message-agent-executor-handoff, paired-turn-fallback)
  and the delegated paired-execution path
- the pending-handoff poll/claim worker (message-runtime-handoffs) and the
  service_handoffs CRUD module (db/service-handoffs, db exports)
- global owner failover in service-routing, its recovery timer in index,
  the dashboard failover line, the codex-review failover prompt pack and
  prompts/codex-review-failover-platform.md
- failoverOwner in RoomRoleContext and the `failover=` ROOM_ROLE field
- OWNER_/REVIEWER_/ARBITER_FALLBACK_ENABLED and FAILOVER_MIN_DURATION_MS
- tests for the removed behaviour

Now, when a Claude run fails with a usage/rate limit (trigger reason
429 or usage-exhausted) the executor closes the open paired task as
completed/claude_usage_limit and sends the room one final notice:
"Claude 사용 한도에 도달했습니다. 21:40에 재개할 수 있습니다." The reset time
comes from the error text (CLI banner "resets 9:40pm (Asia/Seoul)", dated
banners, "try again at ...", ISO timestamps), else from the cached usage
API window at 100%, else "잠시 후 다시 시도해 주세요". Nothing retries
silently; the next user message starts a new task. Other Claude failures
(session failure, org access denied) now end as ordinary run errors.

The service_handoffs table, its columns on paired_turn_attempts and the
migrations stay untouched for the later migration squash; the runtime no
longer reads or writes them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-01 20:14:48 +09:00
Codex
a9eab5cb94 refactor: run Claude and Codex on one fixed account each
The deployment has a single Claude OAuth credential and a single Codex
ChatGPT account, so the N-account rotation machinery only added state
files, cooldown bookkeeping and code paths that never ran.

Removed:
- Claude token rotation (token-rotation.ts, token-rotation-base.ts):
  rotate-on-limit, per-token cooldowns, token-rotation-state.json.
  CLAUDE_CODE_OAUTH_TOKENS is still read, but only its first entry.
- Codex account rotation (codex-token-rotation.ts): account pool,
  rotate-on-429/auth, dead-auth/cooldown tracking, round-robin advance,
  d7 auto-rotate, codex-rotation-state.json, manual account switch.
- Account index plumbing in token-refresh, claude-credentials-path
  (CLAUDE_ACCOUNTS_DIR / ~/.claude-accounts/<n>), Claude/Codex usage
  collectors, the dashboard rows and the Codex warm-up.
- provider-retry.ts rotation loops and the Codex retry path.

Kept:
- Codex exclusive auth lease (one Codex run at a time), the 15-minute
  waitForCodexAuthLease, and a usage-poll lease that skips while a run
  holds the account (codex-auth.ts).
- Session auth copy and write-back of refreshed tokens
  (syncCodexSessionAuthBack, syncClaudeSessionAuthBack).
- Codex auth path: ~/.codex-accounts/0/auth.json, else ~/.codex/auth.json
  (now resolved per run, so a re-login needs no restart).
- Claude token refresh loop, CLAUDE_CREDENTIALS_PATH and the
  CLAUDE_TOKEN_REFRESH_* / CLAUDE_USAGE_USE_HOME_CREDENTIALS flags; an
  auth-expired run still force-refreshes the token and retries once.
- Error classification (classifyClaudeTrigger, classifyCodexTrigger).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-01 20:14:38 +09:00
Codex
f127ac7a2b refactor: remove the main room concept
No room has room_settings.is_main = 1, so every main-only path was dead,
and admin work is done from the host shell. Each room's agent may now
only act on its own room:

- IPC: messages/inbound injection only to the source room; schedule,
  update, pause, resume and cancel only for the source room's tasks;
  drop the assign_room and refresh_groups IPC tasks and the deps they
  needed (assignRoom/syncGroups/getAvailableGroups/writeGroupsSnapshot)
- DB/host evidence is always scoped to the source group folder
- runner MCP server: drop the assign_room tool, the target_group_jid
  parameters and the isMain flag; list_tasks shows only the room's tasks
- drop EJCLAW_IS_MAIN, RunnerInput.isMain and AgentInput.isMain; the
  global CLAUDE.md memory is now included for every room
- drop the available_groups.json snapshot (available-groups.ts), the
  inferred restart announcement that only went to the main room, and
  the unused Channel.syncGroups hook
- setup register: drop --is-main; deregister-room: drop the main-room
  refusal and --force, and fix its unknown[] binding type error
- remove the groups/main/ template

The room_settings.is_main column and migrations are untouched; new rows
get the column default (0) and nothing reads it anymore.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-01 19:37:29 +09:00
Codex
60ff19177a refactor: remove Mixture of Agents and Kimi usage
MOA_* was never configured, so enrichArbiterPromptWithMoa always
returned the prompt unchanged and the Kimi usage fetch only produced an
empty dashboard row. Remove src/moa.ts, src/kimi-usage.ts, the arbiter
prompt enrichment, MoA config/schema, the Kimi row and MoA line in the
Discord status dashboard, and the MOA_* / unused FALLBACK_* provider
examples from the docs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-01 19:10:19 +09:00
Codex
f1abe037e9 perf: cut background polling and log noise
- Codex usage poll: run the repo-pinned CLI (0.159.3) instead of a global
  0.128 install, hold the account lease while polling (skip if a run holds
  it, so the poller cannot rotate a token under a live reviewer session), and
  poll every 5 min instead of every minute (~1,440 app-server spawns a day).
- Claude usage poll: 5 min instead of 1 min. The 1-minute cadence only served
  the auto-paired-mode gate, which is not wired into the runtime; it drew ~32
  HTTP 429s a day.
- Dashboard duplicate cleanup: was a 2 s poll fetching 100 messages (~43k
  Discord REST calls a day) plus a fetch after every edit. Clean up only when a
  fresh status message is posted or on first render, with a 5 min sweep.
- Logging: one line per event and no ANSI colors outside a TTY (events were
  split into ~11 journal lines). Progress-edit audits, Discord progress edits,
  streamed-activity and per-bucket Codex usage logs move to debug; sends,
  agent output and the usage summary stay at info.
- Two tests wrote under the real data/ipc and left fake room folders that the
  live 1 s IPC watcher kept polling; they now clean up after themselves.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-01 18:32:14 +09:00
Eyejoker
7fc558acb6 fix: restore main quality checks 2026-06-02 18:37:37 +08:00
Eyejoker
6b51315eb1 chore: update Claude agent SDK 2026-05-29 03:56:19 +09:00
Eyejoker
f240cf7820 [codex] Recover Codex context overflow sessions 2026-05-19 21:52:54 +09:00
ejclaw
2b32b72119 paired: decouple unsafe host mode from fresh reviewer sessions 2026-04-22 06:47:52 +09:00
ejclaw
8fff703f84 test/runtime: align executor specs and bundled cli resolution 2026-04-20 13:33:13 +09:00
ejclaw
2ab3bddc0e Recover Codex compaction failures in paired owner flow 2026-04-15 03:11:14 +09:00
ejclaw
a858cc0cab paired: suppress stale finalize retries 2026-04-11 09:18:47 +09:00
ejclaw
d8b34db92c fix: persist direct terminal verdicts for paired reviewers 2026-04-10 23:41:41 +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
c67bd1c622 Finalize turn-role invariants and legacy migration cutover 2026-04-10 11:44:34 +09:00
ejclaw
4f557a3b85 style: apply prettier formatting 2026-04-09 14:29:49 +09:00
ejclaw
a632137198 fix: suppress paired completion status reentry 2026-04-09 14:29:14 +09:00
ejclaw
000e672ca8 style: apply prettier formatting 2026-04-09 13:55:59 +09:00
ejclaw
0f994ab2ce fix: harden paired runtime turn coordination 2026-04-09 13:52:42 +09:00
ejclaw
0f751af151 Stabilize paired follow-up routing 2026-04-08 03:50:06 +09:00
ejclaw
f9d9c2af6d Refactor paired runtime orchestration 2026-04-07 23:45:53 +09:00
ejclaw
363b1d408b Fix paired owner completion handoff race 2026-04-07 17:55:50 +09:00
ejclaw
75066f345d Deduplicate paired reviewer handoffs 2026-04-07 08:07:25 +09:00
ejclaw
81cb9bda01 Fix paired finalize re-review reentry 2026-04-07 07:06:34 +09:00
ejclaw
ae12b157be Persist paired turn output before final delivery 2026-04-07 03:38:16 +09:00
ejclaw
58b20fad6c Format retry transition refactor files 2026-04-07 02:50:08 +09:00
ejclaw
9d8c97a8e2 Fix reviewer-to-owner follow-up race 2026-04-07 01:22:27 +09:00
ejclaw
cbb6bc97c7 Refactor paired execution flow boundaries 2026-04-07 00:45:17 +09:00
ejclaw
f22947ba61 Fix paired turn follow-up scheduling 2026-04-06 21:58:22 +09:00
ejclaw
1a6ffa55af Avoid duplicate paired follow-up scheduling 2026-04-06 21:09:46 +09:00
ejclaw
5b832042da Format files touched by executor refactor 2026-04-06 19:40:36 +09:00
ejclaw
8daa3d4779 Refactor agent executor retry and follow-up flow 2026-04-06 19:39:56 +09:00
ejclaw
4650abbd10 Rename readonly reviewer runtime remnants 2026-04-06 17:27:16 +09:00
ejclaw
bf55ad65fd Format files touched by reviewer runtime cleanup 2026-04-06 07:56:59 +09:00
ejclaw
d75d26c23d Stabilize paired reviewer recovery and owner follow-up 2026-04-06 07:49:26 +09:00
ejclaw
2983e0501c Serialize merge-ready owner finalize handoff 2026-04-05 20:11:14 +09:00
Eyejoker
3dd772c229 Refactor local memory and role-fixed runtime routing 2026-04-04 03:50:28 +09:00
Eyejoker
ca58e8c8eb fix: honor handoff agent type during failover 2026-04-01 03:13:05 +09:00
Eyejoker
60f360b5ea fix: preserve handoff roles during failover 2026-04-01 02:54:35 +09:00
Eyejoker
c76126bd58 refactor: replace Memento MCP with local memory 2026-03-31 23:22:50 +09:00
Eyejoker
141898f764 refactor: scope runtime log context 2026-03-31 17:23:43 +09:00
Eyejoker
1c87616c44 fix: support same-service tribunal runtime 2026-03-31 14:01:31 +09:00
Eyejoker
7f8a361f24 refactor: wire role agent plan into runtime 2026-03-31 09:41:40 +09:00
Eyejoker
7085711a7f feat: auto-notify user on paired task completion with @mention
- done → ✅ 작업 완료
- escalated → ⚠️ 자동 해결 불가
- arbiter_escalated → ⚠️ 중재자: 사람 개입 필요
- stopped → no notification (user initiated)
2026-03-31 04:29:24 +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
dddf18428e fix: /stop leaves stale paired task, sawOutput guard, progress text overwrite
- /stop now resets the active paired task to completed so the next
  user message routes to the owner instead of the stuck reviewer
- Owner completion with sawOutput=false (e.g. interrupted by /stop)
  no longer auto-triggers the reviewer — treated as interrupted
- Clear pendingProgressText when intermediate updates arrive on an
  existing progress message, preventing flushPendingProgress from
  overwriting latestProgressText with stale buffered content
2026-03-31 02:54:04 +09:00
Eyejoker
68901e5da9 feat: global failover + dashboard model config section
- Failover is now global (account-level, not per-channel)
- Dashboard shows role model config (Owner/Reviewer/Arbiter + MoA refs)
- Dashboard shows failover status when active
- Auto-clear failover on successful Claude rotation
- Remove per-channel lease writes from failover path
2026-03-31 00:38:29 +09:00
Eyejoker
f98dd27712 refactor: MoA uses lightweight API references + SDK arbiter as aggregator
Instead of spawning separate processes or using OpenRouter, MoA now:
- Queries external API models (Kimi, GLM) in parallel for opinions
- Injects opinions into the SDK arbiter's prompt
- The existing subscription-based arbiter aggregates all perspectives

No extra SDK processes, no OpenRouter dependency. Per-model config via
MOA_REF_MODELS + MOA_{NAME}_MODEL/BASE_URL/API_KEY env vars.
2026-03-31 00:26:24 +09:00