Skip to content

Spare the session-lock owner in every service teardown until it unlocks - #7572

Open
vonsensey wants to merge 14 commits into
omacom:quattrofrom
vonsensey:defer-plugin-reload-while-locked
Open

vonsensey wants to merge 14 commits into
omacom:quattrofrom
vonsensey:defer-plugin-reload-while-locked

Conversation

@vonsensey

@vonsensey vonsensey commented Aug 20, 2026 •

Copy link
Copy Markdown

Closes the teardown paths that #9485 left uncovered, for #7106.

The gap

#9485 made unloadPluginServices() spare a keepLoaded service, so a plugin hot-reload no longer destroys omarchy.lock while Hyprland still holds the session lock. Other paths still destroy the service that owns the live WlSessionLock.

_syncServices() teardown. It destroys services inline, without going through unloadPluginServices() and without consulting keepLoaded, whenever the registry stops listing a plugin as installed, enabled and service-declaring. It does that in two loops. Since #9618, omarchy.lock declares the authentication host capability, so its service is retained in AuthServiceStore rather than _services, and it is the second loop that reaches it:

omarchy plugin disable omarchy.lock       (while the screen is locked)
  -> PluginRegistry.setEnabled            PluginRegistry.qml:565   pluginsChanged()
  -> onPluginsChanged                     shell.qml:1073           pluginReloading is false
  -> _syncServices, authentication loop   shell.qml:1029           AuthServiceStore.destroy(id)
  -> destroy()                            on the live WlSessionLock

A lock copy that is not classified as an authentication service lives in _services and reaches the first loop's inst.destroy() instead. omarchy plugin remove reaches the same teardown through its own setPluginEnabled <id> false step (bin/omarchy-plugin-remove:96). So does a local lock clone whose manifest.json is unreadable at the moment the rescan reads it: parseScanOutput drops that one plugin from the registry, and _syncServices then destroys its service. That is the "local lock-plugin clone" shape reported in #7106.

A second reload. unloadPluginServices() spares by the current manifest's keepLoaded, and the registry no longer lists a lock copy removed mid-lock. The first reload leaves the lock to the _syncServices skip; a second reload before unlock destroyed it. omarchy plugin remove ends in a rescan, and one git pull in a plugin checkout produces several watcher events, so the second reload needs no second user action.

A capability change. A published service that gains the authentication capability is destroyed and recreated in AuthServiceStore. For a lock copy holding the lock, that destroy abandons it. This one is from reading the source, not reproduced.

A clone swap. Enabling a lock clone disables its source in the same mutation (PluginRegistry.qml:548-549), and disabling or removing the clone restores the source. Done while locked, the member holding the lock is retained, and _syncServices mounted the other member beside it. That second lock service finds the compositor lock held, takes it for stranded, and re-locks over it, which Quickshell answers with the qFatal traced in quickshell-mirror/quickshell#962 and still open as #1054. Both services also declare target: "lock". This consequence is from reading the source and the upstream thread, not reproduced.

The disable path was reproduced on a VM on current quattro, and the second reload at 64b98747. Both end the way keepLoaded was added to prevent: the compositor-side ext-session-lock is abandoned without an unlock, Hyprland shows its lockscreen-died failsafe, and the process-global lock manager is left dangling so in-process recovery cannot retake the lock.

The change

Skip the service that owns the lock at every destroy that can reach it, and collect it once it lets go.

  • _syncServices, authentication loop. AuthServiceStore.ownsSessionLock(id) answers yes or no, so the store still hands out no service object. This is the guard that protects omarchy.lock on current quattro, and a lock clone declaring clonedFrom: "omarchy.lock", which inherits the capability.
  • _syncServices, _services loop. inst.sessionLockOwned === true covers a lock copy that is not classified as an authentication service.
  • unloadPluginServices, both loops. The same two checks, beside the keepLoaded spare.
  • Capability change. A published lock owner that gains authentication stays where it is until a later sync. The reverse move needs no guard: AuthServiceStore keeps an id trusted for the life of the process, so a service it holds never loses the capability.
  • Collection after unlock. The lock service emits unlockSettled when an unlock's wake exits. If that service is no longer installed, enabled and service-declaring (the same test both teardown loops use), or no longer belongs in the map it was placed in, or a family member was refused while it held the lock (below), the shell re-runs _syncServices, unless a reload in flight is about to. That pass collects a service the user disabled or removed, or moves one whose capability changed, so its lock IPC target stops answering. An ordinary unlock re-syncs nothing, so third-party services are not handed a fresh manifest copy on every unlock. The signal comes from the wake's exit rather than from sessionLockOwned changing, because every unlock path gives up the lock before it starts omarchy-system-wake, and destroying the service kills a wake still in flight: Quickshell kills a Process's child with the object.
  • An interrupted wake. A plugin change that lands between unlock and the wake's exit still collects a disabled lock service mid-wake. The service reruns the wake detached from Component.onDestruction when one is in flight. Every step is safe to repeat: the display step skips lit panels, and the keyboard step restores a saved value without consuming it. The normal path does not rely on this, so the wake runs once.
  • One lock service per clone family. ensureService records each service's clone family (its clonedFrom source, else its own id) and refuses a family member while another member holds the lock. The record outlives a removal, so a removed clone still matches. The holder can stay wanted (enabling a second clone disables the first-party source, not the holder), so a refusal sets _familyMountDeferred, and the holder's unlock re-syncs while it is set. That pass mounts the waiting member. Each _syncServices pass clears the mark before mounting anything, so a member still refused marks it again.

All the skips read a new sessionLockOwned on the lock service rather than the existing locked. locked carries sessionLock.secure, which resolves through the process-wide session-lock manager; an earlier teardown can leave it dangling, so a guard reading it would suppress every teardown for the life of a poisoned process while protecting nothing. lockRequested is the shell's own state and sessionLock.locked is the instance-local SessionLockManager::mLock, both deterministic on a rebuilt service.

The skips and the signal are duck-typed rather than keyed on the omarchy.lock id, so a cloned lock plugin gets the same protection. A clone made before this change has no sessionLockOwned and is not covered until it is cloned again.

What this does not do

Testing

test/shell.d/lock-service-teardown-test.sh, 54 assertions. Guard checks run on brace-matched function bodies with comments stripped, and compare whole conditions and operand sets, because token-presence matching cannot tell a guard that works from one that reads as present and does nothing. ownsSessionLock is run against the real AuthServiceStore.js in a Node VM, and the real syncServicesAfterUnlock and sessionLockHeldByFamily bodies against stubs. Each of these breakages makes the file fail:

