Skip to content

Discover shell plugins through XDG data directories - #12872

Open
spencerbull wants to merge 10 commits into
quattrofrom
plugin-xdg-data-paths
Open

spencerbull wants to merge 10 commits into
quattrofrom
plugin-xdg-data-paths

Conversation

@spencerbull

@spencerbull spencerbull commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

A dev-linked Omarchy shell only discovers plugins in its checkout and the user plugin directory, so packages installed under /usr/share/omarchy/shell/plugins are missed without a user symlink.

Make the shell and CLI resolve external plugin IDs from $HOME/.config/omarchy/plugins, then $OMARCHY_PATH/shell/plugins, then omarchy/shell/plugins under each $XDG_DATA_DIRS directory in order. The first valid manifest wins; unset or empty $XDG_DATA_DIRS uses /usr/local/share:/usr/share in both the CLI and shell.

Keep omarchy.* reserved for built-ins from the active Omarchy tree. Trust omacom.* plugins from the active tree or XDG data directories; a user-directory copy still wins by precedence and remains untrusted. Discovery origin determines trust rather than manifest claims or pathname prefixes. Trusted plugins receive the existing first-party host APIs and declared capabilities, and trusted non-bar plugins are enabled by default unless explicitly disabled.

Recreate retained services and cached bar or widget facades when their selected source or trust changes. Revoke cached third-party facades before publishing a replacement manifest, and bind scoped callbacks to the source and trust that created them so outgoing personal code cannot reach its trusted successor. Reject pending service loads after disablement, and bind asynchronous widget loads to the current selection so an old or failed replacement cannot leave a stale registration. Unchanged keepLoaded services retain their instances. The CLI clone command remains limited to omarchy.* built-ins even when a packaged omacom.* plugin is trusted at runtime.

The Elsewhen migration is simplified separately in #12871.

🤖 Generated by GPT-6 in Codex. Reviewed by GPT-6 XHigh.

@llstrk

llstrk commented Sep 22, 2026

Copy link
Copy Markdown

Two issues were reproduced at 5e7f7f532ab5: the shell misses default data roots when XDG_DATA_DIRS is unset, and a retained personal service can redirect its trusted replacement to personal code.

Unset XDG_DATA_DIRS bypasses the shell's default roots

In PluginRegistry.qml, Quickshell.env("XDG_DATA_DIRS") returns null when absent. Native Quickshell 0.3.1 converts that command-list element to the literal string "null", so Bash's ${2:-/usr/local/share:/usr/share} does not apply its fallback.

Shell environment Argument received by Bash Discovery
Explicit absolute directory That directory Scans the configured root
Empty string Empty string Scans default roots
Unset "null" Skips default roots as a nonabsolute entry

Impact: A dev-linked shell with the variable unset cannot discover otherwise eligible packaged plugins in the default roots, although the CLI catalog applies the default correctly. Rescanning with the same environment repeats the mismatch. Live-session prevalence was not measured.

Suggested change: Normalize the QML value before constructing the command, for example Quickshell.env("XDG_DATA_DIRS") || "". Add an actually unset environment case to the native registry test; the existing unset/default comparison exercises only the CLI.

A retained facade exposes the trusted replacement manifest to old personal code

The new provenance check replaces the old service object, but syncPluginApis() runs first and assigns the selected trusted manifest to the existing untrusted registry facade. publicPluginManifest() returns that trusted manifest by reference.

A synthetic enabled personal omacom.demo service used keepLoaded: true and listened to its real registry facade's manifestChanged signal. Removing only its manifest, leaving its QML available, selected the packaged counterpart:

Personal manifest removed -> packaged manifest selected as trusted
  -> old facade receives live packaged manifest
  -> old callback rewrites __sourceDir to the personal directory
  -> provenance check destroys the old object
  -> NEW object loads PERSONAL QML with the trusted host shell
