Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
fix(errors): avoid invented controls in generic timeout recovery
Generic timeout errors cannot know whether the caller can change a budget.
Keep their remediation valid for fixed limits and leave exact adjustable
controls to the producer-owned override. Name the CLI command that supports
the JavaScript timeout flag instead of implying the analyze shorthand does.
Cover both counterexamples without changing error identity or cleanup semantics.

Refs #5598

Assisted-by: Kogasa (gensokyo-skills:kogasa-surprise-testing)
  • Loading branch information
gensokyo-dev committed Oct 20, 2026
commit af29cc3ef81d3b983930ffe1b8b162827fc590f7
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,17 @@ A returned REA `provider_timeout` instead means the **server/provider** reached
its deadline. Follow its `remediation.action`, reuse accessible partial Evidence,
and resolve reported incomplete cleanup before retrying. Raising only the
client deadline does not change this server budget. For static JavaScript,
`analysis_timeout_ms` (CLI `--analysis-timeout-ms`) controls each source's
`analysis_timeout_ms` (CLI `rea analyze-javascript-application <path>
--analysis-timeout-ms <milliseconds>`) controls each source's
startup, analysis and transfer deadline in **milliseconds**. Increase that
budget or reduce semantic work / select exact inventoried `source_paths` when
the task permits. Omit `source_paths` for all sources; `[]` is invalid.
`detail: "summary"` reduces delivery, not analysis work. A per-source budget
does not bound the elapsed time for an entire multi-source application.
Partial-Evidence inspection can avoid recomputation; an unavailable reader is
not itself a reason to block a corrected static-analysis retry.
The shorthand `rea analyze <path>` does not expose this timeout flag; use the
explicit JavaScript command when changing that budget.

For invalid arguments, use the connected tool's current input schema, or the
installed CLI's command help. Refresh the catalog if stale; do not guess fields
Expand Down
5 changes: 3 additions & 2 deletions docs/mcp-contracts.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ names the rejected operation: re-read that operation's advertised input schema
(call `tools/list` if the catalog may be stale), correct the listed fields, and
do not repeat the unchanged call. `recovery.kind=inspect_timeout_state` names
the operation and the REA server/provider deadline; inspect partial Evidence
and reported cleanup state, then use the operation's timeout controls or reduce
the work. Raising only the MCP client's deadline cannot extend this budget. These hints never
and reported cleanup state, then follow producer-specific remediation or reduce
supported work. Generic errors do not assume adjustable timeout controls. Raising
only the MCP client's deadline cannot extend this budget. These hints never
include the complete catalog or caller arguments.
Failures omit `structuredContent`, since each advertised `outputSchema`
describes successful results. Successful replies retain their schema-validated
Expand Down
2 changes: 1 addition & 1 deletion docs/user-visible-errors.csv
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ harm_rank,location,trigger,current_copy,user_risk,proposed_replacement,implement
13,src/domain/errors.ts:EvidenceIntegrityError,Evidence validation fails,Raw constructor message,May expose validation internals and lacks recovery,"Evidence is invalid or has changed. Recreate or re-import it, then try again.",implemented,focused assertions passed; full `npm run check` passed
14,src/domain/errors.ts:UnknownRegistryError,Evidence-state mutation fails,"Residual unknown registry mutation failed: {reason}",Exposes internal subsystem and state token,"Missing IDs identify the session and retry; concurrent revision conflicts refresh current state.",implemented,focused assertions passed; full `npm run check` passed
15,src/domain/errors.ts:ProcessCaptureError,Process capture fails,Raw constructor message,May expose process and cleanup internals,"Process capture could not complete. Check command access and limits, then try again.",implemented,focused assertions passed; full `npm run check` passed
16,src/domain/errors.ts:AnalysisTimeoutError,Analysis deadline expires,"REA's {operation} operation reached its {timeoutMs}ms server/provider deadline; extending only the client deadline does not change this budget",Returned server deadline is distinct from a host timeout that discards the response,"Inspect partial Evidence and reported cleanup state; use declared server timeout controls or reduce work. JavaScript names analysis_timeout_ms and exact source_paths; omit an unneeded filter rather than passing an empty array.",implemented,projection and public CLI/MCP timeout regression coverage; client recovery also taught during initialization and in the shipped skill
16,src/domain/errors.ts:AnalysisTimeoutError,Analysis deadline expires,"REA's {operation} operation reached its {timeoutMs}ms server/provider deadline; extending only the client deadline does not change this budget",Returned server deadline is distinct from a host timeout that discards the response,"Inspect partial Evidence and reported cleanup state; diagnose the provider or reduce supported work without assuming adjustable limits. JavaScript specifically names analysis_timeout_ms and exact source_paths; omit an unneeded filter rather than passing an empty array.",implemented,projection and public CLI/MCP timeout regression coverage; client recovery also taught during initialization and in the shipped skill
17,src/domain/errors.ts:HopperTimeoutError,Provider deadline expires,"Hopper did not respond within {timeoutMs}ms",Exposes provider and internal deadline,"Analysis took too long. Try a smaller request, then run `rea doctor` if it continues.",implemented,focused assertions passed; full `npm run check` passed
18,src/domain/errors.ts:ProviderSelectionError,Deep-provider selection fails,"Analysis provider selection failed ({reason}) for {requestedProviderId}; candidates: {candidateIds}",Retains non-secret local selection context that needs a safe structured projection,Reason-specific guidance with stable candidate IDs and actionable rejection diagnostics,implemented,focused registry/CLI/MCP assertions passed; full `npm run check` passed
20,src/domain/errors.ts:AnalysisInputError,Parsed analysis input invalid,"Invalid analysis input for {operation}",Exposes operation identifier and lacks correction,"Analysis input is invalid. Check the arguments and try again.",implemented,focused assertions passed; full `npm run check` passed
Expand Down
2 changes: 1 addition & 1 deletion src/domain/analysisErrorPresentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ const timeoutUserMessage = (error: AnalysisTimeoutError): string =>
`REA's ${error.operation} operation reached its ${String(error.timeoutMs)}ms server/provider deadline. This is not a client-side timeout; extending only the MCP client's deadline does not change this budget.`;

