Skip to content

Carry trust-by-default into the CLI, the recipes and the checker - #170

Merged
jimhoyd merged 1 commit into
mainfrom
claude/trust-model-sweep
Sep 19, 2026
Merged

jimhoyd merged 1 commit into
mainfrom
claude/trust-model-sweep

Conversation

@jimhoyd

@jimhoyd jimhoyd commented Sep 19, 2026

Copy link
Copy Markdown
Collaborator

Closes #169. Addresses the core half of #168.

A fan-out audit across all nine URLCode repositories found the same pattern everywhere: the 0.4.0-alpha.2 trust reversal landed carefully in the runtime's descriptive surfaces — src/capabilities.ts, src/context.ts, src/types.ts and the JSON schema are all correct and precise — and then stopped. The CLI strings, the recipe catalog and the packaging still describe the previous default.

Shipped output, not documentation

Surface Was Why it matters
urlcode doctor functionSandbox:"quickjs-wasm", network:false, filesystem:false, guestNetwork:false Machine-readable, unconditional, and wrong for any route without sandbox: true — trusted routes have full fs and network. An operator or CI job can gate on this.
urlcode --help "Functions run in WASM isolation" The first thing a new user reads.
Homebrew caveats "Live short-link storage needs a Node build carrying the patched SQLite WAL fix" Shown on every brew install, for a feature core does not have.

doctor now reports functionDefault, sandboxEngine, and the trusted/sandboxed capabilities as separate fields, because the honest answer is per-route and a single boolean cannot carry it:

"functionDefault":"trusted-in-process","sandboxEngine":"quickjs-wasm",
"trustedFilesystem":true,"trustedNetwork":true,
"sandboxedFilesystem":false,"sandboxedNetwork":false

This is a breaking change to doctor's output shape. It is deliberate: the field name functionSandbox encodes the assumption that there is one answer. The Homebrew formula test asserted the old field — it passed because of the bug — and is updated in the same commit.

Agent-facing text, which re-emits into every generated project

  • src/agents-guide.ts and all four skill copies gave "untrusted input" as a reason to add sandbox: true. That is precisely the trusted-code/trusted-data conflation: request data is untrusted in both modes, and this taught agents to sandbox any public endpoint reflexively. The criteria are now about code authorship and say so explicitly.
  • Nine of eleven recipes described their functions as sandboxed; only webhook-receiver declares it. Two were wrong about security, not just vocabulary:
    • recipes/middleware told readers "The guest exposes no crypto, so none of these modules can verify signatures or hash passwords." A trusted route has all of node:crypto — the advice actively blocked correct signature verification.
    • recipes/authenticated-json-api credited "the sandbox" for withholding Authorization/Cookie. The host does that before dispatch, identically in both modes; attributing it to the sandbox teaches that the protection is a sandbox property.
    • recipes/cors-api gave the wrong reason for the serverless refusal — middleware needs the self-hosted Node lifecycle, not a sandbox.
  • scripts/generate-claude-plugin.ts published a short-links keyword for a retired capability.

The checker is widened to the surfaces that let this through

check-trust-model-prose.ts scanned Markdown only, so src/ and recipes/ were entirely invisible — which is exactly where the cluster was. It now also scans:

  • comments in src/, recipes/, scripts/, benchmarks/
  • the description / tags / behavior values in recipe.yaml, example.yaml and urlcode.yaml — these are emitted verbatim by explain, context, the manifest, urlcode recipes show and MCP search_recipes, making them among the most agent-facing strings in the repo, and they were completely unguarded

