Commit Graph
337 Commits
Author SHA1 Message Date
chrnx 10c8262824 feat(shutdown): opt into SIGINT/SIGTERM with createApp({ handleSignals })
CI / build (pull_request) Failing after 41s
CI / dco (pull_request) Successful in 6s
CI / runtimes (bun) (pull_request) Successful in 16s
CI / runtimes (deno) (pull_request) Successful in 20s
CI / runtimes (edge) (pull_request) Successful in 12s
The README promised shutdown was *"an extension point, not a SIGTERM handler you
write"*. Half of it was true: `dispose()`, `onShutdown` and `hooks` all deliver the
*content* of teardown, but nothing called `close()`, so every application still wrote
the handler — and wrote it three times, because the spelling is per runtime. Forget it
and the container is SIGKILLed after its grace period, every `dispose()` the registry
so carefully ordered never runs, and nothing reports it.

`createApp({ handleSignals: true })` registers SIGINT/SIGTERM to close and exit.

Off by default, and that is the design rather than caution: a library that installs
process-wide handlers behind your back is worse than one that installs none, because
when the process exits is the application's call. Both halves are now supported and
documented — keep the handler, or hand it over. What is not optional either way is
that *something* calls `close()`, and the README now says so instead of implying the
framework already had it covered.

Declared once on `createApp`, wired per runtime by whichever boot call runs:
`listen()`, `serveDeno()` and `serveBun()` each pass the closer that drains *their*
server to `app.handleSignals`, which returns a close that also unregisters. On Deno
that unregistering is load-bearing rather than tidy — a live `Deno.addSignalListener`
holds the process open, so an app that closed itself would otherwise hang.

Unregistering first also means a *second* signal falls through to the platform default
and ends the process at once. That is deliberate: Ctrl-C twice is the way out of a
teardown that is stuck, and swallowing it for the length of a 10s budget would read as
a hang. An orchestrator sends SIGTERM once and then SIGKILL, so it never gets there.

Tested against real processes, because a handler whose job is to exit its own process
cannot be fired by hand in the runner: Node covers SIGTERM, SIGINT, the double-signal
escape hatch and the default-off case; Deno covers `Deno.addSignalListener`/`Deno.exit`,
which is the API that actually differs. Bun shares Node's `process` path.

Closes #70.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-09-01 09:06:06 -05:00
chrnx 4896ee86d2 fix(jsr): resolve require from source, not from tsup's banner
CI / dco (pull_request) Successful in 6s
CI / runtimes (edge) (pull_request) Successful in 12s
CI / runtimes (deno) (pull_request) Successful in 20s
CI / runtimes (bun) (pull_request) Successful in 16s
CI / build (pull_request) Successful in 28s
JSR publishes `src/` and runs no bundler, so the `createRequire` banner tsup gives
the ESM build (tsup.config.ts) never exists there. Every lazy `require(...)` in the
source had nothing to resolve, and one of them was unguarded: `@Html('file')` and
template mode died at boot on Deno with `ReferenceError: require is not defined`.

The two guarded sites were worse than the crash, because they answered confidently
and wrongly. `static` reported *"needs a filesystem and is unavailable on this
runtime (edge)"* while running on Deno, which has one; multipart reported busboy as
not installed while it sat in node_modules. Both blamed the runtime for a packaging
problem, and both named a runtime the reader was not on.

Route all ten call sites through one `nodeRequire`, which prefers the ambient
`require` — so the CJS build and the banner-carrying ESM build behave exactly as
before — and otherwise rebuilds one from `process.getBuiltinModule('node:module')`.
Node 22.3+, Deno and Bun all expose that synchronously, which is the requirement:
every caller sits on a sync path a dynamic `import()` could not serve. It resolves
from `process.cwd()`, since a peer dependency like busboy belongs to the application,
not to a module served over https from a registry.

Where neither exists — workerd, where esbuild rewrites the call into its own throwing
stub — the behaviour is unchanged: the guarded sites still catch, and their "edge has
no filesystem" story is finally the true one.

Covered by a Deno suite that imports `src/` exactly as JSR serves it. The other Deno
tests already did that; none of them touched a path that loads a Node builtin lazily,
which is how a package that died at boot kept a green suite.

Closes #69.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-09-01 08:50:42 -05:00
chrnx bb0b01cf26 fix(cors): deny the origin when the origins predicate throws
CI / dco (pull_request) Successful in 4s
CI / runtimes (bun) (pull_request) Successful in 13s
CI / runtimes (deno) (pull_request) Successful in 18s
CI / runtimes (edge) (pull_request) Successful in 14s
CI / build (pull_request) Successful in 29s
`CorsOptions.origins` accepts a predicate, and it runs on the request path above the
region where errors convert to a response. A predicate that threw became a rejected
promise nobody awaited, and Node's default for that is to exit — so one cross-origin
GET took the process down, with `onError` never reaching it.

The trigger is a browser: `originAllowed` only runs when an `Origin` header is present,
so the crash is reachable by any cross-origin client and by no test that forgets the
header, which is how it survived a green suite.

Guard the call at `originAllowed`, the single point all four call sites funnel through
(the Node handler, `computeInjected` on both adapters, and the preflight path). A
predicate that throws denies the origin: a lookup that failed has not said yes, and a
broken allowlist must never widen into an open one. The failure is reported through the
app logger rather than swallowed — `HttpOptions` already carries one.

The published behaviour changes for a throwing predicate only. Every other origin shape
is untouched, and the security headers still land on the response.

