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.
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>
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.
`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
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
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.
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.
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>
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.
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.
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.
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).
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.