Skip to content

Scope guest limitations to sandbox: true in live guidance (#196) - #210

Merged
jimhoyd merged 2 commits into
mainfrom
claude/issue-196-trust-docs
Sep 20, 2026
Merged

jimhoyd merged 2 commits into
mainfrom
claude/issue-196-trust-docs

Conversation

@jimhoyd

@jimhoyd jimhoyd commented Sep 20, 2026

Copy link
Copy Markdown
Collaborator

Closes #196.

Live documentation still taught the pre-0.4.0-alpha.2 restrictions as unconditional facts about the runtime. npm run check passed them because none of the prose gate's rules matched the forms used.

Every claim the issue listed was verified against current source before being touched, and the runtime-behavior ones were reproduced.

Confirmed and fixed

Claim Verification
docs/yaml/functions.md:57-58 — Node APIs, npm imports, network and filesystem "do not" work Wrong for the default. src/trusted-functions.ts imports the module directly with no allowlist; a trusted function reading node:fs, os.hostname and fetch served 200 with all three present.
docs/yaml/middleware.md:26 — the chain shares "one sandbox/deadline" The chain shares the route's execution mode plus one deadline; on the default route there is no sandbox.
docs/MIDDLEWARE.md:49-56 — no clone(), native bodies opaque Reproduced both directions: a trusted middleware wrapping respond: {text: hello} returns HELLO and has clone(); the identical sandbox: true route 502s on each.
docs/SPECIFICATION.md:214 — .js is ESM independently of Node package settings Reproduced exactly as reported. With {"type":"commonjs"}, an ESM f.js fails trusted activation ("Function initialization failed"); the identical sandbox: true route serves 200. .mjs works in both modes.
README.md:35, docs/FRAMEWORK.md:47 — grants as the only path for secrets Grants govern the injected env/secrets context; trusted in-process code reaches the host environment on its own. Both rewritten to say which one is meant.
docs/READINESS.md:13 — "the same isolated runtime" It activates each route in that route's declared mode.
test/typescript-authoring.test.ts:10 — "executes only in QuickJS" The fixture declares no sandbox, so it exercises the trusted path. Renamed to name the mode it actually runs.

Found by the new rules, not in the issue

  • docs/TOOLING.md:84 summarized get_context's constraints as "no guest network, no Node APIs" while src/context.ts has emitted the correct trusted-default notes for both since the reversal. The emitted data was right; only the doc describing it was stale.
  • The cookbook and recipe envelope.mjs comment claimed native bodies are opaque, in projects that declare no sandbox and where that middleware can in fact read them.

Prose gate

scripts/check-trust-model-prose.ts keeps its existing design and opt-out markers, and gains:

  • six rules for the forms that slipped through (guest-only-execution, unscoped-no-node-access, chain-shares-a-sandbox, unscoped-response-limits, isolated-runtime, grants-are-the-only-path);
  • test-name scanning: a test name is a claim, so the title argument of test/it/describe in test/ is read alongside comments — never the fixture source those calls embed;
  • a regression fixture per rule, pinning the sentence that shipped green together with the wording that replaced it. Fixtures run on every invocation, a rule without one fails, and a "corrected" wording that trips any rule fails too.

Advisory review (recommendation only, not changed)

src/readiness.ts:67's POST-plus-request.body nudge keys on request shape, while docs/AI-AUTHORING.md tells authors to decide on code trust — so it can read as "untrusted input implies sandbox", the reasoning that guidance explicitly rejects. It is non-blocking and it already offers sandboxReason as an equal answer, so it still earns its place as a prompt to record a decision. Recommendation: keep the trigger, restate the message as a request to record the trust decision rather than a hint that the route may need isolation. Recorded on docs/OPEN-DECISIONS.md rather than acted on here.

Scope

Docs and tooling only. No sandbox boundary changed, and trusted host access is described as the documented default capability it is, never as a vulnerability. The docs/FRAMEWORK.md edit is confined to the one trust/secrets sentence, leaving #200's concurrent work on that file untouched.

Verification

  • npm run lint clean.
  • npm run check: all steps pass except check-workspace-links, which fails because this worktree has no node_modules — environmental, unrelated. Every subsequent step was run individually and passes.
  • npm test: 517/523 pass. The 5 failures are all test/install.test.ts, from the same missing node_modules (the spawned scripts/build.ts cannot resolve its dependencies). Unrelated to this change.
  • npm run typecheck still fails on scripts/release.ts (@types/semver), pre-existing and unrelated.

🤖 Generated with Claude Code

jimhoyd and others added 2 commits September 19, 2026 22:15
Live documentation still taught the pre-0.4.0-alpha.2 restrictions as
unconditional, and the prose gate passed them because none of its rules
matched the forms used. Each claim below was checked against the source
and, where it was about runtime behavior, reproduced.

- docs/yaml/functions.md listed Node APIs, npm imports, network and
  filesystem as unavailable directly under a route declaring no sandbox,
  where all four work. Rewritten to say so and to scope the removal to
  the opt-in.
- docs/yaml/middleware.md said the chain shares "one sandbox/deadline".
  It shares the route's execution mode, which on the default route is
  not a sandbox.
- docs/MIDDLEWARE.md presented the guest Response contract -- no
  clone(), opaque native bodies -- as the middleware contract. Confirmed:
  a trusted chain wrapping `respond: {text: hello}` reads the body and
  returns HELLO, and has clone(); the sandboxed counterpart 502s.
- docs/SPECIFICATION.md said .js is ESM independently of Node package
  settings. Reproduced: with {"type":"commonjs"} an ESM f.js fails
  trusted activation while the same sandboxed route serves 200.
- README.md and docs/FRAMEWORK.md made grants the only path by which a
  secret reaches code. Grants govern the injected env/secrets context,
  not ambient Node access. The FRAMEWORK.md edit is confined to that
  sentence (#200 is editing that file concurrently).
- docs/READINESS.md called the activated runtime isolated.
- docs/TOOLING.md summarized `get_context`'s constraints as "no guest
  network, no Node APIs" while src/context.ts has emitted the
  trusted-default wording for both since the reversal.
- The cookbook/recipe envelope middleware comment claimed native bodies
  are opaque in a project that declares no sandbox.
- test/typescript-authoring.test.ts named itself "executes only in
  QuickJS" over a fixture that omits sandbox and therefore ran trusted.

scripts/check-trust-model-prose.ts gains six rules for the forms that
slipped through, reads test names (a name is a claim) alongside comments,
and carries a regression fixture per rule -- the sentence that shipped
plus the wording that replaced it -- so a later loosening fails the gate
rather than silently reopening the hole. Every rule must have a fixture.

src/readiness.ts:67's POST-plus-request.body advisory is left alone; the
recommendation is recorded on the live decision list instead.

Co-Authored-By: Claude Opus 5 <[email protected]>
docs/CODEBASE-AUDIT-2026-09-20.md landed on main while this branch was open.
It quotes the very wording this change corrects -- finding 4 reproduces the
pre-trusted-default claims verbatim as its evidence -- so the new
grants-are-the-only-path rule reads the quotation as guidance and fails.

The file is a dated review of one commit and is not edited as its findings are
fixed, which is what the historical-file marker is for. The marker carries a
comment saying why, so it is not read later as a silenced live contradiction.

Co-Authored-By: Claude Opus 5 <[email protected]>
@jimhoyd
jimhoyd force-pushed the claude/issue-196-trust-docs branch from a2646fe to ac8f6f4 Compare September 20, 2026 03:18
@jimhoyd
jimhoyd merged commit f89d2a5 into main Sep 20, 2026
20 checks passed
@jimhoyd
jimhoyd deleted the claude/issue-196-trust-docs branch September 20, 2026 03:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Request]: Reconcile live function and middleware guidance with trust by default

1 participant