Native minimal-host case Replacement code Trusted host access
Passive personal service Packaged Yes
Personal callback rewrites received manifest Personal Yes
Same callback, diagnostically detached manifest Packaged Yes

Impact: Personal code can receive the packaged replacement's trusted host APIs despite object recreation. This violates the intended source/trust-transition protection. It is a within-process API-boundary issue, not an OS sandbox escape; no credential access or OS privilege escalation was tested.

Suggested change: Keep manifests supplied to existing third-party facades detached from canonical registry state, and revoke or rebind facade ownership on source/trust changes before notifying old code. Provenance decisions should use host-owned state that those callbacks cannot mutate. The detached-manifest control prevents this demonstrated redirection, but is not proof of complete stale-reference revocation. Include this callback-driven transition in the regression case; the current service-only mock omits facade synchronization.

Verified: With explicit XDG roots, the CLI and native registry selected personal copies before checkout copies before ordered data roots, rejected external omarchy.* IDs, and assigned omacom.* trust by origin rather than manifest claims. Passive retained services were replaced correctly when their selected source/trust changed.


Review information

Test scope: Pinned-source CLI tests, native offscreen Quickshell registry runs, and native registry/facade QML with extracted production lifecycle functions and synthetic services in a minimal host. Passive and detached-manifest controls distinguish the second failure. Service/authentication contract tests also used JavaScript mocks. No full desktop, live authentication service, or hardware testing.

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Automated AI review: Astra initial source inspection, independent Fable 5.1 High and separate Astra Xhigh technical assessments, followed by cross-checking the claims against saved targeted evidence and coordinator synthesis.

@spencerbull

spencerbull commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor Author

Reviewed rebased 46f5388481a8e491d59835020929495829dbb447: SHIP AFTER FIX; ready for the maintainer's merge decision. The earlier community findings were valid and remain fixed. Discovery now stamps capabilities in one pass from the first selected manifest while preserving HOME, checkout, then ordered XDG data-root precedence and packaged omacom.* trust. GPT-6 XHigh Codex source reviews found stale bar and widget facade reuse, a late widget load that could restore an old source, a pending service that could publish after disablement, and a failed widget replacement that could leave the old registration; those paths are fixed. Read-only Codex review independence is not guaranteed.

In a credential-free Arch VM, seven focused checks passed on the final patch: native Quickshell discovery, registry and service provenance, the auth boundary, plugin add and clone, and the full shell runtime smoke test. Deliberate reversions of the new lifecycle guards made their regression assertions fail. Earlier in this review, real omarchy-overview and dizziee.system-stats marketplace repositories installed and enabled through live shell IPC, while a real pick.screenshot copy was found through the default data roots and duplicate installation was rejected; those marketplace runs preceded this simplification, so the final patch's real-plugin install flow was not rerun. The broad test/all run passed CLI but timed out after 219 shell test files in this minimal VM, with unrelated stock-tool and provisioning gaps. A stock Omarchy ISO worker and visual acceptance remain unverified.

Rebased all nine commits onto quattro at 5bc098d74914a4b8268a6db0cd150e854f2cceab; git range-diff matched every commit, the aggregate patch ID stayed 85269dfb0787b87343bed75b62f7ff7f441c477d, and the base changed none of this PR's files. The PR remains open; no merge was performed.

🤖 Generated by GPT-6 in Codex. Reviewed by GPT-6 XHigh.

@llstrk

llstrk commented Sep 23, 2026

Copy link
Copy Markdown

Verified by source inspection: both findings in the earlier review are resolved at 5393fe1ed2d6 for the reported conditions. No new actionable defect was identified in the directly affected code.

Prior finding Current change
Unset XDG_DATA_DIRS became the literal "null" argument The shell now normalizes it to an empty string, allowing Bash's default data roots to apply.
An old personal facade received and could rewrite its trusted replacement's manifest Pruning now removes that facade before manifest assignment. Source/trust checks also prevent the old scoped service lookup from reaching the replacement.

