Commit Graph

3627 Commits

Author SHA1 Message Date
Teknium
ac8d524a45 fix(whatsapp): pairing and the bridge agree on the pin, its validity and its source
Review findings on #162647:

- Pairing read the pin through a second merge implementation that missed the
  managed overlay's precedence, case-blind platform names and gateway.json.
  It now reads the saved WhatsApp block through `platform_blocks()`, the
  side-effect-free reader the cron and left-core paths already use, and
  takes `PlatformConfig.from_dict(block).extra` from it; the parallel
  `yaml_platform_extra` is removed.
- Python accepted pins bridge.js refuses (non-ASCII digits, a float list),
  so `hermes whatsapp` could clear the linked session and then fail on the
  pin. Both sides now accept only three ASCII parts within uint32 (the
  login encoder writes each part as uint32: larger values wrap on the
  wire), lists only of integers.
- The dashboard checked the pin before moving the session aside but the
  queued worker re-read config.yaml. The start route now validates once and
  hands that value to the worker.
- Pair-only treated 502/504 as permanent and stopped; they now reconnect
  like 503.
- A cold start with no version source answering logged "default" and
  /health reported null: the bridge now names Baileys' bundled build, and
  says when a build is the last lookup answer because the sources are
  down.
2026-12-01 16:49:15 -08:00
Teknium
37533108be fix(whatsapp): keep an unpaired WhatsApp card unconfigured; record the pin crossing
A `web_version: ""` default in DEFAULT_CONFIG's whatsapp block made the
merged config carry a whatsapp key on every home, so the dashboard showed an
enabled-but-unpaired WhatsApp as configured. Document the key in the block's
comment instead, like reply_prefix and send_read_receipts.

Record the adapter's import of whatsapp_common.apply_web_version_env in the
boundary-lint baseline: the gateway adapter (plugin) and the CLI/dashboard
pairing (core) must share one validator for the pin, and whatsapp_common is
where the bridge helpers both sides already use live.
2026-12-01 16:49:15 -08:00
Teknium
13d065b107 feat(whatsapp): pin the WhatsApp Web build in config.yaml; back off on 405
When WhatsApp raises its minimum WhatsApp Web build, the bridge closes with
405 on every connect. Automatic resolution (newest of Baileys and
web.whatsapp.com) usually follows it, but when both sources are stale or
unreachable an operator had no supported way to present a known-good build,
and the gateway bridge reconnected every 3 s forever with no word on which
build it sent.

- config.yaml `whatsapp.web_version` (or platforms.whatsapp.extra.web_version,
  which wins): an emergency pin. Unset keeps automatic resolution. It reaches
  bridge.js as WHATSAPP_WEB_VERSION from all three spawners (gateway adapter,
  `hermes whatsapp`, dashboard pairing), each reading its own profile's
  config; the launch env's value is cleared so it never pins another profile.
  It is part of the bridge spawn fingerprint, so a changed pin restarts an
  adopted bridge.
- A malformed pin refuses with the expected format: gateway connect sets
  fatal `whatsapp_web_version_invalid` before any spawn; CLI and dashboard
  pairing refuse before the re-pair step can clear or move the session.
  bridge.js refuses it too when run by hand.
- bridge.js logs the build and its source on every connect and every 405,
  reports waVersion / waVersionSource / versionRefusals on /health, and
  backs consecutive 405s off from 3 s to 5 min (each retry re-resolves),
  naming the remedy from the third. A 405 never touches the session.
- Pair-only 405 failures name the build that was refused.
- Docs: WhatsApp Web version section; troubleshooting no longer sends 405
  loops to re-pairing.

Fixes #88516.
2026-12-01 16:49:15 -08:00
Teknium
10246fea6c fix(whatsapp): pairing stops with the close code instead of looping on 405
In --pair-only mode the bridge reconnected after every close except a
logout. When WhatsApp refuses the connection before a QR (405 = refused
WhatsApp Web build, also 403/411/500), each retry gets the same close, so
`hermes whatsapp` and the dashboard pairing panel sat on "Reconnecting"
forever with no QR and no reason.

