Skip to content

Ecosystem conformance: zod used directly, and URLCode hosted inside Hono (#841) - #887

Merged
jimhoyd merged 1 commit into
mainfrom
claude/direct-library-and-host
Sep 29, 2026
Merged

jimhoyd merged 1 commit into
mainfrom
claude/direct-library-and-host

Conversation

@jimhoyd

@jimhoyd jimhoyd commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator

Adds #841 acceptance evidence for direct library use and a second, materially different host integration. The fixtures are in proofs/ecosystem/, with a README listing supported directions and every gap. npm run test:ecosystem packs core, installs into a copied site, and runs urlcode serve and the Hono host side by side (12/12). It is included in verify:workspaces and the CI workspace-integration job.

Direct npm library use

  • zod 4.6.5 is an ordinary dependency imported by a trusted route. There is no URLCode metadata, and nothing in the YAML names it. validate --local and urlcode test pass.
  • Sandbox refusal: the same import on a sandbox: true route is refused before serving (sandbox-import) by validate, serve and an embedded createRuntime.
  • Explain: shows execution: trusted (in-process).

Hosting URLCode inside Hono (hono 4.13.10, @hono/node-server 2.1.1)

  • Directions:
    • URLCode inside Hono, via createRuntime plus a 112-line bridge;
    • Hono inside URLCode, through a trusted function route (paths declared) or an operator extension mount (/*).
  • Same answers as urlcode serve:
    • routing and 404/405/400/302/422 answers;
    • the 413 limit before reading;
    • X-Request-Id, nosniff, no-store, and separate Set-Cookie lines;
    • streaming;
    • the function URL taken from the configured origin;
    • same-origin checks;
    • startup refusal before listening, and SIGTERM close.

Gaps and core coupling (filed separately)

  1. No public result-to-Response adapter. prepareResponse, prepareStream, errorResponse and the error-code table are unexported, so the bridge copies core's rules and can drift. This is the main embedding blocker.
  2. Server-only protections: trusted-proxy client resolution and the loopback Host 421 check exist only in startServer.
  3. Other features missing under Hono: health, ready and metrics probes, the request log, admission, timeouts, stream limits and reload.
  4. Repeated request headers are lost: headerCounts is optional, which weakens duplicate-header refusals on fetch-only hosts.
  5. No base-path setting for prefix-stripping mounts.
  6. Byte-level differences: repeated response headers are joined, and a default content-type is added.
  7. Review mislabels an in-process call: urlcode review flags app.fetch(request) as an outbound call.

The docs gain "Using npm libraries directly" (FRAMEWORK.md) and "Hosting URLCode inside another framework" (OPERATIONS.md). A stale sentence that said functions support only relative imports is corrected.

Evidence

npm run verify passes: 1150/1150, test:addons, test:proof, test:ecosystem 12/12. npm run test:package passes.

🤖 Generated with Claude Code

… host (#841)

proofs/ecosystem adds two bounded conformance checks, run by
`npm run test:ecosystem` against a packed consumer:

- A trusted function route imports zod 4.6.5 through its own API, with no
  adapter, descriptor or catalog entry. The same import on a
  `sandbox: true` route is refused before serving (sandbox-import).
  explain labels the route trusted (in-process).
- URLCode is embedded in Hono (createRuntime plus an operator bridge) and
  compared request by request with `urlcode serve`. The reverse direction
  is also covered: a Hono app behind function routes and behind an
  extension mount.

The README records every gap found:
- no exported Request/Response adapter;
- trusted proxies, the loopback Host check, probes, the request log,
  admission and stream limits are startServer-only;
- repeated-header counts are lost on pure-fetch hosts;
- no base path;
- no function wildcard;
- a review false positive on app.fetch.

The suite is wired into verify:workspaces, CI and ci-plan. The docs add
"Using npm libraries directly" (FRAMEWORK) and "Hosting URLCode inside
another framework" (OPERATIONS). They also correct the stale OPERATIONS
claim that functions support only relative imports.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@jimhoyd
jimhoyd enabled auto-merge (squash) September 29, 2026 01:52
@jimhoyd
jimhoyd merged commit ce20487 into main Sep 29, 2026
29 checks passed
@jimhoyd
jimhoyd deleted the claude/direct-library-and-host branch September 29, 2026 01:57
jimhoyd added a commit that referenced this pull request Sep 29, 2026
…quest/response rules (#889) (#891)

* feat(core)!: embedded fetch handler for hosting URLCode inside another framework (#889)

createEmbeddedHandler(runtime, options) turns a self-hosted runtime into a
(Request, {peer, rawHeaders}) => Promise<Response> handler that answers
exactly as startServer: both hosts now share one request pipeline
(host-request.ts: header lines and counts, body limits, trusted-proxy client
resolution, error format and policy headers) and the same
prepareResponse/prepareStream/errorResponse answer. Cloudflare's fetch
response builder is the same shared fetchResponse.

- Trusted proxies: trustedProxies resolves the client from the vouched peer
  and exactly one X-Forwarded-For, as --trusted-proxies.
- Repeated headers: the host passes raw header lines, or declares
  headerLines: 'unavailable'; joined values containing a comma then count as
  repeated. runtime.handle() without headerCounts applies the same rule
  instead of reading a missing count as zero.
- basePath: a prefix-stripping mount keeps its prefix in a function's
  request.url and in every path-absolute Location.
- loopbackHost: optional loopback Host admission (421), as the Node server.

Docs: OPERATIONS "Hosting URLCode inside another framework" (what is provided
and what stays server-only), RIM-EMBED-001, SECURITY, FRAMEWORK, llms.
Package budget raised with measured sizes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(proofs): host URLCode in Hono through createEmbeddedHandler (#889)

The ecosystem fixture's Hono host drops its copied response bridge
(hono/urlcode-fetch.mjs) and uses createEmbeddedHandler with trustedProxies,
loopbackHost and, for the prefix-stripping mount, basePath. The integration
test now asserts X-Forwarded-For resolution from a trusted proxy, 421 for a
foreign Host and the kept /mounted prefix in both hosts; the README's gaps
narrow to the server-owned operations, conservative counts on pure-fetch
hosts, basePath scope, byte-level header joining, the function-route
catch-all and review's app.fetch false positive.

fetchResponse sends an empty body as no body, so a host does not give zero
bytes a default content type. OPERATIONS keeps the fixture pointer and the
reverse direction from #887. Core package budget re-measured on current main.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[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.

1 participant