fix(update): ignore flat-install runtime state so autostash cannot sweep state.db

On a flat install (checkout root == $HERMES_HOME) the untracked autostash of
`hermes update` sweeps the live state.db/-wal, snapshots, cron ledger and
lock/pid files into the stash and unlinks them under the running gateway; the
restart recreates an empty store at the same path and the declined restore
leaves the profile with no transcripts (#110648).

Root-anchor the runtime state set in .gitignore, mirroring the
.hermes-bootstrap-complete (#38529) and /.install_method (#66189) precedent
and the $HERMES_HOME-root enumeration in the platforms base module, so the
stash step is never entered for runtime state alone. Regression test runs the
exact stash command against a real repo carrying the tracked .gitignore.

(cherry picked from commit 6c74c24e6131af189801e54f1e11b260a529b74a)
This commit is contained in:
liuhao1024
2026-09-14 15:30:47 +08:00
committed by kshitij
parent db64ddb58e
commit 8f34499851
2 changed files with 131 additions and 0 deletions

27
.gitignore vendored
View File

@@ -168,6 +168,33 @@ docs/superpowers/*
# treat it as a local edit and autostash it on every run (#38529).
.hermes-bootstrap-complete
# Flat-install runtime state (checkout root == $HERMES_HOME, e.g. installs made
# with HERMES_INSTALL_DIR=$HERMES_HOME or by older installers): the live session
# store, its SQLite sidecars and retired-WAL capture dirs, quick snapshots, the
# legacy transcripts, the cron executions ledger, gateway lock/pid files, and
# cache/spill directories are Hermes-managed runtime state, never code changes.
# Ignore them so `hermes update`'s `git stash push --include-untracked` cannot
# sweep the live state.db/-wal into the stash and unlink it under the running
# gateway (#110648). Nested installs keep all of this under $HERMES_HOME outside
# the checkout, where the `.hermes/` rule above already applies.
/state.db
/state.db-wal
/state.db-shm
/state.db-journal
/state.db.retired-wal-*/
/kanban.db
/kanban.db-wal
/kanban.db-shm
/kanban.db-journal
/state-snapshots/
/sessions/
/browser-profile/
/cron/executions.db
/gateway.lock
/gateway.pid
/hook_outputs/
/cache/
# Persistent dev sandbox dir (scripts/dev-sandbox.sh --persistent)
.hermes-sandbox/
# Sandbox dirs used by the install/update E2E (tests/install/). The suffix is