@oscaner-skills/cdd-engine 4.7.0 → 4.9.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.
@@ -1,7 +1,8 @@
1
1
  // packages/cdd-engine/src-next/contract/completion-criterion.ts
2
2
  // P22 T4/T6 — "is this round done?" as criteria behind ONE verb-keyed registry
3
3
  // (design spec §8 · the completion-criterion row): `implement` is done when the
4
- // group's baseline carries at least one commit, `review` (branch review included —
4
+ // group's baseline carries at least one commit OR the round is a zero-diff
5
+ // verification wave with green evidence (P30 §2.4), `review` (branch review included —
5
6
  // branch-review folds to the review op) is done when its carrier is schema-shaped,
6
7
  // and `fix` is done when its work carrier's `dispositions` cover every finding of
7
8
  // the REQUESTING review carrier (design spec §3.4).
@@ -9,9 +10,9 @@
9
10
  // The criterion judges a CompletionContext the dispatch side assembles (Task 7):
10
11
  // the round's verdict-free identity, its ledger row, the row's in-register records,
11
12
  // the persisted carrier bytes, the requester's review path, the git read face and the
12
- // repoRoot path basis. The two cells with a provider seam (`records`, `reviewsPath`) are
13
- // filled by `CliLifecycle` — this module pins the context SHAPE only and imports
14
- // neither `face/` nor the lifecycle.
13
+ // repoRoot path basis. The four cells with a provider seam (`records`, `reviewsPath`,
14
+ // `emptyFileTasks`, `evidenceOk`) are filled by `CliLifecycle` — this module pins the
15
+ // context SHAPE only and imports neither `face/` nor the lifecycle.
15
16
  //
16
17
  // The registry is deliberately PARTIAL while the verbs are ported one at a time: a
17
18
  // verb with no criterion throws at lookup (`CompletionCriteria.of`), so a dispatch of
@@ -21,19 +22,26 @@
21
22
  //
22
23
  // Module-level exports are types / the declared registry / the class — zero
23
24
  // behavior-carrying bare functions.
24
- var _a;
25
- import { readFileSync } from "node:fs";
25
+ var _a, _b;
26
26
  import path from "node:path";
27
+ import { CarrierIntegrity, CarrierMismatchError } from "../session/carrier-integrity.js";
27
28
  import { RoundViolation, } from "../session/ledger.js";
28
29
  /**
29
30
  * CommitsSinceGroupBase — the implement criterion: the round is done when the GROUP
30
- * has at least one commit since the group's baseline (design spec §8).
31
+ * has at least one commit since the group's baseline (design spec §8), OR when the
32
+ * round is a VERIFICATION wave with green evidence (P30 §2.4).
31
33
  *
32
34
  * The baseline is the EARLIEST record's `dispatchBase` of the group — not the round's
33
35
  * own. A group re-dispatched after a failed attempt carries a newer per-attempt base,
34
36
  * so comparing against the round's own base would read "attempt 1 committed, attempt 2
35
37
  * committed nothing" as an empty round (the cross-attempt false negative the group
36
38
  * baseline exists to prevent).
39
+ *
40
+ * The second leg is a strictly additive OR branch: a wave whose EVERY task declares an
41
+ * empty `Files` (a verification wave — it changes no file by design) commits nothing,
42
+ * so its green evidence is the round's completion. The commit test itself is
43
+ * untouched — a wave with any non-empty `Files` row keeps the `committed nothing`
44
+ * refusal on a zero diff.
37
45
  */
