Repository source: docs/plans/browser_keychain/browser_keychain_step3_development_plan.md
Debug mode: enabled
Effort study: railspike-effort / v3/browser_keychain; cycle ledger. Standing P2 enrollment; parent v3/local_pull_simple.
Extended estimates: enabled
Cycle estimate: 0.80
Approved: Step 1 (Option A) and Step 2, 2026-11-28. Feedback: PF-20261104-F19. Its "log out but keep key" request is still pending and outside this plan.
Concepts touched
Browser keychain: created in Stage 6 as
docs/concepts/browser_keychain.md.Key backups and key handoff: changed. Stage 6 updates both entries.
Private key access, key retirement, replaced key: used unchanged.
Completion Contract
Normal entry: Account (
/account/key/), plus every existing way a key becomes active.End-to-end outcome: the Step 2 user flow. Restore Y over X, switch back to X, remove Y, reload, Undo, then let the window expire.
Recovery: a failed switch or restore puts the previous key back and shows a short message with Details. An Undo after expiry says the key is gone and points to Use a key from another device.
Deployment: static assets and one template only. There are no server, schema or config changes.
Release: the smoke set, the named PHP tests and the changed browser checks pass. Ilya merges and tries it in production. The full suite is not run.
Key Risks
High risk: removal or Undo could delete a key the member still needs. Early validation: Stage 1 adds keys before any stage removes them, and Stage 5's check removes X while Y stays. Mitigation: deletion touches one fingerprint only. A key leaves
localStorageonly on removal or after the Undo window.High risk: a switch in one tab could sign a post in another tab with the wrong key. Early validation: Stage 4 replays the
stillInstalledguard with two tabs. Mitigation: a switch reuses theimportAccountPrivateKeysequence.Data: migrating
forum_pki_previous_*could drop the key if the add fails. Mitigation: delete the old values only after the keychain write reads back.Guest keys clutter the keychain. Mitigation: the list shows only with two or more keys.
Stage 1
Estimate: 0.12
Goal: every key that becomes active is added to
forum_pki_keychainfirst.Dependencies: none.
Expected changes: in
browser_signing.js, addkeychainEntries(),addToKeychain(identity)andwriteKeychain(entries). Each entry holds fingerprint, username, armored public and private key, and the time it was added. It is stored as JSON, like compose drafts, because it is browser state and not a canonical record or editable file. CalladdToKeychainfrom the key-making path,saveImportedBrowserIdentityand the Undo restore. A repeat fingerprint updates the username, never adds a second entry. Expose a read-onlykeychain()onwindow.__forumBrowserIdentity.Verification approach: new
tests/browser/browser_keychain.mjsmakes a key, restores another by clipboard, and finds both. A second restore of the same key leaves two entries.Estimate details: driver: three write sites and the record format; uncertainty: low.
Risks or open questions: a full
localStoragemakes the add fail. Then the key change still happens, and the failure shows in Details.Canonical components/API contracts touched:
saveImportedBrowserIdentity, the key-making path nearstorageKeys,window.__forumBrowserIdentity.
Stage 2
Estimate: 0.08
Goal: retire
forum_pki_previous_*.Dependencies: Stage 1.
Expected changes:
browser_signing.jsmoves anyforum_pki_previous_*key into the keychain on load, then deletes it.local_message_pull.jsstops writing the slot. Its status note says the old key stays in this browser's keychain.Verification approach: update
tests/browser/key_handoff.mjsso Connect leaves both keys in the keychain. Add a migration case tobrowser_keychain.mjs.Estimate details: driver: one migration and one test rewrite; uncertainty: low.
Risks or open questions: deletion only after the write reads back (Key Risks).
Canonical components/API contracts touched:
local_message_pull.jsConnect,key_handoff.mjs.
Stage 3
Estimate: 0.10
Goal: restoring a backup of a different key adds it and makes it active.
Dependencies: Stage 1.
Expected changes:
importAccountPrivateKeydrops the "Use a separate browser profile" refusal when the backup is a different key. It signs the session out of the old key withclearAuthenticatedIdentitybefore it signs in with the new one. A backup whose own fingerprint doesn't match its key is still refused.Verification approach: extend
tests/browser/key_backup_ui.mjs: restoring Y over X ends signed in as Y, with X still in the keychain. A failed sign-in leaves X active.Estimate details: driver: session order on failure; uncertainty: medium.
Risks or open questions: the server may hold the old session if sign-out succeeds but sign-in fails. Recovery puts X back and signs in again as X.
Canonical components/API contracts touched:
importAccountPrivateKey,key_backup_ui.jsrestore,PrivateSiteAuth.authenticate.
Stage 4
Estimate: 0.15
Goal: Account lists the keychain, and Use this key switches.
Dependencies: Stages 1 and 3.
Expected changes:
account_key.phpgets oneaccount-groupofaccount-rowentries (name and short fingerprint), hidden with fewer than two keys. The active row is marked; each other row has Use this key. Its page script draws the list before paint and redraws onstorage. Use this key runs the Stage 3 sequence with the entry's private key.Verification approach:
browser_keychain.mjsswitches X to Y and checks the session,forum_pki_fingerprintand the header label. A second tab shows Y without a reload. UpdateAccountKeyPageHooksTestfor the new hooks. Check the list in Word97, Gloss and Ochre.Estimate details: driver: UI plus the two-tab check; uncertainty: medium.
Risks or open questions: the two-tab guard (Key Risks).
Canonical components/API contracts touched:
account-group,account-row,simple-status,syncSimpleUI,toolbar_identity_status.js.
Stage 5
Estimate: 0.15
Goal: Remove this key removes one key, with an Undo that survives a reload for five minutes.
Dependencies: Stage 4.
Expected changes:
private_message_cache.jsgainsclearOwner(fingerprint)besideclearAll.clearBrowserIdentity(fingerprint)removes that key from the keychain and, if active, from the active slot. It deletes only that key's saved copies and keeps the session sign-out it has today. A storedforum_pki_removedrecord replacesclearedKeypairBackupand holds the entry and its removal time. Each load purges an expired record. Rows for keys that aren't active also get Remove, through the same#key-removedialog.Verification approach:
browser_keychain.mjsremoves Y, reloads, and Undo brings Y back. With the clock moved past five minutes, no value holds Y and X's saved copies remain. Extendprivate_message_cache_browser.mjsforclearOwner.Estimate details: driver: replacing the in-memory Undo; uncertainty: medium.
Risks or open questions: deleting the wrong key (Key Risks).
Canonical components/API contracts touched:
clearBrowserIdentity,#key-removedialog,undo-remove,ForumPrivateMessageCache.
Stage 6
Estimate: 0.08
Goal: record the feature and check the whole flow.
Dependencies: Stages 1–5.
Expected changes: create
docs/concepts/browser_keychain.md. Updatedocs/reference/key_backups.md,docs/concepts/key_handoff.mdand PF-20261104-F19 (Workflow,Evidence, a datedNotes:line).Verification approach: replay the Step 2 user flow in one browser run. Run
./v3 test --smoke AccountKeyPageHooksTest, the changed browser checks andgit diff --check. Review the diff for duplication and scope.Estimate details: driver: docs and the end-to-end replay; uncertainty: low.
Risks or open questions: none beyond the earlier stages.
Canonical components/API contracts touched: concept inventory, feedback item format.
Study Checkpoint
2026-11-28T18:55Z; scope v1; starting revision 1d98d94b; R1 (hashes not re-verified); P2 standing enrollment, parent v3/local_pull_simple. Claude, single exposed rater.
Step 3 handoff: 0.80 projected total, reaffirmed from Step 2. The six stages match the Step 2 understanding. Stage estimates are not summed. Not hours or measured labor; no approval to advance.
— Claude · 2026-11-28 UTC · Model: claude-opus-5-5