Repository navigation
feat(execution): run server handlers without guest credentials - #427
Conversation
Astra reviewReviewed StandardsNo merge-blocking method or YAGNI findings. The new package, Runtime-owned SpecNo merge-blocking intent findings. The diff covers the pinned loader, content-hash binding, invocation-bound callback stub, private wire schemas, SDK guest, deadline-bounded inspection, runtime-promise coverage and required ADR/docs. Supervisor, host admission, settlement, fleet and local dev integration are explicitly deferred by this ticket, not missing acceptance criteria. Verification: a disposable smoke run against the actual pinned workerd derived descriptors from an SDK-built bundle and invoked its file handlers through a stub HTTP callback host. Uploads and downloads succeeded at 64 KiB, 1 MiB, 2 MiB and the 20 MiB limit. I did not rerun the full suite or exercise hosted/fleet containment. No repository files changed. Summary: Standards 0 blockers; Spec 0 blockers. No worst issue on either axis. |
Opus reviewReviewed 1. Engine verdicts and guest-authored "Patchy" refusals share one field (correctness)
The server bundle is untrusted, and nothing makes it use
Fix while the port is new: give 2. File callbacks use the tier 1 limit id and the wrong refusal code (correctness, limits registry)
3. Every callback transport failure reaches the handler as
|
allisonmahmood
left a comment
There was a problem hiding this comment.
Reviewed 6e52b74 against tier2/394-revisions-wakes (277d6e3f), issue #395, and the engine slice of #384.
The method is the one the spec decided. A pinned workerd 1.20260924.1 runs one loader Worker. env.loader.get keeps one isolate per company, patch, and version, named with the bundle's SHA-256. The guest's ctx.props are the invocation id and an RPC stub. The callback URL and bearer stay on the loader's attempt map and leave only on the host fetch. Outbound.fetch answers guest fetch with a 403 refusal body. Inspection is a separate process with no callback bindings, a load deadline, and a scope that SIGKILLs the child. Executor is bind and invoke. Runtime does not import execution. Tier 2 publish stays refused.
That is the small cut. There is no pool, no fleet client, and no supervisor in the code. ADR-0012 records those decisions for later tickets. An in-process isolate would miss the workerd boundary #384 asks for.
Spec
Issue #395's build list is in the diff. Engine and inspection are the only entrypoints. The direct workerd harness, the server-list tests, the refused publish path, and the named glossary entries are present. The supervisor, local executor, and fleet stay written down as later work.
Six places diverge from #395 or from this ticket's slice of #384.
-
The loader classifies the deadline, and the two paths disagree. After a normal guest return,
packages/execution/src/loader.tsreplacesGuestReplywithhandler_timeoutwhenDate.now()is pastrequest.deadline. A throw on that same path, including a non-JSON body or a faileddecodeGuestReply, is alwayshandler_failed. ADR-0012 sayshandler_timeoutrequires a confirmed non-commit, and that the host owns the classification. The loader has no commit to look at. Callbacks may already have run. A caller that retrieshandler_failedcan enter the handler again after the deadline. Return the guest reply, or the real failure, plusguestMs. Leave the fence to the host ticket. -
Every thrown callback becomes
access_denied. ThecatchinCallbacks.callmaps a down host, an abort, a non-JSON body, or a decode error toaccess_deniedand "The invocation callback could not complete." The wire already hastimeoutandsource_unavailable.access_deniedis the viewer's permission refusal. Inpackages/patchy/src/guest.ts, a failedctx.logis kept and then replaces a successful handler value, so a blip on the log callback drops the result and reads as an auth denial. -
The 20 MiB file cap uses the wrong code. Both directions call
refusal("limit_exceeded", ...)with no limit id.runtime.file.bytesrefusestoo_large.Runtime.TooLargecarrieslimitId: "runtime.file.bytes".limit_exceededis a different code. -
The private-protocol doc names the wrong media type. ADR-0012 says the HTTP callback carries the file's media type.
loader.tssetscontent-typefromoperation.body.contentType. The engine test expectsapplication/x-test.packages/api/src/markdown.ts, and the generateddocs/API.md, say binary requests areapplication/octet-stream. -
docs/product.mdis ahead of this diff. The canonical promise is in ADR-0010 and ADR-0012. The Tier 2 section paraphrases it. The identity paragraph this PR rewrote says the host reauthorizes the principal on each callback. There is no host gateway here. The opening lines correctly say admission, settlement, and termination are still to build. Keep the identity paragraph in that tense. -
A
PatchyErrorthrown by the guest itself becomeshandler_failed. The query-shape check inguest.tsthrowsPatchyErrorinvalid_request.errorReplyonly preservesHandlerError(source === "handler"). The code and the message are dropped. The generated Postgres prelude throws that sameinvalid_requestand keeps it.
The non-terminating initializer test accepts InspectionError reason load or timeout, so an immediate load failure satisfies the "cannot finish" case. The separate SIGKILL test is the one that shows the child is reaped.
Standards
Effect service conventions, hard:
-
packages/execution/src/process.tsbuilds plainErrors only to fillWorkerdError.cause: unsupported platform, a bad callback URL, an empty esbuild output, andnew Error(stderr)holding up to 8 KiB of workerd output. Fail withWorkerdErrorand a stage. Keepcausefor the original esbuild, spawn, or I/O error. The convention forbids manufacturing anErrorto populatecause, and forbids copying command output into the message. -
preferSchemaOverJson:offoninspection.ts,process.ts, andInspection.test.tsis explained as wall-clock fetch and child ownership. Those files alsoJSON.stringifya known request. Encode with Schema, or name JSON in the suppression reason.
Judgement. process.ts memoizes the loader bundle in a module-global promise. A failed esbuild sticks for the process. Effect.cached would keep that failure inside the effect.
Docs:
-
packages/patchy/README.mdsayscreateGuestis the wire-1 entry used by generated server artifacts.packages/sdk/src/generateServer.tsemitsbindServerand never mentionscreateGuest. The re-export onpatchy/serveris the production caller, plus the engine fixture. Say the bundle entry exists, and that generation does not emit it yet. -
ADR-0011 says this release pins
workerdto1.20260924.1, and a few paragraphs later says the only managed package pin today ispatchy, with tier 2 init addingworkerd. The pin that exists ispackages/execution/package.json. The patch pin is still the init ticket. Those are two different pins. -
ADR-0012 says guest
globalOutboundrefuses TCP connect.Outboundonly implementsfetch. Sockets stay out becauseno_nodejs_compatis set and the acorn walk rejectsnode:netandcloudflare:socketsbefore the isolate starts. Say that mechanism.
YAGNI. Two deletions, and the rest of this cut should stay.
-
packages/patchy/src/guest.tscopies a schema relation onto the publicget,getMany, andlistfunctions withObject.assign. A call to.list()still hits the public relation. A non-public table with one of those three names is only reachable as an extra property on that function. The generated client does not do this stamp. Delete it. The dual proxy, public relation versus schema namespace, matches the generated client and should stay. -
startWorkerd'sstartupTimeoutMshas no caller. A fixed 5 second startup budget is enough.loadTimeoutMsis the deadline the inspection tests set.
The query-shape fold in guest.ts repeats wireShape in packages/integrations/src/postgres/Generate.ts and has already drifted. The prelude uses two invalid_request messages. The guest uses one, then loses it, which is finding 6 above. Leave the fold in the guest. Use the prelude's checks.
Executor, inspect, and engine.ts are the right size. The engine tests check the reply envelope, the bearer, file bytes, isolate identity, and that an old stub cannot call back. Keep those.
Method
Worker Loader in the pinned binary, one isolate per company/patch/version, the capability held by the loader, inspection in a process that has no callback services. The guest protocol's compatibility date and workerd version live once, in packages/api/src/guest.ts, and the process refuses to start on any other version.
The gaps are the refusal bugs above. The unauthenticated loopback is intentional. This ticket leaves the management listener to the supervisor. A spinning handler keeps running. ADR-0012 gives the kill to the supervisor, at the deadline plus one second. Executor.invoke hangs until that ticket exists, which matches the boundary this PR drew.
Spec: 6 findings. Worst: the loader reports handler_timeout for a guest that already returned, and handler_failed for a late throw, so the host never sees the real reply.
Standards: 8 findings. Worst: packages/patchy/README.md says generated server artifacts use createGuest, and generation still emits bindServer.
|
Reviewed The method is the one the spec decided. A pinned workerd That is the small cut. There is no pool, no fleet client, and no supervisor in the code. ADR-0012 records those decisions for later tickets. An in-process isolate would miss the workerd boundary #384 asks for. SpecIssue #395's build list is in the diff. Engine and inspection are the only entrypoints. The direct workerd harness, the server-list tests, the refused publish path, and the named glossary entries are present. The supervisor, local executor, and fleet stay written down as later work. Six places diverge from #395 or from this ticket's slice of #384.
The non-terminating initializer test accepts StandardsEffect service conventions, hard:
Judgement. Docs:
YAGNI. Two deletions, and the rest of this cut should stay.
The query-shape fold in
MethodWorker Loader in the pinned binary, one isolate per company/patch/version, the capability held by the loader, inspection in a process that has no callback services. The guest protocol's compatibility date and The gaps are the refusal bugs above. The unauthenticated loopback is intentional. This ticket leaves the management listener to the supervisor. A spinning handler keeps running. ADR-0012 gives the kill to the supervisor, at the deadline plus one second. Spec: 6 findings. Worst: the loader reports |
Address #427 review findings: preserve host settlement authority, classify callback failures honestly, enforce the tier 2 file contract, retain SDK validation refusals and tighten inspection/process errors. Correct the implementation-boundary and binary framing documentation.
|
Addressed the review findings in Fixed
Kept, with reasons
Verification
No unresolved blockers. Ready to merge; not merged by this agent. |
277d6e3 to
1d2a24d
Compare
Implements #395: private wire 1, credential-free SDK guest callbacks, the Runtime Executor port, isolated inspection, runtime release gates and ADR-0012. Tier 2 publishing remains refused.
Address #427 review findings: preserve host settlement authority, classify callback failures honestly, enforce the tier 2 file contract, retain SDK validation refusals and tighten inspection/process errors. Correct the implementation-boundary and binary framing documentation.
b10524a to
0a9559b
Compare
Tier 2 needs a credential-free engine that can invoke handlers and inspect bundles before hosted admission is enabled.
This adds the pinned workerd engine, invocation-bound SDK callbacks and Runtime Executor port. Inspection derives handler descriptors in a deadline-bounded, throwaway process. Release tests cover the supported runtime APIs and refused network, Node and dynamic-code access; ADR-0012 records the execution boundary.
Stacked on
tier2/394-revisions-wakes. This PR contains the engine and inspection work only. Supervisor, host and fleet integration remain separate; tier 2 publishing is still refused.Verification
pnpm typecheckandpnpm lintpassed.pnpm test --maxWorkers=2: 1,194 tests passed across 107 files.Closes #395. Part of #384.
Implemented with OpenAI GPT-6 Astra using the omp harness.