@oscaner-skills/cdd-engine 4.2.0 → 4.4.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.
Files changed (58) hide show
  1. package/README.md +38 -9
  2. package/README.zh-CN.md +44 -10
  3. package/dist/contract/completion-criterion.js +351 -0
  4. package/dist/contract/declare.js +181 -43
  5. package/dist/contract/doc.js +84 -271
  6. package/dist/contract/frontmatter.js +2 -1
  7. package/dist/contract/home-extractors.js +49 -316
  8. package/dist/contract/invariants.js +400 -296
  9. package/dist/contract/judge.js +74 -49
  10. package/dist/contract/lint.js +3 -2
  11. package/dist/contract/liveness-signal.js +103 -0
  12. package/dist/contract/markdown-document.js +410 -0
  13. package/dist/contract/markdown-tree-types.js +6 -0
  14. package/dist/contract/markdown-tree.js +137 -0
  15. package/dist/contract/project.js +1 -1
  16. package/dist/contract/rules.js +106 -0
  17. package/dist/contract/selector-engine.js +332 -0
  18. package/dist/contract/selector-spec.js +74 -0
  19. package/dist/contract/skill-anatomy.js +29 -1
  20. package/dist/contract/task-block-grammar.js +285 -0
  21. package/dist/contract/task-blocks.js +65 -0
  22. package/dist/contract/translate.js +21 -0
  23. package/dist/contract/wave-width.js +15 -0
  24. package/dist/face/board-view.js +382 -172
  25. package/dist/face/capsule.js +73 -88
  26. package/dist/face/cli.js +152 -38
  27. package/dist/face/declare.js +42 -19
  28. package/dist/face/gate.js +119 -40
  29. package/dist/face/init.js +84 -25
  30. package/dist/face/lifecycle.js +540 -123
  31. package/dist/face/plugins.js +70 -2
  32. package/dist/face/preview.js +69 -18
  33. package/dist/face/route-render.js +60 -21
  34. package/dist/face/termination.js +135 -261
  35. package/dist/face/words.js +139 -13
  36. package/dist/infra/atomic.js +15 -0
  37. package/dist/infra/git.js +25 -0
  38. package/dist/infra/proc.js +150 -0
  39. package/dist/infra/round-log.js +104 -0
  40. package/dist/infra/runtime.js +16 -4
  41. package/dist/infra/workspace.js +7 -2
  42. package/dist/render/brief.js +15 -17
  43. package/dist/render/skeleton.js +41 -28
  44. package/dist/render/templates.js +128 -84
  45. package/dist/session/faces.js +47 -20
  46. package/dist/session/graph.js +13 -37
  47. package/dist/session/handoff-schema.js +16 -8
  48. package/dist/session/inflight.js +282 -0
  49. package/dist/session/ledger.js +603 -145
  50. package/dist/session/line-identity.js +33 -0
  51. package/dist/session/next.js +140 -80
  52. package/dist/session/pipeline.js +247 -0
  53. package/dist/session/preflight.js +276 -68
  54. package/dist/session/reviewed-identity.js +54 -0
  55. package/dist/session/round-naming.js +56 -8
  56. package/dist/session/run.js +364 -80
  57. package/dist/session/wave.js +94 -14
  58. package/package.json +13 -3
@@ -19,6 +19,7 @@
19
19
  // (a completeness contract enforced by the array shape below and by the test
20
20
  // suite, which pins presence/ref-kind domains and per-registry anchor
21
21
  // uniqueness).
22
+ import { SelectorSpec } from "./selector-spec.js";
22
23
  // The legal value vocabularies — the single declared source the guards check
23
24
  // against. Each is pinned to its narrow union, so a domain drift fails the
24
25
  // compile.
@@ -48,6 +49,17 @@ const HOME_VALUES = [
48
49
  "design-body",
49
50
  "conditional",
50
51
  ];
