@warpgogol/forge 9.2.3 → 9.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/bin/cli.ts +3 -2
- package/dist/bin/cli.js +3 -2
- package/dist/bin/cli.js.map +1 -1
- package/dist/os/adr/handlers/implement-stamp.d.ts +6 -0
- package/dist/os/adr/handlers/implement-stamp.d.ts.map +1 -1
- package/dist/os/adr/handlers/implement-stamp.js +23 -15
- package/dist/os/adr/handlers/implement-stamp.js.map +1 -1
- package/dist/os/checks/handlers/counters-journal.d.ts.map +1 -1
- package/dist/os/checks/handlers/counters-journal.js +9 -1
- package/dist/os/checks/handlers/counters-journal.js.map +1 -1
- package/dist/os/core/core.module.d.ts.map +1 -1
- package/dist/os/core/core.module.js +27 -36
- package/dist/os/core/core.module.js.map +1 -1
- package/dist/os/core/lock-holder.d.ts +32 -0
- package/dist/os/core/lock-holder.d.ts.map +1 -0
- package/dist/os/core/lock-holder.js +81 -0
- package/dist/os/core/lock-holder.js.map +1 -0
- package/dist/os/core/stamp-lock.d.ts +30 -0
- package/dist/os/core/stamp-lock.d.ts.map +1 -0
- package/dist/os/core/stamp-lock.js +112 -0
- package/dist/os/core/stamp-lock.js.map +1 -0
- package/dist/os/flow/digest.d.ts +19 -0
- package/dist/os/flow/digest.d.ts.map +1 -1
- package/dist/os/flow/digest.js +33 -4
- package/dist/os/flow/digest.js.map +1 -1
- package/dist/os/flow/flow.module.d.ts.map +1 -1
- package/dist/os/flow/flow.module.js +61 -6
- package/dist/os/flow/flow.module.js.map +1 -1
- package/dist/os/flow/handlers/flow-cut.d.ts +8 -0
- package/dist/os/flow/handlers/flow-cut.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-cut.js +91 -5
- package/dist/os/flow/handlers/flow-cut.js.map +1 -1
- package/dist/os/flow/handlers/flow-digest.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-digest.js +6 -0
- package/dist/os/flow/handlers/flow-digest.js.map +1 -1
- package/dist/os/flow/handlers/flow-discard.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-discard.js +17 -13
- package/dist/os/flow/handlers/flow-discard.js.map +1 -1
- package/dist/os/flow/handlers/flow-fix.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-fix.js +99 -10
- package/dist/os/flow/handlers/flow-fix.js.map +1 -1
- package/dist/os/flow/handlers/flow-integrate.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-integrate.js +32 -15
- package/dist/os/flow/handlers/flow-integrate.js.map +1 -1
- package/dist/os/flow/handlers/flow-publication-retire.d.ts +17 -0
- package/dist/os/flow/handlers/flow-publication-retire.d.ts.map +1 -0
- package/dist/os/flow/handlers/flow-publication-retire.js +132 -0
- package/dist/os/flow/handlers/flow-publication-retire.js.map +1 -0
- package/dist/os/flow/handlers/flow-push.d.ts +7 -0
- package/dist/os/flow/handlers/flow-push.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-push.js +106 -15
- package/dist/os/flow/handlers/flow-push.js.map +1 -1
- package/dist/os/flow/locks.d.ts +6 -1
- package/dist/os/flow/locks.d.ts.map +1 -1
- package/dist/os/flow/locks.js +53 -23
- package/dist/os/flow/locks.js.map +1 -1
- package/dist/os/flow/publication-order.d.ts +25 -0
- package/dist/os/flow/publication-order.d.ts.map +1 -0
- package/dist/os/flow/publication-order.js +75 -0
- package/dist/os/flow/publication-order.js.map +1 -0
- package/dist/os/flow/publish.d.ts +18 -0
- package/dist/os/flow/publish.d.ts.map +1 -1
- package/dist/os/flow/publish.js +58 -2
- package/dist/os/flow/publish.js.map +1 -1
- package/dist/os/flow/registry.d.ts +1 -1
- package/dist/os/flow/registry.d.ts.map +1 -1
- package/dist/os/flow/registry.js +2 -1
- package/dist/os/flow/registry.js.map +1 -1
- package/dist/os/flow/release-tags.d.ts +1 -0
- package/dist/os/flow/release-tags.d.ts.map +1 -1
- package/dist/os/flow/release-tags.js +5 -4
- package/dist/os/flow/release-tags.js.map +1 -1
- package/dist/os/flow/scripts.d.ts +1 -1
- package/dist/os/flow/scripts.d.ts.map +1 -1
- package/dist/os/flow/scripts.js +6 -1
- package/dist/os/flow/scripts.js.map +1 -1
- package/dist/os/flow/task-files.d.ts +11 -0
- package/dist/os/flow/task-files.d.ts.map +1 -0
- package/dist/os/flow/task-files.js +51 -0
- package/dist/os/flow/task-files.js.map +1 -0
- package/dist/os/flow/tests/helpers.d.ts +4 -1
- package/dist/os/flow/tests/helpers.d.ts.map +1 -1
- package/dist/os/flow/tests/helpers.js +9 -5
- package/dist/os/flow/tests/helpers.js.map +1 -1
- package/dist/os/mission/handlers/archive.d.ts.map +1 -1
- package/dist/os/mission/handlers/archive.js +30 -74
- package/dist/os/mission/handlers/archive.js.map +1 -1
- package/dist/os/mission/lockfile.d.ts +21 -0
- package/dist/os/mission/lockfile.d.ts.map +1 -0
- package/dist/os/mission/lockfile.js +76 -0
- package/dist/os/mission/lockfile.js.map +1 -0
- package/dist/os/mission/mission.module.d.ts.map +1 -1
- package/dist/os/mission/mission.module.js +2 -1
- package/dist/os/mission/mission.module.js.map +1 -1
- package/dist/os/rfc/handlers/implement-stamp.d.ts +6 -0
- package/dist/os/rfc/handlers/implement-stamp.d.ts.map +1 -1
- package/dist/os/rfc/handlers/implement-stamp.js +24 -19
- package/dist/os/rfc/handlers/implement-stamp.js.map +1 -1
- package/dist/os/system/handlers/outbox-validate.d.ts +8 -0
- package/dist/os/system/handlers/outbox-validate.d.ts.map +1 -0
- package/dist/os/system/handlers/outbox-validate.js +102 -0
- package/dist/os/system/handlers/outbox-validate.js.map +1 -0
- package/dist/os/system/handlers/system-map-validate.d.ts +13 -0
- package/dist/os/system/handlers/system-map-validate.d.ts.map +1 -0
- package/dist/os/system/handlers/system-map-validate.js +78 -0
- package/dist/os/system/handlers/system-map-validate.js.map +1 -0
- package/dist/os/system/handlers/system-outbox-scan.d.ts +10 -0
- package/dist/os/system/handlers/system-outbox-scan.d.ts.map +1 -0
- package/dist/os/system/handlers/system-outbox-scan.js +195 -0
- package/dist/os/system/handlers/system-outbox-scan.js.map +1 -0
- package/dist/os/system/handlers/system-task-collect.d.ts +13 -0
- package/dist/os/system/handlers/system-task-collect.d.ts.map +1 -0
- package/dist/os/system/handlers/system-task-collect.js +238 -0
- package/dist/os/system/handlers/system-task-collect.js.map +1 -0
- package/dist/os/system/handlers/system-task-create.d.ts +32 -0
- package/dist/os/system/handlers/system-task-create.d.ts.map +1 -0
- package/dist/os/system/handlers/system-task-create.js +216 -0
- package/dist/os/system/handlers/system-task-create.js.map +1 -0
- package/dist/os/system/handlers/system-task-dispatch.d.ts +14 -0
- package/dist/os/system/handlers/system-task-dispatch.d.ts.map +1 -0
- package/dist/os/system/handlers/system-task-dispatch.js +290 -0
- package/dist/os/system/handlers/system-task-dispatch.js.map +1 -0
- package/dist/os/system/handlers/system-task-move.d.ts +12 -0
- package/dist/os/system/handlers/system-task-move.d.ts.map +1 -0
- package/dist/os/system/handlers/system-task-move.js +217 -0
- package/dist/os/system/handlers/system-task-move.js.map +1 -0
- package/dist/os/system/handlers/system-task-status.d.ts +20 -0
- package/dist/os/system/handlers/system-task-status.d.ts.map +1 -0
- package/dist/os/system/handlers/system-task-status.js +139 -0
- package/dist/os/system/handlers/system-task-status.js.map +1 -0
- package/dist/os/system/handlers/system-versionset-record.d.ts +12 -0
- package/dist/os/system/handlers/system-versionset-record.d.ts.map +1 -0
- package/dist/os/system/handlers/system-versionset-record.js +332 -0
- package/dist/os/system/handlers/system-versionset-record.js.map +1 -0
- package/dist/os/system/index.d.ts +6 -0
- package/dist/os/system/index.d.ts.map +1 -0
- package/dist/os/system/index.js +18 -0
- package/dist/os/system/index.js.map +1 -0
- package/dist/os/system/outbox-schema.d.ts +30 -0
- package/dist/os/system/outbox-schema.d.ts.map +1 -0
- package/dist/os/system/outbox-schema.js +29 -0
- package/dist/os/system/outbox-schema.js.map +1 -0
- package/dist/os/system/repo.d.ts +64 -0
- package/dist/os/system/repo.d.ts.map +1 -0
- package/dist/os/system/repo.js +364 -0
- package/dist/os/system/repo.js.map +1 -0
- package/dist/os/system/scenario-schemas.d.ts +26 -0
- package/dist/os/system/scenario-schemas.d.ts.map +1 -0
- package/dist/os/system/scenario-schemas.js +53 -0
- package/dist/os/system/scenario-schemas.js.map +1 -0
- package/dist/os/system/schemas.d.ts +63 -0
- package/dist/os/system/schemas.d.ts.map +1 -0
- package/dist/os/system/schemas.js +83 -0
- package/dist/os/system/schemas.js.map +1 -0
- package/dist/os/system/system.module.d.ts +3 -0
- package/dist/os/system/system.module.d.ts.map +1 -0
- package/dist/os/system/system.module.js +429 -0
- package/dist/os/system/system.module.js.map +1 -0
- package/dist/os/system/task-schemas.d.ts +108 -0
- package/dist/os/system/task-schemas.d.ts.map +1 -0
- package/dist/os/system/task-schemas.js +152 -0
- package/dist/os/system/task-schemas.js.map +1 -0
- package/dist/os/system/task-store.d.ts +41 -0
- package/dist/os/system/task-store.d.ts.map +1 -0
- package/dist/os/system/task-store.js +142 -0
- package/dist/os/system/task-store.js.map +1 -0
- package/dist/os/system/tests/helpers.d.ts +30 -0
- package/dist/os/system/tests/helpers.d.ts.map +1 -0
- package/dist/os/system/tests/helpers.js +178 -0
- package/dist/os/system/tests/helpers.js.map +1 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +5 -4
- package/dist/src/index.js.map +1 -1
- package/os/adr/handlers/implement-stamp-lock.test.ts +90 -0
- package/os/adr/handlers/implement-stamp.ts +29 -20
- package/os/checks/handlers/counters-journal.test.ts +10 -0
- package/os/checks/handlers/counters-journal.ts +8 -1
- package/os/core/core.module.ts +32 -36
- package/os/core/lock-holder.ts +88 -0
- package/os/core/stamp-lock.ts +142 -0
- package/os/flow/digest.ts +46 -4
- package/os/flow/flow.module.ts +62 -6
- package/os/flow/handlers/flow-cut.ts +118 -5
- package/os/flow/handlers/flow-digest.ts +6 -0
- package/os/flow/handlers/flow-discard.ts +22 -13
- package/os/flow/handlers/flow-fix.ts +116 -10
- package/os/flow/handlers/flow-integrate.ts +31 -15
- package/os/flow/handlers/flow-publication-retire.ts +156 -0
- package/os/flow/handlers/flow-push.ts +128 -13
- package/os/flow/locks.ts +75 -25
- package/os/flow/publication-order.ts +99 -0
- package/os/flow/publish.ts +73 -2
- package/os/flow/registry.ts +5 -2
- package/os/flow/release-tags.ts +5 -4
- package/os/flow/scripts.ts +12 -5
- package/os/flow/task-files.ts +59 -0
- package/os/flow/tests/flow-cut-prepare.test.ts +298 -0
- package/os/flow/tests/flow-cut.test.ts +5 -1
- package/os/flow/tests/flow-publication-retire.test.ts +191 -0
- package/os/flow/tests/flow-push-supersede.test.ts +221 -0
- package/os/flow/tests/flow-task-files.test.ts +59 -0
- package/os/flow/tests/helpers.ts +9 -5
- package/os/flow/tests/locks.test.ts +219 -0
- package/os/flow/tests/publication-order.test.ts +102 -0
- package/os/flow/tests/scripts.test.ts +13 -0
- package/os/mission/handlers/archive.test.ts +97 -52
- package/os/mission/handlers/archive.ts +31 -76
- package/os/mission/lockfile.ts +84 -0
- package/os/mission/mission.module.ts +2 -1
- package/os/rfc/handlers/implement-stamp-lock.test.ts +133 -0
- package/os/rfc/handlers/implement-stamp.ts +30 -24
- package/os/system/handlers/outbox-validate.ts +120 -0
- package/os/system/handlers/system-map-validate.ts +107 -0
- package/os/system/handlers/system-outbox-scan.ts +320 -0
- package/os/system/handlers/system-task-collect.ts +305 -0
- package/os/system/handlers/system-task-create.ts +271 -0
- package/os/system/handlers/system-task-dispatch.ts +387 -0
- package/os/system/handlers/system-task-move.ts +353 -0
- package/os/system/handlers/system-task-status.ts +176 -0
- package/os/system/handlers/system-versionset-record.ts +476 -0
- package/os/system/index.ts +47 -0
- package/os/system/outbox-schema.ts +47 -0
- package/os/system/repo.ts +451 -0
- package/os/system/scenario-schemas.ts +62 -0
- package/os/system/schemas.ts +102 -0
- package/os/system/system.module.ts +449 -0
- package/os/system/task-schemas.ts +190 -0
- package/os/system/task-store.ts +184 -0
- package/os/system/tests/helpers.ts +189 -0
- package/os/system/tests/outbox-validate.test.ts +92 -0
- package/os/system/tests/system-map-validate.test.ts +321 -0
- package/os/system/tests/system-outbox-scan.test.ts +273 -0
- package/os/system/tests/system-profile.test.ts +90 -0
- package/os/system/tests/system-task-collect.test.ts +293 -0
- package/os/system/tests/system-task-dispatch.test.ts +279 -0
- package/os/system/tests/system-task-status.test.ts +153 -0
- package/os/system/tests/system-task.test.ts +330 -0
- package/os/system/tests/system-versionset.test.ts +314 -0
- package/package.json +33 -1
- package/profiles/forge-shell.yaml +1 -2
- package/profiles/knowledge.yaml +1 -1
- package/profiles/system.yaml +650 -0
- package/profiles/typescript.yaml +0 -1
- package/skills/fo/fo-outbox/SKILL.md +71 -0
- package/skills/fo/fo-system-dispatch/SKILL.md +65 -0
- package/skills/fo/fo-task-run/SKILL.md +75 -0
- package/src/index.ts +11 -4
- package/src/tests/fixtures/agents-generate-business-before.txt +6 -0
- package/src/tests/profile-flow-hooks.test.ts +15 -0
- package/src/tests/profile-schema.test.ts +2 -1
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>RFC-1509 acceptance tests for system.task.status — the read-only
|
|
4
|
+
projection of task state plus product-side registry/journal evidence
|
|
5
|
+
(registered / integrated / discarded / orphaned / unknown).</purpose>
|
|
6
|
+
</MODULE_CONTRACT>
|
|
7
|
+
<CHANGE_SUMMARY>
|
|
8
|
+
<item>RFC-1509: step 5 — status acceptance tests</item>
|
|
9
|
+
<item>RFC-1509: implement RFC-1509 — system task queue, dispatch briefs and task reports</item>
|
|
10
|
+
<item>RFC-1509: close RFC-1509 review r1 findings — mark-failed escape, open-error refusal, dry-run coverage</item>
|
|
11
|
+
</CHANGE_SUMMARY>
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
// @vitest-environment node
|
|
15
|
+
|
|
16
|
+
import { describe, expect, it } from "vitest";
|
|
17
|
+
|
|
18
|
+
import { runSystemTaskDispatch } from "../handlers/system-task-dispatch.ts";
|
|
19
|
+
import { runSystemTaskStatus } from "../handlers/system-task-status.ts";
|
|
20
|
+
import {
|
|
21
|
+
localMapFor,
|
|
22
|
+
makeContext,
|
|
23
|
+
makeProduct,
|
|
24
|
+
makeSystemRepo,
|
|
25
|
+
readyBrief,
|
|
26
|
+
taskYaml,
|
|
27
|
+
VALID_EDGES_YAML,
|
|
28
|
+
VALID_PRODUCTS_YAML,
|
|
29
|
+
VALID_SYSTEM_YAML,
|
|
30
|
+
} from "./helpers.ts";
|
|
31
|
+
|
|
32
|
+
function input(flags: Record<string, string | string[] | boolean>) {
|
|
33
|
+
return { argv: [], flags };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
describe("system.task.status", () => {
|
|
37
|
+
it("lists every task and is read-only", async () => {
|
|
38
|
+
const systemRoot = await makeSystemRepo({
|
|
39
|
+
"system/system.yaml": VALID_SYSTEM_YAML,
|
|
40
|
+
"system/products.yaml": VALID_PRODUCTS_YAML,
|
|
41
|
+
"system/edges.yaml": VALID_EDGES_YAML,
|
|
42
|
+
"system/products.local.yaml": localMapFor({ alpha: "./alpha" }),
|
|
43
|
+
"alpha/.gitkeep": "",
|
|
44
|
+
"queue/tasks/T-0001.yaml": taskYaml({ id: "T-0001" }),
|
|
45
|
+
"queue/tasks/T-0002.yaml": taskYaml({ id: "T-0002", state: "done" }),
|
|
46
|
+
});
|
|
47
|
+
const result = await runSystemTaskStatus(input({}), makeContext(systemRoot));
|
|
48
|
+
expect(result.exitCode).toBe(0);
|
|
49
|
+
expect(result.data?.tasks.map((t) => t.id)).toEqual(["T-0001", "T-0002"]);
|
|
50
|
+
expect(result.data?.tasks[0].productStatus).toBe("not-dispatched");
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it("--task limits the projection to one id", async () => {
|
|
54
|
+
const systemRoot = await makeSystemRepo({
|
|
55
|
+
"system/system.yaml": VALID_SYSTEM_YAML,
|
|
56
|
+
"system/products.yaml": VALID_PRODUCTS_YAML,
|
|
57
|
+
"system/edges.yaml": VALID_EDGES_YAML,
|
|
58
|
+
"queue/tasks/T-0001.yaml": taskYaml({ id: "T-0001" }),
|
|
59
|
+
"queue/tasks/T-0002.yaml": taskYaml({ id: "T-0002" }),
|
|
60
|
+
});
|
|
61
|
+
const result = await runSystemTaskStatus(input({ task: "T-0002" }), makeContext(systemRoot));
|
|
62
|
+
expect(result.data?.tasks).toHaveLength(1);
|
|
63
|
+
expect(result.data?.tasks[0].id).toBe("T-0002");
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("a dispatched task with a live worktree reports registered", async () => {
|
|
67
|
+
const productRoot = await makeProduct();
|
|
68
|
+
const systemRoot = await makeSystemRepo({
|
|
69
|
+
"system/system.yaml": VALID_SYSTEM_YAML,
|
|
70
|
+
"system/products.yaml": VALID_PRODUCTS_YAML,
|
|
71
|
+
"system/edges.yaml": VALID_EDGES_YAML,
|
|
72
|
+
"system/products.local.yaml": localMapFor({ alpha: productRoot }),
|
|
73
|
+
"queue/tasks/T-0001.yaml": taskYaml({ state: "ready" }),
|
|
74
|
+
"queue/briefs/T-0001.md": readyBrief(),
|
|
75
|
+
});
|
|
76
|
+
await runSystemTaskDispatch(input({ task: "T-0001" }), makeContext(systemRoot));
|
|
77
|
+
const result = await runSystemTaskStatus(input({}), makeContext(systemRoot));
|
|
78
|
+
expect(result.exitCode).toBe(0);
|
|
79
|
+
expect(result.data?.tasks[0].productStatus).toBe("registered");
|
|
80
|
+
expect(result.data?.tasks[0].branch).toMatch(/^auto\/task-/);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("AC-16: a dispatched task with no registry entry and no journal event reports orphaned", async () => {
|
|
84
|
+
const productRoot = await makeProduct();
|
|
85
|
+
const systemRoot = await makeSystemRepo({
|
|
86
|
+
"system/system.yaml": VALID_SYSTEM_YAML,
|
|
87
|
+
"system/products.yaml": VALID_PRODUCTS_YAML,
|
|
88
|
+
"system/edges.yaml": VALID_EDGES_YAML,
|
|
89
|
+
"system/products.local.yaml": localMapFor({ alpha: productRoot }),
|
|
90
|
+
"queue/tasks/T-0001.yaml": taskYaml({
|
|
91
|
+
state: "dispatched",
|
|
92
|
+
dispatch: {
|
|
93
|
+
branch: "auto/task-260101-01-ghost",
|
|
94
|
+
worktree: "/nonexistent/worktree",
|
|
95
|
+
baseCommit: "deadbeef",
|
|
96
|
+
dispatchedAt: "2026-01-01T00:00:00Z",
|
|
97
|
+
},
|
|
98
|
+
}),
|
|
99
|
+
});
|
|
100
|
+
const result = await runSystemTaskStatus(input({}), makeContext(systemRoot));
|
|
101
|
+
expect(result.exitCode).toBe(0);
|
|
102
|
+
expect(result.data?.tasks[0].productStatus).toBe("orphaned");
|
|
103
|
+
expect(result.data?.tasks[0].productMessage).toContain("auto/task-260101-01-ghost");
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it("a corrupt product registry reports unknown — never orphaned on broken evidence", async () => {
|
|
107
|
+
const productRoot = await makeProduct();
|
|
108
|
+
const { mkdir, writeFile } = await import("node:fs/promises");
|
|
109
|
+
const path = await import("node:path");
|
|
110
|
+
await mkdir(path.join(productRoot, ".git", "forge"), { recursive: true });
|
|
111
|
+
await writeFile(path.join(productRoot, ".git", "forge", "registry.yaml"), "not: [valid, registry");
|
|
112
|
+
const systemRoot = await makeSystemRepo({
|
|
113
|
+
"system/system.yaml": VALID_SYSTEM_YAML,
|
|
114
|
+
"system/products.yaml": VALID_PRODUCTS_YAML,
|
|
115
|
+
"system/edges.yaml": VALID_EDGES_YAML,
|
|
116
|
+
"system/products.local.yaml": localMapFor({ alpha: productRoot }),
|
|
117
|
+
"queue/tasks/T-0001.yaml": taskYaml({
|
|
118
|
+
state: "dispatched",
|
|
119
|
+
dispatch: {
|
|
120
|
+
branch: "auto/task-260101-01-ghost",
|
|
121
|
+
worktree: "/nonexistent",
|
|
122
|
+
baseCommit: "deadbeef",
|
|
123
|
+
dispatchedAt: "2026-01-01T00:00:00Z",
|
|
124
|
+
},
|
|
125
|
+
}),
|
|
126
|
+
});
|
|
127
|
+
const result = await runSystemTaskStatus(input({}), makeContext(systemRoot));
|
|
128
|
+
expect(result.exitCode).toBe(0);
|
|
129
|
+
expect(result.data?.tasks[0].productStatus).toBe("unknown");
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it("an unreadable product repo reports unknown, not an error", async () => {
|
|
133
|
+
const systemRoot = await makeSystemRepo({
|
|
134
|
+
"system/system.yaml": VALID_SYSTEM_YAML,
|
|
135
|
+
"system/products.yaml": VALID_PRODUCTS_YAML,
|
|
136
|
+
"system/edges.yaml": VALID_EDGES_YAML,
|
|
137
|
+
"system/products.local.yaml": localMapFor({ alpha: "/definitely/not/a/repo" }),
|
|
138
|
+
"queue/tasks/T-0001.yaml": taskYaml({
|
|
139
|
+
state: "dispatched",
|
|
140
|
+
dispatch: {
|
|
141
|
+
branch: "auto/task-260101-01-x",
|
|
142
|
+
worktree: "/gone",
|
|
143
|
+
baseCommit: "deadbeef",
|
|
144
|
+
dispatchedAt: "2026-01-01T00:00:00Z",
|
|
145
|
+
},
|
|
146
|
+
}),
|
|
147
|
+
});
|
|
148
|
+
const result = await runSystemTaskStatus(input({}), makeContext(systemRoot));
|
|
149
|
+
expect(result.exitCode).toBe(0);
|
|
150
|
+
expect(result.data?.tasks[0].productStatus).toBe("unknown");
|
|
151
|
+
expect(result.data?.tasks[0].productMessage).toBeTruthy();
|
|
152
|
+
});
|
|
153
|
+
});
|
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>RFC-1509 acceptance tests for system.task.create and
|
|
4
|
+
system.task.move — id allocation, schema refusals, the transition table,
|
|
5
|
+
ready-checks (brief, dependencies, edges) and the version-set gate.</purpose>
|
|
6
|
+
</MODULE_CONTRACT>
|
|
7
|
+
<CHANGE_SUMMARY>
|
|
8
|
+
<item>RFC-1509: step 5 — create/move acceptance tests</item>
|
|
9
|
+
<item>RFC-1509: implement RFC-1509 — system task queue, dispatch briefs and task reports</item>
|
|
10
|
+
<item>RFC-1511: accept recorded products map in verified gate, guard folders lookup and exec edges (RFC-1511 review r1)</item>
|
|
11
|
+
<item>RFC-1511: use schema-shaped version-set fixture, record r2 deviations (RFC-1511 review r2)</item>
|
|
12
|
+
</CHANGE_SUMMARY>
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
// @vitest-environment node
|
|
16
|
+
|
|
17
|
+
import { describe, expect, it } from "vitest";
|
|
18
|
+
|
|
19
|
+
import { runSystemTaskCreate } from "../handlers/system-task-create.ts";
|
|
20
|
+
import { runSystemTaskMove } from "../handlers/system-task-move.ts";
|
|
21
|
+
import { readTask } from "../task-store.ts";
|
|
22
|
+
import {
|
|
23
|
+
localMapFor,
|
|
24
|
+
makeContext,
|
|
25
|
+
makeSystemRepo,
|
|
26
|
+
readyBrief,
|
|
27
|
+
taskYaml,
|
|
28
|
+
|
|
29
|
+
VALID_EDGES_YAML,
|
|
30
|
+
VALID_PRODUCTS_YAML,
|
|
31
|
+
VALID_SYSTEM_YAML,
|
|
32
|
+
} from "./helpers.ts";
|
|
33
|
+
|
|
34
|
+
function input(flags: Record<string, string | string[] | boolean>) {
|
|
35
|
+
return { argv: [], flags };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const CREATE_FLAGS = {
|
|
39
|
+
product: "alpha",
|
|
40
|
+
slug: "wire-alpha",
|
|
41
|
+
title: "Wire alpha",
|
|
42
|
+
kind: "change",
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
async function repoWithMap(extra: Record<string, string> = {}) {
|
|
46
|
+
return makeSystemRepo({
|
|
47
|
+
"system/system.yaml": VALID_SYSTEM_YAML,
|
|
48
|
+
"system/products.yaml": VALID_PRODUCTS_YAML,
|
|
49
|
+
"system/edges.yaml": VALID_EDGES_YAML,
|
|
50
|
+
"system/products.local.yaml": localMapFor({ alpha: "./alpha", beta: "./beta" }),
|
|
51
|
+
"alpha/.gitkeep": "",
|
|
52
|
+
"beta/.gitkeep": "",
|
|
53
|
+
...extra,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
describe("system.task.create", () => {
|
|
58
|
+
it("AC-1: two creates allocate sequential T-NNNN ids", async () => {
|
|
59
|
+
const root = await repoWithMap();
|
|
60
|
+
const ctx = makeContext(root);
|
|
61
|
+
const first = await runSystemTaskCreate(input({ ...CREATE_FLAGS }), ctx);
|
|
62
|
+
const second = await runSystemTaskCreate(
|
|
63
|
+
input({ ...CREATE_FLAGS, slug: "wire-alpha-two", title: "Wire alpha two" }),
|
|
64
|
+
ctx,
|
|
65
|
+
);
|
|
66
|
+
expect(first.exitCode).toBe(0);
|
|
67
|
+
expect(second.exitCode).toBe(0);
|
|
68
|
+
expect(first.data?.task).toBe("T-0001");
|
|
69
|
+
expect(second.data?.task).toBe("T-0002");
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it("AC-1: create writes task file + brief scaffold under queue/", async () => {
|
|
73
|
+
const root = await repoWithMap();
|
|
74
|
+
const result = await runSystemTaskCreate(input({ ...CREATE_FLAGS }), makeContext(root));
|
|
75
|
+
expect(result.exitCode).toBe(0);
|
|
76
|
+
const { task } = await readTask(root, (await import("../../../src/utils/io.ts")).resolveIo(undefined), "T-0001");
|
|
77
|
+
expect(task).not.toBeNull();
|
|
78
|
+
expect(task!.state).toBe("proposed");
|
|
79
|
+
expect(task!.brief).toBe("queue/briefs/T-0001.md");
|
|
80
|
+
expect(result.data?.files.some((f) => f.endsWith("queue/briefs/T-0001.md"))).toBe(true);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("create --dry-run writes nothing", async () => {
|
|
84
|
+
const root = await repoWithMap();
|
|
85
|
+
const result = await runSystemTaskCreate(
|
|
86
|
+
input({ ...CREATE_FLAGS, "dry-run": true }),
|
|
87
|
+
makeContext(root),
|
|
88
|
+
);
|
|
89
|
+
expect(result.exitCode).toBe(0);
|
|
90
|
+
const io = (await import("../../../src/utils/io.ts")).resolveIo(undefined);
|
|
91
|
+
const { task } = await readTask(root, io, "T-0001");
|
|
92
|
+
expect(task).toBeNull();
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it("create refuses a product missing from products.yaml (SYSTEM-TASK-05)", async () => {
|
|
96
|
+
const root = await repoWithMap();
|
|
97
|
+
const result = await runSystemTaskCreate(
|
|
98
|
+
input({ ...CREATE_FLAGS, product: "gamma" }),
|
|
99
|
+
makeContext(root),
|
|
100
|
+
);
|
|
101
|
+
expect(result.exitCode).toBe(1);
|
|
102
|
+
expect(result.data?.diagnostics.some((d) => d.ruleId === "SYSTEM-TASK-05")).toBe(true);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it("create refuses outside the system profile (SYSTEM-01)", async () => {
|
|
106
|
+
const { mkdtemp, writeFile } = await import("node:fs/promises");
|
|
107
|
+
const os = await import("node:os");
|
|
108
|
+
const path = await import("node:path");
|
|
109
|
+
const root = await mkdtemp(path.join(os.tmpdir(), "forge-nonsys-"));
|
|
110
|
+
await writeFile(path.join(root, "forge.yaml"), "profile: typescript\n");
|
|
111
|
+
const result = await runSystemTaskCreate(input({ ...CREATE_FLAGS }), makeContext(root));
|
|
112
|
+
expect(result.exitCode).toBe(1);
|
|
113
|
+
expect(result.data?.diagnostics.some((d) => d.ruleId === "SYSTEM-01")).toBe(true);
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
describe("system.task.move", () => {
|
|
118
|
+
it("AC-2: an illegal transition returns SYSTEM-TASK-02", async () => {
|
|
119
|
+
const root = await repoWithMap({
|
|
120
|
+
"queue/tasks/T-0001.yaml": taskYaml({ state: "proposed" }),
|
|
121
|
+
});
|
|
122
|
+
const result = await runSystemTaskMove(
|
|
123
|
+
input({ task: "T-0001", to: "verified" }),
|
|
124
|
+
makeContext(root),
|
|
125
|
+
);
|
|
126
|
+
expect(result.exitCode).toBe(1);
|
|
127
|
+
expect(result.data?.diagnostics.some((d) => d.ruleId === "SYSTEM-TASK-02")).toBe(true);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it("AC-2: a transition owned by dispatch refuses through move", async () => {
|
|
131
|
+
const root = await repoWithMap({
|
|
132
|
+
"queue/tasks/T-0001.yaml": taskYaml({ state: "ready" }),
|
|
133
|
+
});
|
|
134
|
+
const result = await runSystemTaskMove(
|
|
135
|
+
input({ task: "T-0001", to: "dispatched" }),
|
|
136
|
+
makeContext(root),
|
|
137
|
+
);
|
|
138
|
+
expect(result.exitCode).toBe(1);
|
|
139
|
+
expect(
|
|
140
|
+
result.data?.diagnostics.some(
|
|
141
|
+
(d) => d.ruleId === "SYSTEM-TASK-02" && d.message.includes("dispatch"),
|
|
142
|
+
),
|
|
143
|
+
).toBe(true);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
it("AC-3: an incomplete dependency blocks proposed → ready", async () => {
|
|
147
|
+
const root = await repoWithMap({
|
|
148
|
+
"queue/tasks/T-0001.yaml": taskYaml({ dependsOn: ["T-0002"] }),
|
|
149
|
+
"queue/tasks/T-0002.yaml": taskYaml({ id: "T-0002", state: "dispatched" }),
|
|
150
|
+
"queue/briefs/T-0001.md": readyBrief(),
|
|
151
|
+
});
|
|
152
|
+
const result = await runSystemTaskMove(
|
|
153
|
+
input({ task: "T-0001", to: "ready" }),
|
|
154
|
+
makeContext(root),
|
|
155
|
+
);
|
|
156
|
+
expect(result.exitCode).toBe(1);
|
|
157
|
+
const diag = result.data?.diagnostics.find((d) => d.ruleId === "SYSTEM-TASK-02");
|
|
158
|
+
expect(diag?.message).toContain("T-0002");
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it("proposed → ready succeeds with valid brief, done deps and no forbidden edge", async () => {
|
|
162
|
+
const root = await repoWithMap({
|
|
163
|
+
"queue/tasks/T-0001.yaml": taskYaml({ dependsOn: ["T-0002"], contracts: ["alpha-contract"] }),
|
|
164
|
+
"queue/tasks/T-0002.yaml": taskYaml({ id: "T-0002", state: "done" }),
|
|
165
|
+
"queue/briefs/T-0001.md": readyBrief(),
|
|
166
|
+
});
|
|
167
|
+
const result = await runSystemTaskMove(
|
|
168
|
+
input({ task: "T-0001", to: "ready" }),
|
|
169
|
+
makeContext(root),
|
|
170
|
+
);
|
|
171
|
+
expect(result.exitCode).toBe(0);
|
|
172
|
+
expect(result.data?.moved).toBe(true);
|
|
173
|
+
const { task } = await readTask(
|
|
174
|
+
root,
|
|
175
|
+
(await import("../../../src/utils/io.ts")).resolveIo(undefined),
|
|
176
|
+
"T-0001",
|
|
177
|
+
);
|
|
178
|
+
expect(task!.state).toBe("ready");
|
|
179
|
+
expect(task!.history.at(-1)?.to).toBe("ready");
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
it("proposed → ready refuses on a forbidden contract edge (SYSTEM-TASK-03)", async () => {
|
|
183
|
+
const root = await repoWithMap({
|
|
184
|
+
"system/edges.yaml": `schema: forge/system-edges@1
|
|
185
|
+
allowed: []
|
|
186
|
+
forbidden:
|
|
187
|
+
- consumer: alpha
|
|
188
|
+
contract: secret-contract
|
|
189
|
+
reason: alpha must not touch it
|
|
190
|
+
`,
|
|
191
|
+
"queue/tasks/T-0001.yaml": taskYaml({ contracts: ["secret-contract"] }),
|
|
192
|
+
"queue/briefs/T-0001.md": readyBrief(),
|
|
193
|
+
});
|
|
194
|
+
const result = await runSystemTaskMove(
|
|
195
|
+
input({ task: "T-0001", to: "ready" }),
|
|
196
|
+
makeContext(root),
|
|
197
|
+
);
|
|
198
|
+
expect(result.exitCode).toBe(1);
|
|
199
|
+
expect(result.data?.diagnostics.some((d) => d.ruleId === "SYSTEM-TASK-03")).toBe(true);
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
it("proposed → ready warns on an undeclared contract edge (SYSTEM-TASK-04) but moves", async () => {
|
|
203
|
+
const root = await repoWithMap({
|
|
204
|
+
"queue/tasks/T-0001.yaml": taskYaml({ contracts: ["undeclared-contract"] }),
|
|
205
|
+
"queue/briefs/T-0001.md": readyBrief(),
|
|
206
|
+
});
|
|
207
|
+
const result = await runSystemTaskMove(
|
|
208
|
+
input({ task: "T-0001", to: "ready" }),
|
|
209
|
+
makeContext(root),
|
|
210
|
+
);
|
|
211
|
+
expect(result.exitCode).toBe(0);
|
|
212
|
+
expect(result.data?.diagnostics.some((d) => d.ruleId === "SYSTEM-TASK-04" && d.severity === "warning")).toBe(true);
|
|
213
|
+
expect(result.data?.moved).toBe(true);
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
it("proposed → ready refuses while the brief goal is the create placeholder", async () => {
|
|
217
|
+
const root = await repoWithMap();
|
|
218
|
+
// create writes T-0001 task + brief scaffold with the placeholder goal.
|
|
219
|
+
await runSystemTaskCreate(input({ ...CREATE_FLAGS }), makeContext(root));
|
|
220
|
+
const result = await runSystemTaskMove(
|
|
221
|
+
input({ task: "T-0001", to: "ready" }),
|
|
222
|
+
makeContext(root),
|
|
223
|
+
);
|
|
224
|
+
expect(result.exitCode).toBe(1);
|
|
225
|
+
expect(
|
|
226
|
+
result.data?.diagnostics.some(
|
|
227
|
+
(d) => d.ruleId === "SYSTEM-TASK-02" && d.message.includes("placeholder"),
|
|
228
|
+
),
|
|
229
|
+
).toBe(true);
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
it("ready → parked requires --reason", async () => {
|
|
233
|
+
const root = await repoWithMap({
|
|
234
|
+
"queue/tasks/T-0001.yaml": taskYaml({ state: "ready" }),
|
|
235
|
+
});
|
|
236
|
+
const without = await runSystemTaskMove(
|
|
237
|
+
input({ task: "T-0001", to: "parked" }),
|
|
238
|
+
makeContext(root),
|
|
239
|
+
);
|
|
240
|
+
expect(without.exitCode).toBe(1);
|
|
241
|
+
const withReason = await runSystemTaskMove(
|
|
242
|
+
input({ task: "T-0001", to: "parked", reason: "operator stepped away" }),
|
|
243
|
+
makeContext(root),
|
|
244
|
+
);
|
|
245
|
+
expect(withReason.exitCode).toBe(0);
|
|
246
|
+
const io = (await import("../../../src/utils/io.ts")).resolveIo(undefined);
|
|
247
|
+
const { task } = await readTask(root, io, "T-0001");
|
|
248
|
+
expect(task!.state).toBe("parked");
|
|
249
|
+
expect(task!.history.at(-1)?.reason).toBe("operator stepped away");
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
it("verified → done needs no extra check", async () => {
|
|
253
|
+
const root = await repoWithMap({
|
|
254
|
+
"queue/tasks/T-0001.yaml": taskYaml({ state: "verified" }),
|
|
255
|
+
});
|
|
256
|
+
const result = await runSystemTaskMove(
|
|
257
|
+
input({ task: "T-0001", to: "done" }),
|
|
258
|
+
makeContext(root),
|
|
259
|
+
);
|
|
260
|
+
expect(result.exitCode).toBe(0);
|
|
261
|
+
expect(result.data?.moved).toBe(true);
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
it("integrated → verified requires --version-set listing the product", async () => {
|
|
265
|
+
const root = await repoWithMap({
|
|
266
|
+
"queue/tasks/T-0001.yaml": taskYaml({ state: "integrated" }),
|
|
267
|
+
"system/version-sets/VS-0001.yaml": "schema: forge/version-set@1\nid: VS-0001\nproducts: [beta]\n",
|
|
268
|
+
});
|
|
269
|
+
const missing = await runSystemTaskMove(
|
|
270
|
+
input({ task: "T-0001", to: "verified" }),
|
|
271
|
+
makeContext(root),
|
|
272
|
+
);
|
|
273
|
+
expect(missing.exitCode).toBe(1);
|
|
274
|
+
const wrongSet = await runSystemTaskMove(
|
|
275
|
+
input({ task: "T-0001", to: "verified", "version-set": "VS-0001" }),
|
|
276
|
+
makeContext(root),
|
|
277
|
+
);
|
|
278
|
+
expect(wrongSet.exitCode).toBe(1);
|
|
279
|
+
const { writeFile } = await import("node:fs/promises");
|
|
280
|
+
const path = await import("node:path");
|
|
281
|
+
await writeFile(
|
|
282
|
+
path.join(root, "system/version-sets/VS-0001.yaml"),
|
|
283
|
+
"schema: forge/version-set@1\nid: VS-0001\nproducts: [alpha, beta]\n",
|
|
284
|
+
);
|
|
285
|
+
const ok = await runSystemTaskMove(
|
|
286
|
+
input({ task: "T-0001", to: "verified", "version-set": "VS-0001" }),
|
|
287
|
+
makeContext(root),
|
|
288
|
+
);
|
|
289
|
+
expect(ok.exitCode).toBe(0);
|
|
290
|
+
expect(ok.data?.moved).toBe(true);
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
it("integrated → verified accepts the recorded { id: tag } products map (RFC-1511)", async () => {
|
|
294
|
+
const root = await repoWithMap({
|
|
295
|
+
"queue/tasks/T-0001.yaml": taskYaml({ state: "integrated" }),
|
|
296
|
+
"system/version-sets/VS-0007.yaml":
|
|
297
|
+
"schema: forge/version-set@1\nid: VS-0007\nverifiedAt: 2026-11-04T00:00:00.000Z\nproducts:\n alpha: v1.0.0\nscenarios: [scenario-a]\nevidence:\n scenario-a: sha256:0000000000000000000000000000000000000000000000000000000000000000\n",
|
|
298
|
+
});
|
|
299
|
+
const ok = await runSystemTaskMove(
|
|
300
|
+
input({ task: "T-0001", to: "verified", "version-set": "VS-0007" }),
|
|
301
|
+
makeContext(root),
|
|
302
|
+
);
|
|
303
|
+
expect(ok.exitCode).toBe(0);
|
|
304
|
+
expect(ok.data?.moved).toBe(true);
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
it("move --dry-run validates but writes nothing", async () => {
|
|
308
|
+
const root = await repoWithMap({
|
|
309
|
+
"queue/tasks/T-0001.yaml": taskYaml({ state: "verified" }),
|
|
310
|
+
});
|
|
311
|
+
const result = await runSystemTaskMove(
|
|
312
|
+
input({ task: "T-0001", to: "done", "dry-run": true }),
|
|
313
|
+
makeContext(root),
|
|
314
|
+
);
|
|
315
|
+
expect(result.exitCode).toBe(0);
|
|
316
|
+
const io = (await import("../../../src/utils/io.ts")).resolveIo(undefined);
|
|
317
|
+
const { task } = await readTask(root, io, "T-0001");
|
|
318
|
+
expect(task!.state).toBe("verified");
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
it("unknown task id refuses with SYSTEM-TASK-01", async () => {
|
|
322
|
+
const root = await repoWithMap();
|
|
323
|
+
const result = await runSystemTaskMove(
|
|
324
|
+
input({ task: "T-9999", to: "ready" }),
|
|
325
|
+
makeContext(root),
|
|
326
|
+
);
|
|
327
|
+
expect(result.exitCode).toBe(1);
|
|
328
|
+
expect(result.data?.diagnostics.some((d) => d.ruleId === "SYSTEM-TASK-01")).toBe(true);
|
|
329
|
+
});
|
|
330
|
+
});
|