Amends one test from the `maxConcurrentRequests` contribution, which asserted the old
crash as its baseline while proving the gate does not leak a slot. It still proves that,
against a transient failure that is now answered rather than fatal.

Closes #72.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-09-01 08:39:11 -05:00
chrnx d93037e2a0 Merge pull request 'Merge contrib: cap concurrent requests, from an outside contributor' (#75) from contrib into develop
CI / runtimes (bun) (push) Successful in 14s
CI / runtimes (deno) (push) Successful in 18s
CI / runtimes (edge) (push) Successful in 14s
CI / dco (push) Has been skipped
CI / build (push) Successful in 30s
2026-09-01 13:29:40 +00:00
hgshreyas ff94e55496 feat: cap concurrent requests across runtimes
CI / dco (push) Has been skipped
CI / build (push) Successful in 28s
CI / runtimes (deno) (push) Successful in 19s
CI / runtimes (bun) (push) Successful in 59s
CI / runtimes (edge) (push) Successful in 11s
CI / dco (pull_request) Successful in 6s
CI / runtimes (bun) (pull_request) Successful in 16s
CI / runtimes (edge) (pull_request) Successful in 12s
CI / runtimes (deno) (pull_request) Successful in 21s
CI / build (pull_request) Successful in 29s
Signed-off-by: hgshreyas <hgshreyas.cs24@bmsce.ac.in>
2026-08-31 08:53:14 -05:00
hgshreyas 82e1678dea fix: warn when connection limit drops a socket
Signed-off-by: hgshreyas <hgshreyas.cs24@bmsce.ac.in>
2026-08-30 12:55:20 -05:00
chrnx 4b04421ddd Merge pull request 'ci(release): publish the release notes, not just the tag' (#62) from ci/github-releases into develop
CI / dco (pull_request) Successful in 3s
CI / runtimes (bun) (pull_request) Successful in 16s
CI / build (pull_request) Successful in 25s
CI / runtimes (edge) (pull_request) Successful in 12s
CI / runtimes (deno) (pull_request) Successful in 19s
Promote → GitHub / push-github (push) Failing after 6s
CI / runtimes (bun) (push) Successful in 15s
CI / dco (push) Has been skipped
CI / build (push) Successful in 25s
CI / runtimes (deno) (push) Successful in 19s
CI / runtimes (edge) (push) Successful in 13s
2026-08-19 19:32:14 +00:00
chrnx 0fad12688d ci(release): publish the release notes, not just the tag
CI / dco (pull_request) Successful in 4s
CI / runtimes (bun) (pull_request) Successful in 13s
CI / build (pull_request) Successful in 24s
CI / runtimes (edge) (pull_request) Successful in 12s
CI / runtimes (deno) (pull_request) Successful in 18s
The repository had two tags and no releases, so the only way to find out what
a version changed was to open CHANGELOG.md and scroll to the right heading.
The release page is where people who do not read changelogs look, and a
repository with tags and no releases reads as abandoned.

Notes come from CHANGELOG.md rather than from the commit range. The section
was written for humans and already exists by the time a tag is cut; generated
notes would restate merge subjects nobody chose. `scripts/changelog-section.mjs`
extracts one version's section and makes its relative links absolute against
the tag — a release body resolves them against the release page, not the
repository, so `./BENCHMARKS.md` would have 404'd.

That script is a parser writing text that cannot be corrected quietly once it
is published, so its boundaries are pinned by a test rather than checked by
eye at release time. Both of the bugs it caught while being written are in
there: a section swallowing the `[label]: url` block that follows the oldest
version, and a relative link surviving into a body.

The step is idempotent like the publishes before it, so a re-run finishes what
is left instead of stopping here, and `--verify-tag` keeps it from inventing a
tag — it attaches to the one that triggered the run and cannot move it. A
prerelease is marked as one, which is what keeps the "Latest" badge off a beta.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-08-19 14:31:05 -05:00
chrnx ead71dc1b1 Merge pull request 'ci(release): spend the publish's one dist-tag on latest while there is no stable' (#60) from ci/publish-under-latest into develop
CI / dco (pull_request) Successful in 4s
CI / runtimes (bun) (pull_request) Successful in 14s
CI / build (pull_request) Successful in 25s
CI / runtimes (deno) (pull_request) Successful in 17s
CI / runtimes (edge) (pull_request) Successful in 11s
Promote → GitHub / push-github (push) Failing after 6s
CI / dco (push) Has been skipped
CI / build (push) Successful in 24s
CI / runtimes (bun) (push) Successful in 14s
CI / runtimes (deno) (push) Successful in 18s
CI / runtimes (edge) (push) Successful in 12s
2026-08-19 19:18:20 +00:00
chrnx 19fcc18899 ci(release): spend the publish's one dist-tag on latest while there is no stable
CI / dco (pull_request) Successful in 4s
CI / runtimes (bun) (pull_request) Successful in 14s
CI / build (pull_request) Successful in 24s
CI / runtimes (deno) (pull_request) Successful in 18s
CI / runtimes (edge) (pull_request) Successful in 12s
`npm dist-tag` cannot use Trusted Publishing. The OIDC exchange lives inside
`publish.js` and nowhere else, so the token it returns is publish-scoped: the
step added in the previous commit got `E401` on v26.8.0-beta.1, after both
registries had already taken the version.

That leaves one npm write per release, and it has to go where it counts.
While no stable exists, `latest` and `beta` mean the same thing — there is
nothing else to install — so `latest` takes the publish, because that is what
a bare `npm install @green-tea/core` resolves to and an untouched `latest`
hands the default install an older build than the one just released. The
channel tag is moved by hand; the step prints the command and AGENTS.md says
when it applies.

This is temporary by construction. Once a stable version exists it owns
`latest`, a beta published afterwards must not drag it backwards, and the
publish goes back to setting the channel tag directly — with nothing left to
move by hand.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-08-19 14:17:12 -05:00
chrnx 7f9e6b19d6 Merge pull request 'ci(release): keep latest on the newest beta, and make a re-run finishable' (#58) from ci/release-dist-tags into develop
CI / dco (pull_request) Successful in 4s
CI / runtimes (bun) (pull_request) Successful in 15s
CI / build (pull_request) Successful in 24s
CI / runtimes (deno) (pull_request) Successful in 18s
CI / runtimes (edge) (pull_request) Successful in 12s
CI / dco (push) Has been skipped
CI / runtimes (bun) (push) Successful in 15s
CI / build (push) Successful in 25s
CI / runtimes (deno) (push) Successful in 19s
CI / runtimes (edge) (push) Successful in 12s
Release → npmjs / publish-prod (push) Has been skipped
Promote → GitHub / push-github (push) Successful in 5s
v26.8.0-beta.1
2026-08-19 19:11:16 +00:00
chrnx 7be26fda5c ci(release): keep latest on the newest beta, and make a re-run finishable
CI / dco (pull_request) Successful in 5s
CI / runtimes (bun) (pull_request) Successful in 14s
CI / build (pull_request) Successful in 24s
CI / runtimes (edge) (pull_request) Successful in 12s
CI / runtimes (deno) (pull_request) Successful in 19s
While there is no stable release, a bare `npm install @green-tea/core` should
get the same thing `@beta` gets — that is what the docs promise. Since
`1a313c2` a prerelease publishes under its channel tag only, so the next
release would have left `latest` behind on 26.8.0-beta.0: an older build for
anyone who installs without asking for a channel.

`npm publish` sets one tag, and `npm dist-tag` cannot use Trusted Publishing —
the OIDC exchange lives inside `publish.js` and nowhere else. Rather than keep
a long-lived npm token in a secret for one command, the step runs the same
exchange itself: request the Actions id-token, trade it for a short-lived
package-scoped token, move the tag. Both values are masked.

The rule is bounded on purpose. Once a stable version exists it owns `latest`
permanently, and a beta published afterwards must not drag it backwards; the
lookup that decides this is read into a variable first, so a failed request
fails the step instead of passing for "no stable exists".

Both publishes also become skip-if-present. That is not belt-and-braces: the
new step runs after them and can fail, so a re-run has to be able to finish
the remaining work instead of dying on a version npm would reject anyway. The
JSR guard asks api.jsr.io rather than jsr.io/meta.json, which is 404 for a
package with no versions yet — the state this package is actually in.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-08-19 14:10:00 -05:00
chrnx e540752f1e Merge pull request 'chore(release): close the changelog at 26.8.0-beta.1' (#56) from chore/close-changelog-26.8.0-beta.1 into develop
CI / dco (pull_request) Successful in 4s
CI / runtimes (bun) (pull_request) Successful in 13s
CI / build (pull_request) Successful in 24s
CI / runtimes (deno) (pull_request) Successful in 18s
CI / runtimes (edge) (pull_request) Successful in 12s
CI / dco (push) Has been skipped
CI / build (push) Successful in 24s
CI / runtimes (bun) (push) Successful in 14s
CI / runtimes (deno) (push) Successful in 18s
Promote → GitHub / push-github (push) Successful in 6s
CI / runtimes (edge) (push) Successful in 12s
2026-08-19 19:02:33 +00:00
chrnx e86051382d chore(release): close the changelog at 26.8.0-beta.1
CI / dco (pull_request) Successful in 4s
CI / runtimes (bun) (pull_request) Successful in 15s
CI / build (pull_request) Successful in 24s
CI / runtimes (edge) (pull_request) Successful in 12s
CI / runtimes (deno) (pull_request) Successful in 18s
Everything in `[Unreleased]` ships under this tag, so the section gets its
date one step before the tag exists — the order AGENTS.md now prescribes.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-08-19 14:01:14 -05:00
chrnx b8cb684a6b docs: close the changelog at the tag, not when the version is decided
The changelog said [26.8.0-beta.1] - 2026-08-17 with a date, above work that
has never been tagged and is on no registry — npm still ends at beta.0 and
neither forge has the tag. A day of further work then landed underneath it as
[Unreleased], so the file asserted both that beta.1 shipped and that its
contents had not.

Folds that section back into [Unreleased], where all of it actually belongs,
and writes the rule in AGENTS.md so the next version is closed one step before
its tag rather than the day it is decided.

A version number is a plan; a changelog heading is a receipt.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-08-19 14:00:55 -05:00
chrnx 2c838c8753 Merge pull request 'fix(mesh): refuse to export a value the wire cannot carry' (#54) from feat/mesh-transport-guard into develop
CI / dco (pull_request) Successful in 4s
CI / runtimes (bun) (pull_request) Successful in 15s
CI / build (pull_request) Successful in 24s
CI / runtimes (deno) (pull_request) Successful in 18s
CI / runtimes (edge) (pull_request) Successful in 13s
Promote → GitHub / push-github (push) Successful in 6s
CI / dco (push) Has been skipped
CI / runtimes (bun) (push) Successful in 14s
CI / build (push) Successful in 24s
CI / runtimes (deno) (push) Successful in 19s
CI / runtimes (edge) (push) Successful in 14s
2026-08-18 18:39:32 +00:00
chrnx cd4f47486f Merge pull request 'feat(mesh): give boot a grace period for a slow teapot, and fail for an absent one' (#53) from feat/mesh-boot-retry into develop
CI / dco (push) Has been skipped
CI / runtimes (bun) (push) Successful in 22s
CI / build (push) Successful in 25s
CI / runtimes (edge) (push) Successful in 12s
CI / runtimes (deno) (push) Successful in 18s
2026-08-18 18:18:23 +00:00
chrnx ffb5139cae Merge pull request 'feat(mesh): carry the caller's identity across the wire, and bound what an unauthenticated peer can do' (#48) from feat/mesh-envelope into develop
CI / dco (push) Has been skipped
CI / build (push) Successful in 25s
CI / runtimes (bun) (push) Successful in 14s
CI / runtimes (edge) (push) Successful in 12s
CI / runtimes (deno) (push) Successful in 18s
2026-08-18 18:00:58 +00:00
chrnx 46342a0aa2 fix(mesh): refuse to export a value the wire cannot carry, instead of delivering an empty object
CI / dco (pull_request) Successful in 4s
CI / runtimes (bun) (pull_request) Successful in 14s
CI / build (pull_request) Successful in 25s
CI / runtimes (deno) (pull_request) Successful in 18s
CI / runtimes (edge) (pull_request) Successful in 14s
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>
2026-08-18 12:35:48 -05:00
chrnx 1975a7c03f feat(mesh): give boot a grace period for a slow teapot, and fail for an absent one
CI / dco (pull_request) Successful in 4s
CI / build (pull_request) Successful in 24s
CI / runtimes (deno) (pull_request) Successful in 18s
CI / runtimes (edge) (pull_request) Successful in 13s
CI / runtimes (bun) (pull_request) Successful in 16m11s
A teapot that is thirty seconds behind and a teapot that does not exist look
identical for the first thirty seconds, and only one of them should stop a
deploy. bootTimeoutMs is that grace: retries with backoff until it passes.

It still fails after that, deliberately. A provider the graph depends on is
not optional, and booting without it would only move the failure to the first
request, where it is a caller's 503 rather than the deploy's error.

The full battery caught what the first cut got wrong: a bad secret was being
retried. That is not a transient failure — it is the teapot's decision, and it
will be the same decision in thirty seconds, so retrying only spends the
deploy's patience to arrive at the identical error. Refusals now fail at once.

Telling them apart without threading close codes through the neutral socket
contract of four runtimes: a peer that accepted the connection and then hung
up before answering rejected us on purpose; one that never accepted it may
simply not be listening yet. That is exactly the distinction needed here.

Retries are logged and emitted as mesh:boot:retry, kept separate from
mesh:disconnect — that one is a link that was up and went away, this one never
came up, and a deploy watching for trouble wants to tell those apart.

437 vitest / 12 Deno / 7 Bun / edge / JSR dry run.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-08-18 11:28:44 -05:00
chrnx f2cb411eac feat(mesh): carry the caller's identity across the wire, and bound what an unauthenticated peer can do
CI / dco (pull_request) Successful in 4s
CI / runtimes (bun) (pull_request) Successful in 18s
CI / build (pull_request) Successful in 24s
CI / runtimes (edge) (pull_request) Successful in 11s
CI / runtimes (deno) (pull_request) Successful in 18s
The observability release gave every request an id and lost it at the process
boundary — in the one place a distributed trace is the entire point. The RPC
envelope now carries requestId, traceId and url, and the teapot adopts them
instead of opening its own investigation.

Both fields are optional on the wire, so the protocol version does not move.
That decision needed a rule rather than a judgement call, so the rule is now
written beside the constant: bump when an old peer would misparse or misbehave
silently, not when work happened. Bumping per change would make the number
mean the opposite of what it is for.

Three things found while in here:

- mesh:rpc:error emitted the per-link counter where every other emitter puts a
  name, so the two sides of one failure could not be matched up.
- The teapot had no handshake deadline, so an unauthenticated peer could hold
  a socket by saying nothing, and no frame size cap, so it could make the
  process JSON.parse up to whatever the socket layer allowed — 100 MiB with
  the ws defaults, before authenticating.
- The remote-route envelope was cast from the internal request object, putting
  ip and protocol on the wire as fields the protocol never declared.

The cleartext warning is a warning and not a refusal on purpose: a private
network already doing mutual TLS is legitimate, and green-tea cannot tell it
apart from an exposed one.

4 of the 8 new tests verified to fail against the old code; the rest are the
negative cases, which should pass both before and after. The Deno test drives
the teapot's frame loop with a raw client, because server-side close codes are
where these runtimes have already differed once.

431 vitest / 12 Deno / 7 Bun / edge / JSR dry run.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-08-18 11:15:54 -05:00
chrnx 1ccbf6cadf Merge pull request 'fix(mesh): reconnect to a teapot that came back, refusing a manifest that no longer fits' (#47) from feat/mesh-reconnect into develop
CI / dco (push) Has been skipped
CI / runtimes (bun) (push) Successful in 14s
CI / build (push) Successful in 25s
CI / runtimes (deno) (push) Successful in 18s
CI / runtimes (edge) (push) Successful in 12s
2026-08-18 16:04:54 +00:00
chrnx 6ffbad9825 fix(mesh): reconnect to a teapot that came back, refusing a manifest that no longer fits
CI / dco (pull_request) Successful in 4s
CI / runtimes (bun) (pull_request) Successful in 15s
CI / build (pull_request) Successful in 24s
CI / runtimes (edge) (pull_request) Successful in 12s
CI / runtimes (deno) (pull_request) Successful in 18s
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>
2026-08-18 10:53:24 -05:00
chrnx 6672185ba2 Merge pull request 'fix(shutdown): arm the teardown timer before the callback that clears it' (#44) from fix/teardown-timer-ordering into develop
CI / dco (pull_request) Successful in 4s
CI / runtimes (bun) (pull_request) Successful in 14s
CI / build (pull_request) Successful in 23s
CI / runtimes (deno) (pull_request) Successful in 16s
CI / runtimes (edge) (pull_request) Successful in 12s
Promote → GitHub / push-github (push) Successful in 7s
CI / dco (push) Has been skipped
CI / runtimes (bun) (push) Successful in 13s
CI / build (push) Successful in 27s
CI / runtimes (deno) (push) Successful in 17s
CI / runtimes (edge) (push) Successful in 12s
2026-08-18 14:18:47 +00:00
chrnx 198e62944f fix(shutdown): arm the teardown timer before the callback that clears it
CI / dco (pull_request) Successful in 4s
CI / runtimes (bun) (pull_request) Successful in 14s
CI / build (pull_request) Successful in 25s
CI / runtimes (deno) (pull_request) Successful in 17s
CI / runtimes (edge) (pull_request) Successful in 11s
`runTeardown` declared `finish` above the `timer` it clears, so the
reference held only because every caller — the timer's own callback and
`teardown.run().then()` — happens to be asynchronous. That is correct by
timing rather than by construction, which is what #20 asked to remove from
this file; `closeApp` twenty lines below already arms its timer first and
carries a comment explaining why that direction is the safe one.

Reversing the order here leaves both shutdown paths resting the same forward
reference on the same guarantee: setTimeout cannot invoke its callback
synchronously. No behaviour changes.

Closes #20

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-08-18 09:16:27 -05:00
chrnx 7d04b2d736 Merge pull request 'chore: back-merge main so promotions can go back to fast-forward-only' (#42) from chore/backmerge-main into develop
CI / dco (pull_request) Successful in 4s
CI / runtimes (deno) (pull_request) Successful in 17s
CI / runtimes (bun) (pull_request) Successful in 13s
CI / build (pull_request) Successful in 24s
CI / runtimes (edge) (pull_request) Successful in 12s
Promote → GitHub / push-github (push) Successful in 5s
CI / dco (push) Has been skipped
CI / runtimes (bun) (push) Successful in 13s
CI / build (push) Successful in 23s
CI / runtimes (deno) (push) Successful in 16s
CI / runtimes (edge) (push) Successful in 12s
2026-08-17 23:22:22 +00:00
chrnx 51608b0631 chore: back-merge main so promotions can go back to fast-forward-only
CI / dco (pull_request) Successful in 5s
CI / runtimes (bun) (pull_request) Successful in 13s
CI / build (pull_request) Successful in 23s
CI / runtimes (deno) (pull_request) Successful in 17s
CI / runtimes (edge) (pull_request) Successful in 11s
PR #40 promoted develop to main with a merge commit, which left an empty
merge commit living only on main. It carries no content — its diff against
its own develop parent is empty — but it keeps main out of develop's
ancestry, so the next fast-forward-only promotion cannot run at all.

This merge is a no-op by content and exists only to put that commit back
into develop's history. With it, develop -> main is a fast-forward again,
which is what AGENTS.md requires: no commit is ever born on main.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-08-17 18:20:47 -05:00
chrnx bbcc90eb4d Merge pull request 'feat: the trust release — observability, shutdown teardown, routing correctness and the docs split' (#41) from feature/trust-release into develop
CI / dco (push) Has been skipped
CI / runtimes (bun) (push) Successful in 13s
CI / build (push) Successful in 23s
CI / runtimes (deno) (push) Successful in 16s
CI / runtimes (edge) (push) Successful in 13s
2026-08-17 23:17:11 +00:00
chrnx 9b5347aa75 fix(observability): correlate requests on Node 18, where there is no global crypto
CI / dco (pull_request) Successful in 4s
CI / runtimes (bun) (pull_request) Successful in 13s
CI / build (pull_request) Successful in 23s
CI / runtimes (deno) (pull_request) Successful in 17s
CI / runtimes (edge) (pull_request) Successful in 28s
`engines` promises `>=18`. The global `crypto` arrived unflagged in Node 19.
Between those two facts, `correlateRequest` compiled cleanly against an ambient
`declare const crypto` and then threw `ReferenceError: crypto is not defined` on
the first request of every Node 18 process — which is to say the observability
work made the framework unusable on its own stated floor.

Nothing local could see it. Every developer machine here runs 20 or 22, and
Deno, Bun and workerd all expose the global. CI's Node 18 job caught it on the
promotion pull request, which is the entire reason that job is pinned to the
floor rather than to the current release.

The global stays the primary path, because it is why this file does not simply
import node:crypto: it is the runtime-neutral core, and node:crypto is not
available to all four runtimes. The fallback is reached only where the global is
absent, so workerd never evaluates the require, and the ESM build has a real one
from the createRequire banner already in tsup.config.ts. Verified in both built
formats rather than assumed — esbuild rewrites it to require("crypto"), which is
the same module.

test/node-floor.test.ts stubs the global away to reproduce the floor's condition
on any Node, and was confirmed to fail against the previous code. The bug was
invisible where it was written; this makes it visible there.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-08-17 18:11:50 -05:00
chrnx 0218508a96 docs(readme): lead with what the framework owns, not with what it is not
CI / dco (pull_request) Successful in 4s
CI / build (pull_request) Failing after 3m33s
CI / runtimes (bun) (pull_request) Successful in 33s
CI / runtimes (deno) (pull_request) Successful in 18s
CI / runtimes (edge) (pull_request) Successful in 11s
Follows the website copy strategy, translated from marketing register into the
one this file is read in. The strategy's own summary of the change applies
here too: stop selling simplicity because the framework is small, start
selling simplicity because the framework carries the infrastructure.

The hero led with "not a mutable bag threaded through positional middleware".
Middleware ordering was the origin problem, not the whole of what this does,
and a reader who has never hit that pain learns only what green-tea is
against. It now says what it is for: declare what a step needs and produces,
and the framework derives the order, validates the wiring before traffic, and
runs only the slice a route requires.

Added "Who does the work?", the section the strategy ranks first and the file
never had. It is a table of which side of the import each infrastructure
decision lives on, ending with business rules on yours — and it is where the
single runtime dependency now sits, as evidence rather than as a headline. The
number was never the point: fewer moving parts to understand, upgrade,
coordinate and debug is. A framework owning less does not delete that work, it
moves it into your application.

"Batteries included — still one dependency" did both of the things the
strategy says to demote in one heading. It is now "What the foundation already
carries", which is the same list making the ownership argument instead of a
bloat-adjacent one.

Accuracy guardrails re-checked after editing rather than assumed: compile-time
guarantees stay scoped to the typed flow core with decorator wiring
boot-validated, mesh stays alpha, no zero-dependency claim, no benchmark
leadership, no anti-Web-Standards framing.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-08-17 13:21:44 -05:00
chrnx 41c1f4308b chore(release): cut 26.8.0-beta.1
package.json and deno.json both still said 26.8.0-beta.0, which npm already
has. Publishing would have been rejected there and — the expensive half — JSR
versions are immutable, so a wrong one can never be replaced.

The changelog section is closed at today rather than left under Unreleased,
because what it now contains is the whole of this release: the observability
contract, shutdown teardown, the dot-segment behaviour change, and the two
fixes on the fetch and shutdown paths.

The documentation repository is tagged 26.8.0-beta.1 alongside, and that
number means the same thing there: not a version of the site, but the core
release its pages describe. Cutting the two together is what makes the version
a claim that the release is documented rather than only shipped.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-08-17 13:05:27 -05:00
chrnx bb75cabeea docs(changelog): record the release's largest feature, which was missing entirely
Unreleased carried two entries for the 81 commits since v26.8.0-beta.0, and
the observability contract was not one of them — the feature four independent
reviews named as the project's biggest gap, and the reason issue #10 existed,
had no changelog presence in any version. Someone deciding whether to upgrade
would have read the release as a shutdown fix.

Also added, in the order a reader needs them rather than the order they landed:

Changed: `.` and `..` in a request path now resolve instead of 404ing. This is
a behaviour change and belongs under Changed rather than buried in Fixed — it
is Node-only, it ends a divergence where the same bytes reached different
routes per runtime, and it is worth telling anyone whose proxy matches on the
literal path that the proxy and the application no longer agree.

Fixed: the BodyInit narrowing on the app.fetch path, which is the path Deno,
Bun and the edge all use, and the shutdown timer ordering that left a
ReferenceError waiting for whoever touched it next.

Found by diffing the public surface at the tag against HEAD rather than
rereading the file. `createApp` gained five options and the package eleven
exports since the beta; the entries above are what had no home.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-08-17 12:50:37 -05:00
chrnx bead3c1569 docs: make the docs rule followable by the people it addresses
Two problems with the rule added earlier today, both found by asking what it
means for the beta rather than whether to automate it.

green-tea is public and green-tea-docs was private, so CONTRIBUTING.md — read
by external contributors — pointed them at a repository that answered 404 and
asked them to change a page they could not see. The repository is now public,
which is what makes the rule possible at all; nothing in it was ever private,
since the history came from this repository's own website/ directory.

And "in the same pull request" cannot be done: a pull request does not span
two repositories. It is a companion pull request, linked to the first, and
both documents now say so.

Added the escape hatch the rule was missing. A contributor who does not want
to write the docs change can say so and a maintainer writes it — what this
line exists to prevent is an API change nobody mentions, not an unwritten
page, and a rule with no honest way out gets ignored rather than followed.

Neither the automation decision nor the accepted risk changes. The link check
stays rejected on the measurement recorded in the trust-release plan.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-08-17 12:38:09 -05:00
chrnx 0414aff665 docs(plans): reject the docs link check, and record what measuring it showed
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>
2026-08-17 12:32:01 -05:00
chrnx 21765c2a47 docs: put the docs-drift warning where nobody can miss it
The rule was already in both READMEs, and in both it was a subordinate clause
at the end of something else — a trailing "because nothing fails when the two
disagree" here, a closing section titled "The seam this repository opens"
there. Written, and easy to read past.

Both are now a callout: what breaks, that nothing tells you, and what to do
instead. The docs repository's moves to the top, above how to run it, because
someone opening that repository is usually about to edit a page.

Deliberately not in the marketing site. That risk belongs to whoever changes
the API, not to whoever is deciding whether to try the framework.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-08-17 12:17:30 -05:00
chrnx cd6e2f073f docs: put the docs-drift rule where a contributor reads it
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>
2026-08-17 12:11:29 -05:00
chrnx 38b73cebce docs(readme): say which parts are settled and which still move
The last thing a reader needs before betting on a beta, and the one thing
Honest scope did not answer: it admits what is missing, not what is likely to
change under them.

Present state only. No dates, no delivery commitment, and deliberately not a
roadmap — this is one person's spare-time work, and a schedule it cannot keep
would cost more trust than the schedule earns. The API freeze stays declared
under **next**, untouched, and gets planned near the RC.

Every tier is read off the history rather than asserted. The graph is settled
because graph.ts and container.ts have not been touched since the beta
hardening on 7 July, and because the changes to metadata.ts since then only
add decorators (@Head, @Options, @Html) rather than redefine the ones that
were there. The plugin API is listed as moving because it moved this week.
The pipeline context is listed because 4081106 made it one object mutated in
place, which changed what a step that captured it observes — a real semantic
change, not a perf note, and worth a reader knowing.

Two claims the trust-release plan proposed are not made. It grouped decorator
syntax with the volatile things; the volatility there is TC39's, not ours, and
README already explains it. And it listed the CLI, which ships from its own
repository on its own version line, so nothing here can honestly speak for it.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-08-17 11:56:50 -05:00
chrnx 62d0b7aa3a test: execute the circuit-breaker recipe the docs publish
The recipe closing #13 lives in the documentation repository, which imports
nothing from here — so nothing fails when the page and the framework drift
apart. That is the seam Phase 4 opened, and a worked example that quietly
stops working is the worst version of it: it is the page a reader trusts most,
because it looks like code that ran.

This executes the three claims the page rests on rather than asserting them in
prose. That breaker state survives across requests, which is the entire reason
the recipe uses a provider and not a step. That the window re-opens after it
elapses. And that a failed trial in half-open re-opens immediately instead of
making a recovering upstream earn the full threshold again.

Beyond the file list Phase 5 asked for, which named only the guide page. Kept
because it is small and it turns Task 4.4's written rule into something that
fails, for one page at least.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-08-17 11:44:49 -05:00
chrnx 24feca481c feat: shutdown teardown for plugins, providers and applications
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>
2026-08-17 11:37:31 -05:00
chrnx bfe8b66127 ci: run the JSR gate on every push, not only on a release tag
release.yml has always run `deno publish --dry-run` before publishing to
either registry, and keeps doing so — that copy is the last thing standing
between a tag and a JSR version number that can never be replaced.

It runs too late to be feedback, though. A slow type in the public API or a
Deno type error lands on main in silence and surfaces while cutting a
release, which is the same "least time to judge a fix" the audit steps are
already ordered to avoid. The workflow made that argument for advisories and
not for the registry that type-checks us.

This matters more in the next few commits than it did in the last hundred:
Task 2.5 adds Hooks, TeardownFn and PluginApi.onShutdown, and exported types
are exactly what the slow-types check polices.

It is a second compiler over the same source rather than a packaging
formality. `npm run typecheck` is tsc with this repo's config; this is Deno's
checker with Deno's lib, and it is what found the BodyInit hole on the fetch
path that tsc accepted. JSR serves src/ directly, so what it rejects is what
a JSR consumer would have received.

Measured at 0.68s against 2.0s for the whole vitest suite, so it goes in the
runtimes job's Deno leg, which already installs Deno.

test:all covers the same ground locally. npm test stays Node-only on purpose
— it is the loop you run constantly, and booting three more runtimes into it
would tax every run to catch what CI already catches on every push. Verified
end to end: 393 vitest, 9 Deno, 5 Bun, edge, and the dry run, in 6.1s.

It passes --allow-dirty and CI does not, deliberately: locally you are
checking work in progress, and in CI a checkout that is not clean is worth
failing on.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-08-17 11:21:43 -05:00
chrnx 78b5034936 docs(plans): drop 4.5.3 — the decorator warning is already documented, and the reason given for it was wrong
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>
2026-08-17 11:19:41 -05:00
chrnx a5c1fda886 docs(plans): add Phase 4.5 — move the JSR gate off the tag
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>
2026-08-17 10:44:43 -05:00
chrnx e778f62902 docs(plans): settle D8 as a reservation, and plan the implementation
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>
2026-08-17 10:40:32 -05:00
chrnx 9f72604cbb docs(plans): design the shutdown teardown surface, before any code
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>
2026-08-17 10:32:23 -05:00
chrnx 101c4fe65a chore: move the documentation site out to its own repository
website/ is now github.com/Expressive-Tea/green-tea-docs, carrying its own
history — 31 commits, extracted with `git subtree split`, not squashed into
an import that pretends the pages appeared all at once.

What this repository gives up is real and worth naming: the site had no
deploy pipeline at all, and CI here was the only thing proving it still
built. That is why the new repository got a build gate and a tagged release
before this deletion landed, rather than after.

Removed with it: the three website steps in ci.yml (including the second
setup-node that re-pinned 22.12 purely for the docs build — the core job
stays on 18, the minimum supported version), the two package.json scripts,
and the .astro/ and website/dist/ ignore rules that now belong over there.

SECURITY.md pointed at `website/` as an out-of-scope path; it now points at
the repository, since the path no longer exists to be out of scope.

The split trades a CI coupling for a drift risk — nothing fails now when
the docs and the API disagree. Both READMEs state the rule that replaces
the build: a change to public API updates the page documenting it. That is
the weakest of the options considered, and it is written down rather than
assumed.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-08-17 10:05:04 -05:00
chrnx a4bb3c02d6 refactor(http): resolve each request once, in the core that already routes it
Both adapters routed every request themselves, and then handle() routed it
again from the same inputs — a four-route app walked its table 2.5 times
per request. Neither side was wrong: an adapter must know the route to
decide whether to read a body, and the core must know it to dispatch.

The cause was the shape of the handoff. NeutralRequest carried an
already-parsed body, so producing one was the adapter's problem, and every
policy that depends on the matched route came with it — these four chains
were written out in server.ts and web.ts character for character:

    matched.def.maxBodyBytes   ?? opts?.limits?.maxBodyBytes ?? 1_000_000
    matched.def.bodyDuplicates ?? opts?.bodyDuplicates       ?? 'last'
    matched.def.maxParts       ?? opts?.limits?.maxParts     ?? 1000
    opts?.limits?.maxBodyBytes ?? 1_000_000

A fifth knob, or one changed default, meant editing both or letting the
runtimes quietly disagree about limits.

Handing over the ability to read rather than the result moves the decision
to where the route is already known. What stays in an adapter is what
genuinely differs between runtimes: getting bytes in, putting bytes out.
Enforcement stays with the reader too, because Node aborts an oversized
upload as chunks arrive while a fetch runtime can only measure what
arrayBuffer() already resolved — passing the limit in preserves that.
413/400/501 keep their exact current shape, Node's connection: close
included; it now has the test it never had.

Measured through app.fetch, both versions in one process, interleaved:
40 routes with the match declared last, 3.89 -> 3.58 us (-8.2%). One
route, where there is no second scan to save, is unchanged.

The first cut of this was 13% SLOWER, and the reason is worth recording:
a per-request closure for the reader plus the error-context object it
captured cost 250 ns, and the async frames around a body that did not
exist cost another 215 ns — together more than the duplicate scan the
whole change removes. The reader is now built once per server and takes
the runtime's request as an argument, and a bodiless request touches no
promise on this path at all.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-08-16 23:46:57 -05:00
chrnx 0c9f8a545e fix(router): route dot segments the same way on every runtime
The same bytes on the wire reached different routes depending on where
the app ran. `GET /public/../admin` hit a `/admin` route under Deno, Bun
and workerd, and 404'd under Node — 200 vs 404 for one request.

The fetch-based runtimes resolve dot segments inside the `Request`
constructor, before green-tea is handed anything: `new Request(
'http://x/public/../admin').url` is already `http://x/admin`. Node's raw
target has no such step. Rejecting outright — the stricter policy, and
what this module already does for `//` — is not implementable on three of
the four runtimes, because the raw target is unrecoverable there. So Node
converges on the rule the other three cannot opt out of.

`%2e` is a dot to the URL parser, so the encoded spelling resolves too;
leaving it out would keep it as a way to reach a route the plain spelling
resolves away from.

Cost is gated: paths with no `.` and no `%` pay two indexOf scans
(20.0 -> 21.7 ns for `/hello`), a literal dot pays the regex (35.5 ns),
and only real dot segments pay the split (103.6 ns).

The existing parity suite could not have caught this — its `both()`
helper goes through `fetch()`, which normalizes the URL before it reaches
the wire. The new cases write the request line to a socket by hand.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-08-16 23:35:26 -05:00
chrnx e625d5c881 perf(router): stop the route scan at a match nothing can outrank
matchRoute evaluated every registered route before answering, so `/hello`
cost the same whether it was declared first or last among 32 routes —
1227 ns against 1237 ns. That is ~38 ns of scanning per registered route
on every request, growing with the route table, and the benchmark app has
the smallest table any real service would have.

Specificity ranks a literal segment above every other kind, so a pattern
made only of literals cannot be outranked by anything else matching the
same path, and an equal rank keeps registration order — which is the
route already in hand. Finishing the scan only re-derives it.

The path split moves out of matchCompiled for the same reason: `split` +
`filter` ran once per candidate route on every request, always producing
the same array. Doing it once per request is 63.7% off a 32-route scan
that early exit cannot help at all (a :param match, which must be
compared against the rest of the table).

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-08-16 23:35:06 -05:00
chrnx 5fafe97bc5 docs: correct the observability cost, and record why three earlier numbers were wrong
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>
2026-08-16 23:03:07 -05:00
chrnx 8d8ef7ed09 perf(http): look injected header keys up directly instead of rebuilding a Set
mergeInjectedHeaders rebuilt a lowercased Set of the injected header keys on
every response: an array from Object.keys, a mapped array from toLowerCase, and
a Set from that. Three allocations to answer a question the object already
answers.

The lowercasing was the redundant part. Every key `injected` can hold is written
as a lowercase literal in src/security.ts — buildSecurityHeaders and resolveCors
are its only sources — so the mapped array was a copy of the keys it started
with.

hasOwnProperty rather than `in`: a handler may legitimately send a header named
constructor or toString, and `in` would find those on Object.prototype and drop
them silently.

146.4ns to 55.9ns in isolation; -3.2% end to end over five interleaved rounds,
with all five pairs favouring the change.

Third of three fixes from the same profile, and all three are one pattern:
work done unconditionally for a case that rarely or never applies — validating
encoding that is almost never malformed, parsing a query string that is not
there, lowercasing keys that already were.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-08-16 22:57:37 -05:00