mirror of
https://github.com/morluto/rea.git
synced 2026-11-16 19:53:50 +00:00
feat(errors): name a deadline's parameter or environment control in details.limit (#11172)
This commit is contained in:
1 parent
2d4a97b405
commit
863d82e370
16 files changed
+159
-50
No files matched your search
@@ -2,6 +2,7 @@ import { describe, expect, it } from "vitest";
|
||||
|
||||
import { ArtifactResourceScope } from "../artifacts/ArtifactResourceScope.js";
|
||||
import { AnalysisTimeoutError } from "../domain/analysisErrorCore.js";
|
||||
import { MAX_NODE_TIMER_DELAY_MS } from "../domain/analysisResourceLimits.js";
|
||||
import { projectAnalysisError } from "../domain/analysisErrorProjection.js";
|
||||
import { ProviderAdapterError } from "../domain/providerAdapterError.js";
|
||||
import {
|
||||
@@ -68,12 +69,22 @@ describe("translateNativeCommandFailure", () => {
|
||||
retryable: true,
|
||||
});
|
||||
expect(projected.message).toContain("1 ms");
|
||||
expect(projected.remediation.action).toContain(
|
||||
"REA_SWIFTC_COMPILE_TIMEOUT_MS",
|
||||
);
|
||||
expect(projected.remediation.action).not.toContain(
|
||||
"native_command_timeout_ms",
|
||||
);
|
||||
const limit = {
|
||||
control_kind: "environment",
|
||||
environment: "REA_SWIFTC_COMPILE_TIMEOUT_MS",
|
||||
effective_value: 1,
|
||||
unit: "ms",
|
||||
minimum: 1,
|
||||
maximum: MAX_NODE_TIMER_DELAY_MS,
|
||||
default_value: 120_000,
|
||||
applies_at: "next_startup",
|
||||
};
|
||||
expect(projected.details?.limit).toEqual(limit);
|
||||
// A one-invocation caller's next invocation reads it without a restart.
|
||||
expect(projectAnalysisError(error, "invocation").details?.limit).toEqual({
|
||||
...limit,
|
||||
applies_at: "next_invocation",
|
||||
});
|
||||
});
|
||||
|
||||
it("does not infer a compiler timeout duration when it was not reported", () => {
|
||||
@@ -104,22 +115,22 @@ describe("translateNativeCommandFailure", () => {
|
||||
}),
|
||||
new ArtifactResourceScope(),
|
||||
60_000,
|
||||
{
|
||||
timeoutRecovery: {
|
||||
userMessage: "native command deadline",
|
||||
remediationAction: "native_command_timeout_ms",
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(error).toBeInstanceOf(AnalysisTimeoutError);
|
||||
if (!(error instanceof AnalysisTimeoutError)) return;
|
||||
expect(error.timeoutMs).toBe(60_000);
|
||||
const projected = projectAnalysisError(error);
|
||||
expect(projected.remediation.action).toContain("native_command_timeout_ms");
|
||||
expect(projected.remediation.action).not.toContain(
|
||||
"REA_SWIFTC_COMPILE_TIMEOUT_MS",
|
||||
);
|
||||
expect(projectAnalysisError(error).details?.limit).toEqual({
|
||||
control_kind: "parameter",
|
||||
parameter: "native_command_timeout_ms",
|
||||
cli_flag: "--native-command-timeout-ms",
|
||||
effective_value: 60_000,
|
||||
unit: "ms",
|
||||
minimum: 1,
|
||||
maximum: MAX_NODE_TIMER_DELAY_MS,
|
||||
default_value: 60_000,
|
||||
applies_at: "next_call",
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps compiler exit failures distinct from deadlines", () => {
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
AnalysisCapabilityUnavailableError,
|
||||
AnalysisResourceConstraintError,
|
||||
AnalysisTimeoutError,
|
||||
type AnalysisTimeoutRecovery,
|
||||
cancelledBy,
|
||||
carriedReason,
|
||||
} from "../domain/analysisErrorCore.js";
|
||||
@@ -32,10 +33,7 @@ import {
|
||||
/** Operation-owned text for a command deadline or unavailable requirement. */
|
||||
export interface NativeCommandFailurePresentation {
|
||||
readonly unavailableMessage?: string;
|
||||
readonly timeoutRecovery?: {
|
||||
readonly userMessage: string;
|
||||
readonly remediationAction: string;
|
||||
};
|
||||
readonly timeoutRecovery?: AnalysisTimeoutRecovery;
|
||||
}
|
||||
|
||||
/** Translate the command owner's facts once, preserving capture and cleanup authority. */
|
||||
@@ -116,7 +114,7 @@ export const translateNativeCommandFailure = (
|
||||
...(presentation.timeoutRecovery ??
|
||||
nativeDeadlineRecovery({
|
||||
timeoutMs,
|
||||
setting: "native_command_timeout_ms",
|
||||
parameter: "native_command_timeout_ms",
|
||||
cliFlag: "--native-command-timeout-ms",
|
||||
defaultMs: DEFAULT_NATIVE_COMMAND_TIMEOUT_MS,
|
||||
phase: "macOS native command deadline",
|
||||
@@ -135,6 +133,7 @@ export const translateNativeCommandFailure = (
|
||||
...options,
|
||||
userMessage: darwin.compileTimeout.userMessage,
|
||||
remediationAction: darwin.compileTimeout.remediationAction,
|
||||
limit: darwin.compileTimeout.limit,
|
||||
},
|
||||
)
|
||||
: new ProviderAdapterError(IDENTITY.id, operation, options);
|
||||
@@ -201,7 +200,7 @@ export const translateNativeCommandFailure = (
|
||||
...(presentation.timeoutRecovery ??
|
||||
nativeDeadlineRecovery({
|
||||
timeoutMs,
|
||||
setting: "native_command_timeout_ms",
|
||||
parameter: "native_command_timeout_ms",
|
||||
cliFlag: "--native-command-timeout-ms",
|
||||
defaultMs: DEFAULT_NATIVE_COMMAND_TIMEOUT_MS,
|
||||
phase: "macOS native command deadline",
|
||||
|
||||
@@ -91,7 +91,7 @@ export class NativeUiInterruptionControl {
|
||||
partialObservation,
|
||||
...nativeDeadlineRecovery({
|
||||
timeoutMs: this.#deadlineMs,
|
||||
setting: "native_ui_deadline_ms",
|
||||
parameter: "native_ui_deadline_ms",
|
||||
cliFlag: "--native-ui-deadline-ms",
|
||||
defaultMs: DEFAULT_NATIVE_UI_DEADLINE_MS,
|
||||
phase: "native UI observation deadline",
|
||||
|
||||
@@ -533,8 +533,12 @@ it("classifies a helper subprocess timeout as the selected UI deadline", async (
|
||||
const projected = projectAnalysisError(result.error);
|
||||
expect(projected.code).toBe("provider_timeout");
|
||||
expect(projected.message).toContain("of 2500 ms");
|
||||
expect(projected.message).toContain("native_ui_deadline_ms");
|
||||
expect(projected.remediation.action).toContain("above 2500");
|
||||
expect(projected.details?.limit).toMatchObject({
|
||||
control_kind: "parameter",
|
||||
parameter: "native_ui_deadline_ms",
|
||||
effective_value: 2_500,
|
||||
default_value: 180_000,
|
||||
});
|
||||
expect(projected.message).not.toContain("of 30000 ms");
|
||||
expect(projected.message).not.toContain("of 60000 ms");
|
||||
});
|
||||
|
||||
@@ -118,8 +118,13 @@ it("distinguishes the wall deadline from caller-selected producer resource budge
|
||||
);
|
||||
expect(projected.code).toBe("provider_timeout");
|
||||
expect(projected.message).toContain("4500 ms");
|
||||
expect(projected.message).toContain("pwntools_timeout_ms");
|
||||
expect(projected.remediation.action).toContain("--pwntools-timeout-ms");
|
||||
expect(projected.details?.limit).toMatchObject({
|
||||
control_kind: "parameter",
|
||||
parameter: "pwntools_timeout_ms",
|
||||
cli_flag: "--pwntools-timeout-ms",
|
||||
effective_value: 4_500,
|
||||
default_value: 30_000,
|
||||
});
|
||||
expect(projected.remediation.action).toContain("cpu_seconds=30");
|
||||
expect(projected.remediation.action).toContain("producer_limits");
|
||||
expect(projected.remediation.action).toContain("no REA restart");
|
||||
|
||||
@@ -225,7 +225,7 @@ const pwntoolsCommandContext = (
|
||||
const timeoutMs = context.timeoutMs ?? PWNTOOLS_LIMITS.command_timeout_ms;
|
||||
const deadline = nativeDeadlineRecovery({
|
||||
timeoutMs,
|
||||
setting: "pwntools_timeout_ms",
|
||||
parameter: "pwntools_timeout_ms",
|
||||
cliFlag: "--pwntools-timeout-ms",
|
||||
defaultMs: PWNTOOLS_LIMITS.command_timeout_ms,
|
||||
phase: "pwntools command deadline",
|
||||
@@ -254,6 +254,7 @@ const pwntoolsCommandContext = (
|
||||
ms: timeoutMs,
|
||||
userMessage: deadline.userMessage,
|
||||
remediationAction: deadline.remediationAction,
|
||||
limit: deadline.limit,
|
||||
},
|
||||
outputLimit: {
|
||||
limits: {
|
||||
|
||||
Reference in new issue
Block a user