Found while writing llms.txt (#185). Both bugs failed silently, and freezing them into RC.1 would have been worse.
1. provide() and run() must return an object holding the tokens they provide.
Before: a provider written as return client (instead of return { db: client }) booted. db came out undefined in every handler, and the client's own properties were spread over each request's context. A step that forgot its return did the same on every request.
Now: a provider fails the boot and a step fails the request. The error names the node and the fix: provider 'db' returned an object with 'query', but it must return an object holding what it provides: return { db: <value> }.
Plugin nodes (scope.add) are held to the same rule for every token in their provides.
Unchanged: a key whose value is undefined still counts. Remote mesh steps are not checked, because mesh is experimental and builds its own binding.
2. A handler that returns a Fetch Response.
Before: it was JSON-encoded and went out as 200 {}.
Now: it fails the request with a TypeError that points to a plain value, @Transformer or HttpError.
I chose the error over sending the Response through. Supporting Response later is an addition that breaks nothing; doing it now would have to go through security headers, CORS, compression and ETag, and it could not be taken back.
Hot-path cost:
The check stays synchronous for synchronous nodes, so a plain step pays a type check, not a microtask.
The handler pays one instanceof per request.
An A/B on jarvis (develop 2744b22 vs this branch, Node/Deno/Bun, 15 cases) is running; I'll add the results here before merge.
Verified:
test/node-contracts.test.ts covers seven cases: bare provider, async provider returning a string, provider keyed to undefined, step with no return, correct step, plugin missing one of its tokens, and handler returning Response.
Suites: npm test 1220, Deno 67, Bun 56, edge OK.
Official plugins (jwt, rate-limit, metrics) against this build: typecheck, 60 Node tests, 31 Deno and 31 Bun all pass.
Matcha: the stubs from create provider|step|controller and its plugin scaffold already follow the contract, and they boot.
Two health tests (Node, and the Deno/Bun ones from #184) whose providers returned {} are fixed.
CHANGELOG:### Breaking entry with migration. Docs #29 and llms.txt#185 already describe the new behaviour.
Found while writing `llms.txt` (#185). Both bugs failed silently, and freezing them into RC.1 would have been worse.
**1. `provide()` and `run()` must return an object holding the tokens they provide.**
- **Before:** a provider written as `return client` (instead of `return { db: client }`) booted. `db` came out `undefined` in every handler, and the client's own properties were spread over each request's context. A step that forgot its `return` did the same on every request.
- **Now:** a provider fails the boot and a step fails the request. The error names the node and the fix: `provider 'db' returned an object with 'query', but it must return an object holding what it provides: return { db: <value> }`.
- **Plugin nodes** (`scope.add`) are held to the same rule for every token in their `provides`.
- **Unchanged:** a key whose value is `undefined` still counts. Remote mesh steps are not checked, because mesh is experimental and builds its own binding.
**2. A handler that returns a Fetch `Response`.**
- **Before:** it was JSON-encoded and went out as `200 {}`.
- **Now:** it fails the request with a `TypeError` that points to a plain value, `@Transformer` or `HttpError`.
- I chose the error over sending the `Response` through. Supporting `Response` later is an addition that breaks nothing; doing it now would have to go through security headers, CORS, compression and ETag, and it could not be taken back.
**Hot-path cost:**
- The check stays synchronous for synchronous nodes, so a plain step pays a type check, not a microtask.
- The handler pays one `instanceof` per request.
- An A/B on jarvis (develop `2744b22` vs this branch, Node/Deno/Bun, 15 cases) is running; I'll add the results here before merge.
**Verified:**
- `test/node-contracts.test.ts` covers seven cases: bare provider, async provider returning a string, provider keyed to `undefined`, step with no return, correct step, plugin missing one of its tokens, and handler returning `Response`.
- Suites: `npm test` 1220, Deno 67, Bun 56, edge OK.
- Official plugins (jwt, rate-limit, metrics) against this build: typecheck, 60 Node tests, 31 Deno and 31 Bun all pass.
- Matcha: the stubs from `create provider|step|controller` and its plugin scaffold already follow the contract, and they boot.
- Two health tests (Node, and the Deno/Bun ones from #184) whose providers returned `{}` are fixed.
**CHANGELOG:** `### Breaking` entry with migration. Docs #29 and `llms.txt` #185 already describe the new behaviour.
provide() and run() must return an object holding every token the node
provides. A provider that returned its value bare (return client rather
than return { db: client }) booted without complaint: the token was
undefined, and the client's own properties were spread over every
request's context. That now fails, naming the node and the fix:
- providers fail the boot;
- steps fail the request;
- plugin nodes are held to the same rule for each token in provides.
A handler that returned a Fetch Response was JSON-encoded and went out
as 200 {}, with its status, headers and body lost. It now fails the
request with a TypeError that points to a plain value, @Transformer or
HttpError. Sending a Response as is can be added later without
breaking anything; taking it back would not be possible.
The check stays synchronous for a synchronous node, so a plain step
adds no microtask. Fixed health tests whose providers returned {}.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
A @Provider or @Step provides one token, so the check no longer goes
through every() and its callback. On a 3-step pipeline the 4-round A/B
against the freeze commit showed -4.6% on Deno and -3.2% on Bun, both
outside the noise; with this change and 8 rounds every case overlaps.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
44c7834 (first version), 4 rounds, all 15 cases. Most cases overlap. Outside the noise:
case
Node
Deno
Bun
pipeline (3 steps)
-0.1%
-4.6%
-3.2%
steps5
-2.5%
-4.3%
-1.1%
validate (POST)
+1.7%
-1.6%
-0.2%
json 8KB uncompressed
-4.4%
-1.5%
+0.6%
The json 8KB case runs no step, so the Node result is not the check; it was not re-run.
06869e5 (single token tested directly), 8 rounds, step and routing cases. Every case overlaps:
case
Node
Deno
Bun
hello
+0.7%
+1.0%
+0.4%
param
-1.3%
+0.8%
+1.2%
pipeline (3 steps)
-2.1%
-2.9%
-1.6%
steps5
-2.1%
-3.4%
+0.1%
validate (POST)
-1.8%
-1.0%
-1.2%
hello + security
-0.3%
-4.2%
-0.7%
Not covered by the second run: compression with gzip and br, preflight, and json 8KB.
There is still a 2-3% downward trend on step-heavy pipelines, which is the cost of one extra call per node. It could go to zero by moving the check into runSteps next to Object.assign, but that touches the pipeline's step type. I left it out of this fix.
## Benchmark (jarvis, pinned CPUs 6,7,14,15, `bench/compare.ts`, base = freeze commit 2744b22)
**44c7834 (first version), 4 rounds, all 15 cases.** Most cases overlap. Outside the noise:
| case | Node | Deno | Bun |
|---|---|---|---|
| pipeline (3 steps) | -0.1% | **-4.6%** | **-3.2%** |
| steps5 | -2.5% | -4.3% | -1.1% |
| validate (POST) | +1.7% | **-1.6%** | -0.2% |
| json 8KB uncompressed | **-4.4%** | -1.5% | +0.6% |
The json 8KB case runs no step, so the Node result is not the check; it was not re-run.
**06869e5 (single token tested directly), 8 rounds, step and routing cases.** Every case overlaps:
| case | Node | Deno | Bun |
|---|---|---|---|
| hello | +0.7% | +1.0% | +0.4% |
| param | -1.3% | +0.8% | +1.2% |
| pipeline (3 steps) | -2.1% | -2.9% | -1.6% |
| steps5 | -2.1% | -3.4% | +0.1% |
| validate (POST) | -1.8% | -1.0% | -1.2% |
| hello + security | -0.3% | -4.2% | -0.7% |
Not covered by the second run: compression with gzip and br, preflight, and json 8KB.
There is still a 2-3% downward trend on step-heavy pipelines, which is the cost of one extra call per node. It could go to zero by moving the check into `runSteps` next to `Object.assign`, but that touches the pipeline's step type. I left it out of this fix.
chrnx
merged commit 6eaa519059 into develop2026-10-31 01:29:59 +00:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Found while writing
llms.txt(#185). Both bugs failed silently, and freezing them into RC.1 would have been worse.1.
provide()andrun()must return an object holding the tokens they provide.return client(instead ofreturn { db: client }) booted.dbcame outundefinedin every handler, and the client's own properties were spread over each request's context. A step that forgot itsreturndid the same on every request.provider 'db' returned an object with 'query', but it must return an object holding what it provides: return { db: <value> }.scope.add) are held to the same rule for every token in theirprovides.undefinedstill counts. Remote mesh steps are not checked, because mesh is experimental and builds its own binding.2. A handler that returns a Fetch
Response.200 {}.TypeErrorthat points to a plain value,@TransformerorHttpError.Responsethrough. SupportingResponselater is an addition that breaks nothing; doing it now would have to go through security headers, CORS, compression and ETag, and it could not be taken back.Hot-path cost:
instanceofper request.2744b22vs this branch, Node/Deno/Bun, 15 cases) is running; I'll add the results here before merge.Verified:
test/node-contracts.test.tscovers seven cases: bare provider, async provider returning a string, provider keyed toundefined, step with no return, correct step, plugin missing one of its tokens, and handler returningResponse.npm test1220, Deno 67, Bun 56, edge OK.create provider|step|controllerand its plugin scaffold already follow the contract, and they boot.{}are fixed.CHANGELOG:
### Breakingentry with migration. Docs #29 andllms.txt#185 already describe the new behaviour.provide() and run() must return an object holding every token the node provides. A provider that returned its value bare (return client rather than return { db: client }) booted without complaint: the token was undefined, and the client's own properties were spread over every request's context. That now fails, naming the node and the fix: - providers fail the boot; - steps fail the request; - plugin nodes are held to the same rule for each token in provides. A handler that returned a Fetch Response was JSON-encoded and went out as 200 {}, with its status, headers and body lost. It now fails the request with a TypeError that points to a plain value, @Transformer or HttpError. Sending a Response as is can be added later without breaking anything; taking it back would not be possible. The check stays synchronous for a synchronous node, so a plain step adds no microtask. Fixed health tests whose providers returned {}. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>Benchmark (jarvis, pinned CPUs 6,7,14,15,
bench/compare.ts, base = freeze commit2744b22)44c7834(first version), 4 rounds, all 15 cases. Most cases overlap. Outside the noise:The json 8KB case runs no step, so the Node result is not the check; it was not re-run.
06869e5(single token tested directly), 8 rounds, step and routing cases. Every case overlaps:Not covered by the second run: compression with gzip and br, preflight, and json 8KB.
There is still a 2-3% downward trend on step-heavy pipelines, which is the cost of one extra call per node. It could go to zero by moving the check into
runStepsnext toObject.assign, but that touches the pipeline's step type. I left it out of this fix.