Repository navigation
fix: report a missing keychain key instead of silently starting a new one - #32
Conversation
… one When the database recorded its key's fingerprint but the recorded keychain item is gone, a normal start created a fresh key under that name and a move recorded the new item, both reporting "current". Saved passwords then stopped decrypting without a word, and the fresh item or the rewritten settings stood in the way of restoring the original key. Both paths now return `key-missing`: nothing is created under the recorded name, neither setting is touched, the machine-derived key is used for the session, and the window names the item and says how to restore it or reset. A database without a recorded fingerprint still gets a fresh key quietly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A database with no saved passwords lost nothing when its key item vanished, yet got the "can't be decrypted" notice on every start with no way out but editing settings by hand. `key-missing` now also needs a saved secret that no key at hand decrypts; otherwise a fresh key is started quietly. A move that cannot create its new item and finds the recorded item gone now reports `key-missing` too, instead of the keychain-unavailable notice. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review round 1Reviewer: independent Claude agent (Opus 5.5, general-purpose), read-only. Commit reviewed: 4b99528. Verdict: changes. Confirmed correct: a start with no recorded fingerprint stays quiet (fresh install, fallback-only database, after the documented reset). A sibling channel's move cannot delete an item this channel still records (
|
Response to review round 1
Finding 1 was major, so round 2 reviews 29b5f39. |
An empty password is stored encrypted too, so a connection without one still raised the missing-key notice although nothing was lost; it no longer counts. A channel without saved passwords no longer starts a fresh key under an item it shares with a channel whose passwords still need the missing key: that channel would get its key refused, and restoring the item would replace the fresh one. Both report `key-missing` instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review round 2Reviewer: independent Claude agent (Opus 5.5, general-purpose), read-only. Commit reviewed: 29b5f39. Verdict: changes. Confirmed correct:
|
Response to review round 2
Round 2 had a major finding, so round 3 reviews fb50b85. |
…items on the old path - An item holding something other than a key is not "missing": it keeps the earlier fallback outcome, so the reset advice stays right. - When another channel's passwords need the shared item, the log names that channel's database and the docs say how to get out of it. - An unreadable sibling database is ignored rather than said to block. - Tests for one-character passwords and for siblings that must not block. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review round 3Reviewer: independent Claude agent (Opus 5.5, general-purpose), read-only. Commit reviewed: fb50b85. Verdict: approve (no blocker or major). Confirmed:
|
Response to review round 3Only minor and nit findings, so no further round.
|
Summary
When the app database recorded its key's fingerprint (
keychain.masterKeyCheck) but the recorded keychain item is gone:keepRecordedItem) created a fresh key under the recorded name and reportedcurrent;moveKey) whose previous item was missing recorded the new item and fingerprint and reportedcurrent.Either way saved passwords silently stopped decrypting, and the fresh item or the rewritten settings stood in the way of restoring the original key.
These paths now return a new outcome,
key-missing, which mirrorskey-mismatch. So doeskeepPrevious, a move that could not create its new item or was deferred. It fires when the item is absent (store.getreturned null), the database recorded a fingerprint, and one of these holds:On
key-missing:current, a move reportsmigrated);docs/keychain.md. When another channel is the reason, the log names its database.Everything else stays as before and quiet: a fresh install, a database that only ever ran without a keychain, one with no saved passwords or only empty ones, and the start after the documented reset all get a fresh key without a word. An item that holds something other than a key keeps the earlier
fallbackpath.Decisions
keepRecordedItem→keyMissinginsrc/backend-shared/services/master-key.ts; notice insrc/frontend-shared/stores/key-status.tsmoveKey, before the recording transaction; alsokeepPreviouskeyMissingcreates no item and writes no setting; the sibling check stops a fresh key under a name another channel's passwords need; tests assert the settings are unchanged and that restoring the item brings the passwords backtests/master-key.test.ts(normal start, move, failed and deferred move, shared item, viasetupMasterKeyandstorage.keyStatus; quiet starts without a fingerprint, without lost passwords and after a reset),tests/key-status-store.test.ts,src/backend-shared/services/encryption.test.tsVerification
bun test tests/master-key.test.ts tests/key-status-store.test.ts src/backend-shared/services/encryption.test.ts: 84 pass, 1 skip (a macOS-only codesign test). The new tests fail with the guards removed: the 4key-missingtests against the originalmaster-key.ts, and 3 tests with the sibling and empty-password guards removed.bunx tsc --noEmit,bun run lint,bun run format:check: clean. CI runs the full suite.current, no notice; after:key-missing, notice shown).Status
🤖 Generated with Claude Code