38
46
  export class CommitsSinceGroupBase {
39
47
  /** The group baseline — the first record (ledger order = cycle/attempt order) that
@@ -46,27 +54,70 @@ export class CommitsSinceGroupBase {
46
54
  }
47
55
  return null;
48
56
  }
57
+ /** Whether the wave is a VERIFICATION wave: EVERY task id the wave key declares has
58
+ * an empty `Files` declaration. The id set is read from the row's `wave` key (the
59
+ * wave-unitary model's group identity, `"1,2"` = `{1, 2}`) — the empty-`Files` cell
60
+ * carries membership only, so a set that is a mere subset of the wave must not read
61
+ * as "the whole wave changes nothing". A wave key declaring no id is never a
62
+ * verification wave: an empty member set would satisfy "every member" vacuously. */
63
+ static isVerificationWave(row, emptyFileTasks) {
64
+ const ids = _a.waveIdsOf(row.wave);
65
+ if (ids.length === 0)
66
+ return false;
67
+ return ids.every((id) => emptyFileTasks.has(id));
68
+ }
69
+ /** The task ids one wave key declares — the comma-separated digits of `row.wave`,
70
+ * deduped. A non-numeric token carries no task identity and is dropped. */
71
+ static waveIdsOf(wave) {
72
+ const ids = new Set();
73
+ for (const token of wave.split(",")) {
74
+ const trimmed = token.trim();
75
+ if (/^\d+$/.test(trimmed))
76
+ ids.add(Number(trimmed));
77
+ }
78
+ return [...ids];
79
+ }
49
80
  async judge(ctx) {
50
81
  // The round under judgment is APPENDED to the group's recorded history: on a
51
82
  // group's FIRST dispatch the ledger holds no record yet (the round is recorded at
52
83
  // bookkeep, after this judgment), and the round's own `dispatchBase` IS the group
53
84
  // baseline. An earlier record always wins — the group's start, never a retry's.
54
- const base = CommitsSinceGroupBase.groupBaseOf([...ctx.records, ctx.record]);
85
+ const base = _a.groupBaseOf([...ctx.records, ctx.record]);
55
86
  if (base === null) {
56
87
  return this.#hard("the round's group carries no dispatch baseline — a completion judgment needs the HEAD the group started from");
57
88
  }
58
89
  const commits = await ctx.git.commitsSince(ctx.repoRoot, base);
59
- if (commits.length === 0) {
60
- return this.#hard(`the group committed nothing since its baseline ${base}`);
61
- }
62
- // An implement round is judged by its COMMITS, never by its handoff draft: the
63
- // absent carrier is a bookkeeping observation (design spec §3.3), so the round
64
- // still concludes.
90
+ if (commits.length > 0)
91
+ return this.#committed(ctx);
92
+ return this.#zeroCommit(ctx, base);
93
+ }
94
+ /** A round with commits concludes. An implement round is judged by its COMMITS, never
95
+ * by its handoff draft: the absent carrier is a bookkeeping observation (design spec
96
+ * §3.3), so the round still concludes. */
97
+ #committed(ctx) {
65
98
  if (ctx.carrier === null) {
66
99
  return { fulfilled: true, violation: null, observations: [this.#observation()] };
67
100
  }
68
101
  return { fulfilled: true, violation: null };
69
102
  }
103
+ /** A zero-commit round: a verification wave with green evidence concludes (its empty
104
+ * diff is the plan's declaration, not an empty round), every other zero-commit round
105
+ * keeps the `committed nothing` refusal. The two refusals name DIFFERENT gaps — a
106
+ * wave that declares no file changes and owes evidence is not the same defect as a
107
+ * wave that simply produced nothing. */
108
+ #zeroCommit(ctx, base) {
109
+ const verification = _a.isVerificationWave(ctx.row, ctx.emptyFileTasks);
110
+ if (!verification) {
111
+ return this.#hard(`the group committed nothing since its baseline ${base}`);
112
+ }
113
+ if (!ctx.evidenceOk) {
114
+ return this.#hard("the wave declares no file changes on every task, but this round's test evidence is not green — a verification wave still owes green evidence");
115
+ }
116
+ const observations = [this.#verificationObservation()];
117
+ if (ctx.carrier === null)
118
+ observations.push(this.#observation());
119
+ return { fulfilled: true, violation: null, observations };
120
+ }
70
121
  /** The hard verdict of this criterion — the ledger's existing `contract-violation`
71
122
  * cause, never a new violation enum row. */
72
123
  #hard(message) {
@@ -77,7 +128,13 @@ export class CommitsSinceGroupBase {
77
128
  #observation() {
78
129
  return RoundViolation.soft(IMPLEMENT_CARRIER_ABSENT);
79
130
  }
131
+ /** The verification-wave observation — the round passed on its plan declaration plus
132
+ * green evidence rather than on a diff; booked soft, it never gates. */
133
+ #verificationObservation() {
134
+ return RoundViolation.soft(IMPLEMENT_VERIFICATION_WAVE);
135
+ }
80
136
  }
137
+ _a = CommitsSinceGroupBase;
81
138
  /**
82
139
  * JudgeCarrier — the review criterion: a review round is done exactly when its
83
140
  * carrier is a schema-shaped judge payload — a JSON object whose `findings` is an
@@ -105,6 +162,12 @@ export class JudgeCarrier {
105
162
  * round is judged by its COMMITS, so a round that committed its work but wrote no
106
163
  * handoff draft still concludes; the missing carrier is booked, never gated. */
107
164
  export const IMPLEMENT_CARRIER_ABSENT = "the implement round wrote no handoff carrier — the round is judged by its commits, not by its draft";
165
+ /** The zero-diff verification-wave observation (P30 §2.4) — the wave's every task
166
+ * declares an empty `Files`, so its empty diff IS the plan's declaration and its
167
+ * green evidence is the round's completion. Booked soft: the round concluded on the
168
+ * declaration, and the ledger says so instead of reading it as an ordinary commit
169
+ * round that happened to leave nothing. */
170
+ export const IMPLEMENT_VERIFICATION_WAVE = "the implement round committed nothing — every task of this wave declares an empty `Files`, so the round concluded on its green evidence as a verification wave";
108
171
  /** The zero-commit observation of a fix round — a NEW literal (the engine had no
109
172
  * reusable zero-commit warning; `commitsSince` fed the crash postmortem alone).
110
173
  * The yardstick is THIS round's own `dispatchBase`: the implement criterion asks
@@ -116,6 +179,11 @@ export const FIX_DISPOSITIONS_ZERO_COMMIT = "the fix round committed nothing sin
116
179
  /** The empty-input observation — an empty requesting carrier is legal input, so it
117
180
  * is reported, never refused. */
118
181
  export const FIX_DISPOSITIONS_EMPTY_INPUT = "the requesting review carrier carries no findings — the fix round owes no dispositions";
182
+ /** The legacy-key-set observation (P30 §2.5) — the requesting carrier carries no
183
+ * finding `id` (it predates the engine-written key), so the dispositions were matched
184
+ * by summary text. Booked soft: the round is judged, and the ledger says the key it
185
+ * used. No carrier migration — present facts only. */
186
+ export const FIX_DISPOSITIONS_LEGACY_KEYS = "the requesting review carrier carries no finding `id` — the dispositions were matched by summary text, the legacy key";
119
187
  /** The legacy-record observation — no requesting carrier is locatable, so the
120
188
  * judgment is skipped visibly (reading the gap as an empty input set would restore
121
189
  * an always-passing criterion). */
@@ -123,50 +191,71 @@ export const FIX_DISPOSITIONS_UNRECORDED = "the requesting review round records
123
191
  /**
124
192
  * FixDispositions — the fix criterion: the round is done when its work carrier's
125
193
  * `dispositions` cover every finding of the requesting review carrier (design spec
126
- * §3.4). The input set is the REQUESTING side's carrier — the same-key same-cycle
127
- * completed review record's `carrierPath`, falling back to the fix route's
194
+ * §3.4, P30 §2.5). The input set is the REQUESTING side's carrier — the same-key
195
+ * same-cycle completed review record's `carrierPath`, falling back to the fix route's
128
196
  * `--reviews` path; the round's own `carrierPath` is never the input set.
129
197
  *
130
- * Keys are the findings' `summary` strings VERBATIM (no normalization, no
131
- * fingerprint); repeated summaries collapse to one key (one defect owes one
132
- * disposition). Values are `{ status: "fixed" | "rejected", reason?: string }` —
133
- * `rejected` without a reason is a shape violation, hard like the missing slot.
198
+ * Keys are the findings' engine-written `id`s (`F1`, `F2` … in carrier order) — the
199
+ * primary key the engine authors, so rewriting a summary no longer produces an unknown
200
+ * key. `summary` is description text: it labels the failure message (its first
201
+ * sentence) and nothing else. A LEGACY carrier that predates the `id` column carries
202
+ * none, so its `summary` stands in as the key and the round books one soft observation
203
+ * (present facts only — no carrier migration).
204
+ *
205
+ * The key-set refusal prints BOTH diffs in ONE message: the missing side (a carrier
206
+ * finding with no disposition — `id` + summary first sentence, carrier order) and the
207
+ * unknown side (a disposition no finding raised — its bare key, marked `unknown`). One
208
+ * failure therefore names everything the child has to fix.
209
+ *
210
+ * Values are `{ status: "fixed" | "rejected", reason?: string }` — `rejected` without a
211
+ * reason is a shape violation, hard like the missing slot.
134
212
  *
135
213
  * The fix round's zero-commit fact is an OBSERVATION, not a refusal: this criterion
136
214
  * answers from the carrier, never from the diff.
137
215
  */
138
216
  export class FixDispositions {
139
- /** The requesting carrier's path — the completed review record of the SAME key (the
140
- * row's records are already the key's) and the SAME cycle as the fix round; a
141
- * legacy record without `carrierPath` falls back to the route's `--reviews` path. */
217
+ /** The requesting carrier's path — the LATEST attempt of the same-cycle review of the
218
+ * SAME key (the row's records are already the key's), the record whose digest the
219
+ * checked read compares against; a legacy record without `carrierPath` falls back to
220
+ * the route's `--reviews` path. */
142
221
  static requesterPathOf(records, cycle, reviewsPath) {
143
- for (const record of records) {
144
- if (record.op !== "review" || record.cycle !== cycle)
145
- continue;
146
- if (!record.verdict.targetAction)
147
- continue;
148
- return record.carrierPath ?? reviewsPath;
149
- }
150
- return reviewsPath;
222
+ return _b.#requesterOf(records, cycle)?.carrierPath ?? reviewsPath;
151
223
  }
152
- /** Read the requesting carrier's input set (the summaries, deduped in order). The
153
- * read is synchronous on purpose: the input is ONE small carrier, and the dispatch
154
- * face already reads its small inputs synchronously at the same seam.
224
+ /** Read the requesting carrier's input set (the findings, deduped by disposition
225
+ * key in carrier order). The read is synchronous on purpose: the input is ONE small
226
+ * carrier, and the dispatch face already reads its small inputs synchronously at
227
+ * the same seam.
155
228
  *
156
229
  * Every path resolves against `repoRoot`, never `process.cwd()`: the engine runs
157
230
  * from a subdirectory too, `--reviews` arrives repoRoot-relative and a record's
158
231
  * `carrierPath` arrives absolute — both must land on the one basis (`RepoRoot`'s
159
- * rule). The reported `path` is the resolved one, so a failure names a real file. */
232
+ * rule). The reported `path` is the resolved one, so a failure names a real file.
233
+ *
234
+ * P31 §2.2 — the read is the ONE checked carrier read (`CarrierIntegrity.read`):
235
+ * the requesting round's recorded digest decides ok / mismatch, so a tampered
236
+ * input throws instead of being judged as if the round had written those bytes. */
160
237
  static requesterInputOf(records, cycle, reviewsPath, repoRoot) {
161
- const declared = _a.requesterPathOf(records, cycle, reviewsPath);
238
+ const requester = _b.#requesterOf(records, cycle);
239
+ const declared = requester?.carrierPath ?? reviewsPath;
162
240
  if (declared === null)
163
241
  return { kind: "unrecorded" };
164
242
  const target = path.resolve(repoRoot, declared);
165
243
  let carrier;
166
244
  try {
167
- carrier = JSON.parse(readFileSync(target, "utf8"));
245
+ // P31 §2.2 — the input carrier is read through the ONE checked seam: the
246
+ // requesting review record's digest when it declared the path, no comparison on
247
+ // the legacy `--reviews` fallback. A mismatch is NOT an `unreadable` input (that
248
+ // would silently judge the tampered bytes): the error propagates and the CLI's
249
+ // blocked channel names it.
250
+ const bytes = CarrierIntegrity.read(target, _b.#requesterDigestOf(requester));
251
+ if (bytes === null) {
252
+ return { kind: "unreadable", path: target, detail: "the file is absent or not JSON" };
253
+ }
254
+ carrier = JSON.parse(bytes);
168
255
  }
169
- catch {
256
+ catch (raw) {
257
+ if (raw instanceof CarrierMismatchError)
258
+ throw raw;
170
259
  return { kind: "unreadable", path: target, detail: "the file is absent or not JSON" };
171
260
  }
172
261
  const findings = carrier?.findings;
@@ -177,7 +266,7 @@ export class FixDispositions {
177
266
  detail: "the carrier declares no `findings` array",
178
267
  };
179
268
  }
180
- const set = _a.#summariesOf(findings);
269
+ const set = _b.#findingsOf(findings);
181
270
  if ("index" in set) {
182
271
  return {
183
272
  kind: "unreadable",
@@ -185,7 +274,26 @@ export class FixDispositions {
185
274
  detail: `finding #${set.index} carries no string \`summary\``,
186
275
  };
187
276
  }
188
- return { kind: "read", path: target, summaries: set.summaries };
277
+ return { kind: "read", path: target, findings: set.findings };
278
+ }
279
+ /** THE requesting record — the LATEST attempt of the same-cycle review (a re-dispatch
280
+ * supersedes its predecessor, the same rule the ledger's checked carrier read and the
281
+ * dispatch gate apply). Path AND digest come from this one record, so a re-dispatched
282
+ * review is never read against its predecessor's digest: the gate and this criterion
283
+ * cannot disagree about which review round the fix is answering. */
284
+ static #requesterOf(records, cycle) {
285
+ return records
286
+ .filter((record) => record.op === "review" && record.cycle === cycle)
287
+ .reduce((newest, record) => newest === undefined || record.attempt >= newest.attempt ? record : newest, undefined);
288
+ }
289
+ /** The digest the requesting review round recorded — read off the SAME record
290
+ * `requesterPathOf` selects. Null when that record declared no path (the legacy
291
+ * `--reviews` fallback carries no digest, so the read performs no comparison) or when
292
+ * the record predates the digest column. */
293
+ static #requesterDigestOf(record) {
294
+ if (record === undefined || record.carrierPath === null)
295
+ return null;
296
+ return record.carrierDigest ?? null;
189
297
  }
190
298
  /** The carrier's `dispositions` map — null when the slot is absent or not an
191
299
  * object (the criterion's own shape refusal; the schema only pins the slot type). */
@@ -201,32 +309,32 @@ export class FixDispositions {
201
309
  const own = this.#ownRefusal(ctx);
202
310
  if (own !== null)
203
311
  return own;
204
- const requester = _a.requesterInputOf(ctx.records, ctx.record.cycle, ctx.reviewsPath, ctx.repoRoot);
312
+ const requester = _b.requesterInputOf(ctx.records, ctx.record.cycle, ctx.reviewsPath, ctx.repoRoot);
205
313
  if (requester.kind === "unrecorded")
206
314
  return this.#complete([this.#soft(FIX_DISPOSITIONS_UNRECORDED)]);
207
315
  if (requester.kind === "unreadable") {
208
316
  return this.#hard(`the requesting review carrier is missing or unreadable at ${requester.path} — ${requester.detail}`);
209
317
  }
210
- const dispositions = _a.dispositionsOf(ctx.carrier) ?? {};
211
- const refusal = _a.#keyRefusal(dispositions, requester.summaries);
318
+ const dispositions = _b.dispositionsOf(ctx.carrier) ?? {};
319
+ const refusal = _b.#keyRefusal(dispositions, requester.findings);
212
320
  if (refusal !== null)
213
321
  return this.#hard(refusal);
214
- const shape = _a.#valueRefusal(dispositions);
322
+ const shape = _b.#valueRefusal(dispositions);
215
323
  if (shape !== null)
216
324
  return this.#hard(shape);
217
- return this.#complete(await this.#observationsOf(ctx, requester.summaries));
325
+ return this.#complete(await this.#observationsOf(ctx, requester.findings));
218
326
  }
219
327
  /** The round's two summary counts — `fixed` / `rejected`, counted over the SAME
220
- * pair the judgment reads (dispositions ∩ the input set). Counts only: the
328
+ * pair the judgment reads (dispositions ∩ the input key set). Counts only: the
221
329
  * `fixed N · rejected M` line is rendered by the presentation plane
222
330
  * (`face/words.ts` template). A face fact: never stored, never a capsule key,
223
331
  * never a second read face. */
224
332
  summaryOf(carrier, input) {
225
- const wanted = new Set(input);
333
+ const wanted = new Set(input.map((finding) => _b.keyOf(finding)));
226
334
  let fixed = 0;
227
335
  let rejected = 0;
228
- for (const [summary, value] of Object.entries(_a.dispositionsOf(carrier) ?? {})) {
229
- if (!wanted.has(summary))
336
+ for (const [key, value] of Object.entries(_b.dispositionsOf(carrier) ?? {})) {
337
+ if (!wanted.has(key))
230
338
  continue;
231
339
  const status = value?.status;
232
340
  if (status === "fixed")
@@ -236,6 +344,12 @@ export class FixDispositions {
236
344
  }
237
345
  return { fixed, rejected };
238
346
  }
347
+ /** One finding's disposition key — the engine-written `id`, or the summary on a
348
+ * LEGACY carrier that carries none (`keyOf` is the ONE fallback ruling: the read,
349
+ * the judgment and the counts all derive the key here). */
350
+ static keyOf(finding) {
351
+ return finding.id ?? finding.summary;
352
+ }
239
353
  /** The round's own carrier refusals (① missing carrier, ② missing slot). */
240
354
  #ownRefusal(ctx) {
241
355
  const carrier = ctx.carrier;
@@ -245,24 +359,49 @@ export class FixDispositions {
245
359
  ? "the fix round persisted no work carrier and recorded no carrier path"
246
360
  : `the fix round persisted no work carrier at ${at}`);
247
361
  }
248
- if (_a.dispositionsOf(carrier) === null) {
362
+ if (_b.dispositionsOf(carrier) === null) {
249
363
  return this.#hard("the fix carrier declares no `dispositions` object — every requesting finding owes a fixed/rejected row");
250
364
  }
251
365
  return null;
252
366
  }
253
- /** The key-set refusals (③ missing entries, ④ unknown entries) — exact matching,
254
- * one defect one disposition. */
367
+ /** The key-set refusal — BOTH diffs in one message (P30 §2.5), each entry carrying
368
+ * what makes it actionable: the missing side names the finding by `id` + the summary's
369
+ * first sentence (carrier order), the unknown side names the bare key and marks it
370
+ * `unknown` (the carrier raised no such finding, so there is no summary to quote —
371
+ * inventing one would be worse than saying `unknown`). */
255
372
  static #keyRefusal(dispositions, input) {
256
- const wanted = new Set(input);
373
+ const wanted = new Set(input.map((finding) => _b.keyOf(finding)));
257
374
  const unknown = Object.keys(dispositions).filter((key) => !wanted.has(key));
258
- if (unknown.length > 0) {
259
- return `disposition(s) for finding(s) the requesting carrier never raised: ${unknown.join(", ")}`;
260
- }
261
- const missing = input.filter((summary) => !Object.hasOwn(dispositions, summary));
375
+ const missing = input.filter((finding) => !Object.hasOwn(dispositions, _b.keyOf(finding)));
376
+ if (unknown.length === 0 && missing.length === 0)
377
+ return null;
378
+ const parts = [];
262
379
  if (missing.length > 0) {
263
- return `no disposition for finding(s) of the requesting carrier: ${missing.join(", ")}`;
380
+ parts.push(`no disposition for finding(s) of the requesting carrier: ${missing
381
+ .map((finding) => _b.#labelOf(finding))
382
+ .join(", ")}`);
264
383
  }
265
- return null;
384
+ if (unknown.length > 0) {
385
+ parts.push(`disposition(s) for finding(s) the requesting carrier never raised: ${unknown
386
+ .map((key) => `${key} (unknown)`)
387
+ .join(", ")}`);
388
+ }
389
+ return parts.join(" · ");
390
+ }
391
+ /** One finding's failure label — an id-bearing finding reads `F2 "<summary first
392
+ * sentence>"`; a legacy finding's key IS its summary, so the sentence alone is the
393
+ * whole label. */
394
+ static #labelOf(finding) {
395
+ const sentence = _b.#firstSentence(finding.summary);
396
+ return finding.id === null ? `"${sentence}"` : `${finding.id} "${sentence}"`;
397
+ }
398
+ /** The summary's first sentence — the message's actionable excerpt (the whole summary
399
+ * is a paragraph in practice). A summary with no terminator is its own sentence; a
400
+ * leading terminator falls back to the whole line rather than an empty quote. */
401
+ static #firstSentence(summary) {
402
+ const text = summary.trim();
403
+ const cut = text.search(/[.!?。!?]/);
404
+ return cut <= 0 ? text : text.slice(0, cut + 1);
266
405
  }
