Repository navigation
Description
Why this issue exists
Twelve CodeRabbit findings across four PRs in the vps2 view-state stack were deferred for the same reason: the stack has no rule for who owns a write to a shared profile record or shared settings record when several extension-host windows (several ClineProvider instances) can write the same key, and whose write is authoritative for another window. They are not twelve independent bugs, so they are tracked here as one decision.
Covered findings (all deferred pending this decision, now unblocked by it):
- PR fix(webview): isolate parallel mode and provider profile writes (vps2 F3) #1560:
4604037781(src/extension/registerCommands.ts),4604037800(src/core/task/Task.ts),4604037815,4604037826,4604037837(src/core/webview/ClineProvider.ts),4604037875(src/core/webview/webviewMessageHandler.ts),4604037924(src/extension/api.ts) - PR fix(webview): invalidate live sibling view state on reset and settings import (vps2 F4) #1562:
4604437290(sibling write during the secondgetProfileawait),4604437299(read/save/read-back/compensation section boundary),4507542567(forward fan-out outside the hold, unordered against a sibling save) - PR test(e2e): port view-state suite with reload and rehydration coverage (vps2 F6) #1565:
4604351737,4604351756(rollback record ownership, compensation against a concurrent profile update)
Step 1 - the rule being implemented now (compare-and-set on values)
- R1 Single writer unchanged. Every shared-store mode to profile write still goes through the one writer (
sidebarProvider.setModeConfigintoProviderSettingsManager.setModeConfig). Compensation must not bypass it, and no second write path may be introduced. - R2 Snapshot fidelity. Before any mutation set that compensation may undo, record per key the target layer and that layer's pre-write value. A window-local map write must never borrow the manager's value as its snapshot. This is the same bug class as the round-2 fix on test(e2e): port view-state suite with reload and rehydration coverage (vps2 F6) #1565, where the rollback rewound a window-local mapping from the manager's snapshot.
- R3 Compare-and-set restore. On compensation, re-read the same layer and restore a key only when the current value still equals the recorded pre-write value:
===for strings,deepEqualfromfast-deep-equalfor records (already the repo's helper -src/core/config/ProviderSettingsManager.ts:3,src/core/webview/ClineProvider.ts:11,src/core/task-persistence/taskStoreConcurrency.ts:1, with the write-before-compare precedent atProviderSettingsManager.ts:909-910). If the value differs, another window wrote after us: skip that key, keep the rest of the compensation, and log it. If the re-read throws, treat the state as unconfirmed and do not write blind. - R4 Failure semantics must not regress. A rejected or failed store write still drops the window-local pin, still posts state, and the error is logged rather than propagated past the section boundary.
- R5 Known weakness, stated rather than hidden. Value equality cannot distinguish "wrote X" from "wrote X again". If another window rewrites the identical value, our compensation may clear that key; the outcome is still the same value, so this is acceptable for step 1. Removing the ambiguity is the job of step 2.
Step 2 - agreed end state (record-level write revision)
Give each shared record a monotonic write revision, and make compensation and fan-out compare revisions instead of values: a writer captures the revision it read, and a compensation or a forwarded fan-out applies only while the record's revision still matches. That makes "wrote the same value twice" distinguishable, removes the R5 weakness, and replaces per-key value comparisons with one integer check.
Open questions for maintainers before step 2 is scheduled:
- Where should the revision live - inside each profile record, or as a side map in the persisted store? Existing persisted state has no revision field, so a default must be defined for records written before the change.
- Should
ProviderSettingsManagerreject a stale write (a real compare-and-set at the datastore layer), or only expose the revision so callers decide? Rejecting is stronger but changes the manager contract for every caller. - Does
4604437299want the cross-instance lock to span provider re-entry after all, or should the section boundary stay as it is and rely on revisions? This issue assumes the current design (no lock across re-entry) stays.
Where step 1 is implemented
PRs #1560, #1562 and #1565 each carry their own commits for this rule and link back here. Per the stack's collision rule, no shared helper module is created for it - each PR inlines what it needs in files it already touches, so three lanes do not collide on identical new paths.
Activity
fix(webview): re-check ownership across the awaits in profile restore
Settle the activation writes and skip siblings that began teardown
easonLiangWorldedtech commentedon Nov 18, 2026
Addendum - a concrete instance of the undecided revision, from PR 1565.
PR 1565 review comment 4610600217 (2026-11-18T07:46:31Z, Major, Data Integrity and Integration) is an instance of the write-revision half of this issue rather than of the compare-and-set half already treated as decided. The compensation added at head 27c49d0 in src/core/webview/ClineProvider.ts restores the pre-call profile record, or deletes the profile when the save was a create, when a sibling pin read or its overlay commit rejects after the save landed. A second window can complete a newer save of the same profile during that await, and this compensation then overwrites or deletes it. The finding asks for the record-level comparison this issue describes as its end state; it is deferred here rather than adopted, because adopting it would settle the open half inside a pull request thread.
Acceptance criteria carried from that thread, so the issue holds the shape of the fix and not only the symptom:
Open choice, both halves stated, so a maintainer decides rather than a thread: when the comparison finds that the record moved under the failing call, should the operation (a) fail the save outright and report the conflict to the caller, or (b) retain the newer record and let the activation proceed against it. Option a preserves the invariant that a rejected operation leaves nothing half-applied; option b preserves the newer user intent at the cost of activating settings the failing call did not write. Neither is currently implemented anywhere in the extension package: the profile record has no comparison helper, while the mode-mapping path already has compare-before-restore at src/core/webview/ClineProvider.ts:3806 and a disk-authoritative compare-and-clear at :7368, which is the precedent a fix here should follow.
Count, recorded after the fact because it is the argument for deciding rather than deferring. In one day this undecided revision has produced four review items across two pull requests. On 1565: the Persistence integrity pre-merge check on review 5951048605, which was answered by shipping the restore-or-delete compensation at head 27c49d0 and which now passes, since the fresh review 5952562574 at that head carries no failing persistence item; and today review comment 4610600217, a Major asking for the comparison itself, answered by reply 4610685521 with this issue named as the place the choice is recorded. On 1562, sourced from that lane's read with its filters named: both demands come from coderabbitai review 5951499613, submitted 2026-11-18T05:56:55Z at commit 7c7556b, a COMMENTED review whose 17,352-character body carries the Persistence Integrity block, and neither demand was ever posted as an inline thread - measured rather than inferred, because of 417 rows returned by the review-comments endpoint on 1562, zero contain the string allSettled case-insensitively and zero contain committed and failed. Item 1 of that block, replace Promise.all with Promise.allSettled in activateProviderProfileUnlocked and await every shared write before the catch runs, was answered by doing it: the activation fan-out now awaits all four write legs with allSettled at src/core/webview/ClineProvider.ts:4480, decides only after the awaits, keeps the first rejection as the error the caller sees, names the failed legs in the log, and leaves the catch rebuild byte-identical; the answer is published in the 1562 pull request body under Persistence integrity (error-mode review line) and in commit 5014920, not as a thread reply, because there was no thread to reply to. Item 4 of the same block - assert that the manager selection, the shared currentApiConfigName, the shared provider settings and the view state agree, and that no write is pending when the error is received - was declined in prose and now stands as the acceptance criterion of the follow-up unit with ownership assigned to this issue. That lane also reports 127 inline roots on 1562 with zero unanswered under its stated filter.
Two of these four items, both on 1562, exist only inside a 17,352-character review body, where neither a thread count nor an unresolved-thread counter can see them; the 1562 unresolved counter reads clean at zero unanswered while those demands are open text. On 1565 the blocking item is likewise body and CI text rather than a thread. Reviewing by thread counting is therefore blind to most of what this undecided rule has cost in a single day.
Four review items in one day, across two pull requests, all of them downstream of a rule nobody has made. The maintainers who own this issue are the only people who can spend the ten minutes that retires all four; another round of review on any of the affected pull requests costs more than that decision does.
easonLiangWorldedtech commentedon Nov 18, 2026
Deferral criteria from PR #1562 round 11 (two lines left open)
Both items below are recorded here as the criteria a fix has to meet. They are not accepted as "done" by #1562, and no commit on that pull request claims them.
1. Pin compare-and-clear at the serialized clear (carried from #1562 finding …4723b, Major).
2. Store-level existence read: presence independent of per-entry usability (carried from #1562 finding …4765).
getConfig/getProfile(which wrap "absent" and "unreadable" in one plain Error),listConfigHandlesandlistProfiles(which answer "is this id in the listing"), andvalidateProfiles(which reports per-entry usability). Nothing answers "does this record exist" without either reading its contents or running validation over it. A deleted-profile probe therefore currently has to combine a listing with a separate usability answer, and the wording on that path in fix(webview): invalidate live sibling view state on reset and settings import (vps2 F4) #1562 was corrected to say so.Until (1) has the compare-and-clear at the serialized clear and (2) has a presence read with a stated corrupt-blob answer, #1562 keeps Persistence Integrity as a live line on its own pull request rather than describing it as cleared.
Reviewer engagement, recorded because it changes how each line should be read. The compare-and-clear rule (1) has been engaged with: on #1562 comment 4611540605 (2026-11-18T09:17:22Z, 125 s after the answer under root 4611384723) coderabbitai writes "I understand the decision to defer the compare-and-clear rule to
#2488. I am not marking the finding as addressed while that race remains." So that deferral is acknowledged rather than unnoticed, and item (1) is written above as a spec for whoever picks it up, not as a request for agreement. The existence-read item (2) has not been read: nothing was posted under root 4611384765 after the answer that says what was looked for in the store and what was found there, so item (2) still has to argue its case from the beginning.easonLiangWorldedtech commentedon Nov 18, 2026
Evidence that the ownership rule is one question, from four reviewer-side observations
Recorded here as evidence for items (1) and (2) above. Quoted text is the reviewer's own, with comment ids and timestamps, because the point is that the convergence was observed, not asserted by us.
1. The reviewer relocated the answer from the call site to the serialized step. On #1562, comment
4612125530(2026-11-18T10:05:41Z, replying under root4612067427):So per-view pairing is accepted, and the reviewer is the one who names the remaining constraint: the durable write queue serializes these writes, so a view whose write is queued earlier still blocks the one behind it. Item (1) asks for the pin check inside that serialized step. This is the same observation arriving from the other side: the step, not the call site, is where the decision has to be made and validated.
2. The reviewer asked for a property of the mechanism, not a patch. On #1562, comment
4612122369(2026-11-18T10:05:26Z, under root4612067411):A result type that distinguishes "succeeded" from "rejected with no value" is not a hunk at one site; it is what any caller of the serialized write needs. Item (2) is the same demand in the read direction: presence and usability cannot collapse into one answer, for the same reason a success and a valueless rejection cannot collapse into one sentinel.
3. Three findings in one pass on #1562 reach the same rule from three directions (review
5954361618,2026-11-18T10:00:56Z):4612067438(Major,ClineProvider.ts:1246) — the step that records a committed view id records whatever the field holds after the await, so a registration still in flight gets marked as committed.4612067448(Major, heavy lift,ClineProvider.ts:4229) — the compensation restores from a snapshot taken before the queue ran, so a mapping changed between the snapshot and the write is lost.4612067465(Major,ClineProvider.ts:4732) — the identity that the rollback gates compare is taken from a listing rather than from the write that happened, so a record absent from the listing makes both checks decline.Each is a different call site. All three are the same statement: a value established before an await, or a listing consulted in place of the record, is being used to decide what to do after the await.
4. The same pass on #1557 asked both halves as separate Majors. Review
5954370209(2026-11-18T10:01:24Z) on that pull request:Two pull requests, opened 40 seconds apart in review time, independently produced the await question and the listing-authority question.
What this changes about the criteria above. Item (1) and item (2) are one mechanism read two ways — the write must own its decision at the serialized step, and a read must state which question it answers. The queue is that step. Writing the rule per call site would mean implementing it once per finding, which is what these two pull requests are currently doing and what the reviewer keeps meeting again at the next site. The evidence above is for stating the rule once, here, and having both pull requests adopt it.
Scope boundary: this is evidence about the mechanism. It does not answer the scope question raised on either pull request, and no code was shipped against these findings — the last two rounds on #1562 were prose only, by maintainer-side ruling.
ROUND 7 ADDITION, made by editing this comment rather than posting a new one so the thread count does not grow.
The Persistence Integrity row has now landed on pull request 1557 as well. It arrived in review 5954886692, CHANGES_REQUESTED, submitted 2026-11-18T10:34:36Z against head c621114, in a review body of 13,218 characters. Quoted from that body with markdown emphasis and backticks removed and the en dash in the line range written as a hyphen, the row reads:
Why this changes the argument rather than adding a line to it: it is the third site asking for one rule, and it arrives from two pull requests.
An issue that carries three named sites across two pull requests is a different argument from an issue that carries one, and this comment is where that is recorded so the scope question can be decided from evidence rather than from recollection.
The boundary is unchanged from the earlier sections of this comment: this is evidence about the mechanism. It does not answer the scope question, and nothing on this point has been shipped - round 7 on pull request 1557 changed tests and comments only, one file, 40 insertions and 34 deletions, pushed as c9babab at 10:43:38Z.