Commit Graph

58 Commits

Author SHA1 Message Date
Teknium
25db2df103 fix(git): graph refresh honours global core.commitGraph, serializes its slot and covers linked worktrees
Review round on the commit-graph refresh (Greptile + re-review):

- Global graph setting is ignored: core.commitGraph=false is read with the
  user's global/system git config, which the writer's isolated env blanks.
- Expired slots allow duplicate writers: check and claim of the maintenance
  slot run under one flock/msvcrt lock on the slot file, which is never
  unlinked; a failed spawn gives back only a claim holding its own pid.
- Linked worktrees and submodules (a .git file) were skipped: the common git
  dir is resolved once (update_lock._git_common_dir) and used for the object
  store, slot, debris sweep and fresh stamp, on the update spawn and on the
  `hermes -w` pass alike.
- Timeouts were silent: the kill is logged at WARNING, with the timeout
  unrounded.
- kill_process_tree(grace>0) returned once the leader exited on SIGTERM,
  orphaning a group member that ignores it: the rest of the group it led is
  SIGKILLed. grace=0 is unchanged.
- The child's failure line was lost when <home>/logs did not exist: the log
  dir is created at failure time via mkdir_under_hermes_home (a deleted
  profile is not resurrected), and a log that cannot be opened no longer
  raises out of the logger.
2026-10-25 17:51:21 -07:00
Teknium
a80b413cd6 fix(git): graph refresh sweeps only object-store debris and lets git clean up
Review round on #144647 (head d016f04694d):

- CI routing: the refresh (slot claim, bounded runner, stale check, detached spawn) moves to
  hermes_cli/git_commit_graph.py, routed to e2e_upgrade with the update pipeline. The update path
  imports it instead of all of worktree_ops; worktree_ops keeps its repack seams and imports the
  shared slot claim and runner from it (no cycle).
- W1: the -w pass runs in whatever repo it was launched from, so its refresh sweeps only the
  object-store locks (clear_stale_git_locks(names=OBJECT_STORE_LOCK_NAMES)); index.lock / HEAD.lock
  there belong to the user's git. The install checkout's update sweep is unchanged.
- W2: timeout/exit reaping SIGTERMs the git tree first and SIGKILLs only after a 5 s grace
  (kill_process_tree(grace=), default unchanged for every other caller), so git deletes
  commit-graph-chain.lock and tmp_graph_*. The age-gated tmp sweep now also takes
  objects/info/commit-graphs/tmp_graph_*.
- N1: a breakaway-forbidding Windows job gets the no-breakaway retry, and a spawn that fails gives
  the 6 h slot back.
- N2: the detached child logs a failed write (git's fatal line) to the home's agent.log/errors.log.
- core.commitGraph=false in the target repo skips the write.
- N3: a successful no-op write stamps hermes-commit-graph.fresh, so an idle repo is not rewritten
  every slot.
- N4: test_update_finish's completion child and every in-process hermes_cli test stub the
  detached spawn; no writer outlives a test run.
- Greptile: the refresh test now runs on a treeless clone over a Bloom graph and asserts the
  write adds no pack (red when --no-changed-paths is dropped).
2026-10-25 17:51:21 -07:00
Teknium
0c81251886 fix(update): refresh the install checkout's commit-graph after each update
The commit-graph refresh only ran on the `hermes -w` background pass, for the repo
that launch came from. An install checkout that never hosts a `-w` launch never got
a graph, so its startup banner version lookup and `hermes update`'s ancestry checks
kept walking the uncovered history.

_run_post_update_maintenance (post-pull code, run by both the current completion
and the historical finish) now calls worktree_ops.spawn_commit_graph_refresh right
after the release-history fetch: the same missing-or-day-old check and 6 h slot,
then a detached child running the same niced runner (process tree killed at 600 s,
--split --no-changed-paths, GIT_NO_LAZY_FETCH). Detached so the write neither
delays the update nor dies with it; best-effort, so a spawn failure is a debug line,
never a follow-up. ZIP installs have no .git and skip.
2026-10-25 17:51:21 -07:00
Teknium
1675bc9d49 fix(git): keep the commit-graph fresh and clear stale commit-graph/midx locks
`git tag --merged HEAD` (the version lookup run at startup and by `hermes update`)
walks every commit the commit-graph does not cover. On a real install checkout the
graph had stopped two months back (0.34 s per lookup; 0.04 s once fresh) because:

- partial clones have git's own graph writers switched off on purpose
  (gitlock._TREE0_MAINTENANCE_OFF, #127711), and Hermes's pack maintenance never
  wrote one; and
- a killed writer's objects/info/commit-graph.lock sat there for two months.
  gitlock's stale-lock sweep only knew shallow/index/HEAD/MERGE_HEAD locks.

Changes:
- clear_stale_git_locks also sweeps commit-graph.lock, the split chain lock and
  both multi-pack-index locks (same age + no-git-running gates). Covers the
  update path (clear_git_debris) and the background pass.
- _maintain_pack_health (background thread on `hermes -w` launches) refreshes a
  missing or day-old graph with `git commit-graph write --reachable --split
  --no-changed-paths`, under its own single-flight 6 h slot, niced, killed as a
  process tree on timeout, with GIT_NO_LAZY_FETCH. Without Bloom data the write
  reads commits only, never trees, so it cannot start the #127711 lazy-fetch
  loop (tree:0 probe: 0 fetches vs 10 for an inferred-Bloom write), and costs
  ~3 s instead of ~27 s on hermes-agent's 390k commits.
2026-10-25 17:51:21 -07:00
Teknium
adc330b185 fix(worktree): prune each repo once per interval, skip the whole-tree du when the count decides
A multiplexed gateway ticks cron once per served profile and every profile resolves the hermes
checkout, so the 6 h worktree maintenance (throttled per profile home) pruned the same repo once
per profile at the same second. Each pass ends in _warn_worktree_footprint, which ran
`du -sm <repo>/.worktrees` over every file of every tree (node_modules included) even when the
tree count alone (>= 10) already decided the warning. Observed: 4-11 concurrent full walks per
burst, on every boot and every 6 h.

- cron/scheduler.py: repo discovery stays throttled per profile home (own registry and jobs);
  the prune itself is claimed per resolved repo root, once per interval across every profile
  the process serves.
- worktrees_summary(size_below_count=...) skips the size probe when the count decides; the
  footprint warning drops the size text in that case instead of printing "unknown size".
- _tree_size_mb runs du through bounded_probe_run: subprocess.run's post-kill wait() never
  returns for a du stuck in uninterruptible disk I/O, hanging the caller (a `hermes -w`
  launch or the cron prune thread).
2026-10-25 07:53:55 -07:00
kshitijk4poor
26409f994c fix(cli): a classic -w session gets its clean tree back on resume
`hermes -w` (classic, not `--tui -w`) runs its session's tools in the
new worktree: the gateway policy freezes the tree as the session's cwd.
Quit removes a clean tree, and a later `hermes -c` / `--resume` of that
session then had every turn refused `workspace_unavailable`: the owner
refuses a missing directory.

The `--tui -w` resume fix (N8) already recreates a missing tree on
resume, but only one its launcher recorded, and it looked for it in
the session row's cwd. A classic `-w` launcher recorded nothing, and
its row keeps main's stamp, the repo root (e504e030e3, @teknium1,
2026-10-12), not the tree its tools run in.

- The classic launcher passes the profile's state.db to
  `_setup_worktree`, as `--tui -w` does: the tree is recorded for
  resume, and its lock names the store. The row's cwd stays the repo
  root, so a reaped clean classic `-w` tree is not kept; it is
  recreated on resume.
- The resume step reads the session's frozen policy cwd (its local
  receipt; a read) before the row's cwd, since that is the directory
  the owner checks. A store error on that read falls back to the row's
  cwd.