A new outside-the-sandbox rule covers a phrasing that had been corrected by hand twice with no rule behind it. It immediately found a third instance, in docs/policies/security.md:3, that two manual sweeps (including #165, which claimed those were "the last two occurrences") had missed. That is the argument for the rule in one line.

Coverage: 185 files → 414.

Verification

  • npm run verify — lint, typecheck, check, build, 512 tests: 510 pass, 2 skipped, 0 fail
  • Both new checker capabilities regression-tested by reintroducing a defect and confirming the failure names the right file and line:
    • a sandboxed function description in recipes/json-api/recipe.yaml → caught at recipe.yaml:2
    • the restored tree → clean
  • node src/cli.ts doctor output inspected directly

Two things worth reviewing closely

  1. The doctor output shape change is breaking, as described above.
  2. The generated AGENTS.md has a hard 80-line budget (test/cli.test.ts:28). Fitting the corrected criterion required rewording the surrounding sentence to stay net-zero on lines rather than raising the budget. Worth a look that nothing valuable was squeezed out — the trade I made was dropping "and say why in description" in favour of the more precise sandboxReason.

Compatibility and security

No runtime behavior change. The only executable change is doctor's report fields. No schema or API change.

  • Changes match the documented portable contract; docs/examples are updated where needed.
  • Relevant tests and package checks pass, or limitations are explained above.
  • No credentials, customer data or private project material are included.
  • Runtime/starter changes remain aligned where applicable.

🤖 Generated with Claude Code

An audit across every URLCode repository found the 0.4.0-alpha.2 reversal
landed carefully in the runtime's descriptive surfaces and then stopped:
src/capabilities.ts, src/context.ts, src/types.ts and the schema are all
correct, while the CLI strings, the recipe catalog and the packaging still
describe the previous default.

Shipped output, not documentation:

- `urlcode doctor` reported `functionSandbox: 'quickjs-wasm', network: false,
  filesystem: false, guestNetwork: false` as unconditional environment facts.
  For any route without `sandbox: true` the last three are simply wrong —
  trusted routes have full filesystem and network. It now reports
  `functionDefault`, `sandboxEngine`, and the trusted/sandboxed capabilities
  separately, because the honest answer is per-route and one boolean cannot
  carry it. This changes `doctor`'s output shape; the Homebrew formula test
  asserted the old field and is updated with it.
- `urlcode --help` said "Functions run in WASM isolation".
- The Homebrew formula's caveats warned about a SQLite WAL build requirement
  for "live short-link storage" — a feature core does not have.

Agent-facing text, which re-emits into every generated project:

- The generator and all four skill copies gave "untrusted input" as a reason
  to add `sandbox: true`. That is the trusted-code/trusted-data conflation:
  request data is untrusted in both modes. The criteria are now about code
  authorship, and say so explicitly.
- Nine of eleven recipes described their functions as sandboxed while only
  `webhook-receiver` declares it. Two were wrong about security, not just
  vocabulary: `recipes/middleware` told readers the guest has no crypto (a
  trusted route has all of `node:crypto`, so the advice blocked correct
  signature verification), and `recipes/authenticated-json-api` credited the
  sandbox for withholding `Authorization`/`Cookie` when the host does it in
  both modes.
- `scripts/generate-claude-plugin.ts` published a `short-links` keyword.

The checker is widened to the surfaces that let all of this through. It now
scans `src/`, `recipes/`, `scripts/` and `benchmarks/` comments, and the
`description`/`tags`/`behavior` values in `recipe.yaml`/`example.yaml`/
`urlcode.yaml` — those reach agents verbatim through `explain`, `context`,
the manifest and MCP `search_recipes`, and were previously invisible. A new
`outside-the-sandbox` rule covers the phrasing that had been fixed by hand
twice with no rule behind it; it immediately found a third instance in
docs/policies/security.md that two manual sweeps had missed. Coverage goes
from 185 files to 414.

Also: docs/PRERENDER.md still linked to urlcode-docs as a live showcase, and
docs/NEXT-STEPS.md still taught `auth: { required: true, roles: [admin] }` —
`roles` plural, which `routeAuth`'s `additionalProperties: false` rejects
(issue #168).

Verified: npm run verify — 512 tests, 510 pass, 2 skipped, 0 fail. Both new
checker capabilities regression-tested by reintroducing a defect and
confirming it fails with the right file and line.

Co-Authored-By: Claude Opus 5 <[email protected]>
@jimhoyd
jimhoyd merged commit db375bf into main Sep 19, 2026
10 checks passed
@jimhoyd
jimhoyd deleted the claude/trust-model-sweep branch September 19, 2026 19:37
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.

urlcode doctor reports the pre-0.4.0-alpha.2 trust model as machine-readable fact

1 participant