Repository navigation
feat(core,auth,store,audit)!: hermetic test runs with declared seeds; expectJson; resolved captures in failures (#930) - #947
Merged
Conversation
… expectJson; resolved captures in failures (#930) Test, audit and benchmark (and MCP run_tests) never touch the site's live data. With --host-file, loadOperatorHost composes the host on a fresh temporary data directory (a module URL of its own, so host.mjs runs again per run) and removes it on close. composeHost hands every extension host() two new HostContext fields, data and hermetic. The first-party extensions keep every file there, whatever database/STORE_DATABASE/secretFile name; auth creates Better Auth's tables at activation and signs with a throwaway secret. A hermetic registration may declare seedSchema. Core reads the project's tests/seed.json, validates each entry against the named registration's seedSchema and passes it as ExtensionActivation.seed to the first activation of the run only (never after a restart step, a reload, dev, serve or validate). An entry for an unregistered extension, or one without a seedSchema, is refused before serving, so a seed cannot reach live data. auth seeds users with fixed ids; store seeds membership members as `members add` does. Fixtures gain expectJson: RFC 6901 pointers to the value each must equal (deep equality), with {{name}} references, a whole reference standing for the number or boolean a json capture kept. It counts as an assertion for coverage. urlcode test prints a failing case's path as sent (fixturePath as written when different). json and header captures are shown; a capture declared secret: true, and any cookie, stays {{name}} / <cookie NAME>. verify-deployment still names fixtures as written. The GitHub action validates statically and runs test/audit hermetically, so CI provisions no account, membership, migration or auth secret. The Better Auth and Auth.js proofs declare their seeds. Docs: READINESS (test data and seeds, expectJson, output), EXTENSIONS (hermetic runs), CI, STORE, auth/store READMEs, RIM-EXT-HERMETIC-001, llms.txt, starter AGENTS.md. Package budgets re-measured. Co-Authored-By: Claude Opus 5.5 <[email protected]>
jimhoyd
enabled auto-merge (squash)
September 29, 2026 18:31
--local-review and hermetic runs compose: the store-credits recipe seeds its issuer from tests/seed.json instead of adding it to the live database, and the recipe tests assert nothing reaches the configured database. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
jimhoyd
added a commit
that referenced
this pull request
Sep 29, 2026
…se and hermetic seeding compose Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Sep 29, 2026
Merged
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 #930
All three items from the second agent-workflow trial.
1. Hermetic test runs with a declared seed
Design.
urlcode test,urlcode audit,urlcode benchmarkand the MCP server'srun_testsnever touch the site's live data. Everything goes through the generic extension contract. Core imports no package (the boundary check passes).loadOperatorHost(..., { hermetic: true })creates a fresh temporary directory and exposes it through aSymbol.forslot (the same pattern as the revision pin). It importshost.mjsunder a query of its own, so every run composes its own extensions, andclose()removes the directory after the extensions release it.HostContextgainsdata(<site>/data, or the run's temporary directory) andhermetic.A hermetic host keeps every file under
data, whatever the operator's options or environment name. It creates what an operator would (schema, a throwaway signing secret). Only then may it declareRuntimeExtension.seedSchema.Core reads the project's optional
tests/seed.json, an object keyed by extension name. It validates each entry against that registration'sseedSchemaand passes it asExtensionActivation.seed. This happens only on the first activation of the run: never after arestartstep, a reload,dev,serveorvalidate.An entry is refused before serving (
invalid-seed) when:seedSchema;So a seed cannot reach live data, even if a caller passes the harness its own non-hermetic registrations.
auth: in a hermetic run it uses a fresh database, a random secret (it ignores
database,secretFileandBETTER_AUTH_SECRET), and runsmigrateat activation. The seed{"auth": {"users": [{id, email, password, name?}]}}creates accounts through Better Auth's own adapter and password hashing, with fixed ids.store: in a hermetic run it uses a fresh database (it ignores
databaseandSTORE_DATABASE). The seed{"store": {"members": {"<membership collection>": ["<principal id>"]}}}adds members asurlcode-store members adddoes: actoroperator, audited whenaudit: true.audit: in a hermetic run it uses a fresh database.
dev,serve,validateandrouteskeep using<site>/data.validatestays the preflight for whatservewill use, including a missing secret or unmigrated tables, whichtest:proofstill asserts.CI: the action's Validate step is now static, and Test and Audit run hermetically with
host-file. CI therefore provisions no account, membership, migration ordata/auth.secret.Why this shape: the data is declarative JSON beside
tests/requests.json, and each extension owns its seed shape through the existing registration contract. Core only routes it, so a third-party extension opts in the same way.2.
expectJsonexpectJson: {"/balance": 100, "/owner/tags": ["a","b"]}takes RFC 6901 pointers (""is the whole body;~0and~1are escapes).{{name}}references. A string that is exactly one reference to a number or boolean kept by ajsoncapture stands for that value, so"/balance": "{{bal}}"matches100.check: "json"with the pointer, the expected value and the actual value.3. Resolved captures in failure output
urlcode testcase printspathas sent (/probe/acct-7f3a/100), plusfixturePathas written when that differs.jsonandheadercaptures are shown resolved. A capture declared"secret": true, and any cookie, is still redacted as{{name}}/<cookie NAME>.verify-deploymentstill names fixtures as written, because a live deployment's values can be real.Evidence
test/hermetic-accounts.test.tsruns end to end with the real auth and store extensions:readersmount gated by thereviewersmembership, and host options pointing at a "live" store path and a missing secret.data/nor the live path is ever created.test/hermetic-host.test.ts:test/fixture-json.test.tscovers pointer matching and escapes, mismatch reports, typed whole references, the resolved path withfixturePath, secret redaction, audit coverage and file-level refusals.packages/auth/test/auth.test.ts: a hermetic host ignores the site database and secret, migrates, seedsannand signs in withidentity.userId === "ann". A non-hermetic registration declares noseedSchema.app/tests/seed.json. The Auth.js proof's setup now uses fixed ids, so its reviewer membership can be seeded.test:proofandtest:proof:authjspass.npm run verifyis green, including every workspace,audit:packages,test:addons,test:proof,test:proof:authjsandtest:ecosystem.npm run test:packageis green.Breaking:
json/headervalues now print inurlcode testfailures; mark credential capturessecret: true.HostContexthas two new fields, so a host hook that checks its exact keys needs updating.Docs: READINESS (a new "Test data and seeds" section, plus
expectJsonand the output rules), EXTENSIONS ("Hermetic runs and test seeds" and the hostctx), CI andaction.yml, STORE, the auth and store READMEs, the CHANGELOGs, a newRIM-EXT-HERMETIC-001card, FRAMEWORK, AI-AUTHORING, llms.txt and the starter AGENTS.md.Limits
HostContext.datacan still read or write whatever its options name. The Auth.js proof's provider, for example, still reads theusers.jsonthat setup writes. Core cannot enforce this, and the README says so.validateandrouteswith--host-filestill activate against the site's data by design.🤖 Generated with Claude Code