Repository navigation
Let examples/prerender run trusted, and fix the claim instead - #167
Merged
Merged
Conversation
#166 resolved this example's false isolation claim the wrong way round. The comment in functions/page.mjs said the code "runs in the QuickJS/WASM sandbox with no filesystem, network or host code" while no route declared `sandbox: true`; #166 made the claim true by adding `sandbox: true` to all three routes. The code was right and the comment was wrong, not the reverse. docs/AI-AUTHORING.md is explicit: "Do not add `sandbox: true` reflexively to every route 'for safety' — it costs the route the worker-pool capacity ceiling and the ability to use `fetch`, Node builtins, the filesystem or npm packages, for isolation most routes do not need." It then lists the three cases that do warrant it: unreviewed code, a secret whose blast radius matters, or logic complex enough that limiting a bug's reach is the margin wanted. This example meets none of them. `page` is seven lines of reviewed first-party code whose whole body is `new Response(args.body)`, with literal arguments from urlcode.yaml — the trusted default's own case. Shipping the flagship recipe with a reflexive opt-in taught readers to cargo-cult `sandbox: true` and made the example contradict the guidance page. So the three declarations come out and the prose describes what actually runs. "Guest execution"/"guest code" also becomes "project code" where it meant the route's own handlers: under the trusted default those are in-process project code, not a guest. docs/PRERENDER.md already described prerendering as mode-agnostic, and the example now matches it: the README says a route declaring `sandbox: true` prerenders the same way. The `unbacked-isolation-claim` check added in #166 still does its job, and does it in the right direction — it requires prose and YAML to agree, not that a project be sandboxed. Verified both ways: the tree passes, and re-adding a QuickJS claim to page.mjs fails the check naming that line. Verified: npm run verify — 512 tests, 510 pass, 2 skipped, 0 fail. The recipe runs end to end: 7 fixtures, 3 pages rendered, audit 12/12. Co-Authored-By: Claude Opus 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.
Corrects #166. That PR fixed
examples/prerender's false isolation claim by making the claim true — addingsandbox: trueto all three routes — when the code was right and the comment was wrong.Why the example should be trusted
docs/AI-AUTHORING.md, "Deciding when a route needssandbox: true":It then names the three cases that warrant it: code nobody has reviewed, a secret whose blast radius matters, or logic complex enough that limiting a bug's reach is the safety margin wanted.
The example meets none.
functions/page.mjsis:Reviewed first-party code, literal arguments from
urlcode.yaml, no secret, no untrusted input, no I/O. That is the trusted default's own case. Shipping the flagship recipe with a reflexive opt-in teaches readers to cargo-cultsandbox: trueand puts the example in direct conflict with the guidance page.What changed
sandbox: truedeclarations are removed; the YAML comment now says why the default is right here and points at the guidance section.functions/page.mjs's comment describes trusted in-process execution and says there is nothing here forsandbox: trueto isolate.sandbox: trueprerenders the same way — prerendering does not care either way.docs/PRERENDER.mdalready said that; the example now matches it.The check from #166 is unaffected, and points the right way
unbacked-isolation-claimrequires prose and YAML to agree; it does not require a project to be sandboxed. Verified in both directions on this branch:So the original defect stays caught, whichever way a future edit resolves it.
Verification
npm run verify— 512 tests, 510 pass, 2 skipped, 0 failtestpasses 7 fixtures,prerender.mjsemits 3 pages,audit --expect-routes 3passes 12/12Compatibility and security
The example's routes now run trusted rather than sandboxed. That is a behavior change to an example project, not to the runtime, and it restores the default the runtime already applies to any route that declares nothing. No runtime, schema or API change.
🤖 Generated with Claude Code