Commit Graph

628 Commits

Author SHA1 Message Date
kshitijk4poor
d1cb5d5cbd ci(process): no new detached spawn outside spawn_owned without a reason
A child started in its own session or group (start_new_session, os.setsid /
setpgid / setpgrp, windows_detach_popen_kwargs) does not die with a SIGKILLed
Hermes: it reparents to init and runs forever. That is how every family this PR
migrates leaked. With the families on spawn_owned, this keeps the class closed.

scripts/check_detached_spawns.py (AST) flags those shapes in the production trees
unless the line, or the line above it, says `detached-spawn: ok — <why>`. It runs
in scripts/check ("detached-spawns") and as a blocking lint.yml step. The baseline
is empty: every remaining site is on spawn_owned / own_process_groups, or carries
its reason. The reasons this commit adds are the census verdicts:
- must outlive the starter on purpose: restart watchers, /update and the updater
  hand-offs, dashboard/desktop/service launches, cron and kanban workers
  (restart-safe), the update-custody watchdog itself;
- awaited with a group kill on timeout: cron scripts, rg search, the Browser Use
  CLI, update completion (holds the checkout lock fd);
- covered by its own parent guard: the compute host (compute_host._parent_guard_loop
  flushes sessions; a supervisor KILL could cut that short);
- not a spawn: the wake-word `start_new_session` config key and event field.

tests/scripts/test_check_detached_spawns.py: each shape flagged, non-detached and
commented/string shapes not, the marker opts out on its line or the line above
and nowhere else, tests and the helper are out of scope, main() fails on a new
unmarked spawn, and the repository scan is empty. Teeth: appending an unmarked
start_new_session Popen to tools/file_operations_search.py turns
`scripts/check --only detached-spawns` red (rc 1); restoring it turns it green.
2026-10-29 16:58:09 +05:30
Teknium
4bc973abd3 fix(tests): share the account tool store only when pm install would not rewrite it
Review follow-up on #145364 (kshitijk4poor):

- tool_store_pins.py now asks pm's own rule, _installed_location (new
  heal=False keyword keeps it read-only), and also requires each entry's
  recorded env to equal what this checkout's package code records. A store
  at the right pins but with a stale env made `pm install`'s
  _refresh_found_env re-record the shared facts.json.
- run_tests.sh: the concurrency comment now says the unlocked check keeps
  runs that START on different pins apart and names the window before
  pm install's lock; UV_PYTHON_INSTALL_DIR is reused only when the pinned
  minor is already cached; dscl parsed with sed, same-home test with -ef;
  PATH caveat and a never-forward note at the env -i allowlist.
- The test separates the checks: setup-hermes' uv copy broken while pm's
  uv entry is fine, a non-executable ripgrep, and a stale node env, each
  asserting the store is left byte-for-byte and mode-for-mode unchanged.
2026-10-27 17:11:28 -07:00
Teknium
1eeef54ca3 fix(tests): share the account tool store only when its binaries are runnable
_store_has_pins checked facts.installed(), which only proves the recorded
entry directory exists. A store with matching facts but a missing or
non-executable uv passed, so the runner shared it and setup-hermes.sh fell
into its uv re-stage, whose unlocked rm -rf + publish races other runs on
the shared store.

Eligibility now also requires every walked package's binary to be a file
with the exec bit (no healing: read-only), plus setup-hermes.sh's exact
$store/uv-$uv_version-$os-$arch/uv path. The check moves from a heredoc to
scripts/tool_store_pins.py so the regression test runs the real logic.
2026-10-27 17:11:28 -07:00
Teknium
1733a4a653 fix(desktop-update): flush the hand-off log on every exit, encode it only when it opens
Three follow-ups to the queued hand-off log (review on #145712):

- Sync-HandoffLog encoded the whole pending queue before it knew the file
  would open, so a log held through a long step re-encoded a growing queue
  on every poll. It opens the file first and encodes only once it can write.
- -SelfTestLogConcurrency skipped the -InstallRoot requirement but still
  claimed the update marker, and its early exit never released it, leaving
  update state in HERMES_HOME. It no longer claims the marker; its test now
  requires HERMES_HOME to hold no update state afterwards.
- The bounded exit-time flush ran only in the main update's finally. The
  marker helper ops (reclaim/withdraw/custody) and the early marker.ps1
  load failure exited with their lines still queued. Each now flushes after
  its marker lock is released; reclaim/withdraw keep the flush short
  because Electron bounds the whole helper and already has its verdict.
2026-10-27 15:58:38 -07:00
Teknium
3d304a2816 fix(desktop-update): a hand-off log line that meets another holder waits instead of vanishing
The named mutex serializes Hermes's own writers, but any other process holding
the log at the moment of an append (a scanner on the just-closed file, a reader
opened without write sharing) still failed it, and the empty catch dropped the
line for good. The stage relay marks a stage seen before it logs it, so a stage
that lost that race was never written: main's Windows-only job lost "process
cwd set", "running: python ...", the relayed stage and the tail of the
update's output in one run (test_handoff_shows_the_stage_the_update_publishes,
x64), while the same commit passed on arm64.

