Skip to content

Validate plugin updates before changing installed checkouts - #10711

Open
yashranaway wants to merge 10 commits into
omacom:quattrofrom
yashranaway:fix/validate-plugin-before-update
Open

yashranaway wants to merge 10 commits into
omacom:quattrofrom
yashranaway:fix/validate-plugin-before-update

Conversation

@yashranaway

@yashranaway yashranaway commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

This validates a fetched plugin revision before changing the installed checkout. A bad revision leaves local edits alone, and a successful update needs no destructive rollback.

Git still decides whether an update can land. Unrelated edits and cache files stay in place, while overlapping changes or ignored files at new upstream paths stop the update. Successful entries in a partial batch still request a rescan.

@omarchybot omarchybot added the bug Something isn't working label Sep 27, 2026
@greptile-apps

greptile-apps Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[High impact] Changes how plugin updates are staged and validated.

The PR is not ready to merge while a partially failed batch explicitly reloads the failed plugin’s local state.

Summary

The PR validates fetched plugin revisions in a temporary checkout before fast-forwarding installed plugins and updates the manual and regression tests.

  • The updater now preserves unrelated local files and protects ignored files from overwrite.
  • A partially failed batch now explicitly rescans all installed plugins when any entry updated.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  Fetch[Fetch and pin candidate] --> Stage[Stage candidate with separate Git index]
  Stage --> Validate[Validate staged tree]
  Validate -->|Valid| Merge[Fast-forward installed checkout]
  Merge -->|Succeeded| Updated[Set UPDATED_ANY]
  Merge -->|Failed| Failed[Set batch failure]
  Updated --> Rescan[Explicit rescan if any entry updated]
  Failed --> Rescan
  Rescan --> All[Reload all installed plugins]
Loading

Reviews (5) · Last reviewed commit: "Merge remote-tracking branch 'origin/qua..." · Reviewed by Greptile

Comment thread bin/omarchy-plugin-update Resolved
Comment thread bin/omarchy-plugin-update Resolved
Comment thread bin/omarchy-plugin-update Resolved
Comment thread bin/omarchy-plugin-update Resolved
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at 256629e against quattro, on a disposable Omarchy worker. The bug is real and this fixes it, but the clean-checkout requirement stops plugins that keep runtime files in their own directory from ever updating. That needs your call before this can go further.

The bug, reproduced. I set up a plugin checkout with an uncommitted edit to a file upstream doesn't touch (README.md), then pushed an upstream revision with an invalid manifest. On quattro, omarchy plugin update --yes fast-forwards, fails validation, and reset --hard ORIG_HEAD deletes the edit. On this head the staged revision fails validation, the installed checkout isn't touched, and the edit survives.

The regression. bin/omarchy-plugin-update:95 refuses any checkout where git status --porcelain --untracked-files=all --ignored prints anything. Real plugins write into their own directory while they run: a Python helper's __pycache__/ (#11929), or a cache like the bitwarden plugin's data.json (#12158). On the worker, a plugin with an ignored __pycache__/helper.cpython-314.pyc and data.json, given a valid upstream update, updates on quattro and is refused on this head with "has local changes … save them outside the checkout". Adding them to .gitignore doesn't help, and deleting them only lasts until the plugin runs again.

The same check after the merge (line 106) has a second failure mode. If a running helper writes its cache between the fast-forward and the recheck, the update has already been installed but is reported as failed. UPDATED_ANY is never set, so there's no rescan, and running it again just prints "up to date".

The batch rescan. Line 164 skips rescanPlugins for the whole batch if any plugin failed, including the ones that updated fine. The file watcher usually reloads those anyway. But it waits a second before restarting (shell/services/PluginRegistry.qml:684) and doesn't catch up afterwards, so an update that lands in that gap stays stale until something else triggers a reload.

A smaller fix would keep the staging validation, which is what actually fixes the bug, and leave out the blanket clean-checkout check. That way a local edit Git can't fast-forward past is still refused by merge --ff-only, and unrelated or ignored files are left alone, as before. I haven't pushed this because the strict check was a deliberate choice in this branch, and which local state an update should tolerate is your call.

Tests run. test/shell.d/plugin-update-test.sh passes on the worker. ./test/cli passes except for vscode generated theme references current theme file, which also fails on quattro at the merge base and has nothing to do with this change. CI has no runs on this head apart from Greptile's review.

Overlap. #13006 (pausing the local watcher during updates) and #13345 (--no-pager on the diff) both edit this script and will conflict with it. They fix different bugs, so they aren't competing fixes.

The second opinion was Codex at medium effort. It agreed with the regression, but it could read this session's notes, so that agreement isn't a guaranteed independent check. It added the post-merge race and the stale-reload gap, and I checked both against the source. This is waiting on the author.

@greptile-apps

greptile-apps Bot commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Comments Outside Diff

These findings could not be posted inline.

  • P1 Failed batches rescan plugins bin/omarchy-plugin-update:155 ▶

    When one plugin updates but another fails because of conflicting local edits, UPDATED_ANY still requests an explicit rescan. The rescan reloads every installed plugin, including the failed plugin's unvalidated local state. The file watcher may reload plugins independently, but this change adds an avoidable reload even though the batch failed.

    if (( UPDATED_ANY && rc == 0 )); then
    

@yashranaway

Copy link
Copy Markdown
Contributor Author

Fixed in f6649ba. Validation still happens before the checkout changes, but unrelated edits and ignored runtime files can stay. Git refuses overlapping edits and ignored path collisions, and a partial batch rescans successful updates. The plugin update regression covers those cases, merge-time writes, and interruption.

@omarchybot omarchybot added verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge labels Oct 15, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Re-reviewed at f6649ba against quattro, on a disposable Omarchy worker. The regression from the last review is gone and nothing else needs changing. This is now waiting on the maintainer.

The bug, reproduced again. My own reproduction: a plugin checkout with an uncommitted edit to README.md, then an upstream revision with an invalid manifest. With quattro's script, omarchy plugin update --yes fast-forwards, fails validation, and reset --hard ORIG_HEAD deletes the edit. With this head the edit survives and the installed revision doesn't move. test/shell.d/plugin-update-test.sh passes 10/10 on this head, and fails on "invalid update preserves local edits" when quattro's bin/omarchy-plugin-update is put back.

The earlier regression. I used the same plugin with an ignored __pycache__/h.pyc and an untracked data.json, then a valid upstream update. The previous head (256629e) refused it. This head fast-forwards and keeps both files and the local edit. Dropping the clean-checkout check also removes the post-merge race I raised, and successful updates in a partly failed batch now trigger the rescan.

Greptile's rescan comment (bin/omarchy-plugin-update:155) doesn't hold up. A rejected revision never reaches the failed plugin's checkout. So the rescan reloads what was already on disk and already being watched, not anything unvalidated.

Tests run. ./test/cli passes in full on the worker (125 ok, 0 failures). CI is green on this head.

Overlap. #13006 and #13345 still edit this script and will conflict with it. They fix different bugs, so they aren't competing fixes.

The second opinion was Codex at medium effort. It agreed the bug is real and the fix is proportionate. It could read this session's notes, so that agreement isn't a guaranteed independent check. It raised two ways the staged tree could differ from what the fast-forward installs. I don't think either can happen in practice. Populated submodules can't happen, because omarchy plugin add clones without submodules and the update never initialises them. A .gitattributes change in the candidate applying differently in staging and in the merge didn't happen when I tried it on the worker, and the filter variant needs a smudge driver set up on the user's machine.

@omarchybot omarchybot removed the ready Good to merge label Nov 18, 2026
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.

2 participants