Pair-only now reconnects only on closes a retry can fix (408 QR expired,
428 network drop, 503 service blip, 515 restart after scan) and fails at
once on any other close with the status code and a next step. The linked
gateway bridge keeps reconnecting on every close as before.
2026-12-01 16:49:15 -08:00
Teknium
6e3fa226ec fix(chronos): read root settings through load_root_config, drop the baselined core import
Maintainer ruling: plugins use a published API instead of importing core.
Chronos now calls hermes_cli.config_root.load_root_config() and the
boundary-lint baseline entry for bind_profile_scope is removed.
2026-12-01 16:15:32 -08:00
Teknium
8d9f834bf2 fix(chronos): read the root settings under bind_profile_scope, not the legacy setters
main now refuses new raw set_hermes_home_override/set_secret_scope calls
(HX016) and names agent.runtime_scope.bind_profile_scope as the remedy.
It binds the root's home and its owner secret scope together, keeping the
process home's launch semantics (env-only keys from systemd/op run), which
is what the hand-built pair did. No hydration: a config read per fire must
not run external secret sources. The plugin's one crossing moves from
tui_gateway.launch_profile_policy.owner_secret_scope to
agent.runtime_scope.bind_profile_scope; baselined (no published plugin API
binds another home's scope).
2026-12-01 16:15:32 -08:00
Teknium
4440b3e345 fix(windows): owned children never break away; detached spawns share one breakaway-denied retry
The WhatsApp bridge is an owned child (spawn_owned): it must not outlive its gateway. It was
spawned with CREATE_BREAKAWAY_FROM_JOB, so a gateway in a job that forbids breakaway (Desktop, an
IDE or agent host, Task Scheduler) could never start it (WinError 5 on every reconnect), and under
a job that allows breakaway it escaped that job's teardown, keeping the port and the WhatsApp
session. spawn_owned now strips the breakaway bit on Windows, so every owned child stays in its
owner's jobs (the pairing bridge already spawned that way).

Children that must outlive their parent go through one primitive, _subprocess_compat.popen_detached:
breakaway when the parent allows it, else retry inside the job on ERROR_ACCESS_DENIED only. The two
Windows detached spawns without that retry (gateway /update, the Desktop launch) and five copies of
it (default plugins, commit-graph refresh, scratch prune, hermes desktop, launchd fallback) use it.

Fixes #68128

Co-authored-by: morkalg <20704953+morkalg@users.noreply.github.com>
Co-authored-by: IzzyWizzy666 <25311408+IzzyWizzy666@users.noreply.github.com>
Co-authored-by: liuhao1024 <sunsky.lau@gmail.com>
Co-authored-by: Rickard Robin <rickard@kumobits.com>
2026-12-01 13:20:40 -08:00
unsupportedpastels
1b44480c83 fix(pm): pin Chromium to Chrome for Testing 158.0.8127.88
Bump the bundled Chromium pin from 1248+156.0.8078.80 to
1254+158.0.8127.88 across all shipped targets (mac-arm64, mac-x64,
linux-arm64, linux64, win64) to include the fixes for CVE-2026-125350
(157.0.8103.50, CISA KEV) and CVE-2026-134401 (158.0.8127.88, critical).

Bump the pinned Playwright packages (@playwright/test and
playwright-core) from 1.64.0 to 1.65.0 so the Playwright revision (1254,
Chrome 158 milestone) matches the pm store directory chromium-1254, and
raise the floor and revision assertions in tests/pm/test_chromium.py.

Fixes #161567
Reported-by: @hsakkout
2026-12-01 16:16:06 -05:00
alt-glitch
8b5b44c41f fix(code-health): code moved into a rule's folder keeps its violations
A rule with an `include` scope (the function-level import rule covers tools/
only) was measured on the base side with the same scope. A function moved
unchanged into tools/ from a file outside it therefore arrived with no
recorded violations, and every import inside it read as new, though the
ratchet's own contract is that code that moves keeps its cap and its
violations.

The base side is now measured with the rule's `exclude` only. A base hit is
used only by the head unit the comparison pairs it with, so the extra hits
change nothing for a file that stays outside the scope; they cover the same
occurrences once the unit lands inside it. An import the move adds is still
new.
2026-12-02 02:05:07 +05:30
alt-glitch
f25bd9dac0 refactor(agent): the Python toolchain probe moves from tools/ to agent/
tools/env_probe.py becomes agent/environment_probe.py, whole with no line changed.
It builds one line of the system prompt and is called only by agent/ and the
gateway's warm-up; the new name matches its config key agent.environment_probe and
its functions, and keeps "env" free for environment variables (utils/env.py).

No old name is kept: no release, frozen list or pinned catalog plugin reaches
tools.env_probe in a process that outlives an update. Its two path-keyed rows in
tests/fixtures/resolution_allowlist.json follow the file. Its logger now logs under
the agent component.

scripts/ci/prompt_surface.py imports the module to blank the probe line while it
renders the prompt surface, so its import changes with it.
2026-12-02 01:58:47 +05:30
BearHuddleston
1affcba881 refactor(releases): give the Windows channel aliases one owner
Stable kept its prepared Windows aliases inside StableDownloads, while
canary carried its own aliases and R2 credentials as locals through
promote() and ran the VM-proof check twice. WindowsAliases now owns them
for both channels: prepare() returns None unless the exact digests carry a
reviewed VM proof, otherwise checks every alias before any feed moves, and
promote() calls publish() once, right after either channel's Windows feed.
StableDownloads is back to the stable DMG and page.

No behaviour change: the order of R2 requests and channel writes is the
same on both channels. The 20 test files that reach these paths pass
before and after, and seven mutants of the new class and its call site
(proof check, copy skip, read-back, publish call, channel key, release
metadata, order check) each fail the promotion tests.
2026-12-01 11:25:57 -08:00
BearHuddleston
7b130bc736 feat(releases): gate primary Windows .msixbundle aliases and labels on reviewed VM proofs 2026-12-01 11:25:57 -08:00
alt-glitch
f76a32ed2c refactor(tools): tool selection and the platform resolver join tools/toolsets.py
tools/toolsets.py now answers both questions about toolsets: which tool names
a session's enabled and disabled lists come to (_select_tool_names and its
helpers, from model_tools.py), and which toolsets a platform gets from
config.yaml (_get_platform_tools, the 19 functions it calls and the 11 names
they read, from hermes_cli/tools_config.py). Definitions move unchanged;
inside them, the imports that named this file are dropped. Callers, tests and
docs import from tools.toolsets; a test that patched a moved name patches it
where the code it runs now reads it.

