Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(e2e): correct two assertions and drop one the revert-check proved vacuous\n\nRevert-checking found three things, and in two of them the code was right and my\ntest was wrong.\n\n- **#5772 `TimedOut` is not reachable here.** A probe with a `Duration::ZERO`\n window still returned `Alive { elapsed: 42.708µs }`: `tokio::time::timeout`\n polls the inner future before it checks the deadline, and `list_tools` on an\n established stdio connection answers inside that first poll. Producing a real\n timeout needs a stub that stalls on a named method, which `test-mcp-stub`\n cannot be asked for. The assertion is dropped rather than contrived; the test\n keeps the `Missing` half, which is reachable and which the old `bool` API\n could equally not express.\n\n- **#5810 `observed_samples` is 3, not 2.** The allowed dispatch in the same\n test completes, and `run_subagent` folds a real child's wall-clock into the\n estimator on its success path. That the runner measures its own children is\n the mechanism gate 2 rests on, so counting it is the assertion.\n\n- **#5852's pruning test is removed as vacuous.** Deleting `self.remove(task_id)?`\n from `DetachedTaskRegistry::wait` did not make it fail — the run rebuilt\n (1m27s) and still passed, so the entry is pruned by some path other than the\n one `ops.rs:20-23` documents. It asserted something true without being able to\n distinguish the documented mechanism from whatever actually does the work,\n which is not a test that would catch the regression it was written for.\n\nRemaining five, each revert-checked: both #5810 dispatch refusals (gate removed\n-> both fail), #5772 `Missing` (Missing -> Broken -> fails naming the assertion),\n#5772's 8s window (8s -> 30s -> fails naming the message), and #5839's\n`memory_diff` removal.\n

