4.1 KiB
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 |
|
moderate | medium | component | implementation |
|
Description
The queue mechanism: the ADR-010 state machine realized over an in-memory job table — all driver-free.
Queuehandle surface (ADR-019 §1):enqueue(auto-commit, resolving over the handle's opts),claim_one/claim_batch(extents:n <= 0claims nothing),ack_batch(per-id uniform predicate, lapsed/non-claimed silently not counted),cancel(unconditional delete),get_job, and the queue-scopedsweep_expired(no-stranded-rows: every past-expiry row in any state moves to dead + retention enforcement).- Claim discipline: exactly-once handout,
worker_idclaimant 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/failone-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'sresolution.rsis 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, relativeexpires) are mem-owned (third copy); handle-enqueue stamps the handle's opts; the tx/no-handle shapes stamped plain 300/3/5/none inmem-engine-seam-tx.get_jobshows resolved values. - Dead letters: move-to-dead storage,
get_jobsees dead rows (last_error/died_at),dead_letter_retention_s(None = forever) enforced bysweep_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_expiredis caller-driven, cadence recipe unchanged).
Acceptance Criteria
- Full
Queue/JobHandlesurfaces 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-memclean; 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