fix(hopper): diagnose MCP provider failures with stage, state, and request context (#1044)

* fix(hopper): diagnose MCP provider failures with stage, state, and request context

* fix(hopper): retain health at the actual provider lifecycle boundary

* test(hopper): distinguish socket loss from later observed process exit

* test(hopper): cover observed exit separately from socket-first replies

---------

Co-authored-by: N0zoM1z0 <1705004398@qq.com>
This commit is contained in:
Alan Vo
2026-10-09 00:33:56 +08:00
committed by GitHub
co-authored by N0zoM1z0
parent b5c2954ad6
commit 5a67c7fc54
20 changed files with 990 additions and 62 deletions
@@ -390,3 +390,40 @@ describe("analysis error projection: caller contract", () => {
});
});
});
describe("analysis error projection: operational diagnostics", () => {
it("distinguishes an observed Hopper exit from an undetermined provider failure", () => {
const exited = projectAnalysisError(
new HopperProcessError(7, undefined, "search_strings", 4),
);
expect(exited).toMatchObject({
code: "provider_unavailable",
retryable: true,
details: {
stage: "analysis",
provider_state: "exited",
retry_action: "restart_provider",
operation: "search_strings",
request_id: 4,
exit_code: 7,
},
});
expect(exited.message).not.toContain("Run `rea doctor`, then try again.");
expect(exited.remediation.action).toContain("Restart the owned provider");
const unknown = projectAnalysisError(
new HopperProcessError(null, undefined, "search_strings", 5),
);
expect(unknown.details).toMatchObject({
stage: "analysis",
provider_state: "unknown",
retry_action: "unknown",
operation: "search_strings",
request_id: 5,
exit_code: null,
});
expect(unknown.message).toContain("could not determine");
expect(unknown.message).not.toContain("stopped");
expect(unknown.remediation.action).toContain("provider_operation_health");
});
});