Skip to content

api tick: a renew learns from a refusal instead of repeating it - #158

Merged
SSFSKIM merged 2 commits into
mainfrom
worktree-60-api-implementer
Sep 15, 2026
Merged

SSFSKIM merged 2 commits into
mainfrom
worktree-60-api-implementer

Conversation

@SSFSKIM

@SSFSKIM SSFSKIM commented Sep 15, 2026

Copy link
Copy Markdown
Owner

Closes #60

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 an api tick derives
its 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:

  • a run refused repo-mismatch — the client died on it like any other
    refusal, so the tick logged renew failed — retried next tick and did it
    again, forever (observed continuously 2026-09-12 → 09-14 on run 7).
  • a retired seat — sminos retire stops the session and writes
    status=retired; sminos sync answers noop for any status outside
    working/blocked/idle because it declines to reconcile a record it considers
    finished. The liveness verdict read noop as "nothing changed, still live",
    so retiring a seat never silenced its lease.

What changed

renew() routes repo-mismatch to a new RepoMismatch instead of dying — the
same per-route switch obsolete_codes and absent already use, because the
same code is a caller mistake on /tickets (filing into a repo you may not) and
a standing fact about the object on the run-lifecycle routes. The tick records
the refusal on the meta as board_detached; meta_is_mine reads it, so that
binding's scans stop emitting the run at all.

Keyed per binding ("<board>|<repo>"), not machine-wide. This is the part
that 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's drop tuple).

_liveness now treats any status sminos sync will never move again as dead
(retired, stopped, gone, failed), while a meta carrying no status
stays 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_locally and the new _detach_meta_locally now share one writer
(_meta_edit_for_run): same metalock, same "only while the meta still names
this 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-lifecycle
repo rule, src/repo.js:assertActorRepo, and a live probe against a real
service instance:

  • It is 403, not 409.
  • The board does not name the owning repo. It names the caller's own
    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 act
    in 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_detached
    marker 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 no
change: renewLease answers run-ended for a missing run too (API.md's
not-found row does not list renew, and claims.js falls a null repo through
to the run-ended answer), and the api slot counter _api_registry_count
already requires run_id, which _retire_run_locally strips. The drill pinning
that (an ended run releases its local dispatch slot) was already green.

Validation Evidence

Claim Evidence
Both gaps reproduce before the fix The new drills failed on the unfixed tree with the ticket's own symptom verbatim: run 60: renew failed — retried next tick, plus POST /runs/61/renew for the retired seat
Acceptance drill 1 — legacy meta refused repo-mismatch: first tick logs once and stamps, second issues no renew test-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 again
Acceptance drill 2 — a retired meta gets no renew same file: a retired seat's lease is never renewed, nor for the retired seat
A neighbour binding is not silenced, and converges on its own refusal same file: our 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 other
The predicate itself test-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 one
tests/claude-code/board-api/* (17 suites) all green run-skill-tests.sh — full run, every board-api suite [PASS]
No regression in the renew phase against a real board service ARKHO_DIR=… integration/test-lease-renewal.sh → PASS test-lease-renewal.sh, 14/14 ok, on a scratch Postgres + real A1 service
The server's actual repo-mismatch shape Live probe: minted a credential scoped to probe-other, renewed a doperpowers run → 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 routed
scripts/lint-shell.sh baseline unchanged --all output from this worktree is byte-identical (diff clean) to the same command on the pristine main checkout; both exit 1 on the same pre-existing warnings in test-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 0
Version bumped in the same commit scripts/bump-version.sh 7.90.0 — all 4 declared manifests in sync, audit clean

run-skill-tests.sh is not fully green, and not because of this diff.
test-subagent-driven-execution.sh fails: 21 passed / 1 failed / 9 skipped (the
9 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, then Reviewer 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 this
diff (grep -c for them = 0).

Confusions

  • The ticket's Shape describes an error body that carries the owning repo. The
    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, which
    already requires run_id. Left alone. It is worth noting that _slots_used
    does not honour run_ended_at and 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

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.
@SSFSKIM
SSFSKIM merged commit 74a981c into main Sep 15, 2026
@SSFSKIM
SSFSKIM deleted the worktree-60-api-implementer branch September 15, 2026 17:06
SSFSKIM added a commit that referenced this pull request Oct 28, 2026
…lease-order

sminos 1.27.8 for this branch's #156 and #158, above main's 1.27.7.

Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
SSFSKIM added a commit that referenced this pull request Oct 28, 2026
sminos 1.27.8: queued operator events released in the order said, and named after a leave (#158, #156)
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.

gh-mode meta writes truncate bodies that quote a board:meta marker (strip_meta leftmost-match bug)

1 participant