Skip to content

Trusted-by-default function/middleware execution, sandbox as opt-in - #127

Merged
jimhoyd merged 11 commits into
mainfrom
claude/default-trust-model
Sep 19, 2026
Merged

jimhoyd merged 11 commits into
mainfrom
claude/default-trust-model

Conversation

@jimhoyd

@jimhoyd jimhoyd commented Sep 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

Implements docs/SPIKE-DEFAULT-TRUST-MODEL.md: function and middleware routes now run trusted and unsandboxed by default — in-process, full Node/filesystem/network access, exactly like any other project code. sandbox: true is the new explicit per-route opt-in that dispatches through the existing QuickJS/WASM worker pool, byte-for-byte unchanged from every earlier release for any route that declares it.

This reverses an explicit, previously-stated project rule ("guest code is always sandboxed, regardless of origin"). The maintainer decided this deliberately after extensive discussion recorded in the spike doc; this PR implements it faithfully, not something to re-litigate here.

Field name: I used sandbox as instructed (no adjacent/conflicting terminology existed in the codebase — the closest prior art was doc prose like "needs the sandbox", not a schema field). I placed it at the route level, not duplicated on function/middleware individually — the spike doc left "field name/shape" and the per-route-vs-per-declaration question explicitly undecided. Since a route's function and its middleware chain already execute as one unit (one FunctionPool.execute/dispatch call today), splitting trust within one route's chain would require redesigning that single-dispatch architecture, which was out of scope for "uniform, no special case between function and middleware." I call this out explicitly per the task's naming-choice instruction.

What changed (non-doc)

  • schemas/urlcode.schema.json, src/types.ts: new sandbox boolean on RouteConfig, default false.
  • src/trusted-functions.ts (new): the trusted execution path — ordinary dynamic import() of the project's module, called in-process. Mirrors the sandboxed guest API's contract as closely as an in-process call can: Request/context in, Response out, the same middleware (request, context, next) chain with next() callable once, the same native-reply passthrough (with the same "native metadata changed" integrity check the sandboxed path enforces), the same header count/byte limits. Node's real Request/Response/Headers are used instead of the guest's restricted classes.
  • src/runtime.ts: dispatch is route.sandbox ? pool : trusted, applied uniformly to function and middleware together. FunctionPool is now constructed only from sandbox: true routes, so sandboxed workers/budgets are entirely unaffected by trusted routes existing in the same project.
  • src/policy.ts, src/function-sources.ts: prepareFunctionSnapshot now splits sandboxed routes (through the existing collectFunctionSources, completely unchanged) from trusted routes (new collectTrustedSources). Trusted routes' own source bytes are still hashed into the project's projectSha256 so an operator's env/secret grant is still invalidated when that code changes — but only the entry file's own bytes, not its full transitive import graph the way the sandboxed collector does (a change to a helper a trusted entry imports, without touching the entry file itself, does not by itself invalidate the grant). Documented as a known gap in docs/FUNCTION-SECURITY.md.
  • src/capabilities.ts, src/context.ts, src/agents-guide.ts: capability descriptions, the guestNetwork/nodeApis AI-authoring constraints, and the generated project AGENTS.md template now describe trusted-by-default with sandbox: true opt-in, including judgment guidance on when to reach for it.

