Skip to content

A2: plugin board adapter — API binding for the issue-tracker toolkit and dispatchers (v7.42.0) - #50

Merged
SSFSKIM merged 55 commits into
mainfrom
feature/a2-board-adapter
Aug 10, 2026
Merged

SSFSKIM merged 55 commits into
mainfrom
feature/a2-board-adapter

Conversation

@SSFSKIM

@SSFSKIM SSFSKIM commented Aug 10, 2026

Copy link
Copy Markdown
Owner

Closes #44.

A2 of the Arkho roadmap: the issue-tracker toolkit and both dispatchers speak the live A1 board service (https://arkho-board-service.onrender.com) as a per-repo binding (.doperpowers/board.json). gh mode is untouched and remains the default — a repo with no binding file behaves byte-identically to pre-A2.

What's here (52 commits, spec docs/doperpowers/specs/2026-08-09-a2-board-adapter-design.md v1.2.8, plan-driven via subagent-driven development, 14 tasks each review-clean):

  • _binding.sh + credential/principal precedence (run token → operator files; bearers at rest 0600, never printed/argv'd)
  • _board_api.py stdlib client — 15 route wrappers, nested error envelope, transport-only retry
  • API branches in every board verb; new board-comment.sh (both modes, typed --kind events); protocols substituted once, binding-neutral after
  • Claim-based dispatch (implementer/spike/architect/qagent lanes) with nonce journals, five-way reconcile, credential injection; shared _claim_journal.sh
  • Four-phase sweep _sweep_api.sh: lease renewal + bind repair, sentinel relay (delivery-gated ack), resume-first fold, suppression + env-issue escalation; versioned lock-owner identity; whole-tick budget
  • Three test tiers: 11 unit suites (mock server), 7 integration drills against a real A1 on scratch Docker Postgres, and a live smoke (acceptance 8) incl. the A1.G3 epic-recomposition walk and the architect verdict as a run actor
  • Five-round external review loop after the 14 tasks: 33 confirmed findings adjudicated and fixed (one rejected against a live-verified fence), then 8 → 3 → 3 → 1 in convergence rounds; every fix RED-proved
  • origin/main PR feat(review-loop): retire confident-ready — confident verdicts merge; wave cap 4 #48 (confident-ready retirement) merged and reconciled; drills rerouted onto edges both canons hold

Known follow-ups (registered separately): legality-table drift between gh LEGAL and A1 LEGAL_ROWS — headlined by the post-#48 run-actor in-review → done close, which A1 refuses for leaf tickets, so API-mode review workers cannot write their final edge until A1 rules; A1 contract gaps flowed back to arkho#7 (ticket-body read route, claim-successor parentPin, park-note field, pr-required message body).

Live-smoke residue on the production board: drill tickets #2–#6 all terminal, one automation principal row (a2-live-smoke-automation-20260809T200844Z) — retiring it needs one UPDATE, which the insert-only drill rule forbade.

Version: v7.42.0 (main shipped 7.41.0 mid-flight; minor bump lands above it).

SSFSKIM added 30 commits August 9, 2026 22:58
…odies (principal defaults, retry, run_bearer; v1.2 refs)
The toolkit's only HTTP surface for the Arkho board API: request assembly,
principal resolution, contract error mapping, retry. python3 stdlib only.
Every function in the plan's pinned interface block, verbatim.

API.md wins over the plan on the error envelope. The plan's fixtures and its
request() body both read a flat {"error": "fence-mismatch", "message": ...},
but API.md section 1 and the shipped src/server.js both write it nested:
{"error": {"code": ..., "message": ...}}. Not cosmetic — the identifier is
what every die() surfaces verbatim and what RunEnded routes on, so a flat
reader degrades every contract refusal to an opaque http-409 and never
raises RunEnded at all. Logged in the spec's Surprises + Revision Notes;
the plan's later task bodies still carry flat 409 fixtures to correct.

_error() is isinstance-guarded so a non-envelope body (a proxy's 502, an
empty 404) dies diagnostically instead of raising AttributeError on a str.
It does not quietly accept the flat shape: that degrades to http-409 with
the raw payload, so a wrong-shaped fixture still fails loudly.

Tests hit the mock over real HTTP; the three principal cases assert on the
mock's request log, since the Authorization header is invisible from the
client side. Mutation-tested: a flat-envelope parse and a principal-before-
run-token ordering are each caught. Two brief deviations the mutations
forced — the 409 assertion now expects the whole formatted line (the bare
'fence-mismatch' substring also matches a stringified envelope dict), and
the run-token-beats-a-named-principal half of Codex F5 got its own case.
Ephemeral port and a readiness poll replace 8471 and sleep 0.3.
list prints server-ordered rows under an explicit "order is server-owned"
header and drops the ELIGIBLE/waiting/CLOSE? tags (the server owns the pick,
and blocked-by edges and PR linkage are not in the v1 payload). show prints
the ticket row plus its server-side timeline. reconcile reads the wake queue,
the resume backlog and unowned lane tickets, then runs lint for the local
registry half. lint keeps the one check no server can make — a daemon bound
to a ticket the board closed or never had — and says the schema is
server-enforced. map branches only its snapshot source: the API payload
normalizes into the same node shape, so the renderer runs unchanged, and the
table declares the edge class it cannot show.
API mode: after the registry ownership write, POST /runs/<id>/bind with the
session locator (storeNs local:<hostname>, projectKey from BOARD_ROOT,
sessionId the resolved daemon uuid), then record run_id / fence / run_bearer /
bind_confirmed into the daemon meta at 0600.

The gh-mode half needed two changes to be reachable at all in API mode:
- the board snapshot (and the ticket resolution it feeds) is gh-only, so API
  mode validates the ticket ref numerically instead;
- the live-owner and parked-owner stability rules are local adjudication the
  server has already made. The successor path exists precisely because the
  predecessor run was reaped with its meta still marked working and still
  holding the ticket, so the live-owner rule would refuse the handover the
  board just authorized.

Registry rewrites now preserve file mode: a bound meta holds the run bearer at
0600, and the ownership write (both the target and the stripped predecessor)
recreated it at the default umask.
The binding is resolved before the gh probe, so an api-bound repo dispatches
reviewers on a machine with no gh: --sweep reconciles the claim journal (its
own lane only — the directory is shared with implement-dispatch) and then
claims qagent up to REVIEW_MAX_CONCURRENT, counting open reviewers off the
registry and sending the same number as laneCap. The triggered <pr> form
fails loud naming arkho#7: the board has no PR listing to trigger off.

One claim is: journal the nonce, POST /runs/claim, write the assignment body
beside the journal, journal the run id, render the bootstrap in the new `api`
mode, spawn the reviewer with BOARD_RUN_TOKEN/ID/FENCE and BOARD_API_URL in
its environment, mark spawn_completed, bind, open the startup barrier, wait
for the worker's ack, and stamp lane/role/nonce into the registry meta. Every
failure after the grant ends the run as abandoned and drops the journal.

The handover reuses _spawn_reviewer rather than duplicating it: it gains an
optional worktree NAME (the API path has no PR to detach at, so daemon-spawn
cuts the worktree) and a claim-journal hook that marks the spawn between the
spawn and the bind. Its claude route now clears DAEMON_CLAUDE_SETTINGS for the
same reason it pins the effort — an ambient gateway would otherwise ride every
later resume.
…on + env-issue escalation

Phase 3 (resume-first): /runs/needing-resume → claim-successor → persist the
successor run/fence/bearer into the predecessor meta BEFORE any delivery →
daemon-resume with those credentials re-injected → ack the folded answers →
bind. Unrelayed answers for the ticket ride the same resume behind the relay
sentinel (one relay mechanism, two vehicles); the ack is delivery-gated.

A resume that cannot deliver falls back to a fresh spawn on the SAME successor
bearer, carrying the claim body and the timeline-read direction. Three failed
cycles register an env-issue as automation and write a suppression record —
automation holds no transition authority, so the stuck ticket is never parked.
Suppression lifts when the ticket moved or the env-issue closed.

An EXPIRED RESUME WAIT IS NOT A FAILED DELIVERY: daemon-resume forks the turn
and injects the prompt before it blocks, then exits 1 when the bounded watcher
expires — the ordinary outcome for a successor turn longer than the bound this
tick needs to avoid starving lease renewal. A per-run transcript marker
separates that from a genuine failure; without it every slow successor would
be double-workered by the fresh-spawn fallback.

Phase 4 hands the tick to implement-dispatch/review-dispatch in API claim mode
with the suppression directory they already read.
The board-api tier drove a fixture mock everywhere: a payload the mock
happily accepts could still be wrong against the service. This adds the
tier that cannot be fooled that way.

harness.sh brings up a throwaway Postgres and boots $ARKHO_DIR/board-service
against it on 127.0.0.1:8917, waits for /healthz, mints an automation and a
human principal, and writes .harness/env.sh + creds.env for the drills to
source. `stop` kills the service, removes the container and the state dir;
a `start` that dies part-way tears down what it had already built.

Two facts the machine decided rather than the plan. There is no local
Postgres here at all — no psql, initdb or pg_ctl — while Docker is running,
so the scratch database is a container rather than a createdb against a
local server. And principals are minted with SQL, not HTTP: the A1 API has
eighteen routes and none of them creates a principal (API.md § 2), so the
harness writes the same unsalted sha256 that src/auth.js writes.

The smoke test drives the real entry points from a real consumer repo —
.doperpowers/board.json bound to the local instance, board-register.sh in,
board-list.sh back out — so the ticket crosses the toolkit, the service's
birth legality and Postgres before an assertion sees it.

Also wires the eleven board-api unit suites into run-skill-tests.sh (they
ran only by hand until now) plus this one, which carries its own gate:
without $ARKHO_DIR or a container runtime it skips loudly and exits 0. The
runner now prints a passing test's SKIP lines, because its output capture
would otherwise turn every gated skip into a silent pass.
…boundaries, resume-first, renewal, escalation

Six drills against the real A1 board-service on Task 12's harness, plus the
scaffolding they share (drill-lib.sh), a stateful gh stand-in for the gh-mode
half of the transcript comparison (gh-stub.py), and its judge
(transcript-compare.py).

Each drill boots and tears down its own scratch database, is independently
runnable, skips loudly (exit 0) with no ARKHO_DIR or no container runtime, and
leaves zero residue. Workers are scripted daemon stubs; no model call anywhere
in the tier.

The transcript-diff drill does NOT reproduce the spec's "the diff is empty":
against the committed adapter, argv and exit status match step for step, and
the printed surface diverges on thirteen of fourteen steps for reasons pinned
one by one in transcript-compare.py. See the task 13 report.
SSFSKIM added 20 commits August 10, 2026 05:12
…dit, v7.42.0

Task 14 closes A2. The plan-time read-scope audit is discharged: every
worker-executed board read across the implement/architect/review protocols
names the worker's own ticket or a direct child, so X5's read scope holds and
no protocol line needed rewriting. The same pass surfaced a transport hole the
scope question would not have asked about — A1 exposes no ticket-body read
(API.md §4.2), which makes the Architect's child `parent-pin:` lineage
comparison and implement-decompose's `gh issue edit` body fleshing gh-only.
Both are logged under Surprises as flow-back candidates rather than worked
around in the fork.

Acceptance evidence, all eight items, in Outcomes & Retrospective: the full
runner passes 21/0/0 with the integration tier live, the three gh-mode board
suites pass explicitly, and one live smoke ran against the deployed instance
(45 assertions, gh never invoked, the A1.G3 epic-recomposition return
observed on real tickets, drill residue closed).

Spec v1.2.5; version bumped to 7.42.0 (origin/main already holds 7.41.0).
…sk-14 review fixes)

Task 14 review I1: acceptance 8's third leg — the architect verdict — was
never exercised. The first live smoke closed its epic with a human
ready-for-architect -> wontfix, but A1's recomposition verdict is a RUN-actor
edge (in-design -> done|wontfix, guarded on children present AND the architect
lane), so the human close does not stand in for it.

A second drill against the deployed board ran the leg: epic #5 + child #6
registered, the child walked to done, the reconciler returned #5 to
ready-for-architect (marker recomposition-due), POST /runs/claim lane=architect
took it as run 4 / fence 1, and that run wrote ready-for-architect -> in-design
-> wontfix (note "A2 live smoke"). Both edges refused a wrong-fence replay with
fence-mismatch; the verdict ended the run on the server's own authority
(release event, owner cleared, bearer unauthenticated). 30 assertions, gh never
invoked, no new principal minted, both tickets terminal.

Also from the review, evidence precision only:
- M1 _board_api.py is 15 route wrappers over 14 A1 paths, not 18 routes
- M2 acceptance 7's regression fence is the three gh-mode suites plus the
  runner pass set; test-binding.sh asserts binding resolution, not parity
- M3 the first smoke's assertion count is stated as what its transcript
  records (43, plus the separately reported healthz probe)
- M4 triaging-feedback's Worker-mode whole-board board-list.sh read is noted
  in the read-scope record as outside X5's bite (dispatcher principal)
- M5 the transcript drill pins 13 divergences under eight tag strings,
  six families

Revision Note v1.2.6. No design change.
Final-review fixes on _sweep_api.sh (plus the dispatchers' local-cap predicate).

LIVENESS (scalpel-1#1, scalpel-3#3, scalpel-2#4). _alive collapsed three
session outcomes into two. `error` read as live, so a crashed worker's lease
was renewed forever and its ticket never reclaimed; and an UNRESOLVED FORK
(daemon-resume stamps status=error + pending_short and leaves `current` on the
superseded turn) read as live too, so both the relay and the resume path
re-forked it every tick — a fresh zombie turn, and in the resume path a fresh
successor run, per tick. Replaced by a three-word _liveness verdict:
live / forked / dead. Dead is not renewed (expiry IS the designed reclaim),
forked is renewed (the fork may hold the run) but never spoken to, and the
resume path refuses to claim a successor for a ticket whose bound session
carries an unresolved fork — no cycle charged, surfaced for repair. The
ambiguous-fork branch now returns failure instead of success.

ACK-GATED PROGRESS (sweep#8). phase_relay runs behind `|| true`, which
suspends errexit through its whole subtree, so a failed A.ack fell THROUGH to
the progress counter and the level-triggered drain re-read the same unacked
page. The ack is checked explicitly; a failure is reported and buys no read.

RUN RETIREMENT (sweep#6). A run the server ENDS is retired locally: run id,
bearer, fence, bind_confirmed and nonce are stripped (lane and role stay — a
successor inherits them), and both dispatchers' local cap now counts OPEN RUNS
rather than lane-stamped metas.

CREDENTIALS (scalpel-2#3, scalpel-4#7 first half). A relay candidate with no
run_bearer is skipped rather than resumed with an empty BOARD_RUN_TOKEN, which
would have made the worker speak as the configured human/automation principal;
and phase 1's bind repair now passes the bearer it read out of the meta.

ORDERING (scalpel-3#7, scalpel-2#9). board-bind runs BEFORE the journal is
marked handed off, before the folded answers are acked and before the failure
counter resets — a fresh worker holds no credentials until it does. A failed
persist-successor now releases the run instead of "delivering anyway".

SUCCESSOR LANE (scalpel-1#3, scalpel-1#6). The fresh-successor fallback uses
the predecessor's lane: its model, its protocol file named in the prompt, and
lane/role stamped onto the delivered meta so the local cap can see the run. A
qagent is not fresh-spawned from the tick at all — it needs its review barrier
and accepted-commit ledger, so its run is released for review-dispatch's own
cold-successor conversion.

RECONCILIATION (scalpel-1#4, scalpel-3#5). The `successor` lane sits outside
both dispatchers, so nothing reconciled it. _reconcile_successors replays a
journal that never reached a run, closes one whose delivery the transcript
proves landed, releases one that was claimed and never delivered, and HOLDS one
whose target session carries an unresolved fork. The journal now records the
session the delivery was aimed at.

CONCURRENCY (scalpel-2#8, scalpel-3#4, scalpel-5#3). The tick lock names its
owner: a live owner's lock is never stolen, and the EXIT trap removes only its
own. BOARD_RELAY_RESUME_TIMEOUT is clamped at 2 (a resume reads 0 polls as
UNLIMITED). Renewal is interleaved between resume/relay items rather than run
once per tick — the v1.2.3 arithmetic never closed against a 15-minute lease —
and a whole-tick budget stops the serial phases taking new items.

HYGIENE (scalpel-4#9, scalpel-2#10 part). A `duplicate` refusal on escalation
registration means the env-issue already landed, so the suppression record is
written from the existing ticket instead of the ladder cycling forever. Meta
writers unlink their .tmp and create it exclusively — os.open's mode does not
re-mode an existing inode.

Tests: RED-proved against the pre-fix scripts — ended-run slot release, the
retirement stamp, the ack-failure report, the unresolved-fork refusal on both
the relay and the resume path, the held successor journal, and the
bearerless-candidate refusal all fail before these changes. The
daemon-finalize stubs are now meta-driven, matching the real script's
noop-for-terminal-meta behavior.
…, parent pin

scalpel-1#5 — both dispatchers marked the claim journal spawn_completed BEFORE
board-bind. A crash in that window left a journal saying "handed off" over a
meta with no run credential and no locator: reconciliation skips a completed
journal (the unbound-but-live case is its whole point), nothing renewed the
lease, and after the server reclaimed the run the still-running worker
overlapped its replacement. The marker now lands after the bind. Proved by a
board-scripts overlay whose board-bind snapshots the journal at the instant it
runs — ordering is only observable from inside that window.

scalpel-5#8 — reconciliation's `names` set admitted every historical meta, and
daemon names are deterministic per ticket and lane while a retired daemon keeps
its meta. A later entry into the same lane therefore had an old name falsely
prove the new claim had spawned, closing its journal and leaving the run
ownerless until the lease expired. Only a meta in working/blocked counts.

scalpel-5#4 — nothing serializes two dispatch processes, and a peer journals
its nonce BEFORE the POST, so replaying it while that response is in flight
made A1 rotate the bearer under the peer and both callers spawn from their own
answers. The journal now records the writing pid; a journal younger than
BOARD_CLAIM_INFLIGHT_GRACE (120s) whose pid is still alive is left alone.
(The local cap check remains non-atomic; the server's laneCap is its backstop.)

sweep#3 — A1 returns `parentPin` on the ordinary claim and stores it on the
run. A worker's own bearer cannot read its parent's timeline, so that cursor
travels with the dispatch or not at all: both dispatchers now capture it, the
implement bootstrap names it and tells the worker to carry it into its
parent-impact / closure-package payloads (the recomposing Architect CAN read
its children), and both persist it on the registry meta. claim-successor does
not return it — the successor path has no source and is left as-is.

Fold-in 7 — the two dispatchers' _journal_write and _reconcile_claims were
verbatim copies. Both now live in issue-tracker/scripts/_claim_journal.sh,
parameterized by the caller's lanes, per-lane cap and journal-drop, and the
fixes above were made once rather than twice.

Tests: eight new assertions in test-dispatch-claim.sh, all RED against the
pre-fix scripts — the open journal at bind time, the parent pin in the prompt
and the meta, the retired-daemon run being ended, and the in-flight nonce being
left alone. All 11 board-api suites, the three gh-mode suites and shellcheck
pass.
… validation

sweep#1 — a bodyless registration. gh mode seeds a pre-spec skeleton when no
--body-file is given, then refuses an EXPLICIT birth into a lane state and
demotes the DEFAULT one to needs-info; A1 stores an empty body and defaults to
ready-for-implementer, so the same call produced a dispatchable ticket with no
statement of work, and a claim would hand a worker an empty assignment. The
RULING is mirrored, the skeleton is not: A1's body IS the assignment the claim
delivers and this client has no body-edit route (arkho#7), so a skeleton would
ship an assignment nobody can fill and make the park question its own text. An
explicitly empty --body-file stays the registrar's call, exactly as in gh mode.

scalpel-4#11 — a park birth with neither --note nor a body is refused. A1 falls
back to the TITLE as the decision question, so such a birth produced a standing
question that was a ticket name.

sweep#9 — board-register grows --repair-path, which A1 requires for an env-issue
explicitly born into an agent lane; every documented invocation of that birth
was previously rejected. It is refused in gh mode, where an explicit --state IS
the named repair path.

scalpel-4#2 — a plan pin authorizes gate-free PLAN-EXECUTION and A1 stores any
primitive on any legal edge, so the client is the only fence on this side. gh
mode's four checks are mirrored: the Architect handoff EDGE (read from the
board), an immutable path@40-hex pin, a branch the sha is reachable from
(required outright — A1's projection carries no branch to fall back on), and
reachability + path existence verified against the local checkout, failing
CLOSED. "Thin client" never meant dropping a gate the other binding enforces.

scalpel-4#7 — board-bind refuses when no run bearer is in the environment
instead of writing bind_confirmed over a meta no later resume could speak for,
and _board_api.bind() now demands the run principal rather than naming a dead
`automation` fallback the route does not have.

sweep#5 — board-show rendered only body.note, so every human answer, parent
impact and closure package printed BLANK — and reading that timeline is a
successor's first instruction. Typed payloads and answer replies now render,
with multi-line replies indented under their record.

scalpel-2#11 — an unknown `binding` value silently kept the gh default, so a
typo sent every read and mutation to GitHub. It fails loud.

scalpel-3#8 — board-answer's inline relay reported success when the sweep lock
was held and the wake never ran. It now says the answer is recorded and the
next tick delivers.

scalpel-2#10 — board-bind's meta writer unlinks its .tmp and creates it
exclusively: os.open's mode does not re-mode an existing inode, so a leftover
0644 tmp was truncated and handed the run bearer before the chmod.

Ledgered minors folded in: usage_from_header reads the contiguous header block
rather than every column-0 comment; the "recovery cycle 4 of 3" label and the
relay's "resume FAILED" wording (a long turn's expired wait looks identical);
board-comment gains a `--` end-of-options marker and refuses text given twice
instead of silently last-winning; the dead principal argument on bind();
_refuse_no_api_route replaces four drifting copies of a message that misnamed
what board-migrate-gh does.

Tests: new RED-proved assertions across six suites (bodyless births, note-less
park, repair path, plan-pin refusals, typed timeline rendering, unknown
binding, held-lock answer, bearerless bind, comment parsing). All 11 board-api
suites, the three gh-mode suites and shellcheck pass.
…api review mode

sweep#2 — the authoritative implementing / architecting / spike protocols still
told a worker to `gh issue view` its ticket and to hand-write `[parent-impact]`
marker comments, so an API-mode worker had no readable binding and produced
none of the typed events A1's reconciler joins on. Substituted where the
binding-neutral verb genuinely exists:

  * the ticket read becomes `board-show.sh <n>`, with the BODY gap stated
    rather than worked around — under an API board the claim delivered it and
    the bootstrap names the file; A1 has no body route (arkho#7 flow-back).
  * the parent-impact proposal becomes
    `board-comment.sh <n> --kind parent-impact --text "#<parent> …"`, which
    renders the gh sweep's marker AND records the API board's typed event from
    one call. A hand-written marker is invisible to the second.
  * the Architect's proposal MARK is stated per binding and explicitly not
    interchangeable: gh's `[board-epic] reconcile:` comment, or the API
    board's `--kind parent-impact-consumed` with the proposal event id. Each
    reconciler reads only its own.
  * the recomposition lineage check is marked gh-only: it hashes the parent's
    BODY, and under an API board the pin is a CURSOR handed to each child by
    its claim. An Architect says the leg is unverifiable rather than assuming
    lineage held.

sweep#4 — reviewing-prs/SKILL.md branched only for `scale`, so a qagent
dispatched with REVIEW_MODE=api fell into the PR flow with no PR_NUMBER. It now
branches on the ticket's `pr` value, which board-show prints: a PR URL runs the
PR variant (resolve the number from the URL, check out the head yourself, board
half through BOARD_SCRIPTS since the API board has no labels), and a
closure-package EVENT ID is declared not executable there — the scale variant
needs CLOSURE_PACKAGE and INTEGRATION_REF bindings the claim does not carry and
the board exposes no branch column to derive. The worker parks rather than
improvising.

All 11 board-api suites and the three gh-mode suites still pass.
…ytes

scalpel-3#2 — the relay's and the successor path's delivery proof was a
fixed-string grep over the whole transcript JSONL. That file holds everything
the session ever saw, so a marker that appeared only as DATA — a worker
cat-ing a file, a human pasting an earlier answer back — read as proof the
answer had been delivered, and the answer was acked off the feed without ever
reaching anyone. _delivered() now parses the JSONL and accepts only a
user-role entry whose content is a plain STRING: that is a prompt the harness
injected. Tool results ride the same `user` type but arrive as a content LIST,
which is exactly the channel arbitrary bytes come back through (verified
against a real Claude Code transcript: 342 string-content user entries beside
2947 list-content ones).

The transcript stubs in both sweep suites and in the integration drill library
now write REAL JSONL entries rather than raw prompt text — the old stubs made
every transcript unparseable, which is not what the code under test reads.

RED proof: the relay suite poisons the transcript with a tool_result entry
carrying answer 118's sentinel before the relay runs. Against the pre-fix
script the relay reports "already delivered (sentinel)", acks, and never
resumes; after the fix it resumes, delivers and acks in the right order.
Ledgered fold-ins from the Task 12 and Task 13 rounds.

Task 13 minors: the run bearer is masked in the drill stubs' env logs (a log
file carrying it is a credential on disk that outlives its run — the drills
assert it REACHED the child, which the masked form proves as well), the
automation token moves off `bash -c`'s argv into the environment (a 30-second
poll loop held it visible in `ps`), and test-crash-boundaries' dead second
`owner_line()` definition is gone.

Task 12 polish: the Docker skip distinguishes a missing daemon from a missing
CLI and says how to start it; a Postgres that never comes up prints its
container log instead of a bare timeout; drill_start takes INT/TERM as well as
EXIT (a Ctrl-C left the scratch container and the service running); BOARD_PG_DSN
is documented as a superuser test seam nothing outside the drills may read; and
mkrepo's throwaway repos are cleaned up at finish rather than left in TMPDIR.

A SKIP now exits 77, not 0. A skip that exits 0 is indistinguishable from a pass
to anything counting statuses, so a tier that silently stopped running — a
stopped Docker daemon, an unset ARKHO_DIR — read as a green tier. 77 is the
harness's own contract for "prerequisite missing"; it is propagated.

Two drills follow this wave's changes: transcript-diff reads the `content`
string out of the JSONL records the stubs now write (rather than flattening raw
bytes), and crash-boundaries follows the relay's new "returned no delivery"
wording.

Spec v1.2.7 records the scalpel-5#3 amendment to the v1.2.3 per-item bound —
interleaved renewal versus the whole-tick budget, and why they are different
properties — plus the protocol-line substitutions from sweep#2 and #4.

Integration tier, against a real A1 on scratch Postgres: harness-smoke,
protocol-walk, transcript-diff, crash-boundaries, resume-first, escalation and
lease-renewal all PASS.
The verification review of the fix wave (ec2ccf4..d52eee6) found six
regressions in this tick, five of them introduced by the wave itself.
Each one below is RED-proved in the unit suites.

**The recovery path reads runless predecessors** (P1). By the time a ticket
reaches the needing-resume feed its predecessor's run is normally already
retired — the renew that answered 409 run-ended is what put it there — and
_retire_run_locally strips run/bearer/fence while keeping ticket and lane.
Both recovery reads went through _registry_metas, which filters runless
metas out, so the predecessor was invisible: the lane fell back to
IMPLEMENT (wrong protocol, wrong model, for an architect, spike or qagent
ticket) and the fork guard could not see an unresolved fork it must refuse.
_registry_metas / _metas_for_ticket take an `all` mode; the lane read and
the fork guard use it. A failed scan is no longer read as "no lane".

**The relay re-checks its run after the renewal** (P1). phase_relay picks a
candidate, then renews every lease ahead of a delivery that may block — and
that renewal is exactly where a reclaimed run answers run-ended and this
very meta is retired. The four locals still held the pre-renew values, so
the relay resumed the predecessor with REVOKED credentials moments before
the resume phase gave the ticket a real successor. The meta is re-read and
only a meta still naming the same run is delivered to.

**The lock names a process, not a number** (P1). Pids are recycled, and
across a reboot the crashed sweep's number very plausibly belongs to
something long-lived: `kill -0` then answers "alive" forever, the stale
lock is never stolen, and every later api sweep exits at once — no renewal,
no relay, no resume, no dispatch. The owner's `ps -o lstart=` start time is
recorded beside its pid and both must match. A lock predating the file is
judged on the pid alone, as before.

**The successor reconcile plan is 0x1f-separated** (P1, found while
RED-proving the two below). The plan rows were TAB-separated with three
routinely-empty columns — and tab is IFS *whitespace*, so a run of tabs
collapses and every field after an empty one shifts left. `run` is empty
for every replay row by definition, so the replay arm read the ticket out
of the run column, found it empty, and did nothing at all: the whole
lost-response recovery was dead. A settle row with no session read the
daemon name as the session. Same fix in _claim_journal.sh, whose inflight
row has the same shape.

**Only a working session is spawn proof** (P2). Successor names are
deterministic per ticket and lane and daemon-retire keeps the meta, so a
historical name matched the new journal: the crash was misread as
`orphaned`, the journal closed as complete, and the freshly claimed run
owned the ticket with nobody able to speak for it until the lease expired.
The `names` set now admits working/blocked only — the rule
_claim_journal.sh already applied.

**A failed release keeps its journal** (P2). The journal is the only retry
handle there is; deleting it on a failed end left the run open, still
owning the ticket, with no later tick able to retry — "retried next tick"
was never true. It goes only on a release that landed (a typed run-ended
counts: the run is already over).

**The tick budget gates fresh dispatch** (P2). Relay and resume stopped
taking new items at the budget and then handed the tick to the dispatchers
anyway, which claim fresh implement and review work — review barrier wait
included — inside the lock a spent tick is still holding. A phase asked for
by name is its own tick and is never gated.
P1 from the verification review. An api-mode qagent dispatch bound
BASE_REF to the repo's default branch and BASE_IS_DEFAULT to `yes` — but
the board carries no PR base at all. The ticket's `pr` value is read by the
WORKER, so for a ticket whose PR targets an integration branch the engine
ran `--base origin/<default>`: it reviewed the whole stack rather than this
PR's commits, and loaded manifests from the wrong ref.

Resolving it in the dispatcher would mean a `gh` call, and this dispatcher
deliberately never invokes gh — that is why the binding is resolved ahead
of the gh probe, so an api board works on a machine with no GitHub CLI. The
worker does have gh (the api PR variant already resolves the PR number and
checks out its head), so the resolution is its job, and the protocol says
so: read baseRefName/headRefName/headRefOid off the PR before ORIENT and
use them wherever BASE_REF / HEAD_REF / HEAD_SHA appear — above all in
START ENGINE's `--base` and the self-merge base-is-default clause.

The binding is UNRESOLVED rather than a plausible-looking default, and
deliberately not a ref: a worker that skips the step gets
`fatal: bad revision` from git, never a quietly wrong review range. A new
MANIFEST_REF binding names the ref the two snapshots were taken at, so the
worker can re-read them when the real base turns out to differ.
The api base fix introduced per-mode manifest headers because the api
snapshots do not come from a base the dispatcher can name. Binding the
snapshot ref explicitly in every mode says the same thing with one header
line and no mode blocks: it is the PR base for a PR run, the integration
ref for a scale run, and the default branch under api.
Resolving base/head off `gh pr view` is only half the job: gh returns
GitHub's metadata and moves no ref in the worker's long-lived clone. A
stacked PR's integration base is exactly the ref that clone is least likely
to carry, so ORIENT's diff, the manifest re-read and START ENGINE's --base
either fail on a missing revision or review a stale range.

The step is now resolve -> fetch origin <base> <head> -> detach at
headRefOid, all before ORIENT, with BASE_REF bound to the freshly-fetched
tracking ref. A failed fetch is a hard stop naming the ref, never a
fall-back to the default branch. The api bootstrap carries the same recipe
in short form.
Two defects in the lock's owner identity.

`ps -o lstart=` prints a RENDERED date - month and day names from the
locale, clock from the zone - so a lock written by a launchd tick and
checked by one started from a shell with its own LC_ALL or TZ compares two
spellings of one instant and calls them different processes. Both sides go
through _proc_start, so the pin lives there: LC_ALL=C TZ=UTC. macOS ps
offers no epoch-seconds start column; pinning the renderer is the portable
stable token.

And the comparison had two branches where the domain has three. An EMPTY
current start - a lost race with the process table - mismatched as a plain
string, so the lock was taken from an owner kill -0 had just confirmed
alive, and two ticks then interleaved the sentinel check with its resume:
the double delivery this lock exists to prevent. Unknown now fails closed
and keeps the owner. The startless-lock degrade path is untouched.

RED-proved by a new case in the lock suite (a ps stub returning nothing
against a live pid and a stale recorded start); it steals on the parent
commit.
…urnal.sh

A branch regression, not a pre-existing failure: the fix-wave extraction of
the two dispatchers' verbatim claim-journal copies into
_claim_journal.sh left review-dispatch.sh sourcing it out of $BOARD_SCRIPTS
at TOP LEVEL — ahead of any binding fork, so the gh path needs it as much as
the API path. This suite does not point BOARD_SCRIPTS at the real scripts
dir the way the implementing suite does; it builds a stub and copies in the
few real files the dispatcher sources. The journal was not among them, so
every case died at the source line.

Copied into both stub dirs, for the reason each one already documents. The
fail-board dir needs it too: it exists to fail the BIND, and a run that
instead dies at a missing source aborts before a reviewer is ever spawned —
which is exactly the retire the assertion after it looks for.

Suite goes from aborting to 272 assertions green.
Two defects in the r3 fetch step.

The step redefined BASE_REF as `origin/<baseRefName>`, but every consumer
already adds the remote — `--base origin/{{BASE_REF}}`, the ORIENT diff, the
manifest re-read — so a worker following it literally builds
origin/origin/<base> and dies on a bad revision. BASE_REF is the branch NAME;
`origin/<baseRefName>` is only the tracking ref the fetch moves, and the text
now says so in both files.

And the fetch-failure park named a bare `board-transition.sh`. BOARD_SCRIPTS
is a path binding, not a PATH entry: an api worker cannot execute that, so
the park it prescribes fails and the ticket wedges in-review — the one state
the hard stop exists to avoid. Bound absolute form, like every other board
write in these protocols.
…ive owner

Pinning the lstart rendering to C/UTC settles every lock written after the
pin, and breaks the one written across it. The sweep holding the lock during
the upgrade recorded a bare lstart under whatever locale and zone it
inherited; rendered C/UTC, that same LIVE process compares unequal, so the
first tick to find the lock past stale steals it — the upgrade itself causing
the double delivery the lock exists to prevent.

The token now carries the format version that pinning is, and _owner_live
treats anything it cannot read — a legacy bare token, or one from a newer
format — as UNKNOWN. Only a genuine mismatch inside a format this code can
reproduce means "different process"; everything else keeps the owner while
kill -0 answers. _proc_start prints NO token rather than a bare prefix when
ps says nothing, so unreadable stays distinguishable from well-formed.

RED-proved: a new case plants the live pid's own start rendered under
TZ=Asia/Tokyo (standing in for whatever the old writer inherited, and never
equal to UTC, so it cannot pass quietly on a UTC machine). It steals on the
parent commit. The recycled-pid case still steals, so the guard did not
simply disable stealing.
Versioning the start token made every unversioned value UNKNOWN, and
unknown keeps the owner. That is right for a rendering this script cannot
generate and wrong for one it can: a bare C token is reproducible evidence,
so refusing to read it means a recycled pid under a pre-versioning lock is
believed alive forever — no renewal, no relay, no resume, no dispatch. That
wedge is the exact failure recording a start time exists to prevent, so the
migration guard had reintroduced it from the other side.

A bare token is now compared, against the two renderings an earlier shape of
this script could have written: C/UTC (the pinning before it was versioned)
and C in the machine's own zone (an unpinned writer — an unset LC_ALL already
renders C-like, and only the zone moved). Matching either is the same
process. Only a genuinely localized rendering stays unknown, detected on the
month field, which is where a locale shows itself; the zone moves the clock,
which is a value difference rather than a shape one.

_start_raw takes the zone as an argument and inherits the machine's when
given none — TZ= would not do that, since an empty TZ reads as UTC on most
libc, the very value being told apart.

RED-proved: "a bare legacy token whose pid was recycled is stolen" holds the
lock forever on the parent commit. The lock suite now pins seven cases —
versioned match, versioned mismatch, startless, empty read, bare match, bare
mismatch, unreproducible rendering.
…-adapter

#48's content wins for gh-mode review-loop semantics; the branch's content
wins for the API adapter. Where both edited a region, composed:

- version manifests (4): 7.42.0 kept over main's 7.41.0.
- review-dispatch.sh: header composes main's kill-switch/scale-lane wording
  with the branch's API-mode DEFAULT_BRANCH resolution and
  REVIEW_MAX_CONCURRENT; main's re-added gh DEFAULT_BRANCH resolution dropped
  (the branch moved it inside the binding fork above); P_MANIFEST_REF kept on
  all three renders, P_DEFAULT_BRANCH / P_BASE_IS_DEFAULT dropped from all
  three — #48 deleted both bindings from the worker template with the
  self-merge main-exclusion they served.
- review-worker-bootstrap.md + reviewing-prs/SKILL.md: the API variant's
  BASE_IS_DEFAULT prose and its "self-merge tier's base-is-default clause"
  follow those bindings out; BASE_REF stays the UNRESOLVED sentinel.
- accepted main's deletions wholesale: land-dispatch.sh, the land references
  and land-on-approve.yml, tests/reviewing-prs/test-land-dispatch.sh.

Semantic sweep — the A2 drills walked edges only one canon still holds
(A1's LEGAL_ROWS keeps confident-ready; this fork's no longer does, which is
the booked legality-drift follow-up, not something a parity drill should be
exercising):

- test-protocol-walk.sh: the closing verdict is `in-review → done`, the one
  in-review exit both canons keep, instead of in-review → confident-ready →
  done.
- test-transcript-diff.sh: the same verdict change, and the illegal-edge
  refusal probe moves from `needs-human → confident-ready` (gh would now
  answer "unknown state", a different discriminator) to
  `in-progress → ready-for-implementer`, refused by BOTH tables and named as
  an edge by both. Walk drops to 13 steps; transcript-compare.py's PINNED
  table re-indexed to match.
- test-review-dispatch-claim.sh: the BASE_IS_DEFAULT prompt assertion goes
  with the binding.
…anch drifted past

Six assertions, all failing on this branch BEFORE the merge (verified against
c03204b): the A2 adapter added bindings and changed the parent-impact
instruction without updating the pins that exist to notice exactly that.

- implementing worker-bootstrap gains PARENT_PIN (the parent-contract window
  a claim was cut against — no read a worker may make hands it over) and
  TICKET_BODY_FILE (the assignment the claim delivered, since A1 has no
  ticket-body read route).
- the review worker's runtime + bootstrap sets gain MANIFEST_REF, and the
  bootstrap also TICKET_BODY_FILE.
- the parent-impact proposal is now posted with
  `board-comment.sh --kind parent-impact --text "#<parent> …"` — one verb,
  both bindings — so the pin follows the verb, and separately still requires
  each protocol to name the `[parent-impact] #<parent>` marker that verb
  renders under a gh board.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0e3698c944

ℹ️ 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".

echo "claimed #$C_TICKET run=$C_RUN_ID lane=$lane → $uuid"
}

_claim_one() { _claim_one_with_nonce "$1" "$(uuidgen)" "$2"; }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Use a portable nonce generator for API claims

On hosts without the optional uuidgen executable—including this repository's current test container—this command substitution fails inside a loop condition where errexit is suppressed, so _claim_one_with_nonce receives an empty nonce. The server may reject every claim; if it accepts one, all journals use .json/.body.md and a later empty-lane cleanup deletes the successful claim's recovery record. The same undeclared dependency occurs in review-dispatch.sh:1307 and _sweep_api.sh:1095; use Python's standard-library UUID generator or fail before attempting any claim.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 934224d. Shared _claim_nonce in _claim_journal.sh (uuidgen → python3 uuid.uuid4() fallback, both stdlib-only), and an empty result refuses loudly before anything is journalled. All three sites route through it. RED-proved with a failing-uuidgen PATH stub: unfixed, the empty nonce journalled to .json and a second claim on the lane deleted the granted run's recovery record.

Comment on lines +193 to +194
_api_end_run "$run" abandoned
_claim_drop_journal "$nonce" ;;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve the journal when releasing a run fails

When /runs/<id>/end is unreachable or returns a service error during startup reconciliation, both dispatchers' _api_end_run helpers absorb the failure with || true, after which this unconditional drop removes the only record capable of retrying the release. The still-open run continues owning its ticket, but later ticks can no longer reconcile it and must wait for lease expiry. Propagate the release result and delete the journal only after a successful end or a typed run-ended response, as the successor reconciliation path already does.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 934224d. The reconcile end arm (and the new stranded arm) now release through a checked _claim_end_run — a typed RunEnded counts as landed — and drop the journal only on success; a failed release keeps it as the retry handle, matching the successor-journal release shape in _sweep_api.sh. The dispatchers' best-effort _api_end_run is unchanged at its spawn-failure call sites, which hold no journal contradiction.

Comment on lines +191 to +192
out = A.claim(os.environ["T_LANE"], os.environ["T_NONCE"],
lane_cap=int(os.environ["T_CAP"]))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Clear ambient run credentials before automation claims

When this dispatcher is invoked from a board worker's environment, the inherited BOARD_RUN_TOKEN overrides the requested automation principal in _board_api.token(), so this claim is authenticated as the unrelated worker run rather than dispatch automation and is refused. _sweep_api.sh explicitly unsets the same ambient token for this reason, but direct implement-dispatch.sh --sweep and review-dispatch.sh --sweep do not; clear it before either dispatcher's API branch starts claiming.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 934224d. Both dispatchers now unset BOARD_RUN_TOKEN as the first statement of their API branch, pointing at _sweep_api.sh's doctrine block. Scope is dispatch automation only — the explicit per-command BOARD_RUN_TOKEN="$C_BEARER" prefixes still work, and no human-route verb is touched (the server-side fence on those is the settled design). RED-proved: unfixed, an ambient worker bearer reached the wire on the claim; fixed, every claim carries the automation token.

_claim_one architect "$ARCH_CAP" || break
done
while [ "$(_api_registry_count implementer,spike)" -lt "$CAP" ]; do
_claim_one implementer "$CAP" || _claim_one spike "$CAP" || break

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Stop after an uncertain implementer claim

If the implementer claim reaches the server but its response is lost, _claim_one returns failure while deliberately retaining its journal, and this || immediately claims a spike as well. Because IMPLEMENT_MAX_CONCURRENT is a combined implementer-plus-spike cap while the server's laneCap is lane-specific, a later nonce replay spawns the already-granted implementer beside that spike and exceeds the configured combined cap. Distinguish an empty/refused lane from an uncertain journalled claim and only fall through to spike for the former.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 934224d. _claim_one_with_nonce now has a three-valued contract: 0 = handed off, 1 = nothing outstanding (empty/refused/suppressed lane — safe to try the next lane), 2 = the claim may have landed and its journal is kept for replay. The implement loop falls through to spike only on 1; on 2 the whole fresh-claim loop stops for the tick and reconciliation owns the replay. RED-proved with a 503 first-claim fixture: unfixed, the tick claimed and spawned a spike behind the journalled implementer claim.

Comment on lines 744 to 745
[ -z "${CLAIM_JOURNAL:-}" ] || _api_mark_spawned
if ! READY="$bind_ready" LEDGER="$ledger" UUID="$uuid" TICKET="${issue:-none}" python3 - <<'PY'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep the QAgent journal open until the barrier is durable

If the dispatcher dies after board-bind.sh succeeds but before the following bind-ready.json write completes, this marks the claim handed off even though the reviewer is still blocked on a barrier that will never appear. Reconciliation also treats the run-bearing meta as completed, while the sweep classifies the resulting idle/blocked session as live and continually renews its lease, so the ticket can remain owned indefinitely. Make barrier publication and acknowledgement part of the crash-recoverable handoff before closing this journal.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 934224d. _api_mark_spawned moved to after the barrier publish AND the worker's verified ack; the journal now carries the control dir so reconciliation can see the barrier state. The crash window this opens (bound meta under an unmarked journal, writer dead, no ack) is closed by a new stranded reconcile arm: retire the worker, checked-end the run, drop the journal — so the ticket requeues instead of being lease-renewed forever. Full crash-window audit table is in the branch's fix report; the one untouched row (spawned-but-never-bound) is the pre-existing orphaned case, bounded by server lease reclaim by design.

Comment on lines +1543 to +1544
if _budget_left; then phase_dispatch || true
else echo "dispatch: tick budget exhausted — fresh claims ride the next tick"; fi ;;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Enforce the deadline inside fresh dispatch batches

When the earlier phases leave even one second in the tick budget, this single check admits the entire dispatch phase: the implement dispatcher can claim repeatedly up to its caps, followed by the review dispatcher whose workers each wait on a startup barrier. No deadline is checked between those claims or even between the two dispatchers, so a nearly exhausted tick can continue holding the global sweep lock and starting new work for several minutes beyond the advertised whole-tick budget. Pass the remaining deadline into the dispatchers and check it before each fresh claim.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 934224d. The all tick now exports BOARD_TICK_DEADLINE (tick start + budget) into both dispatchers via env_common, and each checks it in _claim_one — i.e. before every fresh claim across all lanes, including ahead of the review barrier wait. A phase invoked by name hands across nothing and keeps its own-tick semantics; reconciliation replays are never gated (recovery, not new work). Both halves RED-proved separately: the sweep hands the epoch across, and a dispatcher with a passed deadline refuses fresh claims with nothing on the wire.

# {"ticket": N, "state": "<board state when it stuck>", "env_issue": N}
# THIS PHASE IS THEIR ONLY WRITER. Both dispatchers read the directory
# (BOARD_SUPPRESS_DIR) and release any claim that yields a suppressed ticket.
SUPPRESS_DIR="$DAEMON_HOME/board-suppress"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Honor the configured suppression directory

When BOARD_SUPPRESS_DIR is set to a non-default location, this assignment discards it, so _suppressed and _check_lift read and write $DAEMON_HOME/board-suppress instead. phase_dispatch then exports that default path to both dispatchers as well, meaning existing suppression records in the configured directory are ignored and their tickets can be claimed again. Initialize this as ${BOARD_SUPPRESS_DIR:-$DAEMON_HOME/board-suppress}.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 934224d. SUPPRESS_DIR="${BOARD_SUPPRESS_DIR:-$DAEMON_HOME/board-suppress}". RED-proved: a resume phase pointed at an operator directory holding a suppression record now lifts and removes that record; unfixed, it read the default directory and the record went unenforced.

Comment on lines +1202 to +1204
git -C "$LOCAL_REPO" show "origin/$DEFAULT_BRANCH:.doperpowers/risk-surfaces.md" > "$tmp/risk.md" 2>/dev/null \
|| : > "$tmp/risk.md"
git -C "$LOCAL_REPO" show "origin/$DEFAULT_BRANCH:.doperpowers/repo-facts.md" > "$tmp/facts.md" 2>/dev/null \

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Refresh the base ref before snapshotting review manifests

In API review dispatch from a long-lived clone, origin/$DEFAULT_BRANCH may be stale or absent because this path performs no fetch before these git show calls. When the claimed PR actually targets that default branch, the worker is instructed to keep these snapshots—re-reading them only when its resolved base differs from MANIFEST_REF—so even though it later fetches the PR base, it can review under outdated or empty risk-surface and repo-facts policy. Fetch the default ref before taking these protected base snapshots, as the ordinary PR dispatch path already does.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 934224d. Best-effort git -C "$LOCAL_REPO" fetch -q origin "$DEFAULT_BRANCH" immediately before the two snapshot git show calls, mirroring the ordinary PR dispatch path. A fetch failure warns and continues — the empty-snapshot fallback stays the designed degradation and the worker's own PR fetch remains the hard gate; git only, no gh, per this dispatcher's binding-before-gh rule. RED-proved with a never-fetched clone: unfixed, the worker prompt carried the empty-manifest fallback; fixed, it carries the remote's manifests.

F1 portable nonce: a shared _claim_nonce (uuidgen, else python3, else a loud
refusal before anything is journalled) replaces bare $(uuidgen) at all three
claim sites. An empty nonce named the journal file, so a granted run's only
recovery record was deleted by the next claim on the same lane.

F2 the reconcile `end` arm releases through a CHECKED end and keeps the journal
when that fails — it is the only retry handle there is. Same shape as the
successor-journal release in _sweep_api.sh.

F3 both dispatchers unset an ambient BOARD_RUN_TOKEN at the top of their API
branch: token() hands it back for any principal, so a --sweep out of a worker
shell claimed and ended runs as that worker. Automation route only; no human
route is touched.

F4 _claim_one_with_nonce gets a three-valued contract (0 handed off, 1 nothing
outstanding, 2 may have landed and is journalled for replay). The implement
loop falls through to spike only on 1: on 2 the replayed implementer and a
fresh spike would both run, over the combined cap.

F5 the review journal is marked spawned only once the handoff is DURABLE —
after the barrier is published and the worker acks. The window that opens (a
bound meta under an unmarked journal) is reconciled by a new `stranded` arm,
which tells a reviewer that crossed its barrier from one that never could by
the ack file in the journalled control dir, and retires + ends the latter.

F6 the tick deadline crosses into the dispatchers (BOARD_TICK_DEADLINE, set
only by the `all` tick) and is checked before each fresh claim. One gate at the
door of the dispatch phase admitted every lane loop and a barrier wait in full
on one second of budget, under the sweep lock.

F7 the sweep honors a configured BOARD_SUPPRESS_DIR instead of overwriting it,
so the side that writes suppression records and the side that enforces them
share a directory again.

F8 the API claim path fetches origin/<default> before snapshotting the
risk-surface and repo-facts manifests, as the PR path already does. A stale or
absent tracking ref reviewed under outdated or empty policy.

RED proofs for every finding in tests/claude-code/board-api/
{test-dispatch-claim,test-review-dispatch-claim,test-sweep-resume}.sh; details
in .doperpowers/sdd/2026-08-09-a2-board-adapter/pr50-codex-fix-report.md.
# Conflicts:
#	.claude-plugin/marketplace.json
#	.claude-plugin/plugin.json
#	.codex-plugin/plugin.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A2: Plugin board adapter — issue-tracker toolkit speaks the Arkho board API

1 participant