267
406
  /** The value-shape refusal (⑥ `rejected` without a reason; a status outside the
268
407
  * two declared words is the same shape family). */
@@ -279,12 +418,15 @@ export class FixDispositions {
279
418
  }
280
419
  return null;
281
420
  }
282
- /** The two soft observations of a completed fix round — the empty input set and the
283
- * zero-commit round (both bookkeeping, neither a gate). */
421
+ /** The soft observations of a completed fix round — the empty input set, the legacy
422
+ * (id-less) key set and the zero-commit round (all bookkeeping, none a gate). */
284
423
  async #observationsOf(ctx, input) {
285
424
  const observations = [];
286
425
  if (input.length === 0)
287
426
  observations.push(this.#soft(FIX_DISPOSITIONS_EMPTY_INPUT));
427
+ if (input.some((finding) => finding.id === null)) {
428
+ observations.push(this.#soft(FIX_DISPOSITIONS_LEGACY_KEYS));
429
+ }
288
430
  // THIS round's own baseline — a null one (legacy fold, non-git tree) carries no
289
431
  // present fact, so the observation is simply unmeasurable, never invented.
290
432
  const base = ctx.record.dispatchBase;
@@ -295,23 +437,32 @@ export class FixDispositions {
295
437
  }
296
438
  return observations;
297
439
  }
298
- /** The deduped input set — repeated summaries collapse to one key. A finding
299
- * without a string `summary` is NOT skipped (a silently dropped finding owes no
300
- * disposition and passes forever): the caller grades it `unreadable`.
301
- * `index` is the first offending entry. */
302
- static #summariesOf(findings) {
303
- const summaries = [];
440
+ /** The deduped input set — repeated disposition KEYS collapse to one entry (a legacy
441
+ * carrier with the same summary twice owes one disposition; id-bearing findings keep
442
+ * their own keys, so distinct findings never collapse). A finding without a string
443
+ * `summary` is NOT skipped (a silently dropped finding owes no disposition and passes
444
+ * forever): the caller grades it `unreadable`. `index` is the first offending entry.
445
+ * An `id` that is absent or not a non-empty string is `null` — the legacy key, never
446
+ * an invented one. */
447
+ static #findingsOf(findings) {
448
+ const rows = [];
304
449
  const seen = new Set();
305
450
  for (const [index, finding] of findings.entries()) {
306
451
  const summary = finding?.summary;
307
452
  if (typeof summary !== "string")
308
453
  return { index };
309
- if (seen.has(summary))
454
+ const raw = finding?.id;
455
+ const row = {
456
+ id: typeof raw === "string" && raw.length > 0 ? raw : null,
457
+ summary,
458
+ };
459
+ const key = _b.keyOf(row);
460
+ if (seen.has(key))
310
461
  continue;
311
- seen.add(summary);
312
- summaries.push(summary);
462
+ seen.add(key);
463
+ rows.push(row);
313
464
  }
314
- return { summaries };
465
+ return { findings: rows };
315
466
  }