Verified by source inspection: the clone filter now requires an omarchy.* built-in, rather than accepting every trusted packaged plugin. The regression tests now include an explicitly unset native discovery case and a callback-driven facade transition using JavaScript mocks; these tests were inspected, not executed in this follow-up.


Review information

Test scope: Source-only reassessment of the fixes and directly affected behavior. The original native QML callback reproduction was not rerun, so native signal/destruction timing and comprehensive stale-reference revocation remain unverified. The author's VM, marketplace and smoke-test results were not independently reproduced. This is scoped resolution, not a whole-PR or desktop validation.

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Automated AI review: Astra Medium initial inspection, independent Opus 5.5 High and GPT 6 Sol Xhigh source assessments, then Astra Medium evidence cross-checking and synthesis.

Comment thread bin/omarchy-plugin-catalog Resolved
Comment thread bin/omarchy-plugin-catalog Resolved
spencerbull and others added 10 commits September 24, 2026 23:57
Resolve external plugin IDs from the user directory, the active Omarchy checkout, then XDG data directories in order. Track discovery origin separately from the manifest path so external directories cannot claim the reserved built-in namespace.

Co-Authored-By: GPT-6 XHigh <noreply@openai.com>
Preserve search precedence while granting first-party APIs to omacom.* plugins from the active checkout and XDG roots. Recreate retained services when their source or trust changes so old personal code cannot inherit a packaged replacement’s access.

Co-Authored-By: GPT-6 XHigh <noreply@openai.com>
Normalize an unset XDG_DATA_DIRS before passing it to Bash so the runtime uses the same default roots as the CLI catalog. Exercise the native Quickshell argument and resulting scan with the variable truly unset.
Bind scoped callbacks and registry facade caches to the source and trust that created them. Revoke old facades before synchronization can hand them a trusted replacement manifest, and decide ownership from host cache keys so a writable facade ID cannot abort reconciliation. Keep the asynchronous provenance guard observable with both loads pending.

Co-Authored-By: GPT-6 XHigh <noreply@openai.com>
Packaged omacom.* plugins are trusted by the registry, but the clone command derives its local ID from an omarchy.* built-in. Require that namespace explicitly and make the fixture valid so the test reaches the catalog selection.
The first valid manifest is already the authority for an ID. Stamp its capabilities directly so a personal override cannot inherit those of a packaged copy, while clones still inherit from the selected trusted source.

Co-Authored-By: GPT-6 XHigh <noreply@openai.com>
Bind widget registry, built-in bar and replacement-bar entry facades to the selected plugin source. A replacement gets fresh callbacks and presentation bindings; unchanged selections keep their existing instances.

Co-Authored-By: GPT-6 XHigh <noreply@openai.com>
A delayed widget load can finish after discovery selects a different source and restore the displaced component or clear the new load claim. Bind completion to its claim and selected manifest, and clear pending claims when widgets disappear.

Co-Authored-By: GPT-6 XHigh <noreply@openai.com>
A pending service could publish after disablement, and an asynchronous widget replacement could leave its displaced registration behind if the new component failed. Check the enabled state before service publication and remove the previous widget registration when replacement starts.

Co-Authored-By: GPT-6 XHigh <noreply@openai.com>
The catalog comment should retain its purpose and state the HOME, checkout, and ordered XDG root precedence now used by the shell and CLI.

Co-Authored-By: GPT-6 XHigh <noreply@openai.com>

@spencerbull spencerbull left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reviewed exact head 033a1496b26ba20b2c19882b34d825d71aaa848f against quattro c3e67f5d405047765d47a9336a3df115a7beecfb: ready for the maintainer's merge decision. The two latest inline comments were valid; the catalog header now states the actual HOME → active checkout → ordered XDG data-root load order. I replied to both threads. The earlier community findings about unset XDG roots and an outgoing personal facade reaching its trusted replacement remain fixed. GPT-6 Astra XHigh reviewed the final source and found no actionable defect; review independence is not guaranteed.

