@oscaner-skills/cdd-engine 1.0.0 → 2.0.0
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/README.md +9 -8
- package/README.zh-CN.md +9 -8
- package/package.json +15 -22
- package/src-next/__tests__/bin.test.ts +128 -0
- package/src-next/__tests__/smoke.integration.test.ts +202 -0
- package/src-next/__tests__/zero-dep.test.ts +134 -0
- package/src-next/bin.ts +61 -0
- package/src-next/contract/__tests__/__snapshots__/project.schema.overall-spec.snap +238 -0
- package/src-next/contract/__tests__/__snapshots__/project.schema.phase-spec.snap +153 -0
- package/src-next/contract/__tests__/__snapshots__/project.schema.plan.snap +173 -0
- package/src-next/contract/__tests__/__snapshots__/project.schema.single-spec.snap +89 -0
- package/src-next/contract/__tests__/__snapshots__/project.shape.overall-spec.snap +225 -0
- package/src-next/contract/__tests__/__snapshots__/project.shape.phase-spec.snap +155 -0
- package/src-next/contract/__tests__/__snapshots__/project.shape.plan.snap +175 -0
- package/src-next/contract/__tests__/__snapshots__/project.shape.single-spec.snap +85 -0
- package/src-next/contract/__tests__/declare.test.ts +242 -0
- package/src-next/contract/__tests__/doc.test.ts +358 -0
- package/src-next/contract/__tests__/judge.test.ts +873 -0
- package/src-next/contract/__tests__/lint.test.ts +314 -0
- package/src-next/contract/__tests__/project.test.ts +419 -0
- package/src-next/contract/__tests__/translate.test.ts +96 -0
- package/src-next/contract/declare.ts +983 -0
- package/src-next/contract/doc.ts +753 -0
- package/src-next/contract/invariants.ts +1268 -0
- package/src-next/contract/judge.ts +142 -0
- package/src-next/contract/lint.ts +275 -0
- package/src-next/contract/project.ts +596 -0
- package/src-next/contract/skill-anatomy.ts +273 -0
- package/src-next/contract/translate.ts +113 -0
- package/src-next/face/__tests__/board-view.test.ts +948 -0
- package/src-next/face/__tests__/capsule.test.ts +276 -0
- package/src-next/face/__tests__/channel-closure.guard.test.ts +102 -0
- package/src-next/face/__tests__/cli.test.ts +4643 -0
- package/src-next/face/__tests__/face.test.ts +289 -0
- package/src-next/face/__tests__/graph-view.test.ts +61 -0
- package/src-next/face/__tests__/host.test.ts +24 -0
- package/src-next/face/__tests__/negation.ts +6 -0
- package/src-next/face/__tests__/projection.test.ts +301 -0
- package/src-next/face/__tests__/sync-runner.test.ts +70 -0
- package/src-next/face/__tests__/words.guard.test.ts +93 -0
- package/src-next/face/artifacts.ts +195 -0
- package/src-next/face/board-view.ts +662 -0
- package/src-next/face/capsule.ts +149 -0
- package/src-next/face/cli.ts +819 -0
- package/src-next/face/declare.ts +326 -0
- package/src-next/face/gate.ts +170 -0
- package/src-next/face/graph-view.ts +74 -0
- package/src-next/face/host.ts +326 -0
- package/src-next/face/lifecycle.ts +700 -0
- package/src-next/face/projection.ts +282 -0
- package/src-next/face/route-render.ts +160 -0
- package/src-next/face/words.ts +296 -0
- package/src-next/infra/__tests__/infra.test.ts +287 -0
- package/src-next/infra/config.ts +42 -0
- package/src-next/infra/git.ts +39 -0
- package/src-next/infra/process.ts +34 -0
- package/src-next/infra/runtime.ts +185 -0
- package/src-next/infra/workspace.ts +232 -0
- package/src-next/render/__tests__/render.test.ts +499 -0
- package/src-next/render/__tests__/skeleton.test.ts +466 -0
- package/src-next/render/brief.ts +121 -0
- package/src-next/render/issue-body.ts +159 -0
- package/src-next/render/skeleton.ts +437 -0
- package/src-next/render/templates.ts +650 -0
- package/src-next/session/__tests__/graph.test.ts +270 -0
- package/src-next/session/__tests__/handoff-plane.guard.test.ts +48 -0
- package/src-next/session/__tests__/handoff-schema.test.ts +310 -0
- package/src-next/session/__tests__/ledger.test.ts +744 -0
- package/src-next/session/__tests__/next.test.ts +368 -0
- package/src-next/session/__tests__/preflight.test.ts +491 -0
- package/src-next/session/__tests__/run.test.ts +1014 -0
- package/src-next/session/__tests__/wave-line-phase.guard.test.ts +49 -0
- package/src-next/session/__tests__/wave.test.ts +469 -0
- package/src-next/session/faces.ts +110 -0
- package/src-next/session/graph.ts +411 -0
- package/src-next/session/handoff-schema.ts +373 -0
- package/src-next/session/ledger.ts +1004 -0
- package/src-next/session/next.ts +192 -0
- package/src-next/session/preflight.ts +240 -0
- package/src-next/session/run.ts +606 -0
- package/src-next/session/state.ts +30 -0
- package/src-next/session/wave.ts +139 -0
- package/templates/report/issue-body.json +18 -20
- package/dist/chunks/branch.mjs +0 -480
- package/dist/chunks/docs.mjs +0 -253
- package/dist/chunks/task.mjs +0 -913
- package/dist/cli.mjs +0 -5457
- package/dist/documents/schema/add-phase-protocol.json +0 -126
- package/dist/documents/schema/overall.json +0 -361
- package/dist/documents/schema/phase-spec.json +0 -145
- package/dist/documents/schema/plan.json +0 -191
- package/dist/documents/schema/skill-anatomy.json +0 -233
- package/dist/resources/harness-registry.json +0 -49
- package/dist/shared/cdd-engine.liioziig.mjs +0 -184
- package/templates/engine-config.json +0 -302
- package/templates/schema/cache-profile-schema.json +0 -23
- package/templates/schema/docs-handoff-schema.json +0 -129
- package/templates/schema/task-handoff-schema.json +0 -332
- package/templates/template-contract.json +0 -231
|
@@ -0,0 +1,948 @@
|
|
|
1
|
+
// packages/cdd-engine/src-next/face/__tests__/board-view.test.ts
|
|
2
|
+
// The board face's colocated pins (T2 slice): the slug → node-tree infrastructure
|
|
3
|
+
// · Workspace.docsOfSlug — the reverse derivation over a hermetic tmp repo
|
|
4
|
+
// (program slug → overall path · phase slug → spec/plan paths · deep-phase
|
|
5
|
+
// suffix parse);
|
|
6
|
+
// · BoardView.scanPhases — the phase-suffix set from the specs dir, sorted by the
|
|
7
|
+
// dot-separated numeric path, with NO on-disk-absent parent synthesized;
|
|
8
|
+
// · the artifact header read — `{version, status, docType}` from the doc's
|
|
9
|
+
// header block, the doc type read from the `- **Doc type**:` declaration line
|
|
10
|
+
// (spec §12 · D34 — null when absent, zero filename-suffix inference).
|
|
11
|
+
// Fixtures are hermetic tmp dirs (no git needed — pure file-system reads).
|
|
12
|
+
|
|
13
|
+
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
14
|
+
import { tmpdir } from "node:os";
|
|
15
|
+
import path from "node:path";
|
|
16
|
+
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
17
|
+
import { ConfigLoader } from "../../infra/config.ts";
|
|
18
|
+
import { Workspace, WorkspaceRoot } from "../../infra/workspace.ts";
|
|
19
|
+
import { Ledger } from "../../session/ledger.ts";
|
|
20
|
+
import { BoardView } from "../board-view.ts";
|
|
21
|
+
import { Capsule } from "../capsule.ts";
|
|
22
|
+
import { ARGV_CHANNEL } from "../declare.ts";
|
|
23
|
+
import { Words } from "../words.ts";
|
|
24
|
+
|
|
25
|
+
describe("Workspace.docsOfSlug — the slug → doc-tree reverse derivation", () => {
|
|
26
|
+
let repo: string;
|
|
27
|
+
let prevCwd: string;
|
|
28
|
+
|
|
29
|
+
beforeEach(() => {
|
|
30
|
+
repo = mkdtempSync(path.join(tmpdir(), "board-view-"));
|
|
31
|
+
prevCwd = process.cwd();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
afterEach(() => {
|
|
35
|
+
process.chdir(prevCwd);
|
|
36
|
+
rmSync(repo, { recursive: true, force: true });
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("a phase slug derives the overall + spec + plan paths from what exists on disk", () => {
|
|
40
|
+
mkdirSync(path.join(repo, "docs/kairos/specs"), { recursive: true });
|
|
41
|
+
mkdirSync(path.join(repo, "docs/kairos/plans"), { recursive: true });
|
|
42
|
+
writeFileSync(path.join(repo, "docs/kairos/specs/prog-overall.md"), "# P\n");
|
|
43
|
+
writeFileSync(path.join(repo, "docs/kairos/specs/prog-p7-design.md"), "# S\n");
|
|
44
|
+
writeFileSync(path.join(repo, "docs/kairos/plans/prog-p7.md"), "# Plan\n");
|
|
45
|
+
|
|
46
|
+
const docs = Workspace.docsOfSlug("prog-p7", repo);
|
|
47
|
+
|
|
48
|
+
expect(docs.phaseSuffix).toBe("-p7");
|
|
49
|
+
expect(docs.overall).toBe(path.join(repo, "docs/kairos/specs/prog-overall.md"));
|
|
50
|
+
expect(docs.spec).toBe(path.join(repo, "docs/kairos/specs/prog-p7-design.md"));
|
|
51
|
+
expect(docs.plan).toBe(path.join(repo, "docs/kairos/plans/prog-p7.md"));
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("a phase slug with the overall absent carries null — nothing synthesized", () => {
|
|
55
|
+
mkdirSync(path.join(repo, "docs/kairos/specs"), { recursive: true });
|
|
56
|
+
writeFileSync(path.join(repo, "docs/kairos/specs/prog-p7-design.md"), "# S\n");
|
|
57
|
+
|
|
58
|
+
const docs = Workspace.docsOfSlug("prog-p7", repo);
|
|
59
|
+
|
|
60
|
+
expect(docs.overall).toBeNull();
|
|
61
|
+
expect(docs.spec).not.toBeNull();
|
|
62
|
+
expect(docs.plan).toBeNull();
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("a deep-phase suffix parses whole and anchors the nearest existing overall", () => {
|
|
66
|
+
mkdirSync(path.join(repo, "docs/kairos/specs"), { recursive: true });
|
|
67
|
+
writeFileSync(path.join(repo, "docs/kairos/specs/prog-p7-overall.md"), "# O\n");
|
|
68
|
+
|
|
69
|
+
const docs = Workspace.docsOfSlug("prog-p7.1", repo);
|
|
70
|
+
|
|
71
|
+
expect(docs.phaseSuffix).toBe("-p7.1");
|
|
72
|
+
expect(docs.overall).toBe(path.join(repo, "docs/kairos/specs/prog-p7-overall.md"));
|
|
73
|
+
expect(docs.spec).toBeNull();
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("a deep-phase suffix falls through to the program overall when no sub-overall exists", () => {
|
|
77
|
+
mkdirSync(path.join(repo, "docs/kairos/specs"), { recursive: true });
|
|
78
|
+
writeFileSync(path.join(repo, "docs/kairos/specs/prog-overall.md"), "# O\n");
|
|
79
|
+
|
|
80
|
+
const docs = Workspace.docsOfSlug("prog-p3.2.1", repo);
|
|
81
|
+
|
|
82
|
+
expect(docs.phaseSuffix).toBe("-p3.2.1");
|
|
83
|
+
expect(docs.overall).toBe(path.join(repo, "docs/kairos/specs/prog-overall.md"));
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it("a deepest suffix parses whole (`-p3.2.1`)", () => {
|
|
87
|
+
const docs = Workspace.docsOfSlug("prog-p3.2.1", repo);
|
|
88
|
+
expect(docs.phaseSuffix).toBe("-p3.2.1");
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it("a program slug (no phase suffix) derives only the overall", () => {
|
|
92
|
+
mkdirSync(path.join(repo, "docs/kairos/specs"), { recursive: true });
|
|
93
|
+
writeFileSync(path.join(repo, "docs/kairos/specs/prog-overall.md"), "# O\n");
|
|
94
|
+
|
|
95
|
+
const docs = Workspace.docsOfSlug("prog", repo);
|
|
96
|
+
|
|
97
|
+
expect(docs.phaseSuffix).toBeNull();
|
|
98
|
+
expect(docs.overall).toBe(path.join(repo, "docs/kairos/specs/prog-overall.md"));
|
|
99
|
+
expect(docs.spec).toBeNull();
|
|
100
|
+
expect(docs.plan).toBeNull();
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
describe("BoardView.scanPhases — the phase-suffix scan (no absent parent synthesized)", () => {
|
|
105
|
+
let repo: string;
|
|
106
|
+
|
|
107
|
+
beforeEach(() => {
|
|
108
|
+
repo = mkdtempSync(path.join(tmpdir(), "board-view-scan-"));
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
afterEach(() => {
|
|
112
|
+
rmSync(repo, { recursive: true, force: true });
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it("only the on-disk suffixes return — a lone `-p4.1` mounts without `-p4`", () => {
|
|
116
|
+
mkdirSync(path.join(repo, "docs/kairos/specs"), { recursive: true });
|
|
117
|
+
writeFileSync(path.join(repo, "docs/kairos/specs/prog-p4.1-design.md"), "# S\n");
|
|
118
|
+
|
|
119
|
+
expect(BoardView.scanPhases("prog", repo)).toEqual(["-p4.1"]);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it("suffixes sort by the dot-separated numeric path (2 before 10, p4 before p4.1)", () => {
|
|
123
|
+
mkdirSync(path.join(repo, "docs/kairos/specs"), { recursive: true });
|
|
124
|
+
for (const name of ["prog-p10", "prog-p2", "prog-p4", "prog-p4.1"])
|
|
125
|
+
writeFileSync(path.join(repo, "docs/kairos/specs", `${name}-design.md`), "# S\n");
|
|
126
|
+
|
|
127
|
+
expect(BoardView.scanPhases("prog", repo)).toEqual(["-p2", "-p4", "-p4.1", "-p10"]);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it("an absent specs dir scans empty (a bare repo is a valid board input)", () => {
|
|
131
|
+
expect(BoardView.scanPhases("prog", repo)).toEqual([]);
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
describe("BoardView.readHeader — the artifact header `{version, status, docType}` read", () => {
|
|
136
|
+
let repo: string;
|
|
137
|
+
|
|
138
|
+
beforeEach(() => {
|
|
139
|
+
repo = mkdtempSync(path.join(tmpdir(), "board-view-head-"));
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
afterEach(() => {
|
|
143
|
+
rmSync(repo, { recursive: true, force: true });
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
it("reads the Version/Status/Doc type markers from a plan doc's header block", () => {
|
|
147
|
+
mkdirSync(path.join(repo, "docs/kairos/plans"), { recursive: true });
|
|
148
|
+
const planPath = path.join(repo, "docs/kairos/plans/prog-p8.md");
|
|
149
|
+
writeFileSync(
|
|
150
|
+
planPath,
|
|
151
|
+
[
|
|
152
|
+
"# The plan",
|
|
153
|
+
"",
|
|
154
|
+
"- **Version**: v0.9 · …",
|
|
155
|
+
"- **Status**: Done",
|
|
156
|
+
"- **Doc type**: plan",
|
|
157
|
+
"",
|
|
158
|
+
"## Constraints",
|
|
159
|
+
"",
|
|
160
|
+
].join("\n"),
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
expect(BoardView.readHeader(planPath)).toEqual({
|
|
164
|
+
version: "v0.9",
|
|
165
|
+
status: "Done",
|
|
166
|
+
docType: "plan",
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it("reads the declared docType from a phase-spec's `- **Doc type**:` declaration line", () => {
|
|
171
|
+
mkdirSync(path.join(repo, "docs/kairos/specs"), { recursive: true });
|
|
172
|
+
const specPath = path.join(repo, "docs/kairos/specs/prog-p8-design.md");
|
|
173
|
+
writeFileSync(
|
|
174
|
+
specPath,
|
|
175
|
+
[
|
|
176
|
+
"# The phase spec",
|
|
177
|
+
"",
|
|
178
|
+
"- **Version**: v1.2 · 2026-10-15",
|
|
179
|
+
"- **Status**: In review",
|
|
180
|
+
"- **Doc type**: phase-spec",
|
|
181
|
+
"",
|
|
182
|
+
"## 1. The design group",
|
|
183
|
+
"",
|
|
184
|
+
].join("\n"),
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
expect(BoardView.readHeader(specPath)).toEqual({
|
|
188
|
+
version: "v1.2",
|
|
189
|
+
status: "In review",
|
|
190
|
+
docType: "phase-spec",
|
|
191
|
+
});
|
|
192
|
+
expect(BoardView.readDocType(specPath)).toBe("phase-spec");
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
it("a doc without a Doc type declaration reads docType null — the consumer blocks, no suffix fallback", () => {
|
|
196
|
+
mkdirSync(path.join(repo, "docs/kairos/specs"), { recursive: true });
|
|
197
|
+
const specPath = path.join(repo, "docs/kairos/specs/prog-p8-design.md");
|
|
198
|
+
writeFileSync(
|
|
199
|
+
specPath,
|
|
200
|
+
["# The phase spec", "", "- **Version**: v1.0", "- **Status**: Draft", ""].join("\n"),
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
expect(BoardView.readHeader(specPath)).toEqual({
|
|
204
|
+
version: "v1.0",
|
|
205
|
+
status: "Draft",
|
|
206
|
+
docType: null,
|
|
207
|
+
});
|
|
208
|
+
expect(BoardView.readDocType(specPath)).toBeNull();
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
it("an out-of-domain Doc type value reads null — present facts, never a fabricated type", () => {
|
|
212
|
+
mkdirSync(path.join(repo, "docs/kairos/plans"), { recursive: true });
|
|
213
|
+
const planPath = path.join(repo, "docs/kairos/plans/prog-p8.md");
|
|
214
|
+
writeFileSync(planPath, ["# The plan", "", "- **Doc type**: memo", ""].join("\n"));
|
|
215
|
+
|
|
216
|
+
expect(BoardView.readDocType(planPath)).toBeNull();
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
it("an absent doc yields nulls — never a fabricated value", () => {
|
|
220
|
+
expect(BoardView.readHeader(path.join(repo, "docs/kairos/plans/ghost-p8.md"))).toEqual({
|
|
221
|
+
version: null,
|
|
222
|
+
status: null,
|
|
223
|
+
docType: null,
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
it("a doc whose first line is not the `# Title` still reads its metadata block", () => {
|
|
228
|
+
mkdirSync(path.join(repo, "docs/kairos/plans"), { recursive: true });
|
|
229
|
+
const planPath = path.join(repo, "docs/kairos/plans/prog-p8.md");
|
|
230
|
+
writeFileSync(
|
|
231
|
+
planPath,
|
|
232
|
+
[
|
|
233
|
+
"- **Version**: v0.9 · …",
|
|
234
|
+
"- **Status**: Done",
|
|
235
|
+
"- **Doc type**: plan",
|
|
236
|
+
"",
|
|
237
|
+
"## Constraints",
|
|
238
|
+
"",
|
|
239
|
+
].join("\n"),
|
|
240
|
+
);
|
|
241
|
+
|
|
242
|
+
expect(BoardView.readHeader(planPath)).toEqual({
|
|
243
|
+
version: "v0.9",
|
|
244
|
+
status: "Done",
|
|
245
|
+
docType: "plan",
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
describe("BoardView projectNode — the per-node progress.json single-source projection", () => {
|
|
251
|
+
let repo: string;
|
|
252
|
+
|
|
253
|
+
beforeEach(() => {
|
|
254
|
+
repo = mkdtempSync(path.join(tmpdir(), "board-progress-"));
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
afterEach(() => {
|
|
258
|
+
rmSync(repo, { recursive: true, force: true });
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
/** Seed a node's own workspace progress.json (the pure data write — the read side
|
|
262
|
+
* is the projection under test, never a Ledger round synthesis). */
|
|
263
|
+
const seedProgress = (slug: string, data: Record<string, unknown>): void => {
|
|
264
|
+
const dir = path.join(repo, ".kairos/cdd", slug);
|
|
265
|
+
mkdirSync(dir, { recursive: true });
|
|
266
|
+
writeFileSync(
|
|
267
|
+
path.join(dir, "progress.json"),
|
|
268
|
+
JSON.stringify({ timeoutCount: 0, contractViolationCount: 0, waves: [], ...data }, null, 2),
|
|
269
|
+
);
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
it("projects each node from its OWN progress.json — the overall node and a phase node", () => {
|
|
273
|
+
seedProgress("o1-overall", {
|
|
274
|
+
waves: [{ wave: "spec", rounds: { review: [1, 2], fix: [1] } }],
|
|
275
|
+
});
|
|
276
|
+
seedProgress("o1-p1", { waves: [{ wave: "plan", rounds: { review: [1], fix: [2] } }] });
|
|
277
|
+
mkdirSync(path.join(repo, "docs/kairos/specs"), { recursive: true });
|
|
278
|
+
writeFileSync(path.join(repo, "docs/kairos/specs/o1-p1-design.md"), "# S\n");
|
|
279
|
+
|
|
280
|
+
const nodes = BoardView.projectNodes("o1", repo);
|
|
281
|
+
const overall = nodes.find((node) => node.label === "o1-overall");
|
|
282
|
+
const phase = nodes.find((node) => node.label === "o1-p1");
|
|
283
|
+
|
|
284
|
+
expect(overall?.rounds).toEqual({ review: [1, 2], fix: [1] });
|
|
285
|
+
expect(phase?.lines.find((line) => line.label === "plan")?.rounds).toEqual({
|
|
286
|
+
review: [1],
|
|
287
|
+
fix: [2],
|
|
288
|
+
});
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
it("renders the ×N from the CYCLE-NUMBER array length — never the stored number", () => {
|
|
292
|
+
expect(BoardView.roundsCell({ review: [1, 3] })).toBe("review×2");
|
|
293
|
+
expect(BoardView.roundsCell({ implement: [1], review: [1, 3], fix: [2] })).toBe(
|
|
294
|
+
"implement×1 · review×2 · fix×1",
|
|
295
|
+
);
|
|
296
|
+
// the retired numeric form is out-of-format — no count renders (zero compat layer)
|
|
297
|
+
expect(BoardView.roundsCell({ review: 2 } as unknown as Record<string, number[]>)).toBe("");
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
it("derives one wave line per wave — the ✔/▶ markers ride the closedWaves() read", () => {
|
|
301
|
+
mkdirSync(path.join(repo, "docs/kairos/plans"), { recursive: true });
|
|
302
|
+
const planPath = path.join(repo, "docs/kairos/plans/o1-p1.md");
|
|
303
|
+
writeFileSync(
|
|
304
|
+
planPath,
|
|
305
|
+
[
|
|
306
|
+
"# Plan",
|
|
307
|
+
"",
|
|
308
|
+
"## Constraints",
|
|
309
|
+
"",
|
|
310
|
+
"- c",
|
|
311
|
+
"",
|
|
312
|
+
"### Task 1: a",
|
|
313
|
+
"- **Objective**: o",
|
|
314
|
+
"- **Files**: `a.ts`",
|
|
315
|
+
"- **Consumes**: x",
|
|
316
|
+
"- **Produces**: y",
|
|
317
|
+
"- **Steps**:",
|
|
318
|
+
" - s — checkable: g",
|
|
319
|
+
"- **Acceptance**: ok",
|
|
320
|
+
"- **DependsOn**: none",
|
|
321
|
+
"",
|
|
322
|
+
"### Task 2: b",
|
|
323
|
+
"- **Objective**: o",
|
|
324
|
+
"- **Files**: `b.ts`",
|
|
325
|
+
"- **Consumes**: x",
|
|
326
|
+
"- **Produces**: y",
|
|
327
|
+
"- **Steps**:",
|
|
328
|
+
" - s — checkable: g",
|
|
329
|
+
"- **Acceptance**: ok",
|
|
330
|
+
"- **DependsOn**: 1",
|
|
331
|
+
"",
|
|
332
|
+
].join("\n"),
|
|
333
|
+
);
|
|
334
|
+
mkdirSync(path.join(repo, "docs/kairos/specs"), { recursive: true });
|
|
335
|
+
writeFileSync(path.join(repo, "docs/kairos/specs/o1-p1-design.md"), "# S\n");
|
|
336
|
+
// Close wave {1}: a recorded zero-findings review round at the wave row "1".
|
|
337
|
+
const workspace = new Workspace(new WorkspaceRoot(repo, ".kairos/cdd"), "o1-p1").ensure();
|
|
338
|
+
const ledger = new Ledger(workspace, new ConfigLoader());
|
|
339
|
+
ledger.persistHandoff("review", "wave", { tasks: "1", round: 1 }, { findings: [] });
|
|
340
|
+
ledger.recordRound("1", "review");
|
|
341
|
+
|
|
342
|
+
const node = BoardView.projectNode("o1-p1", repo);
|
|
343
|
+
const rendered = (node.waveLines ?? []).map((line) => `${line.label} ${line.marker}`);
|
|
344
|
+
|
|
345
|
+
// D40 — the wave line's label carries the wave's task scope in braces (`W1 {1}`),
|
|
346
|
+
// not just the wave number (the board must show W4 = tasks 12,13,14).
|
|
347
|
+
expect(rendered[0]).toContain("W1 {1} ✔");
|
|
348
|
+
expect(rendered[1]).toContain("W2 {2} ▶");
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
it("degrades without error — no plan leaves the wave segment empty, no throw", () => {
|
|
352
|
+
seedProgress("o1-p2", { waves: [{ wave: "spec", rounds: { review: [1] } }] });
|
|
353
|
+
mkdirSync(path.join(repo, "docs/kairos/specs"), { recursive: true });
|
|
354
|
+
writeFileSync(path.join(repo, "docs/kairos/specs/o1-p2-design.md"), "# S\n");
|
|
355
|
+
|
|
356
|
+
const node = BoardView.projectNode("o1-p2", repo);
|
|
357
|
+
|
|
358
|
+
expect(node.waveLines ?? []).toEqual([]);
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
it("leaves the overall segment empty when the program carries no overall doc", () => {
|
|
362
|
+
seedProgress("o1-overall", { waves: [{ wave: "spec", rounds: { review: [1] } }] });
|
|
363
|
+
|
|
364
|
+
const node = BoardView.projectNode("o1-overall", repo);
|
|
365
|
+
|
|
366
|
+
expect(node.version).toBeNull();
|
|
367
|
+
expect(node.rounds).toEqual({ review: [1] });
|
|
368
|
+
});
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
describe("BoardView.render — the phase / program board layouts + the next derivation", () => {
|
|
372
|
+
let repo: string;
|
|
373
|
+
|
|
374
|
+
beforeEach(() => {
|
|
375
|
+
repo = mkdtempSync(path.join(tmpdir(), "board-render-"));
|
|
376
|
+
mkdirSync(path.join(repo, "docs/kairos/specs"), { recursive: true });
|
|
377
|
+
mkdirSync(path.join(repo, "docs/kairos/plans"), { recursive: true });
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
afterEach(() => {
|
|
381
|
+
rmSync(repo, { recursive: true, force: true });
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
/** Write a doc with a declared doc-type (the header declaration the board reads). */
|
|
385
|
+
const writeDoc = (rel: string, lines: readonly string[]): string => {
|
|
386
|
+
const file = path.join(repo, rel);
|
|
387
|
+
mkdirSync(path.dirname(file), { recursive: true });
|
|
388
|
+
writeFileSync(file, `${lines.join("\n")}\n`, "utf8");
|
|
389
|
+
return file;
|
|
390
|
+
};
|
|
391
|
+
|
|
392
|
+
/** Seed a node's own workspace progress.json. */
|
|
393
|
+
const seed = (slug: string, waves: unknown[]): void => {
|
|
394
|
+
const dir = path.join(repo, ".kairos/cdd", slug);
|
|
395
|
+
mkdirSync(dir, { recursive: true });
|
|
396
|
+
writeFileSync(
|
|
397
|
+
path.join(dir, "progress.json"),
|
|
398
|
+
JSON.stringify({ timeoutCount: 0, contractViolationCount: 0, waves }, null, 2),
|
|
399
|
+
);
|
|
400
|
+
};
|
|
401
|
+
|
|
402
|
+
const render = (slug: string, host = "claude"): { text: string; exitCode: number } => {
|
|
403
|
+
const board = BoardView.render(slug, repo, new Words(), host, ARGV_CHANNEL);
|
|
404
|
+
return { text: board.lines.join("\n"), exitCode: board.exitCode };
|
|
405
|
+
};
|
|
406
|
+
|
|
407
|
+
/** The board's `next:` value (the ` next: ` row, the anchor stripped). */
|
|
408
|
+
const nextOf = (slug: string, host = "claude"): string => {
|
|
409
|
+
const line = render(slug, host)
|
|
410
|
+
.text.split("\n")
|
|
411
|
+
.find((row) => row.startsWith(" next: "));
|
|
412
|
+
return line!.slice(" next: ".length);
|
|
413
|
+
};
|
|
414
|
+
|
|
415
|
+
it("renders the phase board header + rows + the fixed legend tail", () => {
|
|
416
|
+
writeDoc("docs/kairos/specs/prog-overall.md", ["# O", "", "- **Doc type**: overall-spec"]);
|
|
417
|
+
writeDoc("docs/kairos/specs/prog-p1-design.md", [
|
|
418
|
+
"# S",
|
|
419
|
+
"",
|
|
420
|
+
"- **Version**: v0.14",
|
|
421
|
+
"- **Status**: Done",
|
|
422
|
+
"- **Doc type**: phase-spec",
|
|
423
|
+
]);
|
|
424
|
+
writeDoc("docs/kairos/plans/prog-p1.md", [
|
|
425
|
+
"# Plan",
|
|
426
|
+
"",
|
|
427
|
+
"- **Version**: v0.9",
|
|
428
|
+
"- **Doc type**: plan",
|
|
429
|
+
]);
|
|
430
|
+
seed("prog-p1", [{ wave: "spec", rounds: { review: [1, 2], fix: [1] } }]);
|
|
431
|
+
|
|
432
|
+
const { text, exitCode } = render("prog-p1");
|
|
433
|
+
|
|
434
|
+
expect(exitCode).toBe(0);
|
|
435
|
+
expect(text).toContain("cdd board: prog-p1");
|
|
436
|
+
expect(text).toContain(" overall ");
|
|
437
|
+
expect(text).toContain("prog-p1-design.md v0.14 · Done");
|
|
438
|
+
expect(text).toContain("prog-p1.md v0.9");
|
|
439
|
+
expect(text).toContain(" branch ○ open");
|
|
440
|
+
expect(text.split("\n").at(-1)).toBe("progress: ✔ done · ▶ current · ○ pending");
|
|
441
|
+
});
|
|
442
|
+
|
|
443
|
+
it("renders one wave line per derived wave with the ✔/▶ markers", () => {
|
|
444
|
+
writeDoc("docs/kairos/specs/prog-overall.md", ["# O", "", "- **Doc type**: overall-spec"]);
|
|
445
|
+
writeDoc("docs/kairos/specs/prog-p1-design.md", ["# S", "", "- **Doc type**: phase-spec"]);
|
|
446
|
+
// Two task blocks → two waves.
|
|
447
|
+
writeDoc("docs/kairos/plans/prog-p1.md", [
|
|
448
|
+
"# Plan",
|
|
449
|
+
"",
|
|
450
|
+
"- **Doc type**: plan",
|
|
451
|
+
"",
|
|
452
|
+
"## Constraints",
|
|
453
|
+
"",
|
|
454
|
+
"- c",
|
|
455
|
+
"",
|
|
456
|
+
"### Task 1: a",
|
|
457
|
+
"- **Objective**: o",
|
|
458
|
+
"- **Files**: `a.ts`",
|
|
459
|
+
"- **Consumes**: x",
|
|
460
|
+
"- **Produces**: y",
|
|
461
|
+
"- **Steps**:",
|
|
462
|
+
" - s — checkable: g",
|
|
463
|
+
"- **Acceptance**: ok",
|
|
464
|
+
"- **DependsOn**: none",
|
|
465
|
+
"",
|
|
466
|
+
"### Task 2: b",
|
|
467
|
+
"- **Objective**: o",
|
|
468
|
+
"- **Files**: `b.ts`",
|
|
469
|
+
"- **Consumes**: x",
|
|
470
|
+
"- **Produces**: y",
|
|
471
|
+
"- **Steps**:",
|
|
472
|
+
" - s — checkable: g",
|
|
473
|
+
"- **Acceptance**: ok",
|
|
474
|
+
"- **DependsOn**: 1",
|
|
475
|
+
]);
|
|
476
|
+
// Close wave {1}: a recorded zero-findings review round.
|
|
477
|
+
const workspace = new Workspace(new WorkspaceRoot(repo, ".kairos/cdd"), "prog-p1").ensure();
|
|
478
|
+
const ledger = new Ledger(workspace, new ConfigLoader());
|
|
479
|
+
ledger.persistHandoff("review", "wave", { tasks: "1", round: 1 }, { findings: [] });
|
|
480
|
+
ledger.recordRound("1", "review");
|
|
481
|
+
|
|
482
|
+
const { text } = render("prog-p1");
|
|
483
|
+
|
|
484
|
+
// D40 — the wave line's label carries the wave's task scope in braces.
|
|
485
|
+
expect(text).toContain("W1 {1}");
|
|
486
|
+
expect(text).toContain("W2 {2}");
|
|
487
|
+
});
|
|
488
|
+
|
|
489
|
+
it("phase board next: the first not-closed line renders its ACTIVE C5 hop (the spec review)", () => {
|
|
490
|
+
// D40 deep-solve — the spec line has not started its C5 (no review round on record),
|
|
491
|
+
// so its ACTIVE hop is the review-lead the dispatch engine would run (Ledger#lineRoute
|
|
492
|
+
// → {kind:"review"}), NOT the exhausted-face handoff `/kairos:cdd-plan`. board next ==
|
|
493
|
+
// engine next (the retired shallow form rendered the face-to-face entry for an open line).
|
|
494
|
+
writeDoc("docs/kairos/specs/prog-overall.md", ["# O", "", "- **Doc type**: overall-spec"]);
|
|
495
|
+
writeDoc("docs/kairos/specs/prog-p1-design.md", ["# S", "", "- **Doc type**: phase-spec"]);
|
|
496
|
+
writeDoc("docs/kairos/plans/prog-p1.md", ["# Plan", "", "- **Doc type**: plan"]);
|
|
497
|
+
|
|
498
|
+
const { text } = render("prog-p1");
|
|
499
|
+
|
|
500
|
+
expect(text).toContain(
|
|
501
|
+
` next: review --type spec --spec ${path.join(repo, "docs/kairos/specs/prog-p1-design.md")}`,
|
|
502
|
+
);
|
|
503
|
+
expect(text).not.toContain(" next: /kairos:cdd-plan");
|
|
504
|
+
});
|
|
505
|
+
|
|
506
|
+
it("phase board next: spec closed + plan not started → the plan line's active review hop", () => {
|
|
507
|
+
writeDoc("docs/kairos/specs/prog-overall.md", ["# O", "", "- **Doc type**: overall-spec"]);
|
|
508
|
+
writeDoc("docs/kairos/specs/prog-p1-design.md", ["# S", "", "- **Doc type**: phase-spec"]);
|
|
509
|
+
writeDoc("docs/kairos/plans/prog-p1.md", ["# Plan", "", "- **Doc type**: plan"]);
|
|
510
|
+
// Close the spec line: a recorded zero-findings spec review.
|
|
511
|
+
const workspace = new Workspace(new WorkspaceRoot(repo, ".kairos/cdd"), "prog-p1").ensure();
|
|
512
|
+
const ledger = new Ledger(workspace, new ConfigLoader());
|
|
513
|
+
ledger.persistHandoff("review", "spec", { round: 1 }, { findings: [] });
|
|
514
|
+
ledger.recordRound("spec", "review");
|
|
515
|
+
|
|
516
|
+
const { text } = render("prog-p1");
|
|
517
|
+
|
|
518
|
+
// The spec face is exhausted → the plan line is the frontier; the plan line has not
|
|
519
|
+
// started its C5 → its ACTIVE hop is the plan review (not the cdd-dev handoff).
|
|
520
|
+
expect(text).toContain(
|
|
521
|
+
` next: review --type plan --plan ${path.join(repo, "docs/kairos/plans/prog-p1.md")}`,
|
|
522
|
+
);
|
|
523
|
+
expect(text).not.toContain(" next: /kairos:cdd-dev");
|
|
524
|
+
});
|
|
525
|
+
|
|
526
|
+
it("phase board next: a skipped-cycle plan line (`{review:[1,2], fix:[2]}`) is CLOSED — the engine's judge, not a count", () => {
|
|
527
|
+
// The drift-voided review-1 shape the reviewer's own P8 workspace carries. A
|
|
528
|
+
// count-based closure judge reads the nonexistent fix cycle 1 → plan OPEN → the
|
|
529
|
+
// plan entry; the engine's identity judge reads the fix at cycle 2 → plan CLOSED
|
|
530
|
+
// → next advances past the plan face.
|
|
531
|
+
writeDoc("docs/kairos/specs/prog-overall.md", ["# O", "", "- **Doc type**: overall-spec"]);
|
|
532
|
+
writeDoc("docs/kairos/specs/prog-p1-design.md", ["# S", "", "- **Doc type**: phase-spec"]);
|
|
533
|
+
writeDoc("docs/kairos/plans/prog-p1.md", ["# Plan", "", "- **Doc type**: plan"]);
|
|
534
|
+
const workspace = new Workspace(new WorkspaceRoot(repo, ".kairos/cdd"), "prog-p1").ensure();
|
|
535
|
+
const ledger = new Ledger(workspace, new ConfigLoader());
|
|
536
|
+
// spec closed (a recorded zero-findings spec review)
|
|
537
|
+
ledger.persistHandoff("review", "spec", { round: 1 }, { findings: [] });
|
|
538
|
+
ledger.recordRound("spec", "review");
|
|
539
|
+
// plan closed by identity: review cycles [1,2], the fix at its own cycle 2
|
|
540
|
+
ledger.persistHandoff("review", "plan", { round: 2 }, { findings: [] });
|
|
541
|
+
ledger.persistHandoff("fix", "plan", { round: 2 }, { findings: [] });
|
|
542
|
+
ledger.recordRound("plan", "review", 1);
|
|
543
|
+
ledger.recordRound("plan", "review", 2);
|
|
544
|
+
ledger.recordRound("plan", "fix", 2);
|
|
545
|
+
|
|
546
|
+
const { text } = render("prog-p1");
|
|
547
|
+
|
|
548
|
+
// plan closed → past the plan face; no plan task blocks → the wave face is the frontier
|
|
549
|
+
expect(text).not.toContain(" next: /kairos:cdd-dev");
|
|
550
|
+
expect(text).toContain(" next: review --type branch --plan");
|
|
551
|
+
});
|
|
552
|
+
|
|
553
|
+
it("D40 — a skipped-cycle row's board judgment EQUALS the engine's Ledger#lineClosed verdict", () => {
|
|
554
|
+
// The board's `next:` walk now delegates its closure reads to Ledger#lineClosed
|
|
555
|
+
// (the single judge) — a jump-number row `{review:[1,2], fix:[2]}` (D28) must read
|
|
556
|
+
// CLOSED on BOTH faces. A count-based board judge (the retired hand-rolled form)
|
|
557
|
+
// would read it OPEN and diverge from the engine.
|
|
558
|
+
writeDoc("docs/kairos/specs/prog-overall.md", ["# O", "", "- **Doc type**: overall-spec"]);
|
|
559
|
+
writeDoc("docs/kairos/specs/prog-p1-design.md", ["# S", "", "- **Doc type**: phase-spec"]);
|
|
560
|
+
writeDoc("docs/kairos/plans/prog-p1.md", ["# Plan", "", "- **Doc type**: plan"]);
|
|
561
|
+
const workspace = new Workspace(new WorkspaceRoot(repo, ".kairos/cdd"), "prog-p1").ensure();
|
|
562
|
+
const ledger = new Ledger(workspace, new ConfigLoader());
|
|
563
|
+
ledger.persistHandoff("review", "plan", { round: 2 }, { findings: [] });
|
|
564
|
+
ledger.persistHandoff("fix", "plan", { round: 2 }, { findings: [] });
|
|
565
|
+
ledger.recordRound("plan", "review", 1);
|
|
566
|
+
ledger.recordRound("plan", "review", 2);
|
|
567
|
+
ledger.recordRound("plan", "fix", 2);
|
|
568
|
+
|
|
569
|
+
// The engine judge: the plan line is CLOSED (the fix at its own cycle 2, D28).
|
|
570
|
+
expect(ledger.lineClosed("plan", "plan")).toBe(true);
|
|
571
|
+
// The board consumes that SAME judge — the plan face is exhausted.
|
|
572
|
+
const { text } = render("prog-p1");
|
|
573
|
+
expect(text).not.toContain(" next: /kairos:cdd-dev");
|
|
574
|
+
});
|
|
575
|
+
|
|
576
|
+
it("D40 — the wave line's label carries the wave's task scope (W3 = tasks 5,11)", () => {
|
|
577
|
+
writeDoc("docs/kairos/specs/prog-overall.md", ["# O", "", "- **Doc type**: overall-spec"]);
|
|
578
|
+
writeDoc("docs/kairos/specs/prog-p1-design.md", ["# S", "", "- **Doc type**: phase-spec"]);
|
|
579
|
+
writeDoc("docs/kairos/plans/prog-p1.md", [
|
|
580
|
+
"# Plan",
|
|
581
|
+
"",
|
|
582
|
+
"- **Doc type**: plan",
|
|
583
|
+
"",
|
|
584
|
+
"## Constraints",
|
|
585
|
+
"",
|
|
586
|
+
"- c",
|
|
587
|
+
"",
|
|
588
|
+
"### Task 5: a",
|
|
589
|
+
"- **Objective**: o",
|
|
590
|
+
"- **Files**: `a.ts`",
|
|
591
|
+
"- **Consumes**: x",
|
|
592
|
+
"- **Produces**: y",
|
|
593
|
+
"- **Steps**:",
|
|
594
|
+
" - s — checkable: g",
|
|
595
|
+
"- **Acceptance**: ok",
|
|
596
|
+
"- **DependsOn**: none",
|
|
597
|
+
"",
|
|
598
|
+
"### Task 11: b",
|
|
599
|
+
"- **Objective**: o",
|
|
600
|
+
"- **Files**: `b.ts`",
|
|
601
|
+
"- **Consumes**: x",
|
|
602
|
+
"- **Produces**: y",
|
|
603
|
+
"- **Steps**:",
|
|
604
|
+
" - s — checkable: g",
|
|
605
|
+
"- **Acceptance**: ok",
|
|
606
|
+
"- **DependsOn**: none",
|
|
607
|
+
]);
|
|
608
|
+
|
|
609
|
+
const node = BoardView.projectNode("prog-p1", repo);
|
|
610
|
+
const labels = (node.waveLines ?? []).map((line) => line.label);
|
|
611
|
+
|
|
612
|
+
// The wave's task ids ride the label in braces (a reader sees `W1 {5,11}`, not a
|
|
613
|
+
// bare W1) — the spec §5.2 `W{n} {<ids>}` form.
|
|
614
|
+
expect(labels[0]).toBe("W1 {5,11}");
|
|
615
|
+
const { text } = render("prog-p1");
|
|
616
|
+
expect(text).toContain("W1 {5,11}");
|
|
617
|
+
});
|
|
618
|
+
|
|
619
|
+
it("D40 — a wave in flight renders the wave line's ACTIVE C5 hop, not the face handoff", () => {
|
|
620
|
+
// The deep-solve (spec §18.1 live case): W1 is closed, W2 ({12,13,14}) is the open
|
|
621
|
+
// frontier with no implement yet — its active C5 hop is the whole-wave implement
|
|
622
|
+
// (`implement --plan <plan> --tasks 12,13,14`), NOT the exhausted-wave face handoff
|
|
623
|
+
// (`review --type branch …`). A shallow `resolve(null, …)` renders the branch-review
|
|
624
|
+
// handoff here — the bug (W4 in flight rendering branch review) this pin drives out.
|
|
625
|
+
writeDoc("docs/kairos/specs/prog-overall.md", ["# O", "", "- **Doc type**: overall-spec"]);
|
|
626
|
+
writeDoc("docs/kairos/specs/prog-p1-design.md", ["# S", "", "- **Doc type**: phase-spec"]);
|
|
627
|
+
writeDoc("docs/kairos/plans/prog-p1.md", [
|
|
628
|
+
"# Plan",
|
|
629
|
+
"",
|
|
630
|
+
"- **Doc type**: plan",
|
|
631
|
+
"",
|
|
632
|
+
"## Constraints",
|
|
633
|
+
"",
|
|
634
|
+
"- c",
|
|
635
|
+
"",
|
|
636
|
+
"### Task 5: a",
|
|
637
|
+
"- **Objective**: o",
|
|
638
|
+
"- **Files**: `a.ts`",
|
|
639
|
+
"- **Consumes**: x",
|
|
640
|
+
"- **Produces**: y",
|
|
641
|
+
"- **Steps**:",
|
|
642
|
+
" - s — checkable: g",
|
|
643
|
+
"- **Acceptance**: ok",
|
|
644
|
+
"- **DependsOn**: none",
|
|
645
|
+
"",
|
|
646
|
+
"### Task 12: b",
|
|
647
|
+
"- **Objective**: o",
|
|
648
|
+
"- **Files**: `b.ts`",
|
|
649
|
+
"- **Consumes**: x",
|
|
650
|
+
"- **Produces**: y",
|
|
651
|
+
"- **Steps**:",
|
|
652
|
+
" - s — checkable: g",
|
|
653
|
+
"- **Acceptance**: ok",
|
|
654
|
+
"- **DependsOn**: 5",
|
|
655
|
+
"",
|
|
656
|
+
"### Task 13: c",
|
|
657
|
+
"- **Objective**: o",
|
|
658
|
+
"- **Files**: `c.ts`",
|
|
659
|
+
"- **Consumes**: x",
|
|
660
|
+
"- **Produces**: y",
|
|
661
|
+
"- **Steps**:",
|
|
662
|
+
" - s — checkable: g",
|
|
663
|
+
"- **Acceptance**: ok",
|
|
664
|
+
"- **DependsOn**: 5",
|
|
665
|
+
"",
|
|
666
|
+
"### Task 14: d",
|
|
667
|
+
"- **Objective**: o",
|
|
668
|
+
"- **Files**: `d.ts`",
|
|
669
|
+
"- **Consumes**: x",
|
|
670
|
+
"- **Produces**: y",
|
|
671
|
+
"- **Steps**:",
|
|
672
|
+
" - s — checkable: g",
|
|
673
|
+
"- **Acceptance**: ok",
|
|
674
|
+
"- **DependsOn**: 5",
|
|
675
|
+
]);
|
|
676
|
+
const workspace = new Workspace(new WorkspaceRoot(repo, ".kairos/cdd"), "prog-p1").ensure();
|
|
677
|
+
const ledger = new Ledger(workspace, new ConfigLoader());
|
|
678
|
+
// Close the spec and plan lines (a recorded zero-findings review each) so the wave
|
|
679
|
+
// face IS the frontier.
|
|
680
|
+
ledger.persistHandoff("review", "spec", { round: 1 }, { findings: [] });
|
|
681
|
+
ledger.recordRound("spec", "review");
|
|
682
|
+
ledger.persistHandoff("review", "plan", { round: 1 }, { findings: [] });
|
|
683
|
+
ledger.recordRound("plan", "review");
|
|
684
|
+
// W1 ({5}) closed: a recorded zero-findings review round.
|
|
685
|
+
ledger.persistHandoff("review", "wave", { tasks: "5", round: 1 }, { findings: [] });
|
|
686
|
+
ledger.recordRound("5", "review");
|
|
687
|
+
// W2 ({12,13,14}) is the open frontier with NO implement yet — its active C5 hop is
|
|
688
|
+
// the whole-wave implement (spec §18.4 live case: W4 in flight → `implement --tasks
|
|
689
|
+
// 12,13,14`, never the exhausted-wave face handoff `review --type branch`).
|
|
690
|
+
|
|
691
|
+
const { text } = render("prog-p1");
|
|
692
|
+
const planPath = path.join(repo, "docs/kairos/plans/prog-p1.md");
|
|
693
|
+
|
|
694
|
+
// The active wave hop — the not-yet-implemented wave renders its implement literal.
|
|
695
|
+
expect(text).toContain(` next: implement --plan ${planPath} --tasks 12,13,14`);
|
|
696
|
+
// NOT the exhausted-wave face handoff (the shallow resolve(null, …) bug).
|
|
697
|
+
expect(text).not.toContain("review --type branch");
|
|
698
|
+
});
|
|
699
|
+
|
|
700
|
+
it("D40 — the wave-line markers align into one fixed-width column across differing id-set widths", () => {
|
|
701
|
+
writeDoc("docs/kairos/specs/prog-overall.md", ["# O", "", "- **Doc type**: overall-spec"]);
|
|
702
|
+
writeDoc("docs/kairos/specs/prog-p1-design.md", ["# S", "", "- **Doc type**: phase-spec"]);
|
|
703
|
+
writeDoc("docs/kairos/plans/prog-p1.md", [
|
|
704
|
+
"# Plan",
|
|
705
|
+
"",
|
|
706
|
+
"- **Doc type**: plan",
|
|
707
|
+
"",
|
|
708
|
+
"## Constraints",
|
|
709
|
+
"",
|
|
710
|
+
"- c",
|
|
711
|
+
"",
|
|
712
|
+
"### Task 1: a",
|
|
713
|
+
"- **Objective**: o",
|
|
714
|
+
"- **Files**: `a.ts`",
|
|
715
|
+
"- **Consumes**: x",
|
|
716
|
+
"- **Produces**: y",
|
|
717
|
+
"- **Steps**:",
|
|
718
|
+
" - s — checkable: g",
|
|
719
|
+
"- **Acceptance**: ok",
|
|
720
|
+
"- **DependsOn**: none",
|
|
721
|
+
"",
|
|
722
|
+
"### Task 2: b",
|
|
723
|
+
"- **Objective**: o",
|
|
724
|
+
"- **Files**: `b.ts`",
|
|
725
|
+
"- **Consumes**: x",
|
|
726
|
+
"- **Produces**: y",
|
|
727
|
+
"- **Steps**:",
|
|
728
|
+
" - s — checkable: g",
|
|
729
|
+
"- **Acceptance**: ok",
|
|
730
|
+
"- **DependsOn**: 1",
|
|
731
|
+
"",
|
|
732
|
+
"### Task 3: c",
|
|
733
|
+
"- **Objective**: o",
|
|
734
|
+
"- **Files**: `c.ts`",
|
|
735
|
+
"- **Consumes**: x",
|
|
736
|
+
"- **Produces**: y",
|
|
737
|
+
"- **Steps**:",
|
|
738
|
+
" - s — checkable: g",
|
|
739
|
+
"- **Acceptance**: ok",
|
|
740
|
+
"- **DependsOn**: 1",
|
|
741
|
+
"",
|
|
742
|
+
"### Task 4: d",
|
|
743
|
+
"- **Objective**: o",
|
|
744
|
+
"- **Files**: `d.ts`",
|
|
745
|
+
"- **Consumes**: x",
|
|
746
|
+
"- **Produces**: y",
|
|
747
|
+
"- **Steps**:",
|
|
748
|
+
" - s — checkable: g",
|
|
749
|
+
"- **Acceptance**: ok",
|
|
750
|
+
"- **DependsOn**: 1,2,3",
|
|
751
|
+
]);
|
|
752
|
+
// Close W1 ({1}) — a recorded zero-findings review at the "1" row.
|
|
753
|
+
const workspace = new Workspace(new WorkspaceRoot(repo, ".kairos/cdd"), "prog-p1").ensure();
|
|
754
|
+
const ledger = new Ledger(workspace, new ConfigLoader());
|
|
755
|
+
ledger.persistHandoff("review", "wave", { tasks: "1", round: 1 }, { findings: [] });
|
|
756
|
+
ledger.recordRound("1", "review");
|
|
757
|
+
|
|
758
|
+
const { text } = render("prog-p1");
|
|
759
|
+
// W1 {1} (narrow) and W2 {2,3} / W3 {4} (wider) — the markers must share one column.
|
|
760
|
+
const waveRows = text.split("\n").filter((line) => /W\d+ \{/.test(line));
|
|
761
|
+
expect(waveRows.length).toBe(3);
|
|
762
|
+
const markerColumns = waveRows.map((row) => row.search(/[✔▶○]/));
|
|
763
|
+
// Every wave row places its ✔/▶/○ marker at the exact same column index.
|
|
764
|
+
expect(new Set(markerColumns).size).toBe(1);
|
|
765
|
+
});
|
|
766
|
+
|
|
767
|
+
it("phase board next: a drained line hands off to the next face's skill ref (host fallback)", () => {
|
|
768
|
+
// D40 deep-solve — the spec line is closed and NO plan doc exists: the plan line
|
|
769
|
+
// (not closed — no row) holds no active C5 hop (no doc), so it hands off to its
|
|
770
|
+
// pipeline entry `PIPELINE_NEXT.plan` → the cdd-dev ref. The board renders that
|
|
771
|
+
// through the SAME RouteRenderer the Capsule's `done` face uses; host "" falls
|
|
772
|
+
// back to the claude form (REFS[ref].claude) — never a bare plugin guess.
|
|
773
|
+
writeDoc("docs/kairos/specs/prog-overall.md", ["# O", "", "- **Doc type**: overall-spec"]);
|
|
774
|
+
writeDoc("docs/kairos/specs/prog-p1-design.md", ["# S", "", "- **Doc type**: phase-spec"]);
|
|
775
|
+
const workspace = new Workspace(new WorkspaceRoot(repo, ".kairos/cdd"), "prog-p1").ensure();
|
|
776
|
+
const ledger = new Ledger(workspace, new ConfigLoader());
|
|
777
|
+
ledger.persistHandoff("review", "spec", { round: 1 }, { findings: [] });
|
|
778
|
+
ledger.recordRound("spec", "review");
|
|
779
|
+
|
|
780
|
+
const { text } = render("prog-p1", "");
|
|
781
|
+
|
|
782
|
+
expect(text).toContain(" next: /kairos:cdd-dev");
|
|
783
|
+
});
|
|
784
|
+
|
|
785
|
+
it("board per-harness ref pins — a drained line renders REFS[ref][host] (host=pi → /skill:…)", () => {
|
|
786
|
+
// The board's per-harness spelling rides REFS[ref][host] (never a claude-form
|
|
787
|
+
// constant). The reachable refs on the phase board's per-line walk: the spec face
|
|
788
|
+
// (no spec doc → the cdd-plan entry) and the plan face (spec closed + no plan doc
|
|
789
|
+
// → the cdd-dev entry). host=pi renders the flat `/skill:<bare>` form.
|
|
790
|
+
writeDoc("docs/kairos/specs/prog-overall.md", ["# O", "", "- **Doc type**: overall-spec"]);
|
|
791
|
+
// The spec face is the frontier with no spec doc → PIPELINE_NEXT."phase-spec" → cdd-plan.
|
|
792
|
+
expect(nextOf("prog-p1", "pi")).toBe("/skill:cdd-plan");
|
|
793
|
+
expect(nextOf("prog-p1", "claude")).toBe("/kairos:cdd-plan");
|
|
794
|
+
|
|
795
|
+
// Close the spec line so the plan face is the frontier; no plan doc → the cdd-dev ref.
|
|
796
|
+
writeDoc("docs/kairos/specs/prog-p1-design.md", ["# S", "", "- **Doc type**: phase-spec"]);
|
|
797
|
+
const workspace = new Workspace(new WorkspaceRoot(repo, ".kairos/cdd"), "prog-p1").ensure();
|
|
798
|
+
const ledger = new Ledger(workspace, new ConfigLoader());
|
|
799
|
+
ledger.persistHandoff("review", "spec", { round: 1 }, { findings: [] });
|
|
800
|
+
ledger.recordRound("spec", "review");
|
|
801
|
+
expect(nextOf("prog-p1", "pi")).toBe("/skill:cdd-dev");
|
|
802
|
+
expect(nextOf("prog-p1", "claude")).toBe("/kairos:cdd-dev");
|
|
803
|
+
});
|
|
804
|
+
|
|
805
|
+
it("board next == the Capsule's done face — the shared renderer byte-identity (host claude / pi)", () => {
|
|
806
|
+
// route-render.ts claims the board's `next:` and the capsule's `next:` are
|
|
807
|
+
// byte-identical by construction (ONE RouteRenderer). Pin it: a drained plan face
|
|
808
|
+
// hands off to the SAME pipeline entry through both seams, and both seams now read
|
|
809
|
+
// the SAME argv channel (the board is threaded ARGV_CHANNEL from the composition
|
|
810
|
+
// root) — a flag-spelling change cannot silently split the two faces.
|
|
811
|
+
writeDoc("docs/kairos/specs/prog-overall.md", ["# O", "", "- **Doc type**: overall-spec"]);
|
|
812
|
+
writeDoc("docs/kairos/specs/prog-p1-design.md", ["# S", "", "- **Doc type**: phase-spec"]);
|
|
813
|
+
const workspace = new Workspace(new WorkspaceRoot(repo, ".kairos/cdd"), "prog-p1").ensure();
|
|
814
|
+
const ledger = new Ledger(workspace, new ConfigLoader());
|
|
815
|
+
ledger.persistHandoff("review", "spec", { round: 1 }, { findings: [] });
|
|
816
|
+
ledger.recordRound("spec", "review");
|
|
817
|
+
const planId = path.join(repo, "docs/kairos/plans/prog-p1.md");
|
|
818
|
+
|
|
819
|
+
for (const host of ["claude", "pi"]) {
|
|
820
|
+
const capsuleNext = new Capsule(new Words(), ARGV_CHANNEL, host, repo)
|
|
821
|
+
.emit("APPROVED", "0", "/h.json", { kind: "done" }, { type: "plan", id: planId })[1]!
|
|
822
|
+
.slice("next: ".length);
|
|
823
|
+
// The board's plan face is drained (spec closed + no plan doc) → the same entry.
|
|
824
|
+
expect(nextOf("prog-p1", host)).toBe(capsuleNext);
|
|
825
|
+
expect(capsuleNext).toBe(host === "pi" ? "/skill:cdd-dev" : "/kairos:cdd-dev");
|
|
826
|
+
}
|
|
827
|
+
});
|
|
828
|
+
|
|
829
|
+
it("a present doc without a Doc type declaration renders BLOCKED and exits 2", () => {
|
|
830
|
+
writeDoc("docs/kairos/specs/prog-overall.md", ["# O", "", "- **Doc type**: overall-spec"]);
|
|
831
|
+
// The spec doc carries NO `- **Doc type**:` line.
|
|
832
|
+
writeDoc("docs/kairos/specs/prog-p1-design.md", ["# S", "", "- **Version**: v1.0"]);
|
|
833
|
+
writeDoc("docs/kairos/plans/prog-p1.md", ["# Plan", "", "- **Doc type**: plan"]);
|
|
834
|
+
|
|
835
|
+
const { text, exitCode } = render("prog-p1");
|
|
836
|
+
|
|
837
|
+
expect(exitCode).toBe(2);
|
|
838
|
+
expect(text).toContain("doc-type: missing (BLOCKED)");
|
|
839
|
+
});
|
|
840
|
+
|
|
841
|
+
it("renders the program board with one phase summary line + next: done", () => {
|
|
842
|
+
writeDoc("docs/kairos/specs/prog-overall.md", [
|
|
843
|
+
"# O",
|
|
844
|
+
"",
|
|
845
|
+
"- **Version**: v2.33",
|
|
846
|
+
"- **Doc type**: overall-spec",
|
|
847
|
+
]);
|
|
848
|
+
writeDoc("docs/kairos/specs/prog-p1-design.md", ["# S", "", "- **Doc type**: phase-spec"]);
|
|
849
|
+
// Two task blocks → two waves, so the phase line carries its `wave W1…` token (spec §5.3).
|
|
850
|
+
writeDoc("docs/kairos/plans/prog-p1.md", [
|
|
851
|
+
"# Plan",
|
|
852
|
+
"",
|
|
853
|
+
"- **Doc type**: plan",
|
|
854
|
+
"",
|
|
855
|
+
"## Constraints",
|
|
856
|
+
"",
|
|
857
|
+
"- c",
|
|
858
|
+
"",
|
|
859
|
+
"### Task 1: a",
|
|
860
|
+
"- **Objective**: o",
|
|
861
|
+
"- **Files**: `a.ts`",
|
|
862
|
+
"- **Consumes**: x",
|
|
863
|
+
"- **Produces**: y",
|
|
864
|
+
"- **Steps**:",
|
|
865
|
+
" - s — checkable: g",
|
|
866
|
+
"- **Acceptance**: ok",
|
|
867
|
+
"- **DependsOn**: none",
|
|
868
|
+
"",
|
|
869
|
+
"### Task 2: b",
|
|
870
|
+
"- **Objective**: o",
|
|
871
|
+
"- **Files**: `b.ts`",
|
|
872
|
+
"- **Consumes**: x",
|
|
873
|
+
"- **Produces**: y",
|
|
874
|
+
"- **Steps**:",
|
|
875
|
+
" - s — checkable: g",
|
|
876
|
+
"- **Acceptance**: ok",
|
|
877
|
+
"- **DependsOn**: 1",
|
|
878
|
+
]);
|
|
879
|
+
seed("prog-overall", [{ wave: "spec", rounds: { review: [1, 2, 3, 4] } }]);
|
|
880
|
+
seed("prog-p1", [
|
|
881
|
+
{ wave: "spec", rounds: { review: [1] } },
|
|
882
|
+
{ wave: "plan", rounds: { review: [1] } },
|
|
883
|
+
{ wave: "branch", rounds: { "branch-review": [1] } },
|
|
884
|
+
]);
|
|
885
|
+
|
|
886
|
+
const { text, exitCode } = render("prog");
|
|
887
|
+
|
|
888
|
+
expect(exitCode).toBe(0);
|
|
889
|
+
expect(text).toContain("cdd board: prog");
|
|
890
|
+
expect(text).toContain("prog-overall.md v2.33 review×4" /* 4 cycle numbers → ×4 */);
|
|
891
|
+
// The full phase line shape (spec §5.3): status + the spec/plan/wave/branch cells,
|
|
892
|
+
// the `wave W1…` token derived from the phase's own wave segment.
|
|
893
|
+
expect(text).toContain(
|
|
894
|
+
" phase P1 Pending spec review×1 · plan review×1 · wave W1… · branch branch-review×1",
|
|
895
|
+
);
|
|
896
|
+
expect(text).toContain(" next: done");
|
|
897
|
+
});
|
|
898
|
+
|
|
899
|
+
it("the program board propagates a phase doc-type BLOCK — a present phase spec without a declaration exits 2", () => {
|
|
900
|
+
writeDoc("docs/kairos/specs/prog-overall.md", ["# O", "", "- **Doc type**: overall-spec"]);
|
|
901
|
+
// The phase spec carries NO `- **Doc type**:` line — the phase board BLOCKs it;
|
|
902
|
+
// the program board must propagate the SAME BLOCK (no silent fallback, spec §12).
|
|
903
|
+
writeDoc("docs/kairos/specs/prog-p1-design.md", ["# S", "", "- **Version**: v1.0"]);
|
|
904
|
+
writeDoc("docs/kairos/plans/prog-p1.md", ["# Plan", "", "- **Doc type**: plan"]);
|
|
905
|
+
|
|
906
|
+
const { text, exitCode } = render("prog");
|
|
907
|
+
|
|
908
|
+
expect(exitCode).toBe(2);
|
|
909
|
+
expect(text).toContain(" phase P1 doc-type: missing (BLOCKED)");
|
|
910
|
+
});
|
|
911
|
+
|
|
912
|
+
it("degrades without error — an absent plan leaves the wave segment empty", () => {
|
|
913
|
+
writeDoc("docs/kairos/specs/prog-overall.md", ["# O", "", "- **Doc type**: overall-spec"]);
|
|
914
|
+
writeDoc("docs/kairos/specs/prog-p1-design.md", ["# S", "", "- **Doc type**: phase-spec"]);
|
|
915
|
+
|
|
916
|
+
const board = BoardView.render("prog-p1", repo, new Words(), "claude");
|
|
917
|
+
|
|
918
|
+
expect(board.lines.join("\n")).toContain(" wave (none)");
|
|
919
|
+
});
|
|
920
|
+
});
|
|
921
|
+
|
|
922
|
+
describe("BoardView.hasNode — the file-system-only existence test", () => {
|
|
923
|
+
let repo: string;
|
|
924
|
+
|
|
925
|
+
beforeEach(() => {
|
|
926
|
+
repo = mkdtempSync(path.join(tmpdir(), "board-hasnode-"));
|
|
927
|
+
mkdirSync(path.join(repo, "docs/kairos/specs"), { recursive: true });
|
|
928
|
+
});
|
|
929
|
+
|
|
930
|
+
afterEach(() => {
|
|
931
|
+
rmSync(repo, { recursive: true, force: true });
|
|
932
|
+
});
|
|
933
|
+
|
|
934
|
+
it("a ghost slug matches nothing on disk", () => {
|
|
935
|
+
expect(BoardView.hasNode("ghost", repo)).toBe(false);
|
|
936
|
+
expect(BoardView.hasNode("ghost-p9", repo)).toBe(false);
|
|
937
|
+
});
|
|
938
|
+
|
|
939
|
+
it("a program slug matches its overall", () => {
|
|
940
|
+
writeFileSync(path.join(repo, "docs/kairos/specs/prog-overall.md"), "# O\n");
|
|
941
|
+
expect(BoardView.hasNode("prog", repo)).toBe(true);
|
|
942
|
+
});
|
|
943
|
+
|
|
944
|
+
it("a phase slug matches its on-disk spec", () => {
|
|
945
|
+
writeFileSync(path.join(repo, "docs/kairos/specs/prog-p1-design.md"), "# S\n");
|
|
946
|
+
expect(BoardView.hasNode("prog-p1", repo)).toBe(true);
|
|
947
|
+
});
|
|
948
|
+
});
|