52
+ const WALK_VALUES = [
53
+ "frontmatter",
54
+ "heading",
55
+ "table",
56
+ "row",
57
+ "cell",
58
+ "list",
59
+ "taskField",
60
+ "taskStep",
61
+ "graphEdge",
62
+ ];
51
63
  export const DOC_TYPE_VALUES = [
52
64
  "overall",
53
65
  "plan",
@@ -63,6 +75,12 @@ export const DOC_TYPE_VALUES = [
63
75
  * identity index (`SlugIndex.isLegalSlug`) compiles this SAME source string, so
64
76
  * the shape judgment has one grammar (this module is the leaf both planes read). */
65
77
  export const SLUG_VALUE_PATTERN = "^(?=.{1,128}$)[A-Za-z0-9][A-Za-z0-9._-]*$";
78
+ /** The legal `DependsOn id` value shape — one positive task id (whole-token). One
79
+ * declared constant: the `DependsOn id` element and the task-block reader (whose
80
+ * `dependsOn` token domain must accept exactly what the registry declares) compile
81
+ * this SAME source string, so the graph's edge domain and the lint's token domain
82
+ * can never drift apart. */
83
+ export const TASK_ID_VALUE_PATTERN = "^[1-9]\\d*$";
66
84
  /**
67
85
  * The registry guards — the runtime contract that narrows an unknown candidate
68
86
  * to a registry element or a full element registry. A static predicate class
@@ -91,6 +109,33 @@ export class RegistryGuard {
91
109
  if (typeof candidate.home !== "string" ||
92
110
  !HOME_VALUES.includes(candidate.home))
93
111
  return false;
112
+ return RegistryGuard.isSelector(candidate.selector);
113
+ }
114
+ /** Narrow a candidate to a well-formed selector: a known walk and a `from` chain
115
+ * that terminates at the document root. */
116
+ static isSelector(value) {
117
+ let current = value;
118
+ while (current !== "root") {
119
+ if (typeof current !== "object" || current === null)
120
+ return false;
121
+ const candidate = current;
122
+ if (typeof candidate.walk !== "string" ||
123
+ !WALK_VALUES.includes(candidate.walk))
124
+ return false;
125
+ if (candidate.match !== undefined && !(candidate.match instanceof RegExp)) {
126
+ if (typeof candidate.match !== "string")
127
+ return false;
128
+ }
129
+ if (candidate.when !== undefined &&
130
+ !["first", "last", "tableBody", "inTaskBlock"].includes(candidate.when))
131
+ return false;
132
+ if (candidate.column !== undefined &&
133
+ !(typeof candidate.column === "number" &&
134
+ Number.isInteger(candidate.column) &&
135
+ candidate.column > 0))
136
+ return false;
137
+ current = candidate.from;
138
+ }
94
139
  return true;
95
140
  }
96
141
  /** Narrow a candidate to a full element registry (doc type + all elements well-formed). */
@@ -118,6 +163,7 @@ const OVERALL_ELEMENTS = [
118
163
  valuePattern: "^.+$",
119
164
  refKind: "none",
120
165
  home: "frontmatter",
166
+ selector: SelectorSpec.frontmatter("title"),
121
167
  },
122
168
  {
123
169
  anchor: "doc-type",
@@ -125,6 +171,7 @@ const OVERALL_ELEMENTS = [
125
171
  valuePattern: `^(${DOC_TYPE_VALUES.join("|")})$`,
126
172
  refKind: "none",
127
173
  home: "frontmatter",
174
+ selector: SelectorSpec.frontmatter("doc-type"),
128
175
  },
129
176
  {
130
177
  anchor: "version",
@@ -132,6 +179,7 @@ const OVERALL_ELEMENTS = [
132
179
  valuePattern: "^v\\d+\\.\\d+$",
133
180
  refKind: "version-lineage",
134
181
  home: "frontmatter",
182
+ selector: SelectorSpec.frontmatter("version"),
135
183
  },
136
184
  {
137
185
  anchor: "date",
@@ -139,6 +187,7 @@ const OVERALL_ELEMENTS = [
139
187
  valuePattern: "^\\d{4}-\\d{2}-\\d{2}$",
140
188
  refKind: "none",
141
189
  home: "frontmatter",
190
+ selector: SelectorSpec.frontmatter("date"),
142
191
  },
143
192
  {
144
193
  anchor: "slug",
@@ -146,13 +195,7 @@ const OVERALL_ELEMENTS = [
146
195
  valuePattern: SLUG_VALUE_PATTERN,
147
196
  refKind: "none",
148
197
  home: "frontmatter",
149
- },
150
- {
151
- anchor: "status",
152
- presence: "required",
153
- valuePattern: "^(Draft|Approved|In progress|Complete)$",
154
- refKind: "none",
155
- home: "frontmatter",
198
+ selector: SelectorSpec.frontmatter("slug"),
156
199
  },
157
200
  {
158
201
  anchor: "author",
@@ -160,6 +203,7 @@ const OVERALL_ELEMENTS = [
160
203
  valuePattern: "^.+$",
161
204
  refKind: "none",
162
205
  home: "frontmatter",
206
+ selector: SelectorSpec.frontmatter("author"),
163
207
  },
164
208
  // `##`-ranked sections.
165
209
  {
@@ -168,6 +212,7 @@ const OVERALL_ELEMENTS = [
168
212
  valuePattern: "^## Document scope$",
169
213
  refKind: "none",
170
214
  home: "section",
215
+ selector: SelectorSpec.heading("## Document scope"),
171
216
  },
172
217
  {
173
218
  anchor: "## File paths",
@@ -175,6 +220,7 @@ const OVERALL_ELEMENTS = [
175
220
  valuePattern: "^## File paths$",
176
221
  refKind: "none",
177
222
  home: "section",
223
+ selector: SelectorSpec.heading("## File paths"),
178
224
  },
179
225
  {
180
226
  anchor: "## Program charter",
@@ -182,6 +228,7 @@ const OVERALL_ELEMENTS = [
182
228
  valuePattern: "^## Program charter$",
183
229
  refKind: "none",
184
230
  home: "section",
231
+ selector: SelectorSpec.heading("## Program charter"),
185
232
  },
186
233
  {
187
234
  anchor: "## Issue inventory",
@@ -189,6 +236,7 @@ const OVERALL_ELEMENTS = [
189
236
  valuePattern: "^## Issue inventory$",
190
237
  refKind: "none",
191
238
  home: "section",
239
+ selector: SelectorSpec.heading("## Issue inventory"),
192
240
  },
193
241
  {
194
242
  anchor: "## Phase inventory",
@@ -196,6 +244,7 @@ const OVERALL_ELEMENTS = [
196
244
  valuePattern: "^## Phase inventory$",
197
245
  refKind: "none",
198
246
  home: "section",
247
+ selector: SelectorSpec.heading("## Phase inventory"),
199
248
  },
200
249
  {
201
250
  anchor: "## Dependency graph",
@@ -203,6 +252,7 @@ const OVERALL_ELEMENTS = [
203
252
  valuePattern: "^## Dependency graph( \\(ASCII\\))?$",
204
253
  refKind: "none",
205
254
  home: "section",
255
+ selector: SelectorSpec.heading("## Dependency graph"),
206
256
  },
207
257
  {
208
258
  anchor: "## Boundary rules",
@@ -210,6 +260,7 @@ const OVERALL_ELEMENTS = [
210
260
  valuePattern: "^## Boundary rules$",
211
261
  refKind: "none",
212
262
  home: "section",
263
+ selector: SelectorSpec.heading("## Boundary rules"),
213
264
  },
214
265
  // The constraint surface (Form A delta-only) — the retired overall Constraints
215
266
  // header bullet normalised to the body section + its delta bullet (the body
@@ -220,6 +271,7 @@ const OVERALL_ELEMENTS = [
220
271
  valuePattern: "^## Constraints$",
221
272
  refKind: "none",
222
273
  home: "section",
274
+ selector: SelectorSpec.heading("## Constraints"),
223
275
  },
224
276
  {
225
277
  anchor: "Constraint delta bullet",
@@ -227,6 +279,7 @@ const OVERALL_ELEMENTS = [
227
279
  valuePattern: "^- ",
228
280
  refKind: "none",
229
281
  home: "section",
282
+ selector: SelectorSpec.list(SelectorSpec.heading("## Constraints"), /^- /),
230
283
  },
231
284
  {
232
285
  anchor: "## Maintenance",
@@ -234,6 +287,7 @@ const OVERALL_ELEMENTS = [
234
287
  valuePattern: "^## Maintenance$",
235
288
  refKind: "none",
236
289
  home: "section",
290
+ selector: SelectorSpec.heading("## Maintenance"),
237
291
  },
238
292
  {
239
293
  anchor: "## Change history",
@@ -241,6 +295,7 @@ const OVERALL_ELEMENTS = [
241
295
  valuePattern: "^## Change history$",
242
296
  refKind: "none",
243
297
  home: "section",
298
+ selector: SelectorSpec.heading("## Change history"),
244
299
  },
245
300
  // Charter facets (`###`/`####` leaves under the charter). The legacy Chinese
246
301
  // markers (the doc-arch decision-group leaves M/F/R/B/E, the doc-arch
@@ -253,6 +308,7 @@ const OVERALL_ELEMENTS = [
253
308
  valuePattern: "^### Goal",
254
309
  refKind: "none",
255
310
  home: "facet",
311
+ selector: SelectorSpec.heading("### Goal"),
256
312
  },
257
313
  {
258
314
  anchor: "### Non-goals",
@@ -260,6 +316,7 @@ const OVERALL_ELEMENTS = [
260
316
  valuePattern: "^### Non-goals",
261
317
  refKind: "none",
262
318
  home: "facet",
319
+ selector: SelectorSpec.heading("### Non-goals"),
263
320
  },
264
321
  {
265
322
  anchor: "### Cross-cutting",
@@ -267,6 +324,7 @@ const OVERALL_ELEMENTS = [
267
324
  valuePattern: "^### Cross-cutting",
268
325
  refKind: "none",
269
326
  home: "facet",
327
+ selector: SelectorSpec.heading("### Cross-cutting"),
270
328
  },
271
329
  {
272
330
  anchor: "#### [MFRBEN] group",
@@ -274,6 +332,7 @@ const OVERALL_ELEMENTS = [
274
332
  valuePattern: "^#### [MFRBEN] group",
275
333
  refKind: "none",
276
334
  home: "facet",
335
+ selector: SelectorSpec.heading(/^#### [MFRBEN] group/),
277
336
  },
278
337
  {
279
338
  anchor: "#### Upstream Endorsements",
@@ -281,6 +340,7 @@ const OVERALL_ELEMENTS = [
281
340
  valuePattern: "^#### Upstream Endorsements$",
282
341
  refKind: "none",
283
342
  home: "facet",
343
+ selector: SelectorSpec.heading("#### Upstream Endorsements"),
284
344
  },
285
345
  // Issue inventory — the anchor-registration domain.
286
346
  {
@@ -289,6 +349,7 @@ const OVERALL_ELEMENTS = [
289
349
  valuePattern: "^\\| Phase \\| Issue \\(ref\\) \\| Title summary \\|$",
290
350
  refKind: "none",
291
351
  home: "table",
352
+ selector: SelectorSpec.table(SelectorSpec.heading("## Issue inventory"), /^\| Phase \| Issue \(ref\) \| Title summary \|$/),
292
353
  },
293
354
  {
294
355
  anchor: "Issue row",
@@ -296,6 +357,7 @@ const OVERALL_ELEMENTS = [
296
357
  valuePattern: "^\\|\\s*P\\d+(\\.\\d+)*\\s*\\|",
297
358
  refKind: "issue-ref",
298
359
  home: "table",
360
+ selector: SelectorSpec.table(SelectorSpec.heading("## Issue inventory"), /^\|\s*P\d+(\.\d+)*\s*\|/),
299
361
  },
300
362
  {
301
363
  anchor: "Issue ref cell",
@@ -303,6 +365,7 @@ const OVERALL_ELEMENTS = [
303
365
  valuePattern: "^(none|#\\d+|\\[#\\d+\\]|#\\d+#issuecomment-\\d+|([^)]*)|\\([^)]*\\))$",
304
366
  refKind: "issue-ref",
305
367
  home: "table",
368
+ selector: SelectorSpec.cell(SelectorSpec.row(SelectorSpec.table(SelectorSpec.heading("## Issue inventory"), /^\|\s*P\d+(\.\d+)*\s*\|/)), /^(none|#\d+|\[#\d+\]|#\d+#issuecomment-\d+|([^)]*)|\([^)]*\))$/, 2),
306
369
  },
307
370
  {
308
371
  anchor: "issuecomment anchor",
@@ -310,6 +373,7 @@ const OVERALL_ELEMENTS = [
310
373
  valuePattern: "^#\\d+#issuecomment-\\d+$",
311
374
  refKind: "issue-ref",
312
375
  home: "table",
376
+ selector: SelectorSpec.cell(SelectorSpec.row(SelectorSpec.table(SelectorSpec.heading("## Issue inventory"), /^\|\s*P\d+(\.\d+)*\s*\|/)), /^#\d+#issuecomment-\d+$/, 2),
313
377
  },
314
378
  // Phase inventory row ledger.
315
379
  {
@@ -318,6 +382,7 @@ const OVERALL_ELEMENTS = [
318
382
  valuePattern: "^\\| # \\| Phase \\| Scope \\| Design spec \\| Implementation plan \\| Acceptance criteria \\| Dependency \\|$",
319
383
  refKind: "none",
320
384
  home: "table",
385
+ selector: SelectorSpec.table(SelectorSpec.heading("## Phase inventory"), /^\| # \| Phase \| Scope \| Design spec \| Implementation plan \| Acceptance criteria \| Dependency \|$/),
321
386
  },
322
387
  {
323
388
  anchor: "Phase row",
@@ -325,6 +390,7 @@ const OVERALL_ELEMENTS = [
325
390
  valuePattern: "^\\|\\s*P\\d+(\\.\\d+)*\\s*\\|",
326
391
  refKind: "phase-id",
327
392
  home: "table",
393
+ selector: SelectorSpec.table(SelectorSpec.heading("## Phase inventory"), /^\|\s*P\d+(\.\d+)*\s*\|/),
328
394
  },
329
395
  {
330
396
  anchor: "Phase id token",
@@ -332,20 +398,23 @@ const OVERALL_ELEMENTS = [
332
398
  valuePattern: "^P\\d+(\\.\\d+)*$",
333
399
  refKind: "phase-id",
334
400
  home: "table",
401
+ selector: SelectorSpec.cell(SelectorSpec.row(SelectorSpec.table(SelectorSpec.heading("## Phase inventory"), /^\|\s*P\d+(\.\d+)*\s*\|/)), /^P\d+(\.\d+)*$/, 1),
335
402
  },
336
403
  {
337
404
  anchor: "Implementation plan cell",
338
405
  presence: "required",
339
- valuePattern: "^(Pending|\\[Pending\\]|In-flight|\\[In-flight\\]|Done|\\[[^\\]]+\\]\\([^)]+\\))$",
406
+ valuePattern: "^(?:✔\\s*)?(?:Pending|\\[Pending\\]|In-flight|\\[In-flight\\]|Done|\\[[^\\]]+\\]\\([^)]+\\))(?:\\s*[((][^))]*[))])?(?:\\s+[\\s\\S]*)?$",
340
407
  refKind: "markdown-link",
341
408
  home: "table",
409
+ selector: SelectorSpec.cell(SelectorSpec.row(SelectorSpec.table(SelectorSpec.heading("## Phase inventory"), /^\|\s*P\d+(\.\d+)*\s*\|/)), /^(?:✔\s*)?(?:Pending|\[Pending\]|In-flight|\[In-flight\]|Done|\[[^\]]+\]\([^)]+\))/, 5),
342
410
  },
343
411
  {
344
412
  anchor: "Design spec cell",
345
413
  presence: "required",
346
- valuePattern: "^(\\[[^\\]]+\\]\\([^)]+\\)|P\\d+(\\.\\d+)*-design|Done|\\[Pending\\])$",
414
+ valuePattern: "^(?:✔\\s*)?(?:\\[[^\\]]+\\]\\([^)]+\\)|P\\d+(\\.\\d+)*-design|Done|\\[Pending\\])(?:\\s*[((][^))]*[))])?(?:\\s+[\\s\\S]*)?$",
347
415
  refKind: "none",
348
416
  home: "table",
417
+ selector: SelectorSpec.cell(SelectorSpec.row(SelectorSpec.table(SelectorSpec.heading("## Phase inventory"), /^\|\s*P\d+(\.\d+)*\s*\|/)), /^(?:✔\s*)?(?:\[[^\]]+\]\([^)]+\)|P\d+(\.\d+)*-design|Done|\[Pending\])/, 4),
349
418
  },
350
419
  {
351
420
  anchor: "Dependency cell",
@@ -353,6 +422,7 @@ const OVERALL_ELEMENTS = [
353
422
  valuePattern: "^P\\d+(\\.\\d+)*\\s*->",
354
423
  refKind: "phase-id",
355
424
  home: "table",
425
+ selector: SelectorSpec.cell(SelectorSpec.row(SelectorSpec.table(SelectorSpec.heading("## Phase inventory"), /^\|\s*P\d+(\.\d+)*\s*\|/)), /^P\d+(\.\d+)*\s*->/, 7),
356
426
  },
357
427
  // Dependency graph edges + legend.
358
428
  {
@@ -361,13 +431,15 @@ const OVERALL_ELEMENTS = [
361
431
  valuePattern: "^P\\d+(\\.\\d+)*\\s*->\\s*P\\d+(\\.\\d+)*",
362
432
  refKind: "phase-id",
363
433
  home: "graph",
434
+ selector: SelectorSpec.graphEdge("hard"),
364
435
  },
365
436
  {
366
437
  anchor: "Soft edge",
367
438
  presence: "optional",
368
- valuePattern: "^P\\d+(\\.\\d+)*\\s*->\\s*\\(?\\s*soft\\s*\\)?",
439
+ valuePattern: "^P\\d+(\\.\\d+)*\\s*->\\s*P\\d+(\\.\\d+)*\\s*\\(?\\s*soft\\s*\\)?",
369
440
  refKind: "phase-id",
370
441
  home: "graph",
442
+ selector: SelectorSpec.graphEdge("soft"),
371
443
  },
372
444
  {
373
445
  anchor: "Graph legend",
@@ -375,6 +447,7 @@ const OVERALL_ELEMENTS = [
375
447
  valuePattern: "^(?:- )?`?->\\s*(?:\\(soft\\))?\\s*`? = hard block|^(?:- )?`?->\\s*\\(soft\\)\\s*`? = suggestion only",
376
448
  refKind: "none",
377
449
  home: "graph",
450
+ selector: SelectorSpec.graphEdge(/->`?\s*=\s*hard block/),
378
451
  },
379
452
  // File paths artifact table.
380
453
  {
@@ -383,6 +456,7 @@ const OVERALL_ELEMENTS = [
383
456
  valuePattern: "^\\| [^|]+ \\| `[^`]+` \\|$",
384
457
  refKind: "none",
385
458
  home: "table",
459
+ selector: SelectorSpec.table(SelectorSpec.heading("## File paths"), /^\| [^|]+ \| `[^`]+` \|$/),
386
460
  },
387
461
  // Change history — the version-lineage surface.
388
462
  {
@@ -391,6 +465,7 @@ const OVERALL_ELEMENTS = [
391
465
  valuePattern: "^\\|\\s*v\\d+\\.\\d+\\s*\\|",
392
466
  refKind: "version-lineage",
393
467
  home: "table",
468
+ selector: SelectorSpec.table(SelectorSpec.heading("## Change history"), /^\|\s*v\d+\.\d+\s*\|/),
394
469
  },
395
470
  {
396
471
  anchor: "Version token",
@@ -398,6 +473,7 @@ const OVERALL_ELEMENTS = [
398
473
  valuePattern: "^v\\d+\\.\\d+$",
399
474
  refKind: "version-lineage",
400
475
  home: "table",
476
+ selector: SelectorSpec.cell(SelectorSpec.row(SelectorSpec.table(SelectorSpec.heading("## Change history"), /^\|\s*v\d+\.\d+\s*\|/)), /^v\d+\.\d+$/, 1),
401
477
  },
402
478
  {
403
479
  anchor: "Change history date",
@@ -405,6 +481,7 @@ const OVERALL_ELEMENTS = [
405
481
  valuePattern: "^\\d{4}-\\d{2}-\\d{2}$",
406
482
  refKind: "none",
407
483
  home: "table",
484
+ selector: SelectorSpec.cell(SelectorSpec.row(SelectorSpec.table(SelectorSpec.heading("## Change history"), /^\|\s*v\d+\.\d+\s*\|/)), /^\d{4}-\d{2}-\d{2}$/, 2),
408
485
  },
409
486
  {
410
487
  anchor: "Backfill clause",
@@ -412,6 +489,7 @@ const OVERALL_ELEMENTS = [
412
489
  valuePattern: "(Pending|\\[Pending\\])\\s*(→|->)\\s*\\S+",
413
490
  refKind: "version-lineage",
414
491
  home: "table",
492
+ selector: SelectorSpec.cell(SelectorSpec.row(SelectorSpec.table(SelectorSpec.heading("## Change history"), /^\|\s*v\d+\.\d+\s*\|/)), /(Pending|\[Pending\])\s*(→|->)\s*\S+/, 3),
415
493
  },
416
494
  {
417
495
  anchor: "Design claim token",
@@ -419,6 +497,7 @@ const OVERALL_ELEMENTS = [
419
497
  valuePattern: "^P\\d+(\\.\\d+)*-design$",
420
498
  refKind: "phase-id",
421
499
  home: "table",
500
+ selector: SelectorSpec.cell(SelectorSpec.row(SelectorSpec.table(SelectorSpec.heading("## Phase inventory"), /^\|\s*P\d+(\.\d+)*\s*\|/)), /^P\d+(\.\d+)*-design$/, 4),
422
501
  },
423
502
  {
424
503
  anchor: "Phase range ref",
@@ -426,6 +505,7 @@ const OVERALL_ELEMENTS = [
426
505
  valuePattern: "^P\\d+(\\.\\d+)*\\s*[-–—]\\s*P\\d+(\\.\\d+)*$",
427
506
  refKind: "phase-id",
428
507
  home: "table",
508
+ selector: SelectorSpec.cell(SelectorSpec.row(SelectorSpec.table(SelectorSpec.heading("## Phase inventory"), /^\|\s*P\d+(\.\d+)*\s*\|/)), /^P\d+(\.\d+)*\s*[-–—]\s*P\d+(\.\d+)*$/, 3),
429
509
  },
430
510
  ];
431
511
  // ---------------------------------------------------------------------------
@@ -433,14 +513,15 @@ const OVERALL_ELEMENTS = [
433
513
  // ---------------------------------------------------------------------------
434
514
  const PLAN_ELEMENTS = [
435
515
  // Header block — YAML front-matter keys (the frontmatter-home anchor IS the
436
- // front-matter key name). Plan deliberately omits `status` / `author` — no
437
- // plan head carries either row (the per-type presence contract of §2.3).
516
+ // front-matter key name). Plan deliberately omits `author` — no plan head
517
+ // carries that row (the per-type presence contract of §2.3).
438
518
  {
439
519
  anchor: "title",
440
520
  presence: "required",
441
521
  valuePattern: "^.+$",
442
522
  refKind: "none",
443
523
  home: "frontmatter",
524
+ selector: SelectorSpec.frontmatter("title"),
444
525
  },
445
526
  {
446
527
  anchor: "doc-type",
@@ -448,6 +529,7 @@ const PLAN_ELEMENTS = [
448
529
  valuePattern: `^(${DOC_TYPE_VALUES.join("|")})$`,
449
530
  refKind: "none",
450
531
  home: "frontmatter",
532
+ selector: SelectorSpec.frontmatter("doc-type"),
451
533
  },
452
534
  {
453
535
  anchor: "version",
@@ -455,6 +537,7 @@ const PLAN_ELEMENTS = [
455
537
  valuePattern: "^v\\d+\\.\\d+$",
456
538
  refKind: "version-lineage",
457
539
  home: "frontmatter",
540
+ selector: SelectorSpec.frontmatter("version"),
458
541
  },
459
542
  {
460
543
  anchor: "date",
@@ -462,6 +545,7 @@ const PLAN_ELEMENTS = [
462
545
  valuePattern: "^\\d{4}-\\d{2}-\\d{2}$",
463
546
  refKind: "none",
464
547
  home: "frontmatter",
548
+ selector: SelectorSpec.frontmatter("date"),
465
549
  },
466
550
  {
467
551
  anchor: "slug",
@@ -469,6 +553,7 @@ const PLAN_ELEMENTS = [
469
553
  valuePattern: SLUG_VALUE_PATTERN,
470
554
  refKind: "none",
471
555
  home: "frontmatter",
556
+ selector: SelectorSpec.frontmatter("slug"),
472
557
  },
473
558
  {
474
559
  anchor: "base",
@@ -476,6 +561,7 @@ const PLAN_ELEMENTS = [
476
561
  valuePattern: "^.+$",
477
562
  refKind: "none",
478
563
  home: "frontmatter",
564
+ selector: SelectorSpec.frontmatter("base"),
479
565
  },
480
566
  // Constraint surface (Form A delta-only).
481
567
  {
@@ -484,6 +570,7 @@ const PLAN_ELEMENTS = [
484
570
  valuePattern: "^## Constraints$",
485
571
  refKind: "none",
486
572
  home: "section",
573
+ selector: SelectorSpec.heading("## Constraints"),
487
574
  },
488
575
  {
489
576
  anchor: "Constraint delta bullet",
@@ -491,6 +578,7 @@ const PLAN_ELEMENTS = [
491
578
  valuePattern: "^- ",
492
579
  refKind: "none",
493
580
  home: "section",
581
+ selector: SelectorSpec.list(SelectorSpec.heading("## Constraints"), /^- /),
494
582
  },
495
583
  {
496
584
  anchor: "Constraint delta sub-heading",
@@ -498,6 +586,7 @@ const PLAN_ELEMENTS = [
498
586
  valuePattern: "^### ",
499
587
  refKind: "none",
500
588
  home: "section",
589
+ selector: SelectorSpec.heading(/^### /, SelectorSpec.heading("## Constraints")),
501
590
  },
502
591
  // Task blocks — the `### Task N:` heading and its number identity. The heading
503
592
  // shape accepts the TITLED form (`### Task N: <title>` — the tree-wide canonical
@@ -509,6 +598,7 @@ const PLAN_ELEMENTS = [
509
598
  valuePattern: "^### Task \\d+:( .*)?$",
510
599
  refKind: "none",
511
600
  home: "task-block",
601
+ selector: SelectorSpec.heading(/^### Task \d+:/),
512
602
  },
513
603
  {
514
604
  anchor: "Task id token",
@@ -516,21 +606,27 @@ const PLAN_ELEMENTS = [
516
606
  valuePattern: "^\\d+$",
517
607
  refKind: "task-id",
518
608
  home: "task-block",
609
+ selector: SelectorSpec.heading(/^### Task ([1-9]\d*):/),
519
610
  },
520
- // Task block fields.
611
+ // Task block sections — the seven reserved `#### Key` headings (P21 §7). The
612
+ // legacy bullet shape (`- **Key**: …`) carries NO declaration of its own: the
613
+ // `PlanTaskBlocksReader` normalizes it into the same block record, so the field
614
+ // key/token surface below judges both shapes by one declaration.
521
615
  {
522
- anchor: "**Objective**",
616
+ anchor: "#### Objective",
523
617
  presence: "required",
524
- valuePattern: "^- \\*\\*Objective\\*\\*:",
618
+ valuePattern: "^#### Objective$",
525
619
  refKind: "none",
526
620
  home: "task-field",
621
+ selector: SelectorSpec.taskField("#### Objective"),
527
622
  },
528
623
  {
529
- anchor: "**Files**",
624
+ anchor: "#### Files",
530
625
  presence: "required",
531
- valuePattern: "^- \\*\\*Files\\*\\*:",
626
+ valuePattern: "^#### Files$",
532
627
  refKind: "none",
533
628
  home: "task-field",
629
+ selector: SelectorSpec.taskField("#### Files"),
534
630
  },
535
631
  {
536
632
  anchor: "File path token",
@@ -538,27 +634,31 @@ const PLAN_ELEMENTS = [
538
634
  valuePattern: "^[\\w./-]+",
539
635
  refKind: "none",
540
636
  home: "task-field",
637
+ selector: SelectorSpec.taskField(/^[\w./-]+/, SelectorSpec.taskField("#### Files")),
541
638
  },
542
639
  {
543
- anchor: "**Consumes**",
640
+ anchor: "#### Consumes",
544
641
  presence: "required",
545
- valuePattern: "^- \\*\\*Consumes\\*\\*:",
642
+ valuePattern: "^#### Consumes$",
546
643
  refKind: "none",
547
644
  home: "task-field",
645
+ selector: SelectorSpec.taskField("#### Consumes"),
548
646
  },
549
647
  {
550
- anchor: "**Produces**",
648
+ anchor: "#### Produces",
551
649
  presence: "required",
552
- valuePattern: "^- \\*\\*Produces\\*\\*:",
650
+ valuePattern: "^#### Produces$",
553
651
  refKind: "none",
554
652
  home: "task-field",
653
+ selector: SelectorSpec.taskField("#### Produces"),
555
654
  },
556
655
  {
557
- anchor: "**Steps**",
656
+ anchor: "#### Steps",
558
657
  presence: "required",
559
- valuePattern: "^- \\*\\*Steps\\*\\*:",
658
+ valuePattern: "^#### Steps$",
560
659
  refKind: "none",
561
660
  home: "task-field",
661
+ selector: SelectorSpec.taskField("#### Steps"),
562
662
  },
563
663
  // Step leaves — execution steps and their verifiable outcomes.
564
664
  {
@@ -567,6 +667,7 @@ const PLAN_ELEMENTS = [
567
667
  valuePattern: "^- ",
568
668
  refKind: "none",
569
669
  home: "task-step",
670
+ selector: SelectorSpec.taskStep(/^- /),
570
671
  },
571
672
  {
572
673
  anchor: "Step checkable",
@@ -574,23 +675,26 @@ const PLAN_ELEMENTS = [
574
675
  valuePattern: "—\\s*checkable:\\s*\\S",
575
676
  refKind: "none",
576
677
  home: "task-step",
678
+ selector: SelectorSpec.taskStep(/—+\s*checkable:\s*\S/),
577
679
  },
578
680
  {
579
- anchor: "**Acceptance**",
681
+ anchor: "#### Acceptance",
580
682
  presence: "required",
581
- valuePattern: "^- \\*\\*Acceptance\\*\\*:",
683
+ valuePattern: "^#### Acceptance$",
582
684
  refKind: "none",
583
685
  home: "task-field",
686
+ selector: SelectorSpec.taskField("#### Acceptance"),
584
687
  },
585
688
  // The single directed edge — declares which other tasks this one depends on
586
689
  // (any existing task id; forward references are legal — the anti-dependency gate
587
690
  // retired, T24; the value prefix carries the list, §3.8).
588
691
  {
589
- anchor: "**DependsOn**",
692
+ anchor: "#### DependsOn",
590
693
  presence: "required",
591
- valuePattern: "^- \\*\\*DependsOn\\*\\*:",
694
+ valuePattern: "^#### DependsOn$",
592
695
  refKind: "none",
593
696
  home: "task-field",
697
+ selector: SelectorSpec.taskField("#### DependsOn"),
594
698
  },
595
699
  {
596
700
  anchor: "DependsOn none",
@@ -598,13 +702,15 @@ const PLAN_ELEMENTS = [
598
702
  valuePattern: "^(none|\\s*)$",
599
703
  refKind: "none",
600
704
  home: "task-field",
705
+ selector: SelectorSpec.taskField(/^(none|\s*)$/, SelectorSpec.taskField("#### DependsOn")),
601
706
  },
602
707
  {
603
708
  anchor: "DependsOn id",
604
709
  presence: "optional",
605
- valuePattern: "^[1-9]\\d*$",
710
+ valuePattern: TASK_ID_VALUE_PATTERN,
606
711
  refKind: "task-id",
607
712
  home: "task-field",
713
+ selector: SelectorSpec.taskField(/^[1-9]\d*$/, SelectorSpec.taskField("#### DependsOn")),
608
714
  },
609
715
  // Reference-lint token — prose mentions of a task id (a WARN-only observation
610
716
  // surface; the crosslink invariant does NOT consume this element — the
@@ -615,6 +721,7 @@ const PLAN_ELEMENTS = [
615
721
  valuePattern: "\\b(?:Task|T)\\s*([1-9]\\d*)\\b(?!\\.\\d)",
616
722
  refKind: "task-id",
617
723
  home: "task-field",
724
+ selector: SelectorSpec.taskField(/\b(?:Task|T)\s*([1-9]\d*)\b(?!\.\d)/),
618
725
  },
619
726
  // Change history — the version-lineage surface (P4.1 T2 · overall-isomorphic): the
620
727
  // section heading + the row/version/date cells. Presence is required on the
@@ -626,6 +733,7 @@ const PLAN_ELEMENTS = [
626
733
  valuePattern: "^## Change history$",
627
734
  refKind: "none",
628
735
  home: "section",
736
+ selector: SelectorSpec.heading("## Change history"),
629
737
  },
630
738
  {
631
739
  anchor: "Change history row",
@@ -633,6 +741,7 @@ const PLAN_ELEMENTS = [
633
741
  valuePattern: "^\\|\\s*v\\d+\\.\\d+\\s*\\|",
634
742
  refKind: "version-lineage",
635
743
  home: "table",
744
+ selector: SelectorSpec.table(SelectorSpec.heading("## Change history"), /^\|\s*v\d+\.\d+\s*\|/),
636
745
  },
637
746
  {
638
747
  anchor: "Version token",
@@ -640,6 +749,7 @@ const PLAN_ELEMENTS = [
640
749
  valuePattern: "^v\\d+\\.\\d+$",
641
750
  refKind: "version-lineage",
642
751
  home: "table",
752
+ selector: SelectorSpec.cell(SelectorSpec.row(SelectorSpec.table(SelectorSpec.heading("## Change history"), /^\|\s*v\d+\.\d+\s*\|/)), /^v\d+\.\d+$/, 1),
643
753
  },
644
754
  {
645
755
  anchor: "Change history date",
@@ -647,6 +757,7 @@ const PLAN_ELEMENTS = [
647
757
  valuePattern: "^\\d{4}-\\d{2}-\\d{2}$",
648
758
  refKind: "none",
649
759
  home: "table",
760
+ selector: SelectorSpec.cell(SelectorSpec.row(SelectorSpec.table(SelectorSpec.heading("## Change history"), /^\|\s*v\d+\.\d+\s*\|/)), /^\d{4}-\d{2}-\d{2}$/, 2),
650
761
  },
651
762
  ];
652
763
  // ---------------------------------------------------------------------------
@@ -662,6 +773,7 @@ const PHASE_SPEC_ELEMENTS = [
662
773
  valuePattern: "^.+$",
663
774
  refKind: "none",
664
775
  home: "frontmatter",
776
+ selector: SelectorSpec.frontmatter("title"),
665
777
  },
666
778
  {
667
779
  anchor: "doc-type",
@@ -669,6 +781,7 @@ const PHASE_SPEC_ELEMENTS = [
669
781
  valuePattern: `^(${DOC_TYPE_VALUES.join("|")})$`,
670
782
  refKind: "none",
671
783
  home: "frontmatter",
784
+ selector: SelectorSpec.frontmatter("doc-type"),
672
785
  },
673
786
  {
674
787
  anchor: "version",
@@ -676,6 +789,7 @@ const PHASE_SPEC_ELEMENTS = [
676
789
  valuePattern: "^v\\d+\\.\\d+$",
677
790
  refKind: "version-lineage",
678
791
  home: "frontmatter",
792
+ selector: SelectorSpec.frontmatter("version"),
679
793
  },
680
794
  {
681
795
  anchor: "date",
@@ -683,6 +797,7 @@ const PHASE_SPEC_ELEMENTS = [
683
797
  valuePattern: "^\\d{4}-\\d{2}-\\d{2}$",
684
798
  refKind: "none",
685
799
  home: "frontmatter",
800
+ selector: SelectorSpec.frontmatter("date"),
686
801
  },
687
802
  {
688
803
  anchor: "slug",
@@ -690,6 +805,7 @@ const PHASE_SPEC_ELEMENTS = [
690
805
  valuePattern: SLUG_VALUE_PATTERN,
691
806
  refKind: "none",
692
807
  home: "frontmatter",
808
+ selector: SelectorSpec.frontmatter("slug"),
693
809
  },
694
810
  {
695
811
  anchor: "program",
@@ -697,13 +813,7 @@ const PHASE_SPEC_ELEMENTS = [
697
813
  valuePattern: SLUG_VALUE_PATTERN,
698
814
  refKind: "slug-ref",
699
815
  home: "frontmatter",
700
- },
701
- {
702
- anchor: "status",
703
- presence: "required",
704
- valuePattern: "^(Draft|Approved|Plan pending|Shipped)$",
705
- refKind: "none",
706
- home: "frontmatter",
816
+ selector: SelectorSpec.frontmatter("program"),
707
817
  },
708
818
  {
709
819
  anchor: "author",
@@ -711,6 +821,7 @@ const PHASE_SPEC_ELEMENTS = [
711
821
  valuePattern: "^.+$",
712
822
  refKind: "none",
713
823
  home: "frontmatter",
824
+ selector: SelectorSpec.frontmatter("author"),
714
825
  },
715
826
  {
716
827
  anchor: "parent-version",
@@ -718,6 +829,7 @@ const PHASE_SPEC_ELEMENTS = [
718
829
  valuePattern: "^v\\d+\\.\\d+$",
719
830
  refKind: "version-lineage",
720
831
  home: "frontmatter",
832
+ selector: SelectorSpec.frontmatter("parent-version"),
721
833
  },
722
834
  // The double-layer design body.
723
835
  {
@@ -726,6 +838,7 @@ const PHASE_SPEC_ELEMENTS = [
726
838
  valuePattern: "^## Design$",
727
839
  refKind: "none",
728
840
  home: "design-body",
841
+ selector: SelectorSpec.heading("## Design"),
729
842
  },
730
843
  {
731
844
  anchor: "### N. group heading",
@@ -733,6 +846,7 @@ const PHASE_SPEC_ELEMENTS = [
733
846
  valuePattern: "^### \\d+\\. ",
734
847
  refKind: "none",
735
848
  home: "design-body",
849
+ selector: SelectorSpec.heading(/^### \d+\. /, SelectorSpec.heading("## Design")),
736
850
  },
737
851
  {
738
852
  anchor: "#### N.M item heading",
@@ -740,6 +854,7 @@ const PHASE_SPEC_ELEMENTS = [
740
854
  valuePattern: "^#### \\d+\\.\\d+ ",
741
855
  refKind: "none",
742
856
  home: "design-body",
857
+ selector: SelectorSpec.heading(/^#### \d+\.\d+ /, SelectorSpec.heading("## Design")),
743
858
  },
744
859
  {
745
860
  anchor: "### Acceptance criteria",
@@ -747,6 +862,7 @@ const PHASE_SPEC_ELEMENTS = [
747
862
  valuePattern: "^### Acceptance criteria$",
748
863
  refKind: "none",
749
864
  home: "design-body",
865
+ selector: SelectorSpec.heading("### Acceptance criteria"),
750
866
  },
751
867
  {
752
868
  anchor: "Acceptance entry",
@@ -754,6 +870,7 @@ const PHASE_SPEC_ELEMENTS = [
754
870
  valuePattern: "^- `",
755
871
  refKind: "none",
756
872
  home: "design-body",
873
+ selector: SelectorSpec.list(SelectorSpec.heading("### Acceptance criteria"), /^- `/),
757
874
  },
758
875
  // The inheritance-point constraint surface (delta-only).
759
876
  {
@@ -762,6 +879,7 @@ const PHASE_SPEC_ELEMENTS = [
762
879
  valuePattern: "^## Constraints$",
763
880
  refKind: "none",
764
881
  home: "section",
882
+ selector: SelectorSpec.heading("## Constraints"),
765
883
  },
766
884
  {
767
885
  anchor: "Constraint delta bullet",
@@ -769,6 +887,7 @@ const PHASE_SPEC_ELEMENTS = [
769
887
  valuePattern: "^- ",
770
888
  refKind: "none",
771
889
  home: "section",
890
+ selector: SelectorSpec.list(SelectorSpec.heading("## Constraints"), /^- /),
772
891
  },
773
892
  // Conditional sections — written only when their condition holds, zero residue otherwise.
774
893
  {
@@ -777,6 +896,7 @@ const PHASE_SPEC_ELEMENTS = [
777
896
  valuePattern: "^## Deviations$",
778
897
  refKind: "none",
779
898
  home: "conditional",
899
+ selector: SelectorSpec.heading("## Deviations"),
780
900
  },
781
901
  {
782
902
  anchor: "Deviations columns",
@@ -784,6 +904,7 @@ const PHASE_SPEC_ELEMENTS = [
784
904
  valuePattern: "^\\| Overall assumption \\| Phase decision \\| Overall updated\\? \\|$",
785
905
  refKind: "none",
786
906
  home: "conditional",
907
+ selector: SelectorSpec.table("root", /^\| Overall assumption \| Phase decision \| Overall updated\? \|$/),
787
908
  },
788
909
  {
789
910
  anchor: "Deviations row",
@@ -791,6 +912,7 @@ const PHASE_SPEC_ELEMENTS = [
791
912
  valuePattern: "^\\|\\s*[^|]+\\s*\\|\\s*[^|]+\\s*\\|\\s*(Yes|No)\\b",
792
913
  refKind: "none",
793
914
  home: "conditional",
915
+ selector: SelectorSpec.table("root", /^\|\s*[^|]+\s*\|\s*[^|]+\s*\|\s*(Yes|No)\b/),
794
916
  },
795
917
  {
796
918
  anchor: "Overall updated answer",
@@ -798,6 +920,7 @@ const PHASE_SPEC_ELEMENTS = [
798
920
  valuePattern: "^Yes",
799
921
  refKind: "none",
800
922
  home: "conditional",
923
+ selector: SelectorSpec.cell(SelectorSpec.row(SelectorSpec.table("root", /^\|\s*[^|]+\s*\|\s*[^|]+\s*\|\s*(Yes|No)\b/)), /^Yes/, 3),
801
924
  },
802
925
  {
803
926
  anchor: "## Incremental warning",
@@ -805,6 +928,7 @@ const PHASE_SPEC_ELEMENTS = [
805
928
  valuePattern: "^## Incremental warning$",
806
929
  refKind: "none",
807
930
  home: "conditional",
931
+ selector: SelectorSpec.heading("## Incremental warning"),
808
932
  },
809
933
  {
810
934
  anchor: "## Notes for downstream",
@@ -812,6 +936,7 @@ const PHASE_SPEC_ELEMENTS = [
812
936
  valuePattern: "^## Notes for downstream$",
813
937
  refKind: "none",
814
938
  home: "conditional",
939
+ selector: SelectorSpec.heading("## Notes for downstream"),
815
940
  },
816
941
  {
817
942
  anchor: "## Review record",
@@ -819,6 +944,7 @@ const PHASE_SPEC_ELEMENTS = [
819
944
  valuePattern: "^## Review record$",
820
945
  refKind: "none",
821
946
  home: "conditional",
947
+ selector: SelectorSpec.heading("## Review record"),
822
948
  },
823
949
  // Change history — the version-lineage surface (P4.1 T2 · overall-isomorphic): the
824
950
  // section heading + the row/version/date cells. Presence is required on the
@@ -829,6 +955,7 @@ const PHASE_SPEC_ELEMENTS = [
829
955
  valuePattern: "^## Change history$",
830
956
  refKind: "none",
831
957
  home: "section",
958
+ selector: SelectorSpec.heading("## Change history"),
832
959
  },
833
960
  {
834
961
  anchor: "Change history row",
@@ -836,6 +963,7 @@ const PHASE_SPEC_ELEMENTS = [
836
963
  valuePattern: "^\\|\\s*v\\d+\\.\\d+\\s*\\|",
837
964
  refKind: "version-lineage",
838
965
  home: "table",
966
+ selector: SelectorSpec.table(SelectorSpec.heading("## Change history"), /^\|\s*v\d+\.\d+\s*\|/),
839
967
  },
840
968
  {
841
969
  anchor: "Version token",
@@ -843,6 +971,7 @@ const PHASE_SPEC_ELEMENTS = [
843
971
  valuePattern: "^v\\d+\\.\\d+$",
844
972
  refKind: "version-lineage",
845
973
  home: "table",
974
+ selector: SelectorSpec.cell(SelectorSpec.row(SelectorSpec.table(SelectorSpec.heading("## Change history"), /^\|\s*v\d+\.\d+\s*\|/)), /^v\d+\.\d+$/, 1),
846
975
  },
847
976
  {
848
977
  anchor: "Change history date",
@@ -850,6 +979,7 @@ const PHASE_SPEC_ELEMENTS = [
850
979
  valuePattern: "^\\d{4}-\\d{2}-\\d{2}$",
851
980
  refKind: "none",
852
981
  home: "table",
982
+ selector: SelectorSpec.cell(SelectorSpec.row(SelectorSpec.table(SelectorSpec.heading("## Change history"), /^\|\s*v\d+\.\d+\s*\|/)), /^\d{4}-\d{2}-\d{2}$/, 2),
853
983
  },
854
984
  ];
855
985
  // ---------------------------------------------------------------------------
@@ -858,7 +988,7 @@ const PHASE_SPEC_ELEMENTS = [
858
988
  // The fourth doc type — the repair/ruling-oriented free-form document (the
859
989
  // 2026-09-28-cdd-review-contract-fix "single-spec" form). Deliberately lighter
860
990
  // than phase-spec: a front-matter key set (title / doc-type / version / date /
861
- // status / author / issues), four prose body sections and the
991
+ // author / issues), four prose body sections and the
862
992
  // change-history lineage. No `### N.` double-layer outline (the free-form has no
863
993
  // numbered design groups), no `program:` key (a single-spec is an independent
864
994
  // program — it names no parent overall). The fixed section sequence runs in
@@ -873,6 +1003,7 @@ const SINGLE_SPEC_ELEMENTS = [
873
1003
  valuePattern: "^.+$",
874
1004
  refKind: "none",
875
1005
  home: "frontmatter",
1006
+ selector: SelectorSpec.frontmatter("title"),
876
1007
  },
877
1008
  {
878
1009
  anchor: "doc-type",
@@ -880,6 +1011,7 @@ const SINGLE_SPEC_ELEMENTS = [
880
1011
  valuePattern: `^(${DOC_TYPE_VALUES.join("|")})$`,
881
1012
  refKind: "none",
882
1013
  home: "frontmatter",
1014
+ selector: SelectorSpec.frontmatter("doc-type"),
883
1015
  },
884
1016
  {
885
1017
  anchor: "version",
@@ -887,6 +1019,7 @@ const SINGLE_SPEC_ELEMENTS = [
887
1019
  valuePattern: "^v\\d+\\.\\d+$",
888
1020
  refKind: "version-lineage",
889
1021
  home: "frontmatter",
1022
+ selector: SelectorSpec.frontmatter("version"),
890
1023
  },
891
1024
  {
892
1025
  anchor: "date",
@@ -894,6 +1027,7 @@ const SINGLE_SPEC_ELEMENTS = [
894
1027
  valuePattern: "^\\d{4}-\\d{2}-\\d{2}$",
895
1028
  refKind: "none",
896
1029
  home: "frontmatter",
1030
+ selector: SelectorSpec.frontmatter("date"),
897
1031
  },
898
1032
  {
899
1033
  anchor: "slug",
@@ -901,13 +1035,7 @@ const SINGLE_SPEC_ELEMENTS = [
901
1035
  valuePattern: SLUG_VALUE_PATTERN,
902
1036
  refKind: "none",
903
1037
  home: "frontmatter",
904
- },
905
- {
906
- anchor: "status",
907
- presence: "required",
908
- valuePattern: "^(Draft|Approved|In progress|Complete)$",
909
- refKind: "none",
910
- home: "frontmatter",
1038
+ selector: SelectorSpec.frontmatter("slug"),
911
1039
  },
912
1040
  {
913
1041
  anchor: "author",
@@ -915,6 +1043,7 @@ const SINGLE_SPEC_ELEMENTS = [
915
1043
  valuePattern: "^.+$",
916
1044
  refKind: "none",
917
1045
  home: "frontmatter",
1046
+ selector: SelectorSpec.frontmatter("author"),
918
1047
  },
919
1048
  {
920
1049
  anchor: "issues",
@@ -922,6 +1051,7 @@ const SINGLE_SPEC_ELEMENTS = [
922
1051
  valuePattern: "^.+$",
923
1052
  refKind: "none",
924
1053
  home: "frontmatter",
1054
+ selector: SelectorSpec.frontmatter("issues"),
925
1055
  },
926
1056
  // The prose body surface — the free-form's four sections in document order.
927
1057
  {
@@ -930,6 +1060,7 @@ const SINGLE_SPEC_ELEMENTS = [
930
1060
  valuePattern: "^## Background & root cause$",
931
1061
  refKind: "none",
932
1062
  home: "section",
1063
+ selector: SelectorSpec.heading("## Background & root cause"),
933
1064
  },
934
1065
  {
935
1066
  anchor: "## Design decisions",
@@ -937,6 +1068,7 @@ const SINGLE_SPEC_ELEMENTS = [
937
1068
  valuePattern: "^## Design decisions$",
938
1069
  refKind: "none",
939
1070
  home: "section",
1071
+ selector: SelectorSpec.heading("## Design decisions"),
940
1072
  },
941
1073
  {
942
1074
  anchor: "## Acceptance",
@@ -944,6 +1076,7 @@ const SINGLE_SPEC_ELEMENTS = [
944
1076
  valuePattern: "^## Acceptance$",
945
1077
  refKind: "none",
946
1078
  home: "section",
1079
+ selector: SelectorSpec.heading("## Acceptance"),
947
1080
  },
948
1081
  {
949
1082
  anchor: "## Constraints",
@@ -951,6 +1084,7 @@ const SINGLE_SPEC_ELEMENTS = [
951
1084
  valuePattern: "^## Constraints$",
952
1085
  refKind: "none",
953
1086
  home: "section",
1087
+ selector: SelectorSpec.heading("## Constraints"),
954
1088
  },
955
1089
  // Change history — the version-lineage surface (same shape as the other types).
956
1090
  {
@@ -959,6 +1093,7 @@ const SINGLE_SPEC_ELEMENTS = [
959
1093
  valuePattern: "^## Change history$",
960
1094
  refKind: "none",
961
1095
  home: "section",
1096
+ selector: SelectorSpec.heading("## Change history"),
962
1097
  },
963
1098
  {
964
1099
  anchor: "Change history row",
@@ -966,6 +1101,7 @@ const SINGLE_SPEC_ELEMENTS = [
966
1101
  valuePattern: "^\\|\\s*v\\d+\\.\\d+\\s*\\|",
967
1102
  refKind: "version-lineage",
968
1103
  home: "table",
1104
+ selector: SelectorSpec.table(SelectorSpec.heading("## Change history"), /^\|\s*v\d+\.\d+\s*\|/),
969
1105
  },
970
1106
  {
971
1107
  anchor: "Version token",
@@ -973,6 +1109,7 @@ const SINGLE_SPEC_ELEMENTS = [
973
1109
  valuePattern: "^v\\d+\\.\\d+$",
974
1110
  refKind: "version-lineage",
975
1111
  home: "table",
1112
+ selector: SelectorSpec.cell(SelectorSpec.row(SelectorSpec.table(SelectorSpec.heading("## Change history"), /^\|\s*v\d+\.\d+\s*\|/)), /^v\d+\.\d+$/, 1),
976
1113
  },
977
1114
  {
978
1115
  anchor: "Change history date",
@@ -980,6 +1117,7 @@ const SINGLE_SPEC_ELEMENTS = [
980
1117
  valuePattern: "^\\d{4}-\\d{2}-\\d{2}$",
981
1118
  refKind: "none",
982
1119
  home: "table",
1120
+ selector: SelectorSpec.cell(SelectorSpec.row(SelectorSpec.table(SelectorSpec.heading("## Change history"), /^\|\s*v\d+\.\d+\s*\|/)), /^\d{4}-\d{2}-\d{2}$/, 2),
983
1121
  },
984
1122
  ];
985
1123
  /** The four declared registries — the judge's judgment data and the projection surfaces' derivation source. */