app.bus is public and Bus is an exported type, but bus is not a token in the graph — so @needs('bus') fails at boot, and nothing tells you that before it does.
What happens
handler 'h' needs 'bus' but nothing (local or mesh) provides it
provideBuiltins (src/app/index.ts:537) registers exactly two tokens: logger and rooms. The bus is reachable in two other places — app.bus after createApp returns, and api.bus.on inside a plugin — but not from inside the graph, which is where a provider, a step or a handler lives.
Why it matters
The framework's answer for "I need the framework's own logger" is @needs('logger'), and the doc comment sells it as such: "one object, two access paths". That teaches a user the pattern, so the first instinct for "I need the framework's own events" is @needs('bus'), and the boot error is the first news that it is not the same shape.
There is a real reason for the difference, and it is a good one: PluginApi hands over bus.on and deliberately not emit — "Hand the plugin ONLY on(), add() and onShutdown()" (src/plugin.ts:34). Putting the Bus instance in the graph would hand emit to every node and turn a one-way observation channel into something anything can forge events on.
So the answer is "observability is a plugin, not a provider" — a design decision that is nowhere written down. It is inferable only by reading provideBuiltins and mountPlugin and noticing what is absent from each.
Scope
Pick one:
Just document it. A sentence on PluginApi and on the observability section: events are subscribed to from a plugin; bus is not a graph token, and that is on purpose so nobody can emit.
Provide a read-only token, e.g. events bound to { on } — the same narrowing plugins already get. It would make @needs('events') work the way @needs('logger') does, and preserve the isolation the current design is protecting.
Option 2 is only worth it if subscribing from inside the graph is something users should be doing; a plugin is arguably the right home for it, in which case option 1 is the whole fix.
Related
Found while writing metrics.plugin.ts for the green-desk demo. It ended up as a plugin — the correct outcome — reached by hitting the boot error first.
`app.bus` is public and `Bus` is an exported type, but `bus` is not a token in the graph — so `@needs('bus')` fails at boot, and nothing tells you that before it does.
## What happens
```
handler 'h' needs 'bus' but nothing (local or mesh) provides it
```
`provideBuiltins` (`src/app/index.ts:537`) registers exactly two tokens: `logger` and `rooms`. The bus is reachable in two other places — `app.bus` after `createApp` returns, and `api.bus.on` inside a plugin — but not from inside the graph, which is where a provider, a step or a handler lives.
## Why it matters
The framework's answer for "I need the framework's own logger" is `@needs('logger')`, and the doc comment sells it as such: *"one object, two access paths"*. That teaches a user the pattern, so the first instinct for "I need the framework's own events" is `@needs('bus')`, and the boot error is the first news that it is not the same shape.
There is a real reason for the difference, and it is a good one: `PluginApi` hands over `bus.on` and deliberately not `emit` — *"Hand the plugin ONLY on(), add() and onShutdown()"* (`src/plugin.ts:34`). Putting the `Bus` instance in the graph would hand `emit` to every node and turn a one-way observation channel into something anything can forge events on.
So the answer is "observability is a plugin, not a provider" — a design decision that is nowhere written down. It is inferable only by reading `provideBuiltins` and `mountPlugin` and noticing what is absent from each.
## Scope
Pick one:
1. **Just document it.** A sentence on `PluginApi` and on the observability section: events are subscribed to from a plugin; `bus` is not a graph token, and that is on purpose so nobody can `emit`.
2. **Provide a read-only token**, e.g. `events` bound to `{ on }` — the same narrowing plugins already get. It would make `@needs('events')` work the way `@needs('logger')` does, and preserve the isolation the current design is protecting.
Option 2 is only worth it if subscribing from inside the graph is something users should be doing; a plugin is arguably the right home for it, in which case option 1 is the whole fix.
## Related
Found while writing `metrics.plugin.ts` for the `green-desk` demo. It ended up as a plugin — the correct outcome — reached by hitting the boot error first.
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.
app.busis public andBusis an exported type, butbusis not a token in the graph — so@needs('bus')fails at boot, and nothing tells you that before it does.What happens
provideBuiltins(src/app/index.ts:537) registers exactly two tokens:loggerandrooms. The bus is reachable in two other places —app.busaftercreateAppreturns, andapi.bus.oninside a plugin — but not from inside the graph, which is where a provider, a step or a handler lives.Why it matters
The framework's answer for "I need the framework's own logger" is
@needs('logger'), and the doc comment sells it as such: "one object, two access paths". That teaches a user the pattern, so the first instinct for "I need the framework's own events" is@needs('bus'), and the boot error is the first news that it is not the same shape.There is a real reason for the difference, and it is a good one:
PluginApihands overbus.onand deliberately notemit— "Hand the plugin ONLY on(), add() and onShutdown()" (src/plugin.ts:34). Putting theBusinstance in the graph would handemitto every node and turn a one-way observation channel into something anything can forge events on.So the answer is "observability is a plugin, not a provider" — a design decision that is nowhere written down. It is inferable only by reading
provideBuiltinsandmountPluginand noticing what is absent from each.Scope
Pick one:
PluginApiand on the observability section: events are subscribed to from a plugin;busis not a graph token, and that is on purpose so nobody canemit.eventsbound to{ on }— the same narrowing plugins already get. It would make@needs('events')work the way@needs('logger')does, and preserve the isolation the current design is protecting.Option 2 is only worth it if subscribing from inside the graph is something users should be doing; a plugin is arguably the right home for it, in which case option 1 is the whole fix.
Related
Found while writing
metrics.plugin.tsfor thegreen-deskdemo. It ended up as a plugin — the correct outcome — reached by hitting the boot error first.