Repository navigation
agora v3: seats — one fleet registry, the daemon substrate folded into the agora CLI - #92
Conversation
…ipeline — execplan skill, plugin keyword, infra comments, tech-debt suite list
…h the agora CLI The five dispatch/sweep scripts reach the substrate through a new AGORA_CLI seam (path to skills/agora/scripts/agora) instead of DAEMON_SCRIPTS, and call verbs instead of scripts: daemon-spawn.sh --no-wait -> agora spawn with --cwd/--worktree/--model, daemon-retire.sh -> agora retire, daemon-finalize.sh -> agora sync, daemon-resume.sh -> agora wake --wait. review-dispatch.sh sources skills/agora/scripts/lib.sh for _identity_local and the host/boot identity. The registry default path becomes ~/.claude/agora everywhere (DAEMON_HOME keeps its name). board-answer.sh loses its codex engine branch and always wakes. Operator-facing error prose now names agora verbs.
…sume verb, atomic migration, ack'd wake, lifecycle locks, live-name refusal, codex retirement
…, and a codex-binding refusal Adopted from the plan's adversarial review. The process-level verb is `agora resume --wait` (not `wake`, which is socket-first and interactive): it stops the live turn and continues under the same id from the invoking environment, so the BOARD_RUN_* prefixes on those calls still reach the worker. Every pipeline entrypoint runs `agora migrate --quiet` right after its CLI preflight, because the registry root moved and these scripts scan it directly. board-answer.sh refuses a ticket bound to a legacy codex worker before it writes anything to the board. Tests: executing and qa-loops suites now stub ONE `agora` executable whose first argument selects the verb, exported as AGORA_CLI.
…end, sync, views, board; hermetic suite (251 assertions)
The pipeline's process-level verb is `agora resume`; `wake` is the interactive socket-first verb these scripts never call. Comments, the board-transition refusal text, the sweep's recovery-exhaustion note and the dispatch ritual in issue-tracker's SKILL.md now all say resume.
…ts and labels Comment and assertion-label sweep so nothing in the pipeline or its suites still names a script that no longer exists: drill-lib's header describes the single agora stub it now builds, board-lint's FIX hint points at `agora retire`, and the reconciliation assertions say sync rather than finalize. Behaviour unchanged; every touched suite re-run green.
…e on as agora verbs, doctrine in the agora SKILL, references repointed; execplan M2/M3 progress
…rule (flags on --bg --resume start a copy)
…ckground session keeps its saved options and any flag starts a copy; banner-based copy detection; route flags ignored on resume
…eports, shell wake, same-id re-fill)
… re-fills a retired seat, launches under addr
A swallowed `agora migrate` failure was indistinguishable from an idle fleet: a half-migrated registry reads as empty, every dedupe and cap check passes, and the tick spawns a second worker on top of every live one. All five pipeline entrypoints now abort with a named error instead, stderr visible. Every direct registry consumer resolves the root as DAEMON_HOME, then AGORA_HOME, then ~/.claude/agora, so the pipeline and agora.py (which prefers AGORA_HOME) can never split roots. review-dispatch.sh pins AGORA_HOME to the same value before sourcing agora's lib.sh, whose own resolution then becomes a no-op rather than re-defaulting the root out from under it. The execute-dispatch stub grows a STUB_MIGRATE_FAIL switch and three assertions: a failed migrate aborts, says why, and spawns nothing.
…daction, crash-safe locked migration, conditional finalize writes, live-name/pid+socket liveness, owning-repo groups, and 20 more review adoptions
…il-closed migrate)
…n-guarded conditional finalizes with in-lock replies, addr-keyed locks incl. wake/retire/remove/sync, stop-and-wait before resume, cwd refusal on resume, alias dedupe + permission tightening in migration, attempts/history, credential-field refusal
…istry re-migrated idempotently)
…e direct reads, attempts-aware streak ONE precedence rule everywhere, the agora CLI's own: $AGORA_HOME, then $DAEMON_HOME, then ~/.claude/agora, in the six shell defaults and the four Python ones. Each entrypoint exports both names at the same value, so the CLI, the board scripts and every spawned child resolve one root; _sweep_api.sh now exports too, where the agora children it calls previously fell back to the default. review-dispatch.sh drops the pinning trick — lib.sh applies the same rule, so sourcing it first leaves the root already settled. Direct registry readers migrate first: _lib.sh covers board-transition, board-register, board-lint, board-bind and board-answer; board-gc.sh, which sources nothing, carries its own. Both gate on the cutover actually being pending (the legacy root still a real directory) — a stat, not a lock. An unconditional migrate takes $DAEMON_HOME/.metalock at SOURCE time, which serialises every board script against every writer and deadlocks a caller already holding it. A re-filled seat keeps one record, so _outage_streak counts max(records, summed attempts) — three failures on one seat are one row with attempts=3 and the 3-consecutive cap was unreachable. _wt_occupied stops treating a terminated UNMANAGED row as occupying: a previous occupant of a re-filled seat is no longer keyed by `current` and would pin the worktree forever.
…d after the final wave
…; agents cannot post or send as the operator
…ormalisation, cutover gate _outage_streak counts FAILED occupants, not lifetime fills: a seat contributes itself plus the trailing run of history[] entries whose status is error or failed, stopping at the first occupant that did not fail, and rows and seat runs still combine with max() so a pre-seat registry reads exactly as before. Counting attempts retired a healthy PR after two ordinary re-reviews and one outage; two clean re-fills then one failure is now a streak of 1. _wt_occupied applies the finished-turn normalisation (state working or blocked with status idle) in the unmapped branch too — the mapped branch already read that shape as an ended turn, and an unmapped row has no record to consult. _agora_cutover_pending also reports pending when a ~/.claude/agora.v2-* aside exists: the rename landed but the groups/ merge did not, which is exactly the half-migrated root a direct reader must not read as an idle fleet. Still one stat and one glob, no lock. board-gc.sh carries the same predicate.
…s with claude-over-codex alias winners, lock-held gen snapshots and in-lock replies, locked unlink, no previous-occupant allowance, running-row-first harness lookup, run-binding clearing on re-fill, session-derived sender identity, harness-failure=unknown, live-pid codex left alone, aside board merging with warnings, sha1 sorted locks, no-resurrect writes, procStart peer check
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
# Conflicts: # skills/execplan/SKILL.md
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0dfb62f429
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| # spawn tree, and the board. The CLI lives in agora.py next to this file; this | ||
| # launcher only resolves its own real path, because the board pipeline reaches | ||
| # it through relative seams (`$AGORA_CLI`) and symlinks. | ||
| exec python3 "$(dirname "$(readlink -f "$0")")/agora.py" "$@" |
There was a problem hiding this comment.
Resolve the launcher without GNU-only readlink
On stock macOS—the supported launchd environment documented in skills/issue-tracker/references/sweep-setup.md—BSD readlink does not support GNU's -f option. It therefore produces no resolved path here, causing the launcher to look for ./agora.py relative to the caller's working directory and making every board pipeline invocation of AGORA_CLI fail unless GNU coreutils happens to be installed or the caller is already in this scripts directory. Resolve the launcher path with a macOS-portable mechanism instead.
Useful? React with 👍 / 👎.
| if prev and (prev["current"] or prev["short"]): | ||
| history.append({"current": prev["current"], "short": prev["short"], "status": prev["status"], | ||
| "ticket": str(prev.get("ticket") or ""), "ended": now()}) |
There was a problem hiding this comment.
Preserve failure stamps when archiving an occupant
When the QA sweep replaces a failed reviewer, _retire_failed first stamps retired_from=failure and then agora retire changes its status to retired; this history entry saves only that final status and omits the failure stamp, which is then removed from the current record during the refill. Consequently _outage_streak sees the new failure plus a prior retired history item rather than prior error failures, so actual repeated dead-worker cycles never reach the three-failure cap and can keep respawning reviewers indefinitely. Archive retired_from or the pre-retirement terminal status and count it in the history predicate.
Useful? React with 👍 / 👎.
| for nodes_dir in glob.glob(os.path.join(r, "groups", "*", "nodes")): | ||
| g = os.path.basename(os.path.dirname(nodes_dir)) | ||
| for nf in glob.glob(os.path.join(nodes_dir, "*.json")): |
There was a problem hiding this comment.
Make shared-session migration ordering deterministic
When a v2 session joined more than one group, the first node visited receives the original session UUID and later nodes receive deterministic surrogate IDs, but glob.glob does not guarantee filesystem ordering. The focused Agora suite demonstrates this: the other/scout2 node sometimes wins UUID 22222222-…, overwriting the expected demo/scout identity and failing the v2 desc became brief assertion. Sort the node paths or otherwise define the canonical winner before converting them so migration does not assign an existing session identity differently across machines.
Useful? React with 👍 / 👎.
| n = convert_v2_nodes(r) | ||
| if n: | ||
| did.append("converted %d v2 node(s) into seats" % n) | ||
| # Pass 2 — dedupe (group, alias): a claude record beats a codex one, | ||
| # then the newest `updated` keeps the alias. | ||
| deduped = 0 | ||
| for (g, alias), recs in by_key.items(): |
There was a problem hiding this comment.
Rebuild the dedupe index after converting v2 nodes
When a v2 node has the same (group, alias) as an existing daemon record but a different session UUID, this conversion creates a second seat after by_key was populated. The immediately following dedupe therefore cannot see the new record, so the first command after cutover exposes two seats with the same qualified name; commands such as agora retire group/alias then report no matching seat, and only a second invocation of migration repairs it. Include converted records in the current dedupe pass rather than leaving the registry inconsistent for one command.
Useful? React with 👍 / 👎.
| if s["status"] in ("working", "blocked") and identity_local(s["host"], s["boot_id"]) and pid_alive(pid): | ||
| try: | ||
| os.kill(int(pid), signal.SIGTERM) | ||
| except (ProcessLookupError, ValueError, TypeError, PermissionError): | ||
| pass | ||
| return |
There was a problem hiding this comment.
Wait for legacy Codex finalization before retiring
For a migrated live Codex worker, sending SIGTERM and returning immediately races the detached Codex wrapper, which writes its terminal idle or error status after the child exits. cmd_retire can therefore write retired first and then have the wrapper overwrite it, leaving a supposedly retired worker active in registry decisions; remove can similarly be followed by the wrapper recreating a partial record. The removed daemon-retire.sh explicitly waited for the run's .rc completion barrier before writing the retirement verdict, and the consolidated path needs the same ordering.
Useful? React with 👍 / 👎.
| lk = board_lock(g) | ||
| try: | ||
| bf = os.path.join(group_dir(g), "board.jsonl") | ||
| rec = {"id": len(read_board(g)) + 1, **body} |
There was a problem hiding this comment.
Allocate board IDs from the maximum existing ID
If board.jsonl contains an unreadable or truncated line, read_board deliberately skips it, so the count of parsed records is no longer a safe next ID. For example, valid posts #1 and #3 around a malformed line yield len(read_board) == 2, and the next post is also assigned #3; subsequent agora board --id 3 returns multiple posts and nudges no longer identify a unique message. Preserve monotonic IDs by deriving the next value from the maximum valid ID or an independent counter.
Useful? React with 👍 / 👎.
| if s["status"] == "idle": | ||
| # Only an idle seat the harness shows as running NOW is interesting — | ||
| # it was woken natively (SendMessage) with no agora write. Promote it. | ||
| if row and normalize_state(row) in ("working", "blocked"): | ||
| meta_set_if(s["seat_id"], {"status": "working", "updated": now()}, guard) | ||
| return "live" | ||
| return "noop" |
There was a problem hiding this comment.
Reconcile native turns that finish while the seat is idle
If native SendMessage wakes an idle seat and the new turn finishes before the next agora sync, the record still enters this branch with status == idle while the harness row is already done, so sync returns noop without recording the new reply or an error. Because agora reply prefers the existing reply file for idle seats, it then continues showing the previous turn indefinitely; a native turn that failed is likewise left looking clean. Handle terminal harness states in this idle-record branch, not only the still-running state.
Useful? React with 👍 / 👎.
| with open(dst, "a") as f: | ||
| for m in moved: | ||
| f.write(m + "\n") | ||
| os.unlink(src) |
There was a problem hiding this comment.
Make aside board merging crash-idempotent
The aside board is appended to the destination before its source is unlinked. If migration is killed after one or more writes but before os.unlink(src), the next automatic migration sees the intact source and appends every post again with fresh IDs, duplicating durable group history. Since the surrounding cutover explicitly retries stranded aside directories after crashes, merge the destination through an atomic replacement or record enough progress to make this retry idempotent.
Useful? React with 👍 / 👎.
…d-neighbours observations
…age streak `agora retire` writes status=retired over whatever terminal status the failure left, so a failed occupant reads `retired` once it has been retired into history — which is why _retire_failed stamps retired_from=failure first. The streak now reads that stamp on history entries exactly as it already did on records, via one shared predicate: status error or failed, OR retired_from=failure. Without it the streak forgot every failure the moment its occupant was retired, and the 3-consecutive cap was unreachable for the dead-worker cycle it exists for. The seat-record test helper accepts a full occupant object as well as a bare status, and two assertions pin the stamp: two re-fills recorded as status=retired with retired_from=failure, plus a current failure, reach the cap and name it as the skip reason. No _sweep_api.sh counterpart exists — its _attempts is a per-ticket board counter, not a seat streak.
…ation for natively-woken seats, codex rc barrier, repoint refusal, board id from max
Summary
agora v3 — seats. The
orchestrating-daemonsbash substrate is folded into theagoraCLI (now a stdlib-only Python core behind a 6-line bash launcher), and the two half-registries become one. The unit is the seat: a named position in a group, with a role, that a Claude Code session fills and that outlives the process filling it. Every background session spawned through agora is a seat — board-pipeline workers included — soagora listis the whole fleet andagora view <group>is one group's organisation chart with live state on every node.What lands:
~/.claude/agoraon the existing daemon-meta layout (seat record = the<uuid>.jsonmeta plusalias/group/parent/addr/role/brief/now,gen,attempts,history), so the board pipeline's direct writers keep working with only a default-path change. First run migrates by atomic rename under a lock and leaves~/.claude/orchestrating-daemonsas a symlink; historical same-alias duplicates are renamed, permissions tightened to 0700/0600.spawn,seat add(+join),fill [--resume],wake,resume,send,reply,sync,mark,status,retire [--purge],remove,list,view,topology,groups,post,board,attach,migrate,meta.wake/sendwrite a frame to a live session's native inbox socket (idle sessions start a turn; the shell can now reach an agent); a stopped session continues under the same id with a bareclaude --bg --resume(a background session keeps its saved options — any flag starts a copy).resumeis the process-level verb the board pipeline relays through (itsBOARD_RUN_*env must reach a fresh process). Fork-chain, purge, andcurrentchurn are gone.gencounter guards every late write so a retire can never be undone by a stale watcher;run_bearerand other secrets never reach model-visible output (list --json,topology,meta get); sender identity forsend/wake/postderives fromCLAUDE_CODE_SESSION_IDand an agent cannot claim--from human; a harness listing failure reads asunknown, never as an empty fleet.executing,qa-loops,issue-tracker) toagora spawn/resume/sync/retirethrough theAGORA_CLIseam; wire formats frozen ([<short> / <seat-id>]banner,syncvocabulary);migrateruns fail-closed at every entrypoint and before direct registry reads; one registry-root precedence rule (AGORA_HOME, thenDAEMON_HOME); outage streak counts failed occupants fromhistory; the codex-CLI engine branch is gone.skills/orchestrating-daemons/and its tests deleted; doctrine absorbed intoskills/agora/SKILL.md; every cross-reference repointed (skill-links linter green).Verification
tests/agora/run-agora-tests.sh: stubclaude(bg banner, agents --json, same-id resume + copy modes, transcripts), a real unix-socket inbox server, fabricated peer records, v1/v2/legacy-codex fixtures, an integration-shaped spawn→retire→spawn case pinning banner == record filename.SCOUT-READYarrived unprompted;agora sendfrom the shell woke an idle seat;retire+fill --resumecontinued the same session id.review --base mainas closure.Plan
docs/doperpowers/execplans/2026-09-02-agora-seats.md— living ExecPlan: Decision Log (grill decisions, review adoptions, two round-1 adoptions reversed in round 2), Surprises (saved-options resume rule; two harness rows per session id after a resume; run-identity boundary; the stub-on-both-sides test gap), Artifacts (live transcripts).