Files
alkstore/tasks/mem-engine-queues.md
T
glm-5.3-flash 5abd351c86 Wave-6 decomposition (mem engine): eleven tasks per the pg-wave rhythm — foundations (crate scaffold, MemStore::new isolation, guarded state core, wake routing, wasm32 gate from birth), seam-tx (the load-bearing tx overlay: eleven staged _tx methods, commit-merge + wake-at-commit — pg-fix-tx-wake's discipline structural from the start, drop = discard trivial, with_tx panic posture), mechanisms mutually parallel (notify-listen close-at-engine-drop/no-replay/never-coalesced; queues = ADR-010 machine driver-free with the equal-jitter curve and opts resolution as ADR-012 §2's third owner; streams log+offsets+trim; locks TTL registry, no busy-path analog), scheduler-outbox (tick/catch-up-64/leadership through the __alkstore_scheduler lock, engine-uniform per ADR-009 §4; outbox over queues with the 60/5/5 seam stamp), integration (suite third StoreFactory column green on host under a current-thread flavor, wasm32 acceptance items, engine-mem.md to implementation-complete), and the review-wave-6 gate (born-pinned audit: conformance read, discharge-map wiring, wasm items, three-way equivalence green, class-1 window discipline). Window riders: suite-harness-current-thread — the wave's one suite-side pre-task, past_stamp_sleep's blocking sleep goes async per review 003's properties.rs:1683 posture note, enabling the current-thread flavor; pg-fix-scheduler-tick-seam — review 003 Finding 1, the cfg(test) transient-fault seam driving the real tick_with_retries through retry-then-success and exhaustion arms (the last uncovered wave-4 hardening arm, sqlite-commit-error-arm pattern). Task hygiene: pg-fix-open-path frontmatter fixed (unquoted 'max_size: 0' colon-space inside the name scalar broke YAML parsing — taskgraph validate had been red one-error since the wave-4 fix-batch decomposition; also restores review-wave-4-fixes' dependency resolution). implementation.md: wave-6 table row → decomposed, task-set listing with the parallelism note (rider + pre-task independent of the mem chain; rider closes before the gate), wave-6 decomposition bullet in the review-rounds record. Docs-only change; verified taskgraph validate (60 tasks, no cycles), cargo fmt --check, cross-reference read
2026-10-10 09:57:01 +00:00

4.1 KiB

id, name, status, depends_on, scope, risk, impact, level, tags
id name status depends_on scope risk impact level tags
mem-engine-queues Mem engine — queues (in-memory job table, ADR-010 state machine, engine-owned backoff curve) pending
mem-engine-seam-tx
mem-engine-notify-listen
moderate medium component implementation
wave-6
mem-engine
queues

Description

The queue mechanism: the ADR-010 state machine realized over an in-memory job table — all driver-free.

  • Queue handle surface (ADR-019 §1): enqueue (auto-commit, resolving over the handle's opts), claim_one/claim_batch (extents: n <= 0 claims nothing), ack_batch (per-id uniform predicate, lapsed/non-claimed silently not counted), cancel (unconditional delete), get_job, and the queue-scoped sweep_expired (no-stranded-rows: every past-expiry row in any state moves to dead + retention enforcement).
  • Claim discipline: exactly-once handout, worker_id claimant identity (non-empty), claim ordering priority DESC → ready-time → enqueue FIFO. Visibility expiry and reclaim — reclaim consumes an attempt; the dual-execution window is contract-honest (a worker past its deadline may complete its work but its ack will not land). Under a single engine instance the claim race is in-process — the guarded merge discipline must still make claim-vs-claim atomic and claim-vs-expiry deterministic at the row level.
  • JobHandle ops (ADR-019 §3): ack/retry/fail one-shot terminal, heartbeat(&self) repeatable absolute-reset renewal; the uniform validity predicate (processing + unexpired deadline); deadline lapse refuses all ops, false not error. retry(err, None) computes the queue's equal-jitter exponential delay — mem's own implementation (ADR-012 §2's one-owner rule, third owner; the SQLite engine's resolution.rs is reference, not a dependency); retry(err, Some(d)) overrides verbatim; fail = immediate dead-letter with the engine-default strings ("failed" / "max attempts exceeded").
  • Opts stamping (ADR-020): resolution rules (delay-over-run_at, relative expires) are mem-owned (third copy); handle-enqueue stamps the handle's opts; the tx/no-handle shapes stamped plain 300/3/5/none in mem-engine-seam-tx. get_job shows resolved values.
  • Dead letters: move-to-dead storage, get_job sees dead rows (last_error/died_at), dead_letter_retention_s (None = forever) enforced by sweep_expired. No redrive API.
  • Timestamps and expiry checks are tokio-time/clock reads against the state core's clock accessor; expiry is checked at claim/renew boundaries (no ambient sweeper — sweep_expired is caller-driven, cadence recipe unchanged).

Acceptance Criteria

  • Full Queue/JobHandle surfaces over the in-memory job table
  • The ADR-010 state machine properties unit-pinned: visibility reclaim consumes an attempt, dead-letter moves, no-stranded-rows sweep, handle-op validity predicate, late-heartbeat boundary
  • Equal-jitter curve + opts resolution pinned to the identical numeric behavior the suite's equivalence rows assert (per the engine-side pin posture used for the cap legs)
  • Numeric-domain guards (extents) at entry — pinned
  • cargo check --target wasm32-unknown-unknown -p alkstore-mem clean; workspace gates green

References

  • docs/architecture/queues.md; core-contract.md §queues
  • docs/architecture/decisions/010-queue-semantics-depth.md; 019-mechanism-handle-surfaces.md §1/§3; 020 §1–§3; 023 §2
  • docs/architecture/engine-mem.md §Mapping the contract (queues row)
  • tasks/pg-engine-queues.md (the structural twin's task of record — the wave-4 rhythm and the resolution rule set)

Notes

To be filled by implementation agent

Summary

To be filled on completion