A line that cannot be appended now waits in a queue and lands, in order, with
the next append that succeeds; the step loop retries every pass and the run
retries for up to 10 s before it exits. Appends use AppendData with
ReadWrite|Delete sharing, so a reader never blocks them and they land at
end-of-file atomically even beside a writer whose mutex wait timed out.
2026-10-27 15:58:38 -07:00
liuhao1024
0b62510eb3 fix(desktop-update): serialize hand-off log appends across concurrent writers
Write-HandoffLog appended with Add-Content, which is unsafe once a second
writer is live: PowerShell caches a content writer per path, so the second
writer receives a handle the first already consumed. On Windows PowerShell
5.1 that surfaces as a "stream is not readable" error flood; on PowerShell
7 it silently loses lines (58% measured on the issue's 8-writer shape,
#126152). The hand-off log is the only record of why a Desktop update
failed, and overlapping hand-off processes are a real event: the marker
claim is a plain write with no mutual exclusion and its failure path logs
a warning and continues.

Serialize the append behind a named, per-log-path mutex plus one FileStream
per write. The mutex instance is created lazily so any runspace or process
writer joins the same OS object; the bounded wait and the empty catch keep
the "logging must never break the update" contract; an abandoned mutex is
still released so a killed writer cannot leak the hold.

Adds a -SelfTestLogConcurrency fixture (8 runspaces x 100 lines through the
real function, holding the file to the exact count with no torn lines) and
a Windows-lane regression test driving it. Measured with Add-Content
restored: 1026-1157 lines present for 800 written, plus torn lines; with
the fix: 800/800 intact across repeated runs.

Co-authored-by: ZCode <agent@zcode.local>
2026-10-27 15:58:38 -07:00
kshitijk4poor
ac0815be60 test(pm): pin the Docker image's own manifest shape in the on-tree payload test
docker/build_agent.py passes the venv's own python, .venv/bin/python, which
the image links out of the tree (/usr/local/bin/python3) and back to the
bundled interpreter under /opt/hermes/tools. The image's manifest therefore
names storePython ".venv/bin/python", and with the on-tree manifest read,
venv_command enters the venv through that chain (bundled python -S
pm/_venv_entry.py <site-packages>). The salvaged test used the bundled
interpreter directly, so the path the image actually takes was untested.

The test now builds that symlink chain, asserts the manifest's storePython,
and runs the venv_command argv to import a dependency from the venv. The
payload_venv docstring no longer says the venv always ships beside the tree.
2026-10-28 03:44:47 +05:30
Mert Kaya
3a03c10e12 test(pm): cover manifest-defined runtime paths 2026-10-28 03:44:47 +05:30
Mert Kaya
b74a29f016 fix(pm): resolve the image's sealed payload from its on-tree manifest
The Docker image assembles /opt/hermes in place (repo: "."), so its
manifest.json lands on the tree itself, but _payload_manifest only probed
the tree's parent. committed_venv() therefore found no sealed payload and
every runtime_command child (skill install, MCP install, doctor, backup)
died with "no dependency environment is committed for this install".

Probe both locations and resolve a manifest's entries relative to its own
directory, which is the payload root in both layouts.
2026-10-28 03:44:47 +05:30
Teknium
20e892f81a fix(desktop): the system proxy reaches only the update's children
Review round on the system-proxy hand-off (#123387):

- The resolved proxy leaked into the relaunched Desktop and everything it
  starts. posix.sh relaunched with the update env scrubbed but the proxy
  env kept, the Windows Start-Process rung and the staged updater pass
  their env on, and gateways `hermes update` restarts inherit it. With a
  NO_PROXY of only localhost, every LAN or internal host the PAC sends
  direct went through the proxy, and the next update read the stale proxy
  as an explicit user setting and never re-resolved it.
  The Desktop now names each variable it adds in HERMES_UPDATE_SYSTEM_PROXY
  and saves a NO_PROXY of the user's it extends as
  HERMES_UPDATE_USER_<KEY>. The Desktop restores its own env at entry (every
  relaunch rung), posix.sh restores it in the relaunch subshells (Linux
  and macOS), windows.ps1 before the tethered Start-Process rung, and the
  gateway and serve/dashboard at start. A marked value is never taken
  for the user's own on the next update.
- NO_PROXY gains 127.0.0.0/8, 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16
  and .local, and a user NO_PROXY is extended instead of replaced. The
  user's value previously also overrode the extended one, because
  process.env was spread after the proxy env.
- Each update host is resolved on its own, and the env proxy is exported
  only when every host is either that one plain PROXY or DIRECT. A PAC
  that sends hosts to different proxies gets a logged note and no env.
- SOCKS and HTTPS answers are no longer exported. Chromium's "SOCKS" is
  SOCKS4 and was mapped to socks5h. Beyond that, Python's urllib sends a
  plaintext CONNECT to any proxy URL, npm reads no SOCKS env, httpx refuses
  socks4, and the update's own git calls drop injected git config. They
  get a logged note instead.

Live (Electron 44.9.3 on Xvnc :95):
- Before: the built Desktop launched with a marked proxy env gave its
  Python backend all six proxy variables. After: only the user's
  NO_PROXY=corp.internal.
- The real posix.sh --relaunch-target: `hermes update` still gets the
  proxy, and the relaunched app gets none (before: all six).
- A PAC resolving LAN and corp hosts DIRECT keeps them direct, and so do
  the update's localhost calls.
2026-10-27 13:23:31 -07:00
liuhao1024
e241405cd1 fix(desktop-update): name the failing updater output in the hand-off failure
当 hermes update 在 Desktop hand-off 里失败时,shim 与下次启动的结果
弹窗只显示 "Update failed (exit N)",从不携带 updater 自己的输出,
用户没有任何可达途径看到真实失败原因(#137327)。

从本轮 log 切片(OUT)提取 updater 最后 3 行非空输出(剥离 ANSI/CR、
过滤 hand-off 自身的时间戳日志行、每行限 120 字符)附加到失败文案;
输出为空时保持原文案不变。
2026-10-27 13:23:31 -07:00
PRATHAMESH75
52223a33d2 fix(desktop-update): read macOS creation times with /bin/date under GNU coreutils
proc_ct() parses `ps -o lstart=` with `date -j -f`, a BSD-only flag. The
Desktop hand-off inherits the login-shell PATH, so with Homebrew's coreutils
gnubin first `date` is GNU date: `-j` fails, `2>/dev/null || return 0`
swallows it, proc_ct prints nothing, ident_state returns 2 for the Desktop's
pid, the bridge-marker claim is refused and posix.sh exits 2 on every update.

Pin /bin/date, as the scripts already do for /usr/bin/python3 and xattr.

Fixes #137925
2026-10-27 13:23:31 -07:00
Akloenx123
7da84c65d4 fix(update): write the hand-off's creation time with a dot under any locale
proc_ct rendered the POSIX hand-off's creation time with awk's printf, and
mawk (the default awk on Debian and Ubuntu) formats %f with LC_NUMERIC's
decimal separator. Under a comma-decimal locale the marker got
ct:1791471938,040, which MARKER_CT_RE and both readers reject, so the
hand-off judged its own claim a previous incarnation, refused to publish
the update child and every Desktop update aborted with exit 3.

Pin that awk to LC_ALL=C, as the ps/date calls beside it already are.

Fixes #135183
2026-10-27 13:23:31 -07:00
Teknium
62eff8cb85 test(desktop-update): wait for the relaunch with wait_until, not a sleep loop 2026-10-27 11:51:03 -07:00
Teknium
a1b19b475a test(desktop-update): name the leaked correlation id when the relaunch env check fails
The hand-off environment dict is too large for pytest to print in full, so the
value that leaked was cut off in the failure message.
2026-10-27 11:51:03 -07:00
Teknium
780a64b266 test(desktop-update): the relaunched-Desktop retry test no longer depends on which relaunch rung wins
The test only saw the relaunched Desktop's environment when windows.ps1 fell all
the way to the Start-Process rung. Its stand-in exited when the WMI or explorer
rung started it, so reaching that rung depended on the explorer rung's
400 ms poll missing the short-lived child. On the arm64 runner the poll caught
it (pid 11620), the explorer rung won, and the stand-in never recorded anything.

Now the stand-in records the id it inherited beside its own exe on every rung
and stays up without a window, so the first rung wins on every runner. While
that rung waits for a window, the test reads the hand-off's own environment.
That environment is what the Start-Process rung hands on, so the strip of
HERMES_UPDATE_CORRELATION_ID is checked whichever rung ran. The run id
assertion (update id == this run's id, consent covered) is unchanged.

The quitting stand-in Desktop also tolerates a refused marker read while the
hand-off rewrites the marker. It crashed with PermissionError on that runner.
2026-10-27 11:51:03 -07:00
Teknium
304caf6e7a test(desktop-update): make the relaunched-Desktop retry test deterministic under parallel runs
- The stand-in Desktop quits once the hand-off adopts its bridge. A fixed 15 s
  lifetime could end before a loaded runner's hand-off adopted it, which the
  script then (rightly) refused as a Desktop that gave up.
- The stand-in relaunch target has its own name. The explorer rung takes any
  fresh process of that name as its launch, and a concurrent test's stand-in
  Hermes.exe was taken for ours.
2026-10-27 11:51:03 -07:00
Teknium
c0016c3cb5 fix(desktop-update): a Close-and-retry runs under its own hand-off run, not an inherited one
Review round on #101789 (R-890-1). A Desktop that the hand-off's tethered
Start-Process rung relaunched inherited that run's HERMES_UPDATE_CORRELATION_ID.
Its next hand-off passed `-HandoffRun Y`, but windows.ps1 kept the inherited id X
for `hermes update`, so take_consent(release, X) dropped the consent bound to Y:
every "Close <program> and retry" in that Desktop session closed nothing and the
dialog came back (fail-safe, but a dead button).

- windows.ps1: -HandoffRun beats an inherited id; an id from the environment is
  kept only when no run was given (older Desktops, other callers).
- windows.ps1: the run's id is removed from the environment before any relaunch
  rung, so the relaunched Desktop never carries it.
- checkout.ts: the Windows script hand-off sets HERMES_UPDATE_CORRELATION_ID to
  the run its consent is bound to (dropped when the script predates protocol 2).
2026-10-27 11:51:03 -07:00
Teknium
719b4c3220 fix(desktop-update): a close-holder consent covers exactly the retry it started
Review round on #101789. The Desktop's "Close <program> and retry" consent stayed valid for an
hour: when the retry failed before the swap (build error, refused apply), the next swap from any
source (gateway /update, cron, another Desktop) closed the program without asking.

- The consent is bound to the retry's hand-off run id (checkout.ts binds it once the run id
  exists; windows.ps1 already exports it to `hermes update` as HERMES_UPDATE_CORRELATION_ID) and
  to the exact processes the user saw (pid + start time + program).
- Every swap attempt consumes the file at its start, matching or not; only the run it was given
  for acts on it. An apply that does not hand off removes it, and the hand-off script removes one
  its run never used.
- A holder whose program path cannot be read (a protected process) is named for the user to close:
  no Close button in the Desktop dialog and no y/N for it at the terminal, since closing it from
  here can never work.
2026-10-27 11:51:03 -07:00
Teknium
b03699fca5 fix(desktop-update): relaunch the Desktop and point its shortcuts at the user home
The Windows hand-off relaunched Hermes.exe (WMI and Start-Process rungs)
with release\win-unpacked as its working directory, and install.ps1 wrote
the Start menu and desktop shortcuts the same way. Every child the Desktop
starts without its own cwd inherits it, and Windows refuses to rename a
directory that is a live process's cwd, so one helper that outlives the app
blocked every later swap of that folder (#101789). Both now use the user
profile, matching the Electron entry point's own relocation.
2026-10-27 11:51:03 -07:00
Teknium
21ead66c56 fix(desktop-update): windows.ps1 keeps release holders in a plain array (PS 5.1 @() over List[object]) 2026-10-27 11:51:03 -07:00
Teknium
ef47d951bd fix(desktop): name the program holding release/ and close it only with consent (#101789)
Windows refuses to rename a directory that any live process uses as its
working directory. A resident helper spawned from a Hermes window (Sogou
IME's SogouCloud.exe in the report) inherits that window's cwd inside
release/win-unpacked and keeps it after the app exits, so every Desktop
stage-and-swap failed with an opaque "Could not publish the desktop build"
although the build succeeded.

The previous commit stopped such processes automatically. A program that is
not part of Hermes is the user's, so this keeps its cwd detection
(hermes_cli/desktop_release_holders.py) and drops the kill:

- When the first swap rename is refused on Windows, every process whose cwd
  is inside release/ is named, one "Desktop app folder held by: NAME (pid N,
  EXE)" line each, and the update failure names it too.
- It is closed only with consent: a yes at an interactive terminal prompt, or
  the Desktop's "Close NAME and retry" choice, which leaves a one-retry consent
  file in release/ naming the programs. Each one is re-checked right before
  (same pid and creation time, cwd still inside, not our ancestor). A hidden
  hand-off or piped run with no consent never closes anything.
- windows.ps1 turns the holder lines into a structured release_holders list
  and a message naming the program; the relaunched Desktop shows it and offers
  the consented close-and-retry (default button: Not now), which runs the
  update hand-off again so the owed app is rebuilt and promoted.

Same goal as #101793 (name the holder instead of failing opaquely), plus the
consented retry.

main.ts: fileExists/directoryExists/isGitCheckout move to electron/fs-probes.ts
to offset the two new lines.

Fixes #101789
2026-10-27 11:51:03 -07:00
Teknium
4b90de5022 fix(update): each update stage names itself where it starts, so a failed build still shows the restart
The Desktop hand-off window's stage text was published from the END mark of the
previous stage (`record_stage` guessed the next one from a table). A failed build
published nothing, but the code is committed so the update still restarts the
gateways, and the window kept the build/packaging message through the whole
restart (Greptile review on #144922).

Each message is now published where its stage begins: "Downloading updates"
after the backup, "Updating dependencies" before the completion's dependency
sync, "Building the apps" at the product build, and "Restarting Hermes services"
inside the fleet restart phase itself, so every caller (current completion and
historical takeover) gets it after a failed build too. `record_stage` is back
to origin/main's shape: no next-stage table, no failed-snapshot special case.

The Windows stage-relay test waits with tests.waiting.wait_until instead of two
hand-rolled sleep loops (the STAGE_CLI child imports it from the repo it already
puts on sys.path).
2026-10-27 07:53:07 -07:00
Teknium
70e42ba889 test(desktop-update): load the tree's hermes_cli in the Windows stage-relay fixture
The fixture install ships its own hermes_cli package, which shadowed
hermes_cli.update_stage on the runner.
2026-10-27 07:53:07 -07:00
Teknium
c9b55ea26d fix(desktop-update): the update window names the stage it is in, on Windows too
The hand-off window showed "Updating code and dependencies" plus a clock for
the whole 20-60 minute update (#139952, #135363, #130460). On Windows the
hermes update child could not publish anything: windows.ps1 never told it
where (posix.sh exports HERMES_UPDATE_STATUS_FILE), and the pipeline's own
stage marks named nothing.

- windows.ps1 exports HERMES_UPDATE_STATUS_FILE and relays what the child
  writes there to the window once a second while the step runs, logging each
  stage to the hand-off log so its timestamps localize the slow one.
- Each pipeline stage mark (snapshot, apply, deps, build) publishes the next
  stage: Downloading updates, Updating dependencies, Building the apps,
  Restarting Hermes services. The desktop build adds "Packaging the desktop
  app" before electron-builder runs.
2026-10-27 07:53:07 -07:00
unsupportedpastels
3f2b1722b1 feat(nix): ship the Webapp in the Nix package
The Nix package had no Webapp bundle, and `hermes webapp` could not build
one in the read-only store. nix/webapp.nix builds it in the npm workspace
the hook prepares (no native rebuild, no Electron), exposed as
`.#webapp`. The agent assembler takes it as a `webapp` frontend: the
wrapper sets HERMES_WEBAPP_DIST to it, as HERMES_WEB_DIST is set for the
dashboard.

hermes_cli/webapp.py serves a HERMES_WEBAPP_DIST bundle as shipped: no
freshness check, no build lock, never rebuilt or marked stale, and
`--force-build` says it cannot rebuild it.
2026-10-27 09:42:22 -04:00
kshitijk4poor
de5f56c92a refactor(deadline): one poll_until for check-until-deadline loops
Twenty loops across 17 files hand-wrote the same thing:

    deadline = time.monotonic() + timeout
    while time.monotonic() < deadline:
        if condition(): return ...
        time.sleep(interval)

with small drifts between copies: some re-checked once after the loop,
some did not, one slept before its first check, and update_cmd_windows
kept a private _poll_until. A copy without the final check can miss a
condition that becomes true during the last sleep.

agent/deadline.py (already the home of clamp_timeout / run_bounded_*)
gains poll_until(predicate, timeout, interval): checks at once, cuts the
last sleep to the time left, checks again at the deadline, and returns
the predicate's last value so callers that wait for a pid / row /
identity get it back directly. timeout <= 0 is one check.

Converted: outbound_webhooks.flush, cron delivery wait and jobs flock,
host_attach channel wait, browser profile unlock, data-cleanup drain,
gateway dbus/bus waits, launchd fresh-pid and supervision waits,
supervised restart, gateway_migrate live-gateway wait, Windows
drain/absent waits, kanban init lock, local-runtime boot wait,
update_cmd_windows (private helper deleted), bot desktop start/stop
waits, TUI browser connect.

Left as is: loops whose body does more than check (progress callbacks,
interrupt handling, two distinct exits) and one site whose blind except
the health gate would reject once moved.

Behaviour changes, all small:
- loops that stopped at the deadline without re-checking now make one
  more check there;
- loops that already re-checked after a full last sleep now cut that
  sleep to the time left, so the check lands at the deadline (up to one
  interval sooner);
- a timeout <= 0 now means one check (some loops made none);
- the local-runtime boot wait checks before its first sleep instead of
  after it;
- _wait_for_user_dbus_socket also exports the user systemd env when the
  socket appears on that final check (before, that path returned True
  without it).

update_cmd_windows is imported by update_cmd on every OS, so the
fresh-source-install acceptance fixture (which keeps agent/ out of the
update path) now copies the stdlib-only agent/deadline.py too.

Tests: 4 pins for poll_until (two red against the classic
no-final-check variant), plus the existing suites for every touched
module.
2026-10-27 16:30:14 +05:30
Teknium
95aed4f8de fix(telemetry): smoke waits for the gateway's turn rows instead of assuming the stop settles them
Review finding "Exit can drop queued metrics" (Greptile P2 + independent review W2): the smoke's
docstring claimed stopping the auto-started gateway settles its asynchronous rows, but the gateway's
graceful exit ends in os._exit, which skips the shared-metrics flush. Poll the probe home's store
(read-only, so polling never creates it) with a 30 s deadline until the gateway turn rows validate,
then stop the gateway; on expiry the store validation reports what is missing.
2026-10-25 22:27:40 -07:00
Teknium
7191be2fc5 fix(telemetry): smoke stops only the probe home's verified live gateway
Review finding "Cleanup repeats weaker process checks" (Greptile P2 + independent review W1): the
smoke's gateway stop trusted the probe home's gateway.pid record (kind + home) and signalled whatever
process held that PID, so a live non-gateway process or a recycled PID named by a stale record was
terminated. Resolve the PID with gateway.status.live_gateway_pid_for_home (start-time reuse guard,
gateway command line, home ownership) and do nothing on a miss; psutil binds the create time so
terminate() refuses a PID reused in between. The driver puts --hermes-repo first on sys.path so the
check comes from the tree under test.
2026-10-25 22:27:40 -07:00
Teknium
142dc8bbbd fix(telemetry): relay shared-metrics smoke passes on main again
The smoke's expected counters predate three merges, so on origin/main it stopped at the first
assertion:

- #106742 (unified gateway runtime): `hermes chat -q` is now served by a gateway it auto-starts
  for the home, which adds hermes.gateway.reply_latency and hermes.platform.delivery (platform
  local) and a second hermes.startup.latency row (surface gateway_boot).
- eb2edce53a: the turn's read_file call now also records hermes.tool_batch.count.
- e76fb951a1: a failed update counts the stage it died in, so the fetch-failed receipt adds an
  (apply, failed) hermes.update.stage row.

Expectations now live in one place: a single EXPECTED_METRIC_NAMES set for the SQLite and the
package checks, exact dimension dicts for the new rows, the update stages derived from the receipt
the probe feeds (UPDATE_RECEIPT, also used to build the probe), and both startup surfaces.

The smoke also stops the gateway the chat auto-started (pid record of its own home, then wait),
so a run no longer leaves a detached `gateway run --idle-exit` behind for 10 minutes, and the
gateway's asynchronous rows land before the package export.

The smoke is not run by CI, so the test file now pins its expectations to the contract: every
expected name is a contract counter, every exact dimension dict has the metric's current field set
and passes counter_dimensions_are_valid, the startup surfaces are contract surfaces, and the
expected update rows equal update_receipt_fields(UPDATE_RECEIPT).
2026-10-25 22:27:40 -07:00
kshitijk4poor
015f47a12b fix(config): keep auth's globals()-dispatched plugin status import; ship the reader gate to hook fixtures
Two regressions from earlier commits on this branch, caught by CI's Python tests:

- 8d7bff7615 dropped `get_plugin_oauth_auth_status` from hermes_cli.auth's imports as unused, but
  `_STATUS_BY_AUTH_TYPE` dispatches oauth_device_code / oauth_external plugin providers through
  `globals()[name]`, so every OAuth plugin provider's status raised KeyError
  (test_plugin_provider_picker_residue). Restored with a noqa naming the dynamic lookup.
- 7131eadb77 registered scripts/check_config_yaml_readers.py as the `config-readers` guard, but the
  code-health CLI tests copy only the listed guard scripts into their temp repos, so the installed
  hooks failed on the missing script. Added it to the fixture's _GUARD_SCRIPTS.
2026-10-25 18:54:09 -07:00
Bear Huddleston
b5eb5ee7a8 feat(webapp): carry the browser-hosted Desktop's server pieces from #93508
Carried from BearHuddleston's #93508 onto main. The Webapp relay and the
profile-incarnation fence stay out: carried code follows main's
named-profile rule and refuses a missing or deleted profile home.

- Webapp routes: one-use launch tickets, window handoff, and gateway
  WebSocket tickets minted for the signed-in browser
- Browser surface policy and the SPA document policy
- A host terminal for the browser that survives reconnects
- Staged browser uploads and file tickets; file.attach takes a staged upload
- hermes sessions adopt
- Webapp bundle build helpers and the renderer freshness check
- Regenerated gateway contracts

Co-authored-by: emozilla <emozilla@nousresearch.com>
2026-10-25 03:22:14 -07:00
Teknium
97253cc182 fix(run_tests): count import/collection failures and missing named paths
A test file that raised at import (e.g. a decorator using pytest without
`import pytest`) exited 2 with "collected 0 items / 1 error" and no
failed-test count, so the Summary line read "2 tests passed, 0 failed"
while the run exited 1, and the file was filed under a generic "no tests
ran" bucket. A positional test path that did not exist was dropped by
discovery and the run exited 0 without testing it.

- mark a failing file whose output shows a collection error and give it
  its own failure bucket, "FAILED AT IMPORT/COLLECTION", with pytest's
  one-line cause (the last traceback E line)
- the Summary line names failing files: "; FAILED: 1 of 2 files
  (1 at import/collection)"; error/crash/skip notes move into one helper
- the failure buckets become a cause -> (header, detail) table
- a positional path that does not exist exits 2 with
  "error: no such test path: ..."; --paths defaults keep skipping missing
  roots
- per-file pytest exit 5 (nothing collected, e.g. platform-gated) stays a
  pass, as deliberately added with the run-level NO TESTS RAN guard
2026-10-24 17:10:39 -07:00
Byrd-IT
cd424473d1 fix(run_tests_parallel): name pytest ERRORs on the Summary line
A file whose tests pass but whose fixtures error at setup ("41 passed,
7 errors") exits 1, yet the Summary read "41 tests passed, 0 failed" and
the file was filed under "all tests passed but pytest exited non-zero".

- accumulate summary["errors"] into tests_errored and print ", N errors"
  on the Summary line when non-zero (same pattern as crashed_note)
- dedicated failure bucket "with pytest ERRORs" listing passed/error
  counts per file; such files no longer land in the passed-but-nonzero
  or no-tests-ran buckets
- tests: parser returns errors for "41 passed, 7 errors"; end-to-end
  probe with a failing fixture asserts the Summary shows "3 errors";
  clean run has no errors note
2026-10-24 17:10:39 -07:00
Teknium
7152bf009a fix(install): browser opt-out uses the name every PM release accepts
install.sh --skip-browser / --no-playwright and install.ps1 -SkipBrowser
now hand PM `--without agent-browser` again instead of `--without chromium`.

The downloaded installer is the newest script, but by default it installs
the stable tag, whose PM (v0.22.5) rejects `--without chromium` with
"--without accepts only optional default packages (agent-browser,
cua-driver)" and exits 1, failing the whole install. The new PM already
reads `agent-browser` as `chromium` (pm.defaults.RETIRED_DEFAULTS), so the
legacy spelling works against both the stable tag and main. Direct
`hermes pm install --without chromium` stays valid on the new PM.
2026-10-23 01:43:17 -07:00
Teknium
1ac18d2b12 refactor(pm): drop the agent-browser package; Chromium is a default package in its own right
- pm: AgentBrowser class + lock entry gone; Chromium default=True and its env
  exports only PLAYWRIGHT_BROWSERS_PATH (Playwright launches without an
  executable path still need it). A recorded or passed --without agent-browser
  maps to chromium (pm.defaults.RETIRED_DEFAULTS), and pm gc forgets the stale
  agent-browser fact so its store entry is reclaimed.
- install.sh --skip-browser/--no-playwright and install.ps1 -SkipBrowser pass
  --without chromium; undo hint is hermes pm install chromium.
- Docker bakes /etc/hermes/chromium-executable-path; stage2-hook validates it
  and exports nothing; the sandbox-desktop image drops the agent-browser npm
  install and keeps its Playwright Chromium.
2026-10-23 01:41:25 -07:00
Teknium
a4072ce7e6 fix(desktop): the short uv cache junction creates its parent
Review follow-up: short_alias now creates the junction's parent directory,
so preparation never depends on the caller having made the work dir first
(the existing prepare_tools test failed on both Windows lanes with WinError 3).
That test now checks the invariant the Windows path keeps: UV_CACHE_DIR
reaches the cache directory, through the short work-local junction on Windows.
2026-10-22 17:47:42 -07:00
Teknium
1aaf75e6f2 fix(desktop): build Windows sdists under a short uv cache path
With a cold desktop-inputs cache, Windows desktop preparation builds sdists
that have no cp314 Windows wheel (obstore on win32-x64, dependency-injector on
win32-arm64). uv builds each one in
<cache>\python\runtime\<toolchain id>\sdists-v10\pypi\<pkg>\<ver>\<id>\src,
about 200 characters below the deep .cache\desktop-inputs root, so MSVC
link.exe outputs passed MAX_PATH and the build failed with LNK1104.

On Windows, prepare_tools now hands uv a short job-local junction
(<work>\uv) that points at the same transported cache directory. uv keeps the
spelling it is given, so builds run under the short path while the bytes are
still restored and saved by the desktop-inputs cache. The native toolchain id
is read through the junction, and prepare_native keeps the absolute spelling
instead of resolving the junction back to the long path.

CARGO_TARGET_DIR is also owned by the preparation environment and points at
<work>\cargo, so Rust sdists link under the work root on every target even
if a tool resolves the junction.
2026-10-22 17:47:42 -07:00
Maciej Lisiewski
2b31d12ade fix(pm): apply lock overrides to requirements builds; read pip check uncoloured
Requirements builds (Termux deb assembly and wheelhouse gate, PM runtime
wheelhouse install) install the lock's export with uv pip install, which
re-resolves and rejects the overridden graph. Pass the lock: its manifest
overrides become --overrides and the closing check accepts them.

FORCE_COLOR/CLICOLOR_FORCE made uv pip check emit ANSI the report parser
cannot read, failing every install with an expected override mismatch.
2026-10-22 17:36:39 +02:00
Teknium
99cc712bf3 fix(update): a damaged .git no longer strands paused gateways
When a checkout's .git exists but git rejects it (empty HEAD, a gitdir:
file pointing nowhere), every `hermes update` failed at the fetch with a
generic "Failed to fetch updates" and, on Windows, left the paused
gateways stopped with "the next `hermes` command restarts them". No
later command could: the whole-tree gate held the set while HEAD was
unreadable, so bots stayed down until someone repaired the checkout by
hand.

- tree gate: a set whose every pause already found HEAD unreadable and
  that never bound a tree move resumes. The gateways were serving that
  exact tree and no update step wrote it. A recorded move, or a HEAD
  that was readable at the pause, still holds the set.
- fetch failure: "not a git repository" now says the checkout's git data
  is damaged and prints the installer one-liner that repairs it.
- install.sh: a dangling `.git` file is moved aside and re-cloned like a
  commit-less one, matching install.ps1 (Test-Path already matched it);
  both installers' warning names a damaged .git, not only an
  interrupted clone.
2026-10-21 16:57:37 -07:00
Teknium
be64dc5b18 test: Termux assembly test skips when the Docker daemon hangs instead of failing main
The bind-mount ownership test probes `docker info` / `docker image inspect`
with a 15 s timeout but only skipped on a non-zero exit, so a CI runner
daemon that hangs past the timeout raised TimeoutExpired and failed the
test (main run 39560831204 on 9ec17f7f4f, both parametrizations). A daemon
that does not answer is as unavailable as one that refuses: skip, the same
way tests/docker/conftest.py::_docker_available already treats a timeout.
Only the assembly run itself may fail this test.
2026-10-21 00:46:50 -07:00
ethernet
d6d77c3649 Merge pull request #141725 from NousResearch/feat/store-auto-publish
feat(release): Store certifies before the gate; publication switches it live
2026-10-20 17:43:36 -04:00
ethernet
01af57a06c Merge pull request #141716 from NousResearch/perf/release-metadata-only-receipts
perf(release): stage candidates from metadata; verify package bytes at publish
2026-10-20 17:31:33 -04:00
ethernet
e8a8a9b65a Merge pull request #141718 from NousResearch/fix/https-origin-opener-reset
test(release): https_origin resets urllib's cached default opener
2026-10-20 17:19:22 -04:00
ethernet
ee8f05a48a Merge pull request #141651 from NousResearch/fix/desktop-prepare-caches
fix(desktop): Windows prepare reuses its restored wheel, vcpkg and npm caches
2026-10-20 16:03:44 -04:00
ethernet
4148f6d1f3 feat(release): Store certifies before the gate; publication switches it live
stable-store commits the Store submission held (targetPublishMode Manual)
instead of leaving an uncommitted draft, so certification runs before the
release gate and a run whose stable-publish fails still shows customers
nothing. The publication pass then PUTs the held submission with
Immediate and commits it again, so it goes live without a Partner Center
click.

Microsoft documents no call that releases a held submission and does not
say whether update accepts a committed one (409 is documented only as
"the current state of the app"). A 409 from the switch leaves the
submission held and prints the Publish now instruction; the release
stays green. The first real release shows which answer the API gives.

Reconcile receipt-bound Store work independently of channel advancement, including
already-current published releases, so an interruption cannot strand a held
submission. Record each upload's claim in certification notes and replace a held
Manual predecessor only after its exact remote abandon marker matches the claim
commit. Unknown owners and publishing submissions remain protected.
2026-10-20 15:50:30 -04:00
ethernet
fa6a127ed6 perf(release): stage candidates from metadata; verify package bytes at publish
candidate-manifest spent ~4 of its 5.2 min downloading 8.7 GB (stable run
38491090442: both MSIX bundles, including the 4.3 GB Store bundle) only to
re-hash them, and each stage-receipt job re-downloaded its group's ZIPs and
bundle (60-256 s). The same bytes are hashed by the build job that uploaded
them, bound by digest in its handoff receipt, and downloaded and digest-
checked again by release_artifacts.publish (materialize) before anything
goes live.

Candidate staging and receipts now download only the metadata JSONs; package
rows still carry the receipt digests. The one check that read package
contents, the universal bundle identity against its per-arch rows, moves to
publish, after materialize has verified the bytes. A Store-only claim has no
metadata to fetch, so candidate-manifest reads its receipts alone.
2026-10-20 15:50:30 -04:00
ethernet
61c6721057 test(release): https_origin resets urllib's cached default opener
urlopen() builds its default opener once per process, capturing the SSL
context from SSL_CERT_FILE at that moment. Every https_origin fixture mints
its own self-signed CA, so whichever test first called urlopen() pinned its
CA for every later test in the same file: later origins failed with
CERTIFICATE_VERIFY_FAILED. Today's tests happen to avoid the order that
trips it; a new publish test in the release stack hit it. Reset the cached
opener per fixture so each origin's CA is the one in use.
2026-10-20 15:50:30 -04:00
ethernet
c8d272e860 test(desktop): give the vswhere identity test the OpenSSL release builds pass
On win32-arm64, native_cache_path deliberately treats identity without the
provider's OpenSSL (OPENSSL_DIR) as incomplete, so the test got a fresh
partition on the arm64 Windows lane while x64 passed. Release builds always
hand vcpkg's static OpenSSL in; the test now does too.
2026-10-20 15:50:30 -04:00
ethernet
550e2a891f feat(release): publication commits the Store draft with auto-publish on
The Store build used to be committed at green with targetPublishMode
Manual, and the publication pass could only print "click Publish now":
the submission API has no call that releases a held submission (update
and commit return 409 once it is committed). Every stable release needed a
person in Partner Center.

stable-store now uploads the verified bundle as an uncommitted draft
(msstore publish --noCommit) and stops. The publication pass, which runs
only when the release really goes out, reads the receipt-bound candidate
manifest, checks the pending draft carries that release's Store bundle,
sets targetPublishMode Immediate and commits it. Certification starts
then, and the build goes live when it passes.

- A draft from a newer green run is left for its own release; a committed
  or live submission is a no-op, so reruns are safe.
- submit refuses to replace a committed submission still on its way live
  (an earlier release); msstore publish would delete it.
- complete's Reconcile step now receives the MS_STORE_* credentials; it had
  none, so the success path silently skipped the Store.
- A failed or unreadable Store step stays a warning: the release publishes.
2026-10-20 15:50:30 -04:00