Harden Guardian v2 hosted messaging tests (#63987)

## What changed

Wait for worker creation with its own timeout before waiting for MCP
delivery in the cached approval invalidation test. This gives a missing
worker a distinct failure from a delivery that never reaches the server.

Disable analytics in the Code Mode conversation history test so hosted
messaging only contacts the mock servers.

GitOrigin-RevId: 15887b9f37cc48b938fd67801a0dda9374027492
This commit is contained in:
Dylan Hurd
2026-11-25 22:38:31 +00:00
committed by copyberry
parent c6bbf8a413
commit 1c1e383a7b
2 changed files with 7 additions and 4 deletions
@@ -199,13 +199,14 @@ async fn confirmed_root_delivery_invalidates_root_and_worker_cached_approvals()
text_elements: Vec::new(),
}]))
.await?;
// The root has to spawn the worker before it can request message delivery.
let worker_id = tokio::time::timeout(ASYNC_TEST_TIMEOUT, created.recv())
.await
.map_err(|_| anyhow::anyhow!("worker thread was not created"))??;
let worker = test.thread_manager.get_thread(worker_id).await?;
tokio::time::timeout(ASYNC_TEST_TIMEOUT, pending_delivery.notified())
.await
.map_err(|_| anyhow::anyhow!("messaging delivery did not reach the MCP server"))?;
let worker = test
.thread_manager
.get_thread(created.recv().await?)
.await?;
let mut config = test.config.clone();
config.features.enable(Feature::GuardianV2)?;
let session_store = ExtensionData::new("worker-cache-session");
@@ -1135,6 +1135,8 @@ async fn sample_configured_conversation_history_with_delivery(
config.approvals_reviewer = ApprovalsReviewer::AutoReview;
config.guardian_policy_config = Some("Policy from the live thread.".to_owned());
if code_mode {
// Hosted messaging should only contact the mock servers.
config.analytics_enabled = Some(false);
for feature in [
Feature::Apps,
Feature::CodeMode,