Feature plan: Step 1 · Step 2 · Step 3 · Step 4

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

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 localStorage only 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 stillInstalled guard with two tabs. Mitigation: a switch reuses the importAccountPrivateKey sequence.

  • 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_keychain first.

  • Dependencies: none.

  • Expected changes: in browser_signing.js, add keychainEntries(), addToKeychain(identity) and writeKeychain(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. Call addToKeychain from the key-making path, saveImportedBrowserIdentity and the Undo restore. A repeat fingerprint updates the username, never adds a second entry. Expose a read-only keychain() on window.__forumBrowserIdentity.

  • Verification approach: new tests/browser/browser_keychain.mjs makes 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 localStorage makes 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 near storageKeys, window.__forumBrowserIdentity.

Stage 2

Estimate: 0.08

  • Goal: retire forum_pki_previous_*.

  • Dependencies: Stage 1.

  • Expected changes: browser_signing.js moves any forum_pki_previous_* key into the keychain on load, then deletes it. local_message_pull.js stops writing the slot. Its status note says the old key stays in this browser's keychain.

  • Verification approach: update tests/browser/key_handoff.mjs so Connect leaves both keys in the keychain. Add a migration case to browser_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.js Connect, 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: importAccountPrivateKey drops the "Use a separate browser profile" refusal when the backup is a different key. It signs the session out of the old key with clearAuthenticatedIdentity before 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.js restore, 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.php gets one account-group of account-row entries (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 on storage. Use this key runs the Stage 3 sequence with the entry's private key.

  • Verification approach: browser_keychain.mjs switches X to Y and checks the session, forum_pki_fingerprint and the header label. A second tab shows Y without a reload. Update AccountKeyPageHooksTest for 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.js gains clearOwner(fingerprint) beside clearAll. 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 stored forum_pki_removed record replaces clearedKeypairBackup and 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-remove dialog.

  • Verification approach: browser_keychain.mjs removes Y, reloads, and Undo brings Y back. With the clock moved past five minutes, no value holds Y and X's saved copies remain. Extend private_message_cache_browser.mjs for clearOwner.

  • 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-remove dialog, 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. Update docs/reference/key_backups.md, docs/concepts/key_handoff.md and PF-20261104-F19 (Workflow, Evidence, a dated Notes: line).

  • Verification approach: replay the Step 2 user flow in one browser run. Run ./v3 test --smoke AccountKeyPageHooksTest, the changed browser checks and git 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