Review follow-ups on the #112631 descendant sweep:
- `_posix_descendants` excluded nothing of the caller. `hermes dashboard --stop` /
`hermes update` run from a shell escape inside the hosted Chat TUI are same-session
descendants of the backend, so the sweep SIGTERMed its own process mid-run (probe:
caller in snapshot, backend SIGKILLed, "survived" line never reached) — the POSIX
twin of the Windows #98814 hazard. The caller, its subtree and its ancestor chain are
now pruned from the same `ps` snapshot; an ancestor's *other* children (the wedged
TUI) stay in the sweep.
- Descendants still alive after their SIGKILL grace were silently dropped and the stop
declared complete; they now land in `failed` so `_kill_stale_dashboard_processes`
prints them — a wedged ui-tui still holding the deleted WAL is the incident itself.
- The Desktop boot reaper SIGKILLed descendants of roots whose own kill raised
(EPERM: not ours), orphaning a foreign tree half-way. Descendants now carry their
root and are skipped when the root is in `failed`. First test of that hunk.
- `_is_detached_session_leader` documents that compute_host / slash_worker children
are exempt by the same rule and rely on their own ppid watchdogs.
`hermes dashboard --stop` / `hermes update` signal only the backend PIDs. When the
lifespan teardown wedges (stop_hosted_room_service, PTY close_all never reached) the
10s grace loses, SIGKILL lands mid-teardown, and the hosted ui-tui / tui_gateway.entry
child is reparented to init still holding the state.db-wal inode; the next start
refuses with DeletedWalGenerationError (#112631, residual of #111912). No finite
root grace covers an unbounded teardown.
_kill_pids_posix now snapshots the dashboard-owned descendant tree BEFORE the kill
(the PPID link is gone once the root dies), and after the root phase SIGTERM→SIGKILLs
the descendants that are still alive, waiting for the tree to be gone before
returning. Descendants are re-checked against their snapshotted start-time
fingerprint (the same PID-reuse guard _kill_pids_windows uses) — no `ps -o lstart`
per system PID.
Detached session leaders without a controlling terminal are pruned from the sweep
with their subtrees: those are the messaging-gateway bots and profile actions the
dashboard launched with start_new_session from /api/gateway/*, which belong to the
user, not the dashboard. A hosted TUI is a session leader too (pty.fork) but owns
the pts whose master the dashboard held, so its tty column is set and it is swept.
The Desktop boot reaper (_reap_orphaned_desktop_local_serves) SIGKILLs the same
class of backend after 1.5s and had the same hole; it now SIGKILLs the surviving
snapshotted descendants (no second grace: the boot path runs under a 10s probe).
Live: pyteman hermes-111912 wedged leg on origin/main
`child_orphan_alive=True deleted_sidecar_holders=2 guard=FATAL DeletedWalGenerationError`,
on this head `child_orphan_alive=False deleted_sidecar_holders=0 guard=clean`; the
start_new_session control sibling survives on both.
Two per-call WARNING surfaces were still outside the warn-once reporter:
- agent/plugin_stream_hooks.py::_worker — the on_stream_start/on_stream_delta/
on_stream_end consumer, which fires once per streaming delta (far more often than
per tool call). A mis-declared callback (signature naming tool_data) logged
"Hook ... raised" at WARNING on every delta: 20 deltas -> 20 WARNING lines.
- hermes_cli/plugins_dispatch.py::_deliver_event — plugin event subscribers that
raise identically were warned on every emit.
Both now go through PluginManager._report_hook_failure (keyed by module/qualname,
cleared on unload): the first failure warns and names the fields the hook/event
provides, identical repeats are DEBUG. Skip-and-continue semantics are unchanged.
Part of #111922
The warn-once reporter added for hooks (and for PluginManager.invoke_middleware)
left the execution chain out: hermes_cli/middleware.py::_run_execution_chain — the
tool_execution / llm_execution frames that run once per tool or LLM call — still
logged "Middleware '%s' callback %s raised" at WARNING on every invocation. A
mis-declared callback (e.g. a signature naming tool_data) therefore flooded the
log exactly like the hook case #111922 reported: 5 calls -> 5 WARNING lines.
Route the frame's except through the manager's _report_hook_failure with the
"Middleware" surface label, so the first failure warns (listing the fields the
middleware does provide) and identical repeats go to DEBUG; the set is already
forgotten on plugin reload. The frame's skip-and-continue semantics are unchanged.
Part of #111922
The parent commit deliberately marks a pool row whose refresh token is
terminally rejected (invalid_grant) STATUS_DEAD via _mark_dead_refresh_grant,
so a manual `hermes auth add` login leaves rotation until re-auth instead of
being benched for a TTL and replaying the dead token every hour (#113023).
STATUS_DEAD already was the pool's "permanent OAuth failure" status, and the
new tests/agent/test_credential_pool_terminal_refresh_visibility.py asserts
exactly this for a manual:device_code openai-codex row.
tests/hermes_cli/test_auth_pool_operations.py[401] still encoded the old
contract and went red. Only the 401 leg changes; the 503 leg (transient
failure) keeps asserting 'exhausted', which is the control for the new
terminal/transient split.
Closes the remaining atoms of #112600.
A) The CLI startup path already passes `-m` as target_model (c358a6fba0), but
its siblings still resolved credentials against config's `default`: the CLI
auth-fallback rung, `--resume` credential re-resolution, the gateway
provider-override helper (channel overrides, persisted /model switches,
API-server provider refresh), the gateway fallback chain, the TUI /model
switch-from runtime and ACP agent construction. With a `*-free` default the
OpenCode free-tier rung fired first and a Go-only model was built against
the keyless Zen relay ("Model mimo-v2.5 is not supported"). Each now passes
the effective model; `_resolve_runtime_agent_kwargs_for_provider` grows an
optional `target_model` and the two test stubs of it accept the kwarg.
B) normalize_opencode_base_url rewrote the /zen vs /zen/go segment for ANY
provider matched by opencode_provider_family, including custom providers
merely named after a family (`opencode-go-bridge`, #85589) whose relay the
user declared explicitly in `providers:`. The family heal now applies to the
built-in canonical providers only; custom prefix-named providers keep their
per-model api_mode routing and /v1 handling. Documented in the providers
guide.
C) Same function: the official-host check uses parsed.hostname (a port no
longer defeats the heal) and only the path is edited, so query/fragment
round-trip instead of being dropped.
Fixes#112600
Dropping an identity-equal legacy `custom_providers` entry from the candidate list also dropped the
models only that entry declared: `/model gpt-5.4-mini` (declared by the legacy row but not by
providers.relay) fell through to the current provider (openrouter) instead of routing to the shared
endpoint — a fail-open flip versus the pre-#112788 behaviour, which routed it to custom:relay.
Keep every entry as a candidate and credit a duplicate's hits to the providers row it duplicates, so
the collapse loses no declaration. `_duplicates_configured_row` now returns the owning slug.
Also require credential equality (not just endpoint) in the raw-list `provider_key` shortcut: a
hand-written entry stamped `provider_key: relay` on the same URL but a different key_env is a
distinct route and stays ambiguous, matching the issue's "preserve ambiguity when credential differs"
criterion.
`_configured_provider_matches` now drops a `custom_providers` entry when it is a second view of a
`providers.<slug>` row: either that row's compat projection (provider_key names the slug AND the
endpoint matches) or a legacy duplicate with the same provider identity (normalized name, endpoint,
credential identity, api_mode — read through the same normalizer that builds the compat view).
Any difference in endpoint, credential or wire protocol keeps two rows distinct.
Why: the first pass (#113103) only filtered entries whose provider_key equalled a providers slug.
A hand-migrated config that kept the same endpoint in both sections was still reported as
"declared by multiple configured providers (custom:relay, relay)", and on the raw-list fallback
(gateway/agent_init pass cfg['custom_providers'] verbatim when the compat view fails) a hand-written
provider_key pointing at a different endpoint was silently hidden instead of ambiguous.
`_route_configured_provider` treats `custom:<name>` of a projected row as an alias of its slug when
checking whether the session is already on the matched provider, so a session running on
`custom:relay` that types a model providers.relay declares stays on `custom:relay` instead of
flipping target_provider/explicit_provider to `relay`.
Closes the remaining atoms of #112788. Identity-tuple approach ported from the
`_configured_provider_identity` hunk of #112794.
Co-authored-by: KoNit-K <124019182+KoNit-K@users.noreply.github.com>
The dispatcher forced `-Q` on goal_mode cards because cli.py only ran the
kanban judge loop in the fully-quiet one-shot branch. `-Q` strips every tool
callback, so the dashboard's Worker log (and `hermes kanban log`) stayed
blank for the whole run while non-goal cards logged normally; users read
that as "the worker is doing nothing" (Discord report, Sep 2026).
Run the judge loop on the `-q` path too, driving follow-up turns through
cli.chat so each turn's tool activity lands on stdout (= the worker log),
and print each judge verdict there as well. The dispatcher spawns goal_mode
and one-shot workers with the identical argv; the mode travels only in
HERMES_KANBAN_GOAL_MODE. The `-Q` hook stays for manual quiet runs.
Live A/B (real `hermes kanban dispatch` + spawned worker against a scripted
loopback provider that answers a terminal tool call then text, judge always
"continue", --goal-max-turns 2): base log = 94 bytes, 0 tool-feed lines,
0 verdict lines; fix log = 1910 bytes, 4 tool-feed lines, 3 verdict lines;
both arms end blocked "exhausted 2/2 turns" (loop behaviour unchanged).
A metadata-only model_overrides entry on a custom provider (only context_window set) took the
unknown-model branch of get_model_capabilities and reported max_output_tokens=8192 from the
_UNKNOWN_MODEL_BASE template; /model info showed "Max output: 8,192 tokens" for a model nobody
knows. The output limit is now left unknown (ModelCapabilities.max_output_tokens=None,
ModelInfo.max_output=0), matching the fail-open treatment #113146 gave supports_vision and
supports_reasoning. Consumers already handle a missing value: the dashboard only renders a
positive limit and the /model card only prints a truthy max_output.
There was also no way for a custom provider that resells a catalogued vendor's models (a
gateway/proxy) to reach _BUILTIN_MODEL_METADATA or the models.dev catalog, which is what forced
the metadata-only override in the first place. providers.<name>.catalog_provider (also honoured
on legacy custom_providers[] rows) names that vendor; models_dev resolves the catalog id through
it for capabilities, context, model info and provider info. It affects metadata lookups only,
never routing or credentials, and an explicit model_overrides entry still wins.
Closes the remaining atoms of #112649 (docs: providers page).
The handoff exemption treated ANY `assigned` event after the PR comment as a
handoff. A no-op same-profile assign (`hermes kanban assign <id> dev`,
dashboard PATCH /tasks/{id}, `reassign --reclaim`), an unassign
(`assignee: null`), and the dispatcher's own `kanban.default_assignee`
fill-in all record an `assigned` event without changing the owner — and each
lifted `active_pr` for the very implementer that opened the PR, re-spawning
it against its own PR. That is the duplicate-work protection #111910 says
must be preserved.
`assign_task` now records `from` in the payload and the guard counts an
`assigned` event as a handoff only when it moves the card to a different,
non-null profile and was not written by the default-assignee pass. Events
without `from` (pre-existing rows) are not trusted — fail closed.
Docs sentence qualified accordingly.
A ready card whose recent comment links a GitHub PR is held by the
``active_pr`` respawn guard for every assignee. That stopped exactly the
spawns the PR evidence calls for: an operator reassigning the card to a
closer/recovery profile, and a reviewer's changes-requested verdict
routing it back to the implementer to fix that PR — the card sat in
``ready`` as ``respawn_guarded=active_pr`` with zero workers (#111910).
``check_respawn_guard`` now lifts ``active_pr`` when a handoff event
(``assigned``, ``changes_requested``, ``review_reopened``) was recorded
strictly after the newest PR comment: the handoff names the profile that
must work on that PR, so it is not a duplicate implementation. Duplicate
protection is kept: no handoff (a crash/reclaim is not one) leaves the
opener guarded, a newer PR comment after the handoff guards again,
same-second ties stay guarded, and ``recent_success`` is untouched. The
review-lane exemption from a235d1917e stands unchanged.
Docs: the kanban respawn-guard section names both supported routes
(``request-review`` and ``assign``).
The transient case that was RED on main: an intact config.yaml holding
real schema sections pinned to their scalar defaults, with the cached
read_raw_config() patched to return {}, must still have every one of those
sections after save_config(load_config()). Pins that the explicit-path
evidence comes from the fail-closed read, not the cached one (#113301).
Sections are chosen only where the first default value is a scalar, and
the floor on how many exist is modest (>= 10) so an unrelated
DEFAULT_CONFIG reorder or reshaping cannot fail this test.
A key the user set explicitly to its schema default (skills.write_approval:
true) must survive save_config(load_config()) on an intact file: the raw
read supplies the preserve set for the strip pass, so this is #113301's
32 -> 32 row. Test from #113323, kept verbatim.
_print_unknown_key_notice always appended "Custom top-level keys are supported and bridged to
the environment". Before the unseeded-key change no nested path reached this notice; now
`stt.provider` or `agent.max_turnz` did and were told they are env-bridged, which they are not.
Nested paths get only the --force hint.
In _validate_config_key the fuzzy same-level sibling (cutoff 0.6) was tried before the
structural "path minus its wrong prefix is a known key" check. While every unknown sub-key was
refused that order did not matter; now that only the wrong-prefix case is refused, a path whose
stray middle segment fuzzy-matched a sibling was WRITTEN with a misleading did-you-mean:
`agent.gateway.strict` -> (False, 'agent.gateway_timeout') instead of being refused as
`gateway.strict`. A structural match is proof, a fuzzy match is a guess; check it first.
Drop the display.tool_progress row (it pinned a did-you-mean the comment itself called misleading; seeding the key would fail it for an unrelated reason) and the skills.creation_nudge_interval row (same invariant as stt.provider, the key named in the issue).
The display.tool_progress row passed suggestion=None, but
_validate_config_key("display.tool_progress") returns
(False, "display.tool_progress_command") because only the _command sibling
is seeded in DEFAULT_CONFIG. The `if suggestion:` guard let the row pass
without ever checking the notice, so the misleading "Did you mean" this
real runtime key (cli.py:2568) receives was neither asserted nor visible.
Pin the actual suggestion for that row and assert the notice text exactly
for every row: present with the expected sibling, or absent. Fix the
comment too — only stt.provider comes from da942e4483's list; the rows are
unseeded runtime-read keys at agent/agent_init.py:1324, cli.py:2568 and
tools/transcription_tools.py:241.
Seeding display.tool_progress in config_defaults.py (hermes_cli/AGENTS.md:
"every reader a registry entry") is the proper follow-up that removes the
misleading suggestion; it is out of scope for this salvage.
Fold the trade-off into the salvaged parametrized test instead of adding a
new test function: `agent.max_turnz` (suggestion `agent.max_turns`) is now
written with the post-write notice rather than refused, because the schema
walk cannot tell a same-section typo from a deliberately unseeded
runtime-read key such as `stt.provider`. Assert the notice and the
suggestion so reviewers see the behaviour change; refresh the class
docstring that still described the pre-#114107 refusal rule.
The self-lock/holder preflight (#99711) deferred the repair on the theory
that the updater's own mapped python.exe makes the venv rename impossible.
Live on windows-latest, a process executing from venv\Scripts\python.exe
(and the repo's real .venv with cp311 .pyd extensions loaded) does NOT block
the rename; what blocks it with WinError 5 is any ordinary handle under the
tree: a process cwd, an open file, a sync client. Since sys.executable is
always under the venv on Windows, the deferral fired on every run and no
Windows install could repair from `hermes update`. Retire it and its tests;
the pyvenv.cfg repoint needs no rename and has none of that exposure. The
wine2e lane now runs the cutover probes instead.
The repoint keeps the live venv's site-packages, so provisioning's
fall-forward to the next minor (3.11 -> 3.12, #76106) must not be pointed at
a cp311 tree: refuse before touching pyvenv.cfg. The live Windows test holds
the venv the way the field does (a child with cwd inside it), asserts the
rename path fails (the symptom) and the repoint succeeds; the rollback and
minor-guard tests run on every host.
Cherry-pick of helix4u's #88836 (75742db5a42) resolved onto current main.
The POSIX runtime cutover parks the live venv with a directory rename. On
Windows that can never succeed from `hermes update`: the updater executes
from venv\Scripts\python.exe and Windows keeps that image mapped, so the
rename fails with WinError 5 on every attempt (#93032). Instead, atomically
replace the live venv's pyvenv.cfg with the candidate's: Scripts\python.exe
is a launcher that reads `home` on every start, so every fresh process runs
the new generation while nothing touches the locked directory. A failed
post-cutover smoke restores the original config; a failed rollback keeps
the generation the live config now references.
Rework of the salvaged #59942 hook so it fixes the whole #52339 class without
regressing what the Desktop updater already gets right:
- macOS only. The Windows arm rmtree'd a possibly-running NSIS install
(partial deletion under a lock) and windows.ps1 already owns that swap;
Linux packages stay with their package manager.
- No re-sign. The rebuilt release/ bundle already carries the stable local
signing identity from _desktop_macos_relaunchable_fixup; a deep `codesign -s -`
on the installed copy replaced it with a fresh ad-hoc cdhash and reset every
TCC grant. ditto preserves the signature, so nothing is signed here.
- Running bundles are reported, not swapped: Electron loads app.asar and helper
apps lazily, so renaming the bundle away and deleting the old tree crashes
the live app. The detached updater waits for exit; a terminal `hermes update`
with the app open now prints what to do instead.
- Failures are printed as warnings; the old `Path | None` return read every
failure as "Desktop app up to date".
- The refresh also runs on the "build stamp current" path, so a stale
/Applications copy left by an earlier update heals on the next `hermes update`
even when there is nothing to rebuild.
- Core is host-independent (_install_rebuilt_macos_bundles takes paths as data);
the two invariant tests run on every OS instead of `skipif(darwin)` tests that
ran nowhere.
Covers the Desktop-button path too: posix.sh runs `hermes update`, so an app
running from apps/desktop/release/ now refreshes the /Applications copy Finder
launches (the Discord report: new shell right after the update, old shell on
the next Dock launch).
Port of #59942 onto post-#102117 main. The refactor moved the desktop
helpers from hermes_cli/main.py into hermes_cli/main_desktop.py, so the
new install machinery (_app_asar_hash, _macos_adhoc_sign_bundle,
_desktop_bundle_install_supported, _swap_in_new_macos_bundle,
_install_rebuilt_desktop_app) lives there now, re-exported through
main.py's frozen updater surface block so _m() resolves them.
_rebuild_desktop_after_update (hermes_cli/update_cmd_deps.py) now, on a
successful --build-only build, installs the rebuilt bundle to the
system location (macOS .app via ditto staged copy + atomic swap with
rollback; Windows via copytree), skipping when the installed app.asar
hash already matches. Linux stays owned by its package mechanism.
Without this, a CLI hermes update leaves the installed app stale —
the in-app updater covers its own path, but the CLI path never swapped
the installed bundle.
Tests: 17/17 ported suite (import/patch targets repointed to
main_desktop) + test_cmd_update.py 47/47 green.
A plugin.yaml with no __init__.py, desktop/plugin.js or plugin.json beside it
installs "successfully" and does nothing (pip-layout repos whose code sits under
src/ behind an entry point). The validator and catalog CI now fail that shape
and check declared Python dependencies parse and are index specs; direct-URL
requirements warn.
Tests: conflicting candidate refused with peers untouched; post-update re-apply
drops only the culprit and keeps the memory provider. Loader wording test
updated to the new hint.
Plugin dependency installs need two things the shared installer ladder did not
expose: a constraints file (so a plugin can never move a core pin) and a dry run
(so a conflict can be detected before anything is written). Both are threaded
through _venv_pip_install; the durable-target path keeps its own core
constraints and a dry run skips syspath activation and bytecode warming.
Independent review of the post-swap hand-off found state that did not cross or was
handled by the wrong side:
- update_cmd_config._LAST_SIBLING_SNAPSHOTS is rebound by the pre-update backup in the
parent; the child read an empty dict and the sibling-profile cron/model-settings safety
nets silently did nothing. It now rides in the payload.
- The ZIP path handed off without the Windows pause token, and the parent's finally/atexit
resumed the paused gateways while the child was reinstalling the venv. The token now
crosses on both paths; the parent flips resume_needed off only after a child actually ran.
- The child inherits HERMES_HOME but re-read the sticky active_profile, finishing a
`-p default` update inside another profile's home. _apply_profile_override keeps the
parent's resolved home for the post-swap child.
- The child env now also sets HERMES_UPDATE_REEXEC so cmd_update's Windows hard-exit tail
covers it and the shim re-exec can never fire a second time from inside it; the
hand-off pid is only claimed when no upstream updater (Tauri/Electron) already named
one.
- Popen + wait instead of subprocess.run: Ctrl-C no longer kills the child (which owns the
receipt and the gateway resume) 250 ms after the interrupt.
- A child that cannot start: the parent takes the receipt back, records the failed step,
writes .update-incomplete and the gateway exit code, exits 1.
- The child consumes the hand-off file and builds git_cmd without re-running the checkout
preflight (no second fork banner).
`hermes` printed "A previous `hermes update` pulled new code but did not restart
running gateways" on every launch after an update whose receipt was `failed` for a
post-restart crash: `fleet` was empty (the matrix never ran), so the check fell back to
the pre-pull `plan.runtimes[].code_sha` against today's checkout and the live gateway,
correctly restarted onto the pulled commit, still read as "not restarted" once a manual
`git pull` had moved the checkout again. Reproduced on the maintainer's box against the
#112604 receipt: gateway on the update's `post_update.sha`, checkout two pulls ahead.
The startup hint now holds a receipt whose restart phase completed (`gateway_restart`
present, `incomplete` false, no `phase_error`) to the code it actually pulled: every owed
gateway serving `post_update.sha` discharges the update. Later drift is
`gateway/code_skew.py`'s job, not a warning that misreports the update. The catch-up
predicate `hermes update` itself runs keeps its checkout semantics (the fleet must reach
HEAD), so the same box still gets its gateway restarted on the next update.
`_live_fleet_covers_receipt` compares stamped `code_sha` against the expected sha for
`current` AND `stale` rows (both labels are relative to the checkout, not to what the
update owed); `unknown`/`down` rows still never cover.
`hermes update` started in an interpreter that had imported the PRE-pull tree, then
kept running every post-swap phase (dependency sync, Node/web/Desktop builds,
maintenance, config migration, fleet restart, verification, receipt) in that same
process, lazily importing NEW source into an OLD `sys.modules` graph. Any rename
between the two commits surfaced as an ImportError/AttributeError inside the updater
after the code swap had already succeeded (#87134, #111271, #112465, #112558, #112604).
Each incident added another purge, reload list or per-step isolation, and each moved
the crash to the next module nobody had listed.
The pre-pull process now stops at the swap: it writes the open receipt, the pre-update
fleet plan, the pre-update version/active features and the Windows pause token to a
hand-off file and re-executes `hermes update <same flags> --post-swap <file>` under the
venv interpreter. The child imports exclusively from the pulled tree, resumes the
receipt and owns the rest of the run; the parent relays its exit code. Git and ZIP paths
both hand off. On Windows, when the updater runs from `hermes.exe`, the child is spawned
detached exactly as the shim hand-off already did (the shim cannot be awaited while the
sync must replace it).
With no pulled code ever executing in a pre-pull interpreter, the stale-module layer is
dead and removed: `_purge_stale_hermes_modules`, `_stale_purge_prefixes`,
`_evict_module`, `_STALE_PURGE_*`, `_reload_updated_runtime_modules`,
`_reload_process_scan_modules`, `_reload_config_modules`, `_UPDATE_RUNTIME_RELOAD_MODULES`
and their tests. `_run_config_check_fresh` / `_run_migrate_config_fresh` keep their names
and simply call the config API.
Tests: the hand-off boundary (child argv/env, detached receipt + plan in the payload,
exit-code relay) and the child side (receipt resumed with its history, plan rebuilt,
pre-update snapshots taken from the payload). Mocked updater flows run the tail
in-process through the same payload round-trip (autouse fixture; opt out with
`@pytest.mark.real_post_swap_handoff`).
The Desktop pool caps local `hermes serve` children and holds each child's
slot lease for its lifetime. Its renderer refreshes lastActiveAt every 60s
for every open socket, so a bot-tile-pinned resident is keepalive-fresh
forever: occupied is not busy, and the pool cannot tell the difference. The
renderer's own turn bookkeeping cannot see cron fires (HERMES_DESKTOP=1 runs
the in-process ticker), messaging turns served by a pooled backend, or a
session blocked on an approval, so it is not a safe proof either.
Add `GET /api/health/idle` (token-gated; whether a turn is running is
activity recon, unlike the public liveness route) returning
`idle: true|false|null` from `hermes_cli/web_server_idle_proof.py`. It
reuses the SSH idle-exit primitive `turn_in_flight()` (running gateway
sessions + running cron jobs) and adds the human-input ledgers: open
server->client requests (`server_requests.open_request_count`) and queued
gateway approvals (`approval.pending_gateway_approval_count`). Any ledger
that cannot be read yields `null`, which the Desktop treats as busy.
Tests: unit invariants over the fail-closed table and the real ledgers, and
a live test that boots three desktop-shaped children (HERMES_DESKTOP=1,
per-child HERMES_HOME, port 0), holds one busy in the cron running-job
ledger, and probes all three over HTTP. RED on base: every child 404s.
Remove metadata-only source caching so mapped edits and transient read
failures cannot leave stale rebuild decisions. Keep directory pruning,
lazy npm lookup, renderer manifests and the COM scheduler query.
Separate stdout and stderr logging, decode bounded logical lines before
redaction, and route desktop records to the GUI log. Add real-child,
mapped-write and temporary-read-lock regressions.
Verified by independent review, targeted Windows/Linux suites, renderer
tests and packaged Windows manual checks. Existing Windows logging
failures reproduce on the parent; no end-to-end startup percentage is
claimed for this corrected version.
`hermes -z` judged the run by whether stdout was non-empty: a turn that hit the
iteration budget, ended `partial`, failed on the provider, or was interrupted
still exited 0 as long as it printed an explanation, so scripts treated a
half-done job (or a 401 summary) as success. The `-q`/`-Q` paths already got
one result-derived contract in 23863ccbafe0d; this is the same class on the
scripted one-shot entry point (#111770).
- `hermes_cli/oneshot.py::_oneshot_exit_code`: 0 only when the turn completed;
130 interrupted; 2 failed / partial / completed:false; 1 a completed turn
with no text (unchanged message).
- `--usage-file` now also reports `partial`, `interrupted` and
`turn_exit_reason`, so a pipeline can tell a budget stop from a Ctrl-C.
- Docs: `hermes -z` exit-code table + usage-file fields in cli-commands.md.
Live probe (run_oneshot with a stubbed _run_agent): partial-with-text 0 -> 2,
budget-with-text 0 -> 2, interrupted-with-text 0 -> 130, failed-with-text 0 -> 2;
completed 0 -> 0 (control), partial-no-text 2 -> 2 (unchanged).
The port prompt deliberately skips saving the default, but skipping the
save never removed a previously stored TERMINAL_SSH_PORT, so answering
"22" silently left the stale port in .env while the wizard's own
connection test used the entered value. Remove the env value when the
user enters the default so the runtime default applies.
Users who set a sticky profile with `hermes profile use <name>` saw
`[HERMES_HOME fallback] HERMES_HOME is unset but active profile is '<name>'
... Any data this process writes will land in the wrong profile` printed by
EVERY `hermes` invocation (`--version`, `update`, `gateway restart`), even
though the CLI re-homes to that profile a few lines later and nothing lands
in the wrong place.
`main._apply_profile_override` scans argv with `top_level_value_flag_sets()`,
which builds the real parser BEFORE the override sets HERMES_HOME. Since
23036e20a6 the `--no-config` help string spells the config path through
`display_hermes_home()` -> `get_hermes_home()`, and that lookup fires the
one-shot fallback warning for a throwaway help string.
`display_hermes_home()` takes an optional `home`; the parser's `_cfg_path()`
passes `get_process_hermes_home()`, which reads HERMES_HOME without the
warning and, after the override, IS the profile home — so `hermes -p coder
--help` still shows `~/.hermes/profiles/coder/config.yaml`. The genuine
warning (a process that really runs under the wrong home) is untouched.
Fixes#112319
Part of #112839
Reviewers asked why /new still rotates agent.session_id mid-turn while
/branch, /resume and /sessions <id> now refuse. new_session flushes the
in-flight turn to the old session before rotating (#47202), so the
refusal rationale does not apply; record that in the invariant suite's
docstring so the exemption reads as a choice, not an omission.
Replace the two salvaged per-command test files with a single suite that drives
the real /branch, /resume and /sessions <id> handlers against a real SessionDB
and asserts the invariant that matters: while a turn is running, the session id
(CLI and agent) is unchanged and the current row is not ended; when idle,
/branch still proceeds. Red on origin/main (3 busy cases), green with the guards.
The /branch MagicMock fixture gains an explicit `_agent_running = False`: a bare
MagicMock attribute is truthy and would trip the new guard.
Docs: /branch and /resume rows in the slash-command reference say they are
refused mid-turn in the classic CLI and why.
Co-authored-by: sonderhq <144971773+sonderhq@users.noreply.github.com>
Co-authored-by: MohamadKanso <91088196+MohamadKanso@users.noreply.github.com>
/branch ends the parent session row and repoints agent.session_id via
_sync_agent_to_session while the turn is still running, so the turn's
remaining messages land on the freshly created branch. /handoff already
refuses this race mid-turn via _handoff_prepare_session; give /branch the
same guard. Regression: tests/hermes_cli/test_branch_mid_turn_guard.py
(failing-first on the pre-fix tree).
The healthy-branch restore after a runtime (SQLite) repair called
_refresh_active_lazy_features as a bare statement and dropped its bool, so a
failed restore into the freshly swapped venv still ended in '✓ Already up to
date!' and a rerun could not recover (the next snapshot sees the stripped venv).
Mirror the pull path (update_cmd_deps): write the lazy-refresh-incomplete marker
before the restore, clear it only when the refresh reports success, otherwise
print the same 'recovery incomplete' hint so the next `hermes` run finishes it.
Test: one invariant case (refresh returns False -> marker written, not cleared);
red on the previous head, green here. The marker helpers are stubbed so the test
never writes into the real home.
The salvaged fix added a third `elif runtime_repaired` arm that duplicated the
whole `_repair_node_deps_on_current_checkout(...)` call from the healthy `else`.
Guard only the restore step inside that branch instead, so there is one
node-deps call and the healthy path stays byte-identical when no repair ran.
`ensure_uv()` already returns the managed uv (or its bootstrap), so the
`updated_uv or ensured_uv` fallback is unnecessary; use the ensured path like
`_repair_venv_on_current_checkout` does.
Tests: the contributor's test was inserted above the class docstring of
`TestCmdUpdateBranchFallback`, orphaning that docstring. Move it into its own
class with a shared fixture and add the control case (healthy venv, no repair
-> no restore calls). A/B: with origin/main's update_cmd.py the restore test
fails and the control passes; on this head both pass.
Path.glob raises NotImplementedError for a non-relative pattern, which a string `workspaces` (iterated char by char, so "/") or an absolute entry produces. The (OSError, ValueError, TypeError) catch missed it, so the error escaped to the caller's suppress(Exception) and no lock was reverted at all -- back to autostash every run. Non-list values are now ignored and each pattern is tried on its own so a bad one just owns nothing.
install.sh: read the workspace globs with `while read` instead of an unquoted $(...) so they are never pathname-expanded against the caller's CWD before `case` sees the pattern.
Keep the two discriminating cases from #112396: a dirty workspace manifest preserves the
root lockfile, and a manifest outside the workspace graph does not. The non-workspace case
in the original PR created an untracked file that `git diff --name-only` never lists, so it
passed on unfixed main; the fixture now commits vendor/foo/package.json first. The git
helper pins an author identity so the test runs on CI runners without git config.
Restore the WHY in `_discard_lockfile_churn`'s docstring (the autostash-every-run motive)
and document that `_npm_lockfile_owners` mirrors `update_cmd_deps._npm_manifest_paths`.
Co-authored-by: KoNit-K <124019182+KoNit-K@users.noreply.github.com>
A workspace manifest can change the dependency graph represented by the root lockfile. Discover the root package workspaces and preserve the root lock when a covered manifest is dirty, while retaining same-directory nested ownership and discarding unrelated churn. Fixes#112378.
`_validate_config_key` is a DEFAULT_CONFIG walk, and several live keys are
deliberately unseeded so that a stored value counts as an explicit user pick
(browser.cloud_provider, stt.provider, cron.misfire_grace_minutes,
gateway.proxy_url / relay_url, dashboard.ssh_isolated_idle_grace_s,
computer_use.backend). The runtime reads all of them and Hermes' own wizards
write some of them, so `hermes config get browser.cloud_provider` asserting
"Hermes does not read it" was a false claim.
Match the set-path notice ("Hermes may not read it"): the key still gets
flagged so a leftover misspelling cannot pass unnoticed, but the CLI no longer
states something it cannot know. Docs updated to the same wording; one test
pins the hedge on an unseeded live key (red before this commit).