Old names stay where releases and pinned catalog plugins import them, until
v0.27.0. model_tools keeps _LEGACY_TOOLSET_MAP and _apply_toolset_selection
(releases up to v0.23.5 import them inside functions). hermes_cli.tools_config
keeps _platform_default_toolset (a pinned catalog plugin imports it),
_xai_credentials_present and enabled_mcp_server_names (releases), besides the
names its own code still uses.

The resolver's warnings and the disabled-bundle notice log under
tools.toolsets, so `hermes logs --component tools` shows them instead of `cli`
and `agent`. Importing model_tools now also loads hermes_cli.toolset_scope and
hermes_cli.toolset_validation, two small modules that import only the
standard library.
2026-12-01 22:51:13 +05:30
alt-glitch
ea4f672368 refactor(terminal): the process registry, terminal config and sudo move from tools/ to terminal_backends/
The 21 flat files that serve the terminal backends join the package:
the process registry and its nine parts, the environment-variable
passthrough, credential file mounts, workspace path resolution, the PTY
query responder, the terminal scope, and the backend table, config,
lifecycle, macOS open rewrite, sudo and sudo askpass of the terminal
tool. file_tools_paths becomes workspace_paths and the terminal_tool_
prefix drops (terminal_tool_backends becomes backends, and so on); every
other file keeps its stem. Function bodies are unchanged; only imports
and module-name strings follow the move. 22 tests move to
tests/terminal_backends/.

Ten old module names keep a generated old-path file and a compat key:
a session started on an older release imports them lazily after an
update from code it has already loaded (the gateway's process notices
and inbound media, an agent's next terminal command, sudo prompt or PTY
process). Each key also binds the module such a session holds to its new
name, so the process table, the sudo password cache and the registered
passthrough variables stay one object. The pinned catalog plugins'
modules are listed in the plugin guide.
2026-12-01 19:40:47 +05:30
BearHuddleston
baa3d58c37 fix(webapp): fail the build when the checkout lacks its preload plugin
buildWebapp skipped the preload plugin when neither the plugin nor
apps/desktop/vite.config.ts existed in the workspace, and threw only when
the config did. That branch existed for the test fixtures, which have no
vite.config.ts, but it keyed a required plugin on a filename: a checkout
whose config is named anything else built without preloads, silently.

The builder now imports the plugin from the workspace unconditionally, so
a checkout without it fails before anything is published, whatever its
config is named. The shared webappSource fixture carries the real plugin,
which also drops the new preload test's own conditional copy.

Test: "a Webapp checkout without its preload plugin fails the build,
whatever its Vite config is named" (vite.config.mjs, no plugin) fails on
680d5851ea (the build resolves) and passes here. A real build:webapp of
this checkout writes a byte-identical index.html.

Reported by Greptile on #162324.
2026-12-01 04:22:34 -08:00
BearHuddleston
447f3ead55 perf(desktop): preload main Webapp bundle during ui-preferences boot 2026-12-01 04:22:34 -08:00
alt-glitch
b85ac0f579 refactor(terminal): the terminal backends move from tools/environments/ to terminal_backends/
The terminal backends and their support files leave tools/, which holds
model tools, for a new root package terminal_backends/. base.py becomes
environment.py and its base_* siblings become environment_*;
sandbox_scope.py becomes hosted_scope.py and sandbox_conformance.py
becomes conformance.py. Every other file keeps its stem. Function bodies
are unchanged; only imports and module-name strings follow the move.

tools.environments, tools.environments.local, tools.environments.base
and tools.environments.sudo_password_note keep generated old-path files:
old releases import the first two after an update, an agent process
started on v0.23.2 to v0.23.5 imports the last on its next terminal
command, and the plugin API publishes BaseEnvironment under both
package names. tools.environments.base_output is a compat key for pinned
catalog plugins. terminal_backends joins the tools log component, the
known logger roots and every hand-written package list.

The package is not named sandboxes: on an install whose checkout is
HERMES_HOME that folder holds live sandbox workspaces, and the updater
of a released version deletes or stashes them when a tracked package of
the same name arrives.
2026-12-01 17:49:22 +05:30
alt-glitch
f92fa098ac fix(tests): the legacy mailbox fixture imports the old checkout's module name
The migration probe runs this file with a checkout from before the move on PYTHONPATH, where the module is tools.bot_live_delivery. The move rewrite now leaves the file alone.
2026-12-01 17:49:22 +05:30
alt-glitch
2115d74421 refactor(bots): Bot Mode and Bot Desktop move from tools/ to bots/
tools/ holds model tools. These 19 files register none: they resolve the
Bot Mode roster, deliver message_agent's DMs and run their by-path runner,
hold the cross-connection relay and its receipts, and run the Bot Desktop
screen. They move to a new root package, bots/ (flat plus bots/desktop/,
with the launcher and wallpaper beside the runtime that reads them).
tools/message_agent_tool.py stays; only its imports change.

