mem-engine-seam-tx — the wave's load-bearing seam lands: the complete Store/TxHandle trait surfaces over the guarded state core, with the tx overlay as the discipline centerpiece. Wider than the sqlite/pg seam twins by design (those rode pre-ported substrate ops and left mechanism methods stubbed; mem has no substrate, and the task's acceptance pins the full trait surfaces implemented over guarded state — a Rust trait impl is all-or-nothing per method): the seam task therefore realizes the mechanisms' committed-state effect layer and every mechanism handle itself, and the wave-6 mechanism tasks now own their acceptance-criteria unit pins against this foundation. Store surface: notify (codec-typed encode as the entry check only — the wake delivers the channel alone; PayloadTooLarge never produced, the ADR-016 §5 non-occurrence arm pinned at 2 MiB), listen (WakeReceiver bridge with the pinned recv forms; attach starts from now, one close path at engine drop), stream/queue/outbox/try_lock (validated constructors → boxed core-owned handle traits: the ADR-010 queue state machine with claims/reclaim-eats-attempt/uniform validity predicate/dead-letter/sweep + mem's third-owner equal-jitter curve — std-only RandomState hash jitter, no rand; ADR-015 log+offsets+trim+wake-driven subscribe; ADR-008 §7 TTL registry with renew-past-expiry refused; ADR-014 outbox helper with run_once ack/retry), schedule/unschedule/run_schedules (ADR-009 collapse: @every-only third-owner parser + register-table with pre-parsed interval and resolved stamps; the 64-cap bounded catch-up + grid-aligned skip-forward tick fired-and-advanced under one guarded op (schedules→queues lock order); leadership through the reserved __alkstore_scheduler lock with runner-unique owner, renew-before-tick, keep-awake sleep renewing on cadence, LeadershipLost / clean-stop-Ok returns). Tx overlay: begin_tx allocates the handle-private overlay; all eleven *_tx stage with entry-point validation before any effect, Codec-typed encode, one clock read, ADR-020 §3 stamp resolution (plain 300/3/5/none, outbox 60/5/5, the per-job max_attempts override via resolution.rs's stamps_with_override); tx reads merge overlay over committed (read-your-own-writes: queue-scoped + dead-visible get_job_tx, monotone staged saves, offset-ASC merged reads, extent guards clamping empty); commit consumes the handle, merges under one guarded op (queues→streams, the canonical lock order documented in state.rs), and fires the overlay's pending wakes AFTER the merge — wake-at-commit structural from birth (the pg-fix-tx-wake failure shape cannot exist here); drop (explicit, or through an unwinding panic — the overlay is plain local data, nothing runs on discard) = rollback with no ghosts, trivially. Stage-time id/offset allocation (the pg-shaped story — rolled-back allocations gap out; claims order id ASC, offsets immutable/never renumbered). Stream subscribers ride a reserved-prefix engine-internal wake channel (__alkstore_stream_wake:{stream}) unreachable by consumer entry points, attached before the stored-offset read; notify's transport stores nothing. 89 mem unit tests: the overlay discipline rows the task pins, the numeric-domain rows (extents/durations/boundaries/grammar/validation), and the mechanism smoke pins (the defect-class catch: ack/ack_batch originally deleted before checking the predicate — fixed; a refusal must leave the row exactly as it was). Manifest: serde_json = 1 joins (the trait signatures cross Value; both engine twins carry it; not a driver dep — wasm32 gate stays green). Task file: status completed, Notes (the whole-engine scope disposition + 11 decision-of-record entries incl. lock-renewal delta vs the sqlite substrate, ScheduleRow shape, runner lease mechanics, substrate predicate parity) + Summary filled. Verified: cargo build; workspace cargo test green (core 25, suite harness 3, mem 89, SQLite 191 lib + 25 suite, pg 124 lib + 25 suite + 9 schema); clippy --all-targets -D warnings clean; cargo fmt --check clean; cargo check --target wasm32-unknown-unknown -p alkstore-mem clean

This commit is contained in:
glm-5.3-flash committed 2026-10-10 11:55:39 +00:00
1 parent 6632dcce1f
commit 1c3e96802f
14 files changed
+5375 -70

No files matched your search

+15 -13
View File
@@ -10,7 +10,7 @@
//! The dependency on `alkstore-mem` *is* the ephemerality declaration;
//! compile-time engine identity (this crate) carries the honesty —
//! no runtime surface is fabricated to detect it. Each
//! `MemStore::new` yields a fully isolated instance sharing nothing;
//! [`MemStore::new`] yields a fully isolated instance sharing nothing;
//! teardown is drop, and engine drop closes open receivers.
//!
//! **Full contract v1** (ADR-024 §3): every mechanism, every guarantee
@@ -19,7 +19,7 @@
//! pinned: the contract suite's third `StoreFactory` column (ADR-022)
//! runs this engine under a current-thread runtime flavor.
//!
//! **wasm32** ([ADR-024] §5): this crate compiles clean for
//! **wasm32** (ADR-024 §5): this crate compiles clean for
//! `wasm32-unknown-unknown` — tokio restricted to the wasm-supported
//! subset (sync + time), no driver dependencies, no `spawn_blocking`
//! anywhere; internals are current-thread-runtime-clean by
@@ -31,21 +31,23 @@
//! The store instance *is* the state: guarded per-mechanism sections
//! (`crate::state`) behind short-held synchronous internal locks,
//! tokio primitives for cross-await coordination. The tx seam is an
//! overlay (stage → commit-merge → wake-at-commit; drop = discard);
//! wakes route through in-process channels (`crate::wakes`) —
//! delivered at the commit boundary directly to each open receiver,
//! per-subscriber FIFO by commit order, never coalesced (no batching
//! boundary exists).
//!
//! Wave 6 is under construction (ADR-024): the foundations —
//! `MemStore::new`, the guarded state core, the wake-routing
//! substrate, the clock accessor, entry-point validation — are laid;
//! the `Store`/`TxHandle` trait surfaces and the mechanism handles
//! land with the wave's seam and mechanism tasks.
//! overlay ([`crate::tx`] — stage in the handle-private overlay, commit
//! merges atomically + wakes at commit, drop discards); wakes route
//! through in-process channels (`crate::wakes`) — delivered at the
//! commit boundary directly to each open receiver, per-subscriber FIFO
//! by commit order, never coalesced (no batching boundary exists).
mod clock;
mod lock;
mod notify;
mod outbox;
mod queue;
mod resolution;
mod scheduler;
mod state;
mod store;
mod stream;
mod tx;
mod validation;
mod wakes;