Trees are still removed on quit.

Refs #134889 (CLI-15)
Refs #139158
2026-10-20 15:08:20 +05:30
Teknium
9e49003893 fix(cli): a resume recreates the --tui -w worktree quit removed, so its turns run
Quitting a clean, idle `hermes --tui -w` session removes its tree and
branch (N8). The session's policy froze that cwd, so a later resume
had every turn refused workspace_unavailable.

The launcher now records each tree it creates in the profile's
tui_worktrees.json. A resume (`--tui --resume`, `--tui -c`, classic
`--resume`/`-c`; all go through _resolve_chat_session_args) whose
session cwd is such a missing tree recreates it at the same path
before attaching. It uses the branch when that survived, else a new
branch of the same name from the repo's current HEAD, and locks the
tree for the session. Only a recorded path directly under the repo's
.worktrees/ is created. Any other missing directory is left alone.

The CLI docs list every keep reason, the resume recreate, and the
remaining quit-time race.

Refs #134889 (N8)
2026-10-19 11:46:26 -07:00
Teknium
3f7393ca6e fix(tui): --tui -w keeps a clean tree the gateway still schedules work in
N8 removed a clean `--tui -w` tree on quit when no admission was pending.
The shared gateway keeps acting in a LOCAL session after its viewer quits,
so between ticks that check said idle and the tree and branch went, and the
next tick was refused workspace_unavailable (policy_scope). Same for a second
viewer (a Desktop window) still on the session.

The launcher now also keeps the tree when, for a session whose cwd is inside
it, the gateway's own records say it still acts there:
- an active loop:, heartbeat: or goal: row (status active, or unparseable);
- the row is not ended. Ink's exit detaches with tui_shutdown and the owner
  ends an idle row only once no other viewer holds it
  (gateway/session_viewer_close.py), so an open row means another viewer;
- an enabled, non-terminal cron job whose workdir is inside the tree, or
  whose origin is that session's local chat.

