The bus is a port of packages/clanker/src/bus/ in dough-quiver (main at 81f7cd7). Its design is in dough-quiver’s docs/design/reactive-core.md. The port keeps clanker’s behaviour, names and store contract:
- Tests: clanker’s bus tests and the store conformance suite run unchanged against the Promise facade, which keeps clanker’s class names.
- Translation: the internals are translated to Effect. Clanker’s own code in dough-quiver is unchanged.
What changed, and why
| Change | Why |
|---|---|
An Effect API at @techsavvyash/bus. Clanker’s classes are at @techsavvyash/bus/promise, and the conformance suite at @techsavvyash/bus/conformance | Dough’s libraries are Effect inside, with plain Promises at the edge for the gateway and worker. The suite imports node:test, so it gets its own entry point |
| Payload schemas are compiled to Effect Schema instead of ajv | Effect Schema replaces ajv in dough |
A schema that uses a keyword Effect can’t enforce is rejected at registration, for example if/then, not, contains and dependentRequired | ajv accepted these. Under Effect Schema they would be silently ignored, and the bus never fails silently |
A schema that uses format is rejected at registration. Use pattern instead | Clanker’s ajv had no format validators, so it ignored format, and Effect Schema ignores it too. A constraint that looks enforced but isn’t would let bad payloads through. None of clanker’s own schemas use format |
If onSubscriberError or onPublishError throws, the error is ignored | In clanker, a throwing reporter broke emit and the sink, despite their guarantees |
Schema error messages use Effect’s wording, for example event.data/ok: Expected boolean instead of ajv’s must be boolean | The path prefix is unchanged. Only the message text comes from the new validator |
Errors are Effect tagged errors with a _tag. Construct them with an object, such as new BusValidationError({ message }), and use DuplicateEventError.of(key, id) | Typed errors. instanceof, message, dedupeKey and existingEventId work as before |
A Promise store that rejects with anything else makes the bus fail with a StoreError carrying its message | One typed failure for storage |
A JSONL line is checked against the full event schema. A line with a mistyped optional field, such as a numeric subject, is now skipped | Clanker checked only id, type, source, time and data. Lines are Schema-decoded records in dough |
In the Effect API, matchesFilter doesn’t check the filter. Stores call validateFilter first. The facade’s matchesFilter still throws, as before | The Effect API returns typed failures instead of throwing |
Without a clock option, time comes from Effect’s Clock | TestClock works. Passing clock behaves as before |
The agent sink accepts any event with a type and a runId (AgentEventLike), not clanker’s AgentEvent union | Clanker’s runtime event types haven’t moved to dough yet. The default source is still "clanker-runtime" |
Not changed (yet)
- JSONL store limits: it still replays the whole file on every read, and the next append can land on a torn last line.
- Dedupe: the check-then-append for a
dedupeKeyisn’t atomic.
Both limits are marked in the code.