Skip to content

Extension mounts own their namespace (overlaps name both routes); 405 before extension gates (#912, #915) - #919

Merged
jimhoyd merged 3 commits into
mainfrom
claude/mount-overlap-and-405
Sep 29, 2026
Merged

jimhoyd merged 3 commits into
mainfrom
claude/mount-overlap-and-405

Conversation

@jimhoyd

@jimhoyd jimhoyd commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator

Fixes #912 and #915, both found by the #841 agent trial.

#912: overlap with extension mounts

  • Why validation missed it: the overlap check ran only in compileRoutes, and its error named no route. Static validate never called it, and a stale pin hid it at activation.
  • Fix: a new pure check, assertExtensionMountsDisjoint(routes), runs in compileRoutes, in createRuntime before extension preparation, and in urlcode validate without --host-file. The error (extension-mount-overlap) names both routes and says which to move.
  • Decision: a broad /* static site or /** redirect beside extension mounts is allowed. Mounts already pick the longest matching prefix, so the extension keeps its whole namespace, including its bare path.
  • Still refused: anything that could take the extension's requests. That means an exact or parameterized route at or under the mount, any mount inside it, and an extension mount enclosing another.
  • Docs: ROUTING.md gains "Extension mounts own their namespace" and a "site-root frontend beside /api/* extension mounts" section (root /* static with index, or spa-shell with /api excluded). ASSETS, SPECIFICATION, EXTENSIONS, llms and the proof README link to it.

#915: 405 before extension gates

  • Core routes had the same problem: on any route an extension protects, including auth: true on a plain respond route, an undeclared method got 401/403 from authorize().

  • New order on protected routes:

    1. agents and throttle policies
    2. the method check (405 with Allow, in the route's error format, through the response policies)
    3. authorize()
    4. cache and plugins
    5. extension middleware()

    Unprotected routes are unchanged.

  • Behavior change: on protected routes, plugins and extension middleware() no longer see undeclared methods.

  • OpenAPI: the x-urlcode.methodNotAllowed description and TOOLING now state this order.

  • Security note (EXTENSIONS, auth README): a 405 before auth reveals only the declared methods. Unprotected routes and the OpenAPI export already publish those.

  • RUNTIME-IMPLEMENTATION: new RIM-ROUTE-MOUNT-001, and RIM-DISPATCH-001 now states the protected-route order.

Evidence (macOS, Node 26)

  • New tests in test/extensions.test.ts:
    • overlap messages name both routes, even with a stale pin;
    • nested, parameterized and /** cases, plus every allowed shape;
    • CLI validate --local refuses an overlap and accepts a root static site;
    • a root static site serves beside a mount;
    • 405 with Allow and zero authorize() calls on a protected mount, on a core auth route and in JSON format. The 405 test fails if the runtime change is reverted.
  • npm run verify passes after merging main (with Named project schemas shared by HTTP bodies and MCP tools, loadable from files offline (#845) #907); test:proof and test:addons are included. npm run test:package passed before the merge.
  • Core budget raised to 960 / 3761 KiB (measured 978,234 / 3,847,730 bytes; CI's Node 24 packs ~800 bytes more).

🤖 Generated with Claude Code

jimhoyd and others added 2 commits September 29, 2026 08:45
…tension gates (#912, #915)

#912: extension mount overlap is now one pure check over route keys
(assertExtensionMountsDisjoint) run by compileRoutes, by createRuntime
before extension preparation (so a stale pin cannot hide it) and by
`urlcode validate` without a host file. The error names the extension
mount and the other route (code extension-mount-overlap). A non-extension
mount strictly enclosing an extension mount (a root `/*` static site, a
`/**` redirect) is now allowed: mounts already select the longest prefix,
so the extension keeps its whole namespace. Routes inside the mount and
extension mounts enclosing it stay refused. ROUTING documents mount
ownership and the supported site-root frontend beside `/api/*` mounts.

#915: on a route an extension protects (mount or policies.extensions,
auth: true included) an undeclared method is 405 with Allow in the
route's error format before any extension authorize()/middleware(),
after the agents/throttle host policies, matching the OpenAPI export's
methodNotAllowed, whose description is updated. The 405 reveals only the
declared methods, which unprotected routes and the OpenAPI export already
publish.

Core package budget raised with measured sizes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@jimhoyd
jimhoyd enabled auto-merge (squash) September 29, 2026 13:59
@jimhoyd
jimhoyd merged commit ba98d7c into main Sep 29, 2026
25 checks passed
@jimhoyd
jimhoyd deleted the claude/mount-overlap-and-405 branch September 29, 2026 14:22
jimhoyd added a commit that referenced this pull request Sep 29, 2026
jimhoyd added a commit that referenced this pull request Sep 29, 2026
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.

A static /* route overlapping extension mounts passes static validation; the activation error names no route

1 participant