Repository navigation
Live worker bindings fence the state machine; resume mutex; review-sweep priority cohort (dp#63, dp#66, dp#64) - #80
Conversation
board-transition consulted only labels: 'already in-progress' was the sole conflict signal, so an orchestrator two-hop-closed a ticket a dispatched worker was mid-turn on, and both sessions shipped independent solutions (ida#1584/obra#1589). The guard runs ahead of the mode fork, in both bindings: a ticket bound in the local daemon registry to a live (host+boot, board-bind's rule) worker in a mid-turn status (working/blocked) refuses every transition except the binding owner's own session (CLAUDE_CODE_SESSION_ID vs the meta's uuid/current). Deliberate exceptions state a reason in BOARD_OWNER_OVERRIDE and are acknowledged on stdout; the sweep's recovery-cap park — the one sanctioned cross-session transition on a live binding — rides it. board-api suites now pin DAEMON_HOME to an empty per-run registry: the guard adjudicates on the local registry, and an operator's real bindings would otherwise inject refusals into fixtures that reuse the same ticket numbers.
Two concurrent daemon-resume invocations raced the current-chain: both forked from the same turn, one fork was purged or orphaned, and the meta's status/current landed on whichever wrote last — observed live as two wrappers holding a five-hour watch (DAEMON_TIMEOUT's 9000x2s default) on a dead fork while a critical-path ticket sat silent, meta stuck working (ida-worker-1, ticket obra#1048). The mutex is a per-daemon flock taken non-blocking on fd 9 and held for the wrapper's whole lifetime: the locking child inherits the fd so the lock lands on the shared open-file description, and the kernel releases it the moment the wrapper dies — a dead holder can never wedge a successor, with no timeout or stale-pid bookkeeping. A twin resume is refused loudly before any mutation (no stop, no fork, meta untouched). The fork invocation closes fd 9 so the detached agent never carries the lock past the wrapper's life; the test proves that with a lingering fd-holding stub child, mutation-verified.
…r closed tickets Two review findings against the dp#63 fence, both real: Ticket numbers are board-local but the daemon registry is machine-global, so a live worker on another board's #9 fenced every transition of this board's #9. board-bind now stamps the binding's board key (gh:<owner/name> / api:<url>) into the meta, and the fence matches it against its own board; a pre-stamp meta still fences (bindings live hours — the ambiguity ages out). A ticket already CLOSED on GitHub is past preventing: lingering working metas on merge-auto-closed tickets are routine (--no-wait workers finalize on the dispatcher's cadence, not the merge's), and refusing the idempotent finalize write (label strip + terminal sweeps) only delays bookkeeping. On the would-refuse path, gh mode probes the issue state once and stands down when it is closed; an unreadable probe still fails closed.
The sweep's candidate walk rides gh pr list's newest-first server order, so under sustained inflow that keeps REVIEW_MAX_CONCURRENT full, an old cohort's turn never comes — observed live as 11 hardening PRs stalled two days (three with no reviewer meta ever created) while fresh main PRs reviewed and landed. REVIEW_PRIORITY_LABEL names an opt-in first-pass cohort: PRs carrying the label enumerate ahead of the rest, order untouched within both groups (one stable sort over the listing the sweep already fetched — labels were already in the JSON). Unset, the enumeration is byte-identical to before. An ordering hint, not a gate: nothing is skipped, the deferred cohort still queues and is still reported by name.
…iority cohort Three adopted, one declined, from the whole-branch review: - A resumed legacy codex-CLI turn has no harness session id, so the fence could not recognize it as its own ticket's owner. codex-resume now hands the daemon uuid over explicitly (DAEMON_SELF_UUID) and the fence accepts it as the owner identity. - Board keys compare normalized: _board_api.url() strips a trailing slash, so "api:http://x/" and "api:http://x" name one board — a raw compare let a slash spelling unfence a live owner. Stamp and compare both normalize now, and the API-mode fence has wire-level drills (refusal never reaches the server; the owner passes). - The dp#64 cohort can sit beyond the 100-newest window the main listing sees. With the hint on, a dedicated --label listing fetches the cohort: its rows lead the enumeration and count as open for the cleanup pass, so an out-of-window labeled PR is neither starved nor retired as "gone". - DECLINED: serializing the fence scan against the registry metalock. The window is a bind publishing mid-transition; closing it means holding the machine-wide meta lock across the transition's own gh/API calls, and gh mode has no arbiter to give the pair a total order anyway. The fence targets the hours-scale divergence, not linearization — now said in the code.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9be2f7d1a3
ℹ️ 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".
| # The BOARD the ticket number belongs to. Ticket numbers are board-local | ||
| # but this registry is machine-global, so the transition fence (dp#63) | ||
| # needs the pair to adjudicate — a live worker on another board's #9 says | ||
| # nothing about this board's #9. Same shape the fence computes for itself. | ||
| target_meta["board"] = ("api:" + env.get("BOARD_API_URL", "").rstrip("/")) \ |
There was a problem hiding this comment.
Scope incumbent owners to the current board
The new board field does not make bindings board-scoped because the owners query above still matches only the ticket number. With the default machine-global registry, a live worker bound to repo A's #9 therefore prevents binding repo B's #9; if that worker is idle, binding repo B instead deletes repo A's ticket field. Filter incumbent owners by the same normalized board key before applying exclusivity or stripping old owners.
Useful? React with 👍 / 👎.
| printf '%s' "$pr_list_json" \ | ||
| | python3 -c ' | ||
| import json, re, sys | ||
| for p in json.load(sys.stdin): | ||
| | PR_PRIO_JSON="$pr_prio_json" python3 -c ' |
There was a problem hiding this comment.
Pass priority JSON outside the process environment
pr_prio_json contains titles and full bodies for up to 100 PRs and is exported as one environment variable when launching Python. On systems with a per-argument/environment-string execve limit, a sufficiently large priority cohort makes this fail with Argument list too long; because the enumeration pipeline is unguarded under set -euo pipefail, the entire sweep exits without dispatching any reviewer. Stream the two JSON documents separately or use a temporary file instead of placing the cohort payload in PR_PRIO_JSON.
Useful? React with 👍 / 👎.
| if ! python3 -c 'import fcntl,sys | ||
| try: fcntl.flock(9, fcntl.LOCK_EX | fcntl.LOCK_NB) | ||
| except OSError: sys.exit(1)'; then | ||
| holder="$(cat "$DAEMON_HOME/$uuid.resume.lock" 2>/dev/null || true)" | ||
| echo "daemon-resume: a resume of $uuid is already in flight${holder:+ ($holder)} — not spawning a twin (dp#66). The mutex releases the moment that process exits; check it with daemon-list.sh / ps before trying again." >&2 | ||
| exit 1 |
There was a problem hiding this comment.
Do not charge refused sweep resumes against the recovery cap
When a sweep-started resume remains in flight and its worker is still silent past SWEEP_STALL_MINUTES, the next sweep calls _recover again; board-sweep.sh increments sweep_recoveries before launching this script, but this new mutex then refuses the launch. Repeated ticks therefore consume the default three-attempt recovery cap without starting additional recovery turns and eventually park a live ticket as needs-human. The caller needs an atomic way to acquire the mutex before incrementing the counter, or the refusal must roll that counter back.
Useful? React with 👍 / 👎.
| pr_prio_json="$(gh pr list -R "$BOARD_REPO" --state open --limit 100 \ | ||
| --label "$REVIEW_PRIORITY_LABEL" \ | ||
| --json number,isDraft,labels,title,body,closingIssuesReferences)" \ |
There was a problem hiding this comment.
Fetch the entire labeled priority cohort
When more than 100 open PRs carry REVIEW_PRIORITY_LABEL, this dedicated listing still returns only 100 of them; the installed gh pr list --help defines --limit as the maximum number of items fetched. Any older labeled PR outside that result and the main newest-100 window remains undispatched, so sustained labeled inflow recreates the starvation this option is meant to prevent. Raise the limit to the supported cohort size or paginate until the labeled listing is exhausted.
Useful? React with 👍 / 👎.
Three reliability fixes in the worker-orbit, each TDD'd against its hermetic suite, plus two rounds of independent codex review (gpt-5.6-sol) with findings adopted or declined on the merits.
dp#63 — a live worker binding is now a transition guard
Closes #63.
board-transition.shconsulted only labels — "already in-progress" was the sole conflict signal — so an orchestrator two-hop-closed a ticket a dispatched worker was mid-turn on, and both sessions shipped independent solutions (ida#1584/obra#1589).The fence runs ahead of the mode fork, in both bindings: a ticket bound in the local daemon registry to a live (host+boot, board-bind's rule) worker in a mid-turn status (working/blocked) refuses every transition except the binding owner's own session. Owner identity is
CLAUDE_CODE_SESSION_IDvs the meta'suuid/current(every dispatched worker is a claude-harness session), plus an explicitDAEMON_SELF_UUIDchannel for resumed legacy codex-CLI turns. Deliberate exceptions state a reason inBOARD_OWNER_OVERRIDEand are acknowledged on stdout — the sweep's recovery-cap park rides it.Review-driven hardening: bindings are board-scoped (
board-bindstampsgh:<owner/name>/api:<url>, normalized the way_board_api.url()normalizes — ticket numbers are board-local, the registry is machine-global), and the fence stands down for tickets already closed on GitHub (lingeringworkingmetas on merge-auto-closed tickets are routine; refusing the idempotent finalize only delays bookkeeping). Declined: serializing the fence scan against the registry metalock — that trades a millisecond race for seconds of machine-wide bind starvation, and gh mode has no arbiter to order the pair anyway; the fence targets the hours-scale divergence, not linearization (now stated in the code).dp#66 — one resume per daemon at a time
Closes #66.
Two concurrent
daemon-resume.shinvocations raced the current-chain: both forked from the same turn, one fork was purged or orphaned, and status/current landed on whichever wrote last — observed live as two wrappers holding a five-hour watch (DAEMON_TIMEOUT's 9000×2s default; the "5시간 반" in the issue is this bound) on a dead fork while the ticket sat silent.The mutex is a per-daemon flock taken non-blocking on fd 9 and held for the wrapper's whole lifetime: the kernel releases it the moment the process dies, so a dead holder can never wedge a successor — no timeouts, no stale-pid bookkeeping. A twin is refused loudly before any mutation. The fork invocation closes fd 9 so the detached agent never carries the lock; the test proves that with a lingering fd-holding stub child, and the assert is mutation-verified (removing
9>&-fails exactly that test).dp#64 — opt-in priority cohort for the review sweep
Closes #64.
--sweepridesgh pr list's newest-first order, so sustained inflow under a fullREVIEW_MAX_CONCURRENTstarved old cohorts (11 hardening PRs stalled two days, three with no reviewer meta ever created).REVIEW_PRIORITY_LABELnames an opt-in first-pass cohort: labeled PRs enumerate first via a dedicated--labellisting (found even beyond the main listing's 100-newest window, and counted as open for the cleanup pass so they are never retired as "gone"), stable order within both groups. Unset, the enumeration is byte-identical to before. An ordering hint, not a gate.Tests
tests/issue-tracker/test-board-scripts.sh— 14 new fence drills (refusals, owner by uuid/current/daemon-uuid, dead-boot, idle, override, cross-board, closed-finalize)tests/claude-code/board-api/test-register-transition.sh— API-binding fence drills at the wire (refusal never reaches the server; slashed board-key spelling still fences; owner passes);helpers.shnow pins a hermetic per-runDAEMON_HOMEtests/orchestrating-daemons/test-daemon-scripts.sh— 6 mutex drills incl. the fd-inheritance prooftests/qa-loops/test-review-dispatch.sh— priority pre-pass ordering + beyond-window cohortVersion: 7.59.0.
🤖 Generated with Claude Code