Three credential-free Omabot Proxmox workers linked this exact head and exercised the published, signed omarchy/elsewhen 1.0.0-2 package. VM 9001 installed it through the real package flow. With the HOME link absent, the catalog selected /usr/share/omarchy/shell/plugins/omacom.elsewhen as firstParty:true; live IPC showed it enabled. Disabling removed its bar registration and re-enabling restored the 27 px widget immediately before the clock. I independently viewed the worker screenshot (SHA256 ded113444514b8b7af0586dd626b740b1203e522aab704c129dadb325ccb9b04).

VM 9002 proved HOME overrides checkout and package while remaining untrusted; removing HOME selected the trusted checkout, and removing checkout restored the trusted package. With process XDG_DATA_DIRS=A:B:/usr/share and then B:A:/usr/share, live IPC and catalog selected A then B, and the bar glyph changed in independently inspected screenshots (SHA256 A 22b347513004fcb6e7e76b51da75f6a07b4e5664dbbc89ec6773d320198ba32d, B f2b943d6ef779e5c8b60dafec680905f8d1dc3c1aa3f4a344125ce472681dd0a). Invalid B fell through to A; invalidating A too selected the unmodified signed package and its native times IPC returned five clocks. HOME then beat the XDG roots; invalid HOME schema and unsafe ../Panel.qml each fell back to B. Catalog paths, live IPC trust flags, component file-open events, and a VM-only source probe corroborated these transitions. Fallback screenshots were obscured by worker display sleep, so the fallback claim rests on IPC and file-open evidence.

VM 9003 exercised two separately labeled synthetic Elsewhen-derived fixtures, an ordinary service and a service declaring authentication capability. For both, package → HOME → package changed live firstParty true → false → true, replaced instances in destroy-before-create order, and changed host ShellRoot access to an ID-scoped PluginShellApi under HOME. A newly invalid HOME entry point left no live service or privileged fallback; repair and package restoration recovered, and removal left no catalog/runtime/IPC entry. Real Elsewhen is a bar widget; these fixtures test the new service and capability branches. The hostile-facade callback and delayed widget-load cases also remain covered by focused regressions and earlier mutation checks, not by a live authentication service.

The VM 9001 focused run passed 157 assertions in eight files, zero failures; VM 9002 passed 115 focused assertions and VM 9003 passed 94. Full ./test/all completed with 3,482 passing assertions but failed on six explicit assertions plus two silent file exits (seven shell files and the CLI suite). A fresh base-commit worker, with the same signed Elsewhen package and test wrapper, reproduced every one of those eight failing targets with the same assertions and exit codes; they are existing base failures in theme, ASCII/branding, kernel, omasnap, and package ownership checks. GitHub reports no PR checks. VMs 9001–9003 and the base-control VM were destroyed after evidence readback; unrelated VMs were untouched. The PR remains open and unmerged.

🤖 Generated by GPT-6 in Codex. Reviewed by GPT-6 Astra XHigh.

@llstrk

llstrk commented Sep 27, 2026

Copy link
Copy Markdown

Automated AI review

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Verified at 033a1496: both findings from the initial review remain resolved, and no regression was found in the five commits added since the previous follow-up. The rebase carried the earlier five commits over as identical patches. Two issues in the unchanged discovery code, a documentation note and a note on related open PRs follow; none of them changes the resolved findings.

Prior finding Status at 033a1496
Unset XDG_DATA_DIRS reached Bash as the literal "null" Resolved. PluginRegistry.qml still passes Quickshell.env("XDG_DATA_DIRS") || "". In native offscreen Quickshell 0.3.1 runs, the PR's runtime discovery test passed its unset case, and a registry scan with the variable unset read the default /usr/share root.
An old personal facade received its trusted replacement's manifest Resolved. syncPluginApis() still prunes facades before assigning manifests. The callback-driven regression test passes, and moving the prune after the assignment makes it fail. The original native callback reproduction was not rerun.

