Files
hermes-agent/scripts/bundles
BearHuddleston 58e0b85e91 fix(bundles): bake the interpreter's stdlib and every existing pyc as unchecked-hash
A sealed macOS bundle is user-writable, so any payload Python that runs without
a cache prefix rewrites stale bytecode inside the signed app. codesign then
reports "file modified", spctl rejects the app, and the next Squirrel.Mac
update waits on a Gatekeeper prompt. The shipped Nov 10 canary (da06acacc9),
inventoried on a real Mac, had:

- stdlib: 1,061 modules, 140 timestamp pycs (all stale: they record the
  2024-01-01 source mtime, the .py files carry the build time) and 921 with
  no pyc at all. bake_bytecode never compiled the interpreter's own library.
- venv site-packages: all 25,439 pycs timestamp-based and stale; pm-runtime:
  all 61. uv's --compile-bytecode writes timestamp pycs, and compileall
  without -f keeps a timestamp pyc whose mtime still matches, even in
  unchecked-hash mode, so the bake left them as they were. Packaging then
  moved the sources' mtimes.
- hermes-agent: unchecked-hash, as intended.

On that build, Desktop's ticket helper rewrote 94 stdlib pycs inside the app,
and a `python -I` import of the gateway (which ignores PYTHONPYCACHEPREFIX)
wrote 248 (103 stdlib, 145 venv).

The bake now also compiles the staged interpreter's library, found by
CPython's own landmark (os.py) beside the binary and refused when it lies
outside the payload, and forces every root (-f) so existing timestamp pycs
become unchecked-hash too. The same payload baked with this change on the Mac:
every module in all four roots unchecked-hash, nothing stale or missing, and
neither the ticket helper nor the `python -I` import wrote a file. The bake
took 25 s there; the stdlib grows by about 16 MiB. The prepared-payload
digests skip __pycache__, so they are unchanged.

Windows and Linux install trees are read-only, so their payloads never hit the
seal break. The Windows launcher reads these source-adjacent pycs (it sets no
cache prefix for a baked payload), so there the change only removes
recompiles.
2026-11-12 22:34:16 -06:00
..