@oscaner-skills/cdd-engine 4.10.0 → 4.12.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.
@@ -3,15 +3,21 @@
3
3
  // converge into ONE single-entry gate a work command consults before ANY child
4
4
  // dispatch — the clean-tree hard gate (tree-clean → BLOCKED with the commit/discard
5
5
  // guidance, the skill-side claim `engine entry gate: dirty → BLOCKED` finally made
6
- // real), then the in-flight gate, the plan/ledger structure gate (`plan-ledger`, P21
7
- // §3.1/§6.4), the graph validate and the doc-side gate (Contract.validate over the
8
- // target doc). The dispatch's own phase — the wave face's gate and the doc/branch
9
- // line's — is NOT judged here: it belongs to the ONE dispatch authority
10
- // (`session/dispatch-authority.ts`, P27 §2), the seam's single consumer.
6
+ // real), then the in-flight gate, the plan read's own structure refusal (the
7
+ // un-gated plan-carrier leg, P35 §2.3), the graph validate, the plan/ledger
8
+ // structure gate (`plan-ledger`, P21 §3.1/§6.4) and the doc-side gate
9
+ // (Contract.validate over the target doc). The dispatch's own phase — the wave
10
+ // face's gate and the doc/branch line's — is NOT judged here: it belongs to the ONE
11
+ // dispatch authority (`session/dispatch-authority.ts`, P27 §2), the seam's single
12
+ // consumer.
11
13
  //
12
14
  // Gate order (the design's pinned sequence, judgeable on every verdict):
13
- // tree-clean → in-flight → graph → plan-ledger →
15
+ // tree-clean → in-flight → plan-carrier → graph → plan-ledger →
14
16
  // (spec/plan faces) Contract.validate → dispatch
17
+ // The plan-carrier leg is the readable plan's OWN refusal (P35 §2.3): an UN-GATED
18
+ // judgment over `ctx.plan` — not a row of the doc-shape block — so the wave face
19
+ // (no doc target, `ctx.doc === null`) is judged too. It speaks the existing
20
+ // `doc-contract` gate id and reason token, so no token joins the table.
15
21
  // The evidence/read-back gates stay at the dispatch child face (the seam never
16
22
  // touches the round's produced artifacts — non-pre-flight by design).
17
23
  //
@@ -25,7 +31,6 @@
25
31
  //
26
32
  // Module-level exports are types / the class — zero behavior-carrying bare
27
33
  // functions (the plan's zero-bare-function discipline).
28
- import { PlanDocType } from "../contract/doc.js";
29
34
  import { FrontMatterExtractor } from "../contract/frontmatter.js";
30
35
  import { LedgerTaskSetRule, NodeFs } from "../contract/invariants.js";
31
36
  import { Contract } from "../contract/judge.js";
@@ -55,9 +60,9 @@ export class PreFlight {
55
60
  this.#words = opts.words;
56
61
  this.#fs = opts.fs ?? new NodeFs();
57
62
  }
58
- /** vet(ctx) — the single seam call: tree-clean → in-flight → graph → plan-ledger
59
- * → doc-contract. The first refused gate owns the verdict; the gates that ran
60
- * precede it (the judgeable order). */
63
+ /** vet(ctx) — the single seam call: tree-clean → in-flight → plan-carrier → graph
64
+ * → plan-ledger → doc-contract. The first refused gate owns the verdict; the gates
65
+ * that ran precede it (the judgeable order). */
61
66
  async vet(ctx) {
62
67
  const gates = [];
63
68
  const checked = [];
@@ -89,24 +94,47 @@ export class PreFlight {
89
94
  holding: inFlight,
90
95
  }, gates, checked, this.#docOutcomeOf(ctx), { kind: "no-ledger-facts" });
91
96
  }
