Repository navigation
fix(browser): serialize cookie imports per partition - #15095
Conversation
cfcea0b to
3121873
Compare
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
Included review availability: Your plan includes up to 10 reviews per rolling hour; 3 remain after this review. 📝 WalkthroughWalkthroughCookie mutation locking now uses a generalized registry with explicit acquisition and callback-scoped APIs. Replace-mode imports retain the lock through clearing, replacement, rollback, and cookie-store disposal. Browser imports protect live-cookie probing, clearing, and in-memory writes with one lock. Concurrency tests cover serialization, interleaving, error release, rollback scope, repeated release, and concurrent imports. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/main/browser/browser-cookie-import-clear.ts (1)
69-76: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueShorten the mutation-lock rationale comments.
Keep the STA reference and one short statement of the transaction boundary.
src/main/browser/browser-cookie-import-clear.ts#L69-L76: Reduce the API rationale to one concise statement.src/main/browser/browser-cookie-import-concurrency.test.ts#L4-L14: Reduce the test background to one concise statement.src/main/browser/browser-cookie-import.ts#L609-L611: Reduce the replace-mode rationale to one concise statement.src/main/browser/browser-cookie-import.ts#L1902-L1905: Reduce the live-jar rationale to one concise statement.As per coding guidelines: “Comments must be concise, non-obvious, and brief—prefer one line; do not explain obvious behavior or walk through code.”
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 240765e2-b2da-46cc-a33e-8eaaad7a0e84
📒 Files selected for processing (3)
src/main/browser/browser-cookie-import-clear.tssrc/main/browser/browser-cookie-import-concurrency.test.tssrc/main/browser/browser-cookie-import.ts
Included review availability: Your plan includes up to 10 reviews per rolling hour; 0 remain after this review.
583ba6e to
cb5cfeb
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/main/browser/browser-cookie-import-concurrency.test.ts (2)
139-144: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueShorten the narrative block comments.
Both blocks record review history and reasoning about mutation testing. Keep the intent in one line each and drop the process narrative.
As per coding guidelines: "Comments must be concise, non-obvious, and brief—prefer one line; do not explain obvious behavior or walk through code."
Also applies to: 233-237
Source: Coding guidelines
19-32: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCover lock release when
dispose()throws.Configure
disposeClearStoreMockto throw and assert that a subsequent import on the same partition completes. No existing test covers this cleanup failure path.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: d3c3687e-9ef7-4be2-9379-6478ad7c6789
📒 Files selected for processing (3)
src/main/browser/browser-cookie-import-clear.tssrc/main/browser/browser-cookie-import-concurrency.test.tssrc/main/browser/browser-cookie-import.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- src/main/browser/browser-cookie-import.ts
- src/main/browser/browser-cookie-import-clear.ts
Included review availability: Your plan includes up to 10 reviews per rolling hour; 1 remains after this review.
Review provenance and one caveat on how the final verdict was deliveredRecording this on the PR rather than only in working notes, because the merge decision is made from here. VerdictRound 4 returned Caveat, stated plainly: that verdict was UNDELIVERED through the orchestration channel. The reviewer's That capability revocation is an infrastructure fault — every worker dispatch in this session started with
The contrast that matters, given this PR's lineage: #14729's review was substantively incomplete — interrupted with concerns never re-verified. This one reached a conclusion; only the message failed to send. What the earlier rounds found, and how each was fixed
Independent mutation testing (not from any review)
A mutation has to be structure-preserving to mean anything: an early attempt dropped path B's wrapper but left the closing Known-flaky CI
|
Two concurrent cookie imports on one partition can erase a session. Nothing serialises imports per partition — neither the renderer IPC handler (browser-session-profile-ipc.ts) nor the runtime RPC method (orca-runtime-browser.ts) — and the clear lock covered only the clear itself, so it was released before the writes and before any rollback. Reachable interleaving: import A replaces cookies for its imported domains, releases the lock, and later fails a write; import B clears and writes; A's rollback then removes cookies B already wrote and reported as imported. Path B has the same shape: A clears, B clears, then A writes its cookies on top of B's jar. Fix: one lock spans the whole live-jar transaction on both paths — the clear/replace, the writes, and the rollback. withCookieClearLock becomes acquireCookieMutationLock/withCookieMutationLock so path A can hold it across a try/finally rather than a single callback. Rebased onto #15030 (STA-4300), which rewrote this file: imports now write through CDP identities, so path A's writes moved from an inline cookies.set() loop into writeImportedCookies(), path B's into the same helper, and — the part that matters for a lock — importValidatedCookies no longer holds the Electron Session at all. It receives a CookieImportTarget that hides the Session behind openWriteStore(), and openWriteStore() builds a FRESH adapter per call, so keying the lock on anything reachable from it would serialise nothing. The target therefore carries mutationLockOwner, set to session.fromPartition's instance, which is the same object the native path locks on. That is what keeps both paths on one key per partition. Deliberately bounded: this covers the LIVE JAR only. Staging and cold-start replay keep their existing semantics, so two other pre-existing hazards in that subsystem are untouched and still open — the crash window between the clear and the result, and a permanently-armed replay when replay keeps failing. Both need the pending-image operations to become provable, which is a different change. The lock is keyed per owner, so imports into different partitions still run concurrently. Mutation-proved against the rebased tree, every mutation structure-preserving (brace/paren balance pinned) and every one re-run rather than carried over: dropping path A's acquire reddens the file-import detector; keying path A's acquire on a fresh object instead of mutationLockOwner reddens it too — the lock-present-but-miskeyed shape this rebase risks; replacing path B's lock with a passthrough reddens the native detector; doing both reddens both, which rules out incidental serialisation; and neutering the cold-init probe's lock reddens the new probe detector. That last detector is new: neutering the probe lock previously left all 779 browser tests green, so the probe's protection was unproven. The concurrency suite's store stub also gained writeCookieIdentity and getStoragePath. Without them the STA-4300 code throws a TypeError that writeImportedCookies catches as a write rejection, so the imports would have taken the failure path while the ordering assertions still passed. Each real import test now asserts writeCookieIdentity was CALLED, and that cookies.set never was. src/main/browser: 72 files, 780 tests, green; typecheck, oxlint, type-aware code quality, oxfmt and the max-lines ratchet all clean.
cb5cfeb to
f8a3a48
Compare
Rebased onto current main — the lock re-established against #15030's rewriteThe review-provenance comment above still stands for the pre-rebase tree. This adds what changed, and re-derives the protection from scratch rather than carrying the old evidence forward. The conflictThe branch went 69 commits behind and Two structural changes matter for a lock:
Resolution: Every live-jar / staged-image mutation in main's current structure, and whether the lock covers itPath A —
Both early Path B —
Stated plainly — what sits outside the lock:
Both are the declared boundary of this change, unchanged from the pre-rebase version: it covers the live jar only. The staging-side hazards (the crash window between the clear and the result, and a permanently-armed replay) still need the pending-image operations to become provable, which is a different change.
Mutation proofs — re-run against the REBASED code, not carried overEvery mutation is structure-preserving; brace/paren/bracket balance was asserted identical to the clean file before each run, so nothing turned into an uninvoked block.
The second row is the one this rebase specifically needed: it is the lock present but no longer covering the right thing shape, and the detector catches it. Two detector defects found and fixed while re-proving1. The store stub went stale and would have made both real-import tests vacuous. STA-4300 writes via 2. The cold-init probe's lock had no detector at all. Neutering it left all 779 browser tests green, because the other native test pre-creates the target DB so the probe never runs. Added Validation at
|
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/main/browser/browser-cookie-import-concurrency.test.ts (1)
233-234: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winA failed assertion leaves import promises pending forever. In all three suites the unblock call runs after the assertions. If an assertion throws, the gate is never resolved, the awaited import promises stay pending, and the run stalls until the Vitest timeout instead of reporting the assertion. Release the gate from cleanup in each suite.
src/main/browser/browser-cookie-import-concurrency.test.ts#L233-L234: callreleaseFirstWrite()in the suiteafterEachas well, and await the imports with the assertions in atry/finally.src/main/browser/browser-cookie-import-concurrency.test.ts#L353-L354: apply the sameafterEachrelease for the native suite gate.src/main/browser/browser-cookie-import-concurrency.test.ts#L456-L457: store the lock release in a suite-scoped variable and call it fromafterEachso a failed probe assertion cannot wedge the lock owner.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 467c162e-edb5-407f-8c65-e5470f8ab67a
📒 Files selected for processing (3)
src/main/browser/browser-cookie-import-clear.tssrc/main/browser/browser-cookie-import-concurrency.test.tssrc/main/browser/browser-cookie-import.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/main/browser/browser-cookie-import-clear.ts
Included review availability: Your plan includes up to 10 reviews per rolling hour; 3 remain after this review.
Review loop — rounds 1 and 2 (round 3 running)Recording each round on the PR, because both rounds changed the branch and the merge decision is made from here. The rebase comment above still stands for The branch is now three commits:
Round 1 — made changesIt re-derived the mutation inventory, found the native path's flush / staging / pending-image mutations sitting outside the lock, and hoisted the lock to cover the whole function.
I did not take its report at face value. What I verified independently:
Round 2 — made changes, agrees round 1 should stayRound 2 was dispatched with round 1's own commit as its primary target. Its verdict, verbatim from its terminal:
It pushed Round 2 also ran its own mutation battery with an explicit brace/paren/bracket balance check before trusting any red result, and confirmed by diff that the source was byte-identical afterwards — the discipline this PR needs, since an earlier attempt on it turned a block into an uninvoked IIFE and read six "the code never ran" failures as a passing mutation. Full suite at One correction to my own earlier reasoningI initially suspected round 1's wrap now holds the partition lock across a blocking macOS Keychain prompt. It does span Round 3 is runningRound 2 stated it did not end clean, so the loop continues. Round 3's primary target is round 2's own detector, with two questions it must settle by mutation rather than by reading:
Two process notes
Not merged. Rounds 1 and 2 are recorded as changed, not clean; the loop continues until a round returns CLEAN WITH NO CHANGES. |
Round 3 — made changes, and its detector is vacuousRecording this because it is the kind of thing that otherwise reads as progress. Round 4 is running with it as the primary target. Round 3 was dispatched with round 2's detector as its target, and asked to settle two things by mutation rather than by reading: whether round 2's It found the first gap correctly and pushed That test does not detect what it was added to detect. Reproduction, from the repo root:
It ran, it was not skipped, and it passed. The captured diag shows why: import A reached For contrast, round 2's detector is genuinely load-bearing. The same narrowing makes it fail: I verified both of these myself rather than relying on the round reports. Where that leaves the branch
Suite at The interleaving nobody has written down yetThree rounds have asserted the staged-image hazard is real without stating it. Here is the sequence I believe is reachable on the pre-
That is the same silent-partial-loss shape as STA-4013 / 4061 / 4090 / 4170, which is why it is worth pinning properly rather than with a test that passes either way. If round 4 finds it is not reachable, then Round 4's instructionsReplace the vacuous test with one that fails against Rounds 1, 2 and 3 are all recorded as changed, not clean. Not merged. |
Rounds 4 and 5 — the loop's premise was wrong, and the real hazard is a different oneRounds 1–3 all argued that round 1's whole-function lock closes a pending-image bookkeeping ordering hazard. That is not the hazard. Round 4 deleted round 3's test for the right action but the wrong reason, and round 5 settled it. Round 4 — deleted the vacuous testRound 4 reproduced the vacuity and pushed The bookkeeping-ordering hazard is NOT reachableI need to correct something I wrote in the previous comment. I described round 3's test as passing by "microtask luck." It wasn't luck — the property holds deterministically, and the test could never have reddened. On
The REAL hazard: a stale staged image
Round 1's whole-function lock closes it by bringing line 1641 inside the transaction: A copies, clears, writes and bookkeeps, and only then does B copy — so no image can predate a completed concurrent import. So Round 5 — confirmed both, and shipped the detector that was missingRound 5 was dispatched with both claims and told explicitly I would rather be corrected than confirmed. Its verdict:
It pushed I ran the acceptance test on it myself. Against Against the current source it passes, 8/8. It is enforced by the lock rather than by scheduling, so unlike round 3's it cannot pass in the broken state. Branch and gates at
|
| Commit | Round | Status |
|---|---|---|
f8a3a48ffb |
— | the rebased STA-4601 change |
70946bda56 |
1 | whole-function native lock — keep, justified by the stale-image hazard |
3d97f1efbe |
2 | flushStore detector — verified load-bearing |
e3003ab36f |
3 | vacuous detector |
6203162fa7 |
4 | deletes it |
57db159ebc |
5 | stale-staging-image detector — verified load-bearing |
src/main/browser— 72 files, 780 tests, green- typecheck (project runner, not
tsc -b) — clean oxlint, native code-quality (src config tests mobile --deny-warnings), type-aware code-quality — all cleanoxfmt --check— clean- max-lines ratchet —
OK — 188 grandfathered suppression(s), no new bypasses; zeromax-linesdisables added across the whole diff
Round 6 is running as a convergence round, with round 5's own detector as its primary target and an explicit instruction that returning CLEAN WITH NO CHANGES is the desired outcome rather than a failure — plus the same acceptance test applied to every test on the branch, since two of six rounds shipped something that did not do what it claimed.
Not merged.
Rounds 6 and 7, and where I am stopping the loopI ran seven rounds. Every round made a change, so the loop never formally returned CLEAN WITH NO CHANGES. But the changes shrank monotonically — round 1 restructured the lock, round 7 changed three lines of test setup — and rounds 6 and 7 both reported no production-code defects. I am calling that substantive convergence and handing it to you rather than running an eighth round, because the marginal finding is now test hardening rather than correctness. Round 6 —
|
| Commit | Round | Outcome |
|---|---|---|
f8a3a48ffb |
— | STA-4601 rebased onto #15030's rewrite |
70946bda56 |
1 | whole-function native lock — keep, justified by the stale-image hazard |
3d97f1efbe |
2 | flushStore detector — load-bearing |
e3003ab36f |
3 | staged-image detector — vacuous |
6203162fa7 |
4 | deletes round 3's test |
57db159ebc |
5 | stale-staging-image detector — load-bearing |
941748430f |
6 | non-vacuity guards |
cdb0db690b |
7 | widens the detector's lock boundary |
Gates, all run by me at this head rather than taken from the round reports:
src/main/browser— 72 files, 780 tests, green; concurrency suite 5× stable- acceptance test — the suite fails against
f8a3a48ffb's source and passes against current, so the detectors are load-bearing rather than decorative - typecheck (project runner, never
tsc -b) — clean oxlint, native code-quality (src config tests mobile --deny-warnings), type-aware code-quality — cleanoxfmt --check— clean- max-lines ratchet —
OK — 188 grandfathered, no new bypasses; zeromax-linesdisables added
main moved 8 commits during the session. Its three newest commits touch none of these three files, and GitHub reports the PR MERGEABLE, so I did not re-rebase again — chasing a moving base adds risk without adding signal.
What I'd want you to decide
- Keep
70946bda56? It crosses the live-jar-only boundaryf8a3a48ffbdeclared. I believe it should stay — the stale-staged-image hazard is real and reachable, and it is now pinned. But it is a scope expansion past what the ticket described, so it is your call, not the loop's. - Squash? Eight commits, four of which are the loop arguing with itself (round 3 adds a test, round 4 deletes it). The repo squash-merges, so this resolves itself on merge — but if you want the branch itself readable, it should collapse to one or two.
Process notes
worker_donedelivery is unreliable (STA-4671). Round 2's capability was revoked mid-run and its verdict never reached the mailbox; I read it from the terminal. Rounds 3, 5, 6 and 7 delivered.worker-startalso twice returned "the Orca runtime closed the connection before responding" and needed--retry-requestto recover idempotently.worker-start --base-branchresolved to a stale local branch atcfcea0b687(92 behind main, carrying an unrelatedrevert(browser): move import serialization out to STA-4601). Round 1 read that tree before I caught it. Every subsequent round's worktree had to be manually repointed at the real head.- Two of seven rounds shipped something that did not do what it claimed (rounds 1 and 3), and both passed their own author's review. The acceptance test — fail against the pre-fix source, pass against current, or be deleted — is what caught them, and is worth making standard for any concurrency detector.
Not merged.
Manual Electron validation (STA-4601)Verdict: IMPORT WORKS This is the missing local Settings-surface run. It does not prove or disprove the concurrency race (that is already pinned by the automated suite). It tests whether wrapping every jar mutation in a per-partition lock broke or deadlocked ordinary import. I did not merge. Instance (CDP ownership)
What I actually clickedSettings → Browser → Session & Cookies → Import Cookies → From Google Chrome → stably.ai (Chrome directory Import 1
Import 2 (same partition, immediately after)
A lock that never released would have hung import 2. It did not. TimingBoth real Chrome imports of 949 cookies finished in ~320–330 ms. That is not a noticeable stall. I did not time Concurrent imports through the UICould not start two imports close together through the UI. Unproven (said plainly)
ScreenshotsBefore — Default / No cookies imported: Menu — From Google Chrome → stably.ai / Brennan: After import 1 — toast + Google Chrome (stably.ai): After import 2 — same partition, completed: |
…d clear (STA-4797) #15095's detector read "has the second import started clearing yet?" off clearData call counts. Scoping the clear removed the bulk clearData path, so that signal is gone and the assertion measured nothing. It now reads the same question off the removals themselves, which is strictly more specific: the seeded jar holds a stale cookie for each import's own domain, so `remove:old-a` present with `remove:old-b` absent proves the first import cleared and the second has not — where a call count could not tell the two apart. The completed run then pins the exact removal sequence, which also records that each import clears only its own domain. The seed had to move onto the imported domains for the same reason its own comment already gave for not leaving the jar empty: under a scoped clear, a jar holding only an unrelated site is the empty-jar case wearing a disguise -- the clear returns having removed nothing and every assertion passes vacuously. Mutation-checked: with the per-partition lock removed this test still fails, so #15095's protection is intact and the re-anchoring did not hollow it out.
…d clear (STA-4797) #15095's detector read "has the second import started clearing yet?" off clearData call counts. Scoping the clear removed the bulk clearData path, so that signal is gone and the assertion measured nothing. It now reads the same question off the removals themselves, which is strictly more specific: the seeded jar holds a stale cookie for each import's own domain, so `remove:old-a` present with `remove:old-b` absent proves the first import cleared and the second has not — where a call count could not tell the two apart. The completed run then pins the exact removal sequence, which also records that each import clears only its own domain. The seed had to move onto the imported domains for the same reason its own comment already gave for not leaving the jar empty: under a scoped clear, a jar holding only an unrelated site is the empty-jar case wearing a disguise -- the clear returns having removed nothing and every assertion passes vacuously. Mutation-checked: with the per-partition lock removed this test still fails, so #15095's protection is intact and the re-anchoring did not hollow it out.
…imports (STA-4797) (#15375) * fix(browser): scope a native cookie import's clear to the domains it imports (STA-4797) A native import (Settings -> Browser -> Import Cookies -> From Google Chrome) cleared the entire target partition's cookie jar, keeping only the non-transplantable google.com family. Every unrelated site the user was signed into in that partition was silently signed out, with no warning before and no disclosure after. Importing three sites signed you out of every other one. The stated rationale -- mixing stale and imported cookies makes sites reject the session -- reaches only as far as the domains being imported. Beyond them a clear has nothing to reconcile. The file/paste path already did the narrow thing via replaceCookiesForImportedDomains; the two import paths simply disagreed about scope, and the narrow one is the defensible shape. The clear now covers only the domains the import writes, through one shared predicate: - browser-cookie-import-policy.ts: importedDomainScope() / domainIsInImportedScope() are exported as the single scope definition used by all three clears, so they cannot drift apart. - browser-cookie-import-clear.ts: removeTransplantableCookies takes a required importScope. It is not defaulted -- a default would be the whole jar again. The scope test runs before the removal-URL derivation, so an unaddressable cookie parked in an unrelated corner of the jar no longer fails an import that was never going to touch it. - The bulk clearData shortcut is gone, and clearData leaves CookieClearSession for the same structural reason 'set' already had. clearData clears by exclusion, so the only scope it can express is "everything except google.com" -- the defect. An include list is no better: it matches at the registrable-domain boundary, so it would still take host-only siblings the import does not replace, and a partial delete followed by a rejection would destroy them with no identity to restore from. The frozen per-coordinate plan is now the only removal path, and it covers the imported domains rather than the jar. - browser-cookie-staged-image-clear.ts (new): the staged image is a copy of the live jar that replaces it wholesale on the next cold start, so its DELETE FROM cookies WHERE NOT (<google>) was a second whole-partition wipe. Narrowing the live clear alone would have re-erased the partition one restart later. It now clears to the identical scope, through the identical predicate. The scope is named from the emitted plan, so the removal set is the write set. Google stays exempt by policy (STA-3811), unchanged. No wire or summary change: the summary's existing `domains` field already names the imported domains, which is now exactly the scope that was cleared. Tests: fixtures in this module start with an empty cookie jar, which is why a full gate stack passed a session-erasing defect before. browser-cookie-import- scope.test.ts uses a populated jar with a session for a site outside the import set, and reads the staged file itself so the restart path is observed rather than assumed. All three cases fail against pre-fix source. The real-Electron partition test now seeds both an in-scope stale cookie (still removed) and an out-of-scope live one (now survives). * refactor(browser): drop the unreachable removal-URL failure branch (STA-4797) Scoping the clear made the `Could not clear existing cookies` throw in removableCookieEntries dead: a cookie whose domain does not normalize is now skipped by the scope test above it, so nothing reaches the URL derivation with anything but an already-parsed hostname. Rather than leave a fail-closed branch that cannot fire — this module has been misread before when a dead safety leg looked like a live one — the impossibility is now structural. cookieRemovalUrl takes a normalizeCookieDomain output and returns a string: `new URL` cannot throw on a host that already parsed as one, and assigning pathname never throws. Both callers lose their null branch, including the silent `if (url)` skip in replaceCookiesForImportedDomains, which would have narrowed a removal plan without saying so. The identically-worded throw in assertClearIdentitiesCoverRemovable is untouched — that one is live and is what keeps the mutated set inside the restorable set. * test(browser): re-anchor the native concurrency detector on the scoped clear (STA-4797) #15095's detector read "has the second import started clearing yet?" off clearData call counts. Scoping the clear removed the bulk clearData path, so that signal is gone and the assertion measured nothing. It now reads the same question off the removals themselves, which is strictly more specific: the seeded jar holds a stale cookie for each import's own domain, so `remove:old-a` present with `remove:old-b` absent proves the first import cleared and the second has not — where a call count could not tell the two apart. The completed run then pins the exact removal sequence, which also records that each import clears only its own domain. The seed had to move onto the imported domains for the same reason its own comment already gave for not leaving the jar empty: under a scoped clear, a jar holding only an unrelated site is the empty-jar case wearing a disguise -- the clear returns having removed nothing and every assertion passes vacuously. Mutation-checked: with the per-partition lock removed this test still fails, so #15095's protection is intact and the re-anchoring did not hollow it out. * fix(browser): merge staged cookie imports by domain scope (STA-4797)
* fix(browser): serialize cookie imports per partition (STA-4601) Two concurrent cookie imports on one partition can erase a session. Nothing serialises imports per partition — neither the renderer IPC handler (browser-session-profile-ipc.ts) nor the runtime RPC method (orca-runtime-browser.ts) — and the clear lock covered only the clear itself, so it was released before the writes and before any rollback. Reachable interleaving: import A replaces cookies for its imported domains, releases the lock, and later fails a write; import B clears and writes; A's rollback then removes cookies B already wrote and reported as imported. Path B has the same shape: A clears, B clears, then A writes its cookies on top of B's jar. Fix: one lock spans the whole live-jar transaction on both paths — the clear/replace, the writes, and the rollback. withCookieClearLock becomes acquireCookieMutationLock/withCookieMutationLock so path A can hold it across a try/finally rather than a single callback. Rebased onto stablyai#15030 (STA-4300), which rewrote this file: imports now write through CDP identities, so path A's writes moved from an inline cookies.set() loop into writeImportedCookies(), path B's into the same helper, and — the part that matters for a lock — importValidatedCookies no longer holds the Electron Session at all. It receives a CookieImportTarget that hides the Session behind openWriteStore(), and openWriteStore() builds a FRESH adapter per call, so keying the lock on anything reachable from it would serialise nothing. The target therefore carries mutationLockOwner, set to session.fromPartition's instance, which is the same object the native path locks on. That is what keeps both paths on one key per partition. Deliberately bounded: this covers the LIVE JAR only. Staging and cold-start replay keep their existing semantics, so two other pre-existing hazards in that subsystem are untouched and still open — the crash window between the clear and the result, and a permanently-armed replay when replay keeps failing. Both need the pending-image operations to become provable, which is a different change. The lock is keyed per owner, so imports into different partitions still run concurrently. Mutation-proved against the rebased tree, every mutation structure-preserving (brace/paren balance pinned) and every one re-run rather than carried over: dropping path A's acquire reddens the file-import detector; keying path A's acquire on a fresh object instead of mutationLockOwner reddens it too — the lock-present-but-miskeyed shape this rebase risks; replacing path B's lock with a passthrough reddens the native detector; doing both reddens both, which rules out incidental serialisation; and neutering the cold-init probe's lock reddens the new probe detector. That last detector is new: neutering the probe lock previously left all 779 browser tests green, so the probe's protection was unproven. The concurrency suite's store stub also gained writeCookieIdentity and getStoragePath. Without them the STA-4300 code throws a TypeError that writeImportedCookies catches as a write rejection, so the imports would have taken the failure path while the ordering assertions still passed. Each real import test now asserts writeCookieIdentity was CALLED, and that cookies.set never was. src/main/browser: 72 files, 780 tests, green; typecheck, oxlint, type-aware code quality, oxfmt and the max-lines ratchet all clean. * fix(browser): serialize native cookie staging * test(browser): pin native flush serialization * test(browser): pin staged cookie replay ordering * test(browser): remove vacuous staged replay detector * test(browser): detect stale native staging images * test(browser): guard cookie import ordering events * test(browser): cover staging lock boundary
…imports (STA-4797) (stablyai#15375) * fix(browser): scope a native cookie import's clear to the domains it imports (STA-4797) A native import (Settings -> Browser -> Import Cookies -> From Google Chrome) cleared the entire target partition's cookie jar, keeping only the non-transplantable google.com family. Every unrelated site the user was signed into in that partition was silently signed out, with no warning before and no disclosure after. Importing three sites signed you out of every other one. The stated rationale -- mixing stale and imported cookies makes sites reject the session -- reaches only as far as the domains being imported. Beyond them a clear has nothing to reconcile. The file/paste path already did the narrow thing via replaceCookiesForImportedDomains; the two import paths simply disagreed about scope, and the narrow one is the defensible shape. The clear now covers only the domains the import writes, through one shared predicate: - browser-cookie-import-policy.ts: importedDomainScope() / domainIsInImportedScope() are exported as the single scope definition used by all three clears, so they cannot drift apart. - browser-cookie-import-clear.ts: removeTransplantableCookies takes a required importScope. It is not defaulted -- a default would be the whole jar again. The scope test runs before the removal-URL derivation, so an unaddressable cookie parked in an unrelated corner of the jar no longer fails an import that was never going to touch it. - The bulk clearData shortcut is gone, and clearData leaves CookieClearSession for the same structural reason 'set' already had. clearData clears by exclusion, so the only scope it can express is "everything except google.com" -- the defect. An include list is no better: it matches at the registrable-domain boundary, so it would still take host-only siblings the import does not replace, and a partial delete followed by a rejection would destroy them with no identity to restore from. The frozen per-coordinate plan is now the only removal path, and it covers the imported domains rather than the jar. - browser-cookie-staged-image-clear.ts (new): the staged image is a copy of the live jar that replaces it wholesale on the next cold start, so its DELETE FROM cookies WHERE NOT (<google>) was a second whole-partition wipe. Narrowing the live clear alone would have re-erased the partition one restart later. It now clears to the identical scope, through the identical predicate. The scope is named from the emitted plan, so the removal set is the write set. Google stays exempt by policy (STA-3811), unchanged. No wire or summary change: the summary's existing `domains` field already names the imported domains, which is now exactly the scope that was cleared. Tests: fixtures in this module start with an empty cookie jar, which is why a full gate stack passed a session-erasing defect before. browser-cookie-import- scope.test.ts uses a populated jar with a session for a site outside the import set, and reads the staged file itself so the restart path is observed rather than assumed. All three cases fail against pre-fix source. The real-Electron partition test now seeds both an in-scope stale cookie (still removed) and an out-of-scope live one (now survives). * refactor(browser): drop the unreachable removal-URL failure branch (STA-4797) Scoping the clear made the `Could not clear existing cookies` throw in removableCookieEntries dead: a cookie whose domain does not normalize is now skipped by the scope test above it, so nothing reaches the URL derivation with anything but an already-parsed hostname. Rather than leave a fail-closed branch that cannot fire — this module has been misread before when a dead safety leg looked like a live one — the impossibility is now structural. cookieRemovalUrl takes a normalizeCookieDomain output and returns a string: `new URL` cannot throw on a host that already parsed as one, and assigning pathname never throws. Both callers lose their null branch, including the silent `if (url)` skip in replaceCookiesForImportedDomains, which would have narrowed a removal plan without saying so. The identically-worded throw in assertClearIdentitiesCoverRemovable is untouched — that one is live and is what keeps the mutated set inside the restorable set. * test(browser): re-anchor the native concurrency detector on the scoped clear (STA-4797) stablyai#15095's detector read "has the second import started clearing yet?" off clearData call counts. Scoping the clear removed the bulk clearData path, so that signal is gone and the assertion measured nothing. It now reads the same question off the removals themselves, which is strictly more specific: the seeded jar holds a stale cookie for each import's own domain, so `remove:old-a` present with `remove:old-b` absent proves the first import cleared and the second has not — where a call count could not tell the two apart. The completed run then pins the exact removal sequence, which also records that each import clears only its own domain. The seed had to move onto the imported domains for the same reason its own comment already gave for not leaving the jar empty: under a scoped clear, a jar holding only an unrelated site is the empty-jar case wearing a disguise -- the clear returns having removed nothing and every assertion passes vacuously. Mutation-checked: with the per-partition lock removed this test still fails, so stablyai#15095's protection is intact and the re-anchoring did not hollow it out. * fix(browser): merge staged cookie imports by domain scope (STA-4797)
* fix(browser): serialize cookie imports per partition (STA-4601) Two concurrent cookie imports on one partition can erase a session. Nothing serialises imports per partition — neither the renderer IPC handler (browser-session-profile-ipc.ts) nor the runtime RPC method (orca-runtime-browser.ts) — and the clear lock covered only the clear itself, so it was released before the writes and before any rollback. Reachable interleaving: import A replaces cookies for its imported domains, releases the lock, and later fails a write; import B clears and writes; A's rollback then removes cookies B already wrote and reported as imported. Path B has the same shape: A clears, B clears, then A writes its cookies on top of B's jar. Fix: one lock spans the whole live-jar transaction on both paths — the clear/replace, the writes, and the rollback. withCookieClearLock becomes acquireCookieMutationLock/withCookieMutationLock so path A can hold it across a try/finally rather than a single callback. Rebased onto stablyai#15030 (STA-4300), which rewrote this file: imports now write through CDP identities, so path A's writes moved from an inline cookies.set() loop into writeImportedCookies(), path B's into the same helper, and — the part that matters for a lock — importValidatedCookies no longer holds the Electron Session at all. It receives a CookieImportTarget that hides the Session behind openWriteStore(), and openWriteStore() builds a FRESH adapter per call, so keying the lock on anything reachable from it would serialise nothing. The target therefore carries mutationLockOwner, set to session.fromPartition's instance, which is the same object the native path locks on. That is what keeps both paths on one key per partition. Deliberately bounded: this covers the LIVE JAR only. Staging and cold-start replay keep their existing semantics, so two other pre-existing hazards in that subsystem are untouched and still open — the crash window between the clear and the result, and a permanently-armed replay when replay keeps failing. Both need the pending-image operations to become provable, which is a different change. The lock is keyed per owner, so imports into different partitions still run concurrently. Mutation-proved against the rebased tree, every mutation structure-preserving (brace/paren balance pinned) and every one re-run rather than carried over: dropping path A's acquire reddens the file-import detector; keying path A's acquire on a fresh object instead of mutationLockOwner reddens it too — the lock-present-but-miskeyed shape this rebase risks; replacing path B's lock with a passthrough reddens the native detector; doing both reddens both, which rules out incidental serialisation; and neutering the cold-init probe's lock reddens the new probe detector. That last detector is new: neutering the probe lock previously left all 779 browser tests green, so the probe's protection was unproven. The concurrency suite's store stub also gained writeCookieIdentity and getStoragePath. Without them the STA-4300 code throws a TypeError that writeImportedCookies catches as a write rejection, so the imports would have taken the failure path while the ordering assertions still passed. Each real import test now asserts writeCookieIdentity was CALLED, and that cookies.set never was. src/main/browser: 72 files, 780 tests, green; typecheck, oxlint, type-aware code quality, oxfmt and the max-lines ratchet all clean. * fix(browser): serialize native cookie staging * test(browser): pin native flush serialization * test(browser): pin staged cookie replay ordering * test(browser): remove vacuous staged replay detector * test(browser): detect stale native staging images * test(browser): guard cookie import ordering events * test(browser): cover staging lock boundary
…imports (STA-4797) (stablyai#15375) * fix(browser): scope a native cookie import's clear to the domains it imports (STA-4797) A native import (Settings -> Browser -> Import Cookies -> From Google Chrome) cleared the entire target partition's cookie jar, keeping only the non-transplantable google.com family. Every unrelated site the user was signed into in that partition was silently signed out, with no warning before and no disclosure after. Importing three sites signed you out of every other one. The stated rationale -- mixing stale and imported cookies makes sites reject the session -- reaches only as far as the domains being imported. Beyond them a clear has nothing to reconcile. The file/paste path already did the narrow thing via replaceCookiesForImportedDomains; the two import paths simply disagreed about scope, and the narrow one is the defensible shape. The clear now covers only the domains the import writes, through one shared predicate: - browser-cookie-import-policy.ts: importedDomainScope() / domainIsInImportedScope() are exported as the single scope definition used by all three clears, so they cannot drift apart. - browser-cookie-import-clear.ts: removeTransplantableCookies takes a required importScope. It is not defaulted -- a default would be the whole jar again. The scope test runs before the removal-URL derivation, so an unaddressable cookie parked in an unrelated corner of the jar no longer fails an import that was never going to touch it. - The bulk clearData shortcut is gone, and clearData leaves CookieClearSession for the same structural reason 'set' already had. clearData clears by exclusion, so the only scope it can express is "everything except google.com" -- the defect. An include list is no better: it matches at the registrable-domain boundary, so it would still take host-only siblings the import does not replace, and a partial delete followed by a rejection would destroy them with no identity to restore from. The frozen per-coordinate plan is now the only removal path, and it covers the imported domains rather than the jar. - browser-cookie-staged-image-clear.ts (new): the staged image is a copy of the live jar that replaces it wholesale on the next cold start, so its DELETE FROM cookies WHERE NOT (<google>) was a second whole-partition wipe. Narrowing the live clear alone would have re-erased the partition one restart later. It now clears to the identical scope, through the identical predicate. The scope is named from the emitted plan, so the removal set is the write set. Google stays exempt by policy (STA-3811), unchanged. No wire or summary change: the summary's existing `domains` field already names the imported domains, which is now exactly the scope that was cleared. Tests: fixtures in this module start with an empty cookie jar, which is why a full gate stack passed a session-erasing defect before. browser-cookie-import- scope.test.ts uses a populated jar with a session for a site outside the import set, and reads the staged file itself so the restart path is observed rather than assumed. All three cases fail against pre-fix source. The real-Electron partition test now seeds both an in-scope stale cookie (still removed) and an out-of-scope live one (now survives). * refactor(browser): drop the unreachable removal-URL failure branch (STA-4797) Scoping the clear made the `Could not clear existing cookies` throw in removableCookieEntries dead: a cookie whose domain does not normalize is now skipped by the scope test above it, so nothing reaches the URL derivation with anything but an already-parsed hostname. Rather than leave a fail-closed branch that cannot fire — this module has been misread before when a dead safety leg looked like a live one — the impossibility is now structural. cookieRemovalUrl takes a normalizeCookieDomain output and returns a string: `new URL` cannot throw on a host that already parsed as one, and assigning pathname never throws. Both callers lose their null branch, including the silent `if (url)` skip in replaceCookiesForImportedDomains, which would have narrowed a removal plan without saying so. The identically-worded throw in assertClearIdentitiesCoverRemovable is untouched — that one is live and is what keeps the mutated set inside the restorable set. * test(browser): re-anchor the native concurrency detector on the scoped clear (STA-4797) stablyai#15095's detector read "has the second import started clearing yet?" off clearData call counts. Scoping the clear removed the bulk clearData path, so that signal is gone and the assertion measured nothing. It now reads the same question off the removals themselves, which is strictly more specific: the seeded jar holds a stale cookie for each import's own domain, so `remove:old-a` present with `remove:old-b` absent proves the first import cleared and the second has not — where a call count could not tell the two apart. The completed run then pins the exact removal sequence, which also records that each import clears only its own domain. The seed had to move onto the imported domains for the same reason its own comment already gave for not leaving the jar empty: under a scoped clear, a jar holding only an unrelated site is the empty-jar case wearing a disguise -- the clear returns having removed nothing and every assertion passes vacuously. Mutation-checked: with the per-partition lock removed this test still fails, so stablyai#15095's protection is intact and the re-anchoring did not hollow it out. * fix(browser): merge staged cookie imports by domain scope (STA-4797)
* fix(browser): serialize cookie imports per partition (STA-4601) Two concurrent cookie imports on one partition can erase a session. Nothing serialises imports per partition — neither the renderer IPC handler (browser-session-profile-ipc.ts) nor the runtime RPC method (orca-runtime-browser.ts) — and the clear lock covered only the clear itself, so it was released before the writes and before any rollback. Reachable interleaving: import A replaces cookies for its imported domains, releases the lock, and later fails a write; import B clears and writes; A's rollback then removes cookies B already wrote and reported as imported. Path B has the same shape: A clears, B clears, then A writes its cookies on top of B's jar. Fix: one lock spans the whole live-jar transaction on both paths — the clear/replace, the writes, and the rollback. withCookieClearLock becomes acquireCookieMutationLock/withCookieMutationLock so path A can hold it across a try/finally rather than a single callback. Rebased onto stablyai#15030 (STA-4300), which rewrote this file: imports now write through CDP identities, so path A's writes moved from an inline cookies.set() loop into writeImportedCookies(), path B's into the same helper, and — the part that matters for a lock — importValidatedCookies no longer holds the Electron Session at all. It receives a CookieImportTarget that hides the Session behind openWriteStore(), and openWriteStore() builds a FRESH adapter per call, so keying the lock on anything reachable from it would serialise nothing. The target therefore carries mutationLockOwner, set to session.fromPartition's instance, which is the same object the native path locks on. That is what keeps both paths on one key per partition. Deliberately bounded: this covers the LIVE JAR only. Staging and cold-start replay keep their existing semantics, so two other pre-existing hazards in that subsystem are untouched and still open — the crash window between the clear and the result, and a permanently-armed replay when replay keeps failing. Both need the pending-image operations to become provable, which is a different change. The lock is keyed per owner, so imports into different partitions still run concurrently. Mutation-proved against the rebased tree, every mutation structure-preserving (brace/paren balance pinned) and every one re-run rather than carried over: dropping path A's acquire reddens the file-import detector; keying path A's acquire on a fresh object instead of mutationLockOwner reddens it too — the lock-present-but-miskeyed shape this rebase risks; replacing path B's lock with a passthrough reddens the native detector; doing both reddens both, which rules out incidental serialisation; and neutering the cold-init probe's lock reddens the new probe detector. That last detector is new: neutering the probe lock previously left all 779 browser tests green, so the probe's protection was unproven. The concurrency suite's store stub also gained writeCookieIdentity and getStoragePath. Without them the STA-4300 code throws a TypeError that writeImportedCookies catches as a write rejection, so the imports would have taken the failure path while the ordering assertions still passed. Each real import test now asserts writeCookieIdentity was CALLED, and that cookies.set never was. src/main/browser: 72 files, 780 tests, green; typecheck, oxlint, type-aware code quality, oxfmt and the max-lines ratchet all clean. * fix(browser): serialize native cookie staging * test(browser): pin native flush serialization * test(browser): pin staged cookie replay ordering * test(browser): remove vacuous staged replay detector * test(browser): detect stale native staging images * test(browser): guard cookie import ordering events * test(browser): cover staging lock boundary
…imports (STA-4797) (stablyai#15375) * fix(browser): scope a native cookie import's clear to the domains it imports (STA-4797) A native import (Settings -> Browser -> Import Cookies -> From Google Chrome) cleared the entire target partition's cookie jar, keeping only the non-transplantable google.com family. Every unrelated site the user was signed into in that partition was silently signed out, with no warning before and no disclosure after. Importing three sites signed you out of every other one. The stated rationale -- mixing stale and imported cookies makes sites reject the session -- reaches only as far as the domains being imported. Beyond them a clear has nothing to reconcile. The file/paste path already did the narrow thing via replaceCookiesForImportedDomains; the two import paths simply disagreed about scope, and the narrow one is the defensible shape. The clear now covers only the domains the import writes, through one shared predicate: - browser-cookie-import-policy.ts: importedDomainScope() / domainIsInImportedScope() are exported as the single scope definition used by all three clears, so they cannot drift apart. - browser-cookie-import-clear.ts: removeTransplantableCookies takes a required importScope. It is not defaulted -- a default would be the whole jar again. The scope test runs before the removal-URL derivation, so an unaddressable cookie parked in an unrelated corner of the jar no longer fails an import that was never going to touch it. - The bulk clearData shortcut is gone, and clearData leaves CookieClearSession for the same structural reason 'set' already had. clearData clears by exclusion, so the only scope it can express is "everything except google.com" -- the defect. An include list is no better: it matches at the registrable-domain boundary, so it would still take host-only siblings the import does not replace, and a partial delete followed by a rejection would destroy them with no identity to restore from. The frozen per-coordinate plan is now the only removal path, and it covers the imported domains rather than the jar. - browser-cookie-staged-image-clear.ts (new): the staged image is a copy of the live jar that replaces it wholesale on the next cold start, so its DELETE FROM cookies WHERE NOT (<google>) was a second whole-partition wipe. Narrowing the live clear alone would have re-erased the partition one restart later. It now clears to the identical scope, through the identical predicate. The scope is named from the emitted plan, so the removal set is the write set. Google stays exempt by policy (STA-3811), unchanged. No wire or summary change: the summary's existing `domains` field already names the imported domains, which is now exactly the scope that was cleared. Tests: fixtures in this module start with an empty cookie jar, which is why a full gate stack passed a session-erasing defect before. browser-cookie-import- scope.test.ts uses a populated jar with a session for a site outside the import set, and reads the staged file itself so the restart path is observed rather than assumed. All three cases fail against pre-fix source. The real-Electron partition test now seeds both an in-scope stale cookie (still removed) and an out-of-scope live one (now survives). * refactor(browser): drop the unreachable removal-URL failure branch (STA-4797) Scoping the clear made the `Could not clear existing cookies` throw in removableCookieEntries dead: a cookie whose domain does not normalize is now skipped by the scope test above it, so nothing reaches the URL derivation with anything but an already-parsed hostname. Rather than leave a fail-closed branch that cannot fire — this module has been misread before when a dead safety leg looked like a live one — the impossibility is now structural. cookieRemovalUrl takes a normalizeCookieDomain output and returns a string: `new URL` cannot throw on a host that already parsed as one, and assigning pathname never throws. Both callers lose their null branch, including the silent `if (url)` skip in replaceCookiesForImportedDomains, which would have narrowed a removal plan without saying so. The identically-worded throw in assertClearIdentitiesCoverRemovable is untouched — that one is live and is what keeps the mutated set inside the restorable set. * test(browser): re-anchor the native concurrency detector on the scoped clear (STA-4797) stablyai#15095's detector read "has the second import started clearing yet?" off clearData call counts. Scoping the clear removed the bulk clearData path, so that signal is gone and the assertion measured nothing. It now reads the same question off the removals themselves, which is strictly more specific: the seeded jar holds a stale cookie for each import's own domain, so `remove:old-a` present with `remove:old-b` absent proves the first import cleared and the second has not — where a call count could not tell the two apart. The completed run then pins the exact removal sequence, which also records that each import clears only its own domain. The seed had to move onto the imported domains for the same reason its own comment already gave for not leaving the jar empty: under a scoped clear, a jar holding only an unrelated site is the empty-jar case wearing a disguise -- the clear returns having removed nothing and every assertion passes vacuously. Mutation-checked: with the per-partition lock removed this test still fails, so stablyai#15095's protection is intact and the re-anchoring did not hollow it out. * fix(browser): merge staged cookie imports by domain scope (STA-4797)




ELI5
Two cookie imports running at the same time on the same browser profile can wipe out each other's work. One import finishes its cleanup after the other has already imported, and undoes it — or leaves behind a stale "restore this on next restart" file that overwrites the newer import when the app restarts.
What Changed
One lock now spans the whole live-jar transaction — the clear/replace, the writes, and the rollback — on both import paths.
withCookieClearLockbecomesacquireCookieMutationLock/withCookieMutationLockso path A can hold it across atry/finallyrather than a single callback.Deliberately bounded: this lock covers the live jar only. Staging and cold-start replay keep their existing semantics.
Why
Nothing serialises imports per partition — neither the renderer IPC handler (
browser-session-profile-ipc.ts) nor the runtime RPC method (orca-runtime-browser.ts) — and the clear lock previously covered only the clear itself, so it was released before the memory writes and the final pending-image decision.Reachable interleaving:
The same gap lets a stale rollback from A remove cookies B has already written and reported as imported.
Linked Issue
STA-4601
Visual Proof
Manual Electron validation was run on head
cdb0db690b— see the "Manual Electron validation (STA-4601)" comment on this PR (4 screenshots, CDP ownership verified, isolatedORCA_DEV_USER_DATA_PATH).Verdict: IMPORT WORKS. Two real Settings-surface imports (Chrome → stably.ai) into
persist:orca-browsercompleted with no hang or deadlock — 949 total / 869 imported / 80 skipped, 333ms then 319ms — andimportedAtadvanced on the second run, showing the lock is released rather than merely not yet deadlocked.The concurrency race itself is not covered by that run and cannot be: the Import Cookies menu is disabled while an import is in flight, so two concurrent imports cannot be started through the UI. The race is pinned by the deterministic concurrency suite instead.
Testing
pnpm vitest run --config config/vitest.config.ts src/main/browser— 63 files, 672 tests, green (onmain)pnpm typecheckclean,oxlintclean,oxfmtclean, max-lines ratchet OKNew
browser-cookie-import-concurrency.test.tsdrives deterministic interleavings against the lock primitive, so a failure names the ordering rule that broke instead of flaking on a raceMutation-proved: making the lock a no-op reddens the two ordering cases and leaves the different-owner and release-on-throw cases green
I manually tested these changes locally (Electron validation on
cdb0db690b— see the comment; the earlier tick predated any manual run)Automated tests added/updated
Review
Superseded — this PR now sits on top of #15030. When it was opened, #15030 was unmerged and this change was deliberately expressed against
mainso neither PR depended on the other. #15030 has since merged and rewrittenbrowser-cookie-import.ts, and this branch was rebased onto it.That rebase was not textual. #15030 removed the Electron
SessionfromimportValidatedCookies' scope, andopenWriteStore()builds a fresh adapter per call — so a lock keyed on that adapter would have been syntactically present and serialised nothing. The lock is now keyed on a newmutationLockOwneronCookieImportTarget. All 7 jar-mutation points across both paths are inside the lock; only cold-start replay is outside, by design. All 5 mutation proofs redden their detectors on the rebased code, including a new lock-present-but-miskeyed case.The bug remains pre-existing and is not introduced by #15030.
Split out of #15030 at your request to keep that P0 reland scoped to partition preservation.
Still open in this subsystem, and deliberately not fixed here: the crash window between the live clear and the result handling, and a permanently-armed replay when replay keeps failing. Both need the pending-image operations to become provable, which is a different change with its own failure modes.
Agent skill upstream boundary
Notes
Checklist
N/Awith reason for visual proofpnpm lint,pnpm typecheck,pnpm testpass locallyAuthor