From e7102f0fbafa644b34c237cd3c06c3dd0cd0d8f3 Mon Sep 17 00:00:00 2001 From: John Morrissey <544926+tachyon-beep@users.noreply.github.com> Date: Wed, 1 Jul 2026 16:30:44 +1000 Subject: [PATCH] test(mcp): pin clock in summary_available tests (fix 2026-07-01 time-bomb) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit orientation_pack_dossier_summary_available_{true_when_cached,false_on_stale_cache_key} seeded a summary-cache row at created_at 2026-01-01 but ran orientation_pack under the real wall clock. summary_available is true only when the cached row is within the 180-day cache horizon (summary_cache_expired), so on 2026-07-01 (181 days later) the true-case flipped to false and the test began failing on main despite unchanged code. The false-case still passed but for the wrong reason (incidental expiry masking the model_tier key-mismatch it means to test). Both tests now inject a fixed clock (2026-01-02, one day after the seed) via ServerState::with_clock — the same pattern state_for_summary already uses — so freshness is deterministic and the tests isolate what they actually assert (key match / key mismatch). No production-code change. Co-Authored-By: Claude Opus 4.8 (1M context) --- crates/loomweave-mcp/tests/storage_tools.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/crates/loomweave-mcp/tests/storage_tools.rs b/crates/loomweave-mcp/tests/storage_tools.rs index a40f46a..ad3a309 100644 --- a/crates/loomweave-mcp/tests/storage_tools.rs +++ b/crates/loomweave-mcp/tests/storage_tools.rs @@ -6854,7 +6854,13 @@ async fn orientation_pack_dossier_summary_available_true_when_cached() { ) .expect("upsert summary cache"); - let state = state_for(project.path(), &db_path); + // Pin the clock just after the seeded created_at so the cache is + // unambiguously fresh: with the real wall clock, the 2026-01-01 row ages + // past the 180-day summary-cache horizon and summary_available flips to + // false (a time-bomb that fires on 2026-07-01). This test is about the + // key MATCH, not freshness, so freeze time to isolate that. + let state = + state_for(project.path(), &db_path).with_clock(|| "2026-01-02T00:00:00Z".to_owned()); let out = call_tool( &state, "orientation_pack", @@ -6902,7 +6908,12 @@ async fn orientation_pack_dossier_summary_available_false_on_stale_cache_key() { ) .expect("upsert summary cache"); - let state = state_for(project.path(), &db_path); + // Pin the clock just after the seeded created_at so freshness is NOT a + // factor: the row must read as false purely because the model_tier key + // mismatches, not because the 2026-01-01 row aged past the cache horizon + // under the real wall clock (which would make it false for the wrong reason). + let state = + state_for(project.path(), &db_path).with_clock(|| "2026-01-02T00:00:00Z".to_owned()); let out = call_tool( &state, "orientation_pack",