Repository navigation
fix(core): hermetic runs enforce the data handover and clean up their directories (#976, #977) - #987
Merged
Merged
Conversation
… directories (#976, #977) #976: the hermetic obligation (keep every file under context.data) is now extension contract 2. A contract-1 extension is refused before its host() runs. composeHost records on the host it returns, under a Symbol.for key, the data directory it gave every host(); a hermetic load refuses a host with registrations that lacks that record for its own directory (hermetic-host-unconfirmed), so an older core copy's composeHost or hand-made registrations can no longer run a hermetic check against the site's live data/. Every first-party descriptor and definition, fixture, recipe, proof and the #844 contract test move to contract 2; the ecosystem proof host is composed with composeHost. #977: run directories are named urlcode-<hermetic|data>-<pid>-XXXXXX and tracked; an exit hook removes what is left, non-serving commands close the host and exit 130/143 on SIGINT/SIGTERM, the unhandled-rejection path goes through the same bounded close, and the MCP runners send SIGTERM with a 5 s grace before SIGKILL. The first run directory of a process sweeps stale ones: lstat-checked real 0700 directories owned by this user, an hour old, whose pid is gone; removal never follows a link. Co-Authored-By: Claude Opus 5.5 <[email protected]>
jimhoyd
enabled auto-merge (squash)
September 29, 2026 22:32
) The sweep test expects the 0755 directory to be swept on win32, where there is no uid or mode to check; the signal subtests skip on win32, where kill() ends the process without running handlers; the child's temp directory is redirected with TEMP/TMP as well as TMPDIR and keeps the system environment Windows needs. Docs state the Windows limitation. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…generate references Co-Authored-By: Claude Opus 5.5 <[email protected]>
…generate references Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Sep 29, 2026
…generate references Co-Authored-By: Claude Opus 5.5 <[email protected]>
…generate references Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Sep 30, 2026
…generate references Co-Authored-By: Claude Opus 5.5 <[email protected]>
…generate references Co-Authored-By: Claude Opus 5.5 <[email protected]>
…generate references Co-Authored-By: Claude Opus 5.5 <[email protected]>
…generate references Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ectory's newest entry (#976, #977) #976 review: the hermetic confirmation was a key on the host object, so a host.mjs that spread or reused a composeHost result could carry a hand-made registration past it (reproduced writing the site's data/). A hermetic load now puts a fresh WeakSet in a Symbol.for slot beside the data directory, composeHost adds each registration it composed, and the load refuses unless every exported registration is in the set. Docs state it is a correctness check (host code is trusted), not a security boundary. #977 review: the one-hour guard read the directory's own mtime, which a database write inside does not change. The sweep now requires the directory and everything in it (bounded lstat walk: 1,024 entries, 8 levels, never following links; kept beyond the bound) to be an hour old. npm test and test:shard preload test/scratch-tmpdir.ts, which points TMPDIR/TEMP/TMP of the run and every process it spawns at a scratch directory, so tests never sweep the developer's real temporary directory. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Collaborator
Author
|
Added 1d410c3 (after merging main at 0017bcc). It fixes the two review findings on #976 and #977. #976: the confirmation is now checked per registration, not per host object.
#977: the sweep's age now comes from the newest entry in a directory.
Local results (macOS, Node 26): |
…generate references Co-Authored-By: Claude Opus 5.5 <[email protected]>
…generate references Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ce, not a serialized value CodeQL js/bad-code-sanitization flagged JSON.stringify interpolated into generated JavaScript in test/hermetic-hardening.test.ts; the schema is constant, so it is now written as literal source. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #976
Fixes #977
#976: a hermetic run can no longer write the site's live data
Core can't see where trusted extension code writes, so it now refuses the two things that could not have agreed to the hermetic obligation.
context.datawhenhermeticis true is now extension contract 2 (extensionContract = 2). A contract-1 extension (anything built before feat(core,auth,store,audit)!: hermetic test runs with declared seeds; expectJson; resolved captures in failures (#930) #947) is refused wherever contracts are checked:add,list --strict, staticvalidate,defineExtension, andcomposeHostbefore itshost()runs. Every first-party descriptor and definition moves to 2, along with the fixtures, recipes, the Auth.js proof and the [Request]: Support independent provider packages and standard inert artifacts #844 contract test. The "future contract" fixtures move to 3.composeHostrecords the data directory it gave everyhost()on the host it returns, underSymbol.for('urlcode.host.hermeticConfirmation').test,audit,benchmark, MCPrun_tests, or a--local-reviewvalidate/routes) refuses a host that has registrations unless that record names its own directory. The refusal code ishermetic-host-unconfirmed.composeHost, or registrations written by hand.Symbol.forkey so a second core copy agrees on it,Object.keys(the host settings check) never lists it, and ahost.mjsthat spreads the composed host keeps it.host.mjsis trusted operator code.Why this option. I chose bump plus confirmation over having extensions declare where they write:
-wal,-shmand journal siblings.The bump alone doesn't catch an older
composeHost, and the confirmation alone doesn't catch a contract-1 extension composed by this core. Together they close both routes in #976, and they stay generic in core: no package import. Comment drift fixed:HostContext.data/hermeticandLoadOptions.hermeticnow include the local review.Behaviour change. A hand-written host (
export default {extensions:[registration]}) still serves, inspects and runs a pinnedvalidate, but a hermetic run refuses it. The fix is to wrap each registration in adefineExtensiondefinition and compose them.proofs/ecosystem/host.mjsand three tests that rantest/run_testwith hand-written hosts were converted.#977: temp directories are cleaned up and swept
Run directories (the hermetic data directory, and the per-run
URLCODE_DATA_DIRfromstartRestartableandstartServer({isolateData})) are now namedurlcode-<hermetic|data>-<pid>-XXXXXXunder the OS temp dir. They are created and tracked bypackages/core/src/temp-dirs.ts.A process
exithook removes any that are still tracked.process.exitreaches that hook from:dev,serveandstudioswap that handler for their graceful stop.The MCP runners send SIGTERM and wait 5 s before SIGKILL.
Sweep. SIGKILL can't be caught, so the first run directory a process creates first sweeps stale ones. A directory is removed only if all of these hold:
lstatshows a real directory, not a link;Removal never follows a symlink. The one-hour age guard covers a pid from another pid namespace sharing
/tmp.Docs
RIM-EXT-HERMETIC-001, docs/EXTENSIONS.md (hermetic runs, the extension contract, hand-written hosts), docs/READINESS.md (test data and seeds), SECURITY.md, llms.txt / llms-full.txt, proofs/ecosystem/README.md.
Evidence
test/hermetic-hardening.test.ts(new):host(), withdata/never created;urlcode test --local-reviewchild with a seeded host killed by SIGINT (130), SIGTERM (143) and ended by an unhandled rejection (1), leaving nourlcode-*directory in itsTMPDIR.test/operator-host.test.ts: contract 2 and a contract-1 refusal.npm run verifyandnpm run test:packagepass locally (Node 26, macOS). Core packs 1056122 bytes, inside the fix(store): deterministic operator-audit lease; package budgets as measurement plus margin (#971) #975 budget; no budget edit.Limitations
🤖 Generated with Claude Code