Plan for dropping @Provider export from the mesh: the manifest carries step
names, an unreachable teapot stops blocking the boot, and the app-scope
binding that cached a remote value for the process lifetime goes away.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
Exporting a provider whose value was a connection pool produced HTTP 200 and
on the other side. JSON keeps the shape and discards everything else, so
what arrived was an object that passed every truthiness check and had no
methods — and the failure surfaced as `db.query is not a function` at a call
site arbitrarily far from the export that caused it. Nothing warned, at either
end, at any point.
The teapot now checks before sending, which is the only place the evidence
still exists: past encode() a pool and an empty object are the same bytes.
An allowlist rather than a denylist. Date is refused too — it would arrive as
a string rather than the declared type, which is the same silent difference
wearing a smaller costume. Bounded by a scan budget so a large legitimate
payload is never turned into an error by the cost of checking it.
The constraint this makes visible was never written down anywhere: a mesh
export carries data, never behaviour. Export what the handle produces rather
than the handle. That limit is what makes an 'executable provider' (#50) the
missing shape rather than a nicety.
442 vitest / 12 Deno / 7 Bun / edge / JSR dry run. All 5 new tests verified to
fail against the old code.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
A dropped link stayed dead for the life of the process. Every RPC answered
503 until the teacup restarted, so deploying a teapot forced a restart of
every teacup depending on it and boot order became load-bearing — a worse
operational property than any gap the docs actually listed.
The Link now outlives any single socket, because the graph captured its rpc
closure at boot and a reconnect that produced a new Link would leave the graph
pointing at the dead one. Backoff doubles from 500ms to 30s with full jitter,
so teacups that went down together do not return in lockstep.
A returning teapot whose manifest no longer exports what the graph was
validated against is refused, not adopted: that graph is already serving, and
a token cannot be validated away after the fact. The link keeps retrying,
since a partial deploy may still restore it, and logs once per distinct
manifest rather than once per attempt. Refusal ships as a named policy
(onManifestChange: 'refuse') so hot reconciliation can arrive later as an
addition rather than as a change of what the default means — these are
separate processes on separate deploy cadences.
close() is terminal. closeLinks runs on shutdown, and a link that reconnected
after the application hung up would leave a process that cannot exit.
Also closes the documented gap where an app-scope export outlived its teapot
with a stale value: a successful reconnect re-registers those bindings, so the
next resolve re-runs the RPC. That invalidation is a named function rather
than inline, because it is the seam a future 'reconcile' reuses.
Tested on all three runtimes rather than on Node alone — Node's ws package,
Deno's global WebSocket and Bun's server-level socket handler are three
implementations, and swapping a socket under a live graph is where they stop
agreeing. 7 of the 9 new Node tests were verified to fail against the old
code; the 2 that pass are the ones that should, since the old code never
reconnected at all.
Mesh stays alpha.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
It was recommended in this plan as the automated guard worth building. Building
enough of it to decide argued the other way, and the reasoning is worth keeping
so the next person does not spend the afternoon rediscovering it.
The narrow version is clean and useless: all 24 symbols the pages import from
@green-tea/core exist among the package's 101 exports, so it finds nothing —
and it structurally could not have caught #18, the one incident there is.
That was close() gaining an option the docs never mentioned. Imports are the
part that does not drift.
Widening it to options and methods produced 17 findings and all 17 were false.
A regex cannot separate a nested tls: { key, cert } from a top-level option, or
prose describing Express's app.use() from a green-tea call. A check that cries
wolf 17 times out of 17 is worse than none, because people learn to skip it.
Type-checking the code blocks would catch the real class, and costs the
documentation repository a dependency on the framework plus examples that must
compile — buying the guarantee back by spending the independence the split was
for. The accepted risk stands, now chosen rather than defaulted to.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
Task 4.4's obligation was to state the risk the docs split opens, and the
first pass met it in the two places that publish rather than the two that
govern: both READMEs. The core README's copy sits in "Docs & development", a
section a user reads and a contributor about to rename a decorator does not.
AGENTS.md and CONTRIBUTING.md both already carried "New public API needs a
note in README.md". Both were written before the split and neither was
updated for it, so the two documents actually read mid-change said nothing
about the new repository — the rule existed everywhere except where it applies.
Both now name green-tea-docs and carry the reason, because a rule without one
is the first thing dropped when a change is nearly finished. #18 is that
reason, and it happened while the two still lived in the same repository.
Neither automated option was built, and the plan now records which is worth
building and why: a link check against the published package targets #18's
real failure mode — a page naming a decorator, a createApp option or a method
that no longer exists — and needs only the identifiers in the pages' code
blocks compared against the package's exports. It catches lies rather than
staleness. A docs job triggered from core releases is weaker: it fires after
the API has already shipped.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
Closing a connection meant writing process.on('SIGTERM') by hand: closeApp
drained the server and mesh links and knew nothing about the graph, and the
Bus had no shutdown event at all, so a plugin could not even observe that the
app was going away.
Implements docs/plans/2026-08-17-shutdown-teardown-design.md, D1-D8.
Three doors into one registry, with one order and one failure policy — a
@Provider may declare dispose(), a plugin may call api.onShutdown(fn), and an
application that wants neither passes createApp({ hooks: [{ onShutdown }] }).
Shipping only the plugin half would have frozen the public API around the less
common case: the thing that holds a database connection is a provider.
Callbacks take no arguments. Whatever needs closing is already in the closure
that registered it, so nothing crosses a scope and the registry needs no
container, app reference or transport. That is what keeps this a registry
rather than a second event bus — Bus.on is synchronous and emit swallows
failures on purpose, and a teardown needs the opposite of both.
Provider dispose() is registered as the provider boots rather than as it is
collected, so reverse-registration is reverse-topological order for free: a
cache that needs db closes before the db it is holding, with no second sort to
keep in step. It registers inside the try, so a provider that failed to boot is
never disposed — nothing it might close was ever opened.
Teardown runs after the drain, because an in-flight request may still be using
what a teardown is about to close, and inside the same timeoutMs, because that
number is a promise about when close() returns. teardownTimeoutMs reserves a
slice of that budget rather than extending it, and is rejected at boot rather
than clamped.
Node, Deno and Bun reach it through the close() each runtime actually uses.
app.close() returns at its no-server guard everywhere but Node, so the Deno and
Bun adapters chain it after their own drain — and app.close() now runs teardown
on that path too, since an app served through app.fetch still booted providers
that opened things. The registry drains once, so both entry points are safe.
Edge gets a doc comment and nothing else. workerd has no shutdown to intercept;
a best-effort call on an event that does not exist would be worse than saying so.
Recorded in mountPlugin's comment while widening it: "isolation is structural"
is a guarantee about the registration surface, not about the request context. A
plugin's step already receives the live context and can overwrite keys in it.
Pre-existing, unrelated, and now written where the next reader will look.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
Two corrections to the phase added an hour ago.
The task asked for documentation that exists. README.md:233 "Why legacy
decorators" and concepts/the-graph.md:43 in the docs repository both already
carry the argument, and carry it better: parameter decorators are
deliberately absent from the TC39 Stage 3 proposal, so a handler taking
`@param('id') id: string` is only expressible with legacy decorators, and
Stage 3 means the replacement is not finalized either. Writing a third,
shorter version of that in Honest scope would have made it worse.
The task also justified itself with a claim that is false. It said the
framework depends on emitDecoratorMetadata. It does not:
`grep -rn 'design:type\|design:paramtypes' src/` returns nothing. The flag is
set in tsconfig.json and deno.json, but no design:* reflection is read
anywhere in src/ — argument positions are recorded explicitly. Both documents
already state this, which is how the error surfaced.
What survives is a note rather than a task, because the warning arrives in CI
together with the new gate and would otherwise read as something the gate
found.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
Task 2.5 adds public API, and exported types are what JSR's slow-types check
polices. Writing that surface with no JSR gate on pull requests means finding
out at release time whether the shape is publishable, so the phase is
numbered as an insertion and says it runs first.
The first reading of this was wrong and the correction is the useful part:
release.yml already runs `deno publish --dry-run`, before either registry
ships, and a dry run passes today with the slow-types check included. The gap
is not a missing gate, it is when it runs — only on a version tag, so a
Deno-typecheck break or a slow type lands on main in silence and surfaces
while cutting a release. That is the moment release.yml's own npm-audit
comment identifies as having the least time to judge a fix; the workflow
makes that argument for advisories and not for JSR.
Measured rather than assumed: the dry run takes 0.68s against 2.0s for the
whole vitest suite, so it goes in the runtimes job's Deno leg, which already
installs Deno, and needs no more thought than that.
npm test stays Node-only. The runtimes job already covers Deno, Bun and edge
on every push, so they are not unguarded — what is missing is one command a
contributor can run before pushing, which is test:all.
Also recorded: every dry run warns that experimentalDecorators is deprecated
and may be removed. Nothing to fix, no workaround worth inventing early, but
it is a dependency on a deprecated compiler option in a runtime we publish
to, and it belongs in Honest scope rather than in a warning nobody reads.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
D8 was the one decision left open: the teardown shares close()'s budget and
may never exceed timeoutMs, but whether lowering teardownTimeoutMs reserves
its slice or merely caps it was never stated.
It reserves. A cap only bounds how long teardown may run and does nothing
about the case the decision exists for — a drain that spends the whole
budget leaves teardown zero milliseconds and the connection stays open.
Reserving is what makes the option a guarantee rather than a ceiling on
something that may never get to run.
The plan orders the work so nothing is observable until close() is wired in
Task 4, and puts the Deno/Bun parity at Task 5 rather than last, because it
is the task most likely to surface something the design did not foresee and
finding that out early is worth more than a tidy sequence.
Two notes carried into it for whoever executes it. Provider dispose() is
registered as the provider boots rather than as it is collected, so the
reverse-topological order D5 asks for falls out of the registry's reverse
registration rule instead of needing a second sort. And the Deno and Bun
suites are not part of npm test, so that task cannot be called done on the
strength of vitest passing.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
Task 2.5 has been open since it was raised while deciding #15, deliberately:
it needs public API, and the API freeze is the next milestone.
Three things the design settles that the task description did not anticipate.
Teardown reaches the graph through hooks, PluginApi and a provider dispose(),
but all three are doors into one registry with one order and one failure
policy. Shipping the plugin half now and providers later would freeze two
mechanisms with different semantics around the less common case: the thing
that holds a database connection is a provider, not a plugin. The hooks
framing also means PluginApi's signature never changes, so nothing breaks at
all, which widening it directly would not have achieved.
Callbacks receive nothing. State lives in the closure that registered it, so
no handle crosses a scope and no container, app reference or transport is
needed. That is what makes this a registry rather than an event bus.
It fires from each runtime's real close, not app.close(), which returns at
its no-server guard on everything except Node. Edge cannot participate at all
and that is documented as a capability difference rather than hidden.
Recorded while verifying: "isolation is structural" protects the registration
surface, not the runtime context. A plugin's step can already overwrite
context keys, and a plugin mounting before provideBuiltins can replace the
logger and rooms builtins. Pre-existing and unrelated to teardown, noted so
the finding outlives the conversation that produced it.
D8, the shared timeout budget, is marked open rather than settled: whether
lowering teardownTimeoutMs reserves its slice or merely caps it was not
decided, and the two differ in whether a slow drain can starve teardown of
the time it needs.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
The published figure was -3.9%. It was measured sequentially rather than
interleaved, and the machine drifts 12% across a session as it warms, so run
order was indistinguishable from effect. Two later attempts to correct it were
also wrong: 0.8% had the same flaw, and -6.8% compared 7bd11bf against HEAD,
which differ by observability *and* three performance fixes pulling the other
way, then reported their net as if it were one of them.
Measured properly, alternating round by round between 7bd11bf and 523e318 (the
last commit before those fixes): +7.0% of the framework's own per-request work,
about 0.29us, roughly 2% of a request over a real socket. Ranges do not overlap.
The guide no longer quotes absolute throughput from this laptop. The reference
numbers come from a two-box setup, and single-box loopback figures invite a
comparison that is not valid.
D7's shape survives: the cost is fixed per request, not per step, because
per-step work is skipped when nothing subscribes.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
D7 predicted ~0.25% per step and called it invisible. Measured over a real
socket it is -3.9% on JSON hello and -2.1% on a three-step pipeline: the route
with *fewer* steps loses more, which falsifies a per-step model rather than
just its constant. Per-step work is skipped when nothing subscribes, so what
remains is a fixed per-request cost that a shallow route amortises over less.
The decision survived, for a better reason than it was made with: there is
nothing per-step left to make optional.
Also records the two regressions that measurement caught and reasoning did not,
both larger than anything the design anticipated — a second async frame in
handle() at 0.43us per request, and a closure allocated per request inside
correlateRequest at 0.16us. On this path an extra promise costs more than any
amount of bookkeeping.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
Eight tasks from the reviewed design, ordered so the correction lands before
anything consumes it — a logger built on uncorrelated events would grow its own
notion of request identity, which is the failure the design exists to prevent.
Two placement details worth having settled in writing. requestId is generated
in the adapters rather than in handle(), because both read and size-check the
body first, so a 413 never reaches handle() — generating there would leave
exactly the failures an operator most wants to correlate without an id. And
step timing takes N+1 timestamps for N steps, since one step's end is the next
one's start; the design measured that against the naive 2N.
Task 7 benchmarks the hot path and says outright that if the measurement
disagrees with D7, the design changes rather than the number being quietly
kept.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
D6: a request span ends when the handler returns, and stream events carry its
requestId. Ending it at stream close would mix 2ms buffered requests with
hour-long SSE connections in one latency distribution; connection duration is
already readable from stream:open/close once they can be joined. Same boundary
#21 chose for its concurrency gate — the framework should not disagree with
itself about when a request is over.
D7: per-step timing is always on. Measured rather than argued: performance.now()
at step boundaries costs 25.2ns per step against a 10.19us request, or 0.25% —
below the 0.3% run-to-run CV of the project's own benchmark. A flag would buy
two code paths for something the harness cannot detect. The measurement also
settles Date.now(), which is both slower (28.6ns) and coarser.
D8: request logging is a Bus subscriber, wrapped to fall back to console. One
path, composable as #10 asks, and the wrapper closes the hole that emit()
swallows listener failures by design — the Bus keeps its guarantee without
buying it with silence.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
The issue says green-tea ships no logging, metrics or tracing contract. The
mechanism is actually already there — Bus has 19 emission points across boot,
pipeline, streams, mesh and plugins, and plugins already subscribe to it. What
is missing is narrower and worse: no event carries request identity, so under
concurrency step events cannot be attributed; durationMs is declared in the
payload and written by nothing; there are no request-level events for step
events to hang from; and a failing step reports as name: 'pipeline'.
That reframes the work. A logger, a metrics exporter and an OpenTelemetry
bridge are not three features, they are three consumers of one corrected event
stream — which is a sharper reason for #10's 'one design, not six' than the
issue had, and it puts most of the work in bus.ts and pipeline.ts rather than
in new files.
Five decisions settled with their reasoning, including why the logger cannot be
an ordinary provider (it must outlive the graph to report the graph failing to
boot) and why route labels carry the pattern rather than the URL (a metrics
consumer labelling on raw paths takes down the backend, not the app).
Three questions left open for review rather than answered alone, the sharpest
being where a request span ends on a streaming route — the same boundary #21
hit, which should be answered once for both.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
The plan asked Task 2.3 to decide between two answers; the decision and what
the runtimes actually allow now sit in it, so the next reader is not re-deriving
either. The Deno constraint in particular was found by measurement and is not
in any issue.
Adds Task 2.5 for the plugin/provider teardown idea, kept out of the #15 work
on purpose: it needs a new await-aware surface on PluginApi, because the
existing Bus is a synchronous observer by design and cannot be made to hold up
a shutdown without losing the guarantee that makes it safe.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
The reports in .specs/reports/ were written independently and converge on
observability as the gap that matters most. Two things they demand had no
issue filed at all: CI never runs the Deno/Bun/edge suites that package.json
defines, so the multi-runtime claim has no evidence behind it, and explain()
returns each node's needs without ever naming what produced them.
Sequenced so the cheap phases land first and produce the material the
observability design needs. API freeze stays out: README already declares it
under 'next', and freezing a surface that is still missing its observability
contract would freeze the wrong thing.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
The README claimed green-tea was Node-only with Deno/Bun/edge "on the
roadmap, not built" — all four have shipped. It also taught that a plain
return of an AsyncIterable streams by Accept, which the explicit-transport
change turned into a 500 TransportMismatchError: the one thing a README
must never do is document behavior that now throws.
docs/ had been frozen since the Starlight site replaced it; nothing but
the README referenced those two files, so they were a second copy to keep
in sync and had already drifted. Point at the site instead.
Also adds what shipped unmentioned (@Html/views/static, the four runtimes,
matcha) and fixes the CHANGELOG's YY.MM.PATCH, which contradicted the
README's correct explanation of why the month is not zero-padded.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
Bring the README in line with what shipped and fill the gaps a technical
reader comparing frameworks needs: the busboy peer dep and dual build, a
Routing section with its limits, an explicit "bring your own auth" scope
note, why legacy decorators is a design choice (not laziness), and CalVer
beta versioning.
Add a full Astro Starlight docs site under website/ — getting started,
concepts, per-feature guides, and an API reference — migrated from the
tested quickstart so the examples stay accurate.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>