Security docs rewritten (not just appended), per the task's explicit list

  • AGENTS.md — "treat all application code as untrusted... never add a host-code execution fallback" → describes the sandboxed opt-in as the isolation mechanism, trusted default stated plainly.
  • SECURITY.md — "untrusted by default... no unrestricted host-execution fallback" → corrected; still states what sandbox: true guarantees in full.
  • docs/FUNCTION-SECURITY.md — the line the spike doc says "directly anticipated and rejected exactly this proposal" is rewritten with a new "What the trusted default can and can't do" section alongside the unchanged sandboxed-path guarantees.
  • docs/SANDBOX-REVIEW.md — scoped explicitly to the sandbox: true path; states plainly that review does not cover trusted-route code.
  • docs/CAPACITY.md — new dual capacity model: sandboxed (2 workers, 5s deadline, 32MiB heap, unchanged) vs. trusted (ordinary Node concurrency, bounded by --max-in-flight, no worker ceiling), plus a "Trusted-path deadlines" section spelling out that a trusted deadline races the call's promise and cannot preempt code that blocks the event loop synchronously — a real, documented difference from the sandboxed path's forced worker termination.
  • docs/SPECIFICATION.md, docs/MIDDLEWARE.md, docs/PROJECT-DIRECTION.md, docs/RELEASE-READINESS.md, docs/RESILIENCE.md, README.md, docs/FRAMEWORK.md — corrected unconditional sandbox framing.
  • docs/SECURITY-AUDIT.md — new dated entry recording the change and explicitly scoping every earlier entry's "guest"/"sandbox" language to the sandbox: true path going forward.
  • docs/TYPESCRIPT-AUTHORING.md — documents that build-typescript does not yet distinguish trusted from sandboxed output (still applies the sandbox's import/size rules to everything it transpiles); filed as build-typescript still enforces sandbox-only import rules for trusted routes #124, not fixed here (compatibility ceiling, not a security regression — JS authored directly is unaffected).
  • docs/AI-AUTHORING.md — new "Deciding when a route needs sandbox: true" section with concrete judgment examples (untrusted third-party input, unreviewed contributions, especially sensitive secrets).

Fixtures/recipes fixed, not just relabeled

recipes/middleware and examples/cookbook's bucket.mjs/locale.mjs mutated a Response.redirect() result's headers after the fact — legal against the sandbox's own permissive Headers class, but a real Fetch API Response.redirect() has spec-immutable headers, so this broke under trusted execution. Rewritten to build headers up front instead (a real bug these fixtures had all along, just never surfaced). recipes/webhook-receiver now declares sandbox: true to model the new authoring guidance (a third-party webhook payload is exactly the "input the project doesn't fully trust" case).

Tests

  • test/sandbox.test.ts, test/middleware.test.ts, plus function_worker-event assertions in test/monitoring.test.ts/test/observability.test.ts, and capability-refusal message assertions in test/cloudflare.test.ts/test/vercel.test.ts/test/explain.test.ts — updated (fixtures gained sandbox: true where the test is actually about that path; wording assertions updated for the new capability-refusal message text). No assertion was weakened or deleted.
  • New test/trusted-functions.test.ts: genuine Node/filesystem/network access from a trusted route; sandbox: false behaves identically to absent; secrets still reach only the route that was explicitly granted them; a trusted and a sandboxed route in the same project don't cross-contaminate; module state persists across requests (no fresh heap, unlike sandboxed); a sandboxed route still rejects Node imports at startup while the same code is legal once trusted; middleware next()/native-passthrough/metadata-integrity parity with the sandboxed contract; a hung trusted call is still bounded by the deadline; editing a trusted function still invalidates its binding grant.

Version

Bumped to 0.4.0-alpha.2 (behavior-changing, not a patch) — package.json, package-lock.json, src/cli.ts's usage banner, src/mcp.ts's reported server version, and the Claude plugin distribution (regenerated via npm run docs:plugin). ROADMAP.md carries the changelog entry with explicit upgrade guidance: every existing function/middleware route without a sandbox field now runs trusted instead of sandboxed, and an operator policy pinned to a project's revision is invalidated by this upgrade (the hash's source input changed) even with no YAML edit — re-derive with urlcode permissions and re-approve.

