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