suite: async past_stamp_sleep for current-thread flavor readiness

Replace the harness's blocking std::thread::sleep with tokio::time::sleep
across all nine call sites, note the no-blocking-calls-inside-rows posture
in the helper's doc comment, and mark the task completed. Both engines'
contract suites re-run green with assertions and tolerances unchanged
(ADR-024 \u00a75 item 4).
This commit is contained in:
glm-5.3-flash committed 2026-10-10 11:11:09 +00:00
1 parent a48c12745a
commit 6f9cfb5778
2 files changed
+44 -18

No files matched your search

+17 -11
View File
@@ -569,7 +569,7 @@ pub async fn lock_ttl_expiry_and_reacquisition(factory: &dyn StoreFactory) {
// second-precision stamp's resolution): exclusion lapses silently
// — the second owner's acquire is a clean Ok(Some) with no error
// preceding it and no revocation event to observe.
past_stamp_sleep(2_500);
past_stamp_sleep(2_500).await;
let second = store
.try_lock("lapse", "b", 300)
.await
@@ -1680,8 +1680,14 @@ pub async fn payload_too_large_produced_on_pg(factory: &dyn StoreFactory) {
/// clock read `> T + 1`; 2.5 s guarantees it, 3.5 s the `expires: 2`
/// stamps). Timing posture: state outcomes are asserted, never
/// durations.
fn past_stamp_sleep(millis: u64) {
std::thread::sleep(std::time::Duration::from_millis(millis));
///
/// Harness posture: **no blocking calls inside suite rows** — this
/// helper is async (`tokio::time::sleep`) and every row awaits it;
/// the mem engine's suite column runs the current-thread flavor
/// ([ADR-024](../../docs/architecture/decisions/024-mem-engine.md)
/// §5), which is what catches a blocking stall here.
async fn past_stamp_sleep(millis: u64) {
tokio::time::sleep(std::time::Duration::from_millis(millis)).await;
}
/// **Job-handle validity predicate** — the uniform rule (processing
@@ -1785,7 +1791,7 @@ pub async fn job_handle_validity_predicate(factory: &dyn StoreFactory) {
"claims hand out in enqueue order (equal priority)"
);
let retry_before = lapsed_retry.job().clone();
past_stamp_sleep(2_500);
past_stamp_sleep(2_500).await;
assert!(
!lapsed_ack.heartbeat(600).await.unwrap(),
"late heartbeat must be refused: the deadline has lapsed"
@@ -1845,7 +1851,7 @@ pub async fn job_handle_validity_predicate(factory: &dyn StoreFactory) {
batch_live.heartbeat(600).await.unwrap(),
"the renewal keeps this id's claim live through the batch"
);
past_stamp_sleep(2_500);
past_stamp_sleep(2_500).await;
let counted = batch
.ack_batch(&[batch_live_id, batch_lapse_id, 987_654_321])
.await
@@ -1967,7 +1973,7 @@ pub async fn queue_depth_reclaim_and_dead_letter(factory: &dyn StoreFactory) {
.job()
.claim_expires_at
.expect("claim stamps the deadline");
past_stamp_sleep(2_500);
past_stamp_sleep(2_500).await;
let second = depth
.claim_one("w2")
@@ -2002,7 +2008,7 @@ pub async fn queue_depth_reclaim_and_dead_letter(factory: &dyn StoreFactory) {
.await
.unwrap();
depth.claim_one("w1").await.unwrap().unwrap();
past_stamp_sleep(2_500);
past_stamp_sleep(2_500).await;
let at_budget = depth.claim_one("w2").await.unwrap().unwrap();
assert_eq!(at_budget.job().id, exhausted);
assert_eq!(
@@ -2010,7 +2016,7 @@ pub async fn queue_depth_reclaim_and_dead_letter(factory: &dyn StoreFactory) {
at_budget.job().max_attempts,
"the reclaim spent the budget"
);
past_stamp_sleep(2_500);
past_stamp_sleep(2_500).await;
assert!(
depth.claim_one("w3").await.unwrap().is_none(),
"the budget-spent row dead-letters instead of reclaiming"
@@ -2139,7 +2145,7 @@ pub async fn sweep_no_stranded_rows(factory: &dyn StoreFactory) {
.enqueue(json!({"leg": "never-expiring"}), EnqueueOpts::default())
.await
.unwrap();
past_stamp_sleep(3_500);
past_stamp_sleep(3_500).await;
let moved = sweeping.sweep_expired().await.unwrap();
assert_eq!(
@@ -2195,7 +2201,7 @@ pub async fn sweep_no_stranded_rows(factory: &dyn StoreFactory) {
.unwrap();
let kept_dies = keeping.claim_one("w1").await.unwrap().unwrap();
assert!(kept_dies.fail(None).await.unwrap());
past_stamp_sleep(2_500);
past_stamp_sleep(2_500).await;
let deleted = retained.sweep_expired().await.unwrap();
assert_eq!(
@@ -2479,7 +2485,7 @@ pub async fn scheduler_bounded_catchup(factory: &dyn StoreFactory) {
// Several boundaries elapse (the first sits one interval past
// registration; a 4 s runner-less pause leaves at least three
// elapsed) — still nothing, no runner in sight.
past_stamp_sleep(4_000);
past_stamp_sleep(4_000).await;
collect_fires(store.as_ref(), "catchup", &mut fired).await;
assert!(
fired.is_empty(),