--- id: suite-harness-current-thread name: Contract-suite harness — async sleep in `past_stamp_sleep`, current-thread flavor readiness status: completed depends_on: [] scope: narrow risk: low impact: component level: implementation tags: [wave-6, contract-suite] --- ## Description The one suite-side change wave 6 carries ([ADR-024](../architecture/decisions/024-mem-engine.md) §5 item 4; the review-003 posture note at `properties.rs:1683`): the suite's `past_stamp_sleep` helper uses a blocking `std::thread::sleep` inside async rows — safe under the multi-thread test flavors both existing engines' targets use, but it would stall a current-thread runtime. The mem engine's suite column **must** run under a current-thread flavor (`#[tokio::test(flavor = "current_thread")]`) to keep the mem engine's internals honestly current-thread-clean — which is what wasm32 needs. - Replace `past_stamp_sleep`'s blocking sleep with `tokio::time::sleep` (async). The helper's semantics are unchanged (a bounded pre-`run_at` settle before reads); the existing rows' determinism posture is untouched — verify the two legs using it re-run green on both engines with no timing drift (tolerances unchanged). - Document (one line in the helper's doc comment or the factory contract notes) the harness posture: **no blocking calls inside suite rows** — the mem column enforces the flavor that catches violations. This task is engine-independent and can run any time before `mem-engine-integration` wires the third column. ## Acceptance Criteria - [x] `past_stamp_sleep` is async (`tokio::time::sleep`) - [x] Both engines' existing suites re-run green with identical assertions and tolerances (determinism posture intact) - [x] The no-blocking-calls posture noted where the harness's determinism posture is documented - [x] Clippy `-D warnings`, fmt clean; workspace gates green ## References - docs/architecture/decisions/024-mem-engine.md §5 - docs/reviews/003-wave-5-general-review.md §Finding 5 (the `properties.rs:1683` posture note) - docs/architecture/decisions/022-contract-suite-layout.md (the factory contract the flavor rides) ## Notes - The posture note went into `past_stamp_sleep`'s doc comment rather than the factory contract notes: the posture is a harness rule about row internals (what a row may call), not part of the `StoreFactory` shape, and the doc comment sits exactly where a row author reaches for a sleep. The comment cites ADR-024 §5 for the current-thread flavor that enforces it. - Five rows exercise the helper across its two use shapes (the lapse-settle legs and the scheduler runner-less-pause leg): `lock_ttl_expiry_and_reacquisition`, `job_handle_validity_predicate`, `queue_depth_reclaim_and_dead_letter`, `sweep_no_stranded_rows`, `scheduler_bounded_catchup`. All nine call sites gained `.await`; assertions and tolerances untouched. ## Summary `past_stamp_sleep` now awaits `tokio::time::sleep` instead of blocking on `std::thread::sleep` (alkstore-contract-suite/src/properties.rs), making every suite row current-thread-safe for the mem engine's `#[tokio::test(flavor = "current_thread")]` column (ADR-024 §5 item 4); the doc comment records the no-blocking-calls-inside-rows posture. Both engines' `contract_suite` re-ran fully green (25/25 each, SQLite 15.0 s / Postgres 21.3 s — no timing drift, tolerances unchanged); the full workspace build, tests, `clippy -D warnings`, and `fmt --check` pass. PostgreSQL leg ran against the POC container (`pglo-poc`, port 15432, creds per docs/reviews/003 §env note).