You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
plugin-profiles: a failed concurrent apply's rollback deletes the other apply's record #18218
Two writers apply a profile to the same settings file at nearly the same time (for example /plugin-profile finishing a pending switch beside a terminal apply, or two sessions switching the same repository).
Both read the same file hash and record. Apply A saves its record and writes the settings file.
Apply B saves its record, then its settings write fails the hash guard.
Expected behavior
Apply B's failure leaves Apply A's record in place, so clear and reset can still undo Apply A.
Actual behavior
Apply B's rollback runs saveRecord(p.recPath, p.previous) or deleteRecord(p.recPath), which overwrites Apply A's record with the pre-A record or deletes it (plugins/plugin-profiles/scripts/profiles.mjs:568-574). Apply A's entries then sit in the settings file with no record: clear reports no record, and reset can only offer to remove every enabledPlugins/skillOverrides entry of that file.
The existing concurrency test (AC21, scripts/profiles.test.mjs:567-585) covers only a non-profile writer, not two profile applies.
Severity
Medium
Severity justification
It needs two writers racing on one file, but the result is a profile change that the plugin's own undo paths can no longer reverse.
Suggested fix location
plugins/plugin-profiles/scripts/profiles.mjs:568-574: roll back with the same compare-then-swap as swapRecord (lib/record.mjs:131-143), restoring the previous record only if the record on disk is still the one this apply wrote; add a test with two profile applies racing.
Environment
plugin-profiles 0.9.5, Claude Code 2.1.330, WSL2. Found by a read-only code audit; not reproduced live.
Owned by the session that filed it (session-owned); worked, if at all, in the profiles follow-up at the end of that session.
Activity
fix(plugin-profiles): claim an apply's record only while it is unchanged