const timeoutRemediation = (error: AnalysisTimeoutError): string =>
`Inspect any partial Evidence and reported session/provider cleanup state for ${error.operation}. Read the operation's declared timeout controls, then retry with a larger server/provider budget or a smaller request. Do not repeat the unchanged call or retry while work or cleanup may still be active.`;
`Inspect any partial Evidence, provider diagnostics and reported session/provider cleanup state for ${error.operation}. Reduce the request if supported, or resolve the reported provider condition before retrying. Do not repeat the unchanged call or retry while work or cleanup may still be active.`;

const UNREADABLE_OUTPUT_TAGS: ReadonlySet<AnalysisErrorTag> = new Set([
"AnalysisProtocolError",
Expand Down
5 changes: 4 additions & 1 deletion src/domain/analysisErrorProjection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,16 @@ describe("agent recovery metadata", () => {
},
message: expect.stringContaining("server/provider deadline"),
remediation: {
action: expect.stringContaining("declared timeout controls"),
action: expect.stringContaining("provider diagnostics"),
},
});
expect(projected.message).toContain("not a client-side timeout");
expect(projected.remediation.action).not.toContain(
"raise its tool deadline",
);
expect(projected.remediation.action).not.toMatch(
/declared timeout controls|larger server\/provider budget/u,
);
expect(analysisErrorProjectionSchema.parse(projected)).toEqual(projected);
});
});
Expand Down
2 changes: 1 addition & 1 deletion src/javascript/analysis/JavaScriptAnalysisWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,7 @@ export class JavaScriptAnalysisWorker {
capturedOutput: this.#captured(),
userMessage: `JavaScript source analysis reached its ${String(this.limits.timeoutMs)}ms per-source server/provider deadline (analysis_timeout_ms), not the MCP client deadline.`,
remediationAction:
"Reuse accessible partial_observation Evidence to avoid recomputation; reading it is not a prerequisite for a corrected retry. Increase analysis_timeout_ms (CLI: --analysis-timeout-ms), or reduce semantic limits / select exact inventoried source_paths (CLI: --source-path). Omit source_paths to analyze all sources; an empty array is invalid. detail: summary reduces response size, not analysis work. Allow execution, cleanup and delivery headroom in the MCP client tool deadline; increasing that client deadline alone does not change this server budget. Resolve any reported incomplete cleanup before retrying.",
"Reuse accessible partial_observation Evidence to avoid recomputation; reading it is not a prerequisite for a corrected retry. Increase analysis_timeout_ms through MCP, or use rea analyze-javascript-application <input_path> --analysis-timeout-ms <milliseconds> on the CLI. Alternatively, reduce semantic limits or select exact inventoried source_paths (CLI: --source-path on that command). Omit source_paths to analyze all sources; an empty array is invalid. detail: summary reduces response size, not analysis work. Allow execution, cleanup and delivery headroom in the MCP client tool deadline; increasing that client deadline alone does not change this server budget. Resolve any reported incomplete cleanup before retrying.",
})
: new AnalysisCancelledError(OPERATION, {
cause: deadline.signal.reason,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ cliTest(
code: "provider_timeout",
message: expect.stringContaining("analysis_timeout_ms"),
remediation: {
action: expect.stringContaining("--analysis-timeout-ms"),
action: expect.stringContaining(
"rea analyze-javascript-application <input_path> --analysis-timeout-ms",
),
},
recovery: { kind: "inspect_timeout_state", timeout_ms: 1 },
});
Expand Down
3 changes: 3 additions & 0 deletions tests/boundary/mcp/javascriptAnalysisResources.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ it("returns a directly usable partial analysis reference for an oversized timeou
expect(error.message).toContain("analysis_timeout_ms");
expect(error.remediation.action).toContain("Increase analysis_timeout_ms");
expect(error.remediation.action).toContain("--analysis-timeout-ms");
expect(error.remediation.action).toContain(
"rea analyze-javascript-application",
);
expect(error.remediation.action).toContain("empty array is invalid");
expect(error.remediation.action).toContain("not analysis work");
expect(error.remediation.action).toContain(
Expand Down
2 changes: 1 addition & 1 deletion tests/boundary/mcp/webBundleContainmentMcp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ it("retains timeout Evidence and recovers on the same MCP server", async () => {
code: "provider_timeout",
message: expect.stringContaining("server/provider deadline"),
remediation: {
action: expect.stringContaining("declared timeout controls"),
action: expect.stringContaining("provider diagnostics"),
},
recovery: {
kind: "inspect_timeout_state",
Expand Down
Loading