All reads are read-only (state.db opened mode=ro, jobs.json parsed without
load_jobs' repair write); an unreadable store keeps the tree. The served
check runs after the in-use grace so a legacy sidecar's tui_shutdown stamp
lands first. Dirty, unpushed and blocker trees are still kept by
_cleanup_worktree, and pending admissions and other processes still keep it.

Refs #134889 (N8)
2026-10-19 05:43:16 -07:00
Teknium
1e55d1ca87 fix(tui): hermes --tui -w removes a clean worktree on quit again
Since the shared gateway landed, quitting `hermes --tui -w` retained every
worktree, clean ones included, so they piled up. Before #106742 a clean tree
was removed with its branch on quit.

The launcher now removes the tree through `_cleanup_worktree` when it is
clean, no queued or started admission targets a session inside it, and no
other process still works in it. A dirty tree, one with unpushed commits, or
one the gateway still has a turn for is kept and re-locked for its session,
as before. `_retained_tree_is_live` gains `pending_only` so the launcher can
ask "does the gateway still owe work here" without counting plain history.

Refs #134889 (N8)
2026-10-19 03:40:39 -07:00
Teknium
06671b7075 fix: worktree removal treats ignored files as disposable
Ignored files in a worktree (.env copies, caches, build and test output,
launcher scripts) are never meant to be preserved: removing a worktree
deletes them, the same as every other worktree tool. The keep-ignored-work
rule kept 461 of 574 real trees forever, so it is removed with its
regenerable-dir list and main-checkout byte comparison.

Kept: keep-large-untracked, keep-unarchivable (embedded repos, including
ones inside ignored dirs, whose commits may exist nowhere else; an
over-budget ignored walk now reports keep-unarchivable), keep-worktree-refs,
the submodule rule, the showUntrackedFiles=no and skip-worktree fixes, and
the staged-edit recheck.
2026-10-17 21:49:14 -07:00
Teknium
ab1c29d8bb fix: worktree sweep keeps any tree holding work an archive cannot restore
The second review found trees deleted with bytes or commits that were in
neither git nor the archive: untracked files over archive_max_file_mb
(skipped from the snapshot, tree still removed), gitignored embedded
repositories (ls-files --exclude-standard never lists them) and every
ignored file (.env edits, *.secret, info/exclude notes). The classic
pruner had three older gaps of the same class: status.showUntrackedFiles=no
made new files invisible, skip-worktree/assume-unchanged edits read clean,
and commits held only by refs/worktree/* or refs/bisect/* died with the
tree's admin dir.

Rule now enforced at one decision point (worktree_retention.removal_blocker)
used by archive_preflight, the post-snapshot removal boundary in
archive_then_remove (sweep, exit Archive, subagent finalize), the classic
clean-tree pruner, the attended `hermes worktree prune` and the clean exit
path: a tree is removed only when everything irreproducible is in git or the
archive. Kept: keep-large-untracked (archive ref stays), keep-unarchivable
(embedded repo, ignored or not), keep-worktree-refs, keep-ignored-work
(ignored files outside a regenerable-dir allowlist that are not
byte-identical to the main checkout's copy, so .worktreeinclude .env copies
never block). Exit Archive and the subagent note name the reason. Every
dirty check forces --untracked-files=normal and counts flagged-index edits.
The ignored-path walk skips dependency stores without descending and is
capped per tree (unverifiable -> keep).
2026-10-17 21:49:14 -07:00
Teknium
d413d8b1b7 fix: worktree sweep never archives or removes a tree with a submodule
An archive records a submodule only as its 160000 gitlink, and removing a
worktree deletes its per-worktree modules/ repositories. The selective check
on d70ebda missed two cases an independent review reproduced with real git:
- `git submodule deinit` keeps the module repository (private branches
  included) under <worktree gitdir>/modules/ while the checkout has no .git,
  so the tree was archived and removed and the private commit was lost;
- an edit to an existing file inside a submodule during capture moves no
  superproject path mtime and no index entry, so the post-snapshot guards
  passed and the edit was deleted.

Until recursive submodule preservation exists, use the conservative rule
the original human review proposed: a tree with any gitlink in its index or
a non-empty modules/ dir is unarchivable (keep-submodule-work). Enforced in
archive_preflight and snapshot_worktree (sweep, exit Archive, subagent
finalize) and re-checked at the shared removal boundary right before
`git worktree remove`. Clean merged trees are also kept unless modules/ is
absent and the gitlink was never initialized (classic pruner, sweep plan,
subagent no-work prune). The selective dirty/local-commit submodule probe is
removed: the blanket rule subsumes it.
2026-10-17 21:49:14 -07:00
Teknium
71a83d74d5 fix: worktree sweep honours --older-than, re-gates each tree, archives exact bytes
Review of the snapshot-then-delete sweep found paths where it could remove
work it should keep or store bytes that differ from the working files:

- `hermes worktree prune --older-than N` ran the sweep before applying N; the
  plan now marks any tree idle < N days skip-young before anything runs.
- execute_plan checked liveness once per batch, then archived trees one by one.
  Each tree is now re-gated (lock, /proc cwd/fds, fresh activity) right before
  it is touched, and archive_then_remove re-checks after the snapshot, keeping
  the tree when a process entered or a file changed during capture.
- _last_activity ignored deleted paths; it now stats each changed path's
  nearest surviving folder, so a fresh deletion counts as activity.
- `--attr-source` does not cover info/attributes or core.attributesFile, so
  eol rules still rewrote bytes. Every blob is re-hashed with
  `hash-object --no-filters` and restore writes blob bytes directly.
- The classic CLI applied the exit Archive answer in atexit, after the exit
  watchdog was armed; it is now applied synchronously in _tui_shutdown, with
  a progress line, before _run_cleanup. A failed or interrupted archive keeps
  the tree.
- web_git.worktree_add's existingBranch path skipped the repo registry.
- subagent-* trees got the 72h named-tree tier; one prune_tier_hours helper
  now gives hermes-* and subagent-* the 24h tier in both planners.
- worktree_sweep.py had a text=True git call without encoding="utf-8" (CI red).
2026-10-17 21:49:14 -07:00
Teknium
3882113085 feat: archive stale dirty worktrees before removing them, sweep every repo, ask on dirty exit
The worktree pruner never removed a dirty or unpushed tree at any age, so leftovers of finished
lanes (stray probe files, WIP commits on closed PRs) accumulated forever: 658 trees / ~1 TB on
one machine, 553 of them named lane trees. Approved design (Teknium, 2026-10-17):

- Snapshot-then-delete: an idle tree past its tier (hermes-*/subagent-* 24h, named 72h) with
  uncommitted changes or unpushed commits is archived to refs/hermes/archive/<tree> (HEAD +
  staged + unstaged + non-ignored untracked bytes, built with a temporary index; large untracked
  files skipped and listed) and then removed. A failed archive keeps the tree. Branch kept when
  published on a remote, otherwise the archive anchors its commits.
- Never touched at any age or budget: live hermes lock owners, any live process whose cwd/open fd
  is inside the tree (/proc on Linux, psutil cwd elsewhere), trees with recent file/ref activity,
  Kanban t_<hex> trees.
- No count cap; optional worktrees.max_total_gb evicts the oldest idle trees first.
- Per-profile registry (<HERMES_HOME>/worktree_repos.json) of every repo Hermes made a worktree
  in (hermes -w, /worktree new, subagent isolation, Desktop git pane); the 6h cron sweep unions
  it with its existing sources, scoped and throttled per profile.
- Subagent worktrees with commits/edits are archived and removed at child finish (branch kept).
- Interactive `hermes -w` (CLI and --tui) exit with a dirty/unpushed tree asks Keep (default) /
  Archive & remove / Remove and discard; non-interactive exits never ask.
- `hermes worktree restore <name> [--path]`, archives in `hermes worktree list`, a full
  decision table in `hermes worktree prune --dry-run`, archive retention (30 days).
- worktrees.archive_dirty: false restores the classic never-delete-dirty pruner exactly.
2026-10-17 21:49:14 -07:00
Teknium
8267406bfb fix(worktree): a retained tree's session cwd matches under Windows path identity
Mechanism: _retained_tree_is_live (new in this PR) decides whether a
retained `--tui -w` worktree may be pruned by matching sessions.cwd against
the tree root with case-sensitive SQLite `=` / substr prefix checks. On
Windows a persisted session can spell the same native path with different
casing (or separators), so a tree whose session still resumes there was
classified dead and an aged clean checkout became eligible for pruning.

Fix: compare through one identity key - os.path.normcase plus '/'
separators, trailing separator stripped - applied to both the candidate
roots and each stored cwd, via a deterministic SQLite function. Equality or
a '/'-bounded prefix counts as inside. Unreadable stores still fail safe
(live); a missing store is still dead. On POSIX normcase is the identity, so
behaviour there is unchanged.

Test: tests/hermes_cli/test_worktree_retained_cwd_identity.py runs on Linux
with os.path.normcase bound to ntpath.normcase (the native Windows
identity): upper-cased and backslash-nested cwds are live; a sibling prefix
and the parent dir are not. The two spelling rows fail on r14-base.

Review: andrexibiza 4243963745
2026-10-11 23:38:02 -07:00
Teknium
da4ae170dd fix(worktree): read lock state from the tree's admin dir, not worktree list -z
_worktree_lock_reason ran `git worktree list --porcelain -z` and raised on a nonzero exit;
_worktree_lock_is_live mapped any exception to "live". `list -z` needs git 2.36, so on Ubuntu
22.04 (2.34) / Debian 11 (2.30) every .worktrees checkout read as live-locked: the startup pruner
never reaped a stale, clean, unlocked tree, and `hermes worktree gc` reported each one as
"in use by a running hermes session".