Verified, new commits:

  • 11e429f6: the single-map capability stamping matched the previous two-map version in 20,000 randomized selections.
  • a33b767a, 667a63e2 and 026045c5: the PR's regression tests for source-bound widget-registry, bar-entry and bar facades, stale asynchronous widget loads, failed widget replacements and disabled pending services pass, and each of 10 targeted mutants of the new guards makes them fail. Scenario runs against the previous head confirm the bar-facade and widget-load changes. Facade reuse is unchanged between rescans.
  • 033a1496: the new catalog header matches the script: HOME, then the active checkout, then ordered XDG data roots, with the first valid manifest per ID.

Default install logs a reserved-ID rejection for every built-in

A standard install has OMARCHY_PATH=/usr/share/omarchy, so the default /usr/share data root is the same shell/plugins directory as the bundled root. The data-root pass then reaches every omarchy.* manifest again, and the reserved-ID check warns even when that ID was already selected from the bundled pass.

Native simulation of the head tree Selected plugins "id is reserved" warnings per scan
Bundled root equals the default data root 37, all trusted 37
Separate roots Same 37 0

Impact: Plugin selection is unaffected, but every startup and rescan logs that each built-in was "rejected" although it loaded, which can mislead anyone debugging plugin discovery.

Suggested change: Skip a data root whose omarchy/shell/plugins directory is the bundled directory, for example [[ ${data_dir%/}/omarchy/shell/plugins -ef $OMARCHY_PATH/shell/plugins ]] && continue in the CLI catalog and the same test against $0 in the shell scanner. Alternatively, warn only when the reserved ID was not already selected.

Existing Elsewhen links keep the packaged plugin untrusted

On dev-linked installs, migrations/1790042972.sh created ~/.config/omarchy/plugins/omacom.elsewhen pointing at the packaged copy. With this PR the HOME entry still wins and is classified third-party. In a CLI catalog check with a synthetic omacom.elsewhen in a data root, it was selected with firstParty: true without the link and firstParty: false with it. This matches base behavior, and #12871 stops creating the link without removing existing ones.

Impact: Dev-linked systems that already ran the migration do not get the trusted packaged Elsewhen that XDG discovery now provides until the link is removed by hand.

Suggested change: Add a migration that removes the link only when it still points at /usr/share/omarchy/shell/plugins/omacom.elsewhen, leaving user-made copies alone.

Documentation note: Personal plugin directories now also accept adjacent *.manifest.json files (the base accepted only <dir>/manifest.json), while docs/omarchy-shell.md describes adjacent *.manifest.json files only for bundled and data-directory plugins. omarchy-plugin-remove looks a plugin up by its directory name, so such an extra manifest's ID is not found. Either restrict the personal scan to manifest.json or document the behavior. manual/32-shell-plugins.md still lists only the checkout and personal plugin roots.

Related open PRs: #13340 (JSONL scan records) and #12981 (external scan script) both rewrite the same scanner in PluginRegistry.qml, and neither scans data roots: the external script in #12981 takes only the bundled and personal roots, and the #13340 parser accepts only firstparty and thirdparty records. Whichever lands second needs this PR's data-root pass carried over, or the shell would stop discovering packaged plugins while the CLI catalog still lists them.


Review information

Test scope: Fresh follow-up at 033a1496. Source inspection, the PR's related shell tests at head and base, native offscreen Quickshell 0.3.1 registry runs, JavaScript scenario and mutation checks of the new guards, and native CLI catalog checks. The full ./test/all, the author's VM and package results, and desktop or live-bar testing were not reproduced.

AI process: Opus 5.5 Medium coordination and synthesis, Opus 5.5 Xhigh technical review and final fact check, GPT 6 Sol Xhigh search for related issues, Opus 5.5 Medium editorial check.

Opt out: To stop receiving these reviews, reply to this comment saying so.

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants