Skip to content

fix(daemon): preserve replacement admin credential during restart - #625

Merged
V3RON merged 4 commits into
mainfrom
bug/609
Oct 16, 2026
Merged

V3RON merged 4 commits into
mainfrom
bug/609

Conversation

@V3RON

@V3RON V3RON commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Closes #609

Status

Implement: done (red 43f9f67, green 81e8bd2). Review: 2 rounds, 0 open. Hardware: n/a. Gate: merged.

What is this?

This PR fixes a daemon replacement race that can leave admin commands without a credential after a restart.

How does it work?

The old daemon removes its admin credential before releasing the endpoint, and releases the endpoint even when that removal fails. A replacement can then claim the endpoint and persist its credential without old shutdown deleting it. The daemon manual and startup flow describe this ordering.

Why is it useful?

Restart authentication has a deterministic regression instead of depending on slow-lane scheduling. Restoring the old ordering fails its credential-read assertion.

Done when

  • Remove the old credential before releasing the endpoint — shutdown ordering in src/daemon/server.ts.
  • Keep the deterministic reproduction as passing regression coverage — src/daemon/server.test.ts; red 43f9f67, green 81e8bd2; fails again with the ordering reverted.
  • Preserve the losing-start guarantee that it never touches the winner's credential — existing daemon test passes.
  • Keep graceful shutdown and startup-failure paths covered — all daemon server tests pass.

Assumptions

none

Review

Spec review: 0 blocking, 0 fixed, 1 note. Code review: 1 blocking, 1 fixed, 0 notes. Claims review: 0 blocking, 0 fixed, 0 notes.
Rounds: 2. Tokens: n/a.

The reviews ran as detached fresh claude -p child sessions (one per reviewer, blind to the PR body and to each other, each in its own worktree of the reviewed head built by review-inputs.sh); this session's harness refused nested subagents. The code finding was raised as a note in both round-1 passes, verified as wrong state by a probe (failing remove() skipped host.stop(), leaving the endpoint claimed), and confirmed; round 2 (code + claims, 6d75aacc..144ed24f) found nothing. A continuation session repeated the round-2 check independently on the same head with the same result, and its own revert probes reddened each test variant for its named reason.

Written by an agent.

V3RON added 3 commits October 16, 2026 20:58
Pin the endpoint-release interleaving that lets an old daemon remove the replacement admin credential.
Keep shutdown credential cleanup within endpoint ownership so an old daemon cannot delete its replacement credential. 1 failing -> 0 failing; 127 daemon server tests pass.
Document credential removal before socket release so replacement credentials remain protected.
@V3RON
V3RON marked this pull request as ready for review October 16, 2026 19:31
@V3RON
V3RON merged commit 93ffed8 into main Oct 16, 2026
63 checks passed
@V3RON
V3RON deleted the bug/609 branch October 16, 2026 19:32
@V3RON
V3RON restored the bug/609 branch October 16, 2026 19:32
@V3RON
V3RON deleted the bug/609 branch October 16, 2026 19:50
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.

Slow lane: simlock token create sometimes runs without the admin credential after a daemon restart

1 participant