From 0e42ea48580d31171a38efaea7b101774aa658a8 Mon Sep 17 00:00:00 2001 From: ScriptedAlchemy Date: Sun, 20 Sep 2026 17:22:22 +0000 Subject: [PATCH] test(mcp): take the first settled search before pinning freshness search_returns_the_named_symbol_and_rejects_a_missing_query warmed the index and then pinned the next search's freshness to fresh. The warm-up proves the generation is current and every lane complete, but the seat can still have a continuation pass in flight, and a search taken while it runs reports verifying. The distribution acceptance battery saw that once in 517 tests. The test now takes the first search that reports the settled state before pinning the literal payload. Co-Authored-By: Claude Fable 5.1 --- .../mcp_handler_test/search_behavior_test.rs | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/crates/tracedecay/tests/mcp_suite/mcp_handler_test/search_behavior_test.rs b/crates/tracedecay/tests/mcp_suite/mcp_handler_test/search_behavior_test.rs index ff0e97ab13..81cbd036f6 100644 --- a/crates/tracedecay/tests/mcp_suite/mcp_handler_test/search_behavior_test.rs +++ b/crates/tracedecay/tests/mcp_suite/mcp_handler_test/search_behavior_test.rs @@ -59,17 +59,28 @@ async fn search_returns_the_named_symbol_and_rejects_a_missing_query() { warm_code_index_search(&server, "ledger_post_entry").await; - let hit = handle_real_server_tool_call( - &server, - "tracedecay_search", - json!({ - "query": "ledger_post_entry", - "prefer_symbol": true, - "format": "json", - }), - ) - .await; - let hit: Value = serde_json::from_str(extract_real_server_text(&hit)).expect("search JSON"); + // The warm-up proves the generation is current and every lane complete. + // The seat can still have a continuation pass in flight after that, and + // a search taken while it runs reports `verifying`. The literal payload + // below is the settled one, so take the first search that reports it. + let mut hit = Value::Null; + for _ in 0..40 { + let response = handle_real_server_tool_call( + &server, + "tracedecay_search", + json!({ + "query": "ledger_post_entry", + "prefer_symbol": true, + "format": "json", + }), + ) + .await; + hit = serde_json::from_str(extract_real_server_text(&response)).expect("search JSON"); + if hit["freshness"] == json!({ "state": "fresh" }) { + break; + } + tokio::time::sleep(std::time::Duration::from_millis(250)).await; + } assert_eq!(hit["freshness"], json!({ "state": "fresh" }), "{hit}"); assert_eq!( hit["coverage"],