@juicesharp/rpiv-pi 2.9.0 → 2.10.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.
- package/extensions/rpiv-core/artifact-collector.ts +30 -7
- package/extensions/rpiv-core/built-in-workflows.ts +222 -70
- package/extensions/rpiv-core/built-ins/citations.ts +9 -0
- package/extensions/rpiv-core/built-ins/design.ts +64 -0
- package/extensions/rpiv-core/built-ins/elaboration.ts +53 -0
- package/extensions/rpiv-core/built-ins/gates.ts +282 -12
- package/extensions/rpiv-core/built-ins/grade-panel.ts +54 -26
- package/extensions/rpiv-core/built-ins/index.ts +20 -1
- package/extensions/rpiv-core/built-ins/markdown-fence.ts +26 -1
- package/extensions/rpiv-core/built-ins/plan-phases.ts +8 -0
- package/extensions/rpiv-core/built-ins/priors.ts +9 -2
- package/extensions/rpiv-core/built-ins/remediation.ts +60 -7
- package/extensions/rpiv-core/built-ins/scope-checks.ts +74 -11
- package/extensions/rpiv-core/built-ins/shared.ts +5 -3
- package/extensions/rpiv-core/built-ins/slice-checks.ts +164 -28
- package/extensions/rpiv-core/built-ins/slices.ts +44 -13
- package/extensions/rpiv-core/built-ins/verdict-collector.ts +207 -0
- package/extensions/rpiv-core/built-ins/verdict-outcome.ts +36 -0
- package/extensions/rpiv-core/lane-list.ts +10 -1
- package/extensions/rpiv-core/lane-progress.ts +1 -1
- package/extensions/rpiv-core/lane-usage.ts +1 -1
- package/extensions/rpiv-core/models-picker.ts +4 -3
- package/extensions/rpiv-core/run-lane-registry.ts +1 -2
- package/extensions/rpiv-core/sdk-workflow-host.ts +20 -4
- package/extensions/rpiv-core/session-hooks.ts +1 -1
- package/package.json +4 -3
- package/skills/_shared/stitch-elaborations.mjs +282 -21
- package/skills/acceptance/SKILL.md +3 -2
- package/skills/amend/SKILL.md +5 -5
- package/skills/design-slice/SKILL.md +5 -0
- package/skills/elaborate/SKILL.md +10 -3
- package/skills/grade/SKILL.md +13 -10
- package/skills/validate/SKILL.md +14 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The slice-design stage's outcome: the `designs` bucket collector with a
|
|
3
|
+
* parser that adds one path-derived fact beside the frontmatter, so the
|
|
4
|
+
* design-slice skill contract can refuse a filename that fails to carry the
|
|
5
|
+
* slice it designs while the lane is still alive to rename it — the twin of
|
|
6
|
+
* elaboration.ts's `fence_walk`. Identity downstream (`designSliceOf`) reads
|
|
7
|
+
* `slice_n` first, so this check guards the FILENAME carrier that
|
|
8
|
+
* `sourcesCoverageGaps` can only ever see as a path string in `sources:`.
|
|
9
|
+
*/
|
|
10
|
+
import { basename } from "node:path";
|
|
11
|
+
import { defineParser, type Outcome, type ParseContext } from "@juicesharp/rpiv-workflow/registration";
|
|
12
|
+
import { frontmatterParser, rpivBucketOutcome } from "../artifact-collector.js";
|
|
13
|
+
import { DESIGN_SLICE_RE } from "./slices.js";
|
|
14
|
+
|
|
15
|
+
interface DesignStructure {
|
|
16
|
+
/** `"matches"`, or the diagnosis the contract's enum failure surfaces verbatim. */
|
|
17
|
+
filename_slice: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** The path-vs-frontmatter slice agreement of one design artifact. */
|
|
21
|
+
const designStructure = (path: string, frontmatter: Record<string, unknown>): DesignStructure => {
|
|
22
|
+
const name = basename(path);
|
|
23
|
+
const token = DESIGN_SLICE_RE.exec(name);
|
|
24
|
+
const sliceN = frontmatter.slice_n;
|
|
25
|
+
if (typeof sliceN !== "number" || !Number.isInteger(sliceN) || sliceN <= 0) {
|
|
26
|
+
return {
|
|
27
|
+
filename_slice: `frontmatter slice_n is ${sliceN === undefined ? "missing" : JSON.stringify(sliceN)} — stamp slice_n: <N> from the dispatched 'Slice N' and name the file <slug>_slice-<N>_<topic>.md`,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
if (!token) {
|
|
31
|
+
return {
|
|
32
|
+
filename_slice: `${name} carries no 'slice-<N>' token — the path is <slug>_slice-${sliceN}_<topic>.md (the slice title is the topic, never the slice id); write the design to that path`,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
if (Number(token[1]) !== sliceN) {
|
|
36
|
+
return {
|
|
37
|
+
filename_slice: `${name} says slice-${token[1]} but frontmatter slice_n is ${sliceN} — the two must agree; the dispatched 'Slice N' is the slice, name the file <slug>_slice-${sliceN}_<topic>.md`,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
return { filename_slice: "matches" };
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/** Frontmatter plus the derived structure; the derived key wins over an authored one. */
|
|
44
|
+
const designParser = defineParser<undefined, "artifact-md", Record<string, unknown>>({
|
|
45
|
+
async parse(ctx: ParseContext<undefined>) {
|
|
46
|
+
const base = await frontmatterParser.parse(ctx);
|
|
47
|
+
const primary = ctx.artifacts[0];
|
|
48
|
+
if (base.kind !== "ok" || primary?.handle.kind !== "fs") return base;
|
|
49
|
+
return {
|
|
50
|
+
kind: "ok",
|
|
51
|
+
payload: {
|
|
52
|
+
kind: "artifact-md",
|
|
53
|
+
data: { ...base.payload.data, ...designStructure(primary.handle.path, base.payload.data) },
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const designOutcome: Outcome<unknown, "artifact-md", Record<string, unknown>> = {
|
|
60
|
+
...rpivBucketOutcome("designs"),
|
|
61
|
+
parser: designParser,
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export { type DesignStructure, designOutcome, designParser, designStructure };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The elaborate stage's outcome: the `elaborations` bucket collector with a
|
|
3
|
+
* parser that adds two body-derived facts beside the frontmatter, so the
|
|
4
|
+
* skill contract's `outputSchema` can refuse a section the stitch would
|
|
5
|
+
* mis-splice while the lane is still alive to fix it.
|
|
6
|
+
*/
|
|
7
|
+
import { readFileSync } from "node:fs";
|
|
8
|
+
import { isAbsolute, join } from "node:path";
|
|
9
|
+
import { defineParser, type Outcome, type ParseContext } from "@juicesharp/rpiv-workflow/registration";
|
|
10
|
+
import { frontmatterParser, rpivBucketOutcome } from "../artifact-collector.js";
|
|
11
|
+
import { countHeadingsOutsideFences, openFenceLine } from "./markdown-fence.js";
|
|
12
|
+
import { PLAN_PHASE_RE } from "./plan-phases.js";
|
|
13
|
+
|
|
14
|
+
interface ElaborationStructure {
|
|
15
|
+
/** `"balanced"`, or the diagnosis the contract's enum failure surfaces verbatim. */
|
|
16
|
+
fence_walk: string;
|
|
17
|
+
/** `## Phase N:` headings outside fences — the splice anchor count, contractually 1. */
|
|
18
|
+
phase_headings: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Structural facts of one elaboration body under the shared fence walk. */
|
|
22
|
+
const elaborationStructure = (content: string): ElaborationStructure => {
|
|
23
|
+
const open = openFenceLine(content);
|
|
24
|
+
return {
|
|
25
|
+
fence_walk:
|
|
26
|
+
open === undefined
|
|
27
|
+
? "balanced"
|
|
28
|
+
: `open from line ${open} — a bare \`\`\` inside a \`\`\` block closes it; open and close the outer block with four backticks (\`\`\`\`)`,
|
|
29
|
+
phase_headings: countHeadingsOutsideFences(content, PLAN_PHASE_RE),
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/** Frontmatter plus the derived structure; derived keys win over authored ones. */
|
|
34
|
+
const elaborationParser = defineParser<undefined, "artifact-md", Record<string, unknown>>({
|
|
35
|
+
async parse(ctx: ParseContext<undefined>) {
|
|
36
|
+
const base = await frontmatterParser.parse(ctx);
|
|
37
|
+
const primary = ctx.artifacts[0];
|
|
38
|
+
if (base.kind !== "ok" || primary?.handle.kind !== "fs") return base;
|
|
39
|
+
const path = primary.handle.path;
|
|
40
|
+
const content = readFileSync(isAbsolute(path) ? path : join(ctx.cwd, path), "utf-8");
|
|
41
|
+
return {
|
|
42
|
+
kind: "ok",
|
|
43
|
+
payload: { kind: "artifact-md", data: { ...base.payload.data, ...elaborationStructure(content) } },
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const elaborationOutcome: Outcome<unknown, "artifact-md", Record<string, unknown>> = {
|
|
49
|
+
...rpivBucketOutcome("elaborations"),
|
|
50
|
+
parser: elaborationParser,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export { type ElaborationStructure, elaborationOutcome, elaborationParser, elaborationStructure };
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* per-gate pass predicates. Pure state-reading folds — no fs I/O, no LLM.
|
|
5
5
|
*/
|
|
6
6
|
import { basename } from "node:path";
|
|
7
|
-
import { handleToString, type Output, type RunView } from "@juicesharp/rpiv-workflow/registration";
|
|
7
|
+
import { handleToString, type Output, type ProgressValue, type RunView } from "@juicesharp/rpiv-workflow/registration";
|
|
8
8
|
import { FILE_LINE_CITATION_RE, latestFsArtifact } from "./shared.js";
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -122,6 +122,8 @@ const gateTier = (state: RunView, verdictChannel: string): GateTier => {
|
|
|
122
122
|
const v = o.data as { severity?: unknown; findings?: unknown } | undefined;
|
|
123
123
|
const s = v?.severity;
|
|
124
124
|
// Anchor-nit clamp: an all-drift-nit verdict must not escalate the tier.
|
|
125
|
+
// Deliberately NOT `verdictBlocks` — this fold arbitrates severity VALUES,
|
|
126
|
+
// not blocking; the clamp lowers the recorded value only.
|
|
125
127
|
if (typeof s === "string") severities.add(anchorNitsOnly(v) ? "low" : s);
|
|
126
128
|
}
|
|
127
129
|
if (
|
|
@@ -225,6 +227,32 @@ const anchorNitsOnly = (v: { findings?: unknown } | undefined): boolean => {
|
|
|
225
227
|
);
|
|
226
228
|
};
|
|
227
229
|
|
|
230
|
+
/**
|
|
231
|
+
* The shared verdict shape every blocking fold reads: `pass` (the grader's
|
|
232
|
+
* free-judgment boolean), `severity` (the graded bar — `low`/`none` never
|
|
233
|
+
* block), and `findings` (the anchor-nit clamp's input). Consumers narrow
|
|
234
|
+
* further at their own cast (`allDimensionsPass` also reads `dimension`), so
|
|
235
|
+
* the dead-unit sentinel shape — a dimension label with none of these
|
|
236
|
+
* fields — still satisfies it.
|
|
237
|
+
*/
|
|
238
|
+
type VerdictRecord = { pass?: boolean; severity?: string; findings?: unknown };
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* The ONE blocking predicate over a grade verdict's own fields: a verdict
|
|
242
|
+
* blocks UNLESS its `pass` is `true`, its severity sits at the `low`/`none`
|
|
243
|
+
* floor, or the anchor-nit clamp applies (every finding a drift nit).
|
|
244
|
+
* `dimensionsToRegrade`, `allDimensionsPass`, `confirmDue`, and ship's
|
|
245
|
+
* `shipGradeStopNote` all fold through this single definition, so the
|
|
246
|
+
* re-grade list, the gate folds, the confirm arm, and the stop note can
|
|
247
|
+
* never drift apart (each site used to hand-roll the same disjunction).
|
|
248
|
+
* Deliberately RISK-BLIND: `risk_rulings` compose ON TOP only where owed
|
|
249
|
+
* (`confirmDue`), never folded in here. A record with none of the three
|
|
250
|
+
* exits — a dimension-bearing sentinel, an older bare trail — reads
|
|
251
|
+
* BLOCKING: fail-safe, same direction as a failed verdict.
|
|
252
|
+
*/
|
|
253
|
+
const verdictBlocks = (v: VerdictRecord | undefined): boolean =>
|
|
254
|
+
!(v?.pass === true || v?.severity === "low" || v?.severity === "none" || anchorNitsOnly(v));
|
|
255
|
+
|
|
228
256
|
/**
|
|
229
257
|
* The subset of `dimensions` a re-grade must actually re-run, given the latest
|
|
230
258
|
* verdict per dimension accumulated so far. A dimension needs re-grading when it
|
|
@@ -246,9 +274,8 @@ const dimensionsToRegrade = (
|
|
|
246
274
|
return dimensions.filter((d) => {
|
|
247
275
|
const o = latest.get(d);
|
|
248
276
|
if (!o) return true; // never graded — must grade at least once
|
|
249
|
-
const v = o.data as
|
|
250
|
-
|
|
251
|
-
if (!dimPass) return true;
|
|
277
|
+
const v = o.data as VerdictRecord | undefined;
|
|
278
|
+
if (verdictBlocks(v)) return true;
|
|
252
279
|
return verdictRiskRulings(o).some((r) => !rulingEffectivePass(r, risks.get(r.id)));
|
|
253
280
|
});
|
|
254
281
|
};
|
|
@@ -267,6 +294,22 @@ const dimensionsToRegrade = (
|
|
|
267
294
|
* fail for `medium`+ findings (the deterministic `slice-check` check emits
|
|
268
295
|
* `high` on a real structural break, so it still blocks). A verdict with no
|
|
269
296
|
* `severity` (an older or replayed grade) falls back to the raw `pass` boolean.
|
|
297
|
+
*
|
|
298
|
+
* SENTINELS: a failed-unit sentinel the fanout fold placed carries
|
|
299
|
+
* `data.dimension` when the dead unit was labeled (grade panels label each
|
|
300
|
+
* dimension unit with the dimension it grades). Such an entry registers here
|
|
301
|
+
* with no `pass`/`severity` — it reads BLOCKING. That is the fix for the
|
|
302
|
+
* three intentional behaviors that composed into the dead-unit gate pass:
|
|
303
|
+
* (1) a collected soft-halt is a PERMANENT skip — the dead unit contributes
|
|
304
|
+
* no verdict, only its sentinel; (2) the fold places the sentinel BY INDEX,
|
|
305
|
+
* overwriting whatever the slot held from prior rounds — the stale round-1
|
|
306
|
+
* fail the gate should have blocked on was erased from the channel;
|
|
307
|
+
* (3) a sentinel with NO dimension is skipped by this fold — absence is not
|
|
308
|
+
* failure — so the gate folded only the four surviving passes and routed
|
|
309
|
+
* onward. The dimension field closes all three: the unresolved dimension now
|
|
310
|
+
* reads as its own latest, blocking entry. (Mirror: an UNFILLED slot — infra
|
|
311
|
+
* death, no row — leaves the stale entry in place and also blocks;
|
|
312
|
+
* `unitFailedDimensions` distinguishes the dead-unit shape for routing.)
|
|
270
313
|
*/
|
|
271
314
|
const allDimensionsPass = (entries: readonly Output[] = [], roster?: readonly string[]): boolean => {
|
|
272
315
|
// Roster-filtered when given: a verdict for a dimension outside the tier's
|
|
@@ -278,15 +321,144 @@ const allDimensionsPass = (entries: readonly Output[] = [], roster?: readonly st
|
|
|
278
321
|
const v = o.data as { dimension?: string; pass?: boolean; severity?: string; findings?: unknown } | undefined;
|
|
279
322
|
if (typeof v?.dimension !== "string") continue;
|
|
280
323
|
if (member && !member.has(v.dimension)) continue;
|
|
281
|
-
// The
|
|
282
|
-
//
|
|
283
|
-
|
|
284
|
-
|
|
324
|
+
// The shared blocking predicate keeps every severity fold on one
|
|
325
|
+
// definition of "blocking" (the anchor-nit clamp backstops the
|
|
326
|
+
// citation-resolution rule: an all-drift-nit verdict never blocks,
|
|
327
|
+
// whatever severity the grader typed).
|
|
328
|
+
latest.set(v.dimension, !verdictBlocks(v));
|
|
285
329
|
}
|
|
286
330
|
const verdicts = [...latest.values()];
|
|
287
331
|
return verdicts.length > 0 && verdicts.every(Boolean);
|
|
288
332
|
};
|
|
289
333
|
|
|
334
|
+
/**
|
|
335
|
+
* The rule core under every whole-lap progress declaration: map the
|
|
336
|
+
* blocking-dimension counts of the COMPLETED rounds behind the current one
|
|
337
|
+
* (oldest first) plus the current round's own count to ONE ProgressValue.
|
|
338
|
+
*
|
|
339
|
+
* [] ⇒ "unknown" — nothing completed behind the current
|
|
340
|
+
* round (the first lap): counted, never
|
|
341
|
+
* waived.
|
|
342
|
+
* < min(earlier) ⇒ "improved" — the blocking set strictly shrank past
|
|
343
|
+
* EVERY earlier round's best; no score
|
|
344
|
+
* tiebreak — the count is the whole signal.
|
|
345
|
+
* > last(earlier) ⇒ "regressed" — grew past the immediately previous round.
|
|
346
|
+
* otherwise ⇒ "unchanged" — flat or between: counted.
|
|
347
|
+
*
|
|
348
|
+
* Deliberately coarse: the waiver buys one extra lap only when the panel's
|
|
349
|
+
* blocking set strictly shrank past every completed round, so flat, flapping,
|
|
350
|
+
* or partially-improving trails keep counting toward the backward-jump cap.
|
|
351
|
+
* Pure arithmetic over counts — no state, no channel reads — so the lane
|
|
352
|
+
* instances and the replay harnesses share one definition of "a lap
|
|
353
|
+
* improved".
|
|
354
|
+
*/
|
|
355
|
+
const progressFromRoundCounts = (earlier: readonly number[], current: number): ProgressValue => {
|
|
356
|
+
if (earlier.length === 0) return "unknown";
|
|
357
|
+
if (current < Math.min(...earlier)) return "improved";
|
|
358
|
+
if (current > earlier[earlier.length - 1]) return "regressed";
|
|
359
|
+
return "unchanged";
|
|
360
|
+
};
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* The whole-lap progress hook factory — the `progress` the quality-panel lanes
|
|
364
|
+
* declare on EVERY stage the backward-jump guard can re-enter (grade /
|
|
365
|
+
* fix-or-confirm / snapshot per lane). One instance per lane, shared by the
|
|
366
|
+
* lane's re-entered destinations, so a lap reads as ONE unit: the hook derives
|
|
367
|
+
* a round's blocking count by folding the lane's OWN verdict channel exactly
|
|
368
|
+
* the way its gate does — latest verdict per dimension over the entries still
|
|
369
|
+
* fresh for the current artifact — and counts blocking dimensions through the
|
|
370
|
+
* shared `verdictBlocks` predicate over the tier roster (`gateRoster(gateTier(
|
|
371
|
+
* state, verdictChannel), dimensions)`, computed once per call and applied to
|
|
372
|
+
* every round uniformly).
|
|
373
|
+
*
|
|
374
|
+
* ROUND DELINEATION — two modes:
|
|
375
|
+
*
|
|
376
|
+
* snapshot mode (`options.snapshotChannel` set — the plan/code lanes, whose
|
|
377
|
+
* fixes AMEND the plan in place so the artifact basename never changes):
|
|
378
|
+
* rounds are cut at each snapshot row's `meta.ts` (ISO-8601 compares
|
|
379
|
+
* lexicographically); a cut is a COMPLETED earlier round iff the verdict
|
|
380
|
+
* channel grew strictly past it — the last cut with nothing after it is the
|
|
381
|
+
* CURRENT round, excluded from the earlier set. The current round folds the
|
|
382
|
+
* WHOLE channel (carry-forward: a dimension not re-graded keeps its latest
|
|
383
|
+
* prior verdict — the same cumulative fold the gate itself reads).
|
|
384
|
+
*
|
|
385
|
+
* basename mode (no snapshotChannel — the slice lane, whose fixes RE-SLICE
|
|
386
|
+
* to a new file): rounds are maximal runs of entries sharing
|
|
387
|
+
* `basename(data.artifact)`; earlier = every group but the last, current =
|
|
388
|
+
* the last group's fold. A regenerated artifact re-grades from scratch, so a
|
|
389
|
+
* healthy basename group carries the full roster; an in-place amend keeps
|
|
390
|
+
* the basename, so amended rounds merge — degradation is toward counting,
|
|
391
|
+
* never toward a spurious waiver.
|
|
392
|
+
*
|
|
393
|
+
* FAIL-SAFE: a roster dimension with NO verdict in the current round's fold ⇒
|
|
394
|
+
* "unknown" (the round is incomplete — never waive on missing evidence); an
|
|
395
|
+
* entry without a string `meta.ts` lands in every earlier snapshot cut and in
|
|
396
|
+
* the current fold, so a malformed trail degrades toward counting. Pure
|
|
397
|
+
* channel history — no module state, no file reads, no model calls — so the
|
|
398
|
+
* hook is resume-safe by construction (the resume fold replays the same
|
|
399
|
+
* channels into `state.named`).
|
|
400
|
+
*/
|
|
401
|
+
const panelProgress =
|
|
402
|
+
(
|
|
403
|
+
verdictChannel: string,
|
|
404
|
+
dimensions: readonly string[],
|
|
405
|
+
{ snapshotChannel, artifactChannel }: { snapshotChannel?: string; artifactChannel?: string } = {},
|
|
406
|
+
) =>
|
|
407
|
+
(state: RunView): ProgressValue => {
|
|
408
|
+
const roster = gateRoster(gateTier(state, verdictChannel), dimensions);
|
|
409
|
+
const entries = state.named[verdictChannel] ?? [];
|
|
410
|
+
const currentArtifact = artifactChannel !== undefined ? latestArtifactPath(state, artifactChannel) : undefined;
|
|
411
|
+
const foldRound = (rows: readonly Output[]): ReadonlyMap<string, Output> =>
|
|
412
|
+
latestVerdictPerDimension(freshVerdicts(rows, currentArtifact));
|
|
413
|
+
const countBlocking = (fold: ReadonlyMap<string, Output>): number => {
|
|
414
|
+
let blocking = 0;
|
|
415
|
+
for (const d of roster) {
|
|
416
|
+
const o = fold.get(d);
|
|
417
|
+
if (o !== undefined && verdictBlocks(o.data as VerdictRecord)) blocking += 1;
|
|
418
|
+
}
|
|
419
|
+
return blocking;
|
|
420
|
+
};
|
|
421
|
+
// An entry with no string ts reads as "" — it joins every earlier snapshot
|
|
422
|
+
// cut (never after one), so a malformed trail can only INFLATE earlier
|
|
423
|
+
// counts: toward counting, never toward a waiver.
|
|
424
|
+
const tsOf = (o: Output): string => {
|
|
425
|
+
const ts = o.meta?.ts;
|
|
426
|
+
return typeof ts === "string" ? ts : "";
|
|
427
|
+
};
|
|
428
|
+
const earlierCounts: number[] = [];
|
|
429
|
+
let currentRows: readonly Output[] = [];
|
|
430
|
+
if (snapshotChannel !== undefined) {
|
|
431
|
+
for (const snap of state.named[snapshotChannel] ?? []) {
|
|
432
|
+
const cut = snap.meta?.ts;
|
|
433
|
+
if (typeof cut !== "string") continue;
|
|
434
|
+
// A cut the channel never grew strictly past is the CURRENT round,
|
|
435
|
+
// not a completed earlier one.
|
|
436
|
+
if (!entries.some((o) => tsOf(o) > cut)) continue;
|
|
437
|
+
earlierCounts.push(countBlocking(foldRound(entries.filter((o) => tsOf(o) <= cut))));
|
|
438
|
+
}
|
|
439
|
+
currentRows = entries;
|
|
440
|
+
} else {
|
|
441
|
+
const groups: { key: string | undefined; rows: Output[] }[] = [];
|
|
442
|
+
for (const o of entries) {
|
|
443
|
+
const a = (o.data as { artifact?: unknown } | undefined)?.artifact;
|
|
444
|
+
const key = typeof a === "string" && a.length > 0 ? basename(a) : undefined;
|
|
445
|
+
const last = groups.at(-1);
|
|
446
|
+
// An entry with no artifact continues the current group — the same
|
|
447
|
+
// compat default freshVerdicts applies; merging rounds degrades
|
|
448
|
+
// toward counting.
|
|
449
|
+
if (last !== undefined && (key === undefined || last.key === key)) last.rows.push(o);
|
|
450
|
+
else groups.push({ key, rows: [o] });
|
|
451
|
+
}
|
|
452
|
+
for (const g of groups.slice(0, -1)) earlierCounts.push(countBlocking(foldRound(g.rows)));
|
|
453
|
+
currentRows = groups.at(-1)?.rows ?? [];
|
|
454
|
+
}
|
|
455
|
+
const currentFold = foldRound(currentRows);
|
|
456
|
+
// An incomplete current round is "unknown" — the roster must be fully
|
|
457
|
+
// adjudicated before the lap can claim progress.
|
|
458
|
+
for (const d of roster) if (!currentFold.has(d)) return "unknown";
|
|
459
|
+
return progressFromRoundCounts(earlierCounts, countBlocking(currentFold));
|
|
460
|
+
};
|
|
461
|
+
|
|
290
462
|
/**
|
|
291
463
|
* One plan-authored risk flag ruled by a grade panel. The plan declares a
|
|
292
464
|
* `risks:` frontmatter array (`{ id, claim }`) — the structured, first-class
|
|
@@ -506,6 +678,74 @@ const sliceGatePasses = (state: RunView): boolean => {
|
|
|
506
678
|
if (!allDimensionsPass(state.named["slice-check"])) return false;
|
|
507
679
|
return allDimensionsPass(fresh, roster) || citeDischargeCoversCurrentMap(state);
|
|
508
680
|
};
|
|
681
|
+
|
|
682
|
+
/**
|
|
683
|
+
* The verdict fields the seed-only cite classification consults — the ONE
|
|
684
|
+
* spelling shared by the route predicate (`seedOnlyCiteFail`), the discharge
|
|
685
|
+
* stamp (`citeRemedyDischarged`), and the seed-lift stage, so all three agree
|
|
686
|
+
* on what a "seed-only cite fail" is. `where` rides the findings for the
|
|
687
|
+
* lift stage's slice-target parse; the classification itself reads only
|
|
688
|
+
* `requires`.
|
|
689
|
+
*/
|
|
690
|
+
type SeedOnlyVerdict = {
|
|
691
|
+
pass?: boolean;
|
|
692
|
+
remedy?: string;
|
|
693
|
+
findings?: readonly { requires?: unknown; where?: unknown }[];
|
|
694
|
+
};
|
|
695
|
+
|
|
696
|
+
/**
|
|
697
|
+
* A verdict is a SEED-ONLY cite fail when it failed, its `remedy` is `"cite"`
|
|
698
|
+
* or absent (an omitted marker must not divert a pure-bookkeeping fail into
|
|
699
|
+
* the structural re-cut arm), it carries at least one finding, and EVERY
|
|
700
|
+
* finding demands a concrete string `requires` seed. A finding without a
|
|
701
|
+
* `requires` is unverifiable — a verdict mixing one in is a structural
|
|
702
|
+
* demand and takes the normal fix arm, exactly as a `remedy` naming another
|
|
703
|
+
* repair would.
|
|
704
|
+
*/
|
|
705
|
+
const seedOnlyFindings = (v: SeedOnlyVerdict | undefined): boolean => {
|
|
706
|
+
if (v?.pass !== false) return false;
|
|
707
|
+
if (v.remedy !== undefined && v.remedy !== "cite") return false;
|
|
708
|
+
const findings = Array.isArray(v.findings) ? v.findings : [];
|
|
709
|
+
return (
|
|
710
|
+
findings.length > 0 && findings.every((f) => f != null && typeof f.requires === "string" && f.requires.length > 0)
|
|
711
|
+
);
|
|
712
|
+
};
|
|
713
|
+
|
|
714
|
+
/**
|
|
715
|
+
* The seed-only classification over the run state: the LATEST
|
|
716
|
+
* `design-readiness` verdict (via `latestVerdictPerDimension` — deliberately
|
|
717
|
+
* the same consultation `citeRemedyDischarged` makes, not a fresh-verdict
|
|
718
|
+
* filter) is a seed-only cite fail. The `slice-grade` edge consults this to
|
|
719
|
+
* route the deterministic seed lift instead of the structural fix arm.
|
|
720
|
+
*/
|
|
721
|
+
const seedOnlyCiteFail = (state: RunView): boolean =>
|
|
722
|
+
seedOnlyFindings(
|
|
723
|
+
latestVerdictPerDimension(state.named["slice-verdicts"]).get("design-readiness")?.data as
|
|
724
|
+
| SeedOnlyVerdict
|
|
725
|
+
| undefined,
|
|
726
|
+
);
|
|
727
|
+
|
|
728
|
+
/**
|
|
729
|
+
* Stuck detection for the seed-lift loop: the gate still fails, the verdict is
|
|
730
|
+
* seed-only, and the LATEST post-verdict fix publication is the seed lift
|
|
731
|
+
* itself — no later re-slice has superseded it. A lift that already ran and
|
|
732
|
+
* still left the gate red cannot be helped by re-grading (the verdict is
|
|
733
|
+
* unchanged) or re-lifting (the dedup makes the second lift a no-op), so the
|
|
734
|
+
* `slice-check` edge routes the structural fix arm instead of another panel.
|
|
735
|
+
* Timestamps are the channel-tail `meta.ts` comparison (ISO-8601 compares
|
|
736
|
+
* lexicographically); a missing timestamp reads not-stuck — the fail-closed
|
|
737
|
+
* direction here is the ordinary re-grade, never a stuck loop.
|
|
738
|
+
*/
|
|
739
|
+
const seedLiftStuck = (state: RunView): boolean => {
|
|
740
|
+
if (sliceGatePasses(state)) return false;
|
|
741
|
+
if (!seedOnlyCiteFail(state)) return false;
|
|
742
|
+
const verdictTs = latestVerdictPerDimension(state.named["slice-verdicts"]).get("design-readiness")?.meta?.ts;
|
|
743
|
+
const liftTs = state.named["slice-seed-lift"]?.at(-1)?.meta?.ts;
|
|
744
|
+
const resliceTs = state.named.slices?.at(-1)?.meta?.ts;
|
|
745
|
+
if (typeof verdictTs !== "string" || typeof liftTs !== "string" || liftTs <= verdictTs) return false;
|
|
746
|
+
return typeof resliceTs !== "string" || liftTs > resliceTs;
|
|
747
|
+
};
|
|
748
|
+
|
|
509
749
|
// The single authority the new `subplan-check` edge consults — the twin of
|
|
510
750
|
// `sliceGatePasses`, but carrying no LLM-verdict roster or risk flags: the
|
|
511
751
|
// `subplan-check` floor is the sole (deterministic) dimension on its channel.
|
|
@@ -593,11 +833,11 @@ const confirmDue = (
|
|
|
593
833
|
for (const o of fresh) {
|
|
594
834
|
const v = o.data as { dimension?: string; pass?: boolean; severity?: string; findings?: unknown } | undefined;
|
|
595
835
|
if (typeof v?.dimension !== "string" || !roster.has(v.dimension)) continue;
|
|
596
|
-
// anchorNitsOnly keeps this floor coherent with the other three
|
|
597
|
-
// severity-fold consumers (gateTier/dimensionsToRegrade/allDimensionsPass).
|
|
598
|
-
const floored = v.pass === true || v.severity === "low" || v.severity === "none" || anchorNitsOnly(v);
|
|
599
836
|
const riskFail = verdictRiskRulings(o).some((r) => !rulingEffectivePass(r, risks.get(r.id)));
|
|
600
|
-
|
|
837
|
+
// `verdictBlocks` keeps this fold coherent with the other severity-fold
|
|
838
|
+
// consumers (dimensionsToRegrade/allDimensionsPass/shipGradeStopNote);
|
|
839
|
+
// risk composes ON TOP — the predicate itself is risk-blind.
|
|
840
|
+
const blocking = verdictBlocks(v) || riskFail;
|
|
601
841
|
const prev = byDim.get(v.dimension);
|
|
602
842
|
byDim.set(v.dimension, {
|
|
603
843
|
blocking, // the latest verdict decides whether the dimension currently blocks
|
|
@@ -610,6 +850,28 @@ const confirmDue = (
|
|
|
610
850
|
);
|
|
611
851
|
};
|
|
612
852
|
|
|
853
|
+
/**
|
|
854
|
+
* Roster dimensions whose latest FRESH verdict entry is a failed sentinel —
|
|
855
|
+
* the dead-unit routing signal. A dimension-bearing sentinel means the unit
|
|
856
|
+
* grading that dimension soft-halted (after its re-dispatch, when the panel
|
|
857
|
+
* wires one) and left "unresolved" as the dimension's channel state; route
|
|
858
|
+
* bodies convert it into the fix arm with a unit-failed note instead of
|
|
859
|
+
* letting the fold's absence-is-not-failure default — or a confirm divert —
|
|
860
|
+
* decide. Pure state reads — resume-safe for `readsData: false` routes. A
|
|
861
|
+
* sentinel survives `freshVerdicts` (no `artifact` field — the compat
|
|
862
|
+
* default), so regenerating the artifact cannot launder a dead unit.
|
|
863
|
+
*/
|
|
864
|
+
export const unitFailedDimensions = (
|
|
865
|
+
state: RunView,
|
|
866
|
+
channel: string,
|
|
867
|
+
verdictChannel: string,
|
|
868
|
+
dimensions: readonly string[],
|
|
869
|
+
): string[] => {
|
|
870
|
+
const fresh = freshVerdicts(state.named[verdictChannel], latestArtifactPath(state, channel));
|
|
871
|
+
const latest = latestVerdictPerDimension(fresh);
|
|
872
|
+
return dimensions.filter((d) => latest.get(d)?.kind === "failed");
|
|
873
|
+
};
|
|
874
|
+
|
|
613
875
|
export {
|
|
614
876
|
allDimensionsPass,
|
|
615
877
|
anchorNitsOnly,
|
|
@@ -624,13 +886,21 @@ export {
|
|
|
624
886
|
latestArtifactPath,
|
|
625
887
|
latestVerdictPerDimension,
|
|
626
888
|
PLAN_DIMENSIONS,
|
|
889
|
+
panelProgress,
|
|
627
890
|
planAuthoredRisks,
|
|
628
891
|
planGatePasses,
|
|
629
892
|
procedureSatisfiesDuty,
|
|
893
|
+
progressFromRoundCounts,
|
|
630
894
|
type RiskRecord,
|
|
631
895
|
rulingEffectivePass,
|
|
896
|
+
type SeedOnlyVerdict,
|
|
632
897
|
SLICE_DIMENSIONS,
|
|
898
|
+
seedLiftStuck,
|
|
899
|
+
seedOnlyCiteFail,
|
|
900
|
+
seedOnlyFindings,
|
|
633
901
|
sliceGatePasses,
|
|
634
902
|
subplanGatePasses,
|
|
903
|
+
type VerdictRecord,
|
|
904
|
+
verdictBlocks,
|
|
635
905
|
verdictRiskRulings,
|
|
636
906
|
};
|
|
@@ -2,13 +2,7 @@
|
|
|
2
2
|
* The grade panels: the shared tiered panel factory, its build-lane instances,
|
|
3
3
|
* and ship's bespoke tier-independent panel and verdict channel.
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
6
|
-
directoryPathCollector,
|
|
7
|
-
fanout,
|
|
8
|
-
handleToString,
|
|
9
|
-
jsonBodyParser,
|
|
10
|
-
type RunView,
|
|
11
|
-
} from "@juicesharp/rpiv-workflow/registration";
|
|
5
|
+
import { fanout, handleToString, type RunView } from "@juicesharp/rpiv-workflow/registration";
|
|
12
6
|
import {
|
|
13
7
|
dimensionsToRegrade,
|
|
14
8
|
freshVerdicts,
|
|
@@ -17,12 +11,14 @@ import {
|
|
|
17
11
|
gateTier,
|
|
18
12
|
latestVerdictPerDimension,
|
|
19
13
|
PLAN_DIMENSIONS,
|
|
14
|
+
panelProgress,
|
|
20
15
|
planAuthoredRisks,
|
|
21
16
|
SHIP_DIMENSIONS,
|
|
22
17
|
SLICE_DIMENSIONS,
|
|
23
18
|
} from "./gates.js";
|
|
24
19
|
import { isSurgicalFix, priorArtifact } from "./priors.js";
|
|
25
|
-
import { latestFsArtifact } from "./shared.js";
|
|
20
|
+
import { haltPreflight, latestFsArtifact } from "./shared.js";
|
|
21
|
+
import { verdictOutcome } from "./verdict-outcome.js";
|
|
26
22
|
|
|
27
23
|
/**
|
|
28
24
|
* The dimension-scoped artifact flags every panel body composes — ONE
|
|
@@ -54,13 +50,24 @@ const dimensionArtifactFlags = (state: RunView): { contextFlag: string; goalFlag
|
|
|
54
50
|
* duplicates (the single most expensive part of the most expensive dimension)
|
|
55
51
|
* and spend its spot-check budget on claim-vs-code semantics — the one thing
|
|
56
52
|
* the floor cannot judge. A findings-bearing verdict additionally carries the
|
|
57
|
-
* advisory leads the grader folds into its sample.
|
|
58
|
-
*
|
|
53
|
+
* advisory leads the grader folds into its sample. Required, never degraded:
|
|
54
|
+
* a panel configured over a cite channel whose channel carries no fs verdict
|
|
55
|
+
* throws the halt preflight — the built-in graphs run the floor before every
|
|
56
|
+
* panel dispatch, so an absent verdict is an integrity break. A panel with no
|
|
57
|
+
* `citeChannel` (the slice gate, a user workflow without a floor) composes no
|
|
58
|
+
* flag.
|
|
59
59
|
*/
|
|
60
60
|
const citeCheckFlag = (state: RunView, citeChannel: string | undefined): string => {
|
|
61
61
|
if (citeChannel === undefined) return "";
|
|
62
62
|
const doc = latestFsArtifact(state, citeChannel);
|
|
63
|
-
|
|
63
|
+
if (doc?.handle.kind !== "fs") {
|
|
64
|
+
throw haltPreflight(
|
|
65
|
+
"grade",
|
|
66
|
+
"grade: no citation-floor verdict to thread as --cite-check",
|
|
67
|
+
`grade: the '${citeChannel}' channel carries no fs verdict — the deterministic citation floor must run before the correctness unit dispatches (a panel configured over a cite channel requires it)`,
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
return ` --cite-check ${handleToString(doc.handle)}`;
|
|
64
71
|
};
|
|
65
72
|
|
|
66
73
|
/**
|
|
@@ -90,14 +97,11 @@ const citeCheckFlag = (state: RunView, citeChannel: string | undefined): string
|
|
|
90
97
|
* (and the slice gate's `design-readiness`, which never grades fit or
|
|
91
98
|
* goal-completeness) gets the bare flags.
|
|
92
99
|
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
* adjudicate the prior
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
* the latest-per-dimension fold). Only PENDING dimensions get the flag: in the
|
|
99
|
-
* degenerate full-roster fallback a carried passing verdict has nothing to
|
|
100
|
-
* adjudicate, and a first grade has no prior at all.
|
|
100
|
+
* `--prior` threads a dimension's latest fresh verdict when that dimension is
|
|
101
|
+
* still pending (a confirm or re-grade of a blocking prior — the grader must
|
|
102
|
+
* adjudicate the prior findings, not out-vote them) and always on correctness
|
|
103
|
+
* (its re-grades scope to the prior). A carried passing prior on any other
|
|
104
|
+
* dimension is not re-adjudicated. Round 1 emits no flag.
|
|
101
105
|
*
|
|
102
106
|
* Every panel wires `haltWhenAllFailed: true`: a generation in which EVERY
|
|
103
107
|
* dispatched dimension unit failed is a dead panel — nothing was collected, so
|
|
@@ -119,6 +123,7 @@ const gradePanelFanout = (
|
|
|
119
123
|
unit: { by: "dimension-list", pattern: "dimensions" },
|
|
120
124
|
max: dimensions.length,
|
|
121
125
|
haltWhenAllFailed: true,
|
|
126
|
+
retryHaltedUnits: 1,
|
|
122
127
|
units: ({ state, cwd }) => {
|
|
123
128
|
const doc = latestFsArtifact(state, channel);
|
|
124
129
|
if (doc?.handle.kind !== "fs") return [];
|
|
@@ -150,7 +155,7 @@ const gradePanelFanout = (
|
|
|
150
155
|
isSurgicalFix(state, priorChannel, cwd, target, latest, pending, risks);
|
|
151
156
|
const priorPresent = priorChannel !== undefined && priorArtifact(state, priorChannel) !== undefined;
|
|
152
157
|
const priorFlag = (d: string): string => {
|
|
153
|
-
if (
|
|
158
|
+
if (d !== "correctness" && !pending.includes(d)) return "";
|
|
154
159
|
const handle = latest.get(d)?.artifacts.find((a) => a.handle.kind === "fs")?.handle;
|
|
155
160
|
return handle ? ` --prior ${handleToString(handle)}` : "";
|
|
156
161
|
};
|
|
@@ -196,6 +201,22 @@ const CODE_CONFIRM_FANOUT = gradePanelFanout("plans", PLAN_DIMENSIONS, "code-ver
|
|
|
196
201
|
citeChannel: "code-cite-check",
|
|
197
202
|
});
|
|
198
203
|
|
|
204
|
+
// The three build lanes' whole-lap progress hooks — one instance per lane,
|
|
205
|
+
// declared on every stage the guard can re-enter (grade / fix-or-confirm /
|
|
206
|
+
// snapshot), beside the fanout twins that grade the same channels. The
|
|
207
|
+
// plan/code lanes amend the plan in place, so their rounds are cut at
|
|
208
|
+
// snapshot rows; the slice lane re-slices to a new file, so its rounds group
|
|
209
|
+
// by artifact basename (see panelProgress).
|
|
210
|
+
const SLICE_PANEL_PROGRESS = panelProgress("slice-verdicts", SLICE_DIMENSIONS);
|
|
211
|
+
const PLAN_PANEL_PROGRESS = panelProgress("plan-verdicts", PLAN_DIMENSIONS, {
|
|
212
|
+
snapshotChannel: "plan-snapshot",
|
|
213
|
+
artifactChannel: "plans",
|
|
214
|
+
});
|
|
215
|
+
const CODE_PANEL_PROGRESS = panelProgress("code-verdicts", PLAN_DIMENSIONS, {
|
|
216
|
+
snapshotChannel: "code-snapshot",
|
|
217
|
+
artifactChannel: "plans",
|
|
218
|
+
});
|
|
219
|
+
|
|
199
220
|
/**
|
|
200
221
|
* Ship's grade panel — a bespoke `fanout({...})` mirroring `gradePanelFanout`'s
|
|
201
222
|
* body but binding the roster to `SHIP_DIMENSIONS` DIRECTLY (no
|
|
@@ -225,6 +246,7 @@ export const SHIP_DIMENSION_FANOUT = fanout({
|
|
|
225
246
|
unit: { by: "dimension-list", pattern: "dimensions" },
|
|
226
247
|
max: SHIP_DIMENSIONS.length,
|
|
227
248
|
haltWhenAllFailed: true,
|
|
249
|
+
retryHaltedUnits: 1,
|
|
228
250
|
units: ({ state }) => {
|
|
229
251
|
const doc = latestFsArtifact(state, "plans");
|
|
230
252
|
if (doc?.handle.kind !== "fs") return [];
|
|
@@ -232,7 +254,8 @@ export const SHIP_DIMENSION_FANOUT = fanout({
|
|
|
232
254
|
// The shared flag-composition site — the twins compose it rather than
|
|
233
255
|
// mirroring it (dimension keying below stays ship's own).
|
|
234
256
|
const { contextFlag, goalFlag, acceptanceFlag } = dimensionArtifactFlags(state);
|
|
235
|
-
// The floor's verdict
|
|
257
|
+
// The floor's verdict is REQUIRED here — citeCheckFlag fails closed when
|
|
258
|
+
// the configured channel carries no fs verdict; a clean verdict settles
|
|
236
259
|
// resolution, findings carry the advisory leads (see citeCheckFlag).
|
|
237
260
|
const citeFlag = citeCheckFlag(state, "plan-cite-check");
|
|
238
261
|
// Tier-independent roster: SHIP_DIMENSIONS verbatim — never gateRoster(gateTier(...)).
|
|
@@ -249,20 +272,25 @@ export const SHIP_DIMENSION_FANOUT = fanout({
|
|
|
249
272
|
},
|
|
250
273
|
});
|
|
251
274
|
|
|
275
|
+
// Ship's whole-lap hook — INERT by topology (the grade gate routes implement
|
|
276
|
+
// or stop, so no edge ever re-enters the grade stage), declared for uniformity
|
|
277
|
+
// so every panel lane names its hook beside its panel.
|
|
278
|
+
const SHIP_PANEL_PROGRESS = panelProgress("ship-verdicts", SHIP_DIMENSIONS);
|
|
279
|
+
|
|
252
280
|
// Ship's grade panel writes its verdicts to a DISTINCT channel (same
|
|
253
281
|
// directory, different artifact basenames) so they never mix with build's
|
|
254
282
|
// plan/code verdicts — named for the workflow, completing the slice-verdicts
|
|
255
283
|
// / plan-verdicts / code-verdicts / ship-verdicts parallel.
|
|
256
|
-
export const shipVerdictOutcome =
|
|
257
|
-
name: "ship-verdicts",
|
|
258
|
-
collector: directoryPathCollector({ dir: ".rpiv/artifacts/verdicts", ext: "json" }),
|
|
259
|
-
parser: jsonBodyParser,
|
|
260
|
-
};
|
|
284
|
+
export const shipVerdictOutcome = verdictOutcome("ship-verdicts", "plans");
|
|
261
285
|
|
|
262
286
|
export {
|
|
263
287
|
CODE_CONFIRM_FANOUT,
|
|
264
288
|
CODE_DIMENSION_FANOUT,
|
|
289
|
+
CODE_PANEL_PROGRESS,
|
|
265
290
|
PLAN_CONFIRM_FANOUT,
|
|
266
291
|
PLAN_DIMENSION_FANOUT,
|
|
292
|
+
PLAN_PANEL_PROGRESS,
|
|
293
|
+
SHIP_PANEL_PROGRESS,
|
|
267
294
|
SLICE_DIMENSION_FANOUT,
|
|
295
|
+
SLICE_PANEL_PROGRESS,
|
|
268
296
|
};
|