CARD-18, decision D9 (graph-wide, including mesh), GitHub Expressive-Tea/green-tea#35. The Gitea #35 is an unrelated, closed issue; there's no Gitea issue for this one.
topoSort/topoLevels/subgraphFor mapped tokens with producedBy.set(key, node), so the last node won. Plugin nodes are registered after module nodes, so a plugin's scope.add({ name: 'shadow', provides: ['user'] }) silently replaced the app's @Provider({ provides: 'user' }).
src/graph.ts: topoSort builds its map through a new producers() that throws on a second producer of a token, naming both nodes and origins: token 'user' is provided twice: by 'user' (module:AppModule) and by 'shadow' (plugin) — a token has exactly one producer; … topoLevels/subgraphFor only see topoSort-validated nodes, so they're unchanged (Option 1 in the card).
The check runs at finalize(), after the mesh splice, so remote steps (mesh:<url>) and built-ins (builtin) are checked by rule, not by registration order.
overrides add no node, so they're unaffected. Steps that provide nothing (plugin observers) aren't producers.
CHANGELOG.md: ### Breaking.
Tests
test/one-producer.test.ts: T1 (provider and step variants, exact message with both origins), T2 (logger, rooms, events), T3, T4, T5, two plugins sharing a token, observers, and T6 on Node (teacup local step auth + teapot exporting auth → duplicate provider/step name 'auth', unchanged).
test/graph.test.ts: order-independence (built-in first / plugin first both throw; covers "swap provideBuiltins and mountPlugins") plus a mesh: origin.
test/deno/mesh.test.ts, test/bun/mesh.test.ts: T6 on Deno and Bun.
Against the old src/graph.ts, all 10 T1–T3/order/mesh-origin cases fail.
T7: the green-tea-plugins develop checkout (jwt, metrics, rate-limit), with this branch's npm pack swapped in for @green-tea/core: npm test 60/60, test:deno 31/31, test:bun 31/31 (no workerd suite there). Matcha's scaffold templates (src/plugin_files.rs, src/cmd_create.rs) keep name = token and give each instance its own token. I checked them by inspection only and didn't run them.
Check
Result
npm run lint
0 errors (50 existing no-explicit-any warnings)
npm run format:check
pass
npm run typecheck
pass
npm test
930 passed
npm run build
pass
npm run complexity:check
every function ≤ 25
npm run test:deno
37 passed, 0 failed
npm run test:bun
27 pass, 0 fail
npm run test:edge
PASS (router parity 1158 + 55)
No frozen router-parity capture changed. Based on develop after #134/#135; npm audit --audit-level=moderate passes locally.
Unsure about / for the owner
Card rule 4 is not true today. The card says seeds (req, params) "cannot be provided by a node (already true; keep the test)". There's no such test, and a probe shows a @Step({ provides: 'req' }) and a plugin node with provides: ['params'] both boot. That isn't a one-producer conflict (seeds have no graph node), so this PR does not add that boot failure. It would be a new breaking rule beyond D9's text. Should it be added (here or as a follow-up)?
Error order: plugins mount before built-ins are registered, so T2 reports 'fake-logger' (plugin) first and 'logger' (builtin) second. Both are always named.
The error hint mentions overrides, which is an app option. It points app authors to the supported way to replace a value.
Docs follow-up (CARD-12)
Plugins guide, "What a plugin can and cannot touch": a plugin node can't provide a token anything else provides (including logger, rooms, events); boot fails naming both producers. Keep name = node name = token.
Migration note for ### Breaking, and mention overrides as the way to replace a token's value in tests.
## What and why
CARD-18, decision D9 (graph-wide, including mesh), GitHub `Expressive-Tea/green-tea#35`. The Gitea `#35` is an unrelated, closed issue; there's no Gitea issue for this one.
`topoSort`/`topoLevels`/`subgraphFor` mapped tokens with `producedBy.set(key, node)`, so the last node won. Plugin nodes are registered after module nodes, so a plugin's `scope.add({ name: 'shadow', provides: ['user'] })` silently replaced the app's `@Provider({ provides: 'user' })`.
- `src/graph.ts`: `topoSort` builds its map through a new `producers()` that throws on a second producer of a token, naming both nodes and origins:
`token 'user' is provided twice: by 'user' (module:AppModule) and by 'shadow' (plugin) — a token has exactly one producer; …`
`topoLevels`/`subgraphFor` only see `topoSort`-validated nodes, so they're unchanged (Option 1 in the card).
- The check runs at `finalize()`, after the mesh splice, so remote steps (`mesh:<url>`) and built-ins (`builtin`) are checked by rule, not by registration order.
- `overrides` add no node, so they're unaffected. Steps that provide nothing (plugin observers) aren't producers.
- `CHANGELOG.md`: `### Breaking`.
## Tests
- `test/one-producer.test.ts`: T1 (provider and step variants, exact message with both origins), T2 (`logger`, `rooms`, `events`), T3, T4, T5, two plugins sharing a token, observers, and T6 on Node (teacup local step `auth` + teapot exporting `auth` → `duplicate provider/step name 'auth'`, unchanged).
- `test/graph.test.ts`: order-independence (built-in first / plugin first both throw; covers "swap `provideBuiltins` and `mountPlugins`") plus a `mesh:` origin.
- `test/deno/mesh.test.ts`, `test/bun/mesh.test.ts`: T6 on Deno and Bun.
- Against the old `src/graph.ts`, all 10 T1–T3/order/mesh-origin cases fail.
- **T7:** the `green-tea-plugins` develop checkout (jwt, metrics, rate-limit), with this branch's `npm pack` swapped in for `@green-tea/core`: `npm test` 60/60, `test:deno` 31/31, `test:bun` 31/31 (no workerd suite there). Matcha's scaffold templates (`src/plugin_files.rs`, `src/cmd_create.rs`) keep name = token and give each instance its own token. I checked them **by inspection only** and didn't run them.
| Check | Result |
|---|---|
| `npm run lint` | 0 errors (50 existing `no-explicit-any` warnings) |
| `npm run format:check` | pass |
| `npm run typecheck` | pass |
| `npm test` | 930 passed |
| `npm run build` | pass |
| `npm run complexity:check` | every function ≤ 25 |
| `npm run test:deno` | 37 passed, 0 failed |
| `npm run test:bun` | 27 pass, 0 fail |
| `npm run test:edge` | PASS (router parity 1158 + 55) |
No frozen router-parity capture changed. Based on develop after #134/#135; `npm audit --audit-level=moderate` passes locally.
## Unsure about / for the owner
- **Card rule 4 is not true today.** The card says seeds (`req`, `params`) "cannot be provided by a node (already true; keep the test)". There's no such test, and a probe shows a `@Step({ provides: 'req' })` and a plugin node with `provides: ['params']` both boot. That isn't a one-producer conflict (seeds have no graph node), so this PR **does not** add that boot failure. It would be a new breaking rule beyond D9's text. Should it be added (here or as a follow-up)?
- Error order: plugins mount before built-ins are registered, so T2 reports `'fake-logger' (plugin)` first and `'logger' (builtin)` second. Both are always named.
- The error hint mentions `overrides`, which is an app option. It points app authors to the supported way to replace a value.
## Docs follow-up (CARD-12)
- Plugins guide, "What a plugin can and cannot touch": a plugin node can't provide a token anything else provides (including `logger`, `rooms`, `events`); boot fails naming both producers. Keep name = node name = token.
- Migration note for `### Breaking`, and mention `overrides` as the way to replace a token's value in tests.
Owner decision (2026-10-23): card rule 4 (seeds cannot be provided) is dropped from CARD-18. It isn't true today, and enforcing it would be a new breaking rule beyond D9. Not merging yet: implementation review first.
Owner decision (2026-10-23): card rule 4 (seeds cannot be provided) is **dropped** from CARD-18. It isn't true today, and enforcing it would be a new breaking rule beyond D9. Not merging yet: implementation review first.
topoSort, topoLevels and subgraphFor built their token -> node map with
producedBy.set(key, node), so the last node registered for a token won.
Plugin nodes are registered after module nodes, which let a plugin's
scope.add({ name: 'shadow', provides: ['user'] }) silently replace the
app's own @Provider({ provides: 'user' }) for every route that needed
it. setRunner only rejects duplicate names, and scope.add is the one
path where a name and its tokens differ.
D9 settles it graph-wide: topoSort now throws when a token already has
a producer, naming both nodes and their origins (module:..., plugin,
mesh:<url>, builtin). One check on the whole node set covers every
current and future registration path. It also protects the built-ins
(logger, rooms, events) by rule rather than by registration order.
topoSort runs at finalize, after the mesh splice, so remote steps are
checked too. topoLevels and subgraphFor only ever see nodes topoSort
has already validated, so they keep their plain maps.
overrides replace the runner of an existing token and add no node, so
they are unaffected. Steps that provide nothing (plugin observers) are
not producers. The official plugins (jwt, metrics, rate-limit) pass
their suites against this build.
BREAKING CHANGE: an app whose graph has two nodes providing one token,
e.g. a plugin scope node providing a token a module or built-in
already provides, now fails createApp instead of letting the later
node win.
Refs: GitHub #35
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
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.
What and why
CARD-18, decision D9 (graph-wide, including mesh), GitHub
Expressive-Tea/green-tea#35. The Gitea#35is an unrelated, closed issue; there's no Gitea issue for this one.topoSort/topoLevels/subgraphFormapped tokens withproducedBy.set(key, node), so the last node won. Plugin nodes are registered after module nodes, so a plugin'sscope.add({ name: 'shadow', provides: ['user'] })silently replaced the app's@Provider({ provides: 'user' }).src/graph.ts:topoSortbuilds its map through a newproducers()that throws on a second producer of a token, naming both nodes and origins:token 'user' is provided twice: by 'user' (module:AppModule) and by 'shadow' (plugin) — a token has exactly one producer; …topoLevels/subgraphForonly seetopoSort-validated nodes, so they're unchanged (Option 1 in the card).finalize(), after the mesh splice, so remote steps (mesh:<url>) and built-ins (builtin) are checked by rule, not by registration order.overridesadd no node, so they're unaffected. Steps that provide nothing (plugin observers) aren't producers.CHANGELOG.md:### Breaking.Tests
test/one-producer.test.ts: T1 (provider and step variants, exact message with both origins), T2 (logger,rooms,events), T3, T4, T5, two plugins sharing a token, observers, and T6 on Node (teacup local stepauth+ teapot exportingauth→duplicate provider/step name 'auth', unchanged).test/graph.test.ts: order-independence (built-in first / plugin first both throw; covers "swapprovideBuiltinsandmountPlugins") plus amesh:origin.test/deno/mesh.test.ts,test/bun/mesh.test.ts: T6 on Deno and Bun.src/graph.ts, all 10 T1–T3/order/mesh-origin cases fail.green-tea-pluginsdevelop checkout (jwt, metrics, rate-limit), with this branch'snpm packswapped in for@green-tea/core:npm test60/60,test:deno31/31,test:bun31/31 (no workerd suite there). Matcha's scaffold templates (src/plugin_files.rs,src/cmd_create.rs) keep name = token and give each instance its own token. I checked them by inspection only and didn't run them.npm run lintno-explicit-anywarnings)npm run format:checknpm run typechecknpm testnpm run buildnpm run complexity:checknpm run test:denonpm run test:bunnpm run test:edgeNo frozen router-parity capture changed. Based on develop after #134/#135;
npm audit --audit-level=moderatepasses locally.Unsure about / for the owner
req,params) "cannot be provided by a node (already true; keep the test)". There's no such test, and a probe shows a@Step({ provides: 'req' })and a plugin node withprovides: ['params']both boot. That isn't a one-producer conflict (seeds have no graph node), so this PR does not add that boot failure. It would be a new breaking rule beyond D9's text. Should it be added (here or as a follow-up)?'fake-logger' (plugin)first and'logger' (builtin)second. Both are always named.overrides, which is an app option. It points app authors to the supported way to replace a value.Docs follow-up (CARD-12)
logger,rooms,events); boot fails naming both producers. Keep name = node name = token.### Breaking, and mentionoverridesas the way to replace a token's value in tests.3757c9bc14to0b80df9e3aOwner decision (2026-10-23): card rule 4 (seeds cannot be provided) is dropped from CARD-18. It isn't true today, and enforcing it would be a new breaking rule beyond D9. Not merging yet: implementation review first.
topoSort, topoLevels and subgraphFor built their token -> node map with producedBy.set(key, node), so the last node registered for a token won. Plugin nodes are registered after module nodes, which let a plugin's scope.add({ name: 'shadow', provides: ['user'] }) silently replace the app's own @Provider({ provides: 'user' }) for every route that needed it. setRunner only rejects duplicate names, and scope.add is the one path where a name and its tokens differ. D9 settles it graph-wide: topoSort now throws when a token already has a producer, naming both nodes and their origins (module:..., plugin, mesh:<url>, builtin). One check on the whole node set covers every current and future registration path. It also protects the built-ins (logger, rooms, events) by rule rather than by registration order. topoSort runs at finalize, after the mesh splice, so remote steps are checked too. topoLevels and subgraphFor only ever see nodes topoSort has already validated, so they keep their plain maps. overrides replace the runner of an existing token and add no node, so they are unaffected. Steps that provide nothing (plugin observers) are not producers. The official plugins (jwt, metrics, rate-limit) pass their suites against this build. BREAKING CHANGE: an app whose graph has two nodes providing one token, e.g. a plugin scope node providing a token a module or built-in already provides, now fails createApp instead of letting the later node win. Refs: GitHub #35 Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>0b80df9e3ato56f953f0bb