Commit Graph

3390 Commits

Author SHA1 Message Date
Maciej Lisiewski
bdc5ecd808 Merge pull request #157620 from NousResearch/salvage/154883-run-tests-named-account-store
fix(tests): keep faked-HOME test runs off the account's tool store
2026-11-19 14:30:16 +01:00
Maciej Lisiewski
cd60f7f25d fix(tests): refuse, with the right cause, a faked-HOME store path readlink cannot read
A failing readlink already refused the run, but no test pinned it (dropping the '|| return 1' let resolution continue from the link's parent), and the refusal blamed a link loop.
2026-11-19 13:05:24 +01:00
Maciej Lisiewski
5637797202 fix(tests): read link targets and store paths byte-exact on BSD readlink
macOS/FreeBSD readlink (stat.c) only appends its newline when the target
does not already end in one, so stripping one LF after $(...; printf x)
turned a link to 'x<newline>' into 'x' there: the macOS tests job failed
test_link_target_ending_in_a_newline_is_followed_as_named. Read the target
with readlink -n (GNU, BSD and busybox all take it) and strip only the
sentinel. The same $(...) capture dropped a resolved store's own final
newline in _avoid_account_stores; sentinel those too.

setup-hermes.sh stages its bootstrap uv into $HOME/.hermes/tools before pm
runs, so with that path linked to the account's store and HERMES_HOME
selecting another, the staging wrote into the account's store. Point
HERMES_RUNTIME_DIR at the store pm resolves in that case.

Co-authored-by: BearHuddleston <196404565+BearHuddleston@users.noreply.github.com>
2026-11-19 13:05:24 +01:00
BearHuddleston
b059196c59 docs(ci): fix inaccurate Linux diagnostic and glibc floor comments
- `scripts/render-builds-table.py`: drop "until smoke-tested" since
  `_UNLISTED_OS` hides Linux rows unconditionally.
- `.github/workflows/desktop-bundled-release.yml` and
  `scripts/bundles/glibc_floor.py`: name `glibc_floor.EXCEPTIONS` for the
  x64 CUDA and ROCm engines (GLIBC 2.38 / GLIBCXX 3.4.32) and state the
  glibc >= 2.38 requirement rather than Ubuntu 24.04+.

Review: https://github.com/NousResearch/hermes-agent/pull/154545#discussion_r4625655929
Review: https://github.com/NousResearch/hermes-agent/pull/154545#discussion_r4625655940
Review: https://github.com/NousResearch/hermes-agent/pull/154545#discussion_r4625655945
2026-11-19 02:35:54 -06:00
BearHuddleston
8c9be67bd5 fix(ci): verify x64 AppImage header and digest inside the CI acceptance worker
Previously `scripts/bundles/linux_appimage_acceptance.py` held the x86-64
type 2 AppImage header + SHA-256 check (`check_image`), but CI ran
`scripts/bundles/appimage_checks.py` directly via
`scripts/ci/linux_x64_userland.sh accept` without the header check, leaving
`linux_appimage_acceptance.py` unused outside its own test import.

Move `check_image` into `scripts/bundles/appimage_checks.py`, invoke it in
`main()` before `--appimage-extract`, forward the producer digest from
`scripts/ci/linux_x64_userland.sh accept`, update `appimage_checks.py`'s
docstring, and drop the duplicate bubblewrap launcher.
2026-11-19 02:35:54 -06:00
BearHuddleston
39ddddb932 refactor(bundles): derive x64 pre-staged GPU tools from Package.minimum_glibc
`scripts/bundles/native.py::_tools_for_builder` and
`scripts/bundles/stage_x64_gpu.py` previously repeated the
`("llamacpp-cuda", "llamacpp-hip")` tuple already declared via
`Package.minimum_glibc` on `LlamaCppCuda` and `LlamaCppHip`.

Filter by `get_package(name).minimum_glibc.get(target)` in both places so
`Package.minimum_glibc` is the single declaration, and add a contract test
in `tests/scripts/test_bundle_glibc_floor.py` pinning `glibc_floor.EXCEPTIONS`
to `Package.minimum_glibc` while keeping `glibc_floor.py` stdlib-only.

Review: https://github.com/NousResearch/hermes-agent/pull/154545#discussion_r4625655955
2026-11-19 02:35:54 -06:00
BearHuddleston
9c15b7cf2c fix(ci): run the x64 floor desktop check with Chromium's sandbox
The Ubuntu 22.04 acceptance container drops every capability and keeps
Docker's default seccomp profile. That profile refuses clone and unshare
with namespace flags without CAP_SYS_ADMIN, and chroot without
CAP_SYS_CHROOT. AppRun's `unshare -Ur true` probe therefore failed and it
launched Electron with --no-sandbox. The window and gateway checks still
passed, so the floor check accepted a desktop running without the
Chromium sandbox, which a 22.04 desktop with user namespaces never does.

The 22.04 run now uses moby/profiles seccomp v0.1.0's default.json
(Docker 29's builtin profile), unchanged, plus two rules appended. Its
upstream sha256 is
01536f1d1df938ae611eba20d6349e0de7a99b6ecdee1549427a0b01b8301e28.
clone and unshare may
create user, PID and network namespaces; mount, UTS, IPC and cgroup
namespaces stay refused. chroot is allowed, which needs a capability
only Chromium's own user namespace grants. --cap-drop ALL, --network
none and the non-root user are unchanged. The 24.04 run, which doesn't
start the desktop, keeps Docker's default.

check_execs now refuses any successful exec that carries --no-sandbox.
That covers AppRun's fallback and the app's own sandbox relaunch.
check_desktop fails first, naming the cause, when the container can't
create a user namespace.

On spark-0 (Ubuntu 24.04 arm64 host, apparmor_restrict_unprivileged_userns=1,
Docker 29.2.1), an Electron 44.9.3 arm64 AppImage was launched under the
leg's container flags in ubuntu:24.04:
- Docker's default profile: AppRun added --no-sandbox, and the window
  and gateway still came up.
- This profile: no exec carried --no-sandbox. The sandboxed zygote and
  the renderer ran in their own user namespace (uid_map 1000 1000 1)
  and nested PID namespaces. The real check_desktop accepted the run.
- Without the chroot rule: no window within 380 s.
- check_desktop under Docker's default profile: refused with the
  user-namespace cause. With that precondition bypassed, it refused
  the trace instead: "Chromium ran without its sandbox".
Not run: the x64 AppImage and the Blacksmith runner.

Review: https://github.com/NousResearch/hermes-agent/pull/154545#discussion_r4623972093
2026-11-19 02:35:54 -06:00
BearHuddleston
39c1fea47d fix(ci): select the Linux bundle userland outside the Actions shell field
Actions rejects matrix expressions in step.shell before any job starts. Give the four shared steps a literal shell and select their existing x64 container or native arm64 Bash via the matrix label in job env.
2026-11-19 02:35:54 -06:00
BearHuddleston
06c0b83444 fix(desktop): build the x64 AppImage on Jammy and stage its GPU engines on Noble
Verify locked CUDA and ROCm payloads on Ubuntu 24.04; refuse to select or execute them below their ABI floor. Build the desktop on Ubuntu 22.04 with a pinned bootstrap interpreter and check desktop startup, offline CPU inference and both packaged GPU probes against one producer digest.
2026-11-19 02:35:54 -06:00
BearHuddleston
cdca5cca57 fix(bundles): account for packed relative relocations in the glibc floor 2026-11-19 02:35:54 -06:00
BearHuddleston
71cebffa7e fix(bundles): reject short files with a complete ELF signature
A truncated identification header was counted as a non-ELF and let the audit succeed. Keep ignoring non-ELF files, but count and name a short ELF as unreadable.

Co-authored-by: Mark S. <274530371+unsupportedpastels@users.noreply.github.com>
2026-11-19 02:35:54 -06:00
BearHuddleston
f23af6fd92 fix(bundles): fail the glibc audit on an ELF whose needs it can't read
An ELF with no section table returned no requirements, so a dynamically
linked executable stripped of its section headers counted as checked
while the loader still enforced its needs through the dynamic segment.
That case is now a named failure. A truncated or malformed ELF, which
crashed the audit with a traceback naming no file, is reported the same
way and the scan goes on to list every other problem.

Failing closed is enough today: none of the 686 ELF files in the
packaged arm64 app lacks section headers.
2026-11-19 02:35:54 -06:00
BearHuddleston
469d6c1e72 fix(release): keep diagnostic Linux AppImages off the download tables
The builds table lists every table-shaped object under releases/tag/<tag>/,
and it already knew the AppImage name shape, so a staged Linux AppImage
would become a download row in the canary release body and on the canary
downloads page. These builds have no smoke and no update path yet, and the
AppImage's gateway still runs from its per-launch mount, so the table
leaves them out (_UNLISTED_OS) while they stay in the tag archive.

The commit page's Linux rows said "Disabled (release leg disabled)" and
the smoke note said Linux bundles are disabled; both now say what is true:
commit builds skip Linux, and Linux AppImages are not install-smoked.
2026-11-19 02:35:54 -06:00
BearHuddleston
1b8bfaa72e fix(release): report the Linux desktop builds without gating releases
publish-canary required build-linux-x64 and build-linux-arm64 to succeed,
the builds table's release gate required every need to succeed, and the
canary controller rechecked both Linux jobs. That was harmless while the
Linux jobs were echo-only dummies, but a real Linux build that fails would
leave every canary release a draft, exactly as a failed Termux .deb does.

Linux builds are diagnostic until they have proven themselves green, so:

- scripts.releases.job_groups.DIAGNOSTIC_JOBS names the two Linux builds and
  gating_jobs() drops them from a needs list.
- The builds table still needs the Linux builds and receives their results,
  but its release gate requires only gating_jobs(needs), and the renderer
  no longer counts a diagnostic job as incomplete, so a failed or skipped
  Linux build neither blocks publish-canary nor holds back the channel's
  downloads page.
- publish-canary no longer needs the Linux builds or requires the
  linux-x64/linux-arm64 groups to be selected; channel_releases.CANARY_NEEDS
  drops them to match.

Making Linux gating later is emptying DIAGNOSTIC_JOBS and restoring the
publish-canary needs and conditions. The darwin/win32 feeds, stable and
channel publication never depended on the Linux jobs.
2026-11-19 02:35:54 -06:00
BearHuddleston
afb03ddd2d feat(bundles): audit a packaged Linux app against its glibc floor
A Linux desktop bundle runs only where the host's glibc and libstdc++
provide every symbol version its ELF files need, so one library built on a
newer distribution silently drops support for every older one.

scripts/bundles/glibc_floor.py reads each ELF file's .gnu.version_r
(no readelf dependency) under electron-builder's unpacked app and fails when
anything needs more than the arch's floor:

- x64: GLIBC_2.35 / GLIBCXX_3.4.30 (Ubuntu 22.04, Debian 12)
- arm64: GLIBC_2.39 / GLIBCXX_3.4.33 (Ubuntu 24.04, Debian 13)

The x64 llama.cpp CUDA and ROCm engines get their own ceiling
(GLIBC_2.38 / GLIBCXX_3.4.32): upstream builds them on Ubuntu 24.04
(b12144 measured at exactly that), so those two engines run only on 24.04
and newer.

Checked against readelf -V on all 686 ELF files of a real arm64 build
(3,325 version names, no differences): it passes the arm64 floor and fails
the x64 floor on the arm64 llama.cpp engines (GLIBC_2.38) and the
sdist-built _libolm (GLIBCXX_3.4.32).
2026-11-19 02:35:54 -06:00
Teknium
27896fd2cd fix(dev): hooks find hoisted lefthook installs and set up the environment only for a matched job
scripts/run-lefthook now searches the hoisted node_modules layouts the generated hook
searches (npm, pnpm --node-linker=hoisted), in this tree and the clone's main checkout,
and only execs lefthook. The jobs call `{just}` (scripts/hook-just), which falls back to
scripts/run-in-hermes-env only once lefthook has matched staged files to the job, so a
commit no job matches never runs, or fails on, environment setup.

Tests: hoisted lookup, main-checkout lookup from a linked worktree, the no-`just` job
path, and a real docs-only commit without `just` that never reaches setup.
2026-11-18 20:35:04 -08:00
Teknium
61f57070a0 fix(dev): git hooks never fall back to uv run, so a commit cannot re-point another checkout's venv 2026-11-18 20:35:04 -08:00
Maciej Lisiewski
c3f28b98b9 fix(tests): keep a link target's own trailing newline when following it
$(readlink) drops every trailing newline, so a link to 'x<newline>' was
followed to a sibling 'x' that pm's Path.resolve() never visits.
2026-11-19 00:57:30 +01:00
Maciej Lisiewski
d8841d7f5c fix(tests): follow every symlink and read relative stores from the checkout
pm reads HERMES_RUNTIME_DIR with Path.resolve(), which follows dangling links
too, and setup-hermes.sh reads it (and HERMES_HOME) after cd'ing to the
checkout. The runner kept dangling links literal and read relative values from
the caller's directory, so both could still name the account's store unseen.
2026-11-19 00:57:30 +01:00
Maciej Lisiewski
a21108f3b7 fix(tests): read store paths as pm does and only guard runs that reach setup
pm takes HERMES_RUNTIME_DIR through Path.resolve(), which collapses a `..`
after a missing component lexically; `-ef` stats the literal path, so
`<account store>/missing/..` was not recognised and setup provisioned the
account's store. HERMES_DATA_DIR_SUFFIX is appended literally (hermes_constants)
so a `/../..` suffix walked the faked home's fallback back into it the same way.
Every compared path is now resolved like Path.resolve() first.

The store check ran before the HERMES_PYTHON / current-activation branch, so a
run that never provisions anything was refused when no bootstrap Python could
answer. It now runs only on the path that re-executes into setup.

The refusal also said "no bootstrap Python" when pm itself failed to resolve
the store; it now names the actual reason.
2026-11-19 00:57:30 +01:00
Maciej Lisiewski
38d45192a1 fix(tests): refuse a faked-HOME run that cannot keep off the account's tool store
The redirect to the faked home's own store trusted three things it never
checked: that $HOME/.hermes/tools is not itself a link into the account's
store, that the account's store is only ~/.hermes/tools (HERMES_DATA_DIR_SUFFIX
selects ~/.hermes<suffix>), and that a bootstrap Python exists to ask pm. Each
let setup provision the account's store anyway.

Compare the fallback by identity and refuse when it is the account's store,
protect the suffixed store too, recognise an explicit HERMES_RUNTIME_DIR
without Python (pm takes it verbatim), and refuse when no interpreter can
tell which store pm would pick: setup would fetch its own and provision it.
2026-11-19 00:57:30 +01:00
Teknium
c3edbe7c33 fix(tests): a faked-HOME run that names the account's tool store no longer re-stages it
run_tests.sh already refuses to share the OS account's tool store with a
faked-HOME run unless that store records the checkout's pins, because
facts.json selects one entry per package and provisioning other pins
re-points the account's own runtime. The check only ran when the runner
picked the store itself. A run that named the store reached pm with no
check at all:

- HERMES_RUNTIME_DIR=<account>/.hermes/tools, the recipe lanes used before
  the runner shared by itself, and
- an inherited HERMES_HOME=<account>/.hermes, which an agent's shell
  exports, so pm resolves <account>/.hermes/tools under the faked HOME.

Either way `pm install --test-environment` re-downloaded and re-staged the
checkout's pins (Chromium included) over the ones the account's Hermes
runs on. On a dev host whose gateway checkout pins chromium 1208 while
origin/main pins 1248, every worktree test run flipped facts.json, and
browser_exec in the gateway failed with "Chromium is not installed: run
`hermes pm install chromium`" while both builds sat in the store.

The runner now asks pm's own resolver which store this run would
provision. When that is the account's store and it records other pins,
the run provisions the faked home's own store instead and says so. A
named store at the checkout's pins is used as before, and so is any other
explicit store.
2026-11-19 00:57:30 +01:00
BearHuddleston
b82eee3030 fix(ci): run the tree-wide lint guards on every pull request
The no-tmp, shebangs and agents-md guards scan files of every lane:
catalog YAML, docs, TypeScript, frontend AGENTS.md files. lint.yml gated
them on detect's python lane, so a PR that changed only such files never
ran them, and main's push was the first run to report the finding. Since
November 7 five catalog entries landed a literal /tmp on main that way,
each followed by a fix commit: safe-swap (894544abd5 -> 1c7a475adb),
no-cap (aa078949dd -> a55a299b65), afterimage (d6ab9f5b9e -> #153055),
sentinel-governance (0e5409abe7 -> 778dc708c2) and memtomem (#152338,
e93b3da9a8 -> #157206).

They now run as unconditional steps of repo-guards.yml, which runs on
every event, beside the other stdlib-only tree scans. The scripts and
their arguments are the ones `scripts/check --only <name>` runs.

tests/ci/test_tree_guard_routing.py replays the real classifier's lanes
for a one-file diff through ci.yaml and the workflows it calls, and
requires each guard to run exactly once. On the old workflows a catalog,
frontend, frontend AGENTS.md or docs-site diff ran each guard 0 times;
a Python diff ran each once.
2026-11-18 11:02:20 -06:00
Teknium
95038c9bcd Merge pull request #151855 from NousResearch/refactor/storage-remove-sessiondb
refactor(storage)!: SessionDB and the hermes_state modules removed, with a stand-in for outside plugins
2026-11-17 10:48:47 -08:00
Teknium
5ebfa750c5 Merge pull request #149567 from NousResearch/refactor/storage-callers
refactor(storage): every caller on the storage interface
2026-11-17 10:46:06 -08:00
yoniebans
2d672a0098 fix(ci): the backend import guard lists the store open's home binding with its reason
A store opens under its own profile folder as the Hermes home, so the connection settings it reads at open are that profile's. The binding compares the store's folder with the current home first, a home read the guard refuses unless it is listed with its reason; it is listed now.
2026-11-17 19:10:58 +01:00
yoniebans
be3d6affc8 refactor(state)!: remove the old session store
hermes_state.py becomes the stand-in plugins import, the rest of the legacy store and its test folder go, and the per-process modules the backend imported from main move under persistence/sqlite/_state/. The backend checks PID namespaces and lease holders through process_identity and its WAL setup through sqlite_support, and its error module takes the shared predicates and classification from storage_errors, so neither helper set has a second copy. The backend, sqlite_support.py and the tests that pin those modules reach their final imports, and the backend-import guard allows no file outside persistence/. The modules no caller imports any more go with it: the agent's onboarding rules (now in session_rules) and gateway/session_admission.py.

The stand-in's SessionDB releases its store on close() and, used again afterwards, opens it again with a warning, as the old class reopened its connection, unless the file at its path was replaced or the store is latched corrupt; a read-only one raises. A close during a call releases the store when the call returns. A named source wins over a source list in its session listing and count.

An agent given a writable stand-in SessionDB as session_db= and no persistence= takes the store handle that SessionDB forwards to as its persistence, so its turn flush, token counts, compression and session row writes go through the storage interface, as an agent given the old SessionDB wrote through it.

The backend-import guard also holds the backend's remaining reads of the process or task home, each with its reason, and refuses any other and any import of the stand-in inside persistence/sqlite/.

Plugin context engines get the agent's store as persistence= beside the deprecated session_db=, in each hook whose signature accepts that keyword, including the rebind after /new, /resume and /branch, and the context engine guide and the plugin guide's replacement table name it. A test fails once the running release reaches the stand-in's removal release, listing what goes with the stand-in.

release_unheld_media and collect_unheld_api_images take a store only: their SessionDB branches, which no caller reaches, go with the gateway's own copies of the admission and transcript queries.
2026-11-17 19:10:57 +01:00
yoniebans
dae3565b0f fix(ci): the backend import guard allows the legacy store's loop guard
hermes_state_loop_guard.py wraps the backend holder's _read_ctx and _execute_write (StoreHolder is the store's choke point once SessionDB forwards to it), so it imports persistence.sqlite._holder like the other legacy modules the guard already allows until the removal.
2026-11-17 17:51:23 +01:00
yoniebans
0c4023c030 fix(ci): the backend import guard reads every file that names sqlite
The text prefilter skipped any file without "persistence.sqlite" or "import sqlite" before the AST check, so `from persistence import core, sqlite`, the two-space form and the parenthesised multi-line form a formatter writes passed the guard.
The prefilter now only skips files that never mention "sqlite"; the AST check decides the rest, and the tree stays clean under it.
New guard cases pin the three forms.
2026-11-17 17:51:21 +01:00
yoniebans
d321a00e91 docs(repo): docs, desktop app, skills and native code for the persistence interface
Documentation, the desktop app, skills and native code follow the interface. The published plugin API lists the storage interface names the plugin guide's replacement table gives, so the guide's examples and the bundled plugins that import them stay on the published list.
2026-11-17 17:51:21 +01:00
yoniebans
2f3405ba9c test(evals): evals, end-to-end suites, scripts and CI on the persistence interface
Evals, the end-to-end and conformance suites, scripts and CI reach the store through the interface.

scripts/ci/check_backend_imports.py, run by scripts/check, refuses an import of persistence.sqlite outside persistence/ and persistence_assembly.py (tests excepted). The two evals that instrumented the backend now reach it through the interface: the failure-ownership probe patches the message repository class of the store it opens, and the attachment bench meters whole-blob reads at the gateway attachment store.
2026-11-17 17:51:21 +01:00
yoniebans
3f91a4a43b refactor(tools): tools, ACP, plugins and cron through the persistence interface
Each legacy store call in these areas moves to the interface operation that carries it, with main's errors and values.
2026-11-17 17:51:20 +01:00
Austin Pickett
82e1b4553d docs: remove the legacy /docs/skills and /docs/plugins hub pages
The Hermes Marketplace replaces them and the portal already redirects both
routes there. The published feeds (plugins.json, skills.json, skills-index.json)
and their generators stay.
2026-11-17 11:27:30 -05:00
Austin Pickett
fdc2a21a29 docs: point catalog copy at Marketplace pages instead of /docs/plugins and /docs/skills 2026-11-17 11:27:30 -05:00
Austin Pickett
37b4f9a07a docs(plugin-catalog): stop describing per-entry /docs/plugins pages in field comments 2026-11-17 11:27:30 -05:00
alt-glitch
7c9b019ab5 fix(plugin api): publish hermes_cli.version_info:hermes_user_agent
Eight bundled plugins already build their User-Agent header with
hermes_user_agent: six model providers, the Slack adapter and the
Perplexity web provider. Each was a baselined private import. The name is
now on the published plugin list, with a section in the plugin guide, and
those eight baseline rows go.

The xAI plugins need the same name before tools/xai_http.py can be split:
its hermes_xai_user_agent returns the string
hermes_user_agent("Hermes-Agent") returns.
2026-11-17 15:38:46 +05:30
alt-glitch
67b3025978 fix(feishu): comment agent tools reach the Lark client again
The Feishu comment bot's five tools (feishu_doc_read and the four
feishu_drive_* tools) answered "Feishu client not available" on every call.
feishu_comment stored the Lark client in a threading.local on the thread
that starts the agent, and since ededa8c4f1 the agent runs each tool call
on a worker thread. The worker gets a copy of the caller's context
variables, not its thread-locals.

The client handle is now a context variable in tools/feishu_lark.py, set
and reset by token around the agent run. The handle's row in
gateway/turn_thread_reset.py goes, because nothing is keyed by thread any
more. The bot's reply was never affected: it is posted outside the tools.
2026-11-17 15:36:07 +05:30
alt-glitch
40d1e95f37 refactor(teams): move the Microsoft Graph auth and client into the teams_pipeline plugin
Some checks failed
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
Deploy Site / deploy-vercel (push) Has been cancelled
Deploy Site / deploy-docs (push) Has been cancelled
Build Skills Index / build-index (push) Has been cancelled
Build Skills Index / trigger-deploy (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
Canary Release / Tag, draft, and start the canary build (push) Has been cancelled
Canary Release / Prune canaries older than 14 days (push) Has been cancelled
Live provider canaries / Live provider canaries (push) Has been cancelled
tools/microsoft_graph_auth.py and tools/microsoft_graph_client.py register
no tool and only Teams code imports them, four of six imports from
plugins/teams_pipeline/. They move there as graph_auth.py and
graph_client.py, with their two tests under tests/plugins/teams_pipeline/.

- Importers change one import line where it stands; summary_writer.py
  keeps its imports inside _build_graph_client.
- The Graph client's only core import, parse_retry_after_seconds, is on
  the published plugin API.
- boundary_lint baseline drops the 8 rows for these imports; an import of
  another in-tree plugin is not a crossing (module_to_core 833 -> 825).
- The Graph app registration guide and its zh-Hans copy name the new path.
- Nothing stays at the old paths; neither module is on a frozen list.

Measured: with teams_pipeline disabled, Graph delivery from the Teams
summary writer still works, but its first call now imports the
teams_pipeline package (17 Hermes modules instead of 2), because
plugins/teams_pipeline/__init__.py imports its CLI.
2026-11-17 09:09:45 +05:30
alt-glitch
69cddd08f4 fix(plugin api): publish agent.retry_utils:parse_retry_after_seconds
Plugins that call a rate-limited HTTP API need to read the Retry-After
header. Discord, Signal and Slack already import Hermes's parser as
baselined private crossings, and the Microsoft Graph client needs it to
move into the teams_pipeline plugin.

- plugin_api.json lists the one name; public-api.md is regenerated.
- plugins/index.md gains a short section with the contract and an example.
- boundary_lint baseline drops the three crossings that are now public
  (Discord, Signal, Slack). No other line changes; a full --update would
  also drop two unrelated stale rows, so it was not used.
- Test: a plugin importing the parser validates with no private-import
  warning, while another name from agent.retry_utils still warns. Red on
  main.
2026-11-17 09:09:45 +05:30
alt-glitch
458a0046ad refactor(agent): six checkpoint files move from tools/ to agent/checkpoints/
tools/ holds model tools. These six files register none: they snapshot and
restore a working directory for the agent loop, /rollback, /undo's
changed-files line and `hermes checkpoints`. They move next to the agent
loop that takes the checkpoints:

  tools/checkpoint_manager.py                -> agent/checkpoints/manager.py
  tools/checkpoint_maintenance.py            -> agent/checkpoints/maintenance.py
  tools/checkpoint_pruning.py                -> agent/checkpoints/pruning.py
  tools/checkpoint_refs.py                   -> agent/checkpoints/refs.py
  tools/checkpoint_undo_hint.py              -> agent/checkpoints/undo_hint.py
  tools/checkpoint_manager_profile_rename.py -> agent/checkpoints/manager_profile_rename.py

agent/checkpoints/__init__.py is a docstring only. Nine test files move to
tests/agent/checkpoints/. Every importer changes its import line in place,
inside the same function. Nothing stays at the old paths: none of the six
names is on the plugin API list, the shipped-release list or the
old-updater list.

Behaviour is unchanged. The four loggers keep their tools.checkpoint_*
names, so the lines stay under `hermes logs --component tools`. The folder
is not a root checkpoints/ package because the checkpoint store is
HERMES_HOME/checkpoints, which is the same directory as such a package on an
install whose checkout root is HERMES_HOME. agent.* is already packaged, so
pyproject.toml and the lists of root packages do not change.

The import and docs rewrites were made by scripts/move/rewrite_imports.py
and rewrite_docs.py.
2026-11-16 19:21:55 -06:00
alt-glitch
f8acc26834 refactor(gateway): outbound send files move from tools/ to gateway/outbound/
tools/ holds model tools. These three files register none: they send a
message to a platform for `hermes send` and for cron delivery, through
gateway adapters and gateway config. They move to the gateway package:

  tools/send_message_tool.py    -> gateway/outbound/send.py
  tools/send_message_senders.py -> gateway/outbound/senders.py
  tools/send_message_targets.py -> gateway/outbound/targets.py

Twelve test files move with them to tests/gateway/outbound/. Every importer
changes its import line in place. Nothing stays at the old paths: none of
the three names is on the plugin API list, the shipped-release list or the
old-updater list.

Behaviour is unchanged. The logger name stays tools.send_message_tool in
the three files and in the QQ Bot sender that shares it, so the lines stay
under `hermes logs --component tools`. The boundary-lint baseline changes
12 keys and no count, because its keys carry the module path of the
underscore names five bundled plugins import.

The import and docs rewrites were made by scripts/move/rewrite_imports.py
and rewrite_docs.py.
2026-11-16 18:09:07 +05:30
alt-glitch
23ddc546a7 fix(move): scan files that name only a moved file
The codemod picked the files to read by the old top-level folder name and the old paths. A file that joins a folder variable to a moved file's name mentions neither, so it was never read and its path was never flagged. The names of the files that left a folder that stays are now search words too. For a whole-package move that set is empty and the files read are the same.
2026-11-16 18:09:00 +05:30
alt-glitch
5e53407e2c fix(move): a path joined through a folder variable to a moved file is flagged
When a file leaves a folder that stays, the folder's name no longer counts
as moved, so the only trace of the old place in a join is the file's own
name. rewrite_imports.py flagged that name only when the join started at a
repository-root expression: tools_dir = ROOT / "tools" followed by
tools_dir / "blueprints.py" kept its old path with no flag.

A path join that ends in the name of a file that left a folder that stays
is now flagged whatever expression holds the folder. For a whole-package
move that set of files is empty, so its output is unchanged.
2026-11-16 18:09:00 +05:30
alt-glitch
3e931466c0 fix(move): files that leave a folder that stays move alone
rewrite_imports.py and rewrite_docs.py treated every folder above a moved
file as a moved folder. That holds when a whole package moves. When a few
files leave a folder it does not: moving three files from tools/ to cron/
printed 58 flags that named tools/, tests/ and tests/tools/ as moved, and
rewrote every `tools/*.py` glob in the docs to `cron/*.py`.

A folder now counts as moved only when every tracked file under it moved.
renames.py holds that rule once (emptied_folders) together with the path
questions the import and TOML passes ask (MovedPaths); the docs pass reads
the same rule. A path built from pieces is flagged by the name of the
outermost file or folder the move took away, so a file that left a folder
that stays is still found. A docs glob follows a move only when every file
it matches moved together under its own name; otherwise it stays as
written and is counted as partial-glob.

rewrite_imports.py takes --no-compat-table for a move whose old names no
release, updater or plugin imports. The default still writes the table,
so build_chunk.py and migrate_branch.py are unchanged.

Whole-folder moves give the same output as before: on
`git mv acp_adapter hermes_agent/acp_adapter` both scripts print the same
log and write the same diff with and without this change.
2026-11-16 17:23:26 +05:30
alt-glitch
a1bbd329ea refactor: split utils.py into the utils package
utils.py held three subjects in one 871-line file. It is now a package with
one module per subject: utils/files.py (atomic writes, temp files, file mode
and owner, signatures and digests, JSON and YAML file helpers), utils/urls.py
(the base_url helpers) and utils/env.py (truthy values, env numbers, proxy
env helpers). utils/__init__.py re-exports every public name, so no importer
changes. Function bodies are unchanged, no function-level import moved, and
the logger keeps the name "utils".

Tests patch a name in the module that now defines it. Patches stay on the
package where production reads the name through a function-level
"from utils import". The tests of utils itself move to tests/utils/.

A root module that becomes a folder drops out of anything that copies root
*.py files plus a fixed list of packages, so the fixtures that build a partial
source tree now list utils, as do pyproject's packages.find, three check
scripts and the CI change classifier.
2026-11-16 17:16:20 +05:30
alt-glitch
aa6d201dfd fix(code-health): packaged-imports models namespace packages; AGENTS.md names its exceptions
Some checks failed
Live provider canaries / Live provider canaries (push) Has been cancelled
packaged-imports knew 69 packages while setuptools ships 181: pyproject's
packages.find leaves `namespaces` at its default of true, so folders
without __init__.py (most of plugins.*) ship too, and the 92 of them
holding Python were never scanned. The shipped set is now every
directory with tracked Python, plus its parents, filtered by `include`,
as setuptools does. Git paths are read as PurePosixPath, so the dotted
names also match on Windows, where str(Path) uses backslashes and the
guard found nothing. test_files_under_a_namespace_directory_are_scanned
fails on the previous guard.

Root AGENTS.md's package section disagreed with three area rules:
- "add none" now excepts the flat siblings tui_gateway/AGENTS.md (RPC
  methods) and tools/AGENTS.md (backends) still prescribe;
- the tools/environments/ example says its table still sits in
  terminal_tool_backends.py;
- input parsing also allows the area's wire model (Pydantic in
  tui_gateway).
Root is 12,038 of its 12,100 characters.

Both changes are the reviewer's patches as posted.
2026-11-16 11:52:44 +05:30
alt-glitch
ec6827c388 fix(code-health): the packaged-imports scan is a guard, and it sees submodule imports
The scan that flags a package the wheel would drop read production
source from a test, which tests/AGENTS.md bans. It is now
scripts/check_packaged_imports.py, registered as `packaged-imports` in
scripts/check with its own lint.yml step, beside `tool-discovery`; the
hook fixture copies it like every guard. It uses only the standard
library: tomllib for the include patterns, the find_packages walk done
over `git ls-files` (a package is reachable only through parent
packages), and ast for imports.

`from acp_adapter import server` and `from . import server` now count
`acp_adapter.server` as imported, not only `acp_adapter`, so a submodule
turned into a folder is caught whichever form imports it.

tests/scripts/test_check_packaged_imports.py covers a root module turned
into a folder, both from-import forms, and a clean tree, on temporary
repos. On the real tree the guard passes, and fails with `toolsets` or
`acp_adapter.server` when either module becomes a folder.
2026-11-16 11:52:44 +05:30
alt-glitch
e6f7b6732d fix(code-health): a folder made from a root module ships, and the guard needs __init__.py
Two review findings on the folder rule:

- A root module or an acp_adapter/ module turned into a folder drops out
  of setup.py's _root_py_modules and ships only if
  [tool.setuptools.packages.find] include matches it. The FILE_LINES fix
  text now names that step, and
  test_every_package_packaged_code_imports_is_found fails when packaged
  code imports a regular package the wheel would not ship (moving
  toolsets.py to toolsets/__init__.py fails it with ['toolsets']).
- Discovery skips a tool package without __init__.py, so
  check_tool_discovery counts only candidates whose package has one,
  and its message says so. An intent-added tools/newpkg/tool.py with no
  __init__.py now fails the guard.

Both changes are the reviewer's patches as suggested.
2026-11-16 11:52:44 +05:30
alt-glitch
c3bd0bfc53 docs(agents): root AGENTS.md says what a good package looks like
The file-size fix text asks for a <stem>/ folder, but nothing said what
a good folder looks like. Root AGENTS.md's facade section becomes
"Packages and Python shape":

- <stem>/__init__.py is the facade: its docstring names each module's
  job, __all__ is the surface, PEP 562 __getattr__ when eager imports
  would cycle, and it holds no behaviour (tools/connectors/ is the model).
- A family folder keeps its ABC or Protocol, one module per variant and
  a name-to-variant table (tools/environments/).
- Flat <stem>_<topic>.py siblings stay until touched; none are added.
- A Shape bullet: code imports on 3.11; importing has no side effects;
  input is parsed where it enters into a frozen dataclass, Enum or
  Literal; one return shape per function; dispatch by table; objects,
  not mixins; no module constant kept only for tests to patch.

The rules live in AGENTS.md because that is what agents load on every
turn; root stays inside its 12,100-character budget (11,831). The
FILE_LINES fix text and CONTRIBUTING's Code Style section point at the
section.
2026-11-16 11:52:44 +05:30
alt-glitch
9f67098233 fix(code-health): carry the tool-discovery guard into the checker fixture
tests/scripts/test_code_health_cli.py builds fixture repos with a hand-kept
copy of every guard scripts/check runs; the new guard and what it imports
(tools/registry.py, hermes_constants.py) were missing, so three hook tests
failed on "can't open file". The guard drops its empty-scan branch, which
failed any tree with no tools, and exposes `unreached_registrations` so
tests/scripts/test_check_tool_discovery.py can prove it flags a module
registering outside `<pkg>/tool.py` on a temp repo.
2026-11-16 11:52:44 +05:30