@oscaner-skills/cdd-engine 2.0.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/README.md +2 -2
  2. package/README.zh-CN.md +2 -2
  3. package/{src-next/bin.ts → dist/bin.js} +18 -21
  4. package/dist/contract/declare.js +998 -0
  5. package/dist/contract/doc.js +565 -0
  6. package/dist/contract/frontmatter.js +209 -0
  7. package/dist/contract/home-extractors.js +379 -0
  8. package/dist/contract/invariants.js +1030 -0
  9. package/dist/contract/judge.js +109 -0
  10. package/dist/contract/lint.js +206 -0
  11. package/dist/contract/project.js +371 -0
  12. package/dist/contract/skill-anatomy.js +156 -0
  13. package/dist/contract/translate.js +85 -0
  14. package/dist/face/artifacts.js +189 -0
  15. package/dist/face/board-view.js +522 -0
  16. package/dist/face/capsule.js +141 -0
  17. package/dist/face/cli.js +891 -0
  18. package/dist/face/declare.js +241 -0
  19. package/dist/face/gate.js +158 -0
  20. package/dist/face/graph-view.js +66 -0
  21. package/dist/face/host.js +211 -0
  22. package/dist/face/lifecycle.js +603 -0
  23. package/dist/face/preview.js +136 -0
  24. package/dist/face/projection.js +259 -0
  25. package/dist/face/route-render.js +162 -0
  26. package/dist/face/termination.js +482 -0
  27. package/dist/face/words.js +220 -0
  28. package/{src-next/infra/config.ts → dist/infra/config.js} +19 -24
  29. package/dist/infra/doc-roots.js +19 -0
  30. package/dist/infra/git.js +37 -0
  31. package/dist/infra/process.js +22 -0
  32. package/dist/infra/root.js +62 -0
  33. package/dist/infra/runtime.js +85 -0
  34. package/dist/infra/workspace.js +276 -0
  35. package/dist/render/brief.js +82 -0
  36. package/dist/render/issue-body.js +129 -0
  37. package/dist/render/skeleton.js +434 -0
  38. package/dist/render/templates.js +520 -0
  39. package/dist/session/faces.js +38 -0
  40. package/dist/session/graph.js +309 -0
  41. package/dist/session/handoff-schema.js +295 -0
  42. package/dist/session/ledger.js +762 -0
  43. package/dist/session/next.js +211 -0
  44. package/dist/session/preflight.js +194 -0
  45. package/dist/session/round-naming.js +73 -0
  46. package/dist/session/run.js +441 -0
  47. package/dist/session/state.js +8 -0
  48. package/dist/session/wave.js +92 -0
  49. package/package.json +8 -7
  50. package/templates/report/issue-body.json +0 -46
  51. package/src-next/__tests__/bin.test.ts +0 -128
  52. package/src-next/__tests__/smoke.integration.test.ts +0 -202
  53. package/src-next/__tests__/zero-dep.test.ts +0 -134
  54. package/src-next/contract/__tests__/__snapshots__/project.schema.overall-spec.snap +0 -238
  55. package/src-next/contract/__tests__/__snapshots__/project.schema.phase-spec.snap +0 -153
  56. package/src-next/contract/__tests__/__snapshots__/project.schema.plan.snap +0 -173
  57. package/src-next/contract/__tests__/__snapshots__/project.schema.single-spec.snap +0 -89
  58. package/src-next/contract/__tests__/__snapshots__/project.shape.overall-spec.snap +0 -225
  59. package/src-next/contract/__tests__/__snapshots__/project.shape.phase-spec.snap +0 -155
  60. package/src-next/contract/__tests__/__snapshots__/project.shape.plan.snap +0 -175
  61. package/src-next/contract/__tests__/__snapshots__/project.shape.single-spec.snap +0 -85
  62. package/src-next/contract/__tests__/declare.test.ts +0 -242
  63. package/src-next/contract/__tests__/doc.test.ts +0 -358
  64. package/src-next/contract/__tests__/judge.test.ts +0 -873
  65. package/src-next/contract/__tests__/lint.test.ts +0 -314
  66. package/src-next/contract/__tests__/project.test.ts +0 -419
  67. package/src-next/contract/__tests__/translate.test.ts +0 -96
  68. package/src-next/contract/declare.ts +0 -983
  69. package/src-next/contract/doc.ts +0 -753
  70. package/src-next/contract/invariants.ts +0 -1268
  71. package/src-next/contract/judge.ts +0 -142
  72. package/src-next/contract/lint.ts +0 -275
  73. package/src-next/contract/project.ts +0 -596
  74. package/src-next/contract/skill-anatomy.ts +0 -273
  75. package/src-next/contract/translate.ts +0 -113
  76. package/src-next/face/__tests__/board-view.test.ts +0 -948
  77. package/src-next/face/__tests__/capsule.test.ts +0 -276
  78. package/src-next/face/__tests__/channel-closure.guard.test.ts +0 -102
  79. package/src-next/face/__tests__/cli.test.ts +0 -4643
  80. package/src-next/face/__tests__/face.test.ts +0 -289
  81. package/src-next/face/__tests__/graph-view.test.ts +0 -61
  82. package/src-next/face/__tests__/host.test.ts +0 -24
  83. package/src-next/face/__tests__/negation.ts +0 -6
  84. package/src-next/face/__tests__/projection.test.ts +0 -301
  85. package/src-next/face/__tests__/sync-runner.test.ts +0 -70
  86. package/src-next/face/__tests__/words.guard.test.ts +0 -93
  87. package/src-next/face/artifacts.ts +0 -195
  88. package/src-next/face/board-view.ts +0 -662
  89. package/src-next/face/capsule.ts +0 -149
  90. package/src-next/face/cli.ts +0 -819
  91. package/src-next/face/declare.ts +0 -326
  92. package/src-next/face/gate.ts +0 -170
  93. package/src-next/face/graph-view.ts +0 -74
  94. package/src-next/face/host.ts +0 -326
  95. package/src-next/face/lifecycle.ts +0 -700
  96. package/src-next/face/projection.ts +0 -282
  97. package/src-next/face/route-render.ts +0 -160
  98. package/src-next/face/words.ts +0 -296
  99. package/src-next/infra/__tests__/infra.test.ts +0 -287
  100. package/src-next/infra/git.ts +0 -39
  101. package/src-next/infra/process.ts +0 -34
  102. package/src-next/infra/runtime.ts +0 -185
  103. package/src-next/infra/workspace.ts +0 -232
  104. package/src-next/render/__tests__/render.test.ts +0 -499
  105. package/src-next/render/__tests__/skeleton.test.ts +0 -466
  106. package/src-next/render/brief.ts +0 -121
  107. package/src-next/render/issue-body.ts +0 -159
  108. package/src-next/render/skeleton.ts +0 -437
  109. package/src-next/render/templates.ts +0 -650
  110. package/src-next/session/__tests__/graph.test.ts +0 -270
  111. package/src-next/session/__tests__/handoff-plane.guard.test.ts +0 -48
  112. package/src-next/session/__tests__/handoff-schema.test.ts +0 -310
  113. package/src-next/session/__tests__/ledger.test.ts +0 -744
  114. package/src-next/session/__tests__/next.test.ts +0 -368
  115. package/src-next/session/__tests__/preflight.test.ts +0 -491
  116. package/src-next/session/__tests__/run.test.ts +0 -1014
  117. package/src-next/session/__tests__/wave-line-phase.guard.test.ts +0 -49
  118. package/src-next/session/__tests__/wave.test.ts +0 -469
  119. package/src-next/session/faces.ts +0 -110
  120. package/src-next/session/graph.ts +0 -411
  121. package/src-next/session/handoff-schema.ts +0 -373
  122. package/src-next/session/ledger.ts +0 -1004
  123. package/src-next/session/next.ts +0 -192
  124. package/src-next/session/preflight.ts +0 -240
  125. package/src-next/session/run.ts +0 -606
  126. package/src-next/session/state.ts +0 -30
  127. package/src-next/session/wave.ts +0 -139
