Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion test/diagnostics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,33 @@ test("a hanging backend cannot stall the fast report", async () => {
const report = await diagnosticReport(ctx, {
dependencies: { memoryRoots: roots, mcpStore: store, mcpClient: hanging, timeoutMs: 50 },
});
assert.ok(Date.now() - started < 500);

// What must hold is that the report CAME BACK and told the truth about the
// probes it could not complete. The previous assertion was a 500ms wall-clock
// budget, which measured the machine rather than the behaviour: a loaded CI
// runner blows it even when the 50ms timeout fired exactly as designed
// (observed on windows-latest at 689ms, and locally at 1818ms under full-suite
// load while passing in isolation at 82ms).
assert.equal(report.mode, "fast");

// A probe fed by one of the hanging clients must never come back claiming it
// verified anything. Named explicitly rather than filtered on an axis: local
// checks like workspace.git legitimately verify here, because nothing about
// them touches the backend that is hanging.
const BACKEND_FED = ["agent.transport", "auth.credential", "agent.catalog", "mcp.broker"];
const probed = report.checks.filter((check) => BACKEND_FED.includes(check.id));
assert.equal(probed.length, BACKEND_FED.length, "every backend-fed check should be present in the report");
for (const check of probed) {
assert.notEqual(check.verified.state, "yes", `${check.id} cannot be verified against a hanging backend`);
}

// Still bound the wall clock, but as a hang detector rather than a stopwatch.
// The failure this guards against is an unbounded await, which never returns
// at all; any finite margin distinguishes that from a slow runner.
assert.ok(
Date.now() - started < 30_000,
"the fast report must be bounded by its own timeout, not by the backend",
);
});

test("--live renders the live report, never the fast one relabelled", async () => {
Expand Down