@oscaner-skills/cdd-engine 2.0.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/README.md +2 -2
  2. package/README.zh-CN.md +2 -2
  3. package/package.json +4 -3
  4. package/src-next/__tests__/dead-decl.guard.test.ts +39 -0
  5. package/src-next/__tests__/floor.guard.test.ts +69 -0
  6. package/src-next/__tests__/issue-body.guard.test.ts +66 -0
  7. package/src-next/__tests__/phase-suffix.guard.test.ts +72 -0
  8. package/src-next/__tests__/smoke.integration.test.ts +60 -77
  9. package/src-next/__tests__/support/strip-comments.ts +99 -0
  10. package/src-next/__tests__/zero-dep.test.ts +6 -46
  11. package/src-next/contract/__tests__/__snapshots__/project.schema.overall-spec.snap +39 -21
  12. package/src-next/contract/__tests__/__snapshots__/project.schema.phase-spec.snap +40 -28
  13. package/src-next/contract/__tests__/__snapshots__/project.schema.plan.snap +40 -23
  14. package/src-next/contract/__tests__/__snapshots__/project.schema.single-spec.snap +38 -21
  15. package/src-next/contract/__tests__/__snapshots__/project.shape.overall-spec.snap +21 -6
  16. package/src-next/contract/__tests__/__snapshots__/project.shape.phase-spec.snap +22 -12
  17. package/src-next/contract/__tests__/__snapshots__/project.shape.plan.snap +23 -8
  18. package/src-next/contract/__tests__/__snapshots__/project.shape.single-spec.snap +21 -6
  19. package/src-next/contract/__tests__/declare.test.ts +251 -12
  20. package/src-next/contract/__tests__/doc.test.ts +214 -45
  21. package/src-next/contract/__tests__/dockey.guard.test.ts +58 -0
  22. package/src-next/contract/__tests__/edge-conditions.guard.test.ts +81 -0
  23. package/src-next/contract/__tests__/frontmatter.test.ts +164 -0
  24. package/src-next/contract/__tests__/judge.test.ts +410 -172
  25. package/src-next/contract/__tests__/lint.test.ts +49 -39
  26. package/src-next/contract/__tests__/project.test.ts +60 -19
  27. package/src-next/contract/__tests__/structure-pin.test.ts +186 -0
  28. package/src-next/contract/declare.ts +179 -91
  29. package/src-next/contract/doc.ts +227 -164
  30. package/src-next/contract/frontmatter.ts +233 -0
  31. package/src-next/contract/home-extractors.ts +397 -0
  32. package/src-next/contract/invariants.ts +214 -69
  33. package/src-next/contract/judge.ts +28 -19
  34. package/src-next/contract/lint.ts +5 -41
  35. package/src-next/contract/project.ts +103 -43
  36. package/src-next/contract/skill-anatomy.ts +39 -11
  37. package/src-next/face/__tests__/board-view.test.ts +318 -115
  38. package/src-next/face/__tests__/capsule.test.ts +49 -25
  39. package/src-next/face/__tests__/channel-closure.guard.test.ts +28 -1
  40. package/src-next/face/__tests__/cli.test.ts +1091 -837
  41. package/src-next/face/__tests__/face.test.ts +5 -5
  42. package/src-next/face/__tests__/install-rows.guard.test.ts +58 -0
  43. package/src-next/face/__tests__/preview.test.ts +374 -0
  44. package/src-next/face/__tests__/projection.test.ts +5 -3
  45. package/src-next/face/__tests__/repo-root.guard.test.ts +120 -0
  46. package/src-next/face/__tests__/termination.test.ts +650 -0
  47. package/src-next/face/artifacts.ts +90 -37
  48. package/src-next/face/board-view.ts +128 -138
  49. package/src-next/face/capsule.ts +30 -16
  50. package/src-next/face/cli.ts +306 -97
  51. package/src-next/face/declare.ts +15 -18
  52. package/src-next/face/gate.ts +19 -18
  53. package/src-next/face/host.ts +6 -30
  54. package/src-next/face/lifecycle.ts +213 -188
  55. package/src-next/face/preview.ts +151 -0
  56. package/src-next/face/projection.ts +4 -1
  57. package/src-next/face/route-render.ts +39 -14
  58. package/src-next/face/termination.ts +573 -0
  59. package/src-next/face/words.ts +20 -2
  60. package/src-next/infra/__tests__/infra.test.ts +49 -3
  61. package/src-next/infra/__tests__/root.test.ts +56 -0
  62. package/src-next/infra/doc-roots.ts +29 -0
  63. package/src-next/infra/root.ts +73 -0
  64. package/src-next/infra/runtime.ts +12 -65
  65. package/src-next/infra/workspace.ts +95 -5
  66. package/src-next/render/__tests__/render.test.ts +92 -41
  67. package/src-next/render/__tests__/skeleton.test.ts +282 -64
  68. package/src-next/render/issue-body.ts +5 -2
  69. package/src-next/render/skeleton.ts +155 -90
  70. package/src-next/render/templates.ts +51 -56
  71. package/src-next/session/__tests__/graph.test.ts +11 -4
  72. package/src-next/session/__tests__/ledger.test.ts +3 -2
  73. package/src-next/session/__tests__/next.test.ts +100 -8
  74. package/src-next/session/__tests__/preflight.test.ts +79 -25
  75. package/src-next/session/__tests__/round-naming.test.ts +142 -0
  76. package/src-next/session/__tests__/run.test.ts +140 -128
  77. package/src-next/session/__tests__/wave.test.ts +11 -4
  78. package/src-next/session/ledger.ts +96 -24
  79. package/src-next/session/next.ts +116 -15
  80. package/src-next/session/preflight.ts +41 -10
  81. package/src-next/session/round-naming.ts +84 -0
  82. package/src-next/session/run.ts +24 -20
  83. package/templates/report/issue-body.json +0 -46
  84. package/src-next/face/__tests__/sync-runner.test.ts +0 -70