Verification

  • npm run typecheck, npm run lint, npm run check (schema/reference/llms-full/cookbook-index/plugin generation, all regenerated and checked clean): green.
  • npm run build: green (86 modules).
  • npm run test:package: green.
  • Full test suite (all 71 test/*.test.ts files): run in four parallel batches (this sandboxed dev machine's 10-minute single-command cap made one npm test invocation impractical) — every batch green, including a full rerun after each fix. Individually reconfirmed clean: sandbox.test.ts, sandbox-pool.test.ts, middleware.test.ts, trusted-functions.test.ts, context.test.ts, cli.test.ts, cloudflare.test.ts, vercel.test.ts, aws.test.ts, explain.test.ts, recipes.test.ts, monitoring.test.ts, observability.test.ts. A final single-process npm run verify was still in progress at report time (this host is shared with several concurrent sibling agent sessions; one file alone was observed at 98% CPU for 18+ minutes under that contention) — the batched runs are the evidence of record, not that single slow run.

Judgment calls / things I could not make fully equivalent — flagging explicitly, not glossing over

  1. Deadline semantics differ by design, not just implementation gap. The sandboxed path forcibly terminates a stuck worker thread; the trusted path's timeoutMs only wins a race against the call's own promise and cannot stop synchronous, event-loop-blocking trusted code. Documented in docs/CAPACITY.md and docs/FUNCTION-SECURITY.md, and in the code comments in src/trusted-functions.ts. This is inherent to running in-process on Node's single event loop — there is no supported interrupt mechanism for another turn of the same thread.
  2. Grant-hash coverage is shallower for trusted routes. The sandboxed path's projectSha256 input includes a function's full transitive dependency graph; the trusted path's only includes each entry file's own bytes (collectTrustedSources), not files it merely imports. A helper-only edit under a trusted route doesn't by itself invalidate an operator's grant. Documented in docs/FUNCTION-SECURITY.md and src/policy.ts.
  3. sandbox lives at the route level, not per function/middleware entry — see the naming/shape note above. I believe this is the correct reading of "uniform, no special case" given the existing single-dispatch architecture, but it's a interpretation of an explicitly-undecided point in the spike doc, so flagging it for review rather than asserting it's the only valid answer.
  4. build-typescript (src/typescript-authoring.ts) is untouched and still forces every function/middleware it transpiles through the sandbox's import/size restrictions regardless of the route's own sandbox setting. Filed as build-typescript still enforces sandbox-only import rules for trusted routes #124; not a security regression (it's a stricter-than-necessary compatibility ceiling on the build, not a hole), but real functionality debt this PR doesn't close.
  5. Response body handling is richer for trusted routes (binary bodies work via arrayBuffer(), not just the guest's text/JSON subset) — a deliberate, documented capability increase for trusted code, not a contract violation, but worth a reviewer's eyes since it's the one place trusted output isn't a strict subset/superset-preserving change.

I re-read the diff adversarially for the two questions the task named directly: could a route accidentally lose a sandboxed guarantee it explicitly asked for? No — FunctionPool is built from routes.filter(route => route.sandbox === true) (strict equality on the schema-validated boolean) and runtime.ts's dispatch is the same strict check; nothing else can route a sandbox: true route through the trusted path. Could the trusted path leak a secret to a function that wasn't granted it? No — context.secrets is built once per route at compile time in router.ts, from that route's own declared+operator-approved bindings, before either executor ever sees it; the trusted path receives the identical object the sandboxed path always has, unchanged by this PR.


🤖 Generated with Claude Code

https://claude.ai/code/session_018neC2tYKPxMPbzZf1wNctr


Generated by Claude Code

Proposal only, nothing implemented. Sequences the two extractions
(link first, middleware second) around the shared extension mechanism
already in src/extensions.ts (mount ownership + authorize()), and
flags the cross-repo dependency on urlcode-auth/-admin/-ui that a
middleware contract change would introduce.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018neC2tYKPxMPbzZf1wNctr
License Apache-2.0 and repo settings mirror core's GOVERNANCE.md; both
new extension repos publish public from the start rather than the
private-until-reviewed pattern auth/admin/ui used. Adds a performance
section (link's extensionResponse overhead on a latency-sensitive path;
middleware's sandbox-vs-trusted-code tradeoff hiding inside what looks
like a speed question) and rules out other core handlers as extraction
candidates (proxy, policies, native routing, management/grants).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018neC2tYKPxMPbzZf1wNctr
Same spike doc: unlike link/middleware (which shrink core), a static
compile target (S3/CloudFront) extends the progression below core
without touching it, reusing the existing per-target capability
refusal mechanism. Flags GitHub Pages' lack of server-side redirects
as a real fidelity gap rather than promising parity it can't deliver.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018neC2tYKPxMPbzZf1wNctr
middleware is project-authored guest code in the same threat category
as function (docs/FUNCTION-SECURITY.md), not a lighter-weight sibling
of auth's trusted authorize() hook. urlcode-middleware keeps its own
sandboxed execution; auth's trusted-extension model stays reserved for
vetted, operator-installed packages. Reframes the sandbox's real
performance cost (paid on every request, not once per route like
function) as a reason to shrink how much needs to be guest code via
native declarative primitives, not a reason to drop isolation.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018neC2tYKPxMPbzZf1wNctr
Maintainer decision, not yet implemented: sandboxing becomes opt-in
(explicit sandbox: true) rather than the current unconditional default.
Documents what this reverses (AGENTS.md, SECURITY.md,
FUNCTION-SECURITY.md, SANDBOX-REVIEW.md, README.md all currently state
the opposite as an absolute guarantee), what actually needs building
(no in-process execution path exists today, it's fully hardwired to
the sandbox), and the test/docs/capacity rework this requires before
it ships. Recommends landing this ahead of the middleware extraction
in SPIKE-CORE-LAYERING.md, since it changes that spike's assumptions.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018neC2tYKPxMPbzZf1wNctr
Express/Next.js/Django/Rails all serve AI-agent-generated code
unsandboxed in production; the industry's actual sandboxing pattern
for AI-written code is generation-time (E2B, Modal, Code Interpreter),
not serve-time. Records this as supporting evidence for the decision
already made, not a re-opening of it.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018neC2tYKPxMPbzZf1wNctr
Covers auth/admin/ui (contract unaffected, but their own docs/examples
may need an audit for now-inaccurate sandboxing claims), versioning
(this is a behavior change needing a major/minor bump and explicit
peers.json pinning, not silent inheritance), dynamic-link (unaffected),
and middleware (directly affected, with an open question on whether it
should inherit trusted-by-default or deliberately stay sandboxed given
it wraps every request through a route rather than one operation).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018neC2tYKPxMPbzZf1wNctr
Maintainer decision: no special case for middleware despite its wider
per-request blast radius versus function — same rule, same opt-in
sandbox mechanism. Marks SPIKE-DEFAULT-TRUST-MODEL.md's middleware
question as resolved and corrects SPIKE-CORE-LAYERING.md's sections
that still assumed middleware stays sandboxed by default (mechanism
choice, sequencing, and the performance analysis), pointing them at
the trust-model doc instead of re-arguing settled ground.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018neC2tYKPxMPbzZf1wNctr
function and middleware routes now run trusted and unsandboxed by default:
in-process, full Node/filesystem/network access, no worker thread, no
QuickJS/WASM. A route opts into today's existing isolated execution with the
new `sandbox: true` field, which is byte-for-byte unchanged behavior for any
route that declares it. Implements docs/SPIKE-DEFAULT-TRUST-MODEL.md.

- schemas/urlcode.schema.json, src/types.ts: add route-level `sandbox`
  (boolean, default false), applying uniformly to a route's function and
  middleware chain together (they already execute as one unit).
- src/trusted-functions.ts (new): the trusted execution path. Ordinary
  dynamic import() of the project's module, called in-process with the same
  Request/context-in, Response-out contract as the sandboxed guest API
  (guest-api.ts), including next()-once middleware semantics and native-reply
  passthrough. A soft timeout races the call's promise (documented as unable
  to preempt synchronous event-loop-blocking code, unlike the sandboxed
  path's forced worker termination).
- src/runtime.ts: dispatch is `route.sandbox ? pool : trusted`, uniform for
  function and middleware. FunctionPool now only receives sandbox:true
  routes, so its module snapshot, worker count and budgets are unaffected by
  trusted routes.
- src/policy.ts, src/function-sources.ts: prepareFunctionSnapshot splits
  sandboxed routes (through the existing collectFunctionSources, unchanged)
  from trusted routes (new collectTrustedSources, which hashes each trusted
  entry file's own bytes for grant-pinning integrity without imposing the
  sandbox's import/size restrictions). The project hash - and therefore
  every operator grant pinned to it - changes with this release.
- src/capabilities.ts, src/context.ts, src/agents-guide.ts: capability
  descriptions, AI-authoring constraints (guestNetwork/nodeApis) and the
  generated project AGENTS.md now describe trusted-by-default with
  sandbox:true as opt-in, including judgment guidance on when to reach for it.

Security docs rewritten to state the accurate default (not just appended):
AGENTS.md, SECURITY.md, docs/FUNCTION-SECURITY.md, docs/SANDBOX-REVIEW.md,
docs/SPECIFICATION.md, docs/MIDDLEWARE.md, docs/CAPACITY.md (dual capacity
model), docs/PROJECT-DIRECTION.md, docs/RELEASE-READINESS.md,
docs/RESILIENCE.md, docs/TYPESCRIPT-AUTHORING.md (documents a known gap:
build-typescript still applies sandbox import rules to all routes; filed as
#124), docs/SECURITY-AUDIT.md (new dated entry scoping
prior entries to the sandbox:true path), README.md, docs/FRAMEWORK.md.

Fixtures/recipes: recipes/middleware and examples/cookbook's bucket.mjs and
locale.mjs mutated a Response.redirect() result, which is spec-immutable
under a trusted route's real Fetch API Response (the sandbox's own Headers
class never enforced this); rewritten to build headers up front instead.
recipes/webhook-receiver now declares `sandbox: true` to model isolating a
third-party payload, per the new authoring guidance.

Tests: existing sandbox/isolation suites (sandbox.test.ts, middleware.test.ts,
observability/monitoring worker-event assertions, capability-refusal message
assertions) updated with explicit `sandbox: true` where they test that path,
unchanged otherwise. New test/trusted-functions.test.ts covers genuine Node/
filesystem/network access, secret-grant scoping, sandbox:false/absent parity,
no cross-contamination between a trusted and sandboxed route in one project,
module-state persistence, deadline behavior and native-reply/middleware
contract parity with the sandboxed path.

Version bumped to 0.4.0-alpha.2 (behavior-changing, not a patch); ROADMAP.md
carries the changelog entry and upgrade guidance for existing projects.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018neC2tYKPxMPbzZf1wNctr
Two real correctness bugs surfaced by running the fuller test suite:

- src/trusted-functions.ts: Node's ESM loader caches an imported module
  forever by URL, so a snapshot reload never picked up an edited trusted
  function/middleware file (the sandboxed pool always rebuilds from
  scratch). Each TrustedFunctions instance (one per createRuntime call, so
  one per reload) now cache-busts its own imports with a per-instance
  random epoch query string, so editing a route's own entry file and
  reloading now takes effect, matching the sandboxed contract for that
  case. A file the entry only *imports* is not similarly busted -
  documented as a known gap in docs/FUNCTION-SECURITY.md and
  docs/CAPACITY.md (ordinary Node module resolution, not a per-reload
  snapshot, governs it), with the one existing test that specifically
  exercises dependency-level reload now marked sandbox: true.
- src/trusted-functions.ts, src/runtime.ts: add TrustedFunctions.start(),
  eagerly importing and validating every trusted route's declared export
  at runtime activation, the same guarantee FunctionPool.start() already
  gives the sandboxed path (a broken function fails startup, not the first
  request that hits it).
- test/http.test.ts: the '/hang' fixture ('while(true){}') was not marked
  sandbox: true, so under the new trusted default it ran synchronously
  in-process and froze the whole test process forever (no forced worker
  termination in-process, exactly the documented trusted-deadline
  limitation) - fixed by declaring sandbox: true, which is what that test
  is actually about (the worker pool's forced termination).
- test/prerender.test.ts: two "serving past the module/byte budget" tests
  exercise the sandboxed snapshot's own limits and needed sandbox: true on
  their generated routes to keep exercising that path; prerenderPages
  itself is unaffected (unrelated to createRuntime's trust split).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018neC2tYKPxMPbzZf1wNctr

jimhoyd commented Sep 19, 2026

Copy link
Copy Markdown
Collaborator Author

Follow-up commit (053dcc6) fixes two real correctness bugs the fuller test suite surfaced after the first commit, worth flagging explicitly since they're exactly the kind of thing this trust-boundary change needs extra scrutiny on:

  1. Reload staleness for trusted routes. Node's ESM loader caches an imported module forever by resolved URL, so a snapshot reload was never picking up an edited trusted function/middleware entry file — the sandboxed pool always rebuilds from scratch, but the trusted path was silently serving stale code after reload(). Fixed with a per-TrustedFunctions-instance cache-busting query string (one instance per createRuntime call, so one per reload). A file the entry file only imports (not the declared entry itself) is not similarly busted — that's ordinary Node module resolution, not a per-reload snapshot, and rewriting it would need a custom module loader hook, which felt like disproportionate risk/complexity for this PR. Documented as a known gap in docs/FUNCTION-SECURITY.md/docs/CAPACITY.md, and the one existing test that specifically exercised dependency-level reload is now marked sandbox: true (that guarantee is exactly what the sandboxed snapshot rebuild is for).
  2. No startup validation for trusted routes. FunctionPool.start() eagerly imports/validates every sandboxed entry so a broken function fails activation, not the first request that hits it. The trusted path had no equivalent — added TrustedFunctions.start(), called from createRuntime alongside pool.start().
  3. A genuine test-suite hang, not a hypothetical: test/http.test.ts had a '/hang' fixture (while(true){}) that wasn't marked sandbox: true. Under the new trusted default it ran synchronously in-process with nothing to preempt it — exactly the documented "trusted deadline can't stop event-loop-blocking code" limitation — and froze the whole test process indefinitely (I killed a npm run verify run after ~20 minutes stuck on it, burning CPU at 98% the whole time, on a shared build host). Fixed by declaring sandbox: true on that fixture, which is what the test is actually about. I searched the rest of the suite and benchmarks//recipes//examples/ for the same while(true)/busy-loop-without-sandbox pattern and found no other instances reachable by an actual request.

All 71 test files, typecheck, lint, and check are green after this commit (see the batched-run notes in the PR body for why one process running all files isn't practical on this dev host).


Generated by Claude Code

main advanced with the static target (#125) and link/dynamicLinks
extraction (#126) while this branch was in progress. Resolved
conflicts in src/capabilities.ts and src/runtime.ts by keeping this
branch's trusted-by-default logic and dropping the now-removed
link-store wiring; combined doc wording from both sides in README.md,
docs/CAPACITY.md, docs/PROJECT-DIRECTION.md and
docs/RELEASE-READINESS.md; regenerated the two generated files
(starters/default/AGENTS.md via renderAgentsGuide, llms-full.txt via
scripts/build-llms-full.ts) rather than hand-editing them; updated
test/explain.test.ts to match. Also tightened the static target's
middleware refusal reason ("no server, so no middleware execution",
dropping the now-stale word "sandboxed") since it no longer applies
uniquely under the new default.

Verified post-merge: typecheck, lint, npm run check, full test suite
(481 tests: 479 pass, 0 fail, 2 skipped), build, test:package all
green.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018neC2tYKPxMPbzZf1wNctr
@jimhoyd
jimhoyd merged commit b3bde4e into main Sep 19, 2026
10 checks passed
@jimhoyd
jimhoyd deleted the claude/default-trust-model branch September 19, 2026 02:04
jimhoyd added a commit that referenced this pull request Sep 19, 2026
Three skill files (skills/urlcode/SKILL.md, .claude/skills/urlcode-authoring
and its packaging/claude-plugin generated copy) still described the sandbox
as an unconditional property of every function/middleware route, predating
#127's trusted-by-default trust model. State the actual default (trusted,
unsandboxed, full Node access) and scope the "no fetch/Node/filesystem/
timers" language to sandbox: true routes, matching docs/AI-AUTHORING.md's
established phrasing. The .claude/skills copy is hand-edited (source of
truth); the plugin copy is regenerated via npm run docs:plugin.

Also add the route's actual `sandbox` boolean to `explain`'s handler output
and to `context`'s per-route listing, so an agent never has to infer the
default. The MCP explain/get_context tools call the same underlying
functions and pick this up with no separate changes needed. Add explain
test coverage for both a sandboxed route (recipes/webhook-receiver) and a
trusted one (cookbook).

Reword two README mentions of urlcode-docs' "sandboxed middleware" to make
explicit that's its own sandbox: true opt-in, not core's default, since it
reads ambiguously to a quick skim.


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

Co-authored-by: Claude <[email protected]>
jimhoyd added a commit that referenced this pull request Sep 19, 2026
…rs (#136)

docs/CAPACITY.md asserted the trusted default's concurrency ceiling
("ordinary Node concurrency... no fixed worker-slot ceiling") as
architectural reasoning from the trust-model change (PR #127), never
backed by a measurement. Add benchmarks/sandbox-vs-trusted.ts, which
runs the same 20ms handler source on a sandbox:true route and a
trusted route in one server at concurrency 1/2/8/32/128, and use its
real output (benchmarks/results/2026-09-19-sandbox-vs-trusted.json) to
replace the assertion in docs/CAPACITY.md with a measured comparison
table.

The measurement confirms the architectural prediction: the sandboxed
path's 2-worker ceiling is already visible at concurrency 8 (>95%
shed, flat ~80 req/s regardless of further concurrency), while the
trusted path scales cleanly to 1,465 req/s at concurrency 32 with zero
shedding, only hitting its own ceiling (the --max-in-flight admission
cap, default 64) at concurrency 128.


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

Co-authored-by: Claude <[email protected]>
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.

2 participants