Files
hermes-agent/tests
helingjun 0e1c0a5a19 fix(constants): a boot reader that resolved its own home must not warn about the sticky profile
With a sticky profile (`hermes profile use <name>`) and HERMES_HOME unset in the shell, every
`hermes` command still printed

  [HERMES_HOME fallback] HERMES_HOME is unset but active profile is 'coder' ...
  which is the DEFAULT profile — not 'coder'. Any data this process writes will land in the
  wrong profile.

even though the CLI re-homes to that profile a few lines later and nothing lands in the wrong
place. 2452b882ad fixed one caller (`hermes_cli/_parser.py::_cfg_path`); the boot scratch setup
carries the same bug: `hermes_bootstrap.export_scratch_tmp_env()` runs at import, resolves the
*process* home correctly, and `get_scratch_dir()` then sent the permission policy back through
`get_hermes_home()` — `apply_secure_dir_policy()` -> `get_managed_system()` reads the `.managed`
marker via the effective home, which before `main._apply_profile_override()` is the default one.

Thread the home the caller already resolved into the policy instead: `get_managed_system(home=None)`
and `apply_secure_dir_policy(path, home=None)` default to the effective home, and
`get_scratch_dir()` passes its own `base`. No caller passes a home it did not resolve, so the
marker is read from the same place it was before. The sibling path
(`hermes_cli/doctor_state.py`, `get_scratch_dir(hermes_home)`) is fixed by the same change.

The genuine warning is untouched: a reader that really runs under the wrong home still reports it
(tests/test_hermes_home_profile_warning.py unchanged for those cases).

Tests: `TestBootReadersBeforeProfileOverride` — the boot scratch export is silent and still points
TMPDIR at the process home's scratch dir; a caller that passes a home never reads the effective
one (both fail on the parent commit).

(cherry picked from commit d5e3e328ea2c933238ac81cc9575809a32b20ae4)
2026-09-22 21:51:01 +05:30
..
…
…
…