@@ -8,55 +8,56 @@
8
8
  // (spec §4.1: pure content slots take `:::fill`, link-shaped anchors a placeholder
9
9
  // link, structure is true value — the doc-contract pin judges the rendered bytes).
10
10
  //
11
- // The per-anchor forms (header lines · link placeholders · generator truths ·
12
- // table scaffolds) are declared constant data below; the document composition
13
- // walks them in document order. render() is a pure byte renderer — it never
14
- // appends a trailing newline (the CLI appends the single `\n`, so a redirected
15
- // fixture ends with exactly one newline). The composition is the judgment site
16
- // of the projection: after assembly render() asserts slot consumption — every
17
- // registered required slot emits a probe and every probe names a registered
18
- // slot, so a registry/composition drift is a loud throw in the renderer, never a
19
- // silent byte gap (the doc-contract pin judges the rendered bytes; this asserts
20
- // the same coverage in-process, before any bytes are produced).
11
+ // The front-matter head is the ONE structured-metadata channel (spec §2.2's
12
+ // standard parser): the frontmatter-home slots render as a `---`-fenced YAML
13
+ // record emitted by `yaml.stringify` in one call — an independent line set, never
14
+ // hand-spun header lines and never part of the slot/probe channel. §4.2's
15
+ // placeholder three-way split: the link-typed keys (`spec` · `parent-program`)
16
+ // emit a `<…>` scalar on the judge's placeholder-exemption chain; the content
17
+ // keys (`title` · `author` · `depends-on` · `base`) emit `:::fill <key>`; the
18
+ // truth keys (`doc-type` · `version` · `date` · `status`) emit true values. The
19
+ // optional `parent-version` key is deliberately NOT emitted — its shape is typed
20
+ // (`v<n>.<m>`, so a fill or a link scalar would violate the domain) and absence
21
+ // is legal. The markdown body stays the registry-driven scaffold. render() is a
22
+ // pure byte renderer — it never appends a trailing newline (the CLI appends the
23
+ // single `\n`, so a redirected fixture ends with exactly one newline). The
24
+ // composition is the judgment site of the projection: after assembly render()
25
+ // asserts slot consumption over the BODY slots — every registered body slot emits
26
+ // a probe and every probe names a registered body slot, so a registry/composition
27
+ // drift is a loud throw in the renderer, never a silent byte gap (the front-matter
28
+ // key set is registry-faithful by construction — the assertion domain is the body
29
+ // the composition hand-assembles).
21
30
  //
