mirror of
https://github.com/morluto/rea.git
synced 2026-10-27 01:45:32 +00:00
feat(sqlite): make worker deadlines adjustable with recovery guidance (#5818)
Expose a per-call SQLite worker deadline with exact CLI/MCP recovery controls, parent-owned execution metadata and historical unknown preservation. Keep fixed resource limits and cleanup admission intact. Share typed cleanup composition with one captured-output owner and preserve the timeout after cleanup resolves. Fixes #5812. Follow-up tracking: #5808. Existing CLI test-oracle failure: #5845. Verified 155 SQLite tests (3 skipped), static/docs/discovery checks, six real CLI/MCP pairs and 13 actual Codex sessions including four corrected deadline recoveries. Three pre-dispatch discovery failures remain explicit, not passes. Review findings include real retained-cleanup and fixture ownership regressions. Assisted-by: Kogasa (gensokyo-skills:kogasa-surprise-testing)
This commit is contained in:
1 parent
5241597594
commit
f801b2fbfd
15 files changed
+496
-49
No files matched your search
@@ -0,0 +1,88 @@
|
||||
import { expect, it } from "vitest";
|
||||
import { OwnedCommandFailure } from "../../../src/process/OwnedCommand.js";
|
||||
import { projectAnalysisError } from "../../../src/domain/analysisErrorProjection.js";
|
||||
import { sqliteDatabaseFailure } from "../../../src/sqlite/SqliteDatabaseFailures.js";
|
||||
|
||||
it.each([null, "owned stop unconfirmed"])(
|
||||
"preserves a selected worker deadline with cleanup=%s",
|
||||
(cleanup) => {
|
||||
const cause = new OwnedCommandFailure(
|
||||
"timeout",
|
||||
"Command deadline elapsed.",
|
||||
{
|
||||
stdout: { text: "partial-owned-output", bytes: 20, observedBytes: 20 },
|
||||
stderr: { text: "", bytes: 0, observedBytes: 0 },
|
||||
exitCode: null,
|
||||
signal: null,
|
||||
},
|
||||
cleanup,
|
||||
undefined,
|
||||
["pid:owned-fixture"],
|
||||
);
|
||||
const failure = sqliteDatabaseFailure(
|
||||
cause,
|
||||
"/selected.db",
|
||||
"worker",
|
||||
undefined,
|
||||
1234,
|
||||
);
|
||||
expect(failure.cause).toBe(cause);
|
||||
const projected = projectAnalysisError(failure);
|
||||
if (cleanup === null)
|
||||
expect(projected).toMatchObject({
|
||||
code: "provider_timeout",
|
||||
details: { timeout_ms: 1234 },
|
||||
remediation: { action: expect.stringContaining("--worker-timeout-ms") },
|
||||
});
|
||||
else
|
||||
expect(projected).toMatchObject({
|
||||
code: "cleanup_incomplete",
|
||||
retryable: false,
|
||||
details: {
|
||||
resources: ["pid:owned-fixture"],
|
||||
diagnostics: {
|
||||
previous_error: {
|
||||
code: "provider_timeout",
|
||||
details: { timeout_ms: 1234 },
|
||||
remediation: {
|
||||
action: expect.stringContaining("worker_timeout_ms"),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(
|
||||
JSON.stringify(projected).split("partial-owned-output"),
|
||||
).toHaveLength(2);
|
||||
if (cleanup !== null) {
|
||||
expect(failure.cleanupPrimary).toMatchObject({
|
||||
_tag: "AnalysisTimeoutError",
|
||||
timeoutMs: 1234,
|
||||
});
|
||||
failure.resolveCleanup();
|
||||
const resolved = projectAnalysisError(failure);
|
||||
expect(resolved).toMatchObject({
|
||||
code: "provider_timeout",
|
||||
details: { timeout_ms: 1234 },
|
||||
});
|
||||
expect(
|
||||
JSON.stringify(resolved).split("partial-owned-output"),
|
||||
).toHaveLength(2);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
it("does not recommend a timer above the supported maximum", () => {
|
||||
const failure = projectAnalysisError(
|
||||
sqliteDatabaseFailure(
|
||||
new OwnedCommandFailure("timeout", "deadline"),
|
||||
"/selected.db",
|
||||
"worker",
|
||||
undefined,
|
||||
2_147_483_647,
|
||||
),
|
||||
);
|
||||
expect(failure.details).toMatchObject({ timeout_ms: 2_147_483_647 });
|
||||
expect(failure.remediation.action).toContain("no higher worker deadline");
|
||||
expect(failure.remediation.action).not.toContain("Increase");
|
||||
});
|
||||
Reference in new issue
Block a user