Skip to content

tidy-secrets: one sequence for a vault mutation - #245

Merged
dinstein merged 1 commit into
mainfrom
tidy-secrets
Aug 7, 2026
Merged

tidy-secrets: one sequence for a vault mutation#245
dinstein merged 1 commit into
mainfrom
tidy-secrets

Conversation

@dinstein

@dinstein dinstein commented Aug 7, 2026

Copy link
Copy Markdown
Owner

Nightly tidy over internal/secrets + internal/session.

  • 1. secrets: writeLocked — one sequence for the four backend mutators (validate Ref → mutex → cross-process vault lock)

Checked and deliberately not done:

  • Chain.Set / Chain.Delete share the same prologue but announce afterwards while still holding c.mu; routing them through the helper would move that announcement out from under the mutex, which changes when a concurrent write becomes visible to a watcher.
  • MemoryManager.List / FindByToken each snapshot the session map under the lock in the same six lines. Two callers, no drift — below the bar.
  • No dead functions in either package. config.md's secrets invariants spot-checked against the code: DefaultKeyringTimeout = 3s, envValue's AGENTHUB_ and reserved-key guards both present.

The four backend mutators — keyringStore and encStore, Set and Delete —
each opened with the same three moves: validate the Ref, take c.mu, take
the cross-process vault lock. The paragraph above them already explains
what that lock is for: Migrate reads from one backend, writes to the
other, verifies, and only then deletes the source, so a concurrent writer
landing between the write and the read-back turns a verified handover
into a delete of the last remaining copy.

A fifth mutator that took only the mutex would reopen exactly that
window, and it would look no different from its neighbours while doing
it. writeLocked makes the sequence one thing, with the Ref check — whose
StorageKey becomes a keyring entry and a map key inside the encrypted
file — at the front of it.

Chain.Set and Chain.Delete deliberately stay out: they announce after the
write, today while c.mu is still held, and moving that out from under the
mutex changes when concurrent writes become visible to a watcher. That is
a behaviour question, not a rename.

make ci green.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@dinstein
dinstein merged commit e4c0dfb into main Aug 7, 2026
3 checks passed
@dinstein
dinstein deleted the tidy-secrets branch August 7, 2026 13:02
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.

1 participant