@juicesharp/rpiv-pi 2.10.1 → 2.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.
@@ -70,11 +70,11 @@ import {
70
70
  planGatePasses,
71
71
  planSnapshot,
72
72
  REVIEW_PHASE_ITERATE,
73
+ RISK_DIMENSION,
73
74
  reconcile,
74
75
  remediationOutcome,
75
76
  rulingEffectivePass,
76
77
  SHIP_DIMENSION_FANOUT,
77
- SHIP_DIMENSIONS,
78
78
  SHIP_PANEL_PROGRESS,
79
79
  SLICE_DESIGN_FANOUT,
80
80
  SLICE_DIMENSION_FANOUT,
@@ -85,6 +85,7 @@ import {
85
85
  seedLiftStuck,
86
86
  seedOnlyCiteFail,
87
87
  shipGatePasses,
88
+ shipRoster,
88
89
  shipVerdictOutcome,
89
90
  sliceGatePasses,
90
91
  sliceSeedLift,
@@ -98,6 +99,7 @@ import {
98
99
  verdictOutcome,
99
100
  verdictRiskRulings,
100
101
  } from "./built-ins/index.js";
102
+ import { metaWorkflow } from "./meta/presets.js";
101
103
 
102
104
  // The code-review stage's output schema is no longer declared here — every
103
105
  // code-review stage sources it from the skill's contract `produces.data`
@@ -652,6 +654,16 @@ const sliceGradeRoute: EdgeFn = defineRoute(
652
654
  { readsData: false },
653
655
  );
654
656
 
657
+ /**
658
+ * Every unit a plan/code panel can dispatch — the tier roster's dimensions
659
+ * plus the risk unit `panelRoster` adds when the plan declares `risks:`. The
660
+ * dead-unit preemption filters on a failed sentinel per dimension, so naming
661
+ * the risk unit here is safe when it was never dispatched (no sentinel ⇒ not
662
+ * listed) and load-bearing when it was (a dead risk unit is a dead panel
663
+ * member, not a vacuous risk pass).
664
+ */
665
+ const PLAN_PANEL_UNITS: readonly string[] = [...PLAN_DIMENSIONS, RISK_DIMENSION];
666
+
655
667
  /** The plan gate's demote edge — the unit-failed preemption fires BEFORE the
656
668
  * confirm divert (a previously-passing dimension whose re-grade died is not
657
669
  * a flap to adjudicate; there is no verdict to adjudicate). */
@@ -659,7 +671,7 @@ const planDemoteRoute: EdgeFn = defineRoute(
659
671
  ["code", "plan-confirm", "plan-snapshot"],
660
672
  ({ state }) => {
661
673
  if (planGatePasses(state)) return "code";
662
- const unitFailed = unitFailedDimensions(state, "plans", "plan-verdicts", PLAN_DIMENSIONS);
674
+ const unitFailed = unitFailedDimensions(state, "plans", "plan-verdicts", PLAN_PANEL_UNITS);
663
675
  if (unitFailed.length > 0) {
664
676
  setRouteNote(planDemoteRoute, unitFailedNote(unitFailed));
665
677
  return "plan-snapshot";
@@ -674,7 +686,7 @@ const codeDemoteRoute: EdgeFn = defineRoute(
674
686
  ["implement", "code-confirm", "code-snapshot"],
675
687
  ({ state }) => {
676
688
  if (codeGatePasses(state)) return "implement";
677
- const unitFailed = unitFailedDimensions(state, "plans", "code-verdicts", PLAN_DIMENSIONS);
689
+ const unitFailed = unitFailedDimensions(state, "plans", "code-verdicts", PLAN_PANEL_UNITS);
678
690
  if (unitFailed.length > 0) {
679
691
  setRouteNote(codeDemoteRoute, unitFailedNote(unitFailed));
680
692
  return "code-snapshot";
@@ -687,7 +699,7 @@ const codeDemoteRoute: EdgeFn = defineRoute(
687
699
  const buildWorkflow = defineWorkflow({
688
700
  name: "build",
689
701
  description:
690
- "Ship, sliced: capture the verbatim brief as a goal artifact (the north star the quality gates' completeness/correctness dimensions and validate anchor against) → research the brief → derive a goal-anchored acceptance inventory (the executable standard of completion, frozen before any plan so it cannot inherit the plan's scope; the completeness gates anchor on it and validate executes its evidence commands) → decompose it into vertical slices → two-phase slice gate (a deterministic floor — dependency-cycle freedom + brief-coverage conservation so a slice-fix can't pass by dropping scope — then one LLM design-readiness judgment that each slice is chewable by a single design pass) with a slice-fix loop → design each slice in parallel → one consolidated developer checkpoint (accept or adjust the proposed interfaces/data types, adjustments applied surgically and cascaded to dependents) → synthesize hierarchically (per-cluster sub-plans → one merged plan) → tier-scaled quality-panel gate (a one-slice, <=2-phase run grades correctness+completeness only; larger or previously-failing runs grade the full completeness/correctness/actionability/pattern-following/architecture-fit roster) where a dimension's fresh HIGH-severity, risk-ruling, or regressed-pass blocking verdict gets one confirming second judgment before it buys a plan-fix round (a first-time medium finding routes straight to the surgical fix) → elaborate code per phase in parallel → splice it into the plan → re-grade the code-bearing plan (same tier + confirm contract) → implement → implement-scope-check → reconcile → validate → commit. Research-led; three automated gates plus one human design checkpoint, before design, before code, and after the splice.",
702
+ "Ship, sliced: capture the verbatim brief as a goal artifact (the north star the quality gates' completeness/correctness dimensions and validate anchor against) → research the brief → derive a goal-anchored acceptance inventory (the executable standard of completion, frozen before any plan so it cannot inherit the plan's scope; the completeness gates anchor on it and validate executes its evidence commands) → decompose it into vertical slices → two-phase slice gate (a deterministic floor — dependency-cycle freedom + brief-coverage conservation so a slice-fix can't pass by dropping scope — then one LLM design-readiness judgment that each slice is chewable by a single design pass) with a slice-fix loop → design each slice in parallel → one consolidated developer checkpoint (accept or adjust the proposed interfaces/data types, adjustments applied surgically and cascaded to dependents) → synthesize hierarchically (per-cluster sub-plans → one merged plan) → tier-scaled quality-panel gate (a one-slice, <=2-phase run grades correctness+completeness only; larger or previously-failing runs grade the full completeness/correctness/actionability/pattern-following/architecture-fit roster; a plan declaring risk flags adds a concurrent risk-rulings unit at every tier) where a dimension's fresh HIGH-severity, risk-ruling, or regressed-pass blocking verdict gets one confirming second judgment before it buys a plan-fix round (a first-time medium finding routes straight to the surgical fix) → elaborate code per phase in parallel → splice it into the plan → re-grade the code-bearing plan (same tier + confirm contract) → implement → implement-scope-check → reconcile → validate → commit. Research-led; three automated gates plus one human design checkpoint, before design, before code, and after the splice.",
691
703
  start: "goal",
692
704
  stages: {
693
705
  // The user's brief, verbatim, on its own channel — the judgment seams
@@ -785,8 +797,11 @@ const buildWorkflow = defineWorkflow({
785
797
  "subplan-check": produces.script({ reads: [fanin("subplans"), "slices"], run: subplanCoverageCheck }),
786
798
  // The root merge reads `research` (threaded as `--research` so cross-slice
787
799
  // constraints reach the merge directly, not only via each subplan's
788
- // refraction) alongside the cluster sub-plans it fans in.
789
- plan: produces({ skill: "synthesize", reads: ["research", fanin("subplans")] }),
800
+ // refraction) alongside the cluster sub-plans it fans in. `goal` +
801
+ // `acceptance` reach it too: synthesize disposes every inventory id in the
802
+ // plan's `acceptance:` block, the same anchors the completeness judge and
803
+ // validate read.
804
+ plan: produces({ skill: "synthesize", reads: ["research", "goal", "acceptance", fanin("subplans")] }),
790
805
  // Deterministic citation floor BEFORE the LLM plan gate (twin of `slice-check`):
791
806
  // a fabricated `file:line` in the plan fails structurally and routes to `plan-fix`.
792
807
  "plan-cite-check": produces.script({ reads: ["plans"], run: planCitationCheck("plan-cite-check") }),
@@ -831,7 +846,15 @@ const buildWorkflow = defineWorkflow({
831
846
  // mirrors `plan`'s own `reads: ["research", fanin("subplans")]`. `subplans`
832
847
  // is plan-fix-ONLY — by the code gate the plan's completeness is settled, so
833
848
  // code-fix repairs code-shape defects and threads no subplans.
834
- reads: ["plans", fanin("plan-verdicts"), fanin("plan-cite-check"), "goal", "research", fanin("subplans")],
849
+ reads: [
850
+ "plans",
851
+ fanin("plan-verdicts"),
852
+ fanin("plan-cite-check"),
853
+ "goal",
854
+ "acceptance",
855
+ "research",
856
+ fanin("subplans"),
857
+ ],
835
858
  }),
836
859
  // Snapshot the graded plan BEFORE plan-fix amends it — one deterministic
837
860
  // hop inside the existing fix loop (plan-grade/plan-confirm → plan-snapshot
@@ -1186,14 +1209,14 @@ const shipGradeStopNote = (state: RunView): string => {
1186
1209
  // A dead grade unit (post-re-dispatch) is the loudest blocker — name it
1187
1210
  // ahead of the severity blockers (ship's arm is stop + hand-repair +
1188
1211
  // resume, so the note IS the repair instruction).
1189
- const unitFailed = unitFailedDimensions(state, "plans", "ship-verdicts", SHIP_DIMENSIONS);
1212
+ const unitFailed = unitFailedDimensions(state, "plans", "ship-verdicts", shipRoster(state));
1190
1213
  if (unitFailed.length > 0) return unitFailedNote(unitFailed);
1191
1214
  const fresh = freshVerdicts(state.named["ship-verdicts"], latestArtifactPath(state, "plans"));
1192
1215
  if (fresh.length === 0) return "no fresh verdicts for the current plan";
1193
1216
  const risks = planAuthoredRisks(state, "plans");
1194
1217
  const latest = latestVerdictPerDimension(fresh);
1195
1218
  const blockers: string[] = [];
1196
- for (const d of SHIP_DIMENSIONS) {
1219
+ for (const d of shipRoster(state)) {
1197
1220
  const o = latest.get(d);
1198
1221
  if (!o) continue;
1199
1222
  const v = o.data as VerdictRecord | undefined;
@@ -1411,4 +1434,10 @@ export { SHIP_DIMENSION_FANOUT, SHIP_DIMENSIONS, shipGatePasses, shipVerdictOutc
1411
1434
  // Position 0 is load-bearing: `build` is the default `/wf` workflow when no
1412
1435
  // project/user config sets one (resolve-default.ts resolves
1413
1436
  // `Map.keys().next().value`), so it MUST stay first in this array.
1414
- export const builtInWorkflows: readonly Workflow[] = [buildWorkflow, vetWorkflow, polishWorkflow, shipWorkflow];
1437
+ export const builtInWorkflows: readonly Workflow[] = [
1438
+ buildWorkflow,
1439
+ vetWorkflow,
1440
+ polishWorkflow,
1441
+ shipWorkflow,
1442
+ metaWorkflow,
1443
+ ];
@@ -50,6 +50,27 @@ const PLAN_DIMENSIONS = [
50
50
  */
51
51
  export const SHIP_DIMENSIONS = ["completeness", "correctness", "architecture-fit"] as const;
52
52
 
53
+ /**
54
+ * The plan-authored risk-flag ruling unit, split OUT of `correctness` so the
55
+ * two judgments run as concurrent panel members instead of one serial judge.
56
+ * Across 175 build panels the correctness unit finished last in 140 (80%), at
57
+ * 2.2× the median sibling with no flags and no prior, and the risk-ruling +
58
+ * prior-adjudication duties added ~1.7 min on top (4.9 → 6.6 min p50) — the
59
+ * panel's wall time IS the correctness unit's. This dimension rules every
60
+ * `risks:` flag (the mechanics-evidence and verify-at-implement duties move
61
+ * with it, see the `grade` skill), adjudicates its OWN prior rulings on a
62
+ * re-grade, and emits `risk_rulings` — the field every risk fold reads
63
+ * (`allRiskFlagsPass`, `dimensionsToRegrade` clause 3, `confirmDue`,
64
+ * `demoteDuties`, amend's cite derivation). Correctness keeps only its
65
+ * semantic three-class findings. Dispatched ONLY when the graded channel's
66
+ * latest record declares `risks:` (`panelRoster`) — a plan with no flags
67
+ * pays for no unit — and at EVERY tier when it does (the light roster used to
68
+ * rule risks through its correctness member; the duty follows the split). A
69
+ * legacy trail whose correctness verdicts still carry `risk_rulings` folds
70
+ * unchanged: every risk fold is dimension-agnostic.
71
+ */
72
+ export const RISK_DIMENSION = "risk-rulings" as const;
73
+
53
74
  /**
54
75
  * The two dimensions the grade panels anchor against the verbatim brief.
55
76
  * "Complete" and "correct" MEAN "against what the user asked" — without the
@@ -156,6 +177,37 @@ const gateRoster = (tier: GateTier, dimensions: readonly string[]): readonly str
156
177
  return light.length > 0 ? light : dimensions;
157
178
  };
158
179
 
180
+ /**
181
+ * The roster a panel over `channel` actually dispatches and its gate actually
182
+ * folds: the tier roster (`gateRoster(gateTier(...))`) plus the
183
+ * `RISK_DIMENSION` unit whenever the channel's latest record declares
184
+ * `risks:` — at every tier, never otherwise. ONE construction site shared by
185
+ * the panel's `units()`, the gate predicates, `confirmDue`, and the progress
186
+ * hook, so "dispatch", "fold", "confirm", and "lap complete" can never
187
+ * disagree on whether the risk unit is a roster member. A roster that never
188
+ * declares risks (the slice gate over `slices`) is unchanged. Idempotent over
189
+ * a `dimensions` list that already names the risk dimension.
190
+ */
191
+ const panelRoster = (
192
+ state: RunView,
193
+ channel: string,
194
+ verdictChannel: string,
195
+ dimensions: readonly string[],
196
+ ): readonly string[] => {
197
+ const roster = gateRoster(gateTier(state, verdictChannel), dimensions);
198
+ if (roster.includes(RISK_DIMENSION) || planAuthoredRisks(state, channel).size === 0) return roster;
199
+ return [...roster, RISK_DIMENSION];
200
+ };
201
+
202
+ /**
203
+ * Ship's tier-independent twin of `panelRoster`: `SHIP_DIMENSIONS` verbatim
204
+ * (never `gateRoster(gateTier(...))`) plus the risk unit when the plan
205
+ * declares `risks:`. Bound by the ship panel, `shipGatePasses`, and ship's
206
+ * stop note alike.
207
+ */
208
+ const shipRoster = (state: RunView): readonly string[] =>
209
+ planAuthoredRisks(state, "plans").size === 0 ? SHIP_DIMENSIONS : [...SHIP_DIMENSIONS, RISK_DIMENSION];
210
+
159
211
  /**
160
212
  * Drop verdicts judged against an artifact the channel has since REPLACED. A
161
213
  * grade verdict embeds the `artifact` path it judged; when a fix REGENERATES
@@ -405,7 +457,14 @@ const panelProgress =
405
457
  { snapshotChannel, artifactChannel }: { snapshotChannel?: string; artifactChannel?: string } = {},
406
458
  ) =>
407
459
  (state: RunView): ProgressValue => {
408
- const roster = gateRoster(gateTier(state, verdictChannel), dimensions);
460
+ // The artifact channel is where `risks:` lives, so a lane that names it
461
+ // folds the risk unit into its roster exactly as its panel and gate do;
462
+ // a lane without one (no plan channel to declare risks on) keeps the
463
+ // tier roster.
464
+ const roster =
465
+ artifactChannel !== undefined
466
+ ? panelRoster(state, artifactChannel, verdictChannel, dimensions)
467
+ : gateRoster(gateTier(state, verdictChannel), dimensions);
409
468
  const entries = state.named[verdictChannel] ?? [];
410
469
  const currentArtifact = artifactChannel !== undefined ? latestArtifactPath(state, artifactChannel) : undefined;
411
470
  const foldRound = (rows: readonly Output[]): ReadonlyMap<string, Output> =>
@@ -752,7 +811,7 @@ const seedLiftStuck = (state: RunView): boolean => {
752
811
  const subplanGatePasses = (state: RunView): boolean => allDimensionsPass(state.named["subplan-check"]);
753
812
  const planGatePasses = (state: RunView): boolean => {
754
813
  const fresh = freshVerdicts(state.named["plan-verdicts"], latestArtifactPath(state, "plans"));
755
- const roster = gateRoster(gateTier(state, "plan-verdicts"), PLAN_DIMENSIONS);
814
+ const roster = panelRoster(state, "plans", "plan-verdicts", PLAN_DIMENSIONS);
756
815
  const risks = planAuthoredRisks(state, "plans");
757
816
  return (
758
817
  allDimensionsPass(state.named["plan-cite-check"]) &&
@@ -762,7 +821,7 @@ const planGatePasses = (state: RunView): boolean => {
762
821
  };
763
822
  const codeGatePasses = (state: RunView): boolean => {
764
823
  const fresh = freshVerdicts(state.named["code-verdicts"], latestArtifactPath(state, "plans"));
765
- const roster = gateRoster(gateTier(state, "code-verdicts"), PLAN_DIMENSIONS);
824
+ const roster = panelRoster(state, "plans", "code-verdicts", PLAN_DIMENSIONS);
766
825
  const risks = planAuthoredRisks(state, "plans");
767
826
  return (
768
827
  allDimensionsPass(state.named["code-cite-check"]) &&
@@ -777,13 +836,16 @@ const codeGatePasses = (state: RunView): boolean => {
777
836
  * (severity-floored) AND every plan-authored risk flag is ruled pass. Unlike
778
837
  * `planGatePasses`/`codeGatePasses` it folds NO deterministic cite channel —
779
838
  * ship's `plan-cite-check` gate is routed at its own edge — and binds the
780
- * roster to `SHIP_DIMENSIONS` verbatim (never `gateRoster(gateTier(...))`), so
781
- * the gate consults the same fixed set the panel graded.
839
+ * roster to `shipRoster` (`SHIP_DIMENSIONS` verbatim plus the risk unit when
840
+ * the plan declares `risks:` — never `gateRoster(gateTier(...))`), so the gate
841
+ * consults the same fixed set the panel graded, and a dead risk unit's
842
+ * dimension-bearing sentinel blocks instead of vanishing behind a vacuous
843
+ * `allRiskFlagsPass`.
782
844
  */
783
845
  export const shipGatePasses = (state: RunView): boolean => {
784
846
  const fresh = freshVerdicts(state.named["ship-verdicts"], latestArtifactPath(state, "plans"));
785
847
  const risks = planAuthoredRisks(state, "plans");
786
- return allDimensionsPass(fresh, SHIP_DIMENSIONS) && allRiskFlagsPass(fresh, risks);
848
+ return allDimensionsPass(fresh, shipRoster(state)) && allRiskFlagsPass(fresh, risks);
787
849
  };
788
850
 
789
851
  /**
@@ -826,7 +888,7 @@ const confirmDue = (
826
888
  verdictChannel: string,
827
889
  dimensions: readonly string[],
828
890
  ): boolean => {
829
- const roster = new Set(gateRoster(gateTier(state, verdictChannel), dimensions));
891
+ const roster = new Set(panelRoster(state, channel, verdictChannel, dimensions));
830
892
  const fresh = freshVerdicts(state.named[verdictChannel], latestArtifactPath(state, channel));
831
893
  const risks = planAuthoredRisks(state, channel);
832
894
  const byDim = new Map<string, { blocking: boolean; confirmWorthy: boolean; prevBlocking?: boolean }>();
@@ -887,6 +949,7 @@ export {
887
949
  latestVerdictPerDimension,
888
950
  PLAN_DIMENSIONS,
889
951
  panelProgress,
952
+ panelRoster,
890
953
  planAuthoredRisks,
891
954
  planGatePasses,
892
955
  procedureSatisfiesDuty,
@@ -898,6 +961,7 @@ export {
898
961
  seedLiftStuck,
899
962
  seedOnlyCiteFail,
900
963
  seedOnlyFindings,
964
+ shipRoster,
901
965
  sliceGatePasses,
902
966
  subplanGatePasses,
903
967
  type VerdictRecord,
@@ -7,14 +7,15 @@ import {
7
7
  dimensionsToRegrade,
8
8
  freshVerdicts,
9
9
  GOAL_DIMENSIONS,
10
- gateRoster,
11
- gateTier,
12
10
  latestVerdictPerDimension,
13
11
  PLAN_DIMENSIONS,
14
12
  panelProgress,
13
+ panelRoster,
15
14
  planAuthoredRisks,
15
+ RISK_DIMENSION,
16
16
  SHIP_DIMENSIONS,
17
17
  SLICE_DIMENSIONS,
18
+ shipRoster,
18
19
  } from "./gates.js";
19
20
  import { isSurgicalFix, priorArtifact } from "./priors.js";
20
21
  import { haltPreflight, latestFsArtifact } from "./shared.js";
@@ -100,8 +101,14 @@ const citeCheckFlag = (state: RunView, citeChannel: string | undefined): string
100
101
  * `--prior` threads a dimension's latest fresh verdict when that dimension is
101
102
  * still pending (a confirm or re-grade of a blocking prior — the grader must
102
103
  * 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.
104
+ * and on the risk unit (their re-grades scope to the prior). A carried
105
+ * passing prior on any other dimension is not re-adjudicated. Round 1 emits
106
+ * no flag.
107
+ *
108
+ * The `RISK_DIMENSION` unit joins the roster through `panelRoster` whenever
109
+ * the graded channel declares `risks:` — bare flags plus `--prior`: no
110
+ * `--goal` (the goal-contradiction class stays with correctness), no
111
+ * `--cite-check` (resolution is correctness's lead source), no `--context`.
105
112
  *
106
113
  * Every panel wires `haltWhenAllFailed: true`: a generation in which EVERY
107
114
  * dispatched dimension unit failed is a dead panel — nothing was collected, so
@@ -121,7 +128,8 @@ const gradePanelFanout = (
121
128
  fanout({
122
129
  source: channel,
123
130
  unit: { by: "dimension-list", pattern: "dimensions" },
124
- max: dimensions.length,
131
+ // +1: the risk unit `panelRoster` may add on top of the dimension list.
132
+ max: dimensions.length + 1,
125
133
  haltWhenAllFailed: true,
126
134
  retryHaltedUnits: 1,
127
135
  units: ({ state, cwd }) => {
@@ -135,7 +143,7 @@ const gradePanelFanout = (
135
143
  // simply emit no flag.
136
144
  const { contextFlag, goalFlag, acceptanceFlag } = dimensionArtifactFlags(state);
137
145
  const citeFlag = citeCheckFlag(state, citeChannel);
138
- const roster = gateRoster(gateTier(state, verdictChannel), dimensions);
146
+ const roster = panelRoster(state, channel, verdictChannel, dimensions);
139
147
  const latest = latestVerdictPerDimension(freshVerdicts(state.named[verdictChannel], target));
140
148
  const risks = planAuthoredRisks(state, channel);
141
149
  const pending = dimensionsToRegrade(roster, latest, risks);
@@ -155,7 +163,7 @@ const gradePanelFanout = (
155
163
  isSurgicalFix(state, priorChannel, cwd, target, latest, pending, risks);
156
164
  const priorPresent = priorChannel !== undefined && priorArtifact(state, priorChannel) !== undefined;
157
165
  const priorFlag = (d: string): string => {
158
- if (d !== "correctness" && !pending.includes(d)) return "";
166
+ if (d !== "correctness" && d !== RISK_DIMENSION && !pending.includes(d)) return "";
159
167
  const handle = latest.get(d)?.artifacts.find((a) => a.handle.kind === "fs")?.handle;
160
168
  return handle ? ` --prior ${handleToString(handle)}` : "";
161
169
  };
@@ -244,7 +252,8 @@ const CODE_PANEL_PROGRESS = panelProgress("code-verdicts", PLAN_DIMENSIONS, {
244
252
  export const SHIP_DIMENSION_FANOUT = fanout({
245
253
  source: "plans",
246
254
  unit: { by: "dimension-list", pattern: "dimensions" },
247
- max: SHIP_DIMENSIONS.length,
255
+ // +1: the risk unit `shipRoster` adds when the plan declares `risks:`.
256
+ max: SHIP_DIMENSIONS.length + 1,
248
257
  haltWhenAllFailed: true,
249
258
  retryHaltedUnits: 1,
250
259
  units: ({ state }) => {
@@ -258,8 +267,9 @@ export const SHIP_DIMENSION_FANOUT = fanout({
258
267
  // the configured channel carries no fs verdict; a clean verdict settles
259
268
  // resolution, findings carry the advisory leads (see citeCheckFlag).
260
269
  const citeFlag = citeCheckFlag(state, "plan-cite-check");
261
- // Tier-independent roster: SHIP_DIMENSIONS verbatim — never gateRoster(gateTier(...)).
262
- const roster = SHIP_DIMENSIONS;
270
+ // Tier-independent roster: SHIP_DIMENSIONS verbatim (plus the risk unit
271
+ // when the plan declares risks) — never gateRoster(gateTier(...)).
272
+ const roster = shipRoster(state);
263
273
  const latest = latestVerdictPerDimension(freshVerdicts(state.named["ship-verdicts"], target));
264
274
  const risks = planAuthoredRisks(state, "plans");
265
275
  const pending = dimensionsToRegrade(roster, latest, risks);
@@ -16,9 +16,11 @@ export {
16
16
  latestVerdictPerDimension,
17
17
  PLAN_DIMENSIONS,
18
18
  panelProgress,
19
+ panelRoster,
19
20
  planAuthoredRisks,
20
21
  planGatePasses,
21
22
  progressFromRoundCounts,
23
+ RISK_DIMENSION,
22
24
  rulingEffectivePass,
23
25
  type SeedOnlyVerdict,
24
26
  SHIP_DIMENSIONS,
@@ -27,6 +29,7 @@ export {
27
29
  seedOnlyCiteFail,
28
30
  seedOnlyFindings,
29
31
  shipGatePasses,
32
+ shipRoster,
30
33
  sliceGatePasses,
31
34
  subplanGatePasses,
32
35
  unitFailedDimensions,
@@ -0,0 +1,90 @@
1
+ # meta — a graph of self-correcting units
2
+
3
+ `meta` is an authoring layer over the rpiv-workflow engine. You write a workflow as an ordered list of **units**. Each unit is one loop:
4
+
5
+ ```
6
+ produce ─► checks (code, first) ─► graders (LLM lenses, parallel) ─► gate
7
+ ▲ │
8
+ └──── fix (return record: unit·verdict·reason·evidence·scope) ◄────┘ while rounds < max
9
+ exhausted ─► halt | advance | escalate upstream
10
+ accepted run ─► learn ─► .rpiv/lessons/meta-lessons.json (standing constraints for the next run's producers)
11
+ ```
12
+
13
+ The loop lives inside a unit, and the graph lives between units. `defineUnitGraph` compiles each unit into engine stages and routes: `<u>`, `<u>-fix`, `<u>-check`, `<u>-grade`, `<u>-gate`.
14
+
15
+ ## Unit spec
16
+
17
+ ```ts
18
+ defineUnitGraph({
19
+ name: "my-flow",
20
+ units: [
21
+ ["research", { skill: "research", output: "research", checks: [minCitations(5)] }], // mandatory, first
22
+ ["plan", {
23
+ skill: "quick-plan", // skill XOR prompt (string or (ctx) => string)
24
+ reads: ["research", "goal"], // the only real edges
25
+ output: "plans", // omit ⇒ side-effect unit (the working tree)
26
+ checks: [planCitations], // deterministic graders, run first
27
+ graders: [{ lens: "correctness", rubric: "FAIL if …", context: ["research"] }],
28
+ fix: { prompt: "Revise the plan in place …" }, // default: re-run producer + return record
29
+ maxRounds: 3, // ≤ 4
30
+ onExhausted: "halt", // | "advance" | { escalateTo: "<earlier unit>" }
31
+ }],
32
+ ],
33
+ commit: true,
34
+ });
35
+ ```
36
+
37
+ - `research` is the only mandatory unit, and it must come first.
38
+ - Every other unit is optional.
39
+ - Built-in: `/wf meta "<brief>"` runs research → acceptance → plan → implement → commit. Research is the mandatory first unit; every later unit is optional when you author your own graph.
40
+ - A project pack can import `defineUnitGraph` and `checks.ts` by absolute path.
41
+
42
+ ## How it differs from `build`
43
+
44
+ | | `build` | `meta` |
45
+ |---|---|---|
46
+ | Unit of correction | Whole artifact. `amend` rewrites the plan (170–785 KB) and the whole 5–6 lens panel re-grades. | The failing items only. The return record lists them, with SCOPE = "touch only what the evidence cites". |
47
+ | Check order | Cite floor, then the LLM panel. Floors were mostly demoted to advisory. | Code checks first and short-circuiting. A red check never pays for a grader. |
48
+ | Graders | 5–6 dimensions tiered by size, plus a confirm pass, demote, and priors snapshots. | 1–2 lenses per unit. No confirm, no demote. |
49
+ | Stop condition | Jump budget 3 per destination, lap ceiling 8, a noisy `progress` label. | Per-unit `maxRounds`, plus an identical failure signature twice = stop early. |
50
+ | Exhausted | Halt. A human resumes. | halt, advance, or escalate to an upstream unit. |
51
+ | Decomposition | slice → design ×N → human design-review → subplans → plan → elaborate → splice. | None. One plan; implement fans out by phase. |
52
+ | Human | design-review checkpoint mid-graph. | Only at the end (commit). |
53
+ | Cross-run learning | None. Death scenes and priors are write-only or in-run. | `learn` records corrected failures, and producers read the top ones. |
54
+ | Size | ~35 stages, hand-wired routes. | 4 units → 17 stages, generated. |
55
+
56
+ ### What the corpus says (52 real build runs in opendots)
57
+
58
+ - Every fix round was whole-batch: 90 amend rounds and 193 panel runs.
59
+ - Confirm upheld 40 of 40 failures (~6 min each).
60
+ - Demote demoted 0 of 193.
61
+ - 7 of ~45 multi-round loops regressed mid-loop.
62
+ - Every terminal halt was a corrector that could not reach the cause ("remediation left the working tree unchanged").
63
+
64
+ `meta` is built to test these points:
65
+ - scoped returns
66
+ - no confirm or demote
67
+ - stuck detection by signature
68
+ - upward escalation
69
+ - lessons that cross runs
70
+
71
+ ## What `meta` gives up (and what an A/B will tell you)
72
+
73
+ - **No slicing or parallel design.** Large briefs may produce a weaker single plan. `build`'s decomposition is its strongest feature on big work.
74
+ - **Fewer lenses.** Actionability, pattern-following, architecture-fit and risk rulings are gone. The corpus shows they rarely failed (3–8%), but "rarely" is not "never".
75
+ - **No mid-graph human checkpoint.**
76
+ - **Lessons are raw failure reasons**, not distilled rules. Noisy until counts accumulate.
77
+
78
+ ## A/B
79
+
80
+ ```bash
81
+ node ab.mjs setup ~/opendots air5-x "<brief>" # two worktrees at HEAD, prints launch commands
82
+ # run each arm in its own terminal (pi, then the printed /wf line); they run in parallel
83
+ node ab.mjs compare ~/opendots air5-x --eval "cd packages/arclet-ui && swift test"
84
+ ```
85
+
86
+ `compare` reports, per arm: outcome, wall clock, active time, sessions, tokens, stage visits and re-entries, rounds per unit, and the diff.
87
+
88
+ It also runs a **shared scorecard**: your `--eval` commands plus every arm's frozen acceptance commands, executed on every arm's tree. No arm is graded only by its own standard.
89
+
90
+ Write the `--eval` checks before looking at either result.