Function bodies are unchanged and every import stays where it was. Tests
whose subject is a moved file go to tests/bots/, whose conftest imports
the tests/tools/ autouse fixtures they ran under. Loggers follow their
modules; bots joins the tools log component, so `hermes logs --component
tools` shows the same lines, and every hand-written root-package list.

Old names keep working. Each moved top-level module has a MOVES key.
Processes started on v0.21.6 to v0.23.5 that outlive an update import
these modules inside functions and start tools/bot_mode_dm.py by path as
the DM runner, so those names get generated old-path files. Pinned catalog
plugins import tools.bot_desktop and tools.bot_live_delivery; the plugin
guide lists both.
2026-12-01 17:49:22 +05:30
alt-glitch
074383f218 refactor(approval): the approval gate, detection and human prompts move from tools/ to approval/
tools/ holds model tools. These 36 files register none: they decide whether
a command or a write may run, detect dangerous commands, and ask a person
(approval prompts, gateway clarify, slash confirmations). They move to a new
root package, approval/, with command detection in approval/detection/.
tools/approval.py becomes approval/gate.py and tools/approval_detection.py
becomes approval/detection/patterns.py; the other files drop the approval_
prefix or keep their stem. 79 tests whose subject is a moved file move to
tests/approval/, whose conftest.py imports the autouse fixtures of
tests/tools/conftest.py they ran under.

Function bodies are unchanged and every import stays where it was. Loggers
follow their modules: the five module loggers that logged as tools.approval
now log as approval.gate, and approval joins the tools entry of
hermes_logging.COMPONENT_PREFIXES, so `hermes logs --component tools` shows
the same lines. approval also joins packages.find, FIRST_PARTY_MODULE_ROOTS,
_KNOWN_LOGGER_ROOTS, the plugin isolation audit, six check scripts, the P33
profile-scope pattern and the test fixtures that list root packages.

Ten old names keep a file at the old path, each a MOVES key, a
REQUIRED_NAMES row and a file written by scripts/move/generate_shims.py:
tools.approval and tools.clarify_gateway are on the published plugin API,
and all ten are imported inside functions on every turn, message, tool call
or human prompt by a process started on a release up to v0.23.5, which
keeps running its old code after an update swaps the checkout. Five more
modules that pinned catalog plugins import keep their old name through a
MOVES key with no file, listed in the plugin guide.

Both new packages call rebind_loaded_modules from their __init__, so a
session that outlives the update keeps the one gate it already holds: a
notifier registered before the update still reaches a background child's
approval request.
2026-12-01 17:49:22 +05:30
Teknium
f090ac7cb5 fix(pm): keep the libc probes identical in pm/store.py and install.sh
- pm/store.py::_elf_loader_is_musl: an interpreter path containing
  "/libc.so" no longer means glibc. glibc's loader is always ld-linux*;
  the only loader named libc.so is musl's own, so that shape is unknown.
- scripts/install.sh: hoist the PT_INTERP reader to a top-level
  _uv_elf_interp_libc (it was a nested function that bash defines
  globally anyway) and drop the new "an ld-linux loader exists on disk"
  fallback. pm/store.py has no such step, and Alpine with gcompat ships
  /lib/ld-linux-x86-64.so.2, so the two probes would disagree on the
  hosts the fallback exists for.
- Tests: an entry-point test drives current_target() on a Fedora-shaped
  glibc host (PT_INTERP at 0x10a000, /lib/ld-musl-x86_64.so.1 on disk);
  the install.sh tests keep main's "musl ELF beats a glibc ldd" stub,
  pin uname so arm64 runners pick the same row, and run the past-8K
  case with no ldd and a musl loader on disk so only PT_INTERP decides.
  The probe-order test is trimmed to the two invariants.
