Merge ticket/t4-step-mirrors: step schemas, whole-plan hash v2, record schemas (#24)
# Conflicts: # test/workflow-journal.test.ts
This commit is contained in:
commit
e15c86f007
8 files changed
+578
-369
No files matched your search
@@ -4,7 +4,7 @@ import * as os from "node:os";
|
||||
import * as path from "node:path";
|
||||
import test, { after } from "node:test";
|
||||
import fc from "fast-check";
|
||||
import { buildWorkflowJournal, workflowItemInputHash, workflowStepInputHash, type WorkflowJournalRun } from "../src/journal.ts";
|
||||
import { buildWorkflowJournal, WORKFLOW_HASH_PAYLOAD_VERSION, workflowItemInputHash, workflowStepInputHash, type WorkflowJournalRun } from "../src/journal.ts";
|
||||
import type { InternalTask } from "../src/job-state.ts";
|
||||
import { SubagentManager } from "../src/manager.ts";
|
||||
import { MAX_TASK_OUTPUT_BYTES, truncateUtf8Head } from "../src/output.ts";
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
WORKFLOW_RUN_ENTRY,
|
||||
} from "../src/persistence.ts";
|
||||
import { prepareWorkflowInvocation, type PrepareContext } from "../src/prepare.ts";
|
||||
import { parseWorkflow, type WorkflowPlan } from "../src/workflow-plan.ts";
|
||||
import { parseWorkflow, type WorkflowPlan, type WorkflowSource } from "../src/workflow-plan.ts";
|
||||
import { emptyUsage, type JobSnapshot, type TaskSnapshot, type TaskStatus, type WorkflowJournal, type WorkflowJournalItem, type WorkflowJournalStep } from "../src/types.ts";
|
||||
import { FakeRunner } from "./helpers.ts";
|
||||
|
||||
@@ -50,9 +50,16 @@ function makeWorkspace(agentNames = ["scout"]): { cwd: string; ctx: PrepareConte
|
||||
};
|
||||
}
|
||||
|
||||
function makePlan(steps: Array<Record<string, unknown>>, args: string[] = []): WorkflowPlan {
|
||||
function makePlan(
|
||||
steps: Array<Record<string, unknown>>,
|
||||
args: string[] = [],
|
||||
provenance: { source?: WorkflowSource; filePath?: string } = {},
|
||||
): WorkflowPlan {
|
||||
const content = `---\n${JSON.stringify({ name: "test-workflow", description: "Test workflow", args, steps }, null, 2)}\n---\n\nNotes.\n`;
|
||||
return parseWorkflow(content, { source: "user", filePath: "/tmp/test-workflow.md" });
|
||||
return parseWorkflow(content, {
|
||||
source: provenance.source ?? "user",
|
||||
filePath: provenance.filePath ?? "/tmp/test-workflow.md",
|
||||
});
|
||||
}
|
||||
|
||||
function pending(runner: FakeRunner, stepId: string) {
|
||||
@@ -250,6 +257,20 @@ test("step input hashes are stable across identical inputs and change with args
|
||||
workflowStepInputHash(first, "scan", { target: "src" }),
|
||||
);
|
||||
assert.notEqual(workflowStepInputHash(first, "ghost", { target: "src" }), workflowStepInputHash(first, "scan", { target: "src" }));
|
||||
|
||||
// Whole steps are hashed: a step field beyond the brief still moves the hash.
|
||||
const withCwd = makePlan([{ id: "scan", agent: "scout", task: "scan {args.target}", cwd: "src" }], ["target"]);
|
||||
assert.notEqual(workflowStepInputHash(withCwd, "scan", { target: "src" }), workflowStepInputHash(first, "scan", { target: "src" }));
|
||||
|
||||
// Provenance is not an input: the same plan copied elsewhere hashes alike.
|
||||
const elsewhere = makePlan(steps, ["target"], { source: "project", filePath: "/repo/.pi/workflows/test-workflow.md" });
|
||||
assert.equal(workflowStepInputHash(elsewhere, "scan", { target: "src" }), workflowStepInputHash(first, "scan", { target: "src" }));
|
||||
});
|
||||
|
||||
test("the input-hash payload carries the replay-contract version", () => {
|
||||
// Nothing replays today (ADR 0004 journal-only); the marker only separates
|
||||
// hash eras, so moving it is a deliberate migration, never a refactor.
|
||||
assert.equal(WORKFLOW_HASH_PAYLOAD_VERSION, 2);
|
||||
});
|
||||
|
||||
test("journals hash the step inputs, not the outputs, so identical runs agree", async () => {
|
||||
|
||||
Reference in new issue
Block a user