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.
tools/context.py holds what a running tool call reads from its thread or
context. It takes tools/interrupt.py, tools/hosted_tool_policy.py,
tools/thread_context.py and agent/tool_progress_relay.py whole, and from
model_tools.py the sync-to-async bridge and the call ids. Function bodies are
unchanged. Three names other modules import lose their underscore: run_async,
CallIds and prompt_callback_accessors.
The file imports no other tool-core file, so the registry and every tool
module can import it at module top. tools/registry.py does, and no longer
imports the bridge from model_tools inside dispatch.
Old names. tools.interrupt and tools.thread_context keep importing through
MOVES keys, for pinned catalog plugins. tools/hosted_tool_policy.py and
tools/thread_context.py are generated files: a TUI, CLI or ACP process that
started on a release up to v0.23.5 and built no agent before the update imports
them when it builds a system prompt or compresses. agent.tool_progress_relay
gets nothing; in such a process the TUI row for MCP progress fails until it
restarts. model_tools keeps _run_async and _CallIds as second names for
run_async and CallIds until v0.27.0: the registry and the inline executors of a
release import them from model_tools inside functions, and without the first a
TUI or ACP process that outlives the update fails every tool with an async
handler.
Log lines follow their module to the logger tools.context. The interrupt trace
(HERMES_DEBUG_INTERRUPT) logs under tools.context.interrupt, so the level it
forces applies to the trace alone. The one line of the progress relay moves
from the agent log component to tools.
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.
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.
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.
The trim test kept passing when an allowlisted tree was widened to its
parent (usr/share/vim to usr/share, <mingw>/share/doc/git-doc to
<mingw>/share/doc) or when the symlinked-root guard was removed, because
every keep file under those parents was license-named.
Keep a non-license sibling under each parent, and add a POSIX test with
a trim root linked outside the staged tree whose target must survive.
Those four mutants survived the previous test and fail this one; the
other four mutants of trim_portable_git still fail it.
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.
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.
Trim audited non-license files under usr/share/vim (2,362 files) and ucrt64/share/doc/git-doc (1,162 files) from staged Windows PortableGit payloads (-3,524 MSIX entries) and refresh tools/facts.json digests afterward.
Preserves cmd/git.exe, usr/bin/bash.exe, sh.exe, ssh.exe, git-core, zoneinfo, all license/COPYING files (including ucrt64/share/doc/xz/COPYING* and usr/share/licenses/**), and existing runtime editor behavior.
A stable sideload MSIX embedded releases/win32/stable/<bundle> as its
MainBundle Uri, an object nothing publishes. Stable promotion points
stable.appinstaller at the receipt-bound archive copy,
releases/tag/<archive>/<bundle>. Canary was right only because
publish_canary_appinstaller keeps its bundle beside the feed.
The JS renderer was a second App Installer writer. The header of
msix-shared.mjs and the stable-releases guide both give that job to
scripts.bundles.release_artifacts. write_embedded_appinstaller now
derives both URLs there and calls write_appinstaller. before-build passes
it the release facts through HERMES_PYTHON, the same way
channelBuildRequest does. The archive is the one the workflow's handoff
stage uses: HERMES_ARCHIVE_TAG, else the payload tag. msixBundleName gives
stage-msixbundle.mjs and the descriptor one bundle filename.
The contract tests check that the embedded bytes match what stable
promotion and canary publication write.
The packer walks long_root(site), which on Windows is the \\?\ spelling,
so the listing-failure test's comparison with the plain tmp_path missed
there and both cases would report DID NOT RAISE. Build the faulted path
with long_root() too; it is the same path on POSIX.
The audit tests build and judge their pycs with the test's own
interpreter, so running the audit under the builder instead of the
staged interpreter passed them all. A fake staged interpreter that
reports a member uncovered now has to win over a pyc the builder could
load; that mutant fails the new test.
os.walk() skips a directory whose listing fails unless it is given an
onerror handler, so one transient listing error (an antivirus or
indexer holding the directory) left that subtree out of the archive.
The pack then removed the loose package, and the staged probe, which
imports only the top-level package, still passed: the bundle shipped
lark_oapi without the subpackage.
Both member walks now re-raise the listing error, before anything is
written or removed.
_uncovered() reports an archive member as Path("<archive>:<member>"),
and the pilot test looked for a forward-slash substring in its str(),
which on Windows carries backslashes. Compare Path objects instead, as
the audit test beside it does.
stage_native() runs prepare with PYTHONPATH set to the repo root and the
builder's own sys.path, and _verify_staged_import() started the staged
interpreter with -S alone, so that path came first in the probe. A
builder whose path holds a loose lark_oapi (a developer venv with the
feishu extra) failed the pack on a valid archive, and the builder's
packages could stand in for dependencies the staged site lacks.
The probe now runs with -I -S, like the compile and audit steps beside
it: it ignores PYTHON* variables and the user site, and the explicit
site.addsitedir() still processes the staged .pth.
verify_hpkg_archive_bytecode() read only the first 16 bytes of each
archived pyc and no caller set its expected_magic parameter, so a
header-only pyc, one stamped with another interpreter's magic, or one
whose body is not a code object passed both the pack check and
_uncovered(). Only the later staged import probe caught them, after the
loose package and its dist-info were already removed.
The audit now runs under the staged interpreter, the one zipimport loads
the archive with: each pyc must carry its magic number, the
unchecked-hash flag and a code object it can unmarshal, and a .py member
without a pyc is compiled with its grammar. Packing runs it before it
touches the loose tree, and the staged import probe keeps only the
zipimport, metadata and inspect checks, so one function defines a valid
archived pyc. _uncovered() now takes the interpreter to pass it through.
Reported by Greptile on #161819.
Pilot Windows site-package .hpkg zipimport packing on lark_oapi alone (21,463 pure-Python files, ~17.0% of the MSIX entry count, zero data or native files).
Packs validated .py sources, deterministically compiled adjacent legacy unchecked-hash .pyc bytecode (-s stripped build root for cross-runner delta stability), and .dist-info metadata into a ZIP_STORED lark_oapi.hpkg archive (DEFLATE-compressed in 64 KiB blocks by MakeAppx), wired via a build-generated relative plain-path _hermes_hpkg.pth loaded by site.addsitedir(). Coordinates scripts/bundles/bytecode.py::_uncovered() to verify .hpkg bytecode coverage and runs staged-interpreter zipimporter, importlib.metadata, inspect.getsource, and .pyc header/marshal verification at build time.
pack_uv_cache_archive staged the archive under a random mkstemp name in the
payload directory. An exception reaches the finally that removes it, but a
killed pack (closing the console on Windows, an OOM kill) left the partial
archive there, and the next preparation into the same output staged under a
new name. Desktop packaging copies the payload directory whole, so a
rebuild without --clean shipped the partial archive beside the real one.
The staging file is now always .uv-cache.hpkg.tmp beside the archive. The
next pack unlinks whatever is there and creates the file exclusively, so it
replaces a killed pack's leftover and never writes through a link left at
that name (mkstemp's O_EXCL gave the same guarantee for its random name).
Packs into one output are already serialized by preparation_lock.
Two new tests hard-kill a real child mid-pack (os._exit, so no finally
runs) and pack again. One expects only uv-cache.hpkg in the directory; on
the previous commit the killed pack's .uv-cache-<random>.hpkg.tmp is still
there. The other puts a hard link to a file outside the payload at the
staging name and expects that file untouched; opening the fixed name in
write mode instead fills it with the archive.
Raised by the Sol review of #161706 (S2, S7).
test_native_cli_consumes_real_minimal_preparation_without_bootstrap is marked
platforms("posix"), so the win32 branch this PR added to its fixture could
never run. The file is back to main's version; the Windows archive layout is
covered by test_native_prepared_validates_windows_archive.
Raised by the Sol review of #161706 (S6).
The archive admission test created a symlink first, so on a Windows host
without symlink rights it failed in os.symlink before reaching the
native_prepared checks. The refusal is now its own require_symlinks test,
and the admission test runs everywhere.
The admission test's docstring also promised that mixed layouts are refused,
but nothing asserted it: it now adds a loose uv-cache/ beside the archive
and expects publish_prepared to refuse. Dropping the loose-cache clause from
native_prepared._input_paths fails it.
Raised by the Sol review of #161706 (S5).
os.walk ignores a directory it cannot list unless given onerror, so
pack_uv_cache_archive could write an archive missing that subtree.
_prepare_native then deleted the loose cache it was packed from, and the
digest it records is of the incomplete archive, so nothing downstream would
notice the missing wheels until an offline sync needed them. The walk now
re-raises, and preparation fails before writing the archive.
The new test makes one bucket directory unlistable; on the previous commit
the pack succeeds without it ("DID NOT RAISE").
Raised by the Sol review of #161706 (S3).
pack_uv_cache_archive opened each member with ZipInfo.file_size still 0, and
zipfile chooses a member's ZIP64 header from that size before writing, so
allowZip64=True never applied to it: any single cache file past 2 GiB - 1
stopped the Windows bundle build with "File size too large, try using
force_zip64". The member's size now goes in from the open file first.
Ordinary members come out byte-identical, so archives for today's caches do
not change. The new test lowers zipfile.ZIP64_LIMIT to stand in for 2 GiB and
fails on c83f704484 with that RuntimeError.
Raised by the Sol review of #161706 (S1).
Collapse ~33,191 loose Windows uv-cache files (~26.3% of the MSIX entry count) into a single deterministic ZIP_STORED archive (uv-cache.hpkg) during Windows native payload staging.
Using the non-excluded .hpkg extension lets MakeAppx DEFLATE-compress 64 KiB blocks natively (preserving MSIX size and block-level delta updates) while cutting ~33k HTTP Range requests and Defender file-open scans on remote and local MSIX installs. POSIX payloads keep loose symlinked uv-cache/ directories unchanged.
Update pm/packages.py to read both uv-cache.hpkg and loose uv-cache/ directories, preserving selective scope='sdists' seeding (.seeded-sdists), selective-to-full upgrade (.seeded), atomic interruption-safe extraction with retry, path-traversal rejection, and expanded 4 KiB-block uv_cache_seed_bytes() accounting. Update scripts/bundles/native_prepared.py to stream file digests and validate uv-cache.hpkg on win32 targets.
The downloads-page label for the single-arch bundles said "manual; in-app
updates". That is false on every page that renders it. Those pages list
tag and commit builds, which carry no channelBuild in their install stamp,
and a bundle opened directly registers no App Installer source. With no
updates.desktop_feed_base_url configured, the app-installer checker
reports "No App Installer update source is registered" and apply() falls
back to the manual-install message.
The label now reads "manual install and updates": a direct install is
updated by opening the next release's bundle, which upgrades it in place.
The downloads-page test asserts the Windows rows say "manual" and never
"in-app".
Emit and sign single-architecture Windows .msixbundle packages (-win-x64.msixbundle and -win-arm64.msixbundle) alongside the existing universal -win.msixbundle in scripts/stage-msixbundle.mjs, and update all release consumers atomically.
Windows rejects in-place upgrades from an installed .msixbundle to a bare .msix, while downloading a single-arch .msixbundle via one HTTP GET cuts clean installs and in-place upgrades from 63–99 minutes down to ~5–6 minutes (verified on Win11 x64 and ARM64).
Key changes:
- scripts/stage-msixbundle.mjs: stage each bundle from an isolated hardlinked/copied directory (removing staging dirs immediately to preserve runner disk), sign all 3 with Azure Trusted Signing, and verify /pa on each.
- scripts/bundles/release_artifacts.py: add select_windows_bundles() and validate_windows_arch_bundle(); accept either historical universal-only receipts (v0.22.0/rc.2) or complete 3-bundle sets (universal + x64 + arm64), failing loudly on incomplete sets.
- scripts/releases/stable.py, scripts/bundles/channel_artifacts.py, scripts/releases/channel_publish.py: select universal vs per-arch bundles explicitly via select_windows_bundles() and validate per-arch manifests when local bytes are present.
- scripts/releases/downloads_page.py: prefer signed per-arch .msixbundle (labeled manual install; uses in-app updates) over bare .msix when present, while keeping .appinstaller primary for OS-managed feeds.
Add contributors to INERT_SNAPSHOT_DIRS in scripts/bundles/payload.py so repository-root contributor attribution files (3,256 tiny files totaling ~0.1 MiB, read only by CI attribution scripts) no longer ship inside macOS, Linux, and Windows desktop payloads.
pm imports hermes_cli.config inside functions, so a utils helper could
reach config through it with no waiver. No utils module imports pm, so the
allowlist entry goes.
utils/AGENTS.md: the product test names its one standing exception (the
atomic writers call hermes_constants.mkdir_under_hermes_home so a write
never resurrects a deleted profile), the owner table gives
hermes_cli/config_backend.py its real path, and the submodule-import rule
is scoped to new callers. The utils/__init__.py docstring says the same.
tests/AGENTS.md no longer lists utils among the modules whose tests sit
directly in tests/.
The rule's tests now cover a root-level product module, `not in
sys.modules`, and a relative import inside utils.
utils is meant to be importable from every package without pulling the
product in, and nothing enforced that. HX018 is a blocking code-health rule
over utils/: it flags an import of a first-party module at any depth,
importlib.import_module or __import__ of a literal name, and a sys.modules
get, subscript or `in` lookup of one. Allowed: other utils modules,
hermes_constants, hermes_platform, hermes_yaml and pm.
First-party names come from the judged tree's tracked files (NAME.py or
NAME/__init__.py at the root), so there is no list to keep in sync.
The two hermes_cli.config imports in utils/files.py, the config writer's
round-trip YAML path, carry `# health: allow HX018 -- why`. They are the
whole exception list.
utils/AGENTS.md states what belongs in utils and what the rule allows. The
root routing table gets no row: root plus gateway/AGENTS.md is 11 characters
under the chain cap.
The alias was dropped from the head's line only when it equalled the old
module name, so `from tools import helper as helper` stopped matching
itself after a move, and `from pkg import (helper)` was not read at all.
Both sides now drop the local name of a from-import that names a moved
module, and the pattern accepts an opening parenthesis.
The ratchet reads a line that names a moved module as the base's line
only when the module has a key in hermes_agent/compat/moves.py. Most
moved modules get no key, so under tools/ every function-level import
of one failed PLC0415 as new, in files the move did not otherwise touch.
module_moves adds the Python files the diff renames to the MOVES table
before lines are compared. module_renames also reads `from pkg import
module`, with the alias a move adds to keep the old local name.
- An import in a function defined under try/except ImportError is checked: the function runs when called, after the handler is gone.
- A try whose ImportError handler re-raises is not a guard, since the missing module still fails the import.
- Tests pin what stays checked: the handler, else, finally, a broader except, a plain if.
Co-authored-by: BearHuddleston <BearHuddleston@users.noreply.github.com>
tool-discovery now flags a registration in tools/registry.py or tools/__init__.py, which discovery never imports; both read one skip set in tools/registry.py.
packaged-imports no longer flags an import inside try/except ImportError or if TYPE_CHECKING, which cannot fail an installed wheel.
packaged-imports now flags a regular package under an unshipped namespace directory.
The FILE_LINES fix text no longer forbids flat siblings an area AGENTS.md prescribes, and is shorter.
CONTRIBUTING.md states the same flat-sibling exception as root AGENTS.md.
ruff's PLC0415 joins the ratchet's pattern rules, scoped to tools/. The 2,716
function-level imports already there are existing debt and keep passing where
they sit; a new one fails unless it carries
'# health: allow PLC0415 -- <why>' (an optional extra or a measured startup
cost). The fix text names the cause: a cycle that forced the import is fixed
by moving the shared names down.
_VALID_ASSETS accepted both linux-x86_64.AppImage, the name
electron-builder gives the x64 AppImage and the one
scripts/releases/linux.py publishes feeds for, and a linux-x64.AppImage
alias nothing produces. Both normalize to the same (linux, x64) row, so
an archive holding both listed whichever name came last.
Drop the alias. The new test feeds both names and expects the produced
one in the row and in the version filter; it failed on the previous head
because the alias overwrote the real file.
Linux x86_64 and arm64 AppImages now build, pass native install-and-chat
smoke, unpack to a stable per-version `$XDG_DATA_HOME/hermes/bundles/`
payload path, and publish updater feeds on daily canaries (`#161336`)
and opt-in `--with linux` stable releases (`#161406`), but the builds
page renderer and documentation still hid them or described them as
unsmoked, unoffered artifacts:
- `scripts/releases/downloads_page.py`: accept real `linux-x86_64.AppImage`
and `linux-arm64.AppImage` filenames via `_VALID_ASSETS` (normalizing
`x86_64` to `x64` while rejecting invalid os/arch/ext combinations),
remove `_UNLISTED_OS = frozenset({"linux"})` so staged Linux AppImages
render in `Hermes Desktop` download tables, and update `_SMOKE_SCOPE`
to reflect diagnostic Linux AppImage smokes while preserving the
unsigned Store notice.
- `tests/scripts/test_render_builds_publication.py`: verify real
`linux-x86_64.AppImage` and `linux-arm64.AppImage` rows render in both
release bodies and R2 `index.html`, while YAML feeds and invalid
os/arch/ext pairs remain hidden.
- `apps/desktop/BUILDING.md`, `tests/install/README.md`, and
`website/docs/` (`platform-support`, `installation`, `updating`,
`desktop`, `shared-bundle-builds`, `stable-releases`): document the
Linux AppImage distro/glibc floors, first-launch payload extraction,
`AppImageUpdater` differential updates, measured canary sizes, and
current non-gating canary / opt-in `--with linux` stable status.
The put_object retry-sleep test needed a loopback server thread to
answer 503 inside a 0.5 s budget, so on a busy runner the PUT could
time out first and fail the test before it reached the retry. Raise the
503 from `put_object`'s own `fetcher` seam instead: no server, no
timing. On 0c5046ba26 it still records three 1 s sleeps and three PUTs.
`put_object` retries a retryable R2 status in its own loop with an
unconditional `time.sleep(1.0)`, so under `time_budget` it slept past a
deadline that `signed_request` had already declined to retry into, and
the next attempt then failed on the spent budget instead of the 503.
`_reconcile_linux` reaches it through `linux.publish_stable_record`.
Use `_retry_sleep(1.0)` like the other retry loops: outside a budget it
sleeps as before; inside one it re-raises the PUT's own error once the
time left cannot cover the sleep.
Test: a loopback endpoint answering 503 under a 0.5 s budget recorded
three 1 s sleeps and three PUTs on the previous head; now none and one,
and the error is the 503.
tests/AGENTS.md asks for wall-clock bounds of at least 2 s so a busy
runner does not fail a working test. The budget tests asserted under
1 s; they now assert under 5 s, which still fails a 60 s or 600 s
socket wait.
The 1 s bound was also what caught a retry sleeping past the budget
(1 s, then 2 s). The stalled `signed_request` case now records
`time.sleep` and asserts no retry slept and only one connection opened,
so that check no longer depends on runner speed: making `_retry_sleep`
ignore the budget fails it.
A socket timeout bounds one wait, not one read. `res.read(n)`, the
whole-body `read()` in `signed_request` and the status/header
`readline()` loop recv until they have their bytes, so a peer that sends
a byte every few milliseconds kept a single call going past the
`time_budget` deadline: the budget was only checked between 1 MiB
chunks, and `signed_request` and `read_public_receipt` never checked it
while reading.
Under an active budget, `_connection` now gives the connection a
response class whose socket reader sets each wait's timeout to what the
budget has left (`_effective_timeout`) and raises once it is spent. That
covers the status line, headers and every body read in all four
readers, so the per-loop `_clamp_socket_timeout` / `_check_budget` calls
go away and the chunk loops read as they did before. Connections opened
outside a budget keep the stock response class.
Sends are unchanged: each `sendall` is bounded by the timeout the
connection opened with, which the budget already clamps, and the
reconcilers only PUT small JSON bodies.
Tests: a loopback server that sends headers or a body one byte every
20 ms holds each of `signed_request`, `read_public_receipt`,
`download_public_object` and `verify_remote_artifact` for the whole
10 s trickle on the previous head (8 failed); all raise `TimeoutError`
at the 0.5 s budget now. A trickle that stops at 2.5 s under a 3 s
budget pins the per-wait clamp: without it the last wait runs the
connection's full 3 s.
Post-publication reconcilers (`_reconcile_store`, `_reconcile_linux`)
run after durable channels have already moved, inside `reconcile`'s
30-minute timeout. Previously they inherited `r2.py`'s 600-second
per-request socket timeout and unbounded retries, so a stalled R2
request could outlast the workflow timeout and fail the run after
publication. `_reconcile_store` also caught only `(StoreError,
ValueError, OSError)` and did not handle `r2.R2RequestError` or
`http.client.HTTPException` when reading the archived candidate
manifest.
Add a `ContextVar`-backed `r2.time_budget(total_seconds, *,
per_request_timeout=None)` context manager wired through
`signed_request`, `read_public_receipt`, `_download_url`, and
`_stream_and_hash` (clamping open socket reads and retry sleeps to the
remaining deadline, strictly tightening nested budgets). Wrap
`_reconcile_store` and `_reconcile_linux` in a 300 s budget with 60 s
per-request caps, and widen `_reconcile_store`'s advisory catch tuple
to log a structured Microsoft Store warning on R2/HTTP errors.
No test caught a mutant of three _arch_evidence_reasons clauses: the
invalid commit SHA, the invalid release tag, and ev.arch != arch.
admit_publication's other refusals hide them there. For record_evidence
these clauses are the only guard before it fetches the staged feeds.
The new parametrized test passes record_evidence one bad identity with
everything else valid. It asserts that exact single reason and zero R2
requests. Replacing each clause with pass fails its row, so no
mutant of the shared helper survives test_release_linux.py.
Found by a Sol review round on #161406.
_reconcile_linux runs after the release and its channels are durable,
and the Linux lane promises never to gate publication. Its except
clause listed the error types it expected, and review kept finding ones
it missed. A truncated R2 read raised http.client.HTTPException
(820a4262ab). A malformed live stable-linux.yml raises ruamel's
ParserError from parse_linux_feed. A handoff receipt with a non-string
sha256 raises TypeError in handoff.validate. Each of them failed
sequencer.main after the release was public.
The lane now catches Exception at its single call, with a BLE001
waiver that says why. It logs the traceback and warns with the
exception's type name, the same form sequencer.main uses for its own
::error::. An unexpected bug therefore still shows up in the job log
and as an annotation, but it no longer turns a finished publication
red. SystemExit and KeyboardInterrupt still propagate.
The new test serves a stable-linux.yml that is not valid YAML from the
loopback R2. On the previous head ParserError escaped _reconcile_linux.
Now it warns, the feed is unchanged and no PUT is made.
Found by a Sol review round on #161406.
When linux-evidence.json was missing, publish_stable_record returned
published=False. _reconcile_linux then logged a plain line, so a skipped
or failed recorder left the stable Linux feeds stale with no annotation,
although the PR promises a :⚠️: for missing receipts. A refusal
now warns the same way an R2 error does.
The warning goes through a new progress.warning, next to notice and
error, so it lands on stderr like the other annotations. The sequencer's
stdout stays the JSON step list that progress.py documents. The earlier
print put the R2-error warning on stdout, and the two tests that read it
now read stderr.
The new test runs _reconcile_linux against an empty loopback R2. On the
previous head it saw only the plain log line.
Reported by Greptile on #161406.
r2.signed_request retries an IncompleteRead and then re-raises it.
IncompleteRead is an http.client.HTTPException, not an OSError, so it
escaped _reconcile_linux's catch. The sequencer job then failed after
the release and its channels were already live, which breaks the Linux
lane's non-gating promise. The catch now includes HTTPException, the
same tuple channels.py already uses for R2 transfers.
The test has the loopback R2 fixture send a short body for
linux-evidence.json on every attempt. On the old head it raises
IncompleteRead out of _reconcile_linux.
Reported by Greptile on #161406.
_preflight_feed returned "noop" for an arch whose live feed already
matched the plan before it checked that arch's AppImage. A retry after a
partial publish (x64 written, arm64 PUT failed) therefore verified only
the arm64 AppImage and wrote the arm64 feed, even if the x64 AppImage the
live feed names had gone missing or corrupt since. That breaks the
all-or-nothing rule publish_admitted states: both AppImages are checked
before the first PUT.
The live-feed checks (downgrade, conflicting same version) still refuse
first, without a download. The AppImage size and SHA-512 check then runs
for every arch, whether its feed is already live or not. A rerun where
both feeds are already live now downloads both AppImages and writes
nothing, the same transfer cost as the first publish.
Test: test_retry_after_partial_publish_reverifies_the_already_live_arch_appimage
seeds a live x64 feed, corrupts the x64 AppImage and retries. It
expects a checksum refusal, no PUT and no arm64 feed. It fails on the
previous head (DID NOT RAISE: the arm64 feed was written) and passes now.
Found by the sol-loop review on #161336.
Greptile on #161336: load_feeds_from_dir had no caller, because
fetch_staged_feeds read both staged feeds itself, with a hand-rolled
copy of the receipt-bound transfer that handoff.fetch already does for
every other leg (read and validate the receipt, then GET each row and
check size and sha256), plus a read of r2.Response's private `_body`.
Keep the loader and drop the copy instead: publish_from_env now
downloads each arch's feed with handoff.fetch into a temporary
directory, one receipt per call with only that arch's feed name
included, and reads both with load_feeds_from_dir. Each feed can still
come only from its own arch's receipt, and a missing or tampered feed
still refuses before the first PUT. A transfer whose bytes disagree with
the receipt now gets the shared download's retries before it fails, and
the error reads "Artifact checksum mismatch".
New test: test_publish_from_env_takes_each_feed_only_from_its_own_arch_receipt
moves the x64 feed's receipt row into the arm64 receipt and expects a
refusal with no PUT. It passes on the previous head too (that code
looked the row up per receipt); it fails on a mutant that fetches both
arches in one handoff.fetch call, which is the shape this change has to
avoid.
Greptile on #161336: linux.py threaded an optional `fetcher` through
every R2 call and, when one was set, ran its own copies of
r2.verify_remote_artifact and r2.put_object (checksums, request
hashes, Cache-Control, error checks). Nothing passes a fetcher: the
workflow runs `python -m scripts.releases.linux publish` and the tests
drive the real transport against the loopback R2 fixture. The copies had
already drifted (the artifact check read `response.data`, which
r2.Response doesn't have), so the first caller would have hit an
AttributeError instead of a checksum verdict.
Remove the parameter and its branches. Artifact verification and the
conditional feed PUT now go only through r2.verify_remote_artifact and
r2.put_object, and _get_live_feed keeps only the 404 handling that
r2.signed_request can actually raise. No behaviour change on the real
path, so the existing loopback tests are the proof: the same 36 test ids
in tests/scripts/test_release_linux.py pass before and after.