2026-12-01 03:05:50 -08:00
Azhar457
a443f25e55 fix(install): read PT_INTERP for the uv bootstrap libc probe
uv_bootstrap_target() grepped a fixed 8 KiB head window of /bin/sh and
/bin/ls for the loader name. Fedora 44 places PT_INTERP at 0x10a000 in
bash and 0x19000 in ls, so the probe missed both and the last-resort
musl glob matched a musl-libc installed for cross-compilation. On such a
host the installer stages the musl uv artifact for a glibc userland
(#145469, #150951).

Read the interpreter from the ELF program headers instead. Grepping the
whole file is not a substitute: astral's glibc uv embeds the string
"/lib/ld-musl-x86_64.so.1", which false-positives as a musl loader.

Before the musl glob, also prefer a native ld-linux loader: a glibc
userland always carries one, while a musl loader on disk may only be a
secondary toolchain. The probe paths are optional arguments so the tests
can pass synthetic ELF images.
2026-12-01 03:05:50 -08:00
Teknium
93ea99fe20 test(install): the pinned-git gate refuses a non-ASCII tree without its helper
Folds the negative case from #157257: under every code page the suite
drives, a tree under the non-ASCII profile that lacks git-remote-https must
still be refused, so the positive assertion cannot pass for the wrong reason.

Co-authored-by: JiaY-77 <47072765+JiaY-77@users.noreply.github.com>
2026-12-01 02:35:12 -08:00
juliiocontreras
7becb37f58 fix(install): decode git --exec-path as UTF-8 so a non-ASCII profile repairs
`Test-PinnedGitHttpsReady` captures `git --exec-path` through `Invoke-Native`
without `-Utf8Output`. Windows PowerShell 5.1 decodes a captured native
stdout with the console code page while git writes that path as UTF-8, so
on any host whose profile name is not ASCII the returned path is mojibake
and `Test-Path` fails on a perfectly good tree. The gate then calls every
healthy pinned git incomplete: `Get-PinnedGit` re-downloads and re-extracts
PortableGit, the post-extract check fails the same way, the fresh tree is
removed, and the bootstrap dies with "pinned git extracted without
git-remote-https" -- an error that blames the download for a decoding bug.

Reproduced on this host (Windows 11, OEM CP850, accented profile path):
the probe returns False against the pinned tree that git itself runs from,
and the bootstrap logged `stage=prerequisites state=Failed
error=pinned git extracted without git-remote-https` twice, ~51s per
attempt spent re-downloading and extracting. `Invoke-Native -Utf8Output`
is the seam the bootstrapper already uses for `uv python find`; with it the
probe returns True and the existing tree is reused instead of replaced.

`scripts/tests/test-install-ps1-utf8.ps1` gains the regression: the native
fixture answers `--exec-path` with UTF-8 bytes, and the gate must still
resolve a tree under the non-ASCII fixture profile on every code page the
suite drives (936, 437, 65001). It fails on the base with "pinned git gate
survives the code page: expected 'True', got 'False'".
2026-12-01 02:35:12 -08:00
Teknium
6ebcaaed94 ci: route sqlite_support to the upgrade E2E lane, the post-update guard now imports it
The guard checks the restored state.db holds every snapshot table on a read-only
connection built with sqlite_support.read_only_db_uri.
2026-12-01 01:57:03 -08:00
Teknium
2629fc5452 ci: route the post-update guard's new imports to the upgrade E2E lane
update_cmd_maint now imports hermes_cli/backup_atomic (fsync of the kept
state.db copy) and gateway/runtime_ownership (the reservation held across
copy + restore); a change to either must start the upgrade journey suite.
2026-12-01 01:57:03 -08:00
Teknium
6c5b74c30a test(whatsapp): stub fetchLatestWaWebVersion in the bridge auth and passkey tests
The bridge now imports fetchLatestWaWebVersion from Baileys, so the
fake Baileys module these two tests load must export it too.

Co-authored-by: ivanarifin <111653938+ivanarifin@users.noreply.github.com>
2026-11-30 23:32:17 -08:00
Hayden
0f30988f2b fix(whatsapp): connect with the newest WhatsApp Web build any source reports
fetchLatestBaileysVersion() reads a JSON file in the Baileys repo that is
only bumped by a commit; it last changed on 2026-07-26 and still answers
2.3000.1043857760 with isLatest: true. Once WhatsApp stopped accepting that
build, every connect closed with 405 while the fetch kept "succeeding", so
linked bridges dropped and never came back.

The resolver now asks fetchLatestBaileysVersion() and
fetchLatestWaWebVersion() (web.whatsapp.com) at once, each bounded by the
existing timeout, ignores isLatest: false answers (the bundled build the
fetchers return on failure), and uses the highest version. The cache keeps
the newest build seen, so a round where only the older source answers does
not step back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 23:32:17 -08:00
BearHuddleston
fe7c80173c fix(releases): close the ranged response before its slot is released
4069fc9509 moved conn.close() inside the ranged slot, but a
`Connection: close` response owns the socket once getresponse()
returns: http.client closes the connection's reference and the
response's file keeps the socket open. conn.close() therefore left an
unread body open after the slot was released. This happens on the
chunk-0 probe that got a 200 and on any error status such as a 503
retry. The frame still referenced the response, so the socket stayed
open through the retry sleep while another worker took the slot.

Both ranged fetches now close the response, then the connection, in
_close_inside_slot() before the slot is released.

Test: test_ranged_slot_outlives_every_socket_opened_under_it records
each socket a thread opens under a slot and checks, in that thread and
before the slot is released, that every one is closed. It runs over
HTTP/1.0 and HTTP/1.1 keep-alive, with a chunk-0 200 and with a part
that answers 503 once. The two HTTP/1.0 cases fail on 4069fc9509 and
pass here. The HTTP/1.1 cases catch a close moved after the slot
release in either fetch.
2026-11-30 15:28:27 -08:00
BearHuddleston
f43d80f804 fix(releases): make ranged R2 opt-in and fix slot pool cancel/lifetime handling 2026-11-30 15:28:27 -08:00
BearHuddleston
62eaace7d4 fix(releases): keep concurrent archive_inputs single-stream and cap ranged R2 slots 2026-11-30 15:28:27 -08:00
BearHuddleston
0fc912ddb8 refactor(releases): drop the imports the inspector move left unused
io and zlib moved to scripts/bundles/msix_autoupdate.py with the inspection; release_artifacts.py no longer uses either.
2026-11-30 15:13:20 -08:00
BearHuddleston
298160821b fix(releases): record windowsAutoUpdate from the bundle job's inspection
The candidate-manifest job downloads only metadata-*.json, never the
multi-GB per-arch bundles, so assemble() never had the bytes it inspected
and a real release recorded no windowsAutoUpdate (Greptile P1).

The Windows bundle job now inspects the signed per-arch bundles it just
built (scripts/bundles/msix_autoupdate.py record) and stages their
uap13:AutoUpdate facts as windows-autoupdate.json in the
windows-universal receipt, keyed by each bundle's sha256. The candidate
job fetches that file with the metadata; assemble() reads it like
metadata (digest-checked against the receipt, never published) and
records windowsAutoUpdate only when each arch's entry carries the
receipt's own digest for that bundle and its facts match this release's
feed, bundle URL, identity, publisher, version and arch. A build with no
per-arch pair stages no verdict, and an older handoff without one
records nothing.

The red/green test runs the workflow's real staging step against a
loopback R2, then stable.main(["candidate-manifest"]); on the previous
head it fails with KeyError: 'windowsAutoUpdate'.
2026-11-30 15:13:20 -08:00
BearHuddleston
0c02ef3364 fix(releases): reject MSIX parts in a codec MakeAppx never uses
MakeAppx stores or deflates every part of a bundle and of its nested
packages. The inspector still handed any other codec to zipfile, so an
LZMA part with a corrupt stream raised lzma.LZMAError out of
bundle_carries_sideload_autoupdate() and aborted assembly, the same
class the previous commit closed for deflate.

Rather than add a handler per codec MakeAppx never uses, return False
when any part of the outer bundle or the nested package uses a method
other than STORED or DEFLATED. An unsupported method id now stops
there too, so the except comment no longer lists it.

Two new cases (a corrupt LZMA bundle manifest, a corrupt LZMA nested
manifest) fail on the previous head with LZMAError; mutants that drop
either check or admit LZMA are each caught.

Found by the Sol review of 5313413 (S10).
2026-11-30 15:13:20 -08:00
BearHuddleston
6ffcd4408d fix(releases): return False, not raise, when a nested MSIX can't be read
bundle_carries_sideload_autoupdate() promises a False verdict on any
malformed ZIP or XML, and assemble() treats that verdict as advisory: a
bundle that fails inspection omits windowsAutoUpdate. Its except tuple
missed most of what zipfile and expat raise on bad bytes, so those
inputs aborted candidate assembly instead:

- a corrupt deflate stream in a member: zlib.error
- an unsupported compression method or an encrypted member:
  NotImplementedError / RuntimeError
- a member name flagged UTF-8 that isn't: UnicodeDecodeError
- an XML encoding declaration expat can't read: LookupError (unknown)
  or ValueError (multi-byte)

Catch those families (RuntimeError, ValueError and LookupError cover
NotImplementedError, UnicodeDecodeError and the old KeyError) alongside
the existing OSError, BadZipFile and ParseError. Programming errors
(TypeError, AttributeError) still surface.

The new parametrized test feeds one crafted nested package per case;
six fail on the previous head, each with its exception, and the
malformed-XML case pins ParseError. Dropping any one type from the
tuple fails its case (8 of 9 mutants caught; the survivor removes the
pre-existing OSError, which no test reaches). A size field running
past the archive end is BadZipFile ("Overlapped entries") on 3.11.15
through 3.14, so EOFError is not added.

Found by the Sol review of ebdb8b1 (S8).
2026-11-30 15:13:20 -08:00
BearHuddleston
b8f6c7fa7e fix(releases): give commit claims no windowsAutoUpdate instead of failing assemble()
A commit claim runs the stable pipeline on its own commit.<stamp>-vX.Y.Z
tag, and stage-msixbundle.mjs plans both per-arch bundles for every tag,
so its windows-universal handoff lists them. assemble() then reached
release_channel(tag), which raises for commit tags ("Commit builds
publish to no release channel"), and the whole candidate manifest
failed. It raised before the is_file() check, so it did so even though
no bundle bytes are on disk in the real candidate-manifest job.

A commit claim publishes to no channel, so there is no feed to inspect
its bundles against: skip the inspection and record nothing.

The new test assembles a commit claim whose bundles are bound to the
stable feed; it fails on the previous head with that ValueError and
passes on the PR base cfecf78752. The existing assemble test's staging
helper moves to module level so both tests share it.
2026-11-30 15:13:20 -08:00
BearHuddleston
30fb992048 fix(releases): resolve OPC percent-encoded inner MSIX names in uap13 inspection 2026-11-30 15:13:20 -08:00
BearHuddleston
7742cb06fd refactor(releases): narrow #161853 to inspection-only uap13 verification (PR 8a)
Decouple static uap13:AutoUpdate inspection and manifest recording (PR 8a) from primary-download alias/label promotion (PR 8b) and post-stable user docs (PR 8c) per unanimous council plan:
- Tighten bundle_carries_sideload_autoupdate() to enforce exact http://schemas.microsoft.com/appx/manifest/uap/windows10/13 namespace, whitespace-delimited IgnorableNamespaces token membership for the bound prefix, and exact universal MainBundle/@Uri.
- Keep assemble() recording digest-bound windowsAutoUpdate in release-candidates.json when both x64 and arm64 pass.
- Defer has_verified_windows_autoupdate(), StableDownloads alias promotion, r2.py protection, downloads_page.py label flips, and website/docs/ updates out of PR 8a.
2026-11-30 15:13:20 -08:00
BearHuddleston
c58c0e09b3 feat(releases): promote uap13-verified single-arch .msixbundle as primary stable Windows download
Promote unversioned stable single-architecture Windows .msixbundle aliases (releases/win32/stable/HermesBundled-win-x64.msixbundle and HermesBundled-win-arm64.msixbundle) alongside stable.appinstaller ONLY when the candidate carries an exact-digest windowsAutoUpdate attestation verified inside each nested .msix.

Key changes:
- scripts/bundles/release_artifacts.py: add bundle_carries_sideload_autoupdate() inspecting each single-arch .msixbundle's AppxBundleManifest.xml + nested .msix AppxManifest.xml <uap13:AutoUpdate> + embedded Update.appinstaller (exact channel feed URI, identity, publisher, version, <OnLaunch>); record digest-bound windowsAutoUpdate in assemble(); extend StableDownloads to server-side copy and HEAD-verify both stable per-arch aliases only when exact-digest attested (unbound/historical candidates never overwrite the aliases).
- scripts/releases/r2.py: add channel_msixbundle_key_for() and protect both stable per-arch aliases in prune().
- scripts/releases/downloads_page.py: upgrade Windows rows from manual label to primary MSIXBUNDLE only when has_verified_windows_autoupdate(manifest) passes.
- website/docs/: document single-arch .msixbundle as primary sideload Windows download (keeping .appinstaller as fallback) and document the unversioned stable aliases.

Held as Draft pending Win11 x64 + ARM64 CI-signed canary proof of no-click OS OnLaunch updates and channel-switch survival after #161817 lands.
2026-11-30 15:13:20 -08:00
BearHuddleston
6ff9f2707a perf(releases): parallelize large R2 downloads with ranged 206 transfers 2026-11-30 12:55:51 -08:00
alt-glitch
3bb8a40b45 refactor(tools): an explicit list of tool modules replaces the folder scan
discover_builtin_tools() imports the modules named in
tools.registry._TOOL_MODULES, in that order, each inside the same try as
before: a module that fails to import is logged and skipped, and the rest
still register. The safe worker still loads only its three modules. The list
is today's scan result in today's order, 38 modules.

Gone with the scan: the AST parse of every tools/*.py at startup, its verdict
cache in HERMES_HOME/cache/tool_discovery_cache.json (an existing file is left
alone and no longer read), the skip set NOT_TOOL_MODULES, which no release
shipped, and the tools_dir parameter, which only tests of the scan passed.

scripts/check_tool_discovery.py now compares the list with the tracked files
under tools/ that call registry.register() at their top level, and fails on
either difference. It reads the list from the text of tools/registry.py and
holds the predicate itself, so the guard imports no application code. A listed
module inside a package must be <pkg>/tool.py in a package with an __init__.py.

Adding a built-in tool is now three edits: the tool file, its name in
_TOOL_MODULES, and its toolset. `just check` names a tool file that is missing
from the list.
2026-11-30 23:20:42 +05:30
alt-glitch
ee18cbb700 ci(routing): a change to gateway/systemd_scope.py starts the upgrade suite
hermes update --force imports the scope stop from the new file, so the change classifier owns it for the upgrade lane, as it owns the registry file.
2026-11-30 22:05:04 +05:30
alt-glitch
ec8f28f684 fix(code-health): modules folded into one file keep their caps and violations
The ratchet read a move as one old file becoming one new file. When several
modules are folded into one, each with its own MOVES key, two things read as
new code:

- A line that names the new module was spelled back as the first key only, so
  an import that had named one of the other old modules no longer matched its
  base line. Every old name of the file is now spelled as the first one, on
  both sides.
- An old module that leaves a generated file at its path was dropped from the
  comparison as generated, so the functions that moved out of it had no base
  unit to match. Such a file now reads as deleted.

A fold of tools/ modules otherwise fails PLC0415 once per function-level import
it only renamed.
2026-11-30 21:57:17 +05:30
alt-glitch
f28a67ffcb fix(move): a generated old-path file run as a script drops its own folder from sys.path
Some checks failed
Deploy Site / deploy-vercel (push) Has been cancelled
Deploy Site / deploy-docs (push) Has been cancelled
auto-fix lint issues & formatting / Generate eslint --fix patch (push) Has been cancelled
auto-fix lint issues & formatting / Apply patch (push) Has been cancelled
Skills Index Freshness Check / check-freshness (push) Has been cancelled
Skills Index Freshness Check / check-catalog-cors (push) Has been cancelled
Docs Search Monitor / probe (push) Has been cancelled
Build Skills Index / build-index (push) Has been cancelled
Build Skills Index / trigger-deploy (push) Has been cancelled
Run as `python tools/<name>.py`, Python puts tools/ first on sys.path. The
generated file put the checkout root in front and left tools/ behind it,
so the moved module it runs as __main__ imported tools/mcp/ in place of
the installed mcp package. The file now removes its own folder before it
adds the root. An import, a -m run and an isolated (-I) run are unchanged.
2026-11-30 21:40:07 +05:30
alt-glitch
54b7f79902 fix(code-health): a from-import with no space before its parenthesis is read too
The pattern required whitespace after the word import, so import(value) kept its module in the compared line.
2026-11-30 20:19:02 +05:30
alt-glitch
355291e998 fix(code-health): an import that follows a name to another module is not new
The ratchet compares code line by line, so a function-level import that
only names a different module read as a new import. Splitting a file
moves names to a new module, and every caller that imported one of them
inside a function then failed PLC0415 for an import it already had.

Lines are now compared with the module of a `from` import left out: the
same names imported in the same place are the same import. A further
name imported there is still new.
2026-11-30 20:19:02 +05:30
alt-glitch
254349e445 refactor(xai): x_search and the xAI video tools register from the xAI plugins
The xai_video_edit and xai_video_extend tools move from tools/xai_video_tools.py into the xAI video
plugin (plugins/video_gen/xai/__init__.py). The x_search tool moves from tools/x_search_tool.py to
plugins/web/xai/x_search.py and is registered by the xAI web plugin. Both plugins register the tools
through ctx.register_tool, with the same names, toolsets, schemas, availability checks, required
environment and emoji. The tool list and every tool schema are unchanged.

A user can notice two differences. A call that leaves out prompt or query now gets the handler's own
error ("query is required for x_search") instead of core's generic missing-argument refusal, which
applies only to tools whose handler lives under tools/. Disabling the video_gen/xai or web/xai plugin
now also removes that plugin's tools.

x_search drops max_result_size_chars=100_000: the result budget is capped at that value already, so
the field changed nothing. The video tools drop self_checked_args, which only affects tools under
tools/. The boundary-lint baseline loses the core-to-plugin import that tools/xai_video_tools.py
made.
2026-11-30 19:41:40 +05:30
alt-glitch
0a5e1935b5 refactor(xai): credentials go to hermes_cli/auth_xai.py and Imagine storage to the image plugin
tools/xai_http.py held three unrelated things and is gone. The xAI credential
resolver and the cheap credential probe now live in hermes_cli/auth_xai.py beside
the rest of xAI sign-in, and plugins may import both: they join the published
plugin API. Callers that sent the xAI User-Agent use hermes_user_agent("Hermes-Agent"),
which gives the same header. Imagine storage options and the one-time storage
notice live in plugins/image_gen/xai/storage.py, which the video plugin imports.
The video_generate tool no longer names xAI: a video backend may return
description_notes from capabilities(), and the xAI backend supplies its chaining
and storage lines that way, so the description text is unchanged.
2026-11-30 19:41:40 +05:30
BearHuddleston
3d30adf954 fix(bundles): trim the arm64 PortableGit's git-doc tree too
Git for Windows builds the x64 PortableGit under ucrt64/ and the arm64
one under clangarm64/ (build-extra make-file-list.sh maps aarch64 to
MSYSTEM_LOWER=clangarm64). The pinned PortableGit-2.56.1-arm64.7z.exe
keeps its 1,162 Git doc files in clangarm64/share/doc/git-doc and has no
ucrt64/ at all, so the allowlist matched only the Vim tree there and the
win32-arm64 MSIX kept every Git doc page.

Allowlist clangarm64/share/doc/git-doc beside the ucrt64 path. The trim
test now runs both layouts; the arm64 case removed 2 of 4 files before.
2026-11-30 05:37:22 -08:00
BearHuddleston
e9f8f4bfbc perf(bundles): drop the duplicate tool-digest pass after the PortableGit trim
The Windows staging step refreshed every tool digest in facts.json right
after trimming PortableGit, then record_tools() hashed every selected tool
again a few lines later. Git is in record_tools' selection on win32-x64 and
win32-arm64, it writes the same out/tools/facts.json, and nothing between
the two reads a digest (_arch_guard only probes binaries), so the first pass
hashed every staged tool tree for nothing.

Drop the refresh. The trim test now publishes through record_tools from a
facts.json seeded with the untrimmed digest, so it pins the step the
pipeline relies on: a record_tools that kept the staged digest fails it.

Raised by Greptile on #161818.
2026-11-30 05:37:22 -08:00