READMEs, contributor guides, AGENTS.md files, skills and the website (with
the zh-Hans translations) give pnpm commands for the workspaces; the
website itself is still an npm project.
installs/ is shared by every profile of a data root, but retention was read from the active
profile: a named profile without the key applied the 14-day default to state the root kept
forever (0). Read worktrees.install_state_retention_days from the config of the root that
owns installs/ (scoped via the home override, through load_config_readonly).
Candidates were all decided before any removal; a state launched (lease taken and released)
while an earlier large orphan was being removed was then deleted. Each candidate is now
re-validated (checkout still missing, provably deleted or idle past retention by a fresh
_last_used, no live lease) while holding its install lock, which stays held through removal.
orphan_install_states only reclaimed installs/<key> when the recorded checkout
was provably deleted (under the data root, or directly in an existing
.worktrees/ dir). A checkout anywhere else (~/.cache/review-*/head, a scratch
clone outside the data root) kept its ~0.5 GB / ~27k-file state forever once
deleted: ~235 of ~300 states on one developer host.
The proof rule stays: a provably deleted checkout is reclaimed at once. A
missing checkout that cannot be proved deleted (it may sit behind a mount
boundary: a container sharing the data root, an unmounted volume) is now
reclaimed once its state has also gone unused for
worktrees.install_state_retention_days (default 14, 0 = keep forever).
"Used" is what the runtime moves, measured on a live install: every sync
recreates inputs/ (and rewrites facts.json on a change), every launch takes a
generation lease (moving its .leases dir). Present checkouts, record-less
states and held states (install lock, generation lease) are never reclaimed;
removal keeps the record-last order, and a part-way removal does not restart
the clock.
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.
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).
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.
A snapshot records a submodule only as its 160000 gitlink, so `git worktree
remove --force` after archiving deleted an initialized submodule's uncommitted
edits (and its per-worktree modules/ repo) with nothing in the archive to
restore them. The shared snapshot_worktree entry point and archive_preflight
now refuse any tree whose populated submodule is dirty (tracked or untracked,
recursively), checked out at another commit than recorded, or holds commits/
stashes no remote-tracking ref has; the planner shows it as
keep-submodule-work. Uninitialized or clean-at-recorded-commit submodules
still archive. Refusing in snapshot_worktree covers exit-time Archive and
subagent finalization, which do not go through the planner.
The post-snapshot removal gate used file/HEAD/reflog mtimes, which an
index-only change (git apply --cached) never moves. snapshot_worktree now
digests the semantic staged entries (ls-files --stage) of exactly the index
it captured; archive_then_remove compares them right before removal and keeps
the tree if they differ. A stat-only refresh by git status does not count.
execute_plan dropped archive_then_remove's removed flag, so a tree kept by the
safety gate was reported as "archived + removed"; the exit path and subagent
note said "removed" too. The flag now propagates: `hermes worktree prune`
prints "archived, kept (changed during the sweep)", the exit Archive prints
archived_kept, and the subagent note says the tree was kept (all locales).
Reported by @unsupportedpastels in review of #140603.
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).
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.
Note the Git LFS consequence (pointer files) and the fix (git lfs pull in the worktree), EN and zh-Hans.
(cherry picked from commit 9870e29a42a77865eac79d01d3b99d516e5ebf0f)
Copilot CLI 1.0.79-3 added /worktree new (start a session in a new
worktree). Hermes already has hermes -w launch-time isolation; this adds
the mid-session counterpart: /worktree new [name] creates a tree under
.worktrees/ (remote-tip base, worktree_sync honored), retargets
TERMINAL_CWD + process cwd, and registers the same keep-if-unpushed exit
cleanup. /worktree shows the active tree; /worktree list lists them.
Named trees skip the hermes- prefix so the startup pruner ages them on
the slower named-tree schedule.
Add a developer-guide page for running the Ink TUI and Electron desktop
app from a git worktree without a full npm install per checkout, via the
htui/hgui shell helpers that share node_modules from a canonical deps
checkout by symlink (falling back to a local npm ci when the lockfile
diverges). Registers it in the sidebar, cross-links from the TUI and git
-worktrees pages, and documents the previously-undocumented
HERMES_DESKTOP_PYTHON / HERMES_DESKTOP_DEV_SERVER env vars the desktop
backend reads.
Major reorganization of the documentation site for better discoverability
and navigation. 94 pages across 8 top-level sections (was 5).
Structural changes:
- Promote Features from 3-level-deep subcategory to top-level section
with new Overview hub page categorizing all 26 feature pages
- Promote Messaging Platforms from User Guide subcategory to top-level
section, add platform comparison matrix (13 platforms x 7 features)
- Create new Integrations section with hub page, grouping MCP, ACP,
API Server, Honcho, Provider Routing, Fallback Providers
- Extract AI provider content (626 lines) from configuration.md into
dedicated integrations/providers.md — configuration.md drops from
1803 to 1178 lines
- Subcategorize Developer Guide into Architecture, Extending, Internals
- Rename "User Guide" to "Using Hermes" for top-level items
Orphan fixes (7 pages now reachable via sidebar):
- build-a-hermes-plugin.md added to Guides
- sms.md added to Messaging Platforms
- context-references.md added to Features > Core
- plugins.md added to Features > Core
- git-worktrees.md added to Using Hermes
- checkpoints-and-rollback.md added to Using Hermes
- checkpoints.md (30-line stub) deleted, superseded by
checkpoints-and-rollback.md (203 lines)
New files:
- integrations/index.md — Integrations hub page
- integrations/providers.md — AI provider setup (extracted)
- user-guide/features/overview.md — Features hub page
Broken link fixes:
- quickstart.md, faq.md: update context-length-detection anchors
- configuration.md: update checkpoints link
- overview.md: fix checkpoint link path
Docusaurus build verified clean (zero broken links/anchors).