Skip to content

fix(update): gitignored user files also block the destructive ZIP overlay - #96440

Merged
kshitijk4poor merged 2 commits into
NousResearch:mainfrom
kshitijk4poor:fix/zip-dirty-tree-ignored-all
Aug 27, 2026
Merged

kshitijk4poor merged 2 commits into
NousResearch:mainfrom
kshitijk4poor:fix/zip-dirty-tree-ignored-all

Conversation

@kshitijk4poor

Copy link
Copy Markdown
Contributor

Summary

Gitignored user files now also block the destructive ZIP-fallback overlay during hermes update. Carried from #87392 (@JoaoMarcos44), whose core ZIP-guard fix was superseded by the #87327#87878 salvage chain but whose --ignored=all hardening never landed.

Root cause: the dirty-tree guard (_zip_overlay_block_reason) ran git status --porcelain --untracked-files=all — gitignored files (local logs, scratch files, user data sitting in the checkout) were invisible to it, and the ZIP overlay permanently deletes them.

Changes

  • hermes_cli/update_cmd.py: the status probe adds --ignored=all; a new _is_zip_preserved_entry_status_line filter exempts the swap's own preserved top-level entries (venv, node_modules, .git, .env — gitignored on every normal install) so they can't become a false refusal.
  • 3 regression tests: ignored user file blocks; the invocation carries --ignored=all; ignored preserved entries don't block.

Validation

Before After
!! scratch/notes.local in checkout overlay proceeds, file deleted overlay refused
!! venv/, !! node_modules/ (invisible) still allowed (preserved entries)
test_update_zip_fallback_guards.py 20 passed 23 passed; 2 new tests fail on unmodified main (mutation-checked)

Credit: @JoaoMarcos44 — commit cherry-picked shape with authorship preserved.

@alt-glitch alt-glitch added type/bug Something isn't working P1 High — major feature broken, no workaround comp/cli CLI entry point, hermes_cli/, setup wizard area/install-update Installer, updater, packaging, wheels, doctor sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades labels Aug 27, 2026
Carried from NousResearch#87392 (closed as superseded — its core guard landed via the
NousResearch#87327 salvage chain): the dirty-tree check now passes --ignored=all, so a
gitignored-but-real user file (logs, scratch files, local data) blocks the
destructive ZIP overlay too. The ZIP path's own preserved top-level entries
(venv, node_modules, .git, .env — gitignored on every normal install) are
exempted so they don't become a false refusal.

Credit: @JoaoMarcos44, whose NousResearch#87392 included this hardening.
@kshitijk4poor
kshitijk4poor force-pushed the fix/zip-dirty-tree-ignored-all branch from d0cde74 to d792113 Compare August 27, 2026 14:58
@kshitijk4poor
kshitijk4poor enabled auto-merge (rebase) August 27, 2026 15:09
@kshitijk4poor
kshitijk4poor disabled auto-merge August 27, 2026 15:12
…hared preserve constant

Review corrections on the first draft (caught by /simplify-code before
merge — the PR was disarmed for these):

- BLOCKER: --ignored=all is not a valid git mode (git exits 128 'Invalid
  ignored mode'); with it, every ZIP update was refused as 'could not
  check the working tree'. The mocked tests could not see this — a new
  real-git test creates an actual repo + .gitignore and asserts the guard
  runs clean, blocks on an ignored user file, and exempts ignored
  preserved entries. --ignored=matching also reports an ignored dir as
  one line instead of enumerating its contents.
- FAIL-OPEN HOLE: the ' -> ' two-path split now applies only to R/C
  rename/copy status codes. Porcelain v1 does not quote plain filenames
  with spaces, so an ignored file literally named 'venv -> node_modules'
  parsed as two preserved tops and slipped past the guard into the
  destructive swap.
- _update_via_zip's swap loop now consumes _ZIP_PRESERVED_TOP_LEVEL
  instead of a comment-synced duplicate set (change-detector test added).
@kshitijk4poor
kshitijk4poor enabled auto-merge (rebase) August 27, 2026 15:33
@kshitijk4poor
kshitijk4poor merged commit f3cbb26 into NousResearch:main Aug 27, 2026
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/install-update Installer, updater, packaging, wheels, doctor comp/cli CLI entry point, hermes_cli/, setup wizard P1 High — major feature broken, no workaround sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants