feat(extensions): establish canonical goal source (#54, #55)

This commit is contained in:
2026-09-06 02:32:32 -05:00
parent 44f257cb06
commit d4696d09eb
43 changed files with 6845 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
import assert from "node:assert/strict";
import { test } from "node:test";
import { initialState, setGoal, recordInProgressReport } from "../lib/state.ts";
import { decideSettle } from "../lib/settle.ts";
import { parseGoalCommand } from "../lib/parse.ts";
const wait = { evidence: "Dependency pending", progress: { kind: "wait" as const, gate: "input", owner: "operator", lastMeasurement: "input absent", nextAction: "Read input when available", nextCheck: "input file arrives" } };
test("opted-in waits suspend settle injection", () => {
const state = { ...setGoal(initialState(), "prepare output"), waitTimeoutSeconds: 60 };
const waiting = recordInProgressReport(state, wait).state;
assert.equal(decideSettle(waiting, "stop").action, "wait");
});
test("operator can select bounded waits per goal", () => {
assert.deepEqual(parseGoalCommand("--wait-timeout 60 --max 5 prepare output"), { kind: "set", text: "prepare output", max: 5, waitTimeoutSeconds: 60 });
});
test("timeout input is bounded and opt-in never leaks to another goal", () => {
for (const args of ["--wait-timeout", "--wait-timeout=", "--wait-timeout 0 x", "--wait-timeout 9 x", "--wait-timeout 86401 x", "--wait-timeout 60.0 x", "--wait-timeout 60", "--wait-timeout 60 --wait-timeout 30 x"]) {
assert.equal(parseGoalCommand(args).kind, "error", args);
}
const opted = setGoal(initialState(), "one", undefined, 60);
assert.equal(setGoal(opted, "two").waitTimeoutSeconds, undefined);
const legacyWait = recordInProgressReport(setGoal(initialState(), "legacy"), wait).state;
assert.equal(decideSettle(legacyWait, "stop").action, "inject");
});