Backend core: workspace, plugin trait, action pipeline, journal, live websocket #4

Closed
opened 2026-10-13 15:01:12 +00:00 by kayg · 2 comments
Owner

Lay the backend foundation everything else plugs into.

  • Cargo workspace + bun workspace monorepo (ADR 0009). Small crates, build budget (ADR 0008).
  • calternal binary: axum server, embedded static SPA placeholder, /healthz, startup that never waits (ADR 0016).
  • Plugin trait (ADR 0010): a plugin registers actions, journal event kinds, routes and search providers. Plugins never touch each other's tables.
  • Action pipeline (ADR 0011): typed actions, one executor, idempotency keys, per-user change journal with sync tokens.
  • One multiplexed websocket per client streaming journal events (ADR 0012).
  • Per-user locks only, never held across I/O, yielding background batches, plus the "A's huge job never slows B" test (ADR 0014).
  • Typed errors from a message catalogue (ADR 0033).

Done when: tests green, cargo check incremental under budget, a demo action round-trips HTTP → journal → websocket.

Lay the backend foundation everything else plugs into. - Cargo workspace + bun workspace monorepo (ADR 0009). Small crates, build budget (ADR 0008). - `calternal` binary: axum server, embedded static SPA placeholder, `/healthz`, startup that never waits (ADR 0016). - Plugin trait (ADR 0010): a plugin registers actions, journal event kinds, routes and search providers. Plugins never touch each other's tables. - Action pipeline (ADR 0011): typed actions, one executor, idempotency keys, per-user change journal with sync tokens. - One multiplexed websocket per client streaming journal events (ADR 0012). - Per-user locks only, never held across I/O, yielding background batches, plus the "A's huge job never slows B" test (ADR 0014). - Typed errors from a message catalogue (ADR 0033). Done when: tests green, `cargo check` incremental under budget, a demo action round-trips HTTP → journal → websocket.
Author
Owner

Progress: core, store and engine crates are in and green.

  • calternal-core: typed actions, plugin trait + registry (namespace enforced), error catalogue, sync tokens, yielding batch helper.
  • calternal-store: per-user index.db (WAL, NORMAL), one writer thread per user, live broadcast sent from the writer in commit order.
  • calternal-engine: one executor with idempotency keys (in-flight joining + stored replay). Actions run as their own task, so a dropped connection never stops one halfway.

ADR 0014 test, during a 200k-event job for user A: user B p50 0.48 ms / max 0.63 ms, user A's own actions p50 0.58 ms / max 1.3 ms.

Next: axum server (HTTP + one websocket), /healthz, demo plugin, binary, CI.

Progress: core, store and engine crates are in and green. - `calternal-core`: typed actions, plugin trait + registry (namespace enforced), error catalogue, sync tokens, yielding batch helper. - `calternal-store`: per-user `index.db` (WAL, NORMAL), one writer thread per user, live broadcast sent from the writer in commit order. - `calternal-engine`: one executor with idempotency keys (in-flight joining + stored replay). Actions run as their own task, so a dropped connection never stops one halfway. ADR 0014 test, during a 200k-event job for user A: user B p50 0.48 ms / max 0.63 ms, user A's own actions p50 0.58 ms / max 1.3 ms. Next: axum server (HTTP + one websocket), `/healthz`, demo plugin, binary, CI.
Author
Owner

PR open for review: #16 (not merged).

Server, websocket, demo plugin, binary and CI are in. 31 tests green. The real binary answers /healthz 5 ms after spawn. Reconnecting from a sync token replays all 2500 missed entries once, in order.

One bug found and fixed on the way: the store capped reads at the same 1000 the engine used for pages, so "is there more?" never fired and catch-up stopped at 1000 entries. Now the engine owns the page size (1000), and the store only has a 10k safety cap.

PR open for review: https://git.kayg.org/kayg/calternal/pulls/16 (not merged). Server, websocket, demo plugin, binary and CI are in. 31 tests green. The real binary answers `/healthz` 5 ms after spawn. Reconnecting from a sync token replays all 2500 missed entries once, in order. One bug found and fixed on the way: the store capped reads at the same 1000 the engine used for pages, so "is there more?" never fired and catch-up stopped at 1000 entries. Now the engine owns the page size (1000), and the store only has a 10k safety cap.
kayg closed this issue 2026-10-13 15:19:12 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
kayg/calternal#4
No description provided.