92
- // 3. graph — the wave/plan faces' structural gate.
97
+ // 3. plan-carrier — the plan READ's own structure judgment (P35 §2.3): every face
98
+ // that carries a plan read (wave / plan / branch) asks the value whether the
99
+ // document it read may be dispatched. The source is `ctx.plan`, never `ctx.doc`
100
+ // — the wave face reaches this point with no doc target at all. The `io` cause
101
+ // never asks this leg: the scene stops at the usage seam before any workspace
102
+ // key exists, so only `syntax` and the `spec-absent` orphan arrive here.
103
+ if (ctx.type === "wave" || ctx.type === "plan" || ctx.type === "branch") {
104
+ const refusal = ctx.plan.refusal(this.#words);
105
+ if (refusal !== null) {
106
+ // The plan face's own gate set already holds `doc-contract`, so its refusal
107
+ // accounts for the gate it PLANNED to run; the wave / branch faces never
108
+ // planned it and must not claim they did.
109
+ if (ctx.type === "plan") {
110
+ gates.push("doc-contract");
111
+ checked.push("doc-contract");
112
+ }
113
+ return this.#refusal({ ok: false, gate: refusal.gate, reason: refusal.reason, message: refusal.message }, gates, checked, this.#docOutcomeOf(ctx), { kind: "no-ledger-facts" });
114
+ }
115
+ }
116
+ // 4. graph — the wave/plan faces' structural gate, on a READY plan only: a
117
+ // non-ready read never enters the gate plan, so the row is neither pushed nor
118
+ // reported (`checked`'s byte set stays the healthy one).
93
119
  let graph = null;
94
- if ((ctx.type === "wave" || ctx.type === "plan") && ctx.planText !== null) {
120
+ if ((ctx.type === "wave" || ctx.type === "plan") && ctx.plan.kind === "ready") {
95
121
  gates.push("graph");
96
122
  checked.push("graph");
97
- graph = new TaskGraph(new PlanDocType("plan").parse(ctx.planText.split("\n")));
98
- const issues = graph.validate();
99
- if (issues.length > 0) {
100
- return this.#refusal({
101
- ok: false,
102
- gate: "graph",
103
- reason: "graph",
104
- message: this.#words.preflightWords().graph.replace("{count}", String(issues.length)),
105
- details: issues.map((issue) => `${issue.kind}@T${issue.task}: ${issue.message}`),
106
- }, gates, checked, this.#docOutcomeOf(ctx), { kind: "no-ledger-facts" });
123
+ graph = ctx.plan.graph();
124
+ if (graph !== null) {
125
+ const issues = graph.validate();
126
+ if (issues.length > 0) {
127
+ return this.#refusal({
128
+ ok: false,
129
+ gate: "graph",
130
+ reason: "graph",
131
+ message: this.#words.preflightWords().graph.replace("{count}", String(issues.length)),
132
+ details: issues.map((issue) => `${issue.kind}@T${issue.task}: ${issue.message}`),
133
+ }, gates, checked, this.#docOutcomeOf(ctx), { kind: "no-ledger-facts" });
134
+ }
107
135
  }
108
136
  }
109
- // 4. plan-ledger — the ledger-scope rules (P21 §3.1/§6.4). Plan / wave / branch
137
+ // 5. plan-ledger — the ledger-scope rules (P21 §3.1/§6.4). Plan / wave / branch
110
138
  // dispatches run it; the doc-scope rules never do (two scopes, two entries).
111
139
  // A missing fact bundle is NOT a refusal: the rows render `skipped`.
112
140
  let ledgerOutcome = { kind: "no-ledger-facts" };
@@ -133,7 +161,7 @@ export class PreFlight {
133
161
  }
134
162
  }
135
163
  }
136
- // 5. doc-contract — the doc shapes' structural gate (the doc-scope rules).
164
+ // 6. doc-contract — the doc shapes' structural gate (the doc-scope rules).
137
165
  // The four document shapes (`phase-spec` · `overall` · `plan` · `single-spec`)
138
166
  // are judged by the SAME gate: the document's declared `doc-type:` picks the
139
167
  // contract, never the command's `--type` spelling.
@@ -308,26 +336,29 @@ export class PreFlight {
308
336
  }
309
337
  return rows;
310
338
  }