The lock is now read where git keeps it: the tree's `.git` file names its admin dir
(`gitdir:`), which must sit under `<common-dir>/worktrees/`; `<admin>/locked` holds the raw
reason (trimmed like git's strbuf_trim), absent means unlocked. No quoting, so `db=` paths with
backslashes or non-ASCII bytes still parse. A repo git cannot read or a malformed `.git` file
still raises -> "live" (fail safe). Plain `--porcelain` is not a fallback: git <= 2.30 omits the
locked line entirely.

Test (red on r11-base under a git shim that rejects `list -z`: the dead-locked tree read "live";
green here): tests/hermes_cli/test_worktree_lock_old_git.py::
test_stale_worktrees_are_reaped_on_git_without_list_z (real git, real worktrees, real prune).

Review: dokterdok N37
(cherry picked from commit cd4a68d50275152aca7464bb81a981c465e9da62)
2026-10-10 22:49:21 -07:00
Teknium
b1ccce898b Merge origin/main (#38: 70 commits to c57331677d) into feat/unified-gateway-runtime
Conflicts: tests/hermes_cli/test_finite_chat_delegation.py and
tests/tools/test_completed_process_results.py, where main's lint sweep (0006a5e229) added
check=False to subprocess.run calls this branch had rewritten. Kept the branch's test bodies
and carried check=False onto their subprocess.run calls.
2026-10-10 17:47:35 -07:00
Maciej Lisiewski
0006a5e229 ci: fix PLW1509, PLW1510, PLW2101 linter errors 2026-10-10 15:20:13 +02:00
Teknium
38756d836a fix: keep a retained --tui -w worktree while any session in it can resume
The 24 h stale pruner judged a retained --tui -w checkout from the parsed
lock text, so three cases read as dead and a clean checkout whose session's
frozen cwd still points at it was deleted (restore_policy then refuses the
missing cwd and the session cannot resume):

1. `git worktree list --porcelain` C-quotes a lock reason containing a
   backslash, quote, control or non-ASCII byte (every Windows path, a
   `Zoë` home), so `db=` never parsed and the store counted as missing.
2. After /new the exit re-lock names only the last (empty) session, while
   the older session in the same checkout has history.
3. Closing the terminal (SIGHUP) skips the exit re-lock in _launch_tui's
   finally, leaving `hermes pid=<dead launcher>`.

Liveness now comes from the session store: the tree is live while any
session whose cwd resolves inside it has history or non-terminal
admissions. The lock is read with `--porcelain -z` (no quoting); a --tui -w
tree names its profile's state.db from creation (`hermes pid=<pid>
db=<state.db>`), so a killed launcher still leaves the tree to its sessions;
a hermes reason this version cannot parse is treated as live. Foreign
locks, dead plain `hermes pid=` locks and trees with no resumable session
are still pruned as before; dirty/unpushed gates are unchanged.

Review: https://github.com/NousResearch/hermes-agent/pull/106742#pullrequestreview-5475590057
2026-10-10 05:52:02 -07:00
Teknium
607a23e858 Merge origin/main (#30: 54 commits to 1744a19e0d) into feat/unified-gateway-runtime
8 conflicts, all from main's lint sweep (#135281 "Harder linter fixes" + the RUF series:
implicit-Optional, unused-unpacked-variable, next(...) for [...][0]). No other main commit touches
a conflicted file. Resolution: the branch side of each file plus main's exact autofix
(ruff 0.15.10, main's ruff.strict.toml, --fix --unsafe-fixes) on it. ruff.strict.toml takes main's
copy (the newly enabled rules). tests/cron/test_bot_chat_delivery_child_env.py stays deleted
(1cc9cb9199 retired its lane).
2026-10-08 21:38:54 -07:00
Teknium
49771f7b2e fix: keep a retained --tui -w worktree while its session is resumable
C1's fix stops the TUI from deleting the -w checkout on exit, but the tree's
only lock is `hermes pid=<launcher pid>`, which is dead once the TUI exits.
A later launch's 24 h stale prune (_setup_tui_worktree ->
_prune_stale_worktrees) then reads the lock as dead, unlocks and removes a
clean merged tree even though the session's frozen cwd still points at it
(restore_policy refuses a missing cwd, so the resume breaks). Probe on
r6-base driving the real _launch_tui exit path + a real git repo/SessionDB:
tree reaped with a resumable session.

On exit the launcher now re-locks a retained tree as
`hermes session=<stored id> db=<state.db>`, using the session Ink wrote to
the active-session file. _worktree_lock_is_live (shared by the startup
prune and `hermes worktree prune`) treats that lock as live while the row
has messages or non-terminal admissions (read-only open; unreadable store
fails safe toward live) and dead once the session is gone or empty, so
clean trees with no resumable session are still pruned as before.

Review: https://github.com/NousResearch/hermes-agent/pull/106742#pullrequestreview-5462648005
2026-10-08 19:09:42 -07:00
Maciej Lisiewski
4278b6aa24 ci: RUF013, RUF015 2026-10-08 21:29:48 +02:00
Maciej Lisiewski
d76cce4f11 ci: apply all automatic linter fixes available 2026-10-08 17:22:54 +02:00
Teknium
3ca97d5e59 fix(pm): orphan reclaim runs on every prune pass and keeps checkouts it cannot see
Follow-up to the review of this PR:

- The startup pruner returned early (no .worktrees/, or no tree past 24h) before the
  reclaim ran, so a tree removed by hand kept its state until some other tree aged out.
  _prune_stale_worktrees now runs the reclaim in a finally around the prune phases.
- A missing recorded path is not proof of deletion: a container sharing the data root
  (-v ~/.hermes:/opt/data) cannot see the host's checkout, and gc there deleted the
  host's live dependency environment. A state is an orphan only when its checkout sat
  under the data root that owns installs/, or directly in a .worktrees/ dir that still
  exists.
- PM runtime generation leases (pm-runtime/generations/*/.leases) now count as held,
  so a worker still running from a deleted checkout's runtime keeps it.
2026-10-07 08:47:47 -07:00
Teknium
ef4b046808 fix(pm): reclaim dependency state of deleted checkouts (pm gc + startup worktree prune)
Every checkout that boots Hermes commits its own dependency state under
<home>/installs/<sha256(path)[:16]>/ (venv, test venv, PM runtime; ~200 MB
each) and nothing removed it when the checkout went away. On a host that
runs `hermes -w` campaigns the directory held 499 entries / 92 GB, of which
402 (80 GB) belonged to worktrees and scratch clones that no longer exist.

The state dir already records its checkout in inputs/.project-root. A new
pm/install_states.py lists entries whose recorded checkout is gone and
removes them unless something could still be reading them (install lock
taken, or a generation lease held). `pm gc` runs it and reports the count;
the startup worktree pruner runs it after its own reaping so a removed
worktree's state follows the tree instead of outliving it.
2026-10-07 08:47:47 -07:00
kshitijk4poor
05d8d0a266 revert: stale worktree reaping revalidation (#132260)
Reverts the nine commits merged by #132260 (merge 05ab8766e7), from
31194ea00e "fix(cli): revalidate worktree cleanup gates before removal"
through 05ab8766e7, restoring hermes_cli/worktree_gc.py,
hermes_cli/worktree_ops.py and tests/security/test_gitspawn_config_injection.py
to their pre-merge state and removing
tests/hermes_cli/test_worktree_reclaim_revalidation.py.

Maintainer decision: back the behaviour change out (trees kept when their
state changed since the audit, plain `git worktree remove` under the tree's
git env, dirty submodule trees kept). No commit on main touched these files
after the merge, so this is the exact inverse of the merged diff.

The contributor mapping for @rudycelekli stays (attribution record only).
2026-10-03 22:03:44 +05:30
kshitijk4poor
4dc2604183 refactor(worktree): share one merge cache and ls-remote across revalidation
Gate findings (Medium efficiency + Low reuse, convergent): the startup
sweep revalidated each reap tree with a fresh _classify_prune_candidates
call. Each call reloaded (and could rewrite) the on-disk merge cache and
built its own ls-remote memo, so every pushed-tier tree paid another
network ls-remote. A 3-tree sweep made 4 loads and 4 ls-remotes; it now
makes 1 of each. The attended reclaim seeded an empty cache and re-ran
`git cherry` for verdicts the audit had just computed.

_classify_prune_candidates takes keyword merge_cache / get_remote_heads.
When the caller supplies them it uses them and leaves the save to the
caller. _prune_stale_worktrees loads once, threads both through
_reap_prune_verdicts, and saves once. reclaim_worktrees seeds from
_load_worktree_merge_cache(). Cache keys include both SHAs, so post-audit
commits still miss. Revalidation still runs per tree, right before
removal. The dead `if not refreshed` guard goes away: a one-item list
always yields one verdict.
2026-10-03 20:53:08 +05:30
kshitijk4poor
f0cacd11e8 fix(worktree): retry the plain remove with --force for clean submodule trees
Gate finding (Medium, 2c + quality convergent): plain `git worktree
remove` always refuses a tree with a checked-out submodule ("working
trees containing submodules cannot be moved or removed"). Once --force
was dropped, clean merged trees like that got a reap verdict on every
startup and every `hermes worktree prune`, and were never removed.

Both paths still try the plain remove first. Only when its stderr names
submodules and an immediate re-check finds the tree still clean
(_worktree_is_dirty False on startup; _dirty_split == (False, []) in the
attended path) do they retry with --force, under the same safe env.
Adds a submodule row to the existing parametrized startup test.
2026-10-03 20:53:08 +05:30
kshitijk4poor
5a4b350480 fix(worktree): run the startup plain remove under the repo-safe git env
Gate finding (High, 2ab): dropping --force from the startup reap's
`git worktree remove` makes git read the tree's index, which executes the
repository's core.fsmonitor (GHSA-7x36-8jrh-v4pw) on the unattended
startup sweep. tests/security/test_gitspawn_config_injection.py went red.

Route the remove through noninteractive_repo_git_env(entry) +
stdin=DEVNULL, the same pattern as _worktree_is_dirty; when the env
cannot be built, keep the tree. Extend the security test to also drive
the attended reclaim_worktrees remove (worktree_gc._git already uses the
safe env) so both plain-remove paths are pinned.
2026-10-03 20:53:08 +05:30
kshitijk4poor
62114d180b fix(worktree): drop .worktreeinclude symlinks before plain startup remove
The startup pruner now runs `git worktree remove` without --force so a
tree that gained work after classification is refused. But git treats
our own .worktreeinclude directory symlinks (node_modules, .venv) as
untracked content, so every include-symlink-only tree that the
classifier already reaps was refused and kept forever.

Unlink exactly the paths _include_symlink_paths() recognises (the same
classification _worktree_is_dirty uses) right before the remove; any
other untracked file still blocks the removal.
2026-10-03 20:53:08 +05:30
Rudy Celekli
31194ea00e fix(cli): revalidate worktree cleanup gates before removal
Signed-off-by: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com>
(cherry picked from commit 86fad9bd6050a985c9119cf59932ddb5df0fff6a)
2026-10-03 20:53:08 +05:30
John Paul Soliva
f3767103e8 fix(git): delete worktree branches under noninteractive_git_env
The reclaim sweep (_reap_prune_verdicts), the orphaned-branch pass
(_prune_orphaned_branches) and the cleanup after a failed worktree add
(_cleanup_failed_worktree_add) ran `git branch -D` with the inherited
environment. A ref update runs the repository's reference-transaction hook
through core.hooksPath, so the unattended sweep executed whatever the
checkout's own config named. The three calls now use the same hardened env
as the other worktree_ops calls, with stdin closed.

(cherry picked from commit 31eec2f67e47a39c1b715f55d4fa649208076473)
2026-10-02 01:24:41 +05:30
John Paul Soliva
13ea517514 fix(git): run the worktree reclaim ls-remote, unshallow fetch and prune under noninteractive_git_env
The reclaim sweep's ls-remote, the shallow-repo fetch --unshallow and both worktree prune calls ran with the inherited environment, so a repository-level core.sshCommand or credential.helper ran unattended. They now use the same pinned env as the base fetch.

(cherry picked from commit a0d8e2a592790a90f6b666445017ea73f88cbc63)
2026-10-02 01:24:41 +05:30
John Paul Soliva
1ff01f4cf7 fix(git): neutralize repository-named filters in subagent finalization, worktree reclaim and hermes -w
finalize_subagent_worktree's status probe re-hashes files the child touched, so it ran a
repository-named clean filter after every delegated subagent. worktree_ops._worktree_is_dirty, the
dirty probe kanban teardown and the stale-worktree sweep run unattended, called git status with no
hardened env at all: core.fsmonitor ran as well. worktree_ops._worktree_add (hermes -w) had the
fixed pins only, so its checkout ran a named smudge filter.

All three now use noninteractive_repo_git_env. When filter discovery fails, finalization keeps the
worktree as unproven, the dirty probe reports dirty (the reclaimers keep the tree), and hermes -w
refuses to create the worktree. worktree remove --force at prune runs no filter once the status
probe is neutralized.

(cherry picked from commit e727281137a495602457fe4a86b51212af2fdbb7)
2026-10-02 01:24:41 +05:30
kshitijk4poor
a567c3ac0c refactor(worktree): drop the include-symlink check's dead timeout parameter
Its only user was the deleted _main_checkout_root fallback.
2026-10-02 00:54:45 +05:30
kshitijk4poor
c3655fece6 refactor(worktree): require repo_root for the dirty/include-symlink checks
Every caller (cli._cleanup_worktree, _prune_stale_worktrees, kanban
teardown) already passes the main checkout, so the git-discovery fallback
(_main_checkout_root) was dead code that could silently disagree with the
caller's root. Make repo_root a required positional and drop it.

Also normalise .worktreeinclude entries with Path(...).as_posix() so an
entry written with backslashes on Windows still matches git status
output, which always uses "/".
2026-10-02 00:54:45 +05:30
kshitijk4poor
99839aad85 fix(worktree): resolve the main checkout from git, not --git-common-dir's parent
_include_symlink_paths took the main checkout as the parent of
--git-common-dir. For a submodule (common dir .git/modules/<name>) or a
--separate-git-dir repo that is not the checkout, so no .worktreeinclude
symlink matched and every include-only worktree was kept forever as
"dirty" — a regression against BASE, which removed it.

_worktree_is_dirty / _include_symlink_paths now take repo_root, and the
CLI exit cleanup, the startup pruner and kanban teardown pass the one
they already hold. When it is None, fall back to the first
`git worktree list --porcelain` entry resolved through
`rev-parse --show-toplevel` (a submodule lists its git dir there).

Also share the .worktreeinclude parsing between the copy step and the
symlink check (_worktreeinclude_entries), compare with rstrip('/') only,
drop the backslash rewrite, and drop the redundant inner try/except —
_worktree_is_dirty's outer handler already fails safe to dirty.
2026-10-02 00:54:45 +05:30
kshitijk4poor
ebb876bb74 fix(worktree): don't count .worktreeinclude symlinks as uncommitted changes
_copy_worktree_includes symlinks included directories (node_modules,
.venv) into the worktree. A trailing-slash gitignore pattern never
matches a symlink, so `git status --porcelain` lists each one as `??`
and _worktree_is_dirty reported the worktree dirty forever. With exit
cleanup now honouring dirtiness, every session in such a repo kept its
worktree; the startup pruner and kanban teardown had the same bug.

Ignore an untracked entry only when it is a symlink at a path listed in
the main repo's .worktreeinclude that resolves to that same entry in the
main checkout. Any other change, a non-zero git exit, or an error still
counts as dirty (fail-safe). Fixes all three callers at once.
2026-10-02 00:54:45 +05:30
kshitijk4poor
596678d665 refactor(update): tighten the partial-clone heal after review
- _deepen_shallow_repo marks packs in its finally without a git config probe
  that could itself raise and turn a finished unshallow into False; markers
  are inert in a clone without a promisor remote.
- Installers warn instead of aborting the stage when a marker cannot be
  written, matching the Python helper.
- Docs: the manual commands follow HERMES_HOME, and the missing-object
  backfill feeds IDs through `fetch --stdin` so a large list cannot exceed
  the Windows command-line limit.
- Test and docstring comments describe the contract, not the incident.
2026-09-29 15:24:15 +05:30
kshitijk4poor
282ad01cb5 fix(update): mark unmarked packs instead of the inert promisor retry (#124272)
git 2.53+ `index-pack --promisor` hands every object outside the promisor
packs to pack-objects, which BUG()s (should_include_obj) on the missing
objects those objects lead to. A partial clone with unmarked packs therefore
keeps crashing its fetches.

The retry added for this ran `git -c remote.origin.promisor= fetch`. That
override does nothing: git registers promisor remotes additively, so the
repo's own `true` still wins (GIT_TRACE on 2.50 and 2.55 shows
`index-pack --promisor` and `filter tree:0` under the override). The retry
only passed when the crashed fetch had already stored the pack; a retry that
has to transfer again crashed again.

- On the crash, give every pack without a `.promisor` marker one, then retry
  the same fetch once. The clone stays partial, no refetch, no config change.
  If git still crashes, the updater points at the docs section.
- The two fetches that turn a full clone partial now mark the clone's old
  packs afterwards: the depth-1 `tree:0` unshallow in
  `fetch_full_commit_graph`, and `worktree_ops._deepen_shallow_repo`
  (`--filter=blob:none`). git writes the partial-clone config before it
  fetches, so this also runs when the fetch fails. Without it, a converted
  depth-1 install crashed every later fetch on git 2.55 (3 of 3 rounds in a
  local repro).
2026-09-29 15:24:15 +05:30
kshitijk4poor
71b1a6fa97 fix(worktree): hermes -w branches from the remote tip on narrow clones
`_resolve_worktree_base` fetched by name, which on a tag-pinned narrow
clone succeeds without creating origin/<branch>. It then reported
"origin/main (fetched)" for a ref that did not exist. Fetch with the
updater's tracking refspec so the ref it names is the remote tip.
2026-09-28 16:23:22 +05:30
ethernet
d29da5fe20 Merge remote-tracking branch 'origin/main' into ethie/pm-clean
Conflicts resolved toward the branch: PM owns dependency preparation, the
Windows shim re-exec/hand-off path stays retired (main's shim-parent wait,
gateway-resume env token and update_cmd_deps tests dropped), docs describe
the PM update flow. The docker workflow parks install-stamp.json around the
toolchain step instead of deleting it so tests/docker can compare provenance.
2026-09-19 13:45:07 -04:00
teknium1
d6f1de3f74 fix(lsp): release a worktree's language servers on removal; reap deleted roots
`LSPService` kept one client per `(server_id, workspace_root)` for the life
of the process.  In a long-running gateway that outlives its coding sessions
the client for a removed worktree stayed registered with its stdio pipes
held open — tsserver heaps of several GiB pointed at trees that no longer
existed (#102345).  The idle reaper (d7578018c5) does not cover this: a
client whose root vanished is not idle from the server's point of view.

- `LSPService.release_workspace(path)`: detaches every client whose folders
  live under `path` under `_state_lock`, waits for in-flight spawns so a
  concurrent `_get_or_spawn` cannot reinsert a client after release, prunes
  the delta baselines and broken-set entries beneath the path, and shuts the
  clients down on the service loop.  Multi-root servers (pyright) only drop
  the folder (`LSPClient.remove_workspace_folder`) so siblings keep their
  shared process.  Idempotent; best-effort; returns the count.
- The reaper sweep now also uses that primitive for clients whose every
  workspace folder no longer exists (externally deleted roots).
- `agent.lsp.release_workspace()` reaches every started service without
  creating one; `hermes_cli.worktree_ops.release_lsp_clients()` is called
  from both worktree-removal paths (`cli._cleanup_worktree`, kanban
  `_cleanup_worktree_workspace`) BEFORE `git worktree remove`.

Salvages the direction of #102381 (@Sahilvishnaliya, release_workspace +
cli hook) and the deleted-root eligibility of #95047 (@israellot); both
matched on `key[1]`, which is `""` for multi-root servers and would have
reaped pyright on every sweep — the primitive here matches on
`client.workspace_folders` instead.

Co-authored-by: Sahil Vishnalya <222165401+Sahilvishnaliya@users.noreply.github.com>
Co-authored-by: Israel Lot <840042+israellot@users.noreply.github.com>
2026-09-19 01:29:03 -07:00
ethernet
b4a294fff9 Merge origin/main; keep PM as plugin dependency owner
Reconcile plugin declarations and validation through PM's atomic generation publication; preserve external runtimes, target markers, and conflict refusal. Keep one source-update completion owner and port upstream lifecycle changes to the PM desktop/runtime paths.
2026-09-17 13:52:05 -04:00
teknium1
76478fc08d fix: hermes -w repack no longer stampedes a shared clone
Every `hermes -w` launch on a clone past the pack-sprawl threshold started
its own `git repack -a -d` of the whole object store in a daemon thread.
On a multi-agent box that meant dozens of concurrent multi-GB repacks of
the same repo, each too starved (nice 19, under the others) to finish
inside the 1800 s timeout. subprocess.run's timeout killed only `git
repack`, so the `pack-objects` grandchild kept running with ppid 1 for
days; the CLI exiting orphaned it the same way. Observed: 51 pack-objects
processes, load 200 on 20 cores, 143 GB swap, 29 GB of `.tmp-*-pack`
debris, and every `hermes` invocation taking 5-7 s of wall clock for
0.6 s of CPU.

- `_claim_repack_slot`: one repack per clone per 6 h across processes
  (`.git/hermes-repack.lock`, mtime = stamp; stale takeover via `replace`
  so only one of N racers wins).
- `_run_bounded_repack`: own process group + `kill_process_tree` on
  timeout and at exit, so the whole tree dies with the launcher.
- incremental `git repack -d --geometric=2 --write-midx` instead of a
  full `-a` rewrite: consolidates sprawl in seconds instead of rewriting
  10 GB per run.
- `.tmp-<pid>-pack*` (pack-objects debris) joins gitlock's stale tmp-pack
  sweep and is swept before repacking.
2026-09-16 16:43:08 -07:00
teknium1
0a3e792942 fix(worktree): judge no-remote repos against the local trunk instead of reaping everything
`hermes worktree prune` (and the startup/cron pruner) classified every clean tree in a
repository with no remote as "clean and fully merged/pushed" and force-deleted its branch,
even when the branch carried commits that exist nowhere else. `audit_branches` returned []
in the same repos, so a unique local-only branch was invisible to the audit as well.

Root cause: `_worktree_has_unpushed_commits` answered False when `refs/remotes` was empty
("nothing to be unpushed against") and both consumers — `worktree_gc._classify_tree` and
`worktree_ops._classify_prune_candidates` — read False as "safe to reap".

The preceding commit (#111897) flips that branch to True, which is safe but also means a
no-remote repo can never reclaim anything (a tree sitting at trunk, or squash-merged into
it, stays "unpushed" forever because `_worktree_commits_all_merged_upstream` finds no
origin/* base). This commit replaces the unconditional True with a real baseline:

- `_worktree_local_trunk`: `main`/`master`, else the branch checked out in the main
  worktree; None when no trunk exists.
- `_worktree_merge_base_ref`: origin/HEAD|origin/main|origin/master, falling back to the
  local trunk ONLY when the repo has no remote-tracking refs at all. Single resolver used
  by `_worktree_commits_all_merged_upstream` and `worktree_gc.audit_branches`.
- `_worktree_has_unpushed_commits`: with no remote refs, `git log HEAD --not <trunk>`;
  no trunk -> True (preserve), matching the docstring's fail-safe promise.

Net effect in a no-remote repo: unique work is kept ("unpushed commits not found
upstream"), trees at/merged into the local trunk still reap, branch audit reports unique
branches as keep and merged ones as delete, and `git branch -D` can only run on a branch
whose every commit is reachable from or patch-equivalent to the trunk.

Tests: the salvaged no-remote keep test now uses a shared `local_repo` fixture; a control
test proves trunk-merged trees still reclaim and the branch audit reports in the same
repo; `test_merged_predicate_fails_safe_without_upstream` now pins both halves of the
contract (trunk resolves -> merged; no trunk at all -> False/preserve).
2026-09-15 18:27:06 -07:00
KoNit-K
1039c15a03 fix(worktree): preserve commits without remote refs 2026-09-15 18:27:06 -07:00
ethernet
612d542281 Merge remote-tracking branch 'origin/main' into ethie/pm-clean
# Conflicts:
#	.gitignore
#	Dockerfile
#	agent/onboarding.py
#	apps/desktop/electron/main.ts
#	apps/desktop/electron/pool-stop.ts
#	apps/desktop/src/components/model-picker.test.tsx
#	apps/desktop/src/store/updates.ts
#	apps/desktop/vite.config.ts
#	datagen-config-examples/run_browser_tasks.sh
#	docs/rca-ssl-cacert-post-git-pull.md
#	gateway/run.py
#	hermes_cli/backup.py
#	hermes_cli/credential_lifecycle.py
#	hermes_cli/dashboard_procs.py
#	hermes_cli/doctor_state.py
#	hermes_cli/env_loader.py
#	hermes_cli/gateway_windows.py
#	hermes_cli/local_runtime/endpoint.py
#	hermes_cli/psutil_android.py
#	hermes_cli/update_cmd.py
#	hermes_cli/update_cmd_windows.py
#	hermes_cli/web_routers/local_models.py
#	hermes_cli/web_server_config.py
#	hermes_cli/web_server_cron.py
#	plugins/memory/hindsight/__init__.py
#	plugins/memory/holographic/__init__.py
#	plugins/memory/honcho/cli.py
#	plugins/memory/mem0/__init__.py
#	plugins/platforms/google_chat/oauth.py
#	plugins/platforms/photon/adapter.py
#	scripts/ci/list_os_marked_tests.py
#	scripts/run_tests.sh
#	tests/agent/test_compression_stall_fallback.py
#	tests/agent/test_create_openai_client_ssl_verify.py
#	tests/gateway/test_google_chat_oauth_dependencies.py
#	tests/hermes_cli/conftest.py
#	tests/hermes_cli/test_cli_init.py
#	tests/hermes_cli/test_gateway_migrate_multiplex.py
#	tests/hermes_cli/test_psutil_android_extract.py
#	tests/hermes_cli/test_relaunch.py
#	tests/hermes_cli/test_update_check.py
#	tests/hermes_cli/test_update_handoff_desktop_rebuild.py
#	tests/hermes_cli/test_worktree_gc.py
#	tests/scripts/desktop_update/test_desktop_update_windows_python_handoff.py
#	tests/scripts/desktop_update/test_desktop_update_windows_retry_policy.py
#	tests/scripts/desktop_update/test_desktop_update_windows_timestamp.py
#	tests/scripts/install/test_install_autostash_conflict_recovery.py
#	tests/scripts/install/test_install_clone_throttle_fallback.py
#	tests/scripts/install/test_install_commit_pin_rollback.py
#	tests/scripts/install/test_install_diverged_update.py
#	tests/scripts/install/test_install_lockfile_churn.py
#	tests/scripts/install/test_install_macos_launcher.py
#	tests/scripts/install/test_install_no_initial_commit.py
#	tests/scripts/install/test_install_ps1_ascii_only.py
#	tests/scripts/install/test_install_ps1_browser_install.py
#	tests/scripts/install/test_install_ps1_managed_node_swap.py
#	tests/scripts/install/test_install_ps1_native_stderr_eap.py
#	tests/scripts/install/test_install_ps1_node_path_for_npm.py
#	tests/scripts/install/test_install_ps1_python_fallback_venv.py
#	tests/scripts/install/test_install_ps1_resolver_strictmode.py
#	tests/scripts/install/test_install_ps1_uv_install_fallback.py
#	tests/scripts/install/test_install_ps1_uv_powershell_host.py
#	tests/scripts/install/test_install_ps1_venv_process_tree.py
#	tests/scripts/install/test_install_ps1_venv_recreate_safety.py
#	tests/scripts/install/test_install_ps1_venv_rename_abort.py
#	tests/scripts/install/test_install_ps1_venv_transaction_boundary.py
#	tests/scripts/install/test_install_ps1_web_server_syntax_probe.py
#	tests/scripts/install/test_install_scripts_computer_use.py
#	tests/scripts/install/test_install_sh_acp_launcher.py
#	tests/scripts/install/test_install_sh_bootstrap_marker.py
#	tests/scripts/install/test_install_sh_browser_install.py
#	tests/scripts/install/test_install_sh_install_method_stamp.py
#	tests/scripts/install/test_install_sh_node_deps_failure.py
#	tests/scripts/install/test_install_sh_node_deps_workspaces.py
#	tests/scripts/install/test_install_sh_node_global_prefix.py
#	tests/scripts/install/test_install_sh_node_npm_check.py
#	tests/scripts/install/test_install_sh_node_prerelease.py
#	tests/scripts/install/test_install_sh_node_probe.py
#	tests/scripts/install/test_install_sh_node_tarball_without_xz.py
#	tests/scripts/install/test_install_sh_pythonpath_sanitization.py
#	tests/scripts/install/test_install_sh_reuse_supported_python.py
#	tests/scripts/install/test_install_sh_root_fhs_uv_python_path.py
#	tests/scripts/install/test_install_sh_setup_wizard_tty_probe.py
#	tests/scripts/install/test_install_sh_symlink_stomp.py
#	tests/scripts/install/test_install_sh_termux_network_prereqs.py
#	tests/scripts/install/test_install_sh_termux_python_bounds.py
#	tests/scripts/install/test_install_sh_uv_lock_config.py
#	tests/scripts/install/test_install_unmerged_index.py
#	tests/scripts/test_run_tests_parallel.py
#	tests/test_managed_runtime_resolution.py
#	tests/test_project_metadata.py
#	tests/tools/test_browser_use_cli.py
#	tests/tools/test_tts_pythonpath_fallback.py
#	tests/tui_gateway/test_hosted_room_driver_runtime.py
#	tests/tui_gateway/test_tui_gateway_server.py
#	tools/lazy_deps.py
#	tools/voice_mode.py
#	uv.lock
#	website/docs/developer-guide/macos-bundle-updates.md
#	website/docs/developer-guide/pm-audit-status.md
#	website/docs/developer-guide/shared-bundle-builds.md
#	website/docs/developer-guide/source-update-completion.md
#	website/docs/developer-guide/stable-releases.md
2026-09-14 15:38:34 -04:00
teknium1
3ef8b384a9 refactor(persistence): 24 hand-rolled atomic JSON/text writers go through utils.atomic_json_write / atomic_write_text
Each copy re-implemented temp+replace by hand and lacked one or more of
fsync, symlink preservation, atomic_replace's Windows-contention retry and
EXDEV/bind-mount fallback, mode preservation, or interrupt-safe temp
cleanup. Three (gateway/session_persistence, cron/suggestions,
agent/shell_hooks) were verbatim inlines of utils._atomic_write; two
modules defined their own directory-fsync helper, now utils.fsync_directory.
plugins/google_meet/_jsonfile.write_json_atomic is deleted (callers use the
canonical helper directly).

Behavior change: every one of these writers now fsyncs the payload, keeps a
pre-existing target's mode, cleans its temp file on BaseException, and
survives Windows AV/indexer contention and cross-device renames the way
config writes already did. cron/suggestions.json is 0600 from creation
(previously chmod'ed after the replace). Skipped on purpose: cron/jobs.py
two-phase staging, gateway/status._write_json_excl (create-only lock),
kanban_transfer staging (not atomic writers); tools/skill_usage.
_write_suppressed_names lives inside a PLUGIN-COMPAT block.
2026-09-13 05:07:11 -07:00
ethernet
25ce047f98 fix(footguns): utf-8-sig on all reads flagged by check-windows-footguns (164 sites)
The 4,272-commit upstream merge brought 164 new utf-8 read violations
across 96 files. Class-fixed: reads utf-8-sig, writes unchanged.
check-windows-footguns.py --all: 164 -> 0.
2026-09-04 14:46:24 -04:00