Repository navigation
[Issue #125, #87] Per-secret operation lock; lock the encrypted vault - #132
Merged
Merged
Conversation
#125: set/rotate/import (setSecret), remove (deleteSecret) and enigma move hold a per-secret flock, keyed by scope and NAME, across their whole write -> index commit -> old-copy cleanup -> render fan-out sequence. A move's cleanup can no longer delete a copy another writer stored at the same address. The lock is async (acquireFileLockAsync) because it can be held across a depository prompt; a waiter fails after 30 s with E_LOCK_TIMEOUT naming the secret. move passes opLockHeld to setSecret. This departs from the issue's "fresh store refs" proposal: a dotenv value's address is the variable name itself, so fresh refs cannot protect it, and the issue's second reproduction deletes a dotenv line. #87: encrypted set/delete/deleteIfUnchanged (and first-use key creation) run under <ENIGMA_HOME>/locks/vault.lock. Tests: both #125 reproductions and a multi-process vault test fail with the locks disabled and pass with them. The render fan-out suites that drive cross-command interleavings now bypass the operation lock (test-only switch), since Rules A-C remain as defence in depth. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (4 files)
Previous Review Summary (commit 3a80e07)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 3a80e07)Status: No Issues Found | Recommendation: Merge Files Reviewed (9 files)
Reviewed by free · Input: 69.8K · Output: 4.8K · Cached: 663.7K |
…st workers Independent review of PR #132: - import holds each entry's operation lock only for its write and index commit; the batch render fan-out runs after the whole batch commits, outside the lock. A rotate in that window can leave the name with no .env line (no stored value lost; enigma render recovers). The docs and the op-lock header no longer claim import holds the lock through fan-out. Holding the locks across the batch is tracked as #133. - secret-op-lock.test.ts tracks its spawned workers and kills any still running in afterEach, so a failed assertion cannot leave a worker parked forever on a go file that teardown deleted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
Author
|
Review fixes pushed (
Gate: lint, typecheck, leak-fence, audit, build, check:native pass; 1758 tests pass, 6 skipped; |
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 #125. Closes #87.
#125: move cleanup could delete the current stored value
setSecret(set / rotate / import),deleteSecretandenigma movenow hold a per-secret lock, keyed by scope and NAME, across their whole sequence: depository write → index commit → old-copy cleanup → render fan-out. Two changes to the same secret can no longer interleave in any depository, so a move's cleanup can't delete a copy another writer just stored at the same address.acquireFileLockAsync) because it may be held across a depository prompt (Keychain, Touch ID, 1Password). A second change to the same name waits; after 30 s it fails withE_LOCK_TIMEOUT: "another change to NAME is in progress; try again when it finishes".flockbinds to the open file description), somovepassesopLockHeldto its innersetSecret.Departure from the issue's proposal. #125 suggested "fresh store refs". That can't protect the env depository, where a value's address is the variable name itself, and the issue's second reproduction deletes a dotenv line. A per-name lock covers every depository.
#87: encrypted vault read-modify-write had no lock
Encrypted
set,deleteanddeleteIfUnchanged(and first-use key creation) run under<ENIGMA_HOME>/locks/vault.lock, so two processes writing at once can't drop an entry.Tests
test/integration/secret-op-lock.test.ts: both enigma move: cleanup can delete the current stored value (data loss); use fresh store refs #125 reproductions plus a multi-process vault race, using real processes. All fail with the locks disabled (the vault test lost 83 of 160 entries) and pass with them on.test/unit/storage/op-lock.test.ts: nested moves, lock timeout, scope isolation.__setSecretOpLockBypassForTesting). It is never read from the environment in shipped code and is not present indist. Rules A–C stay as defence in depth and keep their tests.Docs
docs/api-contracts.md,docs/architecture.mdanddocs/feature-log.mdare updated for the lock and its timeout.Verification (Linux, Node 24, rebased on
mainat 2783b5b)npm audit --audit-level=high, build, check:native: passnpm test: 113 files passed, 1 skipped; 1758 tests passed, 6 skippednpm run buildleaves the committeddistbyte-identical🤖 Generated with Claude Code