Skip to content

Add sandboxReason field and a non-blocking audit heuristic - #149

Merged
jimhoyd merged 1 commit into
mainfrom
feat/sandbox-reason-audit-heuristic
Sep 19, 2026
Merged

jimhoyd merged 1 commit into
mainfrom
feat/sandbox-reason-audit-heuristic

Conversation

@jimhoyd

@jimhoyd jimhoyd commented Sep 19, 2026

Copy link
Copy Markdown
Collaborator

Fixes #135

Part 1 — sandboxReason

An optional sandboxReason string on function/middleware routes, alongside the existing sandbox boolean:

  • Parsed and ajv-validated: type: string, maxLength: 500 (schemas/urlcode.schema.json).
  • Stored on the compiled route (RouteConfig/CompiledRoute in src/types.ts) — a structured field, not just a source comment.
  • Applies regardless of sandbox's value: a route author can explain either "why this needs isolation" (sandbox: true) or "why this is safe to trust" (sandbox: false/absent).
  • Surfaced next to the existing sandbox boolean in urlcode explain's handler output (src/explain.ts) and urlcode context's per-route listing (src/context.ts) — the same code path Update stale skill files and surface sandbox in explain/context #134 used to add sandbox there, so the MCP explain/get_context tools pick it up automatically.
  • recipes/webhook-receiver/urlcode.yaml now declares sandboxReason (moving what was only a source comment into structured YAML tooling can read).

Part 2 — non-blocking urlcode audit heuristic

src/readiness.ts's auditProject now returns an advisories: {route, message}[] array. A route is flagged when it:

  • runs project code (function or middleware),
  • accepts POST,
  • declares a request.body policy, and
  • declares neither sandbox: true nor sandboxReason.

The message: "This route accepts POST with a declared request.body policy but declares neither sandbox: true nor sandboxReason; consider whether this route needs sandbox: true."

This is advisory only — it never affects ready, never touches the CLI's exit code, and never infers the actual trust decision (which docs/AI-AUTHORING.md is explicit tooling cannot do). Setting either sandbox: true or sandboxReason (with sandbox either true or false) silences it.

Docs

  • docs/AI-AUTHORING.md's "Deciding when a route needs sandbox: true" section now describes sandboxReason and the audit heuristic.
  • docs/YAML-REFERENCE.md and llms-full.txt regenerated (npm run docs:reference, npm run docs:llms).

Tests

  • test/config.test.ts: schema accepts sandboxReason with sandbox either true or false, accepts exactly 500 chars, rejects 501.
  • test/explain.test.ts: explain surfaces sandboxReason for both a trusted route (undefined) and the sandboxed webhook-receiver recipe (set).
  • test/context.test.ts: same, via context's per-route listing.
  • test/readiness.test.ts: the heuristic fires on a matching route, stays silent when sandbox: true or sandboxReason is set, stays silent when there's no request.body policy or the route isn't POST, and ready/exit-code semantics are unaffected either way.

Verification

  • npm run typecheck — green
  • npm run lint — green
  • npm run docs:reference — regenerated docs/YAML-REFERENCE.md
  • npm run docs:llms — regenerated llms-full.txt
  • npm run verify — green (495 tests, 493 passed, 2 pre-existing skips, 0 failures)

CI passing and these regression tests are evidence for this change's own scope; they are not an independent security review of the broader trust model, and this PR does not claim to be one.

🤖 Generated with Claude Code

https://claude.ai/code/session_018neC2tYKPxMPbzZf1wNctr


Generated by Claude Code

Part 1: an optional `sandboxReason` string on function/middleware routes,
ajv-validated (max 500 chars, schemas/urlcode.schema.json) and stored on the
compiled route alongside `sandbox`. It applies regardless of whether
`sandbox` is true or false, so an author can record why a route needs
isolation or why it is safe to trust. Surfaced next to the existing
`sandbox` boolean in `explain`'s handler output and `context`'s per-route
listing, the same way #134 added `sandbox` there. recipes/webhook-receiver
now declares it, replacing what was only a source comment.

Part 2: a non-blocking advisory in `urlcode audit`: a route that runs
project code, accepts POST with a declared `request.body` policy, and
declares neither `sandbox: true` nor `sandboxReason` is flagged under a new
`advisories` array on the audit report ("consider whether this route needs
sandbox: true"). It never affects `ready` or the CLI's exit code — same
non-blocking spirit as the rest of `audit`'s reporting.

Update docs/AI-AUTHORING.md's "Deciding when a route needs sandbox: true"
and regenerate docs/YAML-REFERENCE.md and llms-full.txt. Add regression
tests: schema accept/reject including the length cap, explain/context
surfacing, and the audit heuristic firing/staying silent without changing
readiness.

Claude-Session: https://claude.ai/code/session_018neC2tYKPxMPbzZf1wNctr

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@jimhoyd
jimhoyd force-pushed the feat/sandbox-reason-audit-heuristic branch from c4c6e64 to 33c2445 Compare September 19, 2026 13:20
@jimhoyd
jimhoyd merged commit 734527d into main Sep 19, 2026
10 checks passed
@jimhoyd
jimhoyd deleted the feat/sandbox-reason-audit-heuristic branch September 19, 2026 13: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]: surface the sandbox trust decision in audit/explain, not just prose comments

2 participants