Tampering Caught by
any skip deleted guard match
any skip commented out guard match on the comment-stripped body
a skip negated (!== true) or widened (!== false), or if (false && serviceKeepLoaded(...)) whole-condition comparison
a destroy hoisted above its skip index comparison in the brace-matched body
a teardown destroy removed entirely the "still destroys" assertions
ownsSessionLock answering for a service without the lock, or one it does not hold Node VM run of the store
the unlockSettled connection removed, or made after the service is stored index comparison in ensureService
the re-sync running on an ordinary unlock or during a reload, or skipping a disabled, removed, reclassified or no-longer-service-declaring service, or one whose family member was refused run of the real syncServicesAfterUnlock body
a refused family member not marking the deferral, or _syncServices not clearing it before it mounts match and index comparison in ensureService and _syncServices
unlockSettled emitted without the ownership check, or from a sessionLockOwned change whole-condition comparison and an emit count
the wake rerun on destruction deleted or negated, or the normal wake started detached exact match and a startDetached count
the family guard in ensureService deleted, commented out or negated, the family record deleted, or the family ignoring clonedFrom match and index comparison in ensureService
sessionLockHeldByFamily blocking a plugin itself, ignoring the family, ignoring ownership, or missing an owner in either map run of the real sessionLockHeldByFamily body
sessionLockOwned changed from OR to AND operand-set comparison
sessionLock.secure added to sessionLockOwned, directly or through a helper property operand-set comparison

A /* */ block comment or an early return around a guard still gets past a text-matching test; covering every such edit is not proportionate.

@omarchybot ran 61dcbe2e on a disposable Omarchy VM against a live secure=true lock. omarchy plugin disable omarchy.lock while locked drops Hyprland into the lockscreen-died failsafe on quattro, and again on this branch before the authentication-loop skip. With it, the lock screen and its password field stay up and the lock IPC target still answers.

It then ran 987de0ad on the VM, covering the five commits after 61dcbe2e. On quattro (97a9fce5), and on this branch with the three shell files reverted, disabling omarchy.lock while locked still drops into the failsafe. On this branch:

  • Disable while locked, then two rescanPlugins reloads. The lock screen stays up, the lock target answers, and the shell process never restarts.
  • Unlock. The disabled service is collected once the wake exits, and omarchy plugin enable omarchy.lock brings it back. An ordinary unlock leaves the service in place.
  • Clone swap while locked. The original keeps the lock, and after unlock the clone takes over and re-locks.
  • omarchy plugin remove <clone> --yes while the clone holds the lock, then two reloads. The lock holds, and after unlock the restored omarchy.lock is mounted.

987de0ad itself is the bot's: the post-unlock check now uses the service-declaration test the loops use.

It then ran 60c7ca2e (the refused-member deferral) on the VM. Setup: clone omarchy.lock to A, add a disabled second clone B, lock, then enable B while A holds the lock.

  • At 987de0ad, B is refused while locked and is still not mounted after the password unlock.
  • At 60c7ca2e, B is mounted about three seconds after unlock.

The original disable-while-locked case, rechecked at this head against quattro (b18ab495), behaves as above. On the VM at 60c7ca2e, the full ./test/shell fails 7 of 286 files, all of which fail the same way on quattro.

Locally at 60c7ca2e:

  • lock-service-teardown passes 54/54. Its new case fails without the fix.
  • These also pass: plugin-auth-boundary, plugins, plugin-registry-contract, lock-stranded-recovery, system-lock, sleep-lock, plugin-enable, plugin-clone, restart-shell, runtime-smoke (which loads the shell with the changed code), hyprland-session-locked, lock-blank-fingerprint and lock-password-overflow.
  • qmlformat parses shell.qml.
  • The full ./test/shell fails 11 of 286 files, the same count as at 1b376039, a1697289 and 61dcbe2e. None are in lock or plugin code (config, snapper, unowned-system-paths and eight others).

On the bot's VM, ./test/cli has one failure, vscode generated theme references current theme file, which fails the same way on quattro. The two Quickshell behaviours the collection relies on were checked in a throwaway qs instance:

  • destroying an object kills its running Process child
  • startDetached() from Component.onDestruction still runs a fresh copy

Left to the maintainer

  • The wake rerun's scope. Component.onDestruction reruns an in-flight wake detached for any destroy, including shell teardown. The wake steps are safe to repeat, but it is the most discretionary part of the change.
  • The family guard's scope. It defers any plugin whose clonedFrom is a lock, whatever that plugin implements.

History

This PR previously carried a second mechanism: deferring the whole reload until unlock, with a slow poll during the lock, plus a refusal in omarchy plugin add and omarchy plugin clone for the window where discovery was deferred. #9485 made the deferral redundant for the reload path it protected, and the CLI refusal existed only to cover the discovery gap the deferral opened, so both were removed. #9618 then moved omarchy.lock into AuthServiceStore, so the branch was brought up to date with quattro and given the matching skip in the authentication loop. The review of that round listed the remaining gaps (a second reload, the capability change, retention after unlock), and three commits close them. Two more close what those left open: a wake cut short by a plugin change right after unlock, and a second lock service mounted by a clone swap while locked. The bot's next round added the service-declaration check (987de0ad) and found one more gap: a clone refused while a still-wanted sibling held the lock was never mounted after unlock. 60c7ca2e closes it.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LhPK6AtHo1fHNQBBNfKkpk

Fixes #11389

Copilot AI balanced review requested due to automatic review settings August 20, 2026 05:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Defers plugin reloads while the session lock is active, preventing lock-service teardown and session stranding.

Changes:

  • Polls every two seconds until the session unlocks.
  • Adds regression coverage for the reload guard.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
shell/shell.qml Guards plugin reloads while locked.
test/shell.d/plugin-reload-lock-guard-test.sh Tests lock-aware reload deferral.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