22
31
  // Module-level exports are types / the class — zero behavior-carrying bare
23
32
  // functions (the plan's zero-bare-function discipline).
24
33
 
34
+ import { Pair, Scalar, stringify as stringifyYaml, YAMLMap } from "yaml";
25
35
  import type { DocSkeleton, SkeletonSlot } from "../contract/project.ts";
26
36
 
27
- /** The per-anchor header line forms — every registered header anchor of the four
28
- * doc types except the link-typed anchors (their placeholder-link lines assemble
29
- * from LINK_SLOTS): the title fill, the content marker fills, the generator-truth
30
- * status line and the scaffold version row. The `{date}` slot carries the
31
- * injected run date (the version-row date truth). */
32
- const HEADER_FORMS: Record<string, string> = {
33
- "# Title": "# :::fill title",
34
- "**Version**": "- **Version**: v0.1 · {date}",
35
- "**Author**": "- **Author**: :::fill author",
36
- "**Constraints**": "- **Constraints**: :::fill constraints",
37
- "**Depends on**": "- **Depends on**: :::fill depends-on",
37
+ /** The placeholder scalars of the front-matter link keys (spec §4.2 + D3) — the
38
+ * link-typed head keys (`spec` · `parent-program`) render a `<…>`-shaped value
39
+ * that rides the judge's placeholder-exemption chain (a bare `^<[^>]+>$` target
40
+ * the file-existence / sibling-scan / cross-doc-chain strategies all skip),
41
+ * never a `:::fill` (a fill in a link slot is a guaranteed finding). The
42
+ * placeholder IS the fill contract (show-don't-tell — zero prose rules): its
43
+ * inner shape is a BARE relative-path exemplar (`docs/kairos/specs/…-overall.md`),
44
+ * the exact form the consumer must fill — the <>-shell keeps the exemption, the
45
+ * path inside both bookends the value and doubles as the shape sample (#342: a
46
+ * consumer copying the exemplar fills a bare path, never a markdown link). */
47
+ const FRONT_MATTER_LINKS: Record<string, string> = {
48
+ spec: "<docs/kairos/specs/…-design.md>",
49
+ "parent-program": "<docs/kairos/specs/…-overall.md>",
38
50
  };
39
51
 
40
- /** The placeholder-link literals of the link-typed anchor slots (spec §4.1) — the
41
- * `<…>` label/target pairs of the parent-program / spec links. The `<…>`-shaped
42
- * target rides the judge's placeholder-exemption chain (file-existence /
43
- * sibling-scan); the plan's Class-A `**Spec:**` takes label == target so the
44
- * `label == basename` chain check holds. */
45
- const LINK_SLOTS: Record<string, { label: string; target: string }> = {
46
- "**Parent program**": { label: "<parent overall>", target: "<parent path>" },
47
- "**Spec:**": { label: "<spec path>", target: "<spec path>" },
48
- };
49
-
50
- /** The generator truths of the pattern-typed slots (spec §3.2/§4.1) — hand-pinned
51
- * legal literals consistent with each declared value domain (`**Status**` →
52
- * Draft, the first legal literal of its enum; the `none` issue-ref default; the
53
- * `[Pending]` design cell — the only pending form its valuePattern admits, never
54
- * bare `Pending` — and the bare `Pending` plan cell, a legal alternative of its
55
- * domain) and the conforming graph rows (the `P1 -> P2` hard edge + the legend
56
- * line). These are derived true values, guarded by the doc-contract pins that
57
- * judge the rendered bytes — never fill positions. */
52
+ /** The generator truths of the pattern-typed body slots (spec §3.2/§4.1) —
53
+ * hand-pinned legal literals consistent with each declared value domain (the
54
+ * `none` issue-ref default; the `[Pending]` design cell — the only pending form
55
+ * its valuePattern admits, never bare `Pending` — and the bare `Pending` plan
56
+ * cell, a legal alternative of its domain) and the conforming graph rows (the
57
+ * `P1 -> P2` hard edge + the legend line). The head's `status` truth lives in
58
+ * the front-matter emission (`status: Draft` — the first legal literal of every
59
+ * status enum — via `#frontmatterTruth`, never a body fill). */
58
60
  const TRUTH_LINES: Record<string, string> = {
59
- "**Status**": "Draft",
60
61
  "Issue ref cell": "none",
61
62
  "Implementation plan cell": "Pending",
62
63
  "Design spec cell": "[Pending]",
@@ -76,27 +77,33 @@ const HISTORY_HEADER = "| Version | date | summary | author |";
76
77
  * and the run date (the CLI injects the run day; tests inject a fixed date), the
77
78
  * instance is stateless after construction, so sharing one instance composes
78
79
  * safely. The composition per doc type mirrors the doc's section sequence; every
79
- * required element of the type lands in its structural position (the doc-contract
80
- * pin judges the rendered bytes — a missing required anchor is a finding).
80
+ * required element of the type lands in its structural position — the front-
81
+ * matter keys in the head record (the registry's frontmatter-home slot order),
82
+ * the body elements in the section scaffold (the doc-contract pin judges the
83
+ * rendered bytes — a missing required anchor is a finding).
81
84
  */
82
85
  export class SkeletonAssembler {
83
86
  /** The doc type of the projected skeleton. */
84
87
  readonly #docType: DocSkeleton["docType"];
85
- /** The injected run date — the version-row date truth (`YYYY-MM-DD`). */
88
+ /** The injected run date — the front-matter `date:` truth (`YYYY-MM-DD`). */
86
89
  readonly #date: string;
87
- /** The projection's slots in shape-group order. */
90
+ /** The projection's slots in shape-group order (the body slot channel). */
88
91
  readonly #slots: readonly SkeletonSlot[];
92
+ /** The front-matter emission list — the head's required + optional keys. */
93
+ readonly #frontmatterSlots: readonly SkeletonSlot[];
89
94
 
90
95
  constructor(projection: DocSkeleton, date: string) {
91
96
  this.#docType = projection.docType;
92
97
  this.#date = date;
93
98
  this.#slots = projection.slots;
99
+ this.#frontmatterSlots = projection.frontmatter;
94
100
  }
95
101
 
96
102
  /** Render the doc skeleton's markdown bytes — no trailing newline (the CLI owns
97
103
  * the appended `\n`; the EOF-newline rule lands on the redirected fixture).
98
- * Every composed anchor registers a probe; the composition completes only when
99
- * the probes and the projection's required slots coincide (a drift is a loud
104
+ * The front-matter head is emitted as the registry's key set (never probed);
105
+ * every body anchor registers a probe; the composition completes only when
106
+ * the probes and the projection's body slots coincide (a drift is a loud
100
107
  * throw below, never silent bytes). */
101
108
  render(): string {
102
109
  const probe = new Set<string>();
@@ -123,14 +130,20 @@ export class SkeletonAssembler {
123
130
  /** The slot-consumption invariant — the composition-side tripwire of the
124
131
  * registry-derived structure (the finding hardened in: the projection is the
125
132
  * single structure source, the hand-written compositions must not drift from
126
- * it): every required slot of the projection is emitted by the composition,
133
+ * it). The assertion domain is the BODY slots — the front-matter head is
134
+ * emitted from the projection's independent emission list (the §2.2
135
+ * structured channel, never probed), so the tripwire covers the
136
+ * hand-assembled body:
137
+ * every required body slot of the projection is emitted by the composition,
127
138
  * and no composition probe names an anchor the registry does not require — a
128
139
  * registered element with no composition position, or a composed anchor no
129
140
  * longer required, is registry drift, loud never silent. */
130
141
  #assertConsumed(probe: ReadonlySet<string>): void {
131
- const registered = new Set(this.#slots.map((slot) => slot.anchor));
142
+ const registered = new Set(
143
+ this.#slots.filter((slot) => slot.home !== "frontmatter").map((slot) => slot.anchor),
144
+ );
132
145
  const unemitted = this.#slots
133
- .filter((slot) => !probe.has(slot.anchor))
146
+ .filter((slot) => slot.home !== "frontmatter" && !probe.has(slot.anchor))
134
147
  .map((slot) => slot.anchor);
135
148
  if (unemitted.length > 0) {
136
149
  throw new Error(
@@ -148,12 +161,13 @@ export class SkeletonAssembler {
148
161
  // the per-doc-type compositions — the doc section sequence + its scaffolds
149
162
  // -------------------------------------------------------------------------
150
163
 
151
- /** The overall-spec skeleton — the header tuple, the section sequence (the four table
152
- * sections, the charter facets and the dependency graph) and the change-history
153
- * table: every required overall-spec element lands in its structural position. */
164
+ /** The overall-spec skeleton — the front-matter head, the section sequence
165
+ * (the four table sections, the charter facets, the dependency graph, the
166
+ * Form-A constraints surface and the change-history table): every required
167
+ * overall-spec element lands in its structural position. */
154
168
  #renderOverallSpec(probe: Set<string>): string[] {
155
169
  const lines: string[] = [];
156
- this.#pushHeader(lines, probe);
170
+ this.#pushFrontmatter(lines);
157
171
  lines.push(...this.#section("## Document scope", [":::fill document-scope"], probe));
158
172
  lines.push(...this.#section("## File paths", this.#filePathsTable(probe), probe));
159
173
  lines.push(...this.#section("## Program charter", this.#programCharter(probe), probe));
@@ -161,18 +175,34 @@ export class SkeletonAssembler {
161
175
  lines.push(...this.#section("## Phase inventory", this.#phaseTable(probe), probe));
162
176
  lines.push(...this.#section("## Dependency graph", this.#dependencyGraph(probe), probe));
163
177
  lines.push(...this.#section("## Boundary rules", ["- :::fill boundary-rule"], probe));
178
+ // The overall Constraints section — the Form-A delta-only surface shared
179
+ // with the plan/phase-spec: the heading + the `Constraint delta bullet`,
180
+ // composed at the declared registry position (between Boundary rules and
181
+ // Maintenance). The section heading line and its delta bullet land in the
182
+ // SAME composition step — the three same-order parts (the declared section
183
+ // anchor, the composed heading, the composed bullet) must move together, or
184
+ // the `#assertConsumed` tripwire throws (a heading without its bullet omits
185
+ // a registered required slot).
186
+ lines.push(
187
+ ...this.#section(
188
+ "## Constraints",
189
+ ["- :::fill constraint"],
190
+ probe,
191
+ "Constraint delta bullet",
192
+ ),
193
+ );
164
194
  lines.push(...this.#section("## Maintenance", ["- :::fill maintenance-note"], probe));
165
195
  lines.push(...this.#section("## Change history", this.#historyTable(probe), probe));
166
196
  return lines;
167
197
  }
168
198
 
169
- /** The plan skeleton — the header tuple, the constraints section, the first task
170
- * block (`### Task 1:` with the seven required task fields) and the
199
+ /** The plan skeleton — the front-matter head, the constraints section, the first
200
+ * task block (`### Task 1:` with the seven required task fields) and the
171
201
  * change-history table (§3.2 — one task block, more blocks appended when
172
202
  * filling). */
173
203
  #renderPlan(probe: Set<string>): string[] {
174
204
  const lines: string[] = [];
175
- this.#pushHeader(lines, probe);
205
+ this.#pushFrontmatter(lines);
176
206
  lines.push(
177
207
  ...this.#section(
178
208
  "## Constraints",
@@ -186,13 +216,13 @@ export class SkeletonAssembler {
186
216
  return lines;
187
217
  }
188
218
 
189
- /** The phase-spec skeleton — the header five-tuple, the Design double layer
219
+ /** The phase-spec skeleton — the front-matter head, the Design double layer
190
220
  * (one `### 1.` group + one `#### 1.1` item + the acceptance surface), the
191
221
  * constraints section and the change-history table (§3.2 — more groups/items
192
222
  * appended in numeric order when filling). */
193
223
  #renderPhaseSpec(probe: Set<string>): string[] {
194
224
  const lines: string[] = [];
195
- this.#pushHeader(lines, probe);
225
+ this.#pushFrontmatter(lines);
196
226
  lines.push(
197
227
  ...this.#section(
198
228
  "## Design",
@@ -229,14 +259,14 @@ export class SkeletonAssembler {
229
259
  return lines;
230
260
  }
231
261
 
232
- /** The single-spec skeleton — the header five-tuple, the four prose sections
262
+ /** The single-spec skeleton — the front-matter head, the four prose sections
233
263
  * (`:::fill` slots) and the change-history table: the lightweight scaffold of
234
264
  * the free-form spec (P6 T2 · spec §2.1). No `### N.` double-layer outline and
235
- * no `**Parent program**` — the single-spec's deliberate deviations from the
265
+ * no parent-program key — the single-spec's deliberate deviations from the
236
266
  * phase-spec form. */
237
267
  #renderSingleSpec(probe: Set<string>): string[] {
238
268
  const lines: string[] = [];
239
- this.#pushHeader(lines, probe);
269
+ this.#pushFrontmatter(lines);
240
270
  lines.push(
241
271
  ...this.#section("## Background & root cause", [":::fill background-root-cause"], probe),
242
272
  );
@@ -248,46 +278,81 @@ export class SkeletonAssembler {
248
278
  }
249
279
 
250
280
  // -------------------------------------------------------------------------
251
- // the shared scaffolds — header, tables, sections, the join
281
+ // the shared scaffolds — the front-matter head, tables, sections, the join
252
282
  // -------------------------------------------------------------------------
253
283
 
254
- /** The header block — the header-home slots in projection order (the registry
255
- * order — the title, then the version/status truths, the content markers, the
256
- * link placeholders), each probed, followed by the blank separator. */
257
- #pushHeader(lines: string[], probe: Set<string>): void {
258
- for (const slot of this.#slots) {
259
- if (slot.home !== "header") continue;
260
- lines.push(this.#headerLine(slot));
261
- probe.add(slot.anchor);
284
+ /** The front-matter head block — the projection's front-matter emission list
285
+ * (the head's required keys plus the type's optional keys) in registry order,
286
+ * emitted by `yaml.stringify` in one call (§2.2's standard structured-metadata
287
+ * channel): §4.2's placeholder three-way split — the link keys a `<…>` scalar,
288
+ * the content keys a `:::fill <key>`, the truth keys their true values. An
289
+ * independent line set — never part of the slot/probe channel (the
290
+ * `#assertConsumed` domain is the body the composition hand-assembles). The
291
+ * head's `doc-type:` key is the canonical machine read (spec §3.1 ⑩ · D34 —
292
+ * the read faces consume the front-matter record, zero header-line marker
293
+ * grammar). */
294
+ #pushFrontmatter(lines: string[]): void {
295
+ // The front-matter record is emitted by `yaml.stringify` in ONE call over the
296
+ // projection's emission list (spec §2.2's structured channel — the
297
+ // parsed-nodes form keeps the keys ordered and the emission single: D3 quotes
298
+ // the content-fill values so a consumer filling `[human] · …` / `Title: …`
299
+ // into the slot never breaks the scalar (the #341 fill class dies at the
300
+ // skeleton's default form, not at report time). The truth values stay plain,
301
+ // the link placeholders plain (the <>-bookended exemplar — exemption-shaped).
302
+ const fields = new YAMLMap();
303
+ // The emission list is the projection's independent front-matter set — the
304
+ // required head keys plus the type's optional keys (`base` / `depends-on`);
305
+ // `parent-version` never appears (the projection excludes it — §4.2's
306
+ // optional shape-typed key, whose `v<n>.<m>` domain admits no placeholder).
307
+ for (const slot of this.#frontmatterSlots) {
308
+ const value = new Scalar(this.#frontmatterValue(slot));
309
+ // D3: the content fills emit single-quoted — the consumer may fill
310
+ // `[human] · …` / `Title: …` into the slot; the quote keeps the scalar
311
+ // intact regardless of the leading character (the #341 class dies at the
312
+ // skeleton's default form). The truths and the link placeholders stay
313
+ // plain.
314
+ value.type = slot.slot === "content" ? Scalar.QUOTE_SINGLE : Scalar.PLAIN;
315
+ fields.items.push(new Pair(new Scalar(slot.anchor), value));
262
316
  }
263
- lines.push("");
317
+ const block = stringifyYaml(fields).trimEnd().split("\n");
318
+ lines.push("---", ...block, "---", "");
264
319
  }
265
320
 
266
- /** One header line — the anchor's declared form with the injected date (the
267
- * link-typed anchors assemble their placeholder-link line from the LINK_SLOTS
268
- * label/target pair; the header anchors are a closed set over the four
269
- * registries — an unknown header anchor is a registry drift, loud never
270
- * silent). */
271
- #headerLine(slot: SkeletonSlot): string {
321
+ /** One front-matter value — the §4.2 placeholder three-way split over the slot
322
+ * kind: the link keys a `<…>` placeholder scalar, the content keys a content
323
+ * fill (`:::fill <key>`), the truth keys (the fixed version/date scaffold and
324
+ * the doc-type / status patterns) their true values. */
325
+ #frontmatterValue(slot: SkeletonSlot): string {
272
326
  if (slot.slot === "link") {
273
- const pair = LINK_SLOTS[slot.anchor];
274
- if (pair === undefined) {
275
- throw new Error(`no skeleton link slot for the ${slot.anchor} anchor`);
327
+ const placeholder = FRONT_MATTER_LINKS[slot.anchor];
328
+ if (placeholder === undefined) {
329
+ throw new Error(`no skeleton front-matter link placeholder for the ${slot.anchor} anchor`);
276
330
  }
277
- const marker = slot.anchor === "**Spec:**" ? "**Spec:**" : `- ${slot.anchor}:`;
278
- return `${marker} [${pair.label}](${pair.target})`;
331
+ return placeholder;
279
332
  }
280
- if (slot.anchor === "**Status**") {
281
- return `- **Status**: ${this.#truth("**Status**")}`;
282
- }
283
- const form = HEADER_FORMS[slot.anchor];
284
- if (form === undefined) {
285
- throw new Error(`no skeleton header form for the ${slot.anchor} anchor`);
333
+ if (slot.slot === "content") return `:::fill ${slot.anchor}`;
334
+ return this.#frontmatterTruth(slot);
335
+ }
336
+
337
+ /** The true front-matter value of a fixed/patterned front-matter key — the doc
338
+ * type from the projection, the injected run date, the fixed first version and
339
+ * the first legal status literal (`Draft`, the shared head of every status
340
+ * enum domain). An unknown truth key is a registry drift, loud never silent. */
341
+ #frontmatterTruth(slot: SkeletonSlot): string {
342
+ switch (slot.anchor) {
343
+ case "doc-type":
344
+ return this.#docType;
345
+ case "version":
346
+ return "v0.1";
347
+ case "date":
348
+ return this.#date;
349
+ case "status":
350
+ return "Draft";
286
351
  }
287
- return form.replace("{date}", this.#date);
352
+ throw new Error(`no skeleton front-matter truth for the ${slot.anchor} anchor`);
288
353
  }
289
354
 
290
- /** The generator truth of one pattern-typed slot — an unknown anchor is a
355
+ /** The generator truth of one pattern-typed body slot — an unknown anchor is a
291
356
  * registry drift, loud never silent. */
292
357
  #truth(anchor: string): string {
293
358
  const truth = TRUTH_LINES[anchor];