@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,368 @@
|
|
|
1
|
+
// packages/cdd-engine/src-next/session/__tests__/next.test.ts
|
|
2
|
+
// T7 NextStepRouter suite (design spec §3.2 · v1.20 the closure single verdict) — the C5
|
|
3
|
+
// decision table:
|
|
4
|
+
// · review zero findings → close(state) — readyBatch empty → done, else next-wave;
|
|
5
|
+
// · review findings non-empty (any severity) → the one-way fix hop;
|
|
6
|
+
// · fix blocker>0 → a re-review hop (the live tree, no commit identity);
|
|
7
|
+
// · fix blocker==0 (warn/nit only or clean) → close(state) — the unified closure, never
|
|
8
|
+
// the retired `none`;
|
|
9
|
+
// · the review-cycle soft cap → the "BLOCKED: review-cycle-cap" suggestion (outranks the
|
|
10
|
+
// blocker row); REVIEW_CYCLE_CAP + the suggestion wording are the pinned constants;
|
|
11
|
+
// · the fix-route readback suffix — FIX_READBACK_SUFFIX — the declared single-source
|
|
12
|
+
// wording the capsule appends to the fix hop's `next:` render (verbatim, by reference);
|
|
13
|
+
// · BLOCKED/TIMEOUT → null (no next line — the failure face), every phase;
|
|
14
|
+
// · implement → the group's review (the live tree); branch-review → closure / fix;
|
|
15
|
+
// · the `none` route kind is RETIRED (closure renders done / next-wave), and a
|
|
16
|
+
// completed non-failed round producing null is a hard error on the dispatch face.
|
|
17
|
+
// The type assertions at the bottom pin the public surface compile-time (the brief's
|
|
18
|
+
// type-check checkable) — they fail under tsc if the exported signatures drift.
|
|
19
|
+
|
|
20
|
+
import { describe, expect, it } from "vitest";
|
|
21
|
+
import { Capsule } from "../../face/capsule.ts";
|
|
22
|
+
import { CommandTreeBuilder } from "../../face/projection.ts";
|
|
23
|
+
import { Words } from "../../face/words.ts";
|
|
24
|
+
import type { Round, RoundPhase } from "../ledger.ts";
|
|
25
|
+
import type { Route } from "../next.ts";
|
|
26
|
+
import {
|
|
27
|
+
FIX_READBACK_SUFFIX,
|
|
28
|
+
NextStepRouter,
|
|
29
|
+
PIPELINE_NEXT,
|
|
30
|
+
REVIEW_CYCLE_CAP,
|
|
31
|
+
SOFT_CAP_SUGGESTION,
|
|
32
|
+
} from "../next.ts";
|
|
33
|
+
import type { ExecutionState } from "../state.ts";
|
|
34
|
+
|
|
35
|
+
/** A minimal execution-state stub — the router reads only readyBatch(). */
|
|
36
|
+
const state = (ready: readonly number[]): ExecutionState => ({
|
|
37
|
+
doneTasks: () => new Set(),
|
|
38
|
+
readyBatch: () => [...ready],
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
/** A review finding literal shorthand. */
|
|
42
|
+
const finding = (
|
|
43
|
+
severity: "blocker" | "warn" | "nit",
|
|
44
|
+
summary = "",
|
|
45
|
+
): {
|
|
46
|
+
severity: "blocker" | "warn" | "nit";
|
|
47
|
+
summary: string;
|
|
48
|
+
} => ({ severity, summary });
|
|
49
|
+
|
|
50
|
+
/** A round carrier shorthand — the mandated fields default; the case overrides. */
|
|
51
|
+
const round = (over: { phase: RoundPhase } & Partial<Omit<Round, "phase">>): Round => ({
|
|
52
|
+
findings: [],
|
|
53
|
+
consecutiveS1: 0,
|
|
54
|
+
...over,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const router = new NextStepRouter();
|
|
58
|
+
|
|
59
|
+
describe("review rounds — zero findings flows the next wave on or closes the run (close)", () => {
|
|
60
|
+
it("zero findings + a ready batch → the next wave (close() — the ready task ids)", () => {
|
|
61
|
+
expect(router.next(state([3]), round({ phase: "review" }))).toEqual({
|
|
62
|
+
kind: "next-wave",
|
|
63
|
+
tasks: "3",
|
|
64
|
+
});
|
|
65
|
+
expect(router.next(state([4, 5]), round({ phase: "review" }))).toEqual({
|
|
66
|
+
kind: "next-wave",
|
|
67
|
+
tasks: "4,5",
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("zero findings + an exhausted run → done (the v1.20 terminal word, never `none`)", () => {
|
|
72
|
+
expect(router.next(state([]), round({ phase: "review" }))).toEqual({ kind: "done" });
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it("any findings (blocker or warn/nit) → the one-way fix hop carrying the review handoff", () => {
|
|
76
|
+
const findings: Round["findings"] = [finding("warn", "drift")];
|
|
77
|
+
expect(
|
|
78
|
+
router.next(
|
|
79
|
+
state([]),
|
|
80
|
+
round({ phase: "review", findings, findingsPath: "tasks-7,9-review-1.json" }),
|
|
81
|
+
),
|
|
82
|
+
).toEqual({ kind: "fix", findings: "tasks-7,9-review-1.json" });
|
|
83
|
+
|
|
84
|
+
const blockers: Round["findings"] = [finding("blocker", "defect")];
|
|
85
|
+
expect(router.next(state([]), round({ phase: "review", findings: blockers }))).toEqual({
|
|
86
|
+
kind: "fix",
|
|
87
|
+
findings: undefined,
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
describe("fix rounds — the re-review / closure decision point (C5-1, close())", () => {
|
|
93
|
+
it("input blockers remain → a re-review hop (the live tree, no commit identity)", () => {
|
|
94
|
+
expect(
|
|
95
|
+
router.next(state([]), round({ phase: "fix", findings: [finding("blocker", "remaining")] })),
|
|
96
|
+
).toEqual({ kind: "review" });
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it("warn/nit only → done (closure via close() — the #278 REVIEW_FIX state, no re-review preview)", () => {
|
|
100
|
+
expect(
|
|
101
|
+
router.next(state([]), round({ phase: "fix", findings: [finding("warn"), finding("nit")] })),
|
|
102
|
+
).toEqual({ kind: "done" });
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it("zero findings → done (close() with an exhausted run)", () => {
|
|
106
|
+
expect(router.next(state([]), round({ phase: "fix" }))).toEqual({ kind: "done" });
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it("a blocker-free fix with a ready batch → next-wave (the close() routing-table row)", () => {
|
|
110
|
+
expect(router.next(state([7]), round({ phase: "fix", findings: [finding("warn")] }))).toEqual({
|
|
111
|
+
kind: "next-wave",
|
|
112
|
+
tasks: "7",
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it("the soft cap outranks the blocker row — a capped run defers to the user", () => {
|
|
117
|
+
expect(
|
|
118
|
+
router.next(
|
|
119
|
+
state([]),
|
|
120
|
+
round({
|
|
121
|
+
phase: "fix",
|
|
122
|
+
findings: [finding("blocker")],
|
|
123
|
+
consecutiveS1: REVIEW_CYCLE_CAP,
|
|
124
|
+
}),
|
|
125
|
+
),
|
|
126
|
+
).toEqual({ kind: "soft-cap", message: SOFT_CAP_SUGGESTION });
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it("below the cap, blockers still route the re-review", () => {
|
|
130
|
+
expect(
|
|
131
|
+
router.next(
|
|
132
|
+
state([]),
|
|
133
|
+
round({ phase: "fix", findings: [finding("blocker")], consecutiveS1: 2 }),
|
|
134
|
+
)!.kind,
|
|
135
|
+
).toBe("review");
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
describe("implement / branch-review — the lifecycle rows", () => {
|
|
140
|
+
it("implement completes → the group's review (the live tree)", () => {
|
|
141
|
+
expect(router.next(state([]), round({ phase: "implement" }))).toEqual({ kind: "review" });
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it("branch-review zero findings → done (close()); findings → the fix hop", () => {
|
|
145
|
+
expect(router.next(state([]), round({ phase: "branch-review" }))).toEqual({ kind: "done" });
|
|
146
|
+
expect(
|
|
147
|
+
router.next(state([]), round({ phase: "branch-review", findings: [finding("nit")] }))!.kind,
|
|
148
|
+
).toBe("fix");
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
describe("the failure face — BLOCKED/TIMEOUT produce no next line", () => {
|
|
153
|
+
it("a BLOCKED review round → null", () => {
|
|
154
|
+
expect(router.next(state([]), round({ phase: "review", status: "BLOCKED" }))).toBeNull();
|
|
155
|
+
});
|
|
156
|
+
it("a BLOCKED fix round → null (the fix itself BLOCKED keeps the no-next face)", () => {
|
|
157
|
+
expect(
|
|
158
|
+
router.next(
|
|
159
|
+
state([]),
|
|
160
|
+
round({ phase: "fix", status: "BLOCKED", findings: [finding("blocker")] }),
|
|
161
|
+
),
|
|
162
|
+
).toBeNull();
|
|
163
|
+
});
|
|
164
|
+
it("a TIMEOUT round → null", () => {
|
|
165
|
+
expect(router.next(state([]), round({ phase: "implement", status: "TIMEOUT" }))).toBeNull();
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
describe("the pinned surface — Route/soft-cap constants (the brief's type-check checkable)", () => {
|
|
170
|
+
it("the soft-cap constant is the literal 10 and the wording is stable", () => {
|
|
171
|
+
expect(REVIEW_CYCLE_CAP).toBe(10);
|
|
172
|
+
expect(SOFT_CAP_SUGGESTION).toBe("BLOCKED: review-cycle-cap — user adjudicates");
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
it("the fix-route readback suffix is the declared single-source wording", () => {
|
|
176
|
+
expect(FIX_READBACK_SUFFIX).toBe(
|
|
177
|
+
"(confirm the findings · if a finding needs a ruling, record the ruling in the findings file)",
|
|
178
|
+
);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it("the readback suffix keeps its literal type at compile time", () => {
|
|
182
|
+
// Compile-time pin — fails under `tsc --noEmit` if the constant's declared type
|
|
183
|
+
// drifts from the render the capsule appends verbatim (exact suffix wording).
|
|
184
|
+
const suffix: "(confirm the findings · if a finding needs a ruling, record the ruling in the findings file)" =
|
|
185
|
+
FIX_READBACK_SUFFIX;
|
|
186
|
+
expect(suffix).toBe(FIX_READBACK_SUFFIX);
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
it("the soft-cap constants keep their literal types at compile time", () => {
|
|
190
|
+
// Compile-time pins — this file fails under `tsc --noEmit` if either constant's
|
|
191
|
+
// declared type drifts from the decision table's domain (cap == 10, verbatim wording).
|
|
192
|
+
const cap: 10 = REVIEW_CYCLE_CAP;
|
|
193
|
+
const wording: "BLOCKED: review-cycle-cap — user adjudicates" = SOFT_CAP_SUGGESTION;
|
|
194
|
+
expect({ cap, wording }).toEqual({
|
|
195
|
+
cap: 10,
|
|
196
|
+
wording: "BLOCKED: review-cycle-cap — user adjudicates",
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
it("the router is the single next-generation face — the exported signature is pinned", () => {
|
|
201
|
+
const surface: (state: ExecutionState, ref: Round) => Route | null = (s, r) =>
|
|
202
|
+
router.next(s, r);
|
|
203
|
+
expect(surface(state([]), round({ phase: "review" }))).toEqual({ kind: "done" });
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
it("the close() routing table — every closure point renders done | next-wave, never `none`", () => {
|
|
207
|
+
// review approved → exhausted done / ready next-wave
|
|
208
|
+
expect(router.next(state([]), round({ phase: "review" }))).toEqual({ kind: "done" });
|
|
209
|
+
expect(router.next(state([2]), round({ phase: "review" }))).toEqual({
|
|
210
|
+
kind: "next-wave",
|
|
211
|
+
tasks: "2",
|
|
212
|
+
});
|
|
213
|
+
// fix clean (warn/nit) → done / next-wave — the fix closure is a close(), never `none`
|
|
214
|
+
expect(router.next(state([]), round({ phase: "fix", findings: [finding("nit")] }))).toEqual({
|
|
215
|
+
kind: "done",
|
|
216
|
+
});
|
|
217
|
+
expect(router.next(state([2]), round({ phase: "fix", findings: [finding("warn")] }))).toEqual({
|
|
218
|
+
kind: "next-wave",
|
|
219
|
+
tasks: "2",
|
|
220
|
+
});
|
|
221
|
+
// branch-review clean → done
|
|
222
|
+
expect(router.next(state([]), round({ phase: "branch-review" }))).toEqual({ kind: "done" });
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
describe("the severity-combination space — every blocker/warn/nit MIX rides the same three-type routing (v1.29)", () => {
|
|
227
|
+
// The full 2^3 severity mix space (empty through all-three) — the C5 table judges
|
|
228
|
+
// severity only by the blocker/non-blocker axis: a review with ANY findings (any
|
|
229
|
+
// mix) routes the one-way fix hop; a fix with ANY blocker in its input re-reviews;
|
|
230
|
+
// a blocker-free fix (warn/nit in any mix) closes (next-wave when another wave is
|
|
231
|
+
// ready, done when the run is exhausted).
|
|
232
|
+
const MIXES: readonly (readonly ("blocker" | "warn" | "nit")[])[] = [
|
|
233
|
+
[],
|
|
234
|
+
["warn"],
|
|
235
|
+
["nit"],
|
|
236
|
+
["warn", "nit"],
|
|
237
|
+
["blocker"],
|
|
238
|
+
["blocker", "warn"],
|
|
239
|
+
["blocker", "nit"],
|
|
240
|
+
["blocker", "warn", "nit"],
|
|
241
|
+
];
|
|
242
|
+
|
|
243
|
+
it.each(MIXES.map((mix) => [mix]))(
|
|
244
|
+
"review findings %j — any mix routes fix (or close when empty)",
|
|
245
|
+
(mix) => {
|
|
246
|
+
const findings = mix.map((severity) => finding(severity));
|
|
247
|
+
const route = router.next(state([3]), round({ phase: "review", findings }));
|
|
248
|
+
if (mix.length === 0) {
|
|
249
|
+
expect(route).toEqual({ kind: "next-wave", tasks: "3" });
|
|
250
|
+
expect(router.next(state([]), round({ phase: "review", findings }))).toEqual({
|
|
251
|
+
kind: "done",
|
|
252
|
+
});
|
|
253
|
+
} else {
|
|
254
|
+
expect(route!.kind).toBe("fix"); // the one-way hop holding the review handoff
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
);
|
|
258
|
+
|
|
259
|
+
it.each(MIXES.map((mix) => [mix]))(
|
|
260
|
+
"fix findings %j — blocker-any mix re-reviews; warn/nit-only closes",
|
|
261
|
+
(mix) => {
|
|
262
|
+
const findings = mix.map((severity) => finding(severity));
|
|
263
|
+
const fix = round({ phase: "fix", findings });
|
|
264
|
+
if (mix.includes("blocker")) {
|
|
265
|
+
expect(router.next(state([3]), fix)).toEqual({ kind: "review" });
|
|
266
|
+
} else {
|
|
267
|
+
expect(router.next(state([3]), fix)).toEqual({ kind: "next-wave", tasks: "3" });
|
|
268
|
+
expect(router.next(state([]), fix)).toEqual({ kind: "done" });
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
);
|
|
272
|
+
|
|
273
|
+
it.each(MIXES.filter((mix) => mix.includes("warn") && mix.includes("nit")).map((mix) => [mix]))(
|
|
274
|
+
"a re-review round carrying %j rides the SAME review table — the re-review has no severity exemption",
|
|
275
|
+
(mix) => {
|
|
276
|
+
const findings = mix.map((severity) => finding(severity));
|
|
277
|
+
// re-review = a review round at a new ref — the C5 table applies verbatim
|
|
278
|
+
const route = router.next(state([3]), round({ phase: "review", findings }));
|
|
279
|
+
expect(route!.kind).toBe("fix");
|
|
280
|
+
},
|
|
281
|
+
);
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
// ---------------------------------------------------------------------------
|
|
285
|
+
// P4.1 T4 — the route → literal → second-parse roundtrip: every router-route the C5
|
|
286
|
+
// table can emit renders a next literal whose argv parses with zero errors (the
|
|
287
|
+
// executable command reversal) · done is the bare terminal word, never fed.
|
|
288
|
+
// ---------------------------------------------------------------------------
|
|
289
|
+
|
|
290
|
+
describe("P4.1 T4 — the router's routes render parseable next literals (zero-error second parse)", () => {
|
|
291
|
+
/** The next text of a route rendered against a wave-frame target (the task face —
|
|
292
|
+
* the C5 table's real consumer), then the parseable argv (the readback suffix is
|
|
293
|
+
* prompt prose, never argv). */
|
|
294
|
+
function argvOf(route: Route): string[] {
|
|
295
|
+
const lines = new Capsule(new Words()).emit("APPROVED", "0", "/h.json", route, {
|
|
296
|
+
type: "wave",
|
|
297
|
+
id: "1,2",
|
|
298
|
+
plan: "docs/kairos/plans/p3.md",
|
|
299
|
+
});
|
|
300
|
+
const literal = lines[1]!.slice("next: ".length);
|
|
301
|
+
return literal
|
|
302
|
+
.replace(new RegExp(`\\s*\\(${FIX_READBACK_SUFFIX.slice(1, -1)}\\)$`), "")
|
|
303
|
+
.split(/\s+/);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
it.each([
|
|
307
|
+
["implement wave", { kind: "next-wave", tasks: "1,2" } as Route],
|
|
308
|
+
["re-review", { kind: "review" } as Route],
|
|
309
|
+
["the one-way fix hop", { kind: "fix", findings: "tasks-1-review-1.json" } as Route],
|
|
310
|
+
["closure", { kind: "done" } as Route],
|
|
311
|
+
] as const)("%s — the route's literal argv parses", (_label, route) => {
|
|
312
|
+
if (route.kind === "done") {
|
|
313
|
+
// the bare terminal word: never fed to parse (a bare `done` is not a command)
|
|
314
|
+
expect(() => new CommandTreeBuilder().program.parse(["done"], { from: "user" })).toThrow(
|
|
315
|
+
/unknown command 'done'/,
|
|
316
|
+
);
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
expect(() =>
|
|
320
|
+
new CommandTreeBuilder().program.parse(argvOf(route), { from: "user" }),
|
|
321
|
+
).not.toThrow();
|
|
322
|
+
});
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
// ---------------------------------------------------------------------------
|
|
326
|
+
// D40 — ONE "next step" concept turned single-resolver + face-to-face handoff.
|
|
327
|
+
// ---------------------------------------------------------------------------
|
|
328
|
+
|
|
329
|
+
describe("D40 — the face-to-face handoff route + the single resolver", () => {
|
|
330
|
+
it("handoff() carries the pipeline entry for a doc-class — the ONE route kind", () => {
|
|
331
|
+
expect(NextStepRouter.handoff("phase-spec")).toEqual({
|
|
332
|
+
kind: "handoff",
|
|
333
|
+
entry: PIPELINE_NEXT["phase-spec"],
|
|
334
|
+
});
|
|
335
|
+
expect(NextStepRouter.handoff("branch")).toEqual({
|
|
336
|
+
kind: "handoff",
|
|
337
|
+
entry: PIPELINE_NEXT.branch,
|
|
338
|
+
});
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
it("resolve() passes an ACTIVE C5 hop through untouched (the line is not drained)", () => {
|
|
342
|
+
// The line's own C5 frontier decides next until it drains — a review/fix/next-wave
|
|
343
|
+
// route is the line's next step, never the face-to-face handoff.
|
|
344
|
+
expect(NextStepRouter.resolve({ kind: "review" }, "phase-spec")).toEqual({ kind: "review" });
|
|
345
|
+
expect(NextStepRouter.resolve({ kind: "next-wave", tasks: "3" }, "wave")).toEqual({
|
|
346
|
+
kind: "next-wave",
|
|
347
|
+
tasks: "3",
|
|
348
|
+
});
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
it("resolve() yields the face-to-face handoff when the line's C5 frontier drained (done)", () => {
|
|
352
|
+
expect(NextStepRouter.resolve({ kind: "done" }, "plan")).toEqual({
|
|
353
|
+
kind: "handoff",
|
|
354
|
+
entry: PIPELINE_NEXT.plan,
|
|
355
|
+
});
|
|
356
|
+
// a null C5 route (a not-yet-started frontier) also hands off to the next face.
|
|
357
|
+
expect(NextStepRouter.resolve(null, "branch")).toEqual({
|
|
358
|
+
kind: "handoff",
|
|
359
|
+
entry: PIPELINE_NEXT.branch,
|
|
360
|
+
});
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
it("resolve() with no face seam (null doc-class) renders the bare terminal `done`", () => {
|
|
364
|
+
// The overall line / a bare terminal: no pipeline seam carries it — the terminal word.
|
|
365
|
+
expect(NextStepRouter.resolve({ kind: "done" }, null)).toEqual({ kind: "done" });
|
|
366
|
+
expect(NextStepRouter.resolve(null, null)).toEqual({ kind: "done" });
|
|
367
|
+
});
|
|
368
|
+
});
|