A rule with an `include` scope (the function-level import rule covers tools/
only) was measured on the base side with the same scope. A function moved
unchanged into tools/ from a file outside it therefore arrived with no
recorded violations, and every import inside it read as new, though the
ratchet's own contract is that code that moves keeps its cap and its
violations.
The base side is now measured with the rule's `exclude` only. A base hit is
used only by the head unit the comparison pairs it with, so the extra hits
change nothing for a file that stays outside the scope; they cover the same
occurrences once the unit lands inside it. An import the move adds is still
new.
The registry test required the two published canary proofs by version, so
retiring either one would fail CI without any change to the gate. It now
checks that every checked-in proof opens the gate for the exact candidate
it names, and runs the fail-closed cases against a fixture registry.
It also covers the gate clauses the old test let through: the same
digests claimed for another version, packages built at a version other
than windowsAutoUpdate records, a windowsAutoUpdate channel that disagrees
with the tag, and a registry in another schema. Against nine mutants of
has_verified_windows_autoupdate and load_vm_proofs, the old test caught
five and the new one catches all nine; with the 26.1130.23.2922 proof
removed from the registry the old test fails and the new one passes.
test_stable_windows_aliases_reject_downgrade_and_readback_mismatch named a
public read-back failure but only covered the downgrade and the
same-version swap. It now promotes a verified candidate while the public
origin serves another size for the arm64 alias: promotion raises
"Channel read-back differs" after R2 took the copy, releases/stable/index.html
stays unwritten, and a retry against a consistent origin finishes the release.
On the PR head the old test passes with the alias read-back deleted, and
with it limited to x64; the new case fails on both.
The 21 flat files that serve the terminal backends join the package:
the process registry and its nine parts, the environment-variable
passthrough, credential file mounts, workspace path resolution, the PTY
query responder, the terminal scope, and the backend table, config,
lifecycle, macOS open rewrite, sudo and sudo askpass of the terminal
tool. file_tools_paths becomes workspace_paths and the terminal_tool_
prefix drops (terminal_tool_backends becomes backends, and so on); every
other file keeps its stem. Function bodies are unchanged; only imports
and module-name strings follow the move. 22 tests move to
tests/terminal_backends/.
Ten old module names keep a generated old-path file and a compat key:
a session started on an older release imports them lazily after an
update from code it has already loaded (the gateway's process notices
and inbound media, an agent's next terminal command, sudo prompt or PTY
process). Each key also binds the module such a session holds to its new
name, so the process table, the sudo password cache and the registered
passthrough variables stay one object. The pinned catalog plugins'
modules are listed in the plugin guide.
The terminal backends and their support files leave tools/, which holds
model tools, for a new root package terminal_backends/. base.py becomes
environment.py and its base_* siblings become environment_*;
sandbox_scope.py becomes hosted_scope.py and sandbox_conformance.py
becomes conformance.py. Every other file keeps its stem. Function bodies
are unchanged; only imports and module-name strings follow the move.
tools.environments, tools.environments.local, tools.environments.base
and tools.environments.sudo_password_note keep generated old-path files:
old releases import the first two after an update, an agent process
started on v0.23.2 to v0.23.5 imports the last on its next terminal
command, and the plugin API publishes BaseEnvironment under both
package names. tools.environments.base_output is a compat key for pinned
catalog plugins. terminal_backends joins the tools log component, the
known logger roots and every hand-written package list.
The package is not named sandboxes: on an install whose checkout is
HERMES_HOME that folder holds live sandbox workspaces, and the updater
of a released version deletes or stashes them when a tracked package of
the same name arrives.
tools/ holds model tools. These 36 files register none: they decide whether
a command or a write may run, detect dangerous commands, and ask a person
(approval prompts, gateway clarify, slash confirmations). They move to a new
root package, approval/, with command detection in approval/detection/.
tools/approval.py becomes approval/gate.py and tools/approval_detection.py
becomes approval/detection/patterns.py; the other files drop the approval_
prefix or keep their stem. 79 tests whose subject is a moved file move to
tests/approval/, whose conftest.py imports the autouse fixtures of
tests/tools/conftest.py they ran under.
Function bodies are unchanged and every import stays where it was. Loggers
follow their modules: the five module loggers that logged as tools.approval
now log as approval.gate, and approval joins the tools entry of
hermes_logging.COMPONENT_PREFIXES, so `hermes logs --component tools` shows
the same lines. approval also joins packages.find, FIRST_PARTY_MODULE_ROOTS,
_KNOWN_LOGGER_ROOTS, the plugin isolation audit, six check scripts, the P33
profile-scope pattern and the test fixtures that list root packages.
Ten old names keep a file at the old path, each a MOVES key, a
REQUIRED_NAMES row and a file written by scripts/move/generate_shims.py:
tools.approval and tools.clarify_gateway are on the published plugin API,
and all ten are imported inside functions on every turn, message, tool call
or human prompt by a process started on a release up to v0.23.5, which
keeps running its old code after an update swaps the checkout. Five more
modules that pinned catalog plugins import keep their old name through a
MOVES key with no file, listed in the plugin guide.
Both new packages call rebind_loaded_modules from their __init__, so a
session that outlives the update keeps the one gate it already holds: a
notifier registered before the update still reaches a background child's
approval request.
- pm/store.py::_elf_loader_is_musl: an interpreter path containing
"/libc.so" no longer means glibc. glibc's loader is always ld-linux*;
the only loader named libc.so is musl's own, so that shape is unknown.
- scripts/install.sh: hoist the PT_INTERP reader to a top-level
_uv_elf_interp_libc (it was a nested function that bash defines
globally anyway) and drop the new "an ld-linux loader exists on disk"
fallback. pm/store.py has no such step, and Alpine with gcompat ships
/lib/ld-linux-x86-64.so.2, so the two probes would disagree on the
hosts the fallback exists for.
- Tests: an entry-point test drives current_target() on a Fedora-shaped
glibc host (PT_INTERP at 0x10a000, /lib/ld-musl-x86_64.so.1 on disk);
the install.sh tests keep main's "musl ELF beats a glibc ldd" stub,
pin uname so arm64 runners pick the same row, and run the past-8K
case with no ldd and a musl loader on disk so only PT_INTERP decides.
The probe-order test is trimmed to the two invariants.
uv_bootstrap_target() grepped a fixed 8 KiB head window of /bin/sh and
/bin/ls for the loader name. Fedora 44 places PT_INTERP at 0x10a000 in
bash and 0x19000 in ls, so the probe missed both and the last-resort
musl glob matched a musl-libc installed for cross-compilation. On such a
host the installer stages the musl uv artifact for a glibc userland
(#145469, #150951).
Read the interpreter from the ELF program headers instead. Grepping the
whole file is not a substitute: astral's glibc uv embeds the string
"/lib/ld-musl-x86_64.so.1", which false-positives as a musl loader.
Before the musl glob, also prefer a native ld-linux loader: a glibc
userland always carries one, while a musl loader on disk may only be a
secondary toolchain. The probe paths are optional arguments so the tests
can pass synthetic ELF images.
4069fc9509 moved conn.close() inside the ranged slot, but a
`Connection: close` response owns the socket once getresponse()
returns: http.client closes the connection's reference and the
response's file keeps the socket open. conn.close() therefore left an
unread body open after the slot was released. This happens on the
chunk-0 probe that got a 200 and on any error status such as a 503
retry. The frame still referenced the response, so the socket stayed
open through the retry sleep while another worker took the slot.
Both ranged fetches now close the response, then the connection, in
_close_inside_slot() before the slot is released.
Test: test_ranged_slot_outlives_every_socket_opened_under_it records
each socket a thread opens under a slot and checks, in that thread and
before the slot is released, that every one is closed. It runs over
HTTP/1.0 and HTTP/1.1 keep-alive, with a chunk-0 200 and with a part
that answers 503 once. The two HTTP/1.0 cases fail on 4069fc9509 and
pass here. The HTTP/1.1 cases catch a close moved after the slot
release in either fetch.
4069fc9509 makes a queued ranged part give up on cancel:
_download_remaining_parts sets cancel and then calls
_RANGED_SLOTS.wake(). Its own cancel subtest calls occupied.wake()
itself and can set cancel before the waiter has queued. A mutation run
of r2_multipart.py at 4069fc9509 showed that dropping the wake() call
from _download_remaining_parts survives the whole file.
test_failed_part_cancels_siblings_queued_behind_another_transfers_slots
holds the only slot for an unrelated transfer and waits until one part
has queued for it. It then fails the sibling part with a 403 and
expects _download_remaining_parts to raise that 403 while the slot is
still held.
Mutants caught: no wake() after cancel, a wake() that notifies nobody,
and no cancel check while waiting. The test passes on 4069fc9509.
The positive assembly case ran only for stable, so sending a canary to the tag bundle URL went unnoticed; it now runs for both channels. The no-promotion check compares the stable page rendered with and without the windowsAutoUpdate record instead of pinning today's label text.
The bundle job's checkout for a stable or canary claim is the claimed
payload, while the workflow comes from the controller. Once this lands,
a claim on a payload older than scripts/bundles/msix_autoupdate.py runs
`python -m scripts.bundles.msix_autoupdate` from a tree without it:
"No module named scripts.bundles.msix_autoupdate", exit 1, and the
step fails before staging the bundles, though a missing verdict only
means no windowsAutoUpdate record. A tagged commit claim reached the
same branch too, hashing both bundles for a verdict assemble() ignores.
Record only when HERMES_BUILD_COMMIT is unset and the payload has the
recorder. The new test runs the real staging step for both cases and
asserts the bundles are staged with no verdict; both fail on 2b1bd61.
The candidate-manifest job downloads only metadata-*.json, never the
multi-GB per-arch bundles, so assemble() never had the bytes it inspected
and a real release recorded no windowsAutoUpdate (Greptile P1).
The Windows bundle job now inspects the signed per-arch bundles it just
built (scripts/bundles/msix_autoupdate.py record) and stages their
uap13:AutoUpdate facts as windows-autoupdate.json in the
windows-universal receipt, keyed by each bundle's sha256. The candidate
job fetches that file with the metadata; assemble() reads it like
metadata (digest-checked against the receipt, never published) and
records windowsAutoUpdate only when each arch's entry carries the
receipt's own digest for that bundle and its facts match this release's
feed, bundle URL, identity, publisher, version and arch. A build with no
per-arch pair stages no verdict, and an older handoff without one
records nothing.
The red/green test runs the workflow's real staging step against a
loopback R2, then stable.main(["candidate-manifest"]); on the previous
head it fails with KeyError: 'windowsAutoUpdate'.
MakeAppx stores or deflates every part of a bundle and of its nested
packages. The inspector still handed any other codec to zipfile, so an
LZMA part with a corrupt stream raised lzma.LZMAError out of
bundle_carries_sideload_autoupdate() and aborted assembly, the same
class the previous commit closed for deflate.
Rather than add a handler per codec MakeAppx never uses, return False
when any part of the outer bundle or the nested package uses a method
other than STORED or DEFLATED. An unsupported method id now stops
there too, so the except comment no longer lists it.
Two new cases (a corrupt LZMA bundle manifest, a corrupt LZMA nested
manifest) fail on the previous head with LZMAError; mutants that drop
either check or admit LZMA are each caught.
Found by the Sol review of 5313413 (S10).
The commit-claim test bound its bundles to the stable feed only, so it
caught a commit tag mapped to stable but not one mapped to canary,
though its comment claimed any channel. Parametrize the binding over
both channels' feed and bundle URIs.
Mutants that drop the guard and send commit tags to a channel: the old
test catches the stable mapping and lets the canary one survive; the
parametrized test catches both.
Found by the Sol review of ebdb8b1 (S9).
bundle_carries_sideload_autoupdate() promises a False verdict on any
malformed ZIP or XML, and assemble() treats that verdict as advisory: a
bundle that fails inspection omits windowsAutoUpdate. Its except tuple
missed most of what zipfile and expat raise on bad bytes, so those
inputs aborted candidate assembly instead:
- a corrupt deflate stream in a member: zlib.error
- an unsupported compression method or an encrypted member:
NotImplementedError / RuntimeError
- a member name flagged UTF-8 that isn't: UnicodeDecodeError
- an XML encoding declaration expat can't read: LookupError (unknown)
or ValueError (multi-byte)
Catch those families (RuntimeError, ValueError and LookupError cover
NotImplementedError, UnicodeDecodeError and the old KeyError) alongside
the existing OSError, BadZipFile and ParseError. Programming errors
(TypeError, AttributeError) still surface.
The new parametrized test feeds one crafted nested package per case;
six fail on the previous head, each with its exception, and the
malformed-XML case pins ParseError. Dropping any one type from the
tuple fails its case (8 of 9 mutants caught; the survivor removes the
pre-existing OSError, which no test reaches). A size field running
past the archive end is BadZipFile ("Overlapped entries") on 3.11.15
through 3.14, so EOFError is not added.
Found by the Sol review of ebdb8b1 (S8).
A commit claim runs the stable pipeline on its own commit.<stamp>-vX.Y.Z
tag, and stage-msixbundle.mjs plans both per-arch bundles for every tag,
so its windows-universal handoff lists them. assemble() then reached
release_channel(tag), which raises for commit tags ("Commit builds
publish to no release channel"), and the whole candidate manifest
failed. It raised before the is_file() check, so it did so even though
no bundle bytes are on disk in the real candidate-manifest job.
A commit claim publishes to no channel, so there is no feed to inspect
its bundles against: skip the inspection and record nothing.
The new test assembles a commit claim whose bundles are bound to the
stable feed; it fails on the previous head with that ValueError and
passes on the PR base cfecf78752. The existing assemble test's staging
helper moves to module level so both tests share it.
Decouple static uap13:AutoUpdate inspection and manifest recording (PR 8a) from primary-download alias/label promotion (PR 8b) and post-stable user docs (PR 8c) per unanimous council plan:
- Tighten bundle_carries_sideload_autoupdate() to enforce exact http://schemas.microsoft.com/appx/manifest/uap/windows10/13 namespace, whitespace-delimited IgnorableNamespaces token membership for the bound prefix, and exact universal MainBundle/@Uri.
- Keep assemble() recording digest-bound windowsAutoUpdate in release-candidates.json when both x64 and arm64 pass.
- Defer has_verified_windows_autoupdate(), StableDownloads alias promotion, r2.py protection, downloads_page.py label flips, and website/docs/ updates out of PR 8a.
Promote unversioned stable single-architecture Windows .msixbundle aliases (releases/win32/stable/HermesBundled-win-x64.msixbundle and HermesBundled-win-arm64.msixbundle) alongside stable.appinstaller ONLY when the candidate carries an exact-digest windowsAutoUpdate attestation verified inside each nested .msix.
Key changes:
- scripts/bundles/release_artifacts.py: add bundle_carries_sideload_autoupdate() inspecting each single-arch .msixbundle's AppxBundleManifest.xml + nested .msix AppxManifest.xml <uap13:AutoUpdate> + embedded Update.appinstaller (exact channel feed URI, identity, publisher, version, <OnLaunch>); record digest-bound windowsAutoUpdate in assemble(); extend StableDownloads to server-side copy and HEAD-verify both stable per-arch aliases only when exact-digest attested (unbound/historical candidates never overwrite the aliases).
- scripts/releases/r2.py: add channel_msixbundle_key_for() and protect both stable per-arch aliases in prune().
- scripts/releases/downloads_page.py: upgrade Windows rows from manual label to primary MSIXBUNDLE only when has_verified_windows_autoupdate(manifest) passes.
- website/docs/: document single-arch .msixbundle as primary sideload Windows download (keeping .appinstaller as fallback) and document the unversioned stable aliases.
Held as Draft pending Win11 x64 + ARM64 CI-signed canary proof of no-click OS OnLaunch updates and channel-switch survival after #161817 lands.
Review follow-up: the first socket read can return just the headers, so
expiring the deadline there could time attempt 1 out before the body and skip
the mid-body path (temporary file written, then cleaned up). The clock now
jumps once the client has read 8 KiB, which is past the headers and into the
half body the server sent before waiting. 30/30 runs pass.
test_ranged_download_retries_single_failed_or_truncated_part_and_chunk0_timeout
jumped the fake clock inside the server handler, before it sent the 206
headers and the whole 16 KiB body in one write. The client checks the
per-attempt deadline only when a socket read starts, so a read that began
before the jump could take the headers and the entire body at once: attempt 1
then finished inside its budget, the download made one chunk-0 request, and
`assert chunk0_calls[0] == 2` failed (1 of 5 and 1 of 25 local runs on main;
also red on main's CI run for 82aebc81 and on unrelated PR CI).
Now the server sends the headers and half the body, the clock jumps as the
client's first socket read returns, and only then is the rest sent, so the
next read always starts after the jump and sees the expired deadline.
25/25 runs pass (base: 24/25).
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".