311
- /** The ledger fact bundle of one dispatch — built from the ledger, the plan text
312
- * and the plan's topological layers. Null when either fact source is absent
313
- * (the gate then renders `skipped (no ledger facts)`). */
339
+ /** The ledger fact bundle of one dispatch — built from the ledger, the plan read
340
+ * and the plan's topological layers. Null when either fact source is absent (the
341
+ * gate then renders `skipped (no ledger facts)`). */
314
342
  #ledgerFactsOf(ctx, graph) {
315
343
  const ledger = ctx.ledger;
316
- if (ledger === null || ctx.planText === null)
344
+ const doc = ctx.plan.doc();
345
+ if (ledger === null || doc === null)
317
346
  return null;
318
- const parsed = new PlanDocType("plan").parse(ctx.planText.split("\n"));
319
- const planTasks = parsed.taskBlocks.map((block) => block.id);
320
- const layers = (graph ?? new TaskGraph(parsed)).batches();
347
+ const planTasks = doc.taskBlocks.map((block) => block.id);
348
+ const layers = (graph ?? ctx.plan.graph() ?? new TaskGraph(doc)).batches();
321
349
  const data = ledger.readProgress();
322
350
  const recorded = this.#recordedTasksOf(data);
323
351
  const closed = ledger.closedWaves();
