3.5 KiB
3.5 KiB
id, name, status, depends_on, scope, risk, impact, level, tags
| id | name | status | depends_on | scope | risk | impact | level | tags | |||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| mem-engine-streams | Mem engine — streams (in-memory log, per-consumer offsets, trim) | pending |
|
moderate | medium | component | implementation |
|
Description
The streams mechanism over an in-memory event log + per-consumer offset table (engine-mem.md §Mapping the contract, streams row):
StreamHandlesurface (ADR-019 §2):publish/publish_with_key(present key must be non-empty →InvalidName),read_since/read_from_consumer(cursor reads,offset ASC, extents clamp empty per ADR-023 §2),save_offset/get_offset(monotone saves — below-checkpoint saves are silent no-ops,Errarm carriesDatabaseonly),trim_to(deleteoffset <= horizon, exact-boundary, returns deleted count, negative horizon deletes nothing idempotently, wakes nothing, surviving rows keep offsets, never renumbered), andsubscribe(durable consumption: attach, read to tail, resume from saved offset; wake-driven with re-read — the wake substrate delivers at commit; explicit saves only, no auto-checkpoint).- Ordering: engine-assigned monotonically increasing per-stream offsets, global FIFO by offset — the ADR-015 ordering row, mem's own counter (per-stream; absolute values need not equal the SQL engines' — the equivalence rows pin relative order).
StreamEventshape exactly as pinned (ADR-015 §3):{ offset, stream, key, payload, created_at }—created_atis unix-seconds at publish, informational, from the clock accessor. Reads from a trimmed-away region resume at the horizon's first remaining row.- Keyed publish rides the tx overlay (staged
publish_with_key_txlanded inmem-engine-seam-tx); this task's non-tx forms, receiver, and trim live here. - Receiver close arms (ADR-021
§5):
recv()'sErrcarriesDatabaseonly (payloads cross raw;Codecatpayload_as<T>); close is terminal — the one close path is engine drop (the notify-listen task's close arm, realized identically); no reconnection concept (the pg stays-open-across- reconnect row is absent from mem's column).
Acceptance Criteria
- Full
StreamHandlesurface over the in-memory log + per-consumer offsets - The ADR-015 properties unit-pinned: global FIFO, immutable never-renumbered offsets (gaps legal post-trim), exact-boundary trim semantics (reads resume at horizon; saved sub-horizon offsets stay valid; trim wakes nothing), monotone save composition (direct + receiver forms interleave)
- Key round-trips exactly (
NonevsSome); empty-Some-key rejected at every entry point - Extent/offset numeric-domain guards at entry — pinned
cargo check --target wasm32-unknown-unknown -p alkstore-memclean; workspace gates green
References
- docs/architecture/core-contract.md §streams
- docs/architecture/decisions/015-streams-depth.md; 019-mechanism-handle-surfaces.md §2/§6; 021 §5; 023 §2
- docs/architecture/engine-mem.md §Mapping the contract (streams row)
- tasks/pg-engine-streams.md (the structural twin's task of record)
Notes
To be filled by implementation agent
Summary
To be filled on completion