Repository navigation
api tick: a renew learns from a refusal instead of repeating it - #158
Merged
Merged
Conversation
Two shapes reached the renew set on every tick of every api binding on a machine, and neither renewal could ever succeed. A run refused `repo-mismatch`. A renewal names a RUN and no repo, so the board resolves the repo through that run's ticket — and $DAEMON_HOME is machine-global, so a tick derives its work-list from metas that include runs it is not entitled to (one written before the repo stamp existed reads as every binding's). The client died on that refusal like any other, so the tick logged `renew failed — retried next tick` and did it again forever. Routed now: `renew()` raises RepoMismatch, and the tick records the refusal on the meta so its own later scans skip the run. Recorded PER BINDING, keyed by "<board>|<repo>". The binding that meets the refusal is routinely NOT the run's owner — a legacy meta reads as everyone's — so a machine-wide mark would let any neighbour strand the owner's live run: no renewal, the lease expires, the board reclaims a worker that is still writing. Per binding, each pays one refused call once and the owner (never refused) keeps its reach. The marks merge, so two bindings cannot detach each other in turn. The run association deliberately survives the mark. An ended run is over everywhere; a detached one may still be held by a live worker on its own board, and taking its bearer would break writes it is entitled to make. A re-fill drops the map with the rest of the run binding. A retired seat. `sminos retire` stops the session and writes status=retired, and `sminos sync` answers `noop` for any status outside working/blocked/idle — it declines to reconcile a record it considers finished. The liveness verdict read `noop` as "nothing changed, still live", so retiring a seat did not silence its lease. A status sync will never move again is now dead, whatever word it is; a meta carrying no status at all stays live, by the same legacy-is-ours rule the registry scans follow. The board does NOT name the owning repo on `repo-mismatch` (it names the caller's own scope) and answers 403, not 409 — verified against arkho's API.md, src/repo.js assertActorRepo, and a live probe. So the ticket's "stamp the repo the server named" is not available; the `board_detached` marker it offers as the alternative is the whole of what such an answer admits.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #60
A renewal names a run and no repo, so the board resolves the repo through
that run's ticket — and
$DAEMON_HOMEis machine-global, so an api tick derivesits work-list from metas that include runs it is not entitled to. Two such
shapes reached the renew set on every tick of every binding here, and neither
renewal could ever succeed:
repo-mismatch— the client died on it like any otherrefusal, so the tick logged
renew failed — retried next tickand did itagain, forever (observed continuously 2026-09-12 → 09-14 on run 7).
sminos retirestops the session and writesstatus=retired;sminos syncanswersnoopfor any status outsideworking/blocked/idle because it declines to reconcile a record it considers
finished. The liveness verdict read
noopas "nothing changed, still live",so retiring a seat never silenced its lease.
What changed
renew()routesrepo-mismatchto a newRepoMismatchinstead of dying — thesame per-route switch
obsolete_codesandabsentalready use, because thesame code is a caller mistake on
/tickets(filing into a repo you may not) anda standing fact about the object on the run-lifecycle routes. The tick records
the refusal on the meta as
board_detached;meta_is_minereads it, so thatbinding's scans stop emitting the run at all.
Keyed per binding (
"<board>|<repo>"), not machine-wide. This is the partthat matters. A legacy meta reads as every binding's, so the tick that meets
the refusal is routinely a neighbour of the run's real owner. Detached
machine-wide, that neighbour would strand the owner's live run — no renewal,
lease expires, the board reclaims a worker that is still writing, which is worse
than the noise being fixed. Per binding, each pays one refused call once and the
owner (never refused) keeps full reach. The marks merge, so two bindings cannot
detach each other in turn.
The run association deliberately survives the mark. An ended run is over
everywhere; a detached one may still be held by a live worker on its own board,
and taking its bearer would break writes it is entitled to make. A re-fill drops
the map with the rest of the run binding (
sminos.py'sdroptuple)._livenessnow treats any statussminos syncwill never move again as dead(
retired,stopped,gone,failed), while a meta carrying no statusstays live — the same legacy-is-ours asymmetry the registry scans follow, since
wrongly excluding a meta silently kills a live run while wrongly including one
only costs a refused request.
_retire_run_locallyand the new_detach_meta_locallynow share one writer(
_meta_edit_for_run): same metalock, same "only while the meta still namesthis run" guard, same mode-preserving tmp+replace.
Corrections to the ticket's Shape
Two of its premises are wrong, and the design follows the code rather than the
ticket. Verified three ways —
arkho/board-service/API.md§ the run-lifecyclerepo rule,
src/repo.js:assertActorRepo, and a live probe against a realservice instance:
scope:
this credential acts in probe-other — what it named belongs to another repo. API.md states the withholding is deliberate ("a caller that cannot actin it is owed a refusal rather than a fact"). So "stamp the meta with the repo
the server named (the error body carries it)" is not available, and guessing
one out of the message would be worse than not guessing — a guess landing on
the caller's own repo recreates the exact retry loop. The
board_detachedmarker the ticket offers as the alternative is the whole of what such an
answer admits.
Its third bullet (
run-ended/not-found→ mark the meta released) needed nochange:
renewLeaseanswersrun-endedfor a missing run too (API.md'snot-foundrow does not listrenew, andclaims.jsfalls a null repo throughto the
run-endedanswer), and the api slot counter_api_registry_countalready requires
run_id, which_retire_run_locallystrips. The drill pinningthat (
an ended run releases its local dispatch slot) was already green.Validation Evidence
run 60: renew failed — retried next tick, plusPOST /runs/61/renewfor the retired seatrepo-mismatch: first tick logs once and stamps, second issues no renewtest-sweep-renew-relay.sh:a repo-mismatch refusal is named for what it is,the refused binding marks itself off,the second tick issues no renew for the detached run,and reports neither of them againa retired seat's lease is never renewed,nor for the retired seatour mark never silences a neighbour,which marks itself off on its own refusal,so its second tick is quiet as well,and neither mark erased the othertest-client-core.sh:the refused binding is detached,a neighbour's refusal does not detach the owner,gh keys the same way,an empty detach map detaches nothing,nor does a malformed onetests/claude-code/board-api/*(17 suites) all greenrun-skill-tests.sh— full run, every board-api suite[PASS]ARKHO_DIR=… integration/test-lease-renewal.sh→PASS test-lease-renewal.sh, 14/14 ok, on a scratch Postgres + real A1 servicerepo-mismatchshapeprobe-other, renewed adoperpowersrun →HTTP 403 {"error":{"code":"repo-mismatch","message":"this credential acts in probe-other — what it named belongs to another repo"}}, and the client routed it:RESULT: RepoMismatch routedscripts/lint-shell.shbaseline unchanged--alloutput from this worktree is byte-identical (diffclean) to the same command on the pristine main checkout; both exit 1 on the same pre-existing warnings intest-subagent-driven-execution-integration.sh,test-worktree-path-policy.sh,tests/review-bench/*. Default (changed-files) mode over the 4 shell files in this diff: exit 0scripts/bump-version.sh 7.90.0— all 4 declared manifests in sync, audit cleanrun-skill-tests.shis not fully green, and not because of this diff.test-subagent-driven-execution.shfails: 21 passed / 1 failed / 9 skipped (the9 are the ARKHO_DIR-gated tier). That test asks a live Claude session to
describe the SDE skill and regex-matches its free prose; its own header says
so ("string-matches its verbal explanation… Kept by design"). It is
nondeterministic: it passed on an earlier full run of this same diff, then
failed three different ways —
timeout after 900s, thenReviewer is skeptical,then
Read at beginning. Run from the pristine main checkout it fails too(
[FAIL] Read at beginning, 65s). It references none of the six files in thisdiff (
grep -cfor them = 0).Confusions
service deliberately withholds it and answers 403 rather than 409 — see
Corrections above. Worth knowing when writing future tickets against this
surface: the run-lifecycle routes tell a caller only that an object is not
theirs, never whose it is.
_slots_used(named in the ticket) turned out to be the gh-mode counter —it reads
_board.snapshot(). The api path uses_api_registry_count, whichalready requires
run_id. Left alone. It is worth noting that_slots_useddoes not honour
run_ended_atand does not filter by board identity at all,but both are gh-mode concerns outside this ticket and TECH-DEBT.md row 13
already tracks the second.
FOLLOW-UPS: none