@oscaner-skills/cdd-engine 3.0.0 → 3.1.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/{src-next/bin.ts → dist/bin.js} +18 -21
- package/dist/contract/declare.js +998 -0
- package/dist/contract/doc.js +565 -0
- package/dist/contract/frontmatter.js +209 -0
- package/dist/contract/home-extractors.js +379 -0
- package/dist/contract/invariants.js +1030 -0
- package/dist/contract/judge.js +109 -0
- package/dist/contract/lint.js +206 -0
- package/dist/contract/project.js +371 -0
- package/dist/contract/skill-anatomy.js +156 -0
- package/dist/contract/translate.js +85 -0
- package/dist/face/artifacts.js +189 -0
- package/dist/face/board-view.js +522 -0
- package/dist/face/capsule.js +149 -0
- package/dist/face/cli.js +893 -0
- package/dist/face/declare.js +241 -0
- package/dist/face/gate.js +158 -0
- package/dist/face/graph-view.js +66 -0
- package/dist/face/host.js +211 -0
- package/dist/face/lifecycle.js +702 -0
- package/dist/face/preview.js +136 -0
- package/dist/face/projection.js +259 -0
- package/dist/face/route-render.js +162 -0
- package/dist/face/termination.js +504 -0
- package/dist/face/words.js +258 -0
- package/{src-next/infra/config.ts → dist/infra/config.js} +19 -24
- package/{src-next/infra/doc-roots.ts → dist/infra/doc-roots.js} +3 -13
- package/dist/infra/git.js +37 -0
- package/dist/infra/process.js +22 -0
- package/{src-next/infra/root.ts → dist/infra/root.js} +25 -36
- package/dist/infra/runtime.js +85 -0
- package/dist/infra/workspace.js +276 -0
- package/dist/render/brief.js +82 -0
- package/dist/render/issue-body.js +129 -0
- package/dist/render/skeleton.js +434 -0
- package/dist/render/templates.js +520 -0
- package/dist/session/faces.js +38 -0
- package/dist/session/graph.js +309 -0
- package/dist/session/handoff-schema.js +295 -0
- package/dist/session/ledger.js +762 -0
- package/dist/session/next.js +211 -0
- package/dist/session/preflight.js +194 -0
- package/dist/session/round-naming.js +73 -0
- package/dist/session/run.js +453 -0
- package/dist/session/state.js +8 -0
- package/dist/session/wave.js +92 -0
- package/package.json +5 -5
- package/src-next/__tests__/bin.test.ts +0 -128
- package/src-next/__tests__/dead-decl.guard.test.ts +0 -39
- package/src-next/__tests__/floor.guard.test.ts +0 -69
- package/src-next/__tests__/issue-body.guard.test.ts +0 -66
- package/src-next/__tests__/phase-suffix.guard.test.ts +0 -72
- package/src-next/__tests__/smoke.integration.test.ts +0 -185
- package/src-next/__tests__/support/strip-comments.ts +0 -99
- package/src-next/__tests__/zero-dep.test.ts +0 -94
- package/src-next/contract/__tests__/__snapshots__/project.schema.overall-spec.snap +0 -256
- package/src-next/contract/__tests__/__snapshots__/project.schema.phase-spec.snap +0 -165
- package/src-next/contract/__tests__/__snapshots__/project.schema.plan.snap +0 -190
- package/src-next/contract/__tests__/__snapshots__/project.schema.single-spec.snap +0 -106
- package/src-next/contract/__tests__/__snapshots__/project.shape.overall-spec.snap +0 -240
- package/src-next/contract/__tests__/__snapshots__/project.shape.phase-spec.snap +0 -165
- package/src-next/contract/__tests__/__snapshots__/project.shape.plan.snap +0 -190
- package/src-next/contract/__tests__/__snapshots__/project.shape.single-spec.snap +0 -100
- package/src-next/contract/__tests__/declare.test.ts +0 -481
- package/src-next/contract/__tests__/doc.test.ts +0 -527
- package/src-next/contract/__tests__/dockey.guard.test.ts +0 -58
- package/src-next/contract/__tests__/edge-conditions.guard.test.ts +0 -81
- package/src-next/contract/__tests__/frontmatter.test.ts +0 -164
- package/src-next/contract/__tests__/judge.test.ts +0 -1111
- package/src-next/contract/__tests__/lint.test.ts +0 -324
- package/src-next/contract/__tests__/project.test.ts +0 -460
- package/src-next/contract/__tests__/structure-pin.test.ts +0 -186
- package/src-next/contract/__tests__/translate.test.ts +0 -96
- package/src-next/contract/declare.ts +0 -1071
- package/src-next/contract/doc.ts +0 -816
- package/src-next/contract/frontmatter.ts +0 -233
- package/src-next/contract/home-extractors.ts +0 -397
- package/src-next/contract/invariants.ts +0 -1413
- package/src-next/contract/judge.ts +0 -151
- package/src-next/contract/lint.ts +0 -239
- package/src-next/contract/project.ts +0 -656
- package/src-next/contract/skill-anatomy.ts +0 -301
- package/src-next/contract/translate.ts +0 -113
- package/src-next/face/__tests__/board-view.test.ts +0 -1151
- package/src-next/face/__tests__/capsule.test.ts +0 -300
- package/src-next/face/__tests__/channel-closure.guard.test.ts +0 -129
- package/src-next/face/__tests__/cli.test.ts +0 -4897
- package/src-next/face/__tests__/face.test.ts +0 -289
- package/src-next/face/__tests__/graph-view.test.ts +0 -61
- package/src-next/face/__tests__/host.test.ts +0 -24
- package/src-next/face/__tests__/install-rows.guard.test.ts +0 -58
- package/src-next/face/__tests__/negation.ts +0 -6
- package/src-next/face/__tests__/preview.test.ts +0 -374
- package/src-next/face/__tests__/projection.test.ts +0 -303
- package/src-next/face/__tests__/repo-root.guard.test.ts +0 -120
- package/src-next/face/__tests__/termination.test.ts +0 -650
- package/src-next/face/__tests__/words.guard.test.ts +0 -93
- package/src-next/face/artifacts.ts +0 -248
- package/src-next/face/board-view.ts +0 -652
- package/src-next/face/capsule.ts +0 -163
- package/src-next/face/cli.ts +0 -1028
- package/src-next/face/declare.ts +0 -323
- package/src-next/face/gate.ts +0 -171
- package/src-next/face/graph-view.ts +0 -74
- package/src-next/face/host.ts +0 -302
- package/src-next/face/lifecycle.ts +0 -725
- package/src-next/face/preview.ts +0 -151
- package/src-next/face/projection.ts +0 -285
- package/src-next/face/route-render.ts +0 -185
- package/src-next/face/termination.ts +0 -573
- package/src-next/face/words.ts +0 -314
- package/src-next/infra/__tests__/infra.test.ts +0 -333
- package/src-next/infra/__tests__/root.test.ts +0 -56
- package/src-next/infra/git.ts +0 -39
- package/src-next/infra/process.ts +0 -34
- package/src-next/infra/runtime.ts +0 -132
- package/src-next/infra/workspace.ts +0 -322
- package/src-next/render/__tests__/render.test.ts +0 -550
- package/src-next/render/__tests__/skeleton.test.ts +0 -684
- package/src-next/render/brief.ts +0 -121
- package/src-next/render/issue-body.ts +0 -162
- package/src-next/render/skeleton.ts +0 -502
- package/src-next/render/templates.ts +0 -645
- package/src-next/session/__tests__/graph.test.ts +0 -277
- package/src-next/session/__tests__/handoff-plane.guard.test.ts +0 -48
- package/src-next/session/__tests__/handoff-schema.test.ts +0 -310
- package/src-next/session/__tests__/ledger.test.ts +0 -745
- package/src-next/session/__tests__/next.test.ts +0 -460
- package/src-next/session/__tests__/preflight.test.ts +0 -545
- package/src-next/session/__tests__/round-naming.test.ts +0 -142
- package/src-next/session/__tests__/run.test.ts +0 -1026
- package/src-next/session/__tests__/wave-line-phase.guard.test.ts +0 -49
- package/src-next/session/__tests__/wave.test.ts +0 -476
- package/src-next/session/faces.ts +0 -110
- package/src-next/session/graph.ts +0 -411
- package/src-next/session/handoff-schema.ts +0 -373
- package/src-next/session/ledger.ts +0 -1076
- package/src-next/session/next.ts +0 -293
- package/src-next/session/preflight.ts +0 -271
- package/src-next/session/round-naming.ts +0 -84
- package/src-next/session/run.ts +0 -610
- package/src-next/session/state.ts +0 -30
- package/src-next/session/wave.ts +0 -139
|
@@ -1,300 +0,0 @@
|
|
|
1
|
-
// packages/cdd-engine/src-next/face/__tests__/capsule.test.ts
|
|
2
|
-
// P4.1 T7 — find #7 closeout (design §5.6): the complete-executable next literal's
|
|
3
|
-
// required-flag coverage. One literal per verb × type must secondary-parse with zero
|
|
4
|
-
// errors (T4) AND carry every runtime-required flag of its type — the design §5.6
|
|
5
|
-
// "parse green ⇒ full required-flag coverage" rule. The regression the suite pins: #routeText's review→wave
|
|
6
|
-
// branch rendered `review --type wave --tasks <n>` WITHOUT the runtime-required
|
|
7
|
-
// `--plan` (the implement/next-wave and fix→wave branches both carried it — a
|
|
8
|
-
// composition-face inconsistency), so the literal parsed green yet BLOCKED the
|
|
9
|
-
// dispatch at run time (`missing required --plan <path>`), as first observed in the
|
|
10
|
-
// W3 task-5 review dispatch.
|
|
11
|
-
//
|
|
12
|
-
// Module-level: the literals come from the Capsule face over the ROUTE + the frame's
|
|
13
|
-
// own facts (type + id + plan — the RouteTarget), then re-parse through the CLI's
|
|
14
|
-
// own parse gate (the same channel the dispatch reads).
|
|
15
|
-
|
|
16
|
-
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
17
|
-
import { tmpdir } from "node:os";
|
|
18
|
-
import path from "node:path";
|
|
19
|
-
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
20
|
-
import { RepoRoot } from "../../infra/root.ts";
|
|
21
|
-
import type { RouteTarget } from "../../session/faces.ts";
|
|
22
|
-
import type { Route } from "../../session/next.ts";
|
|
23
|
-
import { FIX_READBACK_SUFFIX, PIPELINE_NEXT } from "../../session/next.ts";
|
|
24
|
-
import { Capsule } from "../capsule.ts";
|
|
25
|
-
import { CommandTreeBuilder } from "../projection.ts";
|
|
26
|
-
import { Words } from "../words.ts";
|
|
27
|
-
|
|
28
|
-
/** The commander parse gate — the same channel the CLI dispatch reads (P3 T3: the
|
|
29
|
-
* composition root parses through the projection's program; `Cli#parse()` retired). */
|
|
30
|
-
const parseGate = new CommandTreeBuilder().program;
|
|
31
|
-
|
|
32
|
-
/** The next-text of a capsule emit (the second line, the station prefix stripped). */
|
|
33
|
-
const literalOf = (route: Route, target?: RouteTarget): string => {
|
|
34
|
-
const lines = new Capsule(new Words()).emit("APPROVED", "0", "/h.json", route, target);
|
|
35
|
-
return lines[1]!.slice("next: ".length);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
/** The parseable argv of a literal — the fix readback suffix is prompt prose, never
|
|
39
|
-
* argv (the parse gate strips the declared suffix before feeding). */
|
|
40
|
-
const argvOf = (literal: string): string[] => {
|
|
41
|
-
return literal
|
|
42
|
-
.replace(new RegExp(`\\s*\\(${FIX_READBACK_SUFFIX.slice(1, -1)}\\)$`), "")
|
|
43
|
-
.split(/\s+/);
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
/** The frame-fact targets of the four types (the dispatch frame's own identity). */
|
|
47
|
-
const wave = { type: "wave", id: "1,2", plan: "docs/kairos/plans/p3.md" } as const;
|
|
48
|
-
const spec = { type: "spec", id: "docs/kairos/specs/p3-design.md" } as const;
|
|
49
|
-
const planT = { type: "plan", id: "docs/kairos/plans/p3.md" } as const;
|
|
50
|
-
// find #9 — the branch target carries the workspace --plan · the id is the branch
|
|
51
|
-
// line's stable key `"branch"` (the range shas retired engine-wide · spec §6.6)
|
|
52
|
-
const branch = {
|
|
53
|
-
type: "branch",
|
|
54
|
-
id: "branch",
|
|
55
|
-
plan: "docs/kairos/plans/p3.md",
|
|
56
|
-
} as const;
|
|
57
|
-
|
|
58
|
-
/** One verb × type row of the coverage table — the route + the frame facts + the
|
|
59
|
-
* runtime-required flags of the type (the flags the CLI run would demand: the
|
|
60
|
-
* declared required keys + the type's scene rules — wave demands --plan, spec/plan
|
|
61
|
-
* their doc flags, branch the workspace --plan/--reviews face). */
|
|
62
|
-
interface CoverageRow {
|
|
63
|
-
label: string;
|
|
64
|
-
route: Route;
|
|
65
|
-
target?: RouteTarget;
|
|
66
|
-
required: readonly string[];
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const COVERAGE: readonly CoverageRow[] = [
|
|
70
|
-
{
|
|
71
|
-
label: "implement",
|
|
72
|
-
route: { kind: "next-wave", tasks: "1,2" },
|
|
73
|
-
target: wave,
|
|
74
|
-
required: ["--tasks", "--plan"],
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
label: "review wave",
|
|
78
|
-
route: { kind: "review" },
|
|
79
|
-
target: wave,
|
|
80
|
-
required: ["--type", "--tasks", "--plan"],
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
label: "review spec",
|
|
84
|
-
route: { kind: "review" },
|
|
85
|
-
target: spec,
|
|
86
|
-
required: ["--type", "--spec"],
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
label: "review plan",
|
|
90
|
-
route: { kind: "review" },
|
|
91
|
-
target: planT,
|
|
92
|
-
required: ["--type", "--plan"],
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
label: "review branch",
|
|
96
|
-
route: { kind: "review" },
|
|
97
|
-
target: branch,
|
|
98
|
-
required: ["--type", "--plan"],
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
label: "fix wave",
|
|
102
|
-
route: { kind: "fix", reviews: "tasks-1-review-1.json" },
|
|
103
|
-
target: wave,
|
|
104
|
-
required: ["--type", "--tasks", "--plan", "--reviews"],
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
label: "fix spec",
|
|
108
|
-
route: { kind: "fix", reviews: "s1-review-1.json" },
|
|
109
|
-
target: spec,
|
|
110
|
-
required: ["--type", "--spec", "--reviews"],
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
label: "fix plan",
|
|
114
|
-
route: { kind: "fix", reviews: "p1-review-1.json" },
|
|
115
|
-
target: planT,
|
|
116
|
-
required: ["--type", "--plan", "--reviews"],
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
// find #8 F1b — the branch fix carries the workspace-identity `--plan` plus the
|
|
120
|
-
// source review handoff `--reviews` (the review judges the live tree — no
|
|
121
|
-
// re-declared base/head on the CLI)
|
|
122
|
-
label: "fix branch",
|
|
123
|
-
route: { kind: "fix", reviews: "br1-review-1.json" },
|
|
124
|
-
target: branch,
|
|
125
|
-
required: ["--type", "--reviews", "--plan"],
|
|
126
|
-
},
|
|
127
|
-
];
|
|
128
|
-
|
|
129
|
-
describe("P4.1 T7 (find #7) — the next literal's required-flag coverage (parse green ⇒ the type's required flags fully covered)", () => {
|
|
130
|
-
it("review→wave renders `--plan {path}` — the find #7 regression (the missing --plan previously parsed green yet refused the dispatch at runtime)", () => {
|
|
131
|
-
const literal = literalOf({ kind: "review" }, wave);
|
|
132
|
-
expect(literal).toBe("review --type wave --tasks 1,2 --plan docs/kairos/plans/p3.md");
|
|
133
|
-
expect(() => parseGate.parse(argvOf(literal), { from: "user" })).not.toThrow();
|
|
134
|
-
// the ready-to-dispatch wave review must carry its runtime-required --plan — the
|
|
135
|
-
// same argv domain as the W3 task-5 dispatch that exposed the gap
|
|
136
|
-
expect(argvOf(literal)).toEqual([
|
|
137
|
-
"review",
|
|
138
|
-
"--type",
|
|
139
|
-
"wave",
|
|
140
|
-
"--tasks",
|
|
141
|
-
"1,2",
|
|
142
|
-
"--plan",
|
|
143
|
-
"docs/kairos/plans/p3.md",
|
|
144
|
-
]);
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
it("coverage table — every verb × type literal parses green AND carries its type's runtime-required flags", () => {
|
|
148
|
-
for (const row of COVERAGE) {
|
|
149
|
-
const literal = literalOf(row.route, row.target);
|
|
150
|
-
// parse green (T4) …
|
|
151
|
-
expect(() => parseGate.parse(argvOf(literal), { from: "user" })).not.toThrow();
|
|
152
|
-
// … and the type's required flags are all present in the same arg domain (find #7)
|
|
153
|
-
for (const flag of row.required) {
|
|
154
|
-
expect(literal, `${row.label} must carry ${flag}`).toContain(flag);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
it("review four-type literals carry zero sha — the live-tree review, no commit range", () => {
|
|
160
|
-
// §2.6 — every review literal is the live-tree judgment: the wave face carries
|
|
161
|
-
// `--tasks` + `--plan`, the branch/spec/plan faces their single doc arg; none
|
|
162
|
-
// carries a `--base`/`--head` range or a sha token.
|
|
163
|
-
const waveLiteral = literalOf({ kind: "review" }, wave);
|
|
164
|
-
const branchLiteral = literalOf({ kind: "review" }, branch);
|
|
165
|
-
const specLiteral = literalOf({ kind: "review" }, spec);
|
|
166
|
-
const planLiteral = literalOf({ kind: "review" }, planT);
|
|
167
|
-
expect(waveLiteral).toBe("review --type wave --tasks 1,2 --plan docs/kairos/plans/p3.md");
|
|
168
|
-
expect(branchLiteral).toBe("review --type branch --plan docs/kairos/plans/p3.md");
|
|
169
|
-
expect(specLiteral).toBe("review --type spec --spec docs/kairos/specs/p3-design.md");
|
|
170
|
-
expect(planLiteral).toBe("review --type plan --plan docs/kairos/plans/p3.md");
|
|
171
|
-
for (const literal of [waveLiteral, branchLiteral, specLiteral, planLiteral]) {
|
|
172
|
-
expect(literal).not.toContain("--base");
|
|
173
|
-
expect(literal).not.toContain("--head");
|
|
174
|
-
expect(literal).not.toMatch(/\b[0-9a-f]{8}\.\./);
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
it("the fix route keeps the FIX_READBACK_SUFFIX verbatim", () => {
|
|
179
|
-
const literal = literalOf({ kind: "fix", reviews: "tasks-1-review-1.json" }, wave);
|
|
180
|
-
expect(literal).toContain(FIX_READBACK_SUFFIX);
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
it("D47 — the next: literal's embedded paths render repoRoot-relative (absolute target + findings)", () => {
|
|
184
|
-
// §2.13 — the ONE renderer normalizes every embedded path value to the repoRoot-
|
|
185
|
-
// relative shape; an absolute target path and an absolute review path both come
|
|
186
|
-
// out relative, and the repo root never appears in the literal.
|
|
187
|
-
const repo = "/tmp/d47-repo";
|
|
188
|
-
const capsule = new Capsule(new Words(), {}, "", new RepoRoot(repo));
|
|
189
|
-
const lines = capsule.emit(
|
|
190
|
-
"CHANGES_REQUESTED",
|
|
191
|
-
"1",
|
|
192
|
-
`${repo}/.kairos/cdd/p3/tasks-1-review-1.json`,
|
|
193
|
-
{ kind: "fix", reviews: `${repo}/.kairos/cdd/p3/tasks-1-review-1.json` },
|
|
194
|
-
{ type: "plan", id: `${repo}/docs/kairos/plans/p3.md` },
|
|
195
|
-
);
|
|
196
|
-
const literal = lines[1]!.slice("next: ".length);
|
|
197
|
-
expect(literal).toBe(
|
|
198
|
-
`fix --type plan --plan docs/kairos/plans/p3.md --reviews .kairos/cdd/p3/tasks-1-review-1.json ${FIX_READBACK_SUFFIX}`,
|
|
199
|
-
);
|
|
200
|
-
expect(literal).not.toContain(repo);
|
|
201
|
-
// The handoff: cell is the same basis — repoRoot-relative, never absolute.
|
|
202
|
-
expect(lines[0]).toContain("handoff: .kairos/cdd/p3/tasks-1-review-1.json");
|
|
203
|
-
expect(lines[0]).not.toContain(repo);
|
|
204
|
-
});
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
// ---------------------------------------------------------------------------
|
|
208
|
-
// T3 — the unified next face: the `done` route's PIPELINE_NEXT doc-class lookup
|
|
209
|
-
// ---------------------------------------------------------------------------
|
|
210
|
-
|
|
211
|
-
/** The hermetic declaration repo — the spec docs the doc-class discrimination reads
|
|
212
|
-
* (spec §12 · D34: the declared front-matter `doc-type:` key, never the filename). */
|
|
213
|
-
describe("Capsule — the `done` route's PIPELINE_NEXT doc-class lookup (D33 · the unified next face)", () => {
|
|
214
|
-
let repo: string;
|
|
215
|
-
|
|
216
|
-
beforeEach(() => {
|
|
217
|
-
repo = mkdtempSync(path.join(tmpdir(), "capsule-done-"));
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
afterEach(() => {
|
|
221
|
-
rmSync(repo, { recursive: true, force: true });
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
/** A spec doc on disk declaring its doc type (the front-matter head key). */
|
|
225
|
-
const declareSpec = (name: string, docType: string | null): RouteTarget => {
|
|
226
|
-
mkdirSync(path.dirname(path.join(repo, name)), { recursive: true });
|
|
227
|
-
const head =
|
|
228
|
-
docType === null
|
|
229
|
-
? ["---", "title: The doc", "version: v1.0", "status: Draft", "---"]
|
|
230
|
-
: [
|
|
231
|
-
"---",
|
|
232
|
-
"title: The doc",
|
|
233
|
-
"version: v1.0",
|
|
234
|
-
"status: Draft",
|
|
235
|
-
`doc-type: ${docType}`,
|
|
236
|
-
"---",
|
|
237
|
-
];
|
|
238
|
-
writeFileSync(path.join(repo, name), [...head, ""].join("\n"), "utf8");
|
|
239
|
-
return { type: "spec", id: name } as const;
|
|
240
|
-
};
|
|
241
|
-
|
|
242
|
-
/** The done-text of a capsule emit for a host-injected capsule over the repo. */
|
|
243
|
-
const doneOf = (target?: RouteTarget, host = ""): string => {
|
|
244
|
-
const lines = new Capsule(new Words(), {}, host, new RepoRoot(repo)).emit(
|
|
245
|
-
"APPROVED",
|
|
246
|
-
"0",
|
|
247
|
-
"/h.json",
|
|
248
|
-
{ kind: "done" },
|
|
249
|
-
target,
|
|
250
|
-
);
|
|
251
|
-
return lines[1]!.slice("next: ".length);
|
|
252
|
-
};
|
|
253
|
-
|
|
254
|
-
it("PIPELINE_NEXT carries exactly the five pipeline keys", () => {
|
|
255
|
-
expect(Object.keys(PIPELINE_NEXT).sort()).toEqual(
|
|
256
|
-
["branch", "overall-spec", "phase-spec", "plan", "wave"].sort(),
|
|
257
|
-
);
|
|
258
|
-
});
|
|
259
|
-
|
|
260
|
-
it("no target renders the bare terminal word (the byte-pinned fallback)", () => {
|
|
261
|
-
expect(doneOf()).toBe("done");
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
it("a phase-spec-declared target routes the cdd-plan ref per host (claude / pi / empty)", () => {
|
|
265
|
-
const phaseSpec = declareSpec("docs/kairos/specs/prog-p8-design.md", "phase-spec");
|
|
266
|
-
expect(doneOf(phaseSpec, "claude")).toBe("/kairos:cdd-plan");
|
|
267
|
-
expect(doneOf(phaseSpec, "pi")).toBe("/skill:cdd-plan");
|
|
268
|
-
expect(doneOf(phaseSpec)).toBe("/kairos:cdd-plan");
|
|
269
|
-
});
|
|
270
|
-
|
|
271
|
-
it("an overall-spec-declared target renders the bare terminal word (the pipeline terminal)", () => {
|
|
272
|
-
const overall = declareSpec("docs/kairos/specs/prog-overall.md", "overall-spec");
|
|
273
|
-
expect(doneOf(overall)).toBe("done");
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
it("a spec target declaring no doc-type renders the BLOCKED face — zero filename-suffix fallback", () => {
|
|
277
|
-
const undeclared = declareSpec("docs/kairos/specs/prog-p8-design.md", null);
|
|
278
|
-
expect(doneOf(undeclared)).toBe(
|
|
279
|
-
"CDD_BLOCKED: the doc declares no `doc-type:` key — add `doc-type: <overall-spec|phase-spec|single-spec|plan>` to the doc's front-matter (spec §12 · D34) and re-run",
|
|
280
|
-
);
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
it("a single-spec-declared target renders the bare terminal word — no pipeline seam carries it", () => {
|
|
284
|
-
const single = declareSpec("docs/kairos/specs/prog-single-spec.md", "single-spec");
|
|
285
|
-
expect(doneOf(single)).toBe("done");
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
it("a plan target routes the cdd-dev ref; a branch target the cdd-close ref", () => {
|
|
289
|
-
expect(doneOf({ type: "plan", id: "docs/kairos/plans/prog-p8.md" })).toBe("/kairos:cdd-dev");
|
|
290
|
-
expect(doneOf({ type: "branch", id: "branch", plan: "docs/kairos/plans/prog-p8.md" })).toBe(
|
|
291
|
-
"/kairos:cdd-close",
|
|
292
|
-
);
|
|
293
|
-
});
|
|
294
|
-
|
|
295
|
-
it("a wave target renders the wiring literal with the plan slot filled", () => {
|
|
296
|
-
expect(doneOf({ type: "wave", id: "1,2", plan: "docs/kairos/plans/prog-p8.md" })).toBe(
|
|
297
|
-
"review --type branch --plan docs/kairos/plans/prog-p8.md",
|
|
298
|
-
);
|
|
299
|
-
});
|
|
300
|
-
});
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
// packages/cdd-engine/src-next/face/__tests__/channel-closure.guard.test.ts
|
|
2
|
-
// P5 — the engine-side channel-closure pin, colocated after the D17 six-premise
|
|
3
|
-
// ownership-migration (the root guard's checkChannels assertion face re-homed into the engine
|
|
4
|
-
// test plane — every check lives in its owning package's suite, zero root
|
|
5
|
-
// validation implementation). The three closure legs read the engine's OWN typed
|
|
6
|
-
// single sources — `face/declare.ts` (CLI_COMMANDS + ARGV_CHANNEL) and
|
|
7
|
-
// `face/host.ts` (HOSTS detect rows · DISPATCH · REFS) — the same surfaces the
|
|
8
|
-
// runtime consumes, never a parallel allowlist:
|
|
9
|
-
//
|
|
10
|
-
// 1. the CLI channel closure — every command-declared key resolves in the
|
|
11
|
-
// declare argv channel, and every non-program channel key is declared by a
|
|
12
|
-
// command (the single-surface closure);
|
|
13
|
-
// 2. the host-marker closure — the detect env keys ∪ PATH match the pinned
|
|
14
|
-
// four, derived from the harness detect rows as the live single source;
|
|
15
|
-
// 3. the dispatch/refs derivation — every dispatch-slot ref is registered and
|
|
16
|
-
// every per-harness slash form derives (`pi` /skill:<bare>, claude/cursor
|
|
17
|
-
// /<ref>);
|
|
18
|
-
// 4. the pipeline-next refs closure (T13 ⑨) — every `PIPELINE_NEXT` ref-key entry
|
|
19
|
-
// is registered in REFS and derives its per-harness forms (the face-to-face
|
|
20
|
-
// handoff table × the ref table cross-closure).
|
|
21
|
-
//
|
|
22
|
-
// Zero module-level bare functions — the assertions read the typed exports with
|
|
23
|
-
// `const` helpers only (the P5 zero-`function`-declaration discipline).
|
|
24
|
-
|
|
25
|
-
import { describe, expect, it } from "vitest";
|
|
26
|
-
|
|
27
|
-
import { PIPELINE_NEXT } from "../../session/next.ts";
|
|
28
|
-
import { ARGV_CHANNEL, CLI_COMMANDS } from "../declare.ts";
|
|
29
|
-
import { DISPATCH, HOSTS, REFS } from "../host.ts";
|
|
30
|
-
|
|
31
|
-
describe("the CLI channel closure — command keys × the declare argv channel (the single-surface closure)", () => {
|
|
32
|
-
it("every command/leaf declared key resolves in ARGV_CHANNEL — and every non-program channel key is declared by a command", () => {
|
|
33
|
-
// The declared aggregate — every key any command/leaf declares (the guard's
|
|
34
|
-
// collect face: keys only — positionals are arguments, never channel flags).
|
|
35
|
-
const declaredKeys = new Set<string>();
|
|
36
|
-
const collect = (spec: { keys: readonly { key: string }[] }): void => {
|
|
37
|
-
for (const declared of spec.keys) declaredKeys.add(declared.key);
|
|
38
|
-
};
|
|
39
|
-
for (const command of CLI_COMMANDS) {
|
|
40
|
-
collect(command);
|
|
41
|
-
for (const leaf of command.leaves ?? []) collect(leaf);
|
|
42
|
-
}
|
|
43
|
-
// Forward leg — a declared key absent from the channel is a broken closure.
|
|
44
|
-
const missing: string[] = [];
|
|
45
|
-
for (const key of declaredKeys) {
|
|
46
|
-
if (!(key in ARGV_CHANNEL)) missing.push(key);
|
|
47
|
-
}
|
|
48
|
-
expect(missing).toEqual([]);
|
|
49
|
-
// Reverse leg — a channel key declared by no command and not program-scoped
|
|
50
|
-
// (dry-run/help) is a broken closure.
|
|
51
|
-
const orphan: string[] = [];
|
|
52
|
-
for (const [key, row] of Object.entries(ARGV_CHANNEL)) {
|
|
53
|
-
if (declaredKeys.has(key) || ("scope" in row && row.scope === "program")) continue;
|
|
54
|
-
orphan.push(key);
|
|
55
|
-
}
|
|
56
|
-
expect(orphan).toEqual([]);
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it("the D19 schema merge keeps the closure — the `output` key is the get leaf's declared channel row", () => {
|
|
60
|
-
// The merged single leaf declares `--output` (json|skeleton): the closure
|
|
61
|
-
// leg reads the leaf's declared keys, so the new row is covered exactly like
|
|
62
|
-
// every other declared key (a drag of the D19 deliberate change).
|
|
63
|
-
const schema = CLI_COMMANDS.find((command) => command.name === "schema")!;
|
|
64
|
-
const get = schema.leaves!.find((leaf) => leaf.name === "get")!;
|
|
65
|
-
expect(get.keys.map((declared) => declared.key)).toContain("output");
|
|
66
|
-
expect(ARGV_CHANNEL.output.values).toEqual(["json", "skeleton"]);
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
describe("the host-marker closure — the detect env keys ∪ PATH (single-sourced at the harness detect rows)", () => {
|
|
71
|
-
it("every HOSTS detect env key + PATH equals the pinned four (the deliberate half-update oracle)", () => {
|
|
72
|
-
const markerKeys = Object.values(HOSTS).map((row) => row.detect.env);
|
|
73
|
-
const expectedClosure = [...markerKeys, "PATH"].sort();
|
|
74
|
-
const pinned = ["AI_AGENT", "CLAUDE_CODE_SESSION_ID", "CURSOR_TRACE_ID", "PATH"].sort();
|
|
75
|
-
expect(expectedClosure).toEqual(pinned);
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
describe("the dispatch/refs derivation — every dispatch-slot ref registered + every per-harness form derived", () => {
|
|
80
|
-
it("the dispatch table's ref-shaped slots derive their per-harness slash forms", () => {
|
|
81
|
-
// The ref-shaped slots (`pkg:skill`, lowercase) are the table entries; a
|
|
82
|
-
// non-ref literal (the URC prose — spaces/uppercase) has no per-harness form.
|
|
83
|
-
const refKeys: string[] = [];
|
|
84
|
-
const pushRef = (value: string | { ref: string }): void => {
|
|
85
|
-
const ref = typeof value === "string" ? value : value.ref;
|
|
86
|
-
if (/^[a-z][a-z-]*:[a-z][a-z-]*$/.test(ref)) refKeys.push(ref);
|
|
87
|
-
};
|
|
88
|
-
pushRef(DISPATCH.implement);
|
|
89
|
-
for (const slot of Object.values(DISPATCH.review)) pushRef(slot);
|
|
90
|
-
// The shape is the closed pair — implement + the review rows (never vacuous);
|
|
91
|
-
// both review slots name the same ref key — deduped before the derivation.
|
|
92
|
-
expect([...new Set(refKeys)].sort()).toEqual([
|
|
93
|
-
"mattpocock-skills:code-review",
|
|
94
|
-
"mattpocock-skills:implement",
|
|
95
|
-
]);
|
|
96
|
-
for (const ref of refKeys) {
|
|
97
|
-
const form = REFS[ref as keyof typeof REFS];
|
|
98
|
-
expect(form, `dispatch slot names the registered ref key "${ref}"`).toBeDefined();
|
|
99
|
-
if (form === undefined) continue;
|
|
100
|
-
for (const id of ["claude", "cursor", "pi"] as const) {
|
|
101
|
-
const expected = id === "pi" ? `/skill:${ref.split(":")[1]}` : `/${ref}`;
|
|
102
|
-
expect(form[id], `ref "${ref}" per-harness form for ${id}`).toBe(expected);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it("the PIPELINE_NEXT ref-key entries close over REFS (every handoff ref is registered + derives its forms)", () => {
|
|
108
|
-
// The face-to-face handoff table (session/next.ts PIPELINE_NEXT) routes each
|
|
109
|
-
// pipeline seam through a skill ref; every `{ kind: "ref" }` entry must name a
|
|
110
|
-
// registered REFS key and derive its per-harness slash forms — the same closure
|
|
111
|
-
// the dispatch leg enforces (a handoff ref absent from REFS renders the bare
|
|
112
|
-
// `done` word at the capsule's render, a silent mis-route).
|
|
113
|
-
const pipelineRefs = Object.values(PIPELINE_NEXT)
|
|
114
|
-
.filter((entry): entry is { kind: "ref"; ref: string } => entry.kind === "ref")
|
|
115
|
-
.map((entry) => entry.ref);
|
|
116
|
-
// The ref-shaped subset is non-empty (the phase-spec/plan/branch seams all route
|
|
117
|
-
// through refs; only the overall-spec seam is the `done` terminal + wave a literal).
|
|
118
|
-
expect(pipelineRefs.length).toBeGreaterThan(0);
|
|
119
|
-
for (const ref of pipelineRefs) {
|
|
120
|
-
const form = REFS[ref as keyof typeof REFS];
|
|
121
|
-
expect(form, `PIPELINE_NEXT names the registered ref key "${ref}"`).toBeDefined();
|
|
122
|
-
if (form === undefined) continue;
|
|
123
|
-
for (const id of ["claude", "cursor", "pi"] as const) {
|
|
124
|
-
const expected = id === "pi" ? `/skill:${ref.split(":")[1]}` : `/${ref}`;
|
|
125
|
-
expect(form[id], `PIPELINE_NEXT ref "${ref}" per-harness form for ${id}`).toBe(expected);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
});
|