M3gA-Mind34d26e52efa9
diff --git a/tests/mcp_registry_e2e.rs b/tests/mcp_registry_e2e.rs
index c5f35467ad..7a379ba982 100644
--- a/tests/mcp_registry_e2e.rs
+++ b/tests/mcp_registry_e2e.rs
@@ -758,14 +758,16 @@ async fn per_config_lookups_see_a_per_config_connection() {
// ── Probe outcomes (#5772) ────────────────────────────────────────────────────
-/// `probe_alive` returns a four-variant `ProbeOutcome`, and the distinction the
-/// enum exists to carry is `TimedOut` vs `Broken`: a slow server is not a failed
-/// one, and collapsing the two is what made the supervisor tear down working
-/// sessions and then report a drop that never happened (#5636).
+/// `probe_alive` returns a four-variant `ProbeOutcome` instead of a bool, and
+/// `probe_alive_reflects_transport_liveness` above only ever asks
+/// `.is_alive()` — which is `false` for `Missing`, `Broken` and `TimedOut`
+/// alike, so nothing pinned which one comes back.
///
-/// `probe_alive_reflects_transport_liveness` above only ever asks `.is_alive()`,
-/// which is `false` for all three non-alive variants alike, so nothing pinned
-/// which one comes back. This does.
+/// This pins the two that are reachable in a hermetic test: an entry that was
+/// never connected, and one that has been disconnected, must both report
+/// `Missing` — "there was nothing to probe" — rather than a transport failure
+/// nobody observed. That distinction is what the old bool could not express and
+/// is the half of #5636 this harness can actually demonstrate.
#[tokio::test]
async fn probe_alive_distinguishes_a_missing_entry_from_a_timed_out_one() {
let (_tmp, cfg) = fresh_workspace_config();
@@ -804,43 +806,15 @@ async fn probe_alive_distinguishes_a_missing_entry_from_a_timed_out_one() {
other => panic!("a live stub must probe Alive, got {other:?}"),
}
- // The same live, healthy connection probed with a window it cannot meet.
- // `Duration::ZERO` is deterministic rather than racy: an async stdio round
- // trip cannot complete on the first poll, and tokio's zero-length sleep is
- // already elapsed, so the timeout arm is taken every time.
- //
- // This is the assertion that matters: the server is demonstrably fine — it
- // answered a moment ago and answers again below — so anything other than
- // `TimedOut` would be the supervisor asserting a drop it did not observe.
- match h
- .dynamic()
- .connections()
- .probe_alive(&server.server_id, std::time::Duration::ZERO)
- .await
- {
- tinymcp::ProbeOutcome::TimedOut { after } => {
- assert_eq!(
- after,
- std::time::Duration::ZERO,
- "the window is reported back"
- );
- }
- other => panic!(
- "a healthy server probed with an unmeetable window must report TimedOut, not a \
- failure it did not observe; got {other:?}"
- ),
- }
-
- // Still alive: the impossible window did not disturb the session, which is
- // the whole point of not treating a timeout as a break.
- assert!(
- h.dynamic()
- .connections()
- .probe_alive(&server.server_id, std::time::Duration::from_secs(8))
- .await
- .is_alive(),
- "a timed-out probe must leave the connection usable"
- );
+ // NOT asserted here: `TimedOut`. It is the variant this enum most exists
+ // for, and it is unreachable against this stub — a probe with a
+ // `Duration::ZERO` window still came back `Alive { elapsed: 42.708µs }`,
+ // because `tokio::time::timeout` polls the inner future before it checks
+ // the deadline and `list_tools` on an established connection answers inside
+ // that first poll. Producing a real timeout needs a server that stalls on
+ // `tools/list`, which `test-mcp-stub` cannot be asked to do. Asserting it
+ // by contriving the window would have pinned nothing; see
+ // ~/tinyhuman/bugs/W6-test-findings.md.
// Disconnecting removes the entry, so the outcome goes back to Missing
// rather than to a transport error.
diff --git a/tests/raw_coverage/agent_harness_leftovers_raw_coverage_e2e.rs b/tests/raw_coverage/agent_harness_leftovers_raw_coverage_e2e.rs
index 2ba4965f15..e0a0dcb937 100644
--- a/tests/raw_coverage/agent_harness_leftovers_raw_coverage_e2e.rs
+++ b/tests/raw_coverage/agent_harness_leftovers_raw_coverage_e2e.rs
@@ -870,9 +870,14 @@ async fn dispatch_is_refused_when_less_budget_remains_than_the_slowest_child() -
remaining_ms < observed_max_ms,
"refused with {remaining_ms} ms remaining against a {observed_max_ms} ms maximum"
);
+ // Three, not the two recorded by hand: the ALLOWED dispatch above
+ // completed, and `run_subagent` folds a real child's wall-clock
+ // into the estimator on its own success path. That the runner
+ // measures its own children is the whole mechanism gate 2 rests
+ // on, so counting it here is the assertion, not an off-by-one.
assert_eq!(
- observed_samples, 2,
- "both completed children must have fed the estimator"
+ observed_samples, 3,
+ "the two hand-recorded samples plus the real completed dispatch"
);
}
other => panic!(
@@ -888,98 +893,3 @@ async fn dispatch_is_refused_when_less_budget_remains_than_the_slowest_child() -
);
Ok(())
}
-
-// ── Orchestration registry pruning (#5852) ────────────────────────────────────
-
-/// `wait_agents` prunes a child once it observes a terminal status, so a child
-/// can be waited on exactly once (#5852).
-///
-/// This is the one *semantic* change in a PR that otherwise claimed to be a
-/// pure deletion: `AgentOrchestrationSession` moved off its own process-local
-/// `SessionState` onto the crate's `DetachedTaskRegistry`, whose `wait` prunes.
-/// The PR records it as an accepted behaviour change and `ops.rs:20-23` states
-/// it in the module docs, but nothing anywhere asserted it — so the contract
-/// existed only in prose, and a future registry swap could quietly restore the
-/// old "wait as often as you like" behaviour with every test still green.
-///
-/// Both halves are in one test on purpose: the first wait must succeed and
-/// report a terminal child (otherwise the second wait's failure proves nothing
-/// beyond "spawn is broken"), and only then must the second wait miss.
-#[tokio::test]
-async fn waiting_twice_on_one_orchestration_child_misses_the_pruned_entry() -> Result<()> {
- use openhuman_core::openhuman::agent::harness::definition::AgentDefinitionRegistry;
- use openhuman_core::openhuman::agent::orchestration::{
- AgentOrchestrationSession, OrchestrationError, OrchestrationTaskStatus, SpawnAgentRequest,
- WaitAgentOptions,
- };
-
- // Idempotent: other cases in this binary initialise it too.
- let _ = AgentDefinitionRegistry::init_global_builtins();
-
- let tmp = TempDir::new()?;
- let provider = ScriptedModel::new(vec![text_response("child finished its work")]);
- let parent = parent_context(tmp.path().to_path_buf(), provider);
- let session = AgentOrchestrationSession::new("w6-prune-session");
-
- let orchestration_id = with_parent_context(parent, async {
- session
- .spawn_agent(SpawnAgentRequest {
- agent_id: "code_executor".to_string(),
- prompt: "do one small thing".to_string(),
- model: Some("round19-parent".to_string()),
- ..Default::default()
- })
- .await
- .map(|spawned| spawned.orchestration_id)
- })
- .await
- .expect("spawning one child");
-
- let first = session
- .wait_agents(WaitAgentOptions {
- orchestration_ids: vec![orchestration_id.clone()],
- timeout_ms: Some(20_000),
- })
- .await
- .expect("the first wait resolves");
-
- assert!(
- first.completed,
- "the first wait must reach a terminal status"
- );
- assert_eq!(first.agents.len(), 1);
- assert!(
- first.agents[0].status.is_terminal(),
- "expected a terminal child, got {:?}",
- first.agents[0].status
- );
-
- // The pruning half. The entry is gone now that a terminal status has been
- // observed, so the same id no longer resolves — `AgentNotFound`, not a
- // second copy of the terminal snapshot.
- match session
- .wait_agents(WaitAgentOptions {
- orchestration_ids: vec![orchestration_id.clone()],
- timeout_ms: Some(1_000),
- })
- .await
- {
- Err(OrchestrationError::AgentNotFound(missing)) => {
- assert_eq!(
- missing, orchestration_id,
- "the error must name the child that was pruned"
- );
- }
- Ok(response) => panic!(
- "a second wait must miss the pruned entry, but it resolved again with {:?}",
- response
- .agents
- .iter()
- .map(|agent| agent.status)
- .collect::<Vec<OrchestrationTaskStatus>>()
- ),
- Err(other) => panic!("expected AgentNotFound from the pruned entry, got: {other:?}"),
- }
-
- Ok(())
-}