Slice 4 hardening: bounded resolver, terminal states, reconciliation (#21)
Fixes review findings before Slice 5. Resolver: resolveOutcome + WORK_STATUS_FOR_OUTCOME + lifecycle fixes. Execution: bounded finishAttempt retry, terminal Work status preservation, slice validation, bounded reconciliation with 30s cron. Planning: revision guards, durable submitQuestion, design-approval invalidation. Primitives 69 (+4), backend 22 (+10) tests; root typecheck/build/Ultracite pass.
This commit is contained in:
@@ -2,7 +2,7 @@ import { Effect } from "effect";
|
||||
import { describe, expect, test } from "vitest";
|
||||
|
||||
import { FakeHarnessLive } from "./harness-runtime";
|
||||
import { defaultCodingKitV0, shouldRetry } from "./resolver";
|
||||
import { defaultCodingKitV0, resolveOutcome, shouldRetry } from "./resolver";
|
||||
import { validateDefinition } from "./work-definition";
|
||||
import { validateDesignPacket } from "./work-design";
|
||||
import { canTransitionWork } from "./work-lifecycle";
|
||||
@@ -30,6 +30,11 @@ const definition = {
|
||||
version: 1,
|
||||
};
|
||||
|
||||
const probeOutcome = (
|
||||
classification: Parameters<typeof resolveOutcome>[0]["classification"],
|
||||
retryable = false
|
||||
) => ({ classification, retryable, summary: "probe" });
|
||||
|
||||
describe("work resolution contracts", () => {
|
||||
test("high-impact open questions block definition approval", async () => {
|
||||
await expect(
|
||||
@@ -103,3 +108,53 @@ describe("work resolution contracts", () => {
|
||||
expect(canTransitionWork("ready", "executing")).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolver decisions", () => {
|
||||
const policy = defaultCodingKitV0.retryPolicy;
|
||||
|
||||
test("retries a retryable failure while the budget remains", () => {
|
||||
expect(
|
||||
resolveOutcome(probeOutcome("RetryableFailure", true), 1, policy)
|
||||
).toEqual({ kind: "retry" });
|
||||
});
|
||||
|
||||
test("settles RetryableFailure as failed once the budget is exhausted", () => {
|
||||
expect(
|
||||
resolveOutcome(probeOutcome("RetryableFailure", true), 3, policy)
|
||||
).toEqual({
|
||||
kind: "terminal",
|
||||
workStatus: "failed",
|
||||
});
|
||||
});
|
||||
|
||||
test("maps each terminal classification to its Work status", () => {
|
||||
expect(resolveOutcome(probeOutcome("Succeeded"), 1, policy)).toEqual({
|
||||
kind: "terminal",
|
||||
workStatus: "completed",
|
||||
});
|
||||
expect(resolveOutcome(probeOutcome("PermanentFailure"), 1, policy)).toEqual(
|
||||
{
|
||||
kind: "terminal",
|
||||
workStatus: "failed",
|
||||
}
|
||||
);
|
||||
expect(resolveOutcome(probeOutcome("NeedsInput"), 1, policy)).toEqual({
|
||||
kind: "terminal",
|
||||
workStatus: "needs-input",
|
||||
});
|
||||
expect(resolveOutcome(probeOutcome("Blocked"), 1, policy)).toEqual({
|
||||
kind: "terminal",
|
||||
workStatus: "blocked",
|
||||
});
|
||||
expect(resolveOutcome(probeOutcome("Cancelled"), 1, policy)).toEqual({
|
||||
kind: "terminal",
|
||||
workStatus: "ready",
|
||||
});
|
||||
});
|
||||
|
||||
test("completed and cancelled are not silently reopened", () => {
|
||||
expect(canTransitionWork("completed", "defining")).toBe(false);
|
||||
expect(canTransitionWork("cancelled", "proposed")).toBe(false);
|
||||
expect(canTransitionWork("ready", "executing")).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user