// A deferred reload is postponed, not dropped: the guard re-arms the reload
// timer so the pending change is picked up shortly after unlock.
assert(
/if \(lockService && lockService\.locked\) \{\s*\n\s*localPluginReloadTimer\.interval = \d+\s*\n\s*localPluginReloadTimer\.restart\(\)\s*\n\s*return/.test(shellQml),

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in defd790 — rather than pinning 2000 (which would fail on any legitimate retune), the test now captures both intervals and asserts the deferral poll is numerically slower than the debounce, which is the actual invariant. 🤖 via Claude Code

Copilot AI review requested due to automatic review settings August 20, 2026 05:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@omarchybot

Copy link
Copy Markdown
Collaborator

Re-reviewed at 15e872fb. The previous pass was against defd790e; this covers the new commit and answers every finding that was open against it. Checked by me and by Codex at xhigh reasoning as an independent second opinion, and exercised on a disposable Omarchy VM with a real compositor and a real session lock.

What the new commit fixes

_syncServices was the hole, and the skip at shell.qml:359 closes it for the lock service. I verified the finding you posted on #7106 against quattro rather than against your description of it, and every part of it holds: scanProcess.onExited binds exitCode at PluginRegistry.qml:619 and reads only scanStdout.text; parseScanOutput has no empty-output and no scan-success guard, so installedPlugins = merged at :611 publishes an empty map after a failed or empty scan; pluginsChanged() fires at :614, and shell.qml:377 routes that straight into _syncServices whenever pluginReloading is false. The four emit sites are where you said they are — :290, :358, :540, :614 — and localPluginIdForPath filtering .git/ at :709 is right too. Codex agreed on all of it; since its independence is not currently guaranteed, the weight there is on the line numbers, which I read back myself.

Two things that skip does not do, worth stating so nobody reads it as broader than it is. It preserves only a service whose sessionLockOwned is exactly true — every other service still dies on an empty scan at :360, and panel entries and widgets still recompute from the empty registry. And the registry-integrity defect underneath is untouched: a failed scan still replaces a good registry with nothing, with no retry and no report. That is pre-existing and outside this PR, but it is the thing that makes the path reachable at all.

Excluding sessionLock.secure from sessionLockOwned is the right call for a guard: secure does not establish that this service owns a live WlSessionLock, and including it would let a poisoned process suppress reloads for its whole life while protecting nothing. One consequence to be aware of rather than to fix here — in the already-poisoned state where stale secure is true, checkStrandedLock (plugins/lock/Service.qml:91-100) sees locked as true, marks resolution complete and never runs the compositor probe, so recovery does not set lockRequested and the guard stays false. Where secure is false and the probe does report a stranded lock, beginLock() sets lockRequested = true at :144 and the guard comes back on from that assignment.

What is still open

The one that matters: omarchy plugin add --enable and omarchy plugin clone fail for the whole duration of a lock. Reproduced on the VM, at this head, against a real lock rather than by reading:

  • unlocked, planting a plugin and calling omarchy-shell shell rescanPlugins, the exact poll from omarchy-plugin-add:157-163 found it on attempt 1, in about 50ms;
  • locked (sessionLocked: true, secure: true), the same sequence returned discovered=0 after all 40 attempts, and still discovered=0 after a further 10 seconds — five deferral ticks.

omarchy-plugin-list does not read the disk; it goes through the shell's listPlugins IPC (bin/omarchy-plugin-list:28), which reads the in-memory registry, and the deferral means no scan ever populates it. So clone hits the hard fail at :158 and its EXIT trap at :139-143 deletes the clone it just made, and add --enable hits fail at :164 leaving the plugin installed but disabled with a message that does not say why. Without --enable and non-interactive, add polls nothing and reports success on a plugin the shell has not seen.

I am re-rating this medium rather than the high it was given last time, and the reason is worth stating plainly: reaching it needs a terminal on a locked session, and in that same window today's quattro does not fail the command — it strands the session. This is a narrower failure than the one being fixed. It is still a regression against unlocked behaviour, and it wants either a distinct IPC path for an explicit user-initiated rescan or a clear refusal in the CLI. Which of those is right is a design call, and with three competing fixes open on #7106 it is not mine to push into one of them, so nothing was pushed to your branch.

Timer interval leaks across the lock boundary (shell.qml:769 and :773). localPluginReloadTimer.interval is shared mutable state on one timer and only reloadPlugins restores 150. After a locked deferral has set it to 2000, the first unlocked edit arrives through onLocalPluginChanged at :793-795, which calls restart() and nothing else, so that edit waits 2s instead of 150ms; it is back to 150 after that reload runs. Codex added the sharper version of this, which I had not reasoned through: while the interval is still 2000, writes arriving less than 2s apart keep restarting it and the reload never fires at all, so an active editing session or a sync job can starve the hot reload it previously got. Separately, if an IPC rescanPlugins arrives after unlock while the deferral timer is still armed, :773 changes the running timer's interval without stopping it and you get one redundant reload behind the real one. Low, but the fix is small — localPluginReloadTimer.stop() alongside the reset, and setting the interval where the timer is armed rather than only where a reload runs.

The reload replayed at unlock is a single full teardown, within 2s of unlock, unloadPanels() and all. That is inherent to deferring rather than a defect, and it is the trade #7605 declines to make; naming it so the maintainer weighs it.

What does not hold

The guard sitting after the pluginReloading || scanning early-return at :759 was raised last time as failing open on the re-entrant onScanFinished path (:797-803). It does fail open there — _services is empty and the ownership scan returns false — but there is no live lock-owning service at that moment to destroy, because unloadPluginServices() already ran. Codex traced this to the same conclusion independently of my own read. Not a defect; withdrawn.

The deferral is also not lossy and holds nothing unbounded in memory: many writes during a lock coalesce into one eventual scan.

The tests

test/shell.d/plugin-reload-lock-guard-test.sh passes 9/9 on the VM, as do plugin-add, plugin-clone, plugin-enable, plugins, plugin-registry-contract, lock-stranded-recovery, system-lock, sleep-lock, runtime-smoke and menu-plugin — 97 assertions, 0 failures.

They also cannot fail. Codex reported that the nine assertions survive deliberate breakage, and I re-ran that myself against the head rather than taking it: all nine still pass with shell.unloadPluginServices() inserted at the top of reloadPlugins() before the guard; with inst.destroy() inserted before the _syncServices skip; with sessionLockOwned changed from || to &&; with sessionLock.secure laundered back in through a helper property; and with the intervals set to an hour and zero. The cause is structural — [\s\S]*? between anchors proves that one occurrence follows another, never that a destructive call does not precede it, and the secure and lockRequested checks are token presence on a single line. Assertion 9 is the clearest case: it claims sessionLockOwned "covers both", and lockRequested && sessionLock.locked satisfies it. A green run here tells a maintainer less than it looks like it does, and since this is the only automated evidence the change has, that is worth tightening.

Where this sits

#7572, #7169 and #7605 are three different fixes for #7106 and choosing between them is the maintainer's call, not mine — I am not recommending one over another and I have not touched the other two. What the VM run does establish for this one: with the patch, the #7106 trigger fired while locked — a write into a live plugin directory, Local plugin changed, reloading in the journal — and the lock came through intact, secure=true and sessionLocked=true unchanged, quickshell's PID unchanged, no lock-stranded: recovering, no FATAL. The patch does what it says.

Worth keeping in the frame that none of the three is a fix for the underlying defect. That is quickshell-mirror/quickshell#962: ~QSWaylandSessionLock() releases the Wayland object without clearing the process-global QSWaylandSessionLockManager::active, so the pointer dangles for the life of the process. Every one of these PRs is a QML-side workaround that keeps Omarchy from reaching the defect, which is the correct thing to ship now and is not the same as the defect being fixed.

One small thing on the body: it now carries two ## Testing sections and reads as the history of the branch — "Testing (updated)", "The guard now reads a deterministic field", "What I changed in #7572". Whoever reads it arrives at the final diff. Folding that into a description of the change as it stands would cost you nothing and save the maintainer reconstructing a history that is only in the log.

Waiting on you for the plugin add/clone behaviour and the timer interval, and on the maintainer for which of the three approaches lands.

@vonsensey

Copy link
Copy Markdown
Author

Both open items are in bd6a022a and 321396b2.

Timer interval. The timer is now armed from one helper that picks its interval from the lock state, and a reload that proceeds stops it. One note on the suggested shape: setting the interval where the timer is armed and leaving onLocalPluginChanged unconditional fixes the 2s-delay and the starvation on the unlocked side, but then every write during a lock re-arms at the debounce — a 150ms wakeup per write for the length of the lock, which is what the "deferral poll is slower than the debounce" assertion exists to prevent. Having the arming site read the guard covers both sides. I confirmed the stop() is live rather than dead code first: pluginRegistry.scanning is only true during an actual scan, so the IPC-rescan-after-unlock case you describe reaches it rather than the early return at the top.

plugin add / plugin clone. Both refuse up front, before anything is staged, so clone's EXIT trap never deletes a clone and add --enable never leaves a plugin installed-but-disabled with a message that does not say why. I took the clear-refusal option rather than a distinct IPC path: the latter adds surface to exactly the machinery the three PRs are arguing over, and refusing is the smaller change while the design question is open.

The check reads requested and sessionLocked from lock status rather than lock isLocked — isLocked also carries sessionLock.secure, so refusing on it would be the same trap you documented in omarchy-restart-shell, where a poisoned process refuses its own recovery. A shell that cannot answer is treated as unlocked, since a shell that is not running is not deferring anything.

Tests. You were right that the nine assertions could not fail, and the point about [\s\S]*? proving succession rather than absence was the whole problem. Every ordering claim is now an index comparison against a brace-matched function body; sessionLockOwned is compared by operand set rather than token presence, which is what kills both the && swap and the laundered helper; and the CLI refusal is covered by running the real commands against a stubbed shell rather than by matching their source.

The file is now checked against nine deliberate breakages — your five, plus four for the behaviour these commits add — and each one makes it fail:

Tampering Caught by
unloadPluginServices() hoisted above the guard no teardown runs before the guard
inst.destroy() hoisted above the _syncServices skip no destroy runs before the skip
sessionLockOwned changed from OR to AND operand-set comparison
sessionLock.secure laundered in via a helper property operand-set comparison
intervals set to an hour and zero debounce/deferral range checks
the stale re-arm cancellation deleted cancellation ordering
the arming site no longer reading the lock state interval-source assertion
the CLI refusal removed behavioural run
the CLI refusing on .locked instead of the deterministic pair stale-secure behavioural case

27 assertions, plus 126 across the affected shell suites and 116 in ./test/cli, no failures, qmllint clean. I have not re-run the tests that spawn a second quickshell against a live compositor — no disposable VM here, and doing that against a live session is the failure mode this PR is about.

Body. Rewritten as a description of the change as it stands, one Testing section, branch history dropped. It also folds in your two corrections from #7106, both of which I checked against source first: _syncServices has three entry points rather than the one I described — :155, :377 and :817 — and the onScanFinished one is ungated, so the reload path is precisely where an unguarded _syncServices would undo a retained service. And pluginsChanged() has five emitters, not four; the fifth is shell.qml:66-70, outside PluginRegistry entirely, so a plain write to shell.json reaches _syncServices without touching the registry. The omarchy plugin disable omarchy.lock route is named in the body too — it needs no scan failure and no reload, and the skip covers it.

Still yours and the maintainer's call which of the three lands; nothing here is an argument that it should be this one.

@omarchybot

Copy link
Copy Markdown
Collaborator

Re-reviewed at 321396b2, and I pushed one commit on top. Everything below was run on a disposable VM serving this branch's shell, never on the machine doing the review. Two reviewers: Claude Opus 5, and Codex at xhigh reasoning as an independent second opinion.

Timer interval — the reasoning holds, checked rather than taken. armLocalPluginReload() is the only arming path. interval: 150 at shell.qml:62 is a literal that never re-arms anything; there is no running: binding, no .start(), no running = true, and no other file in the repo names the timer id. Both callers — the deferral at :779 and onLocalPluginChanged at :807 — go through the helper, so nothing can re-arm at the debounce while the lock is owned. Your objection to setting the interval at the arming site while leaving onLocalPluginChanged unconditional is right on its own terms too: that shape wakes the process every 150ms for the length of the lock.

stop() is live. pluginRegistry.scanning is set only in rescan() (PluginRegistry.qml:663-664) and cleared at :613, so it is true only during an actual scan, and the IPC rescanPlugins path at shell.qml:933 reaches :785 with the timer genuinely armed rather than hitting the early return. The Qt.callLater(reloadPlugins) from onScanFinished at :813 can reach it armed as well, when a local edit armed the timer while the scan was in flight.

plugin add / plugin clone — the finding is fixed, and it took a smaller regression with it. Reproduced both sides on the worker against a real session lock. At head, locked: plugin add --enable refuses in 37ms with nothing staged, and plugin clone in 49ms with nothing left in ~/.config/omarchy/plugins. With the refusal disabled on the same locked session, add --enable fails after 3.1s with plugin 'probe.seven' is not known and leaves the plugin installed-but-disabled — exactly the shape reported. So the polling paths are fixed.

The part not yet spoken to: the refusal is unconditional, but the discovery poll only exists on the enable branch (omarchy-plugin-add:176-187). On that same locked session, omarchy plugin add <url> --yes without --enable previously cloned, installed, printed Enable it later with: … and exited 0 in 0.08s — the deferred rescan picked it up after unlock, which is the behaviour this PR is otherwise built around. It now fails and installs nothing. Interactive use hits the same thing whenever the user declines the enable prompt. That is a case that worked being turned into a hard failure, which is the one thing worth being careful about in a change whose whole argument is that deferral is cheaper than breakage. Whether to gate the refusal on the enable branch is a product call, so I have not touched it — it goes to the maintainer along with the choice between the three PRs. Codex reached the same conclusion independently, and also noticed that the new test at plugin-reload-lock-guard-test.sh:215 pins the behaviour in place by exercising an add without --enable, while the comment above it names only add --enable as discovery-dependent.

Two mutations still got through the suite. Pushed as eee64ff6. Codex found both and I confirmed each on the worker before acting on it; this is the part of its review that stands on its own rather than agreeing with something already written down.

  • if (!shell.sessionLockOwned()) in reloadPlugins() — the guard inverted, so a plugin write during a lock destroys the live WlSessionLock, which is the bug this branch exists to fix — kept all 27 assertions green. The ordering assertions search for the call, and the negated form still contains it, still returns where they expect a return, and still sits before the teardown. shell.sessionLockOwned() === false escaped the same way.
  • Dropping .requested from the CLI's jq expression kept all 27 green, because both refusal cases set sessionLocked: true and nothing covered requested: true, sessionLocked: false — a lock that has been asked for and not yet confirmed, which is precisely the window the shell's own guard defers in.

The commit compares the guard's whole condition rather than looking for the call inside it, and adds the requested-only case for both commands. 30 assertions now, and I re-ran six of your nine breakages against the edited file — all but the inst.destroy() hoist, the laundered-secure property and the out-of-range intervals — and each still fails.

Still open, low. shell.qml:354-358 says an engaged lock service is "collect[ed] after unlock", and nothing connects unlock to _syncServices. Its three entry points are startup (:155), onPluginsChanged (:377) and onScanFinished (:817); neither finishUnlock() nor the fallback at lock/Service.qml:263-270 reaches any of them. When a deferral was armed the reload after unlock does collect it, so the common path is fine — but on the omarchy plugin disable omarchy.lock route you name in the body, no timer is armed, and the retained service stays in _services after unlock, still returned by serviceFor() and still answering on the lock IPC target, until some unrelated later pluginsChanged. Retention is the point and the trade is right; it is the word "after unlock" that is doing more work than the code does.

What ran: plugin-reload-lock-guard-test.sh (30 assertions), plugin-add, plugin-clone, plugin-enable, plugins, plugin-registry-contract, lock-stranded-recovery, system-lock, hyprland-session-locked, bin-style, and ./test/cli at 116 — all green, on the worker, with $OMARCHY_PATH pointed at this branch and quickshell confirmed running from it. Plus the live locked-session reproduction above and nineteen mutation runs.

Waiting on the maintainer, for the unconditional-refusal question and for which of #7572, #7169 and #7605 lands. Nothing here argues for one over another; for what it is worth, this PR and #7169 do not overlap much — #7169 carries recovery for an already-poisoned process and this carries prevention — while #7605 is an alternative to the prevention half.

@parker-brown-family

Copy link
Copy Markdown

Reproduced on the post-0.3.1 stack, so this hasn't been overtaken by the quickshell update — Omarchy 4.0.1-1, quickshell 0.3.1-1, qt6-base 6.11.2-2. A git pull in an installed plugin's checkout, 72 seconds into a healthy secure=true lock, stranded the lock one second later and hit the qFatal seven seconds after that. Full timeline, coredump offsets and journal at #8647 — they match the offsets a second reporter posted there, so that's three machines on the same two addresses.

One thing from those runs that's worth having before anyone verifies this PR: the stranding is deterministic, the abort isn't. Two locked plugin writes here, both stranded the lock at +1s, only one reached FATAL: Tried to show lockscreen surfaces without active lock. The other recovered quietly and would have read as a clean pass. So a manual verification run should assert on lock-stranded: recovering being absent rather than on the absence of a crash, or roughly half of them will look green either way. Your plugin-reload-lock-guard-test.sh already asserts on teardown ordering rather than on the abort, which is the right shape — this is only a caution for anyone checking it by hand on a live session.

Also a small data point for the debounce: one git pull of a two-file commit produced six Local plugin changed, reloading: events in the same second, so git's own bookkeeping writes reach the watcher too and a reload can re-enter while the previous one is unwinding.

Glad to run this branch against a real session lock on this box if another 0.3.1 data point would help.

unloadPluginServices() now keeps a keepLoaded service across a plugin
hot-reload, but _syncServices destroys services inline on its own,
without going through it and without consulting keepLoaded, whenever the
registry stops listing a plugin as installed, enabled and
service-declaring. It is reached straight from pluginsChanged, so
`omarchy plugin disable omarchy.lock` gets there with no reload at all,
as does a local lock clone whose manifest is unreadable during the write
that triggered the rescan.

Destroying the service that holds the live ext-session-lock abandons the
compositor-side lock and drops Hyprland into its lockscreen-died
failsafe, which is the failure keepLoaded was added to prevent. Skip that
one service for as long as it owns the lock.

The signal is a new readonly property on the lock service rather than
`locked`, which carries sessionLock.secure: secure resolves through the
process-wide session-lock manager and an earlier teardown can leave it
dangling, so a poisoned process would suppress every teardown for its
whole life while protecting nothing. The skip is duck-typed rather than
keyed on the omarchy.lock id so a cloned lock plugin is covered too.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LhPK6AtHo1fHNQBBNfKkpk
@vonsensey
vonsensey force-pushed the defer-plugin-reload-while-locked branch from eee64ff to 64b9874 Compare September 4, 2026 10:46
@vonsensey vonsensey changed the title Defer plugin reloads while the session lock is engaged Spare the session-lock owner in the _syncServices teardown Sep 4, 2026
@vonsensey

Copy link
Copy Markdown
Author

Force-pushed. The branch is rebuilt from current quattro as a single commit, so the diff every finding above was written against no longer exists — here is where each one went.

#9485 landed, and it changes what this PR should be. unloadPluginServices() now spares a keepLoaded service, which covers the reload teardown this PR was deferring around. So the deferral is gone: armLocalPluginReload(), the reloadPlugins() guard, the two-interval timer. With it goes the CLI refusal in omarchy plugin add and omarchy plugin clone — it only ever existed to cover the discovery gap the deferral opened, and @omarchybot was right that its unconditional form turned a working plugin add --yes into a hard failure. Both open findings are answered by deletion rather than by a fix.

What the merge does not cover, and what is left here. _syncServices() destroys services inline, without going through unloadPluginServices() and without consulting keepLoaded, whenever the registry stops listing a plugin as installed, enabled and service-declaring. omarchy plugin disable omarchy.lock while locked reaches inst.destroy() on the live WlSessionLock with no reload and no scan failure anywhere in the path. The PR body has the trace.

I am deliberately not making the broader claim that any empty scan strands the lock. parseScanOutput catches a bad manifest per block and continues, and first-party manifests come from $OMARCHY_PATH, which a write under ~/.config/omarchy/plugins cannot empty. The route that needs no failure at all is the defensible one; the local-lock-clone case is the same route reached by one plugin dropping out of the registry rather than all of them.

@omarchybot's still-open low finding — "collect[ed] after unlock" with nothing connecting unlock to _syncServices — was correct, and removing the deferral removes the timer that was the de facto collector. Rather than add a re-sync, the comment now says what the code does: retention is indefinite, and the instance is collected by whichever pluginsChanged lands next. Naming the trade beat leaving prose that outran it.

The tests. plugin-reload-lock-guard-test.sh is gone with the mechanism it covered; lock-service-teardown-test.sh replaces it at 8 assertions, keeping the shape @omarchybot's eee64ff6 established — brace-matched bodies, whole-condition comparison, operand sets. Both escapes that commit found are still closed: the inverted guard is caught by comparing the whole condition rather than looking for the property name inside it. Eight mutations run, eight caught; the table is in the body.

@parker-brown-family — thank you for the caution about asserting on lock-stranded: recovering rather than on the crash, and for the six watcher events from one git pull. Neither changes this diff, but if you still have the 0.3.1 box: the case worth a live run now is omarchy plugin disable omarchy.lock on a secure=true session, on plain quattro with #9485 in it. That is the one that should still strand today.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LhPK6AtHo1fHNQBBNfKkpk

omarchybot and others added 4 commits September 28, 2026 12:30
The lock service moved into AuthServiceStore when first-party plugins gained the authentication capability, so the teardown this branch guards has to be read against current quattro.
On quattro the first-party lock carries the authentication capability, so it is retained in AuthServiceStore rather than _services, and _syncServices destroys it through the authentication loop the existing skip never reaches. Disabling omarchy.lock while locked still dropped Hyprland into its lockscreen-died failsafe with this branch merged. The store answers whether a service owns the lock instead of handing the service out, so it still exposes no credential-bearing object.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
quattro's _syncServices destroys a published service earlier, when it gains the authentication capability, so the first .destroy() in the body is no longer the teardown's and the ordering assertion failed on the merged tree.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The ordering checks searched raw source, so a guard commented out still satisfied them while the lock was destroyed again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Sep 28, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed and run on a disposable Omarchy VM. The bug is real, but on current quattro this branch no longer reached it, so I pushed a fix to it.

What changed under it. Since this branch was cut, first-party plugins gained host capabilities (#9618), and omarchy.lock declares authentication. Its service is now retained in AuthServiceStore, not _services, and _syncServices tears it down in the separate authentication loop, which the skip here never reaches. On the VM, locking and then running omarchy plugin disable omarchy.lock put Hyprland into its "lockscreen app died" failsafe on quattro, and again with this branch merged into quattro.

Pushed to your branch:

  • 8ebfe09b merges quattro in, so the fix is tested on the code it would land on.
  • f8806e3a gives the authentication loop the same skip: AuthServiceStore.ownsSessionLock(id) returns only a yes/no, so the store still hands out no service object. With it, the same steps leave the lock screen and its password field up, and the lock IPC target still answers.
  • f94272e7 anchors the ordering check on inst.destroy(), because quattro's _syncServices now destroys a service earlier, when it gains the authentication capability. That made the test fail after the merge.
  • 61dcbe2e strips comments before the guard checks, so a guard that is commented out no longer passes them. Your _services skip stays: it still covers a lock copy that is not classified as an authentication service.

Tests, on the VM at 61dcbe2e: lock-service-teardown passes 14/14, and fails with the new guard reverted or with either guard commented out. plugin-auth-boundary, plugins, plugin-registry-contract, lock-stranded-recovery, system-lock, sleep-lock and runtime-smoke all pass. ./test/cli has one failure, vscode generated theme references current theme file, and it fails the same way on quattro. GitHub reports no CI checks on this branch.

Second opinion: Codex Medium reviewed it over two rounds, and its independence from this review is not guaranteed. It found the commented-out-guard hole fixed above. It also pointed out that a lock copy declaring clonedFrom: "omarchy.lock" inherits the authentication capability and so relies on the new guard too. Two of its points are for the maintainer rather than this branch:

  • As the description says, a lock service disabled mid-lock stays alive after unlock until the next plugin change. Codex adds that in that window its lock IPC target still answers, so a disabled lock plugin can lock the screen again.
  • unloadPluginServices() spares services by their current manifest's keepLoaded. A lock copy removed while locked survives the first reload, but a second reload before unlock still destroys it. The first-party lock cannot be removed, so this only affects copies.

I declined one further test point: a /* */ block comment around a guard still gets past this text-matching test. So does an early return, and chasing every such edit isn't proportionate.

This now waits on the maintainer: whether the retention after unlock is acceptable, and whether to merge.

vonsensey and others added 3 commits September 28, 2026 13:21
unloadPluginServices spares a service by the keepLoaded of its current manifest, and the registry no longer lists a lock plugin removed while locked. The first reload after the removal leaves the lock to the _syncServices skip, and a second reload before unlock destroyed it. Both loops now also spare the instance that owns the session lock.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A published service that gains the authentication capability is destroyed and recreated in AuthServiceStore. For a lock copy that holds the session lock, that destroy abandoned the lock. It now stays where it is until a later sync. The reverse move needs no guard: the store keeps an id trusted for the life of the process, so a service it holds never loses the capability.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The teardown skips kept a lock service that was disabled or removed mid-lock until whichever pluginsChanged came next. Its lock IPC target kept answering in that window, so the disabled plugin could lock the screen again. The lock service now emits unlockSettled when an unlock's wake exits. If that service is no longer enabled and installed, or no longer belongs in the map it was placed in, the shell re-runs _syncServices, which collects or moves it. An ordinary unlock re-syncs nothing, so third-party services are not handed a fresh manifest copy on every unlock.

The signal comes from the wake's exit, not from sessionLockOwned changing. Every unlock path gives up the lock before it starts the wake, and destroying the service kills a wake still in flight, because Quickshell kills a Process's child with the object.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vonsensey vonsensey changed the title Spare the session-lock owner in the _syncServices teardown Spare the session-lock owner in every service teardown until it unlocks Sep 28, 2026
@omarchybot omarchybot removed the verified Omarchy Triage has verified that this issue is ready for final review label Sep 28, 2026
vonsensey and others added 3 commits September 28, 2026 13:54
A plugin change that lands between unlock and the wake's exit collects a disabled lock service while omarchy-system-wake is still running, and Quickshell kills a Process's child with its object, so the displays or keyboard backlight could stay off. The service now reruns the wake detached from Component.onDestruction when one is in flight. Every step of the wake is safe to repeat: the display step skips lit panels, and the keyboard step restores a saved value without consuming it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Enabling, disabling or removing a lock clone while locked swaps which member of the clone family the registry wants, while the member holding the lock is kept until unlock. _syncServices then mounted the other member beside it. That second lock service found the compositor lock held, took it for stranded and re-locked over it, which Quickshell answers with the qFatal traced in quickshell-mirror/quickshell#962 and still open as omacom#1054. That consequence is from reading the source and the upstream thread; it was not reproduced here. Both services also declared the lock IPC target.

ensureService now records each service's clone family (its clone source, else its own id), and refuses a family member while another member holds the lock. The record outlives a removal, so a removed clone still matches. The re-sync after unlock mounts the waiting member.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The teardown loops in _syncServices keep a lock owner that is no longer installed, enabled and service-declaring, but the unlock re-sync only checked installed, enabled and classification. A lock clone whose manifest dropped its service entry point while locked was kept by the loop and then never collected, so its lock IPC target kept answering after unlock. Check the same service declaration the loops do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Sep 28, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Re-reviewed at 987de0ad, covering the five commits since 61dcbe2e, and ran them on a disposable Omarchy VM against a live secure=true session lock, since the description says they had not been.

On the VM. On current quattro (97a9fce5), and on this branch with the three shell files reverted, locking and then running omarchy plugin disable omarchy.lock drops Hyprland into its "lockscreen app died" failsafe. On this branch:

  • Disable while locked, then two rescanPlugins reloads: the lock screen and password field stay up, the lock IPC target answers, and the shell process never restarts.
  • Unlock with the password: the disabled service is collected once the wake exits (the lock target stops answering), and omarchy plugin enable omarchy.lock brings it back. An ordinary unlock of an enabled lock leaves the service in place.
  • Clone swap while locked (omarchy plugin clone omarchy.lock, which enables the clone and disables the source): the original keeps the lock in the same shell process, and after unlock the clone takes over and re-locks.
  • omarchy plugin remove <clone> --yes while the clone holds the lock, then two reloads: the lock holds; after unlock the restored omarchy.lock is mounted.

Pushed to your branch: 987de0ad makes syncServicesAfterUnlock check that the manifest still declares a service (kinds includes service and entryPoints.service is set), the same test both teardown loops in _syncServices use. Without it, a lock clone whose manifest stopped declaring a service while locked was retained by the loop and then never collected after unlock, so its lock target kept answering. The resync fixture now uses a real service manifest, and a new case fails without the fix.

Tests, on the VM at 987de0ad: lock-service-teardown 50/50, plus plugin-auth-boundary, plugins, plugin-registry-contract, lock-stranded-recovery, system-lock, sleep-lock, plugin-enable, plugin-clone, restart-shell, runtime-smoke, hyprland-session-locked, lock-blank-fingerprint and lock-password-overflow, all green. ./test/cli has the one failure it also has on quattro, vscode generated theme references current theme file. The full ./test/shell was not run. GitHub reports no CI checks on this branch.

Second opinion: Codex Medium reviewed the five new commits and then the fix, over two rounds. Its independence from this review is not guaranteed. It found the gap fixed above, and one more that is still open:

  • ensureService refuses a clone-family member while another member holds the lock, but nothing retries it afterwards unless the holder is no longer wanted. Enabling clone B while clone A holds the lock disables the first-party source, not A (PluginRegistry.qml:548), so A stays wanted, the unlock re-syncs nothing, and B stays unmounted until the next plugin change. This needs two lock clones enabled at once, and fixing it means tracking deferred mounts, so I left it.

It also flagged two things as choices rather than defects: the detached wake rerun in Component.onDestruction fires for any destroy during a wake, including shell teardown, which it called the most discretionary part of the change; and the family guard defers any plugin whose clonedFrom is a lock, whatever it implements. It judged the unloadPluginServices, capability-move and post-unlock collection guards to be warranted by the invariant the PR states.

This now waits on the maintainer: the open clone-retry gap, the scope of the wake rerun, and whether to merge.

ensureService refuses a clone-family member while another member holds the
session lock, and the unlock re-sync mounts it. But the re-sync only ran for a
holder no longer wanted where it is. Enabling clone B while clone A holds the
lock disables the first-party source, not A, so A stays wanted, its unlock
re-synced nothing, and B stayed unmounted until the next plugin change.

A refusal now marks the deferral, and the holder's unlock re-syncs while it is
set. Each _syncServices pass clears it before mounting anything, so a member
still refused on that pass marks it again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@omarchybot omarchybot added verified Omarchy Triage has verified that this issue is ready for final review and removed verified Omarchy Triage has verified that this issue is ready for final review labels Sep 28, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Re-reviewed at 60c7ca2e, the refused-member deferral, and ran it on a disposable Omarchy VM with a live secure=true session lock. It closes the clone-retry gap left open last round, and I found nothing wrong with it. Nothing pushed.

The new case, on the VM. Clone omarchy.lock to A, add a second lock clone B (disabled), lock, then enable B while A holds the lock. B's service carried a probe that records when it is created. At 987de0ad, B is refused while locked and still not mounted after unlocking with the password. At 60c7ca2e, B is refused while locked and mounted about three seconds after the unlock.

The original bug, re-checked at this head. On current quattro (b18ab495), and on this branch with the three shell files reverted, omarchy plugin disable omarchy.lock while locked drops Hyprland into its "lockscreen app died" failsafe. On this branch the lock survives the disable and two rescanPlugins reloads in the same shell process. After unlocking with the password the disabled service is collected, and omarchy plugin enable omarchy.lock brings it back.

Reading the change. ensureService is only called from _syncServices, which clears _familyMountDeferred before it mounts anything, so the flag can only stay set by a refusal in the latest pass. The flag is shared, not per family, so its worst case is one extra _syncServices on an unlock, which is harmless. An unlock during a reload still leaves the re-sync to the reload, whose pass retries the refused member.

Tests, on the VM at 60c7ca2e:

  • lock-service-teardown passes 54/54.
  • These 13 are also green: plugin-auth-boundary, plugins, plugin-registry-contract, lock-stranded-recovery, system-lock, sleep-lock, plugin-enable, plugin-clone, restart-shell, runtime-smoke, hyprland-session-locked, lock-blank-fingerprint and lock-password-overflow.
  • The full ./test/shell fails 7 of 286 files: ascii, branding-about-animation, kernel-headers-migration, network-captive-portal, omarchy-kernel-migration, passwordless-grant-lifecycle and video-background. All 7 fail the same way on quattro on the same VM.
  • ./test/cli has one failure, vscode generated theme references current theme file, which also fails on quattro.
  • GitHub reports no CI checks on this branch.

Second opinion: none this round. Only Claude Opus 5.5 reviewed this commit. Codex Medium answers a ping, but omabot's daily review budget was used up before it could review this commit. Codex Medium did agree with classifying the PR as a bug fix.

This now waits on the maintainer: a second review of 60c7ca2e, the scope of the detached wake rerun and of the family guard (both in the description), and whether to merge.

omarchybot and others added 2 commits November 17, 2026 03:41
A clone of omarchy.lock is a copy of Service.qml as it was when cloned, so one made before this branch has no sessionLockOwned and no unlockSettled. Every ownership skip read false for it, and disabling or removing it while locked still destroyed the live session lock, which is the setup reported in omacom#11389. The store now falls back to the clone's own locked for a service without sessionLockOwned, and such a clone re-syncs when locked falls instead of when its wake exits. Only authentication services get the fallback: those are omarchy.lock, omarchy.polkit and their clones, and polkit has no locked.

Co-Authored-By: Taksh <takshkothari09@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@omarchybot

Copy link
Copy Markdown
Collaborator

I pushed two commits to this branch and re-ran it on a disposable Omarchy VM with a live secure=true session lock.

What I pushed:

  • da664968 merges current quattro (3b36b9e1). It merged without conflicts. finishUnlock() still releases the lock before it starts the wake, and both authentication-service loops still reach the guards.
  • 3ce96716 covers lock clones made before this branch. A clone of omarchy.lock is a copy of Service.qml from the day it was made. So an existing clone has no sessionLockOwned and no unlockSettled, and disabling it while locked still destroyed the live lock. That is the setup in _syncServices() destroys keepLoaded services the builtin-defaults window marks disabled — any third-party lock plugin strands the session on resume #11389. Now, for a service without sessionLockOwned, AuthServiceStore.ownsSessionLock() falls back to the clone's own locked. Such a clone re-syncs when locked falls, since it has no unlockSettled. The fallback applies only in the authentication store, which holds omarchy.lock, omarchy.polkit and their clones, and polkit has no locked. The idea comes from @chessing234's fix: keep keepLoaded services across _syncServices disable #12937, which keyed retention on locked. The commit credits them as co-author. Three assertions in lock-service-teardown-test.sh cover the fallback, and the first fails without it.

The description's line "A clone made before this change has no sessionLockOwned and is not covered until it is cloned again" no longer holds. I've linked #11389, which this now fixes.

On the VM. The pre-change clone below is quattro's Service.qml, cloned from omarchy.lock:

  • Pre-change clone, at 3ce96716. I locked it, then disabled it. It kept the lock through the disable and a rescan, and was collected after the password unlock. omarchy.lock was mounted after that. The trigger from _syncServices() destroys keepLoaded services the builtin-defaults window marks disabled — any third-party lock plugin strands the session on resume #11389 behaves the same way: truncating shell.json while locked.
  • Pre-change clone, at da664968 (the same tree without 3ce96716). The clone was destroyed on disable. A fresh omarchy.lock found the lock stranded, stuck at lock-pending, and the password unlock never landed.
  • Disabling omarchy.lock while locked. On quattro the lock service is destroyed, the compositor stays locked, and re-enabling the plugin cannot recover it. At 3ce96716 the lock holds through two rescans in the same shell process and is collected after unlock.

Tests on the VM at 3ce96716:

  • lock-service-teardown passes 57/57.
  • plugin-auth-boundary, plugins, plugin-registry-contract, system-lock, sleep-lock, plugin-enable, plugin-clone, restart-shell and hyprland-session-lock pass.
  • The full ./test/shell fails 6 of 428 files. Five of them fail the same way on quattro: ascii, branding-about-animation, first-run, provision-owner-keyboard and runtime-smoke.
  • remote-session-service passes on quattro's checkout. It still fails on this branch's checkout with quattro's versions of the three changed shell files swapped in, so it is not this change.
  • ./test/cli is green.
  • GitHub reports no CI checks on this branch.

Second opinion: Codex Medium and muse-wonder (pi, thinking high) reviewed the merge and the new commit. Both found the merge sound and agreed that limiting the fallback to the authentication store is right. Both can read this session's working files, so that agreement is not guaranteed to be independent. Codex Medium raised one issue I have not changed. When a pre-change clone is collected right after unlock, it can still be running omarchy-system-wake. The old file has no detached rerun on destruction, so keyboard backlight or clamshell state may not be restored until the next wake. It only happens for a pre-change clone that was disabled or removed while locked, and the session lock is never at risk. muse-wonder judged it not worth more machinery; Codex Medium suggested running a detached wake from the shell when it collects such a clone.

This waits on the maintainer: the scope of the wake rerun and of the family guard (both in the description), whether that wake gap for pre-change clones needs closing, and whether to merge.

@greptile-apps

greptile-apps Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The changes affect lock-service teardown, unlock, and clone swaps in the shell's plugin workflow.

The testing-rule violation must be addressed before merging; no separate behavioral blocker was established.

Findings

  1. P2 Tests check spelling, not teardown ▶

Summary

Keeps the service that owns the session lock alive across plugin disable, removal, reload, and capability changes.

  • Lock-owning services stay mounted until they release the session lock.
  • The shell reconciles lock services after their wake finishes.
  • A clone waits to mount until its family's lock owner unlocks.

Acknowledged scope: vonsensey leaves detached wake reruns during shell teardown and the breadth of the clone-family guard to the maintainer. Older non-authentication clones without sessionLockOwned are explicitly outside the protection described in the PR. vonsensey also explicitly describes keeping a newly classified authentication service published until unlock as intentional, to avoid destroying the live lock owner.

No tests or graphical checks were run during this review.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Plugin change] --> B{Service owns the lock?}
  B -->|Yes| C[Keep the service]
  C --> D[Refuse another family member]
  C --> E[User unlocks]
  E --> F[Wake finishes]
  F --> G[Sync services if needed]
  G --> H[Collect unwanted service or move it]
  G --> I[Mount waiting family member]
  B -->|No| J[Normal teardown]
Loading

Reviews (1) · Last reviewed commit: "Keep a lock clone made before sessionLoc..." · Reviewed by Greptile

Comment on lines +49 to +54
const syncGuardMatch = sync.match(/if \((.+?)\) continue\s*\n\s*if \(inst && typeof inst\.destroy/)
assert(syncGuardMatch, '_syncServices guards the destroy with a skip that continues')
assertEqual(
syncGuardMatch[1].trim(),
'inst && inst.sessionLockOwned === true',
'the skip fires when the instance owns the session lock -- not negated, not widened'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Tests check spelling, not teardown

These assertions require an exact spelling of the ownership guard rather than checking what teardown does. An equivalent rewrite fails, while broken control flow around the guard can pass.

AGENTS.md says not to restate the implementation and to extend an existing area test. Before merging, replace the source comparisons with checks that run the teardown logic against service objects, and put them in an existing lock or authentication suite. Keep the checks that already run real functions.

File Used: AGENTS.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

_syncServices() destroys keepLoaded services the builtin-defaults window marks disabled — any third-party lock plugin strands the session on resume

4 participants