324
- const closedWaves = (data?.waves ?? [])
352
+ const waves = (data?.waves ?? [])
325
353
  .map((row) => this.#taskIdsOf(row.wave))
326
- .filter((ids) => ids.length > 0 && ids.every((id) => closed.has(id)));
354
+ .filter((ids) => ids.length > 0);
355
+ const closedWaves = waves.filter((ids) => ids.every((id) => closed.has(id)));
356
+ const openWaves = waves.filter((ids) => ids.some((id) => !closed.has(id)));
327
357
  return {
328
358
  planTasks,
329
359
  recordedTasks: recorded,
330
360
  closedWaves,
361
+ openWaves,
331
362
  // The wave rows' closure-time plan-task snapshots (P21 §5.1) — read from the
332
363
  // SAME ledger face the wave gate's append judgment reads (zero second source).
333
364
  snapshots: this.#snapshotsOf(data),
@@ -381,7 +412,7 @@ export class PreFlight {
381
412
  return {
382
413
  docKey: "plan",
383
414
  path: ctx.doc?.path ?? "",
384
- content: ctx.planText ?? "",
415
+ content: ctx.plan.text() ?? "",
385
416
  root: ctx.repoRoot,
386
417
  fs: this.#fs,
387
418
  };
@@ -1,54 +1,120 @@
1
1
  // packages/cdd-engine/src-next/session/round-naming.ts
2
- // P11 T4 — the round-naming single source: the frame → artifact-name derivations
3
- // (report · evidence · brief) the lifecycle's read-back and the dry-run preview
4
- // share, plus the frame → family-op mapping those names key on. The handoff carrier's
5
- // DRAFT name is NOT derived here — it stays with the Ledger's HANDOFF_FAMILIES table
6
- // (the naming table is the single truth, never a second list); the FINAL name (P31
7
- // §2.3) is that name with its suffix swapped, so the rule runs on the filled name.
2
+ // P34 T1 — the naming single source: ONE round identity renders every artifact name
3
+ // (draft · final · report · log · crash · evidence) through `renderName`, so a kind's
4
+ // spelling and its siblings' can never drift, and the reverse attribution
5
+ // (`Ledger#handoffOwner`) parses back exactly the identity this face renders.
8
6
  //
9
- // Module-level exports are the class — zero behavior-carrying bare functions.
7
+ // The identity is a triple: the LINE (`tasks-{tasks}` · `branch` · the doc word), the
8
+ // OP (`implement` · `review` · `fix` — branch-review rides the review family), the
9
+ // CYCLE and the ATTEMPT. Every kind shares one stem, so the carrier's draft, its
10
+ // final beside it, the round's report, log, crash record and test-evidence file all
11
+ // name the same round. The attempt rides the stem as `-a{n}` and is omitted on the
12
+ // first attempt; a cycle-less identity (an inferred params with no round) omits the
13
+ // cycle segment too, never a `-undefined` token.
14
+ //
15
+ // Module-level exports are types / the class — zero behavior-carrying bare functions.
16
+ // One module-level value: the compiled carrier predicate below (`CARRIER`).
17
+ var _a;
10
18
  import { TargetFaceTable, targetFaces } from "./faces.js";
19
+ /** The two carrier-name shapes this engine MINTS — the draft and its final twin.
20
+ * Both accept the `-a{n}` attempt segment and the final's `.c{cycle}` suffix; every
21
+ * other artifact (report · log · crash · evidence) is deliberately outside the
22
+ * predicate, so the seal sweep can never touch it. The legacy cycle-less implement
23
+ * spelling (`tasks-{tasks}-implement.json`) stays accepted for the drafts a
24
+ * pre-P34 engine left on disk.
25
+ *
26
+ * Module scope, not a `static readonly #CARRIER` field: tsc down-levels a static
27
+ * field initializer that reads the class's own private static member into a temp
28
+ * (`static #CARRIER = _a.#carrierPattern()`) assigned only AFTER the class body, so
29
+ * the module threw `Receiver must be class RoundNaming` at import. Reading a plain
30
+ * const keeps the pattern out of that transform's reach.
31
+ *
32
+ * A wave line takes the wave-only `tasks-` spine, every other line word takes the
33
+ * round-bearing ops; the op set and the line words come from the ONE target-face
34
+ * table, so neither is re-spelled here. The `.c{cycle}` final suffix hangs off the
35
+ * CYCLE-BEARING alternatives alone — a cycle-less identity has no cycle to suffix, so
36
+ * `tasks-1-implement.c1.json` is a shape the renderer can never mint. */
37
+ const carrierPattern = () => {
38
+ const lines = Object.keys(targetFaces).filter((word) => word !== "wave");
39
+ const attempt = "(?:-a\\d+)?";
40
+ const final = "(?:\\.c\\d+)?";
41
+ const cycleBearing = [
42
+ "tasks-.+?-implement-\\d+",
43
+ "tasks-.+?-(?:review|fix)-\\d+",
44
+ `(?:${lines.join("|")})-(?:review|fix)-\\d+`,
45
+ ].join("|");
46
+ // The legacy cycle-less implement draft: a draft on disk, never a final and never
47
+ // an attempt — this engine mints neither on a cycle-less identity.
48
+ const legacy = "tasks-.+?-implement";
49
+ return new RegExp(`^(?:(?:${cycleBearing})${attempt}${final}|${legacy})\\.json$`);
50
+ };
51
+ const CARRIER = carrierPattern();
11
52
  /**
12
53
  * RoundNaming — the one home of a round's prescribed artifact names. A frame's
13
- * report / evidence / brief names derive here, so every consumer (the lifecycle's
14
- * write-back and read-back, the dry-run preview, the brief render) names the same
15
- * artifacts by the same rule — one fact, one place. The class holds only the
16
- * workspace the names resolve against.
54
+ * report / log / crash / evidence / carrier names derive here, so every consumer
55
+ * (the lifecycle's write-back and read-back, the ledger's carrier persist, the dry-run
56
+ * preview, the seal sweep) names the same artifacts by the same rule — one fact, one
57
+ * place. The class holds only the workspace the names resolve against.
17
58
  */
18
59
  export class RoundNaming {
19
60
  #workspace;
20
61
  constructor(workspace) {
21
62
  this.#workspace = workspace;
22
63
  }
23
- /** The two carrier-name shapes this engine MINTS — the draft family spelling
24
- * (`{line}-{op}[-{round}].json`) and its final twin (`…[-{round}].c{N}.json`). The
25
- * line words come from the ONE target-face table (the wave line's spelling is the
26
- * `tasks-` spine, never the `wave` word itself) and the ops from the ONE op
27
- * vocabulary, so neither set is re-spelled here. */
28
- static #CARRIER = RoundNaming.#carrierPattern();
29
- /** The carrier-name predicate's compiled pattern — `tasks-{tasks}` is the one
30
- * wave-only line (implement exists there alone), the other line words take the
31
- * round-bearing ops. */
32
- static #carrierPattern() {
33
- const lines = Object.keys(targetFaces).filter((word) => word !== "wave");
34
- return new RegExp(`^(?:tasks-.+-(?:implement|review|fix)(?:-\\d+)?|(?:${lines.join("|")})-(?:review|fix)(?:-\\d+)?)(?:\\.c\\d+)?\\.json$`);
35
- }
36
- /** The carrier's FINAL name of one round — the draft family name with its `.json`
37
- * suffix swapped for `.c{round}.json` (P31 §2.3: the finalized carrier never
38
- * overwrites the child's draft, so the two names share the stem and differ in the
39
- * suffix). The draft spelling stays the Ledger's family table (`handoffName` — the
40
- * naming truth); this rule runs on the name that table filled, so the two spellings
41
- * cannot drift. A round-less family has no cycle to key on: the family name comes
42
- * back unchanged, never a `.c.json` malformed suffix. */
43
- finalName(draftName, round = undefined) {
44
- if (round === undefined)
45
- return draftName;
46
- return `${draftName.replace(/\.json$/, "")}.c${round}.json`;
47
- }
48
- /** The final carrier's on-disk path — `finalName` resolved against the workspace
49
- * (the name is the input, so an absolute path is never re-joined). */
50
- finalPath(draftName, round = undefined) {
51
- return this.#workspace.resolve(this.finalName(draftName, round));
64
+ /** The identity of one (op, type, params) triple — the ONE adapter from the
65
+ * params-carrying surface (`Ledger#handoffName`, the seal legs) onto the renderer. */
66
+ static artifactOf(op, type, params) {
67
+ return {
68
+ line: _a.lineOf(type, params),
69
+ op,
70
+ cycle: params.round,
71
+ attempt: params.attempt,
72
+ };
73
+ }
74
+ /** The line word of a (type, params) pair — the wave line's `tasks-{tasks}` spine,
75
+ * every other type its own word. */
76
+ static lineOf(type, params) {
77
+ return type === "wave" ? `tasks-${params.tasks ?? ""}` : type;
78
+ }
79
+ /** Render one round identity as one artifact name — the ONE naming rule. The four
80
+ * segments (`line` · `op` · cycle · attempt) join in this order for every kind, so
81
+ * a kind only picks its own prefix/suffix around the shared stem. A `final` has no
82
+ * cycle to key on when the identity carries none: it renders the draft name back,
83
+ * never a malformed `.cundefined` suffix. The stem's cycle segment is omitted for a
84
+ * cycle-less identity; its attempt segment is omitted on the first attempt (an
85
+ * `-a1` never appears). */
86
+ static renderName(artifact, kind) {
87
+ const cycle = artifact.cycle === undefined || artifact.cycle === "" ? "" : `-${artifact.cycle}`;
88
+ const attempt = artifact.attempt === undefined || artifact.attempt <= 1 ? "" : `-a${artifact.attempt}`;
89
+ const stem = `${artifact.line}-${artifact.op}${cycle}${attempt}`;
90
+ switch (kind) {
91
+ case "draft":
92
+ return `${stem}.json`;
93
+ case "final":
94
+ return artifact.cycle === undefined || artifact.cycle === ""
95
+ ? `${stem}.json`
96
+ : `${stem}.c${artifact.cycle}.json`;
97
+ case "report":
98
+ return `${stem}-report.md`;
99
+ case "log":
100
+ return `${stem}.log`;
101
+ case "crash":
102
+ return `crash-${stem}.json`;
103
+ case "evidence":
104
+ return `${stem}-test-evidence.json`;
105
+ }
106
+ }
107
+ /** The carrier-name predicate's compiled pattern — a wave line takes the wave-only
108
+ * `tasks-` spine, every other line word takes the round-bearing ops. The op set and
109
+ * the line words come from the ONE target-face table, so neither is re-spelled here.
110
+ * Only `implement` has a cycle-less spelling (the pre-P34 draft on disk); `review`
111
+ * and `fix` always carry their cycle, so a `tasks-1-review.json` is no carrier at all.
112
+ * The `.c{cycle}` final suffix hangs off the CYCLE-BEARING alternatives alone — a
113
+ * cycle-less identity has no cycle to suffix, so `tasks-1-implement.c1.json` is a
114
+ * shape the renderer can never mint. */
115
+ /** The rendered name resolved against the workspace — the read/write syscall form. */
116
+ renderPath(artifact, kind) {
117
+ return this.#workspace.resolve(_a.renderName(artifact, kind));
52
118
  }
53
119
  /** Whether a workspace file name is one of the two carrier shapes this engine mints.
54
120
  * Every neighbouring artifact — `progress.json` · `base.json` · the test-evidence
@@ -57,17 +123,18 @@ export class RoundNaming {
57
123
  * judgment reads a NAME and nothing else, so the seal sweep (`CarrierSeal`) applies
58
124
  * the same predicate without holding a workspace. */
59
125
  static isCarrierName(name) {
60
- return RoundNaming.#CARRIER.test(name);
126
+ return CARRIER.test(name);
61
127
  }
62
128
  /** The handoff-family op of a frame — branch-review rides the review family. The
63
- * artifact stems embed this op, so the mapping is a naming fact owned here (the
129
+ * artifact names embed this op, so the mapping is a naming fact owned here (the
64
130
  * lifecycle's op read delegates, never a second copy of the rule). */
65
131
  op(frame) {
66
132
  return frame.phase === "branch-review" ? "review" : frame.phase;
67
133
  }
68
134
  /** The engine-rendered brief path of a wave's task group —
69
135
  * `tasks-{tasks}-brief.md` (the implement dispatch's read input; its producer is
70
- * `CliGate#renderBrief`). */
136
+ * `CliGate#renderBrief`). The brief is the dispatch's INPUT, not a round artifact:
137
+ * it carries no cycle or attempt. */
71
138
  brief(tasks) {
72
139
  return this.#workspace.resolve(this.briefName(tasks));
73
140
  }
@@ -76,13 +143,9 @@ export class RoundNaming {
76
143
  briefName(tasks) {
77
144
  return `tasks-${tasks}-brief.md`;
78
145
  }
79
- /** The prescribed report path of a round — the doc line's
80
- * `{type}-{op}-{round}-report.md` stem, the wave/branch line's
81
- * `{family}-{op}{-round}-report.md` (the implement round carries no round token:
82
- * the line keys the implement round alone). */
146
+ /** The prescribed report path of a round — the shared stem with `-report.md`. */
83
147
  report(frame) {
84
- const params = { tasks: frame.params.tasks, round: frame.round };
85
- return this.#workspace.resolve(`${this.#stem(this.op(frame), frame.type, params)}-report.md`);
148
+ return this.renderPath(this.#artifact(frame), "report");
86
149
  }
87
150
  /** The prescribed test-evidence path of a round — "" off the evidence rounds (the doc
88
151
  * lines and the review rounds prescribe no evidence file). */
@@ -90,23 +153,15 @@ export class RoundNaming {
90
153
  const name = this.evidenceName(frame);
91
154
  return name === "" ? "" : this.#workspace.resolve(name);
92
155
  }
93
- /** The test-evidence file NAME of a work frame — the workspace-relative face the
94
- * read-back gate reads it by (`{line}-test-evidence.json`: the task families key
95
- * the line, the branch line names the family alone). "" off the evidence rounds
96
- * — the doc shapes (phase-spec · overall · plan · single-spec) prescribe none. */
156
+ /** The test-evidence file NAME of a work frame — the shared stem with
157
+ * `-test-evidence.json`. "" off the evidence rounds — the doc shapes (phase-spec ·
158
+ * overall · plan · single-spec) and the review phase prescribe none. */
97
159
  evidenceName(frame) {
98
160
  if (TargetFaceTable.isDocShape(frame.type))
99
161
  return "";
100
162
  if (frame.phase !== "implement" && frame.phase !== "fix")
101
163
  return "";
102
- const key = frame.type === "wave" ? (frame.params.tasks ?? "") : "";
103
- const line = key === "" ? this.prefix(frame) : `${this.prefix(frame)}-${key}`;
104
- return `${line}-test-evidence.json`;
105
- }
106
- /** The evidence file's family prefix — `tasks` for the wave families, `branch`
107
- * for the branch line (never the misleading tasks- spine). */
108
- prefix(frame) {
109
- return frame.type === "wave" ? "tasks" : "branch";
164
+ return _a.renderName(this.#artifact(frame), "evidence");
110
165
  }
111
166
  /** The attempt number a dispatch of one op/cycle would take — the max attempt
112
167
  * already on record for that identity plus one (1 when the cycle was never
@@ -121,41 +176,35 @@ export class RoundNaming {
121
176
  }
122
177
  return latest + 1;
123
178
  }
124
- /** The per-round log file NAME of a round — the report stem with `.log` instead
125
- * of `-report.md`, carrying `-a{attempt}` when the dispatch is a re-attempt (so
126
- * attempt 1's log is never overwritten). The attempt is allocated by `attemptOf`
127
- * and passed in, never extrapolated here. */
179
+ /** The per-round log file NAME of a round — the shared stem with `.log`, carrying
180
+ * `-a{attempt}` when the dispatch is a re-attempt (so attempt 1's log is never
181
+ * overwritten). The attempt is allocated by `attemptOf` and passed in, never
182
+ * extrapolated here. */
128
183
  logName(op, type, params, attempt) {
129
- const attemptSuffix = attempt > 1 ? `-a${attempt}` : "";
130
- return `${this.#stem(op, type, params)}${attemptSuffix}.log`;
131
- }
132
- /** The round's artifact STEM — the ONE derivation the report and the log name read
133
- * (`{type}-{op}-{round}` on the doc lines, `{family}-{op}{-round}` on the
134
- * wave/branch lines). The round-token decision keys on the FAMILY OP (implement is
135
- * the round-less family), so the report and its log can never diverge. */
136
- #stem(op, type, params) {
137
- if (TargetFaceTable.isDocShape(type))
138
- return `${type}-${op}-${params.round}`;
139
- const family = type === "wave" ? `tasks-${params.tasks ?? ""}` : "branch";
140
- const suffix = op === "implement" ? "" : `-${params.round}`;
141
- return `${family}-${op}${suffix}`;
142
- }
143
- /** The crash record's workspace-relative name — `crash-{line}-{op}-{round}.json`.
144
- * The `line` derives from the frame's ONE identity (wave → `tasks-{tasks}`;
145
- * branch / the doc shapes → the line-type constant), the `op` keeps the verb
146
- * (`RoundNaming.op`: branch-review rides the review family) — so a wave's
147
- * implement-2 and review-2 crash records never overwrite each other. */
184
+ const artifact = _a.artifactOf(op, type, { ...params, attempt });
185
+ return _a.renderName(artifact, "log");
186
+ }
187
+ /** The crash record's workspace-relative name — the shared stem with its own
188
+ * `crash-` prefix, so a wave's implement and review round crash records never
189
+ * overwrite each other. */
148
190
  crashName(frame) {
149
- return `crash-${this.#line(frame)}-${this.op(frame)}-${frame.round}.json`;
191
+ return _a.renderName(this.#artifact(frame), "crash");
150
192
  }
151
193
  /** The crash record's on-disk path — the same derivation as `crashName` (one
152
194
  * name, one rule; the read and write faces agree by construction). */
153
195
  crashPath(frame) {
154
196
  return this.#workspace.resolve(this.crashName(frame));
155
197
  }
156
- /** A frame's line identity — the dispatch unit the crash record keys on: the
157
- * wave's task group (`tasks-{tasks}`), the branch line, or the doc-type line. */
158
- #line(frame) {
159
- return frame.type === "wave" ? `tasks-${frame.params.tasks ?? ""}` : frame.type;
198
+ /** A frame's naming identity — the ONE adapter from the frame onto the renderer.
199
+ * `op` defaults to the frame's own (`op()`), and the attempt falls back to the
200
+ * params' cell so a caller that only carried it there still names its round. */
201
+ #artifact(frame, op = this.op(frame)) {
202
+ return {
203
+ line: _a.lineOf(frame.type, frame.params),
204
+ op,
205
+ cycle: frame.round,
206
+ attempt: frame.attempt ?? frame.params.attempt,
207
+ };
160
208
  }
161
209
  }
210
+ _a = RoundNaming;