@@ -1,983 +0,0 @@
1
- // packages/cdd-engine/src-next/contract/declare.ts
2
- // T2 — the element-registry declaration (the design spec's single-declaration root).
3
- //
4
- // Each doc type (overall-spec / plan / phase-spec / single-spec) carries one typed
5
- // element registry:
6
- // flat declared data, one row per element — anchor token · presence · value
7
- // pattern · ref kind · home surface. The registry is simultaneously the
8
- // interpreter's judgment data (judge.ts consumes the anchors/domains) and the
9
- // projection surfaces' derivation source (project.ts derives shape / schema /
10
- // slices / tokens / reference from it) — no hand-written duplicate exists
11
- // anywhere in the new tree.
12
- //
13
- // The element lines are enumerated from the methodology skeleton semantics (the
14
- // machine skeleton of each doc type as pinned by the four repo schema JSONs,
15
- // read as steady contract data) — freshly declared anchors, never cut from the
16
- // old tree's sources. Counts stand at overall-spec 39 / plan 28 / phase-spec 25 /
17
- // single-spec 13,
18
- // each within the planned 20–40 band (single-spec deliberately below it — the
19
- // lightweight-scaffold charter) and each element carrying all five fields
20
- // (a completeness contract enforced by the array shape below and by the test
21
- // suite, which pins presence/ref-kind domains and per-registry anchor
22
- // uniqueness).
23
-
24
- /** The presence category of an element: carried unconditionally, optionally, or only when its declared condition holds. */
25
- export type Presence = "required" | "optional" | "conditional";
26
-
27
- /** The four doc types the engine validates. */
28
- export type DocType = "overall-spec" | "plan" | "phase-spec" | "single-spec";
29
-
30
- /** The referential kind an element participates in — what its value points at. */
31
- export type RefKind =
32
- | "none"
33
- | "version-lineage"
34
- | "markdown-link"
35
- | "phase-id"
36
- | "issue-ref"
37
- | "spec-ref"
38
- | "parent-program"
39
- | "task-id";
40
-
41
- /** The document surface an element belongs to — where the anchor lives in a conforming document. */
42
- export type Home =
43
- | "header"
44
- | "section"
45
- | "facet"
46
- | "table"
47
- | "graph"
48
- | "task-block"
49
- | "task-field"
50
- | "task-step"
51
- | "design-body"
52
- | "conditional";
53
-
54
- /** One declared element: a structural fact of a doc type's skeleton. */
55
- export interface RegistryElement {
56
- /** The machine anchor token the engine keys on — a heading literal, a header marker, or a row/field key. */
57
- anchor: string;
58
- /** Whether a conforming document must carry the element, may carry it, or carries it only when its condition holds. */
59
- presence: Presence;
60
- /** The value shape the element carries — a match pattern over the anchor's line/cell. Optional: a pure presence marker has no value to shape. */
61
- valuePattern?: string;
62
- /** The referential kind the element participates in. Optional: presence-only elements carry no reference. */
63
- refKind?: RefKind;
64
- /** The document surface the element belongs to. */
65
- home: Home;
66
- }
67
-
68
- /** One doc type's full element registry. */
69
- export interface ElementRegistry {
70
- docType: DocType;
71
- elements: readonly RegistryElement[];
72
- }
73
-
74
- /** The declared-registries record surface (the brief's `declaredRegistries` shape). */
75
- export interface DeclaredRegistries {
76
- "overall-spec": ElementRegistry;
77
- plan: ElementRegistry;
78
- "phase-spec": ElementRegistry;
79
- "single-spec": ElementRegistry;
80
- }
81
-
82
- // The legal value vocabularies — the single declared source the guards check
83
- // against. Each is pinned to its narrow union, so a domain drift fails the
84
- // compile.
85
- const PRESENCE_VALUES = [
86
- "required",
87
- "optional",
88
- "conditional",
89
- ] as const satisfies readonly Presence[];
90
- const REF_KIND_VALUES = [
91
- "none",
92
- "version-lineage",
93
- "markdown-link",
94
- "phase-id",
95
- "issue-ref",
96
- "spec-ref",
97
- "parent-program",
98
- "task-id",
99
- ] as const satisfies readonly RefKind[];
100
- const HOME_VALUES = [
101
- "header",
102
- "section",
103
- "facet",
104
- "table",
105
- "graph",
106
- "task-block",
107
- "task-field",
108
- "task-step",
109
- "design-body",
110
- "conditional",
111
- ] as const satisfies readonly Home[];
112
- const DOC_TYPE_VALUES = [
113
- "overall-spec",
114
- "plan",
115
- "phase-spec",
116
- "single-spec",
117
- ] as const satisfies readonly DocType[];
118
-
119
- /**
120
- * The registry guards — the runtime contract that narrows an unknown candidate
121
- * to a registry element or a full element registry. A static predicate class
122
- * (zero instance state): every guard reads its legal vocabulary from the
123
- * declared constants above, so a domain drift fails the guard tests.
124
- */
125
- // biome-ignore lint/complexity/noStaticOnlyClass: the plan-mandated static guard surface — the zero-bare-function discipline admits no standalone predicate functions.
126
- export class RegistryGuard {
127
- /** Narrow a candidate to a well-formed registry element: anchor token, presence,
128
- * value pattern, ref kind and home all inside their legal domains. */
129
- static isElement(value: unknown): value is RegistryElement {
130
- if (typeof value !== "object" || value === null) return false;
131
- const candidate = value as Record<string, unknown>;
132
- if (typeof candidate.anchor !== "string" || candidate.anchor.length === 0) return false;
133
- if (
134
- typeof candidate.presence !== "string" ||
135
- !(PRESENCE_VALUES as readonly string[]).includes(candidate.presence)
136
- )
137
- return false;
138
- if (candidate.valuePattern !== undefined && typeof candidate.valuePattern !== "string")
139
- return false;
140
- if (
141
- candidate.refKind !== undefined &&
142
- (typeof candidate.refKind !== "string" ||
143
- !(REF_KIND_VALUES as readonly string[]).includes(candidate.refKind))
144
- )
145
- return false;
146
- if (
147
- typeof candidate.home !== "string" ||
148
- !(HOME_VALUES as readonly string[]).includes(candidate.home)
149
- )
150
- return false;
151
- return true;
152
- }
153
-
154
- /** Narrow a candidate to a full element registry (doc type + all elements well-formed). */
155
- static isRegistry(value: unknown): value is ElementRegistry {
156
- if (typeof value !== "object" || value === null) return false;
157
- const candidate = value as Record<string, unknown>;
158
- if (
159
- typeof candidate.docType !== "string" ||
160
- !(DOC_TYPE_VALUES as readonly string[]).includes(candidate.docType)
161
- )
162
- return false;
163
- if (!Array.isArray(candidate.elements)) return false;
164
- return (candidate.elements as unknown[]).every((element) => RegistryGuard.isElement(element));
165
- }
166
- }
167
-
168
- // ---------------------------------------------------------------------------
169
- // overall-spec — the charter section surface
170
- // ---------------------------------------------------------------------------
171
- const OVERALL_SPEC_ELEMENTS = [
172
- // Header block (H1 + bullet metadata).
173
- {
174
- anchor: "# Title",
175
- presence: "required",
176
- valuePattern: "^# \\S.*$",
177
- refKind: "none",
178
- home: "header",
179
- },
180
- {
181
- anchor: "**Version**",
182
- presence: "required",
183
- valuePattern: "^- \\*\\*Version\\*\\*: v\\d+\\.\\d+ · \\d{4}-\\d{2}-\\d{2}$",
184
- refKind: "version-lineage",
185
- home: "header",
186
- },
187
- {
188
- anchor: "**Status**",
189
- presence: "required",
190
- valuePattern: "^- \\*\\*Status\\*\\*: (Draft|Approved|In progress|Complete)$",
191
- refKind: "none",
192
- home: "header",
193
- },
194
- {
195
- anchor: "**Author**",
196
- presence: "required",
197
- valuePattern: "^- \\*\\*Author\\*\\*:",
198
- refKind: "none",
199
- home: "header",
200
- },
201
- {
202
- anchor: "**Constraints**",
203
- presence: "required",
204
- valuePattern: "^- \\*\\*Constraints\\*\\*:",
205
- refKind: "none",
206
- home: "header",
207
- },
208
- // `##`-ranked sections.
209
- {
210
- anchor: "## Document scope",
211
- presence: "required",
212
- valuePattern: "^## Document scope$",
213
- refKind: "none",
214
- home: "section",
215
- },
216
- {
217
- anchor: "## File paths",
218
- presence: "required",
219
- valuePattern: "^## File paths$",
220
- refKind: "none",
221
- home: "section",
222
- },
223
- {
224
- anchor: "## Program charter",
225
- presence: "required",
226
- valuePattern: "^## Program charter$",
227
- refKind: "none",
228
- home: "section",
229
- },
230
- {
231
- anchor: "## Issue inventory",
232
- presence: "required",
233
- valuePattern: "^## Issue inventory$",
234
- refKind: "none",
235
- home: "section",
236
- },
237
- {
238
- anchor: "## Phase inventory",
239
- presence: "required",
240
- valuePattern: "^## Phase inventory$",
241
- refKind: "none",
242
- home: "section",
243
- },
244
- {
245
- anchor: "## Dependency graph",
246
- presence: "required",
247
- valuePattern: "^## Dependency graph( \\(ASCII\\))?$",
248
- refKind: "none",
249
- home: "section",
250
- },
251
- {
252
- anchor: "## Boundary rules",
253
- presence: "required",
254
- valuePattern: "^## Boundary rules$",
255
- refKind: "none",
256
- home: "section",
257
- },
258
- {
259
- anchor: "## Maintenance",
260
- presence: "required",
261
- valuePattern: "^## Maintenance$",
262
- refKind: "none",
263
- home: "section",
264
- },
265
- {
266
- anchor: "## Change history",
267
- presence: "required",
268
- valuePattern: "^## Change history$",
269
- refKind: "none",
270
- home: "section",
271
- },
272
- // Charter facets (`###`/`####` leaves under the charter). The legacy Chinese
273
- // markers (the doc-arch decision-group leaves M/F/R/B/E, the doc-arch
274
- // upstream-endorsements facet) match through the judge's canonicalize row-source
275
- // seam (contract/judge.ts) — the value patterns below are English canonicals,
276
- // never a second hand-written zh pattern.
277
- {
278
- anchor: "### Goal",
279
- presence: "required",
280
- valuePattern: "^### Goal",
281
- refKind: "none",
282
- home: "facet",
283
- },
284
- {
285
- anchor: "### Non-goals",
286
- presence: "required",
287
- valuePattern: "^### Non-goals",
288
- refKind: "none",
289
- home: "facet",
290
- },
291
- {
292
- anchor: "### Cross-cutting",
293
- presence: "required",
294
- valuePattern: "^### Cross-cutting",
295
- refKind: "none",
296
- home: "facet",
297
- },
298
- {
299
- anchor: "#### [MFRBEN] group",
300
- presence: "optional",
301
- valuePattern: "^#### [MFRBEN] group",
302
- refKind: "none",
303
- home: "facet",
304
- },
305
- {
306
- anchor: "#### Upstream Endorsements",
307
- presence: "optional",
308
- valuePattern: "^#### Upstream Endorsements$",
309
- refKind: "none",
310
- home: "facet",
311
- },
312
- // Issue inventory — the anchor-registration domain.
313
- {
314
- anchor: "Issue inventory columns",
315
- presence: "required",
316
- valuePattern: "^\\| Phase \\| Issue \\(ref\\) \\| Title summary \\|$",
317
- refKind: "none",
318
- home: "table",
319
- },
320
- {
321
- anchor: "Issue row",
322
- presence: "required",
323
- valuePattern: "^\\|\\s*P\\d+(\\.\\d+)*\\s*\\|",
324
- refKind: "issue-ref",
325
- home: "table",
326
- },
327
- {
328
- anchor: "Issue ref cell",
329
- presence: "required",
330
- valuePattern: "^(none|#\\d+|\\[#\\d+\\]|#\\d+#issuecomment-\\d+|([^)]*)|\\([^)]*\\))$",
331
- refKind: "issue-ref",
332
- home: "table",
333
- },
334
- {
335
- anchor: "issuecomment anchor",
336
- presence: "conditional",
337
- valuePattern: "^#\\d+#issuecomment-\\d+$",
338
- refKind: "issue-ref",
339
- home: "table",
340
- },
341
- // Phase inventory row ledger.
342
- {
343
- anchor: "Phase inventory columns",
344
- presence: "required",
345
- valuePattern:
346
- "^\\| # \\| Phase \\| Scope \\| Design spec \\| Implementation plan \\| Acceptance criteria \\| Dependency \\|$",
347
- refKind: "none",
348
- home: "table",
349
- },
350
- {
351
- anchor: "Phase row",
352
- presence: "required",
353
- valuePattern: "^\\|\\s*P\\d+(\\.\\d+)*\\s*\\|",
354
- refKind: "phase-id",
355
- home: "table",
356
- },
357
- {
358
- anchor: "Phase id token",
359
- presence: "required",
360
- valuePattern: "^P\\d+(\\.\\d+)*$",
361
- refKind: "phase-id",
362
- home: "table",
363
- },
364
- {
365
- anchor: "Implementation plan cell",
366
- presence: "required",
367
- valuePattern:
368
- "^(Pending|\\[Pending\\]|In-flight|\\[In-flight\\]|Done|\\[[^\\]]+\\]\\([^)]+\\))$",
369
- refKind: "markdown-link",
370
- home: "table",
371
- },
372
- {
373
- anchor: "Design spec cell",
374
- presence: "required",
375
- valuePattern: "^(\\[[^\\]]+\\]\\([^)]+\\)|P\\d+(\\.\\d+)*-design|Done|\\[Pending\\])$",
376
- refKind: "spec-ref",
377
- home: "table",
378
- },
379
- {
380
- anchor: "Dependency cell",
381
- presence: "required",
382
- valuePattern: "^P\\d+(\\.\\d+)*\\s*->",
383
- refKind: "phase-id",
384
- home: "table",
385
- },
386
- // Dependency graph edges + legend.
387
- {
388
- anchor: "Hard edge",
389
- presence: "required",
390
- valuePattern: "^P\\d+(\\.\\d+)*\\s*->\\s*P\\d+(\\.\\d+)*",
391
- refKind: "phase-id",
392
- home: "graph",
393
- },
394
- {
395
- anchor: "Soft edge",
396
- presence: "optional",
397
- valuePattern: "^P\\d+(\\.\\d+)*\\s*->\\s*\\(?\\s*soft\\s*\\)?",
398
- refKind: "phase-id",
399
- home: "graph",
400
- },
401
- {
402
- anchor: "Graph legend",
403
- presence: "required",
404
- valuePattern:
405
- "^(?:- )?`?->\\s*(?:\\(soft\\))?\\s*`? = hard block|^(?:- )?`?->\\s*\\(soft\\)\\s*`? = suggestion only",
406
- refKind: "none",
407
- home: "graph",
408
- },
409
- // File paths artifact table.
410
- {
411
- anchor: "File path row",
412
- presence: "required",
413
- valuePattern: "^\\| [^|]+ \\| `[^`]+` \\|$",
414
- refKind: "none",
415
- home: "table",
416
- },
417
- // Change history — the version-lineage surface.
418
- {
419
- anchor: "Change history row",
420
- presence: "required",
421
- valuePattern: "^\\|\\s*v\\d+\\.\\d+\\s*\\|",
422
- refKind: "version-lineage",
423
- home: "table",
424
- },
425
- {
426
- anchor: "Version token",
427
- presence: "required",
428
- valuePattern: "^v\\d+\\.\\d+$",
429
- refKind: "version-lineage",
430
- home: "table",
431
- },
432
- {
433
- anchor: "Change history date",
434
- presence: "required",
435
- valuePattern: "^\\d{4}-\\d{2}-\\d{2}$",
436
- refKind: "none",
437
- home: "table",
438
- },
439
- {
440
- anchor: "Backfill clause",
441
- presence: "conditional",
442
- valuePattern: "(Pending|\\[Pending\\])\\s*(→|->)\\s*\\S+",
443
- refKind: "version-lineage",
444
- home: "table",
445
- },
446
- {
447
- anchor: "Design claim token",
448
- presence: "conditional",
449
- valuePattern: "^P\\d+(\\.\\d+)*-design$",
450
- refKind: "spec-ref",
451
- home: "table",
452
- },
453
- {
454
- anchor: "Phase range ref",
455
- presence: "optional",
456
- valuePattern: "^P\\d+(\\.\\d+)*\\s*[-–—]\\s*P\\d+(\\.\\d+)*$",
457
- refKind: "phase-id",
458
- home: "table",
459
- },
460
- ] as const satisfies readonly Required<RegistryElement>[];
461
-
462
- // ---------------------------------------------------------------------------
463
- // plan — the task-block + header-field surface
464
- // ---------------------------------------------------------------------------
465
- const PLAN_ELEMENTS = [
466
- // Header block (H1 + header fields).
467
- {
468
- anchor: "# Title",
469
- presence: "required",
470
- valuePattern: "^# \\S.*$",
471
- refKind: "none",
472
- home: "header",
473
- },
474
- {
475
- anchor: "**Spec:**",
476
- presence: "required",
477
- valuePattern: "^\\*\\*Spec:\\*\\*\\s+\\[[^\\]]+\\]\\([^)]+\\)$",
478
- refKind: "spec-ref",
479
- home: "header",
480
- },
481
- {
482
- anchor: "**Parent program**",
483
- presence: "required",
484
- valuePattern: "^- \\*\\*Parent program\\*\\*:? \\[[^\\]]+\\]\\([^)]+\\)",
485
- refKind: "parent-program",
486
- home: "header",
487
- },
488
- {
489
- anchor: "**Version**",
490
- presence: "required",
491
- valuePattern: "^- \\*\\*Version\\*\\*: v\\d+\\.\\d+ · \\d{4}-\\d{2}-\\d{2}$",
492
- refKind: "version-lineage",
493
- home: "header",
494
- },
495
- {
496
- anchor: "**Depends on**",
497
- presence: "optional",
498
- valuePattern: "^- \\*\\*Depends on\\*\\*:",
499
- refKind: "phase-id",
500
- home: "header",
501
- },
502
- {
503
- anchor: "**Base**",
504
- presence: "optional",
505
- valuePattern: "^- \\*\\*Base\\*\\*:",
506
- refKind: "none",
507
- home: "header",
508
- },
509
- // Constraint surface (Form A delta-only).
510
- {
511
- anchor: "## Constraints",
512
- presence: "required",
513
- valuePattern: "^## Constraints$",
514
- refKind: "none",
515
- home: "section",
516
- },
517
- {
518
- anchor: "Constraint delta bullet",
519
- presence: "required",
520
- valuePattern: "^- ",
521
- refKind: "none",
522
- home: "section",
523
- },
524
- {
525
- anchor: "Constraint delta sub-heading",
526
- presence: "optional",
527
- valuePattern: "^### ",
528
- refKind: "none",
529
- home: "section",
530
- },
531
- // Task blocks — the `### Task N:` heading and its number identity. The heading
532
- // shape accepts the TITLED form (`### Task N: <title>` — the tree-wide canonical
533
- // form; the parse face anchors on `^### Task (\d+):`); the bare heading is one
534
- // instance of the same pattern, never a second form.
535
- {
536
- anchor: "### Task N:",
537
- presence: "required",
538
- valuePattern: "^### Task \\d+:( .*)?$",
539
- refKind: "none",
540
- home: "task-block",
541
- },
542
- {
543
- anchor: "Task id token",
544
- presence: "required",
545
- valuePattern: "^\\d+$",
546
- refKind: "task-id",
547
- home: "task-block",
548
- },
549
- // Task block fields.
550
- {
551
- anchor: "**Objective**",
552
- presence: "required",
553
- valuePattern: "^- \\*\\*Objective\\*\\*:",
554
- refKind: "none",
555
- home: "task-field",
556
- },
557
- {
558
- anchor: "**Files**",
559
- presence: "required",
560
- valuePattern: "^- \\*\\*Files\\*\\*:",
561
- refKind: "none",
562
- home: "task-field",
563
- },
564
- {
565
- anchor: "File path token",
566
- presence: "required",
567
- valuePattern: "^[\\w./-]+",
568
- refKind: "none",
569
- home: "task-field",
570
- },
571
- {
572
- anchor: "**Consumes**",
573
- presence: "required",
574
- valuePattern: "^- \\*\\*Consumes\\*\\*:",
575
- refKind: "none",
576
- home: "task-field",
577
- },
578
- {
579
- anchor: "**Produces**",
580
- presence: "required",
581
- valuePattern: "^- \\*\\*Produces\\*\\*:",
582
- refKind: "none",
583
- home: "task-field",
584
- },
585
- {
586
- anchor: "**Steps**",
587
- presence: "required",
588
- valuePattern: "^- \\*\\*Steps\\*\\*:",
589
- refKind: "none",
590
- home: "task-field",
591
- },
592
- // Step leaves — execution steps and their verifiable outcomes.
593
- {
594
- anchor: "Step action",
595
- presence: "required",
596
- valuePattern: "^- ",
597
- refKind: "none",
598
- home: "task-step",
599
- },
600
- {
601
- anchor: "Step checkable",
602
- presence: "required",
603
- valuePattern: "—\\s*checkable:\\s*\\S",
604
- refKind: "none",
605
- home: "task-step",
606
- },
607
- {
608
- anchor: "**Acceptance**",
609
- presence: "required",
610
- valuePattern: "^- \\*\\*Acceptance\\*\\*:",
611
- refKind: "none",
612
- home: "task-field",
613
- },
614
- // The single directed edge — declares which other tasks this one depends on
615
- // (any existing task id; forward references are legal — the anti-dependency gate
616
- // retired, T24; the value prefix carries the list, §3.8).
617
- {
618
- anchor: "**DependsOn**",
619
- presence: "required",
620
- valuePattern: "^- \\*\\*DependsOn\\*\\*:",
621
- refKind: "none",
622
- home: "task-field",
623
- },
624
- {
625
- anchor: "DependsOn none",
626
- presence: "optional",
627
- valuePattern: "^(none|\\s*)$",
628
- refKind: "none",
629
- home: "task-field",
630
- },
631
- {
632
- anchor: "DependsOn id",
633
- presence: "optional",
634
- valuePattern: "^[1-9]\\d*$",
635
- refKind: "task-id",
636
- home: "task-field",
637
- },
638
- // Reference-lint token — prose mentions of a task id (a WARN-only observation
639
- // surface; the crosslink invariant does NOT consume this element — the
640
- // reference-lint pass is its only consumer).
641
- {
642
- anchor: "Task prose reference",
643
- presence: "optional",
644
- valuePattern: "\\b(?:Task|T)\\s*([1-9]\\d*)\\b(?!\\.\\d)",
645
- refKind: "task-id",
646
- home: "task-field",
647
- },
648
- // Change history — the version-lineage surface (P4.1 T2 · overall-isomorphic): the
649
- // section heading + the row/version/date cells. Presence is required on the
650
- // heading (since P4.1 every plan carries a Change-history table); the row cells are
651
- // domain-judged on the table rows.
652
- {
653
- anchor: "## Change history",
654
- presence: "required",
655
- valuePattern: "^## Change history$",
656
- refKind: "none",
657
- home: "section",
658
- },
659
- {
660
- anchor: "Change history row",
661
- presence: "required",
662
- valuePattern: "^\\|\\s*v\\d+\\.\\d+\\s*\\|",
663
- refKind: "version-lineage",
664
- home: "table",
665
- },
666
- {
667
- anchor: "Version token",
668
- presence: "required",
669
- valuePattern: "^v\\d+\\.\\d+$",
670
- refKind: "version-lineage",
671
- home: "table",
672
- },
673
- {
674
- anchor: "Change history date",
675
- presence: "required",
676
- valuePattern: "^\\d{4}-\\d{2}-\\d{2}$",
677
- refKind: "none",
678
- home: "table",
679
- },
680
- ] as const satisfies readonly Required<RegistryElement>[];
681
-
682
- // ---------------------------------------------------------------------------
683
- // phase-spec — the skeleton surface
684
- // ---------------------------------------------------------------------------
685
- const PHASE_SPEC_ELEMENTS = [
686
- // Header five-tuple — `**Version**` strictly required.
687
- {
688
- anchor: "# Title",
689
- presence: "required",
690
- valuePattern: "^# \\S.*$",
691
- refKind: "none",
692
- home: "header",
693
- },
694
- {
695
- anchor: "**Version**",
696
- presence: "required",
697
- valuePattern: "^- \\*\\*Version\\*\\*: v\\d+\\.\\d+ · \\d{4}-\\d{2}-\\d{2}$",
698
- refKind: "version-lineage",
699
- home: "header",
700
- },
701
- {
702
- anchor: "**Status**",
703
- presence: "required",
704
- valuePattern: "^- \\*\\*Status\\*\\*: (Draft|Approved|Plan pending|Shipped)$",
705
- refKind: "none",
706
- home: "header",
707
- },
708
- {
709
- anchor: "**Author**",
710
- presence: "required",
711
- valuePattern: "^- \\*\\*Author\\*\\*:",
712
- refKind: "none",
713
- home: "header",
714
- },
715
- {
716
- anchor: "**Parent program**",
717
- presence: "required",
718
- valuePattern: "^- \\*\\*Parent program\\*\\*:? \\[[^\\]]+\\]\\([^)]+\\)",
719
- refKind: "parent-program",
720
- home: "header",
721
- },
722
- {
723
- anchor: "**Depends on**",
724
- presence: "required",
725
- valuePattern: "^- \\*\\*Depends on\\*\\*:",
726
- refKind: "none",
727
- home: "header",
728
- },
729
- {
730
- anchor: "Depends on ref",
731
- presence: "conditional",
732
- valuePattern: "^P\\d+(\\.\\d+)*",
733
- refKind: "phase-id",
734
- home: "header",
735
- },
736
- // The double-layer design body.
737
- {
738
- anchor: "## Design",
739
- presence: "required",
740
- valuePattern: "^## Design$",
741
- refKind: "none",
742
- home: "design-body",
743
- },
744
- {
745
- anchor: "### N. group heading",
746
- presence: "required",
747
- valuePattern: "^### \\d+\\. ",
748
- refKind: "none",
749
- home: "design-body",
750
- },
751
- {
752
- anchor: "#### N.M item heading",
753
- presence: "required",
754
- valuePattern: "^#### \\d+\\.\\d+ ",
755
- refKind: "none",
756
- home: "design-body",
757
- },
758
- {
759
- anchor: "### Acceptance criteria",
760
- presence: "required",
761
- valuePattern: "^### Acceptance criteria$",
762
- refKind: "none",
763
- home: "design-body",
764
- },
765
- {
766
- anchor: "Acceptance entry",
767
- presence: "required",
768
- valuePattern: "^- `",
769
- refKind: "none",
770
- home: "design-body",
771
- },
772
- // The inheritance-point constraint surface (delta-only).
773
- {
774
- anchor: "## Constraints",
775
- presence: "required",
776
- valuePattern: "^## Constraints$",
777
- refKind: "none",
778
- home: "section",
779
- },
780
- {
781
- anchor: "Constraint delta bullet",
782
- presence: "required",
783
- valuePattern: "^- ",
784
- refKind: "none",
785
- home: "section",
786
- },
787
- // Conditional sections — written only when their condition holds, zero residue otherwise.
788
- {
789
- anchor: "## Deviations",
790
- presence: "conditional",
791
- valuePattern: "^## Deviations$",
792
- refKind: "none",
793
- home: "conditional",
794
- },
795
- {
796
- anchor: "Deviations columns",
797
- presence: "conditional",
798
- valuePattern: "^\\| Overall assumption \\| Phase decision \\| Overall updated\\? \\|$",
799
- refKind: "none",
800
- home: "conditional",
801
- },
802
- {
803
- anchor: "Deviations row",
804
- presence: "conditional",
805
- valuePattern: "^\\|\\s*[^|]+\\s*\\|\\s*[^|]+\\s*\\|\\s*(Yes|No)\\b",
806
- refKind: "none",
807
- home: "conditional",
808
- },
809
- {
810
- anchor: "Overall updated answer",
811
- presence: "conditional",
812
- valuePattern: "^Yes",
813
- refKind: "none",
814
- home: "conditional",
815
- },
816
- {
817
- anchor: "## Incremental warning",
818
- presence: "conditional",
819
- valuePattern: "^## Incremental warning$",
820
- refKind: "none",
821
- home: "conditional",
822
- },
823
- {
824
- anchor: "## Notes for downstream",
825
- presence: "conditional",
826
- valuePattern: "^## Notes for downstream$",
827
- refKind: "none",
828
- home: "conditional",
829
- },
830
- {
831
- anchor: "## Review record",
832
- presence: "conditional",
833
- valuePattern: "^## Review record$",
834
- refKind: "none",
835
- home: "conditional",
836
- },
837
- // Change history — the version-lineage surface (P4.1 T2 · overall-isomorphic): the
838
- // section heading + the row/version/date cells. Presence is required on the
839
- // heading (since P4.1 every phase-spec carries a Change-history table).
840
- {
841
- anchor: "## Change history",
842
- presence: "required",
843
- valuePattern: "^## Change history$",
844
- refKind: "none",
845
- home: "section",
846
- },
847
- {
848
- anchor: "Change history row",
849
- presence: "required",
850
- valuePattern: "^\\|\\s*v\\d+\\.\\d+\\s*\\|",
851
- refKind: "version-lineage",
852
- home: "table",
853
- },
854
- {
855
- anchor: "Version token",
856
- presence: "required",
857
- valuePattern: "^v\\d+\\.\\d+$",
858
- refKind: "version-lineage",
859
- home: "table",
860
- },
861
- {
862
- anchor: "Change history date",
863
- presence: "required",
864
- valuePattern: "^\\d{4}-\\d{2}-\\d{2}$",
865
- refKind: "none",
866
- home: "table",
867
- },
868
- ] as const satisfies readonly Required<RegistryElement>[];
869
-
870
- // ---------------------------------------------------------------------------
871
- // single-spec — the lightweight free-form scaffold (P6 T2 · spec §2.1)
872
- // ---------------------------------------------------------------------------
873
- // The fourth doc type — the repair/ruling-oriented free-form document (the
874
- // 2026-09-28-cdd-review-contract-fix "single-spec" form). Deliberately lighter
875
- // than phase-spec: a header five-tuple (title / version / status / author /
876
- // `- **Depends on**`), four prose body sections and the change-history lineage.
877
- // No `### N.` double-layer outline (the free-form has no numbered design groups),
878
- // no `**Parent program**` requirement (a single-spec has no parent overall — an
879
- // independent program shape). The fixed section sequence runs in document order.
880
- const SINGLE_SPEC_ELEMENTS = [
881
- // Header five-tuple — title + the four bullet metadata rows.
882
- {
883
- anchor: "# Title",
884
- presence: "required",
885
- valuePattern: "^# \\S.*$",
886
- refKind: "none",
887
- home: "header",
888
- },
889
- {
890
- anchor: "**Version**",
891
- presence: "required",
892
- valuePattern: "^- \\*\\*Version\\*\\*: v\\d+\\.\\d+ · \\d{4}-\\d{2}-\\d{2}$",
893
- refKind: "version-lineage",
894
- home: "header",
895
- },
896
- {
897
- anchor: "**Status**",
898
- presence: "required",
899
- valuePattern: "^- \\*\\*Status\\*\\*: (Draft|Approved|In progress|Complete)$",
900
- refKind: "none",
901
- home: "header",
902
- },
903
- {
904
- anchor: "**Author**",
905
- presence: "required",
906
- valuePattern: "^- \\*\\*Author\\*\\*:",
907
- refKind: "none",
908
- home: "header",
909
- },
910
- {
911
- anchor: "**Depends on**",
912
- presence: "required",
913
- valuePattern: "^- \\*\\*Depends on\\*\\*:",
914
- refKind: "none",
915
- home: "header",
916
- },
917
- // The prose body surface — the free-form's four sections in document order.
918
- {
919
- anchor: "## Background & root cause",
920
- presence: "required",
921
- valuePattern: "^## Background & root cause$",
922
- refKind: "none",
923
- home: "section",
924
- },
925
- {
926
- anchor: "## Design decisions",
927
- presence: "required",
928
- valuePattern: "^## Design decisions$",
929
- refKind: "none",
930
- home: "section",
931
- },
932
- {
933
- anchor: "## Acceptance",
934
- presence: "required",
935
- valuePattern: "^## Acceptance$",
936
- refKind: "none",
937
- home: "section",
938
- },
939
- {
940
- anchor: "## Constraints",
941
- presence: "required",
942
- valuePattern: "^## Constraints$",
943
- refKind: "none",
944
- home: "section",
945
- },
946
- // Change history — the version-lineage surface (same shape as the other types).
947
- {
948
- anchor: "## Change history",
949
- presence: "required",
950
- valuePattern: "^## Change history$",
951
- refKind: "none",
952
- home: "section",
953
- },
954
- {
955
- anchor: "Change history row",
956
- presence: "required",
957
- valuePattern: "^\\|\\s*v\\d+\\.\\d+\\s*\\|",
958
- refKind: "version-lineage",
959
- home: "table",
960
- },
961
- {
962
- anchor: "Version token",
963
- presence: "required",
964
- valuePattern: "^v\\d+\\.\\d+$",
965
- refKind: "version-lineage",
966
- home: "table",
967
- },
968
- {
969
- anchor: "Change history date",
970
- presence: "required",
971
- valuePattern: "^\\d{4}-\\d{2}-\\d{2}$",
972
- refKind: "none",
973
- home: "table",
974
- },
975
- ] as const satisfies readonly Required<RegistryElement>[];
976
-
977
- /** The four declared registries — the judge's judgment data and the projection surfaces' derivation source. */
978
- export const declaredRegistries: DeclaredRegistries = {
979
- "overall-spec": { docType: "overall-spec", elements: OVERALL_SPEC_ELEMENTS },
980
- plan: { docType: "plan", elements: PLAN_ELEMENTS },
981
- "phase-spec": { docType: "phase-spec", elements: PHASE_SPEC_ELEMENTS },
982
- "single-spec": { docType: "single-spec", elements: SINGLE_SPEC_ELEMENTS },
983
- };