316
467
  #complete(observations) {
317
468
  return { fulfilled: true, violation: null, observations };
@@ -327,7 +478,7 @@ export class FixDispositions {
327
478
  return RoundViolation.soft(message);
328
479
  }
329
480
  }
330
- _a = FixDispositions;
481
+ _b = FixDispositions;
331
482
  /** The verb-keyed criterion registry — one criterion per op verb. A verb is
332
483
  * registered when its criterion lands (branch review folds to `review`, so it needs
333
484
  * no own row); an UNREGISTERED verb still throws at lookup, so a future verb can
@@ -458,7 +458,10 @@ const OVERALL_ELEMENTS = [
458
458
  home: "table",
459
459
  selector: SelectorSpec.table(SelectorSpec.heading("## File paths"), /^\| [^|]+ \| `[^`]+` \|$/),
460
460
  },
461
- // Change history — the version-lineage surface.
461
+ // Change history — the version-lineage surface. Both the row selector and the
462
+ // version-cell read are anchored at the FIRST column: a row's identity is a cell
463
+ // that IS `v<n>.<m>`, never prose carrying a version token. The judgment plane's
464
+ // `lineageRows` / `lineageVersion` reads hold the same anchor (`invariants.ts`).
462
465
  {
463
466
  anchor: "Change history row",
464
467
  presence: "required",