Repository navigation
feat(issue-tracker): make api mode repo-aware (board ticket 33) - #103
Conversation
One board service serves several repositories out of one ticket namespace,
and the toolkit named none of them. The server therefore chose: its founding
repo on an ordinary write, every repo on a list read. Observed on the arkho
live flip — board-register.sh run from the arkho checkout filed into
doperpowers, and board-list.sh from there printed every repo's tickets.
.doperpowers/board.json gains a third key beside binding and url:
{ "binding": "api", "url": "...", "repo": "doperpowers" }
_binding.sh parses it into BOARD_REPO and hands it to python3 through
_api_py. An api binding with no repo (and no env override) is a
configuration error that dies before any verb runs — there is no fallback
to the server's default, because that default IS the bug, and none to the
checkout's directory name, because a checkout is not its board identity.
BOARD_REPO means the board's repo key here; in gh mode it stays owner/name.
review-dispatch.sh's `basename $BOARD_ROOT` guess goes away with it.
Writes name their repo in the body (register, claim); list-shaped reads name it as a query parameter appended after the caller's own parameters, so a walk's &cursor= still lands last (tickets_all, tickets_search, tickets_by_ids, queue_decisions_all, needing_resume, unrelayed, and the by-id rollback probe). The narrowing rides the walk BASE, so every page carries it — a page that dropped it would splice another repo's rows into the middle of a result. Id-targeted routes send nothing: a ticket already has its repo, and reading a foreign ticket by id stays allowed. For a scoped token or a run bearer the sent repo is redundant with what the server derives. That is deliberate: a board.json disagreeing with the token file now surfaces as 403 repo-mismatch instead of quietly working on some other repo's board. Principals are not special-cased.
board-list.sh and board-search.sh can widen a read back to the whole board service on demand — prior art is prior art wherever it was filed, and an operator browsing is not the same actor as a sweep. The header says when the widening is on, because rows from several repos look exactly like rows from one and #12 means a different ticket in each. board-search --bodies hydrates at the same scope as the search that produced the ids. Nothing else offers it: the sweep, lint, map, reconcile, answer's decisions walk and both dispatchers always narrow — a checkout has no business sweeping a neighbour's tickets. In gh mode the flag is refused rather than dropped: a gh board is one repo.
Every throwaway board.json fixture gains a repo key; the suites that drive the client directly hand BOARD_REPO to python3 the way _api_py does, and helpers.sh unsets an operator's ambient one so it cannot retarget a fixture. New assertions: the binding exports the declared repo, refuses an api binding without one, honours an env override, treats a blank env as no declaration, and resolves the same repo from a linked worktree; the register body names its repo and a transition does not; both dispatchers' claims name theirs; the list walk carries the filter on the cursor page too; and --all-repos widens, says so, and sends no filter. Literal path assertions gain the &repo= suffix, and the cursor-bearing mock fixtures gain it ahead of &cursor= — the walk appends the cursor last.
SKILL.md gains an API binding section — there was none: the board.json shape with all three keys and what repo means, that the file is committed so every worktree resolves the same board, the credentials file and its two tokens, what $BOARD_REPO means per binding, and --all-repos on the two browse verbs. The Toolkit preamble said "Target repo = $BOARD_REPO (owner/name)" without saying which binding that described; it now says. The A2 spec's binding shape gains the key, and a v1.3 revision note records that "board.json is repo-agnostic" is revised — a service is not a board — with the arkho flip as the finding.
The decisions walk, the unrelayed feed and the needing-resume feed are all list-shaped: unnarrowed they answer for every repo the service holds, so a tick here would relay and resume a neighbour's runs. Their fixtures matched by prefix and passed silently either way, so the filter is asserted explicitly. Integration: api_repo takes the repo key (default the founding repo the schema seeds), and test-human-verbs gains a two-repo case — a second repo_state row seeded the way principals are, a register from the second checkout landing in the second repo, each checkout's list showing only its own board, and --all-repos showing both.
…oute /runs/claim is dispatch-shaped, and the harness principals are unscoped: a claim naming no repo is refused `repo-required` rather than served from the founding one. The drills' raw-curl claim seam took the repo from nowhere; it now reads the drill's own binding file, so it cannot drift from what the toolkit's verbs send. The smoke drill's hand-written binding file — the one that exists to show what a binding looks like — gains the key too.
…e checkout dir The api dispatch path rendered the worker prompt's REPO binding from `basename $BOARD_ROOT` — a fact about this machine's directory layout, not about the board the ticket lives on. gh mode passes owner/name there, and review-dispatch now passes the binding's declared repo; this is the last site guessing. The transcript-diff drill drives BOTH walks through one helper and forced BOARD_REPO to the gh stub's slug. That is the gh walk's target repo; in api mode the same variable is the board's repo key and wins over the binding file, so the api walk was sending a repo the service never registered. The api walk now gets a blank, which the binding reads as no declaration.
…ed reads The two feed-read counters matched `/answers/unrelayed"` with its closing quote and counted zero once the route carried `?repo=`; the resume suite's rollback probe, ids batch and duplicate-walk cursor page pin whole paths the same way. All of them now name the filter, so a read that lost it fails rather than passing on a looser prefix.
… repo The server resolves /runs/claim-successor through the same dispatch rule /runs/claim uses (arkho `claimSuccessorRoute` → `dispatchRepo`), so an unscoped credential that names no repo is refused `repo-required`. Naming the ticket is not naming the repo: that rule reads the credential and the request, never the row the id points at. Unfixed, every run the sweep tried to reclaim would stick in the recovery loop until it escalated.
`[ -n " " ]` is true, so a repo of spaces passed the binding's emptiness check and reached the wire as `repo=%20` — which the server reads as NO filter on a list read and as no name on a write, the exact widening this key exists to close. The file's value and the env override are both trimmed before they are weighed, so both land on the existing refusal, and a padded key resolves trimmed rather than becoming a different repo. The client strips and refuses the same way: _binding.sh is the gate, but the client is what puts bytes on the wire.
…eckouts _binding.sh honours an inherited BOARD_REPO so a USER can override the binding file. A value the parent DERIVED from its own board.json is not that override — but _lib.sh exported it unconditionally, so a verb run from a neighbouring api-bound checkout hit that guard with the parent's key and never read its own board.json. It then read and wrote the parent's repo: this branch's own bug, one level down. The value is repo-scoped exactly like BOARD_API_URL and the credentials file, so api mode no longer exports it. Nothing downstream loses it: _api_py hands it to python3 explicitly, both dispatchers' P_REPO is an ordinary expansion of their own shell variable, and a spawned worker resolves its worktree's checked-in binding. gh mode keeps its export — _board.py's repo() and board-transition's closed-ticket probe read it from the environment there. review-dispatch.sh's own export is narrowed the same way and for the same reason its comment already gives: the reader it serves is gh-only.
…r's checkout A worker checks out the head it was dispatched for — `git checkout --detach <headRefOid>` for a reviewer, the feature branch for an executor — and a head that predates this migration carries a two-key board.json. Every board script the worker ran after that checkout then died on `binding=api but no repo`, so a claimed review or implementation could never post its final transition and the run sat until its lease expired. Both dispatchers now state BOARD_REPO on the spawn prefix beside BOARD_API_URL, which is there for exactly this reason. Env wins over the file in _binding.sh, so the pin holds through any checkout. This is the deliberate exception to fix wave 1's no-export rule, and it is a pin rather than a leak: the worker is bound to this dispatcher's repo by construction, since the run bearer on the same prefix ties it to a ticket in that repo and nothing else. The comments in _lib.sh and review-dispatch.sh that justify the no-export now name the exception.
`/runs/needing-resume` and `/answers/unrelayed` both resolve through the server's dispatch rule (arkho server.js:663, :807), so the harness's unscoped automation principal is refused `repo-required` on a request that names no repo. Five raw call sites still did: drill-lib's needing_resume_ids, the escalation drill's reclaim poll, and the unrelayed assertions in the crash and protocol drills. All now go through drill_repo_key, the same helper the raw claim route uses, so they cannot drift from the toolkit's own requests. `/queue/decisions` is left alone deliberately: it is an ordinary read filter server-side, not a dispatch-shaped call, so it is neither refused nor wrong unnarrowed.
The dispatchers pin BOARD_REPO for a worker's FIRST turn, but the sweep drives every turn after that and pinned only the URL — so a worker on a pre-migration head kept the pin for its initial dispatch and lost it on every sweep-driven turn, dying on `binding=api but no repo` where it could no longer report why. All three handovers now carry it: the relay resume, the successor resume, and the fresh-successor spawn. The rule this is an instance of is stated once, in _lib.sh's no-export comment: wherever BOARD_API_URL is pinned on an env prefix for a worker, BOARD_REPO is pinned beside it. The two facts have the same lifetime and the same blast radius, so a new handover inherits the rule rather than needing a review to catch it.
Ticket numbers are repo-local, so across repos `#12` is not one ticket — but `--all-repos` printed rows whose ids were indistinguishable, and every id-targeted verb the reader reaches for next (show, transition, comment) takes a bare number. An unscoped human token turns that ambiguity into a mutation of a neighbour's ticket from the wrong checkout, with neither side saying so. board-list.sh and board-search.sh now carry the repo as a second column when widened, search's --bodies hydration included (it prints through the same row). An absent repo renders "-" like an absent priority — a pre-repo-field server is the one shape these bytes arrive in without one. The narrowed default is byte-identical to what it printed before: there the repo is the binding, stated once rather than once per row.
…machine $DAEMON_HOME is machine-global and several api-bound repos share it, but a tick serializes against ONE board's state — its renew, relay, resume and dispatch phases touch only runs that board knows. One `.sweep-api.lock` for all of them made two repos' timers mutually exclusive instead: the loser exited having renewed nothing for a whole tick, up to the 900s budget and so longer than a lease, on runs the winner's board had never heard of. The key is a sha256 digest of `url|repo` — hashed rather than sanitized, so no url or repo name can collide with another's after character substitution and the path stays a fixed, filesystem-safe length.
…ur own The daemon registry is machine-global; a board is not. Two api-bound repos on one machine share $DAEMON_HOME, and their `board` values are identical — one service, several repos — so nothing separated their daemons. The api sweep's scan therefore emitted every api-mode daemon on the machine and acted on it: renewing a neighbour's run, and repairing its bind, which overwrites that run's session locator with THIS repo's projectKey. board-lint reported the same daemons as drifted, and its verdict is a retire recommendation — to kill a live worker on a board this checkout cannot see. board-bind.sh now stamps `board_repo` beside the `board` key it already wrote, and both api-mode registry scans go through one predicate, _board_api.meta_is_mine. A meta missing either field is legacy and reads as ours: on this machine only one repo has ever run api-mode daemons, so those metas are in fact ours and skipping them would strand live runs unrenewed. board-reconcile.sh needs nothing — in api mode it delegates to board-lint, and its own registry scan is on the gh arm.
… predicate A half-filtered machine-global registry is worse than either extreme, so the remaining six scans now ask the same question the sweep and lint already did: board-answer's two owner scans, board-bind's prior-owner strip (it was unbinding a neighbour's live worker off ITS same-numbered ticket), board-transition's dp#63 fence (a neighbour's worker on #9 was refusing legitimate transitions of ours), _claim_journal's live-run set, and the sweep's successor reconcile. meta_is_mine is now PURE — it takes the identity rather than reading the environment — because three of these scans run under gh mode in scripts that never resolve an api url. That also gives gh mode the same protection for free: two gh checkouts on one machine collide identically, and there the owner/name inside the board key is the whole identity, so no repo dimension is passed. An unstamped meta still reads as the caller's everywhere. board-bind.sh gains one _board_ident() used both to stamp a meta and to recognize its own — two spellings of a board key in one file is how a stamp and its reader drift apart.
It was added for a successor-reconcile drill that turned out not to bite — the journal that drill plants is not successor-lane, so the scan never reaches the meta and the assertion passed with or without the filter. The drill is gone rather than left asserting nothing; the seam goes with it.
…ane slot Both dispatchers count their local lane cap off the machine-global daemon registry, unfiltered. With cap 1, one open worker on another api-bound repo made this checkout read its architect lane as full — and the tick then fell through to the NEXT lane and dispatched this repo's architect ticket as an implementer, on the implementer model. Not a starvation that reports itself: a silent mis-dispatch. Same predicate as the other eight scans. The drill plants such a worker in the shared registry before the tick, and the surrounding claim/model assertions become load-bearing for it: without the filter they fail with the ticket claimed on the wrong lane.
The per-binding tick lock digested the raw $BOARD_API_URL while the client's api_url() rstrips the trailing slash, so a BOARD_API_URL override spelled `https://host/` addressed the same service as `https://host` on the wire but a different lock directory on disk — two ticks for one binding running concurrently, which is exactly the interleaving the lock exists to prevent. Normalize the url the same way api_url() does before hashing. The test lock_key helpers, which mirror the digest, normalize too.
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7d1cd67799
ℹ️ 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".
| if not meta_is_mine(m, os.environ.get("T_BOARD", ""), | ||
| os.environ.get("T_BOARD_REPO", "")): |
There was a problem hiding this comment.
Scope claim journals before filtering live runs
When two API-bound repos share DAEMON_HOME, this filters the neighboring repo's bound daemon out of live but the subsequent scan still processes every machine-global board-claims/*.json. If that neighbor's dispatcher crashes after binding its worker but before setting spawn_completed, this repo classifies the foreign journal as end and _claim_end_run terminates the neighbor's still-active run; its ticket can then be reclaimed while the original worker continues. Stamp/filter journals by board and repo, or place them in a binding-specific directory, before narrowing the metadata set. This multi-repo crash boundary also needs the repository-required pressure coverage. CLAUDE.mdL34-L39
Useful? React with 👍 / 👎.
| BOARD_RUN_TOKEN="$C_BEARER" BOARD_RUN_ID="$C_RUN_ID" BOARD_RUN_FENCE="$C_FENCE" \ | ||
| BOARD_API_URL="$BOARD_API_URL" \ | ||
| BOARD_API_URL="$BOARD_API_URL" BOARD_REPO="$BOARD_REPO" \ |
There was a problem hiding this comment.
Persist the repo pin into background workers
For an API reviewer that checks out a PR head predating this change, that head's board.json has no repo, so the worker depends entirely on this prefix. However, the real daemon-spawn.sh launches claude --bg, which does not propagate these prefix variables into the worker's shell (the repository itself records that limitation in _lib.sh); the added test only proves the stub received the variable. Such a worker therefore fails every board command at _binding.sh's new mandatory-repo check and cannot transition its claimed ticket. Persist BOARD_REPO through the daemon handoff rather than only passing it to the spawn wrapper, and pressure-test the real background route. CLAUDE.mdL34-L39
Useful? React with 👍 / 👎.
…inos call sites
Main folded the daemon substrate into the sminos CLI while this branch
was in review. The env-prefix rule ("wherever BOARD_API_URL is pinned
for a worker, BOARD_REPO is pinned beside it") carries over unchanged:
the three sweep sites and the two dispatchers now pin it on `sminos
resume`/`sminos spawn` instead of daemon-resume/daemon-spawn, and the
reviewer's pin rides the `_spawn_reviewer` call site main introduced.
Test seams follow the rename (SMINOS_CLI replaces DAEMON_SCRIPTS in the
cases this branch added). test-bind's neighbour-repo strip case asserted
on compact JSON spelling to prove the foreign meta was never rewritten;
`sminos migrate`, now a once-per-process preflight in _lib.sh,
re-renders every record, so the case asserts on content instead — the
ticket, repo and name stay the neighbour's and no run of ours lands on
it. TECH-DEBT rows renumbered behind main's row 11.
mods-types: a gate that typechecks every plugin's function-hook mods (board #103)
Summary
Board ticket 33 (P1). Makes the issue-tracker toolkit's api mode repo-aware: the client now declares which board repo it speaks for, every repo-dimensioned call carries it, and reads narrow to it by default.
Found by the arkho live flip (2026-09-03):
board-register.shfrom the arkho checkout registered intodoperpowers(the server's founding-repo default) and the mirror createdSSFSKIM/doperpowers#96;board-list.shand the sweep read every repo's tickets from any checkout.Design:
.doperpowers/direct/api-repo-aware/brief.md(approved 2026-09-04, direct track).What changed
.doperpowers/board.jsonin api mode gains a requiredrepokey ({binding, url, repo})._binding.shparses it intoBOARD_REPO; a missing/blank repo with no env override is a fatal configuration error (no fallback to the server default — that was the bug — and no fallback to a directory name;review-dispatch.sh's basename fallback is removed). In gh modeBOARD_REPOstaysowner/name._board_api.py:register,claim,claim_successorsendrepoin the body;tickets_all/search/by_ids,queue_decisions_all,needing_resume,unrelayedand the ticket probe append?repo=. Id-targeted routes send nothing. A scoped token that disagrees withboard.jsonsurfaces as403 repo-mismatchinstead of silently doing something.BOARD_API_URLis pinned for a spawned worker (execute-dispatch.sh,review-dispatch.sh, three_sweep_api.shsites),BOARD_REPOis pinned beside it.BOARD_REPOis exported only in gh mode so an api key never leaks into a child checkout.--all-reposonboard-list.sh/board-search.shonly; rows then carry a repo column..sweep-api.<sha256(url|repo)[:16]>.lock; daemon metas are stampedboard+board_repo; a puremeta_is_mine()predicate filters all eight registry scans plus the lane counter, so two api-bound repos on one machine no longer collide on ticket numbers.issue-tracker/SKILL.mdgains an "API binding" section; A2 adapter spec v1.3 revision note;TECH-DEBT.mdrows 11–13.Review
Six codex review rounds (
gpt-5.6-sol) with a fix wave after each; every round found the same defect class ("repo-dimensioned surface missed") in a new place — routes → spawn env → sweep env → row rendering → local locks/registry → remaining scans + lane counter → lock url normalization. Round 6 closed the loop: its remaining P1 (crash-recovery journals are machine-global) is ticket 36, already filed and deferred behind ticket 35.Tests
tests/claude-code/board-api/— 14/14 suites PASS (all extended;mock-server.pyprefix-matching; ~150 path assertions gained&repo=).ARKHO_DIR):test-human-verbs.shtwo-repo case — register from the second repo lands in it, list narrows,--all-reposshows both. Ran.scripts/lint-shell.shclean on every touched shell file.Follow-ups (tickets, not this PR)
claude --bgdrops the entire spawn env prefix for the worker's Bash shells, so spawned workers act as the human principal; the env pin above is correct but only reaches foregroundclaude -p.board-claims/,board-suppress/,surface-locks/underDAEMON_HOMEstill machine-global.After merge: commit
"repo": "arkho"intoarkho/.doperpowers/board.jsonand drop the runbook step-4 caveat.