@juicesharp/rpiv-pi 2.8.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/agent-enablement.ts +164 -0
- package/extensions/rpiv-core/agents.ts +98 -12
- package/extensions/rpiv-core/artifact-collector.ts +30 -7
- package/extensions/rpiv-core/built-in-workflows.ts +370 -96
- 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/reconcile-directives.d.mts +29 -0
- package/extensions/rpiv-core/built-ins/reconcile-directives.mjs +338 -0
- package/extensions/rpiv-core/built-ins/reconcile.ts +88 -130
- 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/frontmatter.ts +22 -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-config.ts +86 -6
- package/extensions/rpiv-core/models-picker.ts +4 -3
- package/extensions/rpiv-core/package-checks.ts +13 -0
- 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/extensions/rpiv-core/workflow-execution-host.ts +3 -2
- package/package.json +4 -3
- package/skills/_shared/reconcile-lint.mjs +125 -0
- 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 +13 -6
- package/skills/grade/SKILL.md +15 -12
- package/skills/implement/SKILL.md +17 -2
- package/skills/research/SKILL.md +1 -1
- package/skills/slice/SKILL.md +2 -2
- package/skills/synthesize/SKILL.md +1 -1
- package/skills/validate/SKILL.md +14 -0
|
@@ -20,7 +20,6 @@ import {
|
|
|
20
20
|
acts,
|
|
21
21
|
defineRoute,
|
|
22
22
|
defineWorkflow,
|
|
23
|
-
directoryPathCollector,
|
|
24
23
|
type EdgeFn,
|
|
25
24
|
eq,
|
|
26
25
|
fanin,
|
|
@@ -28,7 +27,6 @@ import {
|
|
|
28
27
|
gitCommitOutcome,
|
|
29
28
|
gt,
|
|
30
29
|
handleToString,
|
|
31
|
-
jsonBodyParser,
|
|
32
30
|
match,
|
|
33
31
|
type PromptFn,
|
|
34
32
|
produces,
|
|
@@ -39,9 +37,9 @@ import {
|
|
|
39
37
|
import { rpivBucketOutcome } from "./artifact-collector.js";
|
|
40
38
|
import {
|
|
41
39
|
allDimensionsPass,
|
|
42
|
-
anchorNitsOnly,
|
|
43
40
|
CODE_CONFIRM_FANOUT,
|
|
44
41
|
CODE_DIMENSION_FANOUT,
|
|
42
|
+
CODE_PANEL_PROGRESS,
|
|
45
43
|
COMMIT_BASELINE_PROMPT,
|
|
46
44
|
captureGoal,
|
|
47
45
|
captureReviewScope,
|
|
@@ -49,7 +47,9 @@ import {
|
|
|
49
47
|
codeGatePasses,
|
|
50
48
|
codeSnapshot,
|
|
51
49
|
confirmDue,
|
|
52
|
-
|
|
50
|
+
designOutcome,
|
|
51
|
+
ELABORATE_PHASE_FANOUT,
|
|
52
|
+
elaborationOutcome,
|
|
53
53
|
freshVerdicts,
|
|
54
54
|
haltPreflight,
|
|
55
55
|
IMPLEMENT_DAG_FANOUT,
|
|
@@ -63,6 +63,7 @@ import {
|
|
|
63
63
|
PLAN_CONFIRM_FANOUT,
|
|
64
64
|
PLAN_DIMENSION_FANOUT,
|
|
65
65
|
PLAN_DIMENSIONS,
|
|
66
|
+
PLAN_PANEL_PROGRESS,
|
|
66
67
|
planAuthoredRisks,
|
|
67
68
|
planCitationCheck,
|
|
68
69
|
planDemote,
|
|
@@ -74,17 +75,27 @@ import {
|
|
|
74
75
|
rulingEffectivePass,
|
|
75
76
|
SHIP_DIMENSION_FANOUT,
|
|
76
77
|
SHIP_DIMENSIONS,
|
|
78
|
+
SHIP_PANEL_PROGRESS,
|
|
77
79
|
SLICE_DESIGN_FANOUT,
|
|
78
80
|
SLICE_DIMENSION_FANOUT,
|
|
81
|
+
SLICE_DIMENSIONS,
|
|
82
|
+
SLICE_PANEL_PROGRESS,
|
|
79
83
|
SYNTH_CLUSTER_FANOUT,
|
|
80
84
|
scopeQuarantine,
|
|
85
|
+
seedLiftStuck,
|
|
86
|
+
seedOnlyCiteFail,
|
|
81
87
|
shipGatePasses,
|
|
82
88
|
shipVerdictOutcome,
|
|
83
89
|
sliceGatePasses,
|
|
90
|
+
sliceSeedLift,
|
|
84
91
|
sliceStructureCheck,
|
|
85
92
|
subplanCoverageCheck,
|
|
86
93
|
subplanGatePasses,
|
|
94
|
+
unitFailedDimensions,
|
|
87
95
|
VALIDATE_GOAL_PROMPT,
|
|
96
|
+
type VerdictRecord,
|
|
97
|
+
verdictBlocks,
|
|
98
|
+
verdictOutcome,
|
|
88
99
|
verdictRiskRulings,
|
|
89
100
|
} from "./built-ins/index.js";
|
|
90
101
|
|
|
@@ -138,7 +149,9 @@ const polishWorkflow = defineWorkflow({
|
|
|
138
149
|
validate: "code-review",
|
|
139
150
|
// Backward edge: code-review → blueprint re-plans (implement needs a plan).
|
|
140
151
|
// The iterate stage re-runs over every review phase; bounded by the
|
|
141
|
-
// runner's default maxBackwardJumps (3 → up to 4 review iterations)
|
|
152
|
+
// runner's default maxBackwardJumps (3 → up to 4 review iterations)
|
|
153
|
+
// under the absolute per-stage maxLaps ceiling (default 8; both
|
|
154
|
+
// budgets fresh per invocation — a resume re-opens the loop).
|
|
142
155
|
"code-review": gate("blockers_count", { blueprint: gt(0), commit: eq(0) }, "commit"),
|
|
143
156
|
commit: "stop",
|
|
144
157
|
},
|
|
@@ -223,24 +236,20 @@ const SHIP_RESEARCH_PROMPT: PromptFn = ({ state }) =>
|
|
|
223
236
|
].join("\n");
|
|
224
237
|
|
|
225
238
|
/**
|
|
226
|
-
* Verdict channels — grade writes JSON to `.rpiv/artifacts/verdicts/`, so
|
|
227
|
-
* use the
|
|
228
|
-
* `rpivBucketOutcome`). The slice gate and plan gate publish to
|
|
229
|
-
* channels (same dir, different artifact basenames) so their
|
|
230
|
-
* collide and `plan-fix`/`code-fix` can pick each via the
|
|
239
|
+
* Verdict channels — grade writes JSON to `.rpiv/artifacts/verdicts/`, so
|
|
240
|
+
* these use the disk-first verdict factory in `built-ins/verdict-outcome.ts`
|
|
241
|
+
* (NOT the md `rpivBucketOutcome`). The slice gate and plan gate publish to
|
|
242
|
+
* DISTINCT named channels (same dir, different artifact basenames) so their
|
|
243
|
+
* verdicts never collide and `plan-fix`/`code-fix` can pick each via the
|
|
244
|
+
* `-verdicts` suffix convention.
|
|
231
245
|
*/
|
|
232
|
-
const
|
|
233
|
-
|
|
234
|
-
collector: directoryPathCollector({ dir: ".rpiv/artifacts/verdicts", ext: "json" }),
|
|
235
|
-
parser: jsonBodyParser,
|
|
236
|
-
});
|
|
237
|
-
const sliceVerdictOutcome = verdictOutcome("slice-verdicts");
|
|
238
|
-
const planVerdictOutcome = verdictOutcome("plan-verdicts");
|
|
246
|
+
const sliceVerdictOutcome = verdictOutcome("slice-verdicts", "slices");
|
|
247
|
+
const planVerdictOutcome = verdictOutcome("plan-verdicts", "plans");
|
|
239
248
|
// The post-splice code gate re-grades the now code-bearing plan on its own
|
|
240
249
|
// channel, so its verdicts never mix with the pre-elaborate plan gate's. Named
|
|
241
250
|
// for the object under judgment — the code the gate grades — completing the
|
|
242
251
|
// slice-verdicts / plan-verdicts / code-verdicts parallel.
|
|
243
|
-
const codeVerdictOutcome = verdictOutcome("code-verdicts");
|
|
252
|
+
const codeVerdictOutcome = verdictOutcome("code-verdicts", "plans");
|
|
244
253
|
|
|
245
254
|
/**
|
|
246
255
|
* Absolute path to rpiv-pi's bundled deterministic stitch script. Resolved off
|
|
@@ -275,21 +284,33 @@ const STITCH_SCRIPT = join(
|
|
|
275
284
|
* tracked excess to downstream adjudication (build threads the verdict to
|
|
276
285
|
* validate via `--scope`; vet's review loop sees the whole diff) instead of
|
|
277
286
|
* halting, the citation-floor precedent (demote where a remedy or adjudicator
|
|
278
|
-
* exists).
|
|
287
|
+
* exists). The excess pick is an HONEST pass-through: it attaches a route note
|
|
288
|
+
* naming the downstream adjudicator (`opts.deferredTo` — validate on build,
|
|
289
|
+
* code-review on vet) so the end-of-run recap's `routingNotes` can surface the
|
|
290
|
+
* deferral; the pass pick attaches no note (a clean pass needs no
|
|
291
|
+
* explanation). "untracked-only" takes the deterministic `scope-quarantine`
|
|
292
|
+
* arm.
|
|
279
293
|
* Anything else — a missing or corrupt verdict — terminates ("stop" with a
|
|
280
294
|
* route note): the integrity clause every de-halting change has preserved.
|
|
281
295
|
* A `match` cannot send two enum values to one target, hence `defineRoute`;
|
|
282
296
|
* `readsData: false` — the route consults the stage's published channel, not
|
|
283
297
|
* its projected output (matching the other deterministic-floor routes).
|
|
284
298
|
*/
|
|
285
|
-
const scopeFloorGate = (): EdgeFn => {
|
|
299
|
+
const scopeFloorGate = (opts: { deferredTo: string }): EdgeFn => {
|
|
286
300
|
const route: EdgeFn = defineRoute(
|
|
287
301
|
["reconcile", "scope-quarantine", "stop"],
|
|
288
302
|
({ state }) => {
|
|
289
303
|
const verdict = (state.named["implement-scope-check"]?.at(-1)?.data as { verdict?: unknown } | undefined)
|
|
290
304
|
?.verdict;
|
|
291
305
|
if (verdict === "untracked-only") return "scope-quarantine";
|
|
292
|
-
if (verdict === "pass"
|
|
306
|
+
if (verdict === "pass") return "reconcile";
|
|
307
|
+
if (verdict === "excess") {
|
|
308
|
+
// Honest pass-through: the floor did not PASS, it DEFERRED — record why
|
|
309
|
+
// on the routing row (the recap's routingNotes) instead of a silent
|
|
310
|
+
// reconcile that reads like a clean pass.
|
|
311
|
+
setRouteNote(route, `pass-through: implement-scope-check defers to ${opts.deferredTo}`);
|
|
312
|
+
return "reconcile";
|
|
313
|
+
}
|
|
293
314
|
setRouteNote(
|
|
294
315
|
route,
|
|
295
316
|
`implement-scope-check verdict ${JSON.stringify(verdict ?? null)} is not a ScopeVerdict — terminated (integrity stop)`,
|
|
@@ -301,6 +322,97 @@ const scopeFloorGate = (): EdgeFn => {
|
|
|
301
322
|
return route;
|
|
302
323
|
};
|
|
303
324
|
|
|
325
|
+
/**
|
|
326
|
+
* The reconciliation gate — pass ⇒ validate; fail ⇒ the `reconcile-fix` repair
|
|
327
|
+
* arm; missing/corrupt verdict ⇒ STOP (integrity clause, exactly the `match` it
|
|
328
|
+
* replaces). The arm exists because every reconcile failure class — a malformed
|
|
329
|
+
* directive, a stale `find`, a non-test target — is a defect in the PLAN's
|
|
330
|
+
* directive text, which is `amend`'s exact authority ("fix the artifact, never
|
|
331
|
+
* the repo"); the old no-arm route stopped the run on a fail that hand-repairing
|
|
332
|
+
* the TREE could never clear (run 2026-08-31_15-21-14-57d0: a multi-line
|
|
333
|
+
* directive re-failed every resume because the defect lived in the plan
|
|
334
|
+
* artifact, which nothing in the pipeline could edit). Reconcile itself stays
|
|
335
|
+
* the sole test-file writer — the arm only repairs directives; the loop
|
|
336
|
+
* re-enters reconcile to apply them.
|
|
337
|
+
*
|
|
338
|
+
* A factory for the validateGate/scopeFloorGate reason — each workflow's
|
|
339
|
+
* route-note symbol must never alias the other's. `maxFixRounds` caps the
|
|
340
|
+
* amend hops a fail may buy, counted from the `reconcile-fix` channel — the
|
|
341
|
+
* channel ONLY the arm itself writes (its outcome publishes there, not on
|
|
342
|
+
* `plans`), mirroring validateGate's `remediation`-channel cap. It must NOT
|
|
343
|
+
* count reconcile-channel entries: reconcile re-executes on paths that spend
|
|
344
|
+
* no amend hop — ship's validate-fix loop re-enters through
|
|
345
|
+
* implement-scope-check → reconcile, and a resume replays entries — so an
|
|
346
|
+
* entry-count budget let the validate-fix loop spend the arm's only round
|
|
347
|
+
* before the arm ever ran, with a stop-note claiming a fix round that never
|
|
348
|
+
* happened (review 2026-08-31 I1; the fourth instance of the cap-must-read-a-
|
|
349
|
+
* channel-the-arm-writes lesson). Build/vet pass no cap (the runner's
|
|
350
|
+
* per-destination backward-jump budget on `reconcile-fix` is theirs, the
|
|
351
|
+
* plan-fix precedent); ship caps at ONE — the same single bounded hop its
|
|
352
|
+
* stop-on-fail identity concedes at the validate gate.
|
|
353
|
+
*/
|
|
354
|
+
const reconcileGate = (opts?: { maxFixRounds?: number }): EdgeFn => {
|
|
355
|
+
const maxFixRounds = opts?.maxFixRounds ?? Number.POSITIVE_INFINITY;
|
|
356
|
+
const route: EdgeFn = defineRoute(
|
|
357
|
+
["validate", "reconcile-fix", "stop"],
|
|
358
|
+
({ state }) => {
|
|
359
|
+
const verdict = (state.named.reconcile?.at(-1)?.data as { verdict?: unknown } | undefined)?.verdict;
|
|
360
|
+
if (verdict === "pass") return "validate";
|
|
361
|
+
if (verdict !== "fail") {
|
|
362
|
+
setRouteNote(
|
|
363
|
+
route,
|
|
364
|
+
`reconcile verdict ${JSON.stringify(verdict ?? null)} matched no branch — terminated (no fallback)`,
|
|
365
|
+
);
|
|
366
|
+
return "stop";
|
|
367
|
+
}
|
|
368
|
+
const roundsSpent = state.named["reconcile-fix"]?.length ?? 0;
|
|
369
|
+
if (roundsSpent >= maxFixRounds) {
|
|
370
|
+
setRouteNote(
|
|
371
|
+
route,
|
|
372
|
+
`reconcile still fails after ${roundsSpent} amend round${roundsSpent === 1 ? "" : "s"} — repair the #### Reconciliation directives in the PLAN artifact by hand (the failure lives in the plan text, not the tree), then resume`,
|
|
373
|
+
);
|
|
374
|
+
return "stop";
|
|
375
|
+
}
|
|
376
|
+
return "reconcile-fix";
|
|
377
|
+
},
|
|
378
|
+
{ readsData: false },
|
|
379
|
+
);
|
|
380
|
+
return route;
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* The `reconcile-fix` arm's dispatch — `/skill:amend` over the latest plan and
|
|
385
|
+
* the reconcile verdict. A PROMPT stage (owning its whole message, the
|
|
386
|
+
* VALIDATE_PLANS_PROMPT precedent) because amend's generic flag parser keys
|
|
387
|
+
* verdict inputs on the `-verdicts` name suffix, and reconcile's script stage
|
|
388
|
+
* publishes on its stage-key channel `reconcile` — a `reads: ["reconcile"]`
|
|
389
|
+
* skill stage would thread `--reconcile <path>`, which amend reads as a SECOND
|
|
390
|
+
* artifact flag and refuses. The explicit `--reconcile-verdicts` spelling
|
|
391
|
+
* parses as exactly one artifact (`--plans`) + one verdicts flag. The gate only
|
|
392
|
+
* dispatches this arm on a fail verdict, so both channel reads are present by
|
|
393
|
+
* construction; a torn state degrades to amend's own front-door refusal
|
|
394
|
+
* (exactly-one-artifact + at-least-one-verdicts), never a silent guess.
|
|
395
|
+
*/
|
|
396
|
+
const RECONCILE_FIX_PROMPT: PromptFn = ({ state }) => {
|
|
397
|
+
const parts = ["/skill:amend"];
|
|
398
|
+
const plan = latestFsArtifact(state, "plans");
|
|
399
|
+
if (plan) parts.push("--plans", handleToString(plan.handle));
|
|
400
|
+
const verdict = state.named.reconcile?.at(-1)?.artifacts.find((a) => a.handle.kind === "fs");
|
|
401
|
+
if (verdict) parts.push("--reconcile-verdicts", handleToString(verdict.handle));
|
|
402
|
+
return parts.join(" ");
|
|
403
|
+
};
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* The arm's outcome — the plans-bucket collector publishing on the arm's OWN
|
|
407
|
+
* `reconcile-fix` channel. Amend re-emits the plan IN PLACE (same path, its
|
|
408
|
+
* hard rule), so the `plans` channel's latest entry stays correct without a
|
|
409
|
+
* republish; what the channel choice buys is the round counter ONLY the arm
|
|
410
|
+
* increments, which `reconcileGate`'s cap reads (the validateGate/
|
|
411
|
+
* `remediation` pattern — see the gate doc for why counting reconcile
|
|
412
|
+
* executions instead let the validate-fix loop spend the budget).
|
|
413
|
+
*/
|
|
414
|
+
const RECONCILE_FIX_OUTCOME = { ...rpivBucketOutcome("plans"), name: "reconcile-fix" };
|
|
415
|
+
|
|
304
416
|
const vetWorkflow = defineWorkflow({
|
|
305
417
|
name: "vet",
|
|
306
418
|
description:
|
|
@@ -349,11 +461,16 @@ const vetWorkflow = defineWorkflow({
|
|
|
349
461
|
"scope-quarantine": produces.script({ reads: ["implement-scope-check"], run: scopeQuarantine }),
|
|
350
462
|
// Deterministic post-implement reconciliation (no LLM) — the SAME `reconcile`
|
|
351
463
|
// run-function as build (no vet twin): applies every `#### Reconciliation`
|
|
352
|
-
// directive (write-restricted to
|
|
353
|
-
//
|
|
354
|
-
//
|
|
355
|
-
// baseline. The `from` form suppresses the READS_DATA outputSchema lint.
|
|
464
|
+
// directive (write-restricted to the plan's declared write-set), fail-soft. Pass ⇒ validate;
|
|
465
|
+
// fail ⇒ the reconcile-fix arm (see reconcileGate); missing ⇒ STOP.
|
|
466
|
+
// `reads: ["plans"]` only — no run-start goal baseline.
|
|
356
467
|
reconcile: produces.script({ reads: ["plans"], run: reconcile }),
|
|
468
|
+
// Repair arm for the reconciliation gate: /skill:amend over the plan's
|
|
469
|
+
// directives from the reconcile verdict (a prompt stage — see
|
|
470
|
+
// RECONCILE_FIX_PROMPT), re-emitting the plan latest-wins, then back
|
|
471
|
+
// through reconcile to apply. Bounded by the runner's per-destination
|
|
472
|
+
// backward-jump budget (the plan-fix precedent).
|
|
473
|
+
"reconcile-fix": produces.prompt({ prompt: RECONCILE_FIX_PROMPT, outcome: RECONCILE_FIX_OUTCOME }),
|
|
357
474
|
validate: produces(),
|
|
358
475
|
commit: acts({ outcome: gitCommitOutcome }),
|
|
359
476
|
},
|
|
@@ -370,24 +487,31 @@ const vetWorkflow = defineWorkflow({
|
|
|
370
487
|
implement: "implement-scope-check",
|
|
371
488
|
// Scope-check still gates onward into `reconcile` (not validate): the
|
|
372
489
|
// coherence backstop runs after the write-set is judged. Tiered route —
|
|
373
|
-
// see scopeFloorGate: pass/excess ⇒ reconcile
|
|
374
|
-
//
|
|
375
|
-
|
|
490
|
+
// see scopeFloorGate: pass/excess ⇒ reconcile (excess carries the
|
|
491
|
+
// code-review pass-through note), untracked-only ⇒ the quarantine arm,
|
|
492
|
+
// missing/corrupt verdict ⇒ STOP.
|
|
493
|
+
"implement-scope-check": scopeFloorGate({ deferredTo: "code-review" }),
|
|
376
494
|
// Deterministic re-entry after the quarantine arm: a plain string edge
|
|
377
495
|
// (non-counted, mirroring build's validate-fix hop) with guaranteed
|
|
378
496
|
// progress — quarantined paths leave the dirty set, so the re-check
|
|
379
497
|
// either passes or reveals tracked drift. At most one quarantine hop per
|
|
380
498
|
// gate entry; no new loop budget.
|
|
381
499
|
"scope-quarantine": "implement-scope-check",
|
|
382
|
-
// Reconciliation gate. Pass ⇒ validate; a `fail` (
|
|
383
|
-
// absent find /
|
|
384
|
-
//
|
|
385
|
-
reconcile:
|
|
500
|
+
// Reconciliation gate. Pass ⇒ validate; a `fail` (malformed directive /
|
|
501
|
+
// absent find / non-test target — all plan-TEXT defects) ⇒ the
|
|
502
|
+
// reconcile-fix amend arm; a missing verdict ⇒ STOP (integrity clause).
|
|
503
|
+
reconcile: reconcileGate(),
|
|
504
|
+
// Deterministic re-entry after the amend arm: reconcile re-parses the
|
|
505
|
+
// repaired directives and applies them (a plain string edge — the
|
|
506
|
+
// counted decision is the gate's reconcile-fix pick).
|
|
507
|
+
"reconcile-fix": "reconcile",
|
|
386
508
|
// Backward edge: validate → code-review creates the review-fix loop —
|
|
387
509
|
// UNCHANGED. The scope-check inserts before validate, so a failing scope
|
|
388
510
|
// verdict halts before re-review, and a passing one flows into validate and
|
|
389
511
|
// back to code-review exactly as today. Bounded by the runner's default
|
|
390
|
-
// maxBackwardJumps (3 → at most 4 review iterations)
|
|
512
|
+
// maxBackwardJumps (3 → at most 4 review iterations) under the absolute
|
|
513
|
+
// per-stage maxLaps ceiling (default 8; both budgets fresh per
|
|
514
|
+
// invocation — a resume re-opens the loop).
|
|
391
515
|
validate: "code-review",
|
|
392
516
|
commit: "stop",
|
|
393
517
|
},
|
|
@@ -495,6 +619,71 @@ const validateFixGate = (): EdgeFn => {
|
|
|
495
619
|
return route;
|
|
496
620
|
};
|
|
497
621
|
|
|
622
|
+
/**
|
|
623
|
+
* The fix-arm note for a dead grade unit — the dimension soft-halted (after
|
|
624
|
+
* its retry budget ran out, when the panel wires one) and left no verdict to
|
|
625
|
+
* fold. Naming it keeps the failure legible and the repair targeted: the fix
|
|
626
|
+
* arm re-enters the panel, `dimensionsToRegrade` still lists the dimension as
|
|
627
|
+
* pending, and a healthy re-dispatch grades it for real.
|
|
628
|
+
*/
|
|
629
|
+
const unitFailedNote = (dims: readonly string[]): string => `unit-failed: ${dims.join(", ")} produced no verdict`;
|
|
630
|
+
|
|
631
|
+
/** The slice gate's grade edge — design-readiness pass ⇒ design; a dead
|
|
632
|
+
* dimension unit ⇒ slice-fix with the note (a verdict-less dead dimension is
|
|
633
|
+
* never a classification candidate). A SEED-ONLY cite fail (every finding
|
|
634
|
+
* naming a concrete seed to add) ⇒ the deterministic `slice-seed-lift` arm,
|
|
635
|
+
* which appends the seeds and re-enters `slice-check` for the discharge
|
|
636
|
+
* stamp; anything else ⇒ slice-fix. Belt-and-suspenders for the live graph:
|
|
637
|
+
* the slice roster is one dimension, so a double miss makes the generation
|
|
638
|
+
* all-failed and `haltWhenAllFailed` halts at the panel close before any
|
|
639
|
+
* route runs — the arms pin the route contract for any future multi-dimension
|
|
640
|
+
* slice roster and for constructed-state trails. */
|
|
641
|
+
const sliceGradeRoute: EdgeFn = defineRoute(
|
|
642
|
+
["slice-design", "slice-seed-lift", "slice-fix"],
|
|
643
|
+
({ state }) => {
|
|
644
|
+
if (sliceGatePasses(state)) return "slice-design";
|
|
645
|
+
const unitFailed = unitFailedDimensions(state, "slices", "slice-verdicts", SLICE_DIMENSIONS);
|
|
646
|
+
if (unitFailed.length > 0) {
|
|
647
|
+
setRouteNote(sliceGradeRoute, unitFailedNote(unitFailed));
|
|
648
|
+
return "slice-fix";
|
|
649
|
+
}
|
|
650
|
+
return seedOnlyCiteFail(state) ? "slice-seed-lift" : "slice-fix";
|
|
651
|
+
},
|
|
652
|
+
{ readsData: false },
|
|
653
|
+
);
|
|
654
|
+
|
|
655
|
+
/** The plan gate's demote edge — the unit-failed preemption fires BEFORE the
|
|
656
|
+
* confirm divert (a previously-passing dimension whose re-grade died is not
|
|
657
|
+
* a flap to adjudicate; there is no verdict to adjudicate). */
|
|
658
|
+
const planDemoteRoute: EdgeFn = defineRoute(
|
|
659
|
+
["code", "plan-confirm", "plan-snapshot"],
|
|
660
|
+
({ state }) => {
|
|
661
|
+
if (planGatePasses(state)) return "code";
|
|
662
|
+
const unitFailed = unitFailedDimensions(state, "plans", "plan-verdicts", PLAN_DIMENSIONS);
|
|
663
|
+
if (unitFailed.length > 0) {
|
|
664
|
+
setRouteNote(planDemoteRoute, unitFailedNote(unitFailed));
|
|
665
|
+
return "plan-snapshot";
|
|
666
|
+
}
|
|
667
|
+
return confirmDue(state, "plans", "plan-verdicts", PLAN_DIMENSIONS) ? "plan-confirm" : "plan-snapshot";
|
|
668
|
+
},
|
|
669
|
+
{ readsData: false },
|
|
670
|
+
);
|
|
671
|
+
|
|
672
|
+
/** The code gate's demote edge — the plan gate's twin on `code-verdicts`. */
|
|
673
|
+
const codeDemoteRoute: EdgeFn = defineRoute(
|
|
674
|
+
["implement", "code-confirm", "code-snapshot"],
|
|
675
|
+
({ state }) => {
|
|
676
|
+
if (codeGatePasses(state)) return "implement";
|
|
677
|
+
const unitFailed = unitFailedDimensions(state, "plans", "code-verdicts", PLAN_DIMENSIONS);
|
|
678
|
+
if (unitFailed.length > 0) {
|
|
679
|
+
setRouteNote(codeDemoteRoute, unitFailedNote(unitFailed));
|
|
680
|
+
return "code-snapshot";
|
|
681
|
+
}
|
|
682
|
+
return confirmDue(state, "plans", "code-verdicts", PLAN_DIMENSIONS) ? "code-confirm" : "code-snapshot";
|
|
683
|
+
},
|
|
684
|
+
{ readsData: false },
|
|
685
|
+
);
|
|
686
|
+
|
|
498
687
|
const buildWorkflow = defineWorkflow({
|
|
499
688
|
name: "build",
|
|
500
689
|
description:
|
|
@@ -532,6 +721,10 @@ const buildWorkflow = defineWorkflow({
|
|
|
532
721
|
skill: "grade",
|
|
533
722
|
loop: SLICE_DIMENSION_FANOUT,
|
|
534
723
|
outcome: sliceVerdictOutcome,
|
|
724
|
+
// Whole-lap progress: the slice lane's three re-entered destinations
|
|
725
|
+
// (grade/fix/seed-lift) share ONE hook instance, so every counted
|
|
726
|
+
// re-entry reads the same verdict-channel fold.
|
|
727
|
+
progress: SLICE_PANEL_PROGRESS,
|
|
535
728
|
reads: ["slices"],
|
|
536
729
|
}),
|
|
537
730
|
// Re-cut the slice map from the failing verdicts. Routes through `slice`
|
|
@@ -542,10 +735,27 @@ const buildWorkflow = defineWorkflow({
|
|
|
542
735
|
"slice-fix": produces({
|
|
543
736
|
skill: "slice",
|
|
544
737
|
outcome: rpivBucketOutcome("slices"),
|
|
738
|
+
progress: SLICE_PANEL_PROGRESS,
|
|
545
739
|
reads: ["slices", fanin("slice-verdicts"), fanin("slice-check")],
|
|
546
740
|
}),
|
|
741
|
+
// Deterministic seed lift — the engine-owned half of the cite remedy: a
|
|
742
|
+
// seed-only design-readiness fail (every finding demanding a concrete
|
|
743
|
+
// `requires` citation) is repaired by appending the seeds to the named
|
|
744
|
+
// slices' `Draws on` lines in place, never by a full re-slice + re-grade.
|
|
745
|
+
// Publishes on its OWN stage channel (a script stage cannot carry an
|
|
746
|
+
// outcome; the in-place amend keeps `latestFsArtifact(state, "slices")`
|
|
747
|
+
// resolving the same amended file), then re-enters `slice-check`, whose
|
|
748
|
+
// re-run stamps the cite discharge the gate folds on — no second panel.
|
|
749
|
+
"slice-seed-lift": produces.script({
|
|
750
|
+
reads: ["slices", fanin("slice-verdicts")],
|
|
751
|
+
run: sliceSeedLift,
|
|
752
|
+
progress: SLICE_PANEL_PROGRESS,
|
|
753
|
+
}),
|
|
547
754
|
// Design every slice in parallel.
|
|
548
|
-
|
|
755
|
+
// `designOutcome` derives `filename_slice` beside the frontmatter so the
|
|
756
|
+
// design-slice contract refuses a path whose `_slice-<N>_` token is missing
|
|
757
|
+
// or disagrees with `slice_n` while the lane can still rename it.
|
|
758
|
+
"slice-design": produces({ skill: "design-slice", loop: SLICE_DESIGN_FANOUT, outcome: designOutcome }),
|
|
549
759
|
// One consolidated developer checkpoint over EVERY per-slice design, at the
|
|
550
760
|
// single fan-in seam where they all exist and nothing parallel is running.
|
|
551
761
|
// Presents the proposed shape (interfaces, data types, scope) and lets the
|
|
@@ -585,6 +795,9 @@ const buildWorkflow = defineWorkflow({
|
|
|
585
795
|
skill: "grade",
|
|
586
796
|
loop: PLAN_DIMENSION_FANOUT,
|
|
587
797
|
outcome: planVerdictOutcome,
|
|
798
|
+
// Whole-lap progress: the plan lane's three re-entered destinations
|
|
799
|
+
// (grade/confirm/snapshot) share ONE hook instance — a lap is one unit.
|
|
800
|
+
progress: PLAN_PANEL_PROGRESS,
|
|
588
801
|
// `research` is read so the architecture-fit unit can thread it as
|
|
589
802
|
// --context; `goal` so completeness/correctness anchor on the brief.
|
|
590
803
|
reads: ["plans", "research", "goal", "acceptance"],
|
|
@@ -606,6 +819,7 @@ const buildWorkflow = defineWorkflow({
|
|
|
606
819
|
skill: "grade",
|
|
607
820
|
loop: PLAN_CONFIRM_FANOUT,
|
|
608
821
|
outcome: planVerdictOutcome,
|
|
822
|
+
progress: PLAN_PANEL_PROGRESS,
|
|
609
823
|
reads: ["plans", "research", "goal", "acceptance"],
|
|
610
824
|
}),
|
|
611
825
|
"plan-fix": produces({
|
|
@@ -627,11 +841,16 @@ const buildWorkflow = defineWorkflow({
|
|
|
627
841
|
// rides its stage-name channel, so this publishes to `plan-snapshot`, NOT
|
|
628
842
|
// `plans` — `latestFsArtifact(state, "plans")` still resolves to the real
|
|
629
843
|
// (amended) plan.
|
|
630
|
-
"plan-snapshot": produces.script({ reads: ["plans"], run: planSnapshot }),
|
|
844
|
+
"plan-snapshot": produces.script({ reads: ["plans"], run: planSnapshot, progress: PLAN_PANEL_PROGRESS }),
|
|
631
845
|
// Elaborate implement-ready code into each phase in parallel (fanout),
|
|
632
846
|
// deterministically splice it back into the plan (code-splice), then
|
|
633
847
|
// re-grade the now code-bearing plan — guarding the blind-splice risk.
|
|
634
|
-
code: produces({
|
|
848
|
+
code: produces({
|
|
849
|
+
skill: "elaborate",
|
|
850
|
+
loop: ELABORATE_PHASE_FANOUT,
|
|
851
|
+
reads: ["plans"],
|
|
852
|
+
outcome: elaborationOutcome,
|
|
853
|
+
}),
|
|
635
854
|
"code-splice": acts.script({
|
|
636
855
|
reads: ["plans"],
|
|
637
856
|
run: ({ state, cwd }) => {
|
|
@@ -644,7 +863,16 @@ const buildWorkflow = defineWorkflow({
|
|
|
644
863
|
);
|
|
645
864
|
}
|
|
646
865
|
const planPath = isAbsolute(plan.handle.path) ? plan.handle.path : join(cwd, plan.handle.path);
|
|
647
|
-
|
|
866
|
+
try {
|
|
867
|
+
execFileSync("node", [STITCH_SCRIPT, planPath], { cwd, stdio: ["ignore", "pipe", "pipe"] });
|
|
868
|
+
} catch (err) {
|
|
869
|
+
const stderr = (err as { stderr?: Buffer | string }).stderr?.toString().trim();
|
|
870
|
+
throw haltPreflight(
|
|
871
|
+
"code-splice",
|
|
872
|
+
"code-splice: stitch refused the elaborations",
|
|
873
|
+
stderr || (err instanceof Error ? err.message : String(err)),
|
|
874
|
+
);
|
|
875
|
+
}
|
|
648
876
|
},
|
|
649
877
|
}),
|
|
650
878
|
// Deterministic citation floor over the SPLICED (code-bearing) plan before
|
|
@@ -654,6 +882,9 @@ const buildWorkflow = defineWorkflow({
|
|
|
654
882
|
skill: "grade",
|
|
655
883
|
loop: CODE_DIMENSION_FANOUT,
|
|
656
884
|
outcome: codeVerdictOutcome,
|
|
885
|
+
// Whole-lap progress: the code lane's three re-entered destinations
|
|
886
|
+
// (grade/confirm/snapshot) share ONE hook instance — a lap is one unit.
|
|
887
|
+
progress: CODE_PANEL_PROGRESS,
|
|
657
888
|
// `research` is read so the architecture-fit unit can thread it as
|
|
658
889
|
// --context; `goal` so completeness/correctness anchor on the brief.
|
|
659
890
|
reads: ["plans", "research", "goal", "acceptance"],
|
|
@@ -677,6 +908,7 @@ const buildWorkflow = defineWorkflow({
|
|
|
677
908
|
skill: "grade",
|
|
678
909
|
loop: CODE_CONFIRM_FANOUT,
|
|
679
910
|
outcome: codeVerdictOutcome,
|
|
911
|
+
progress: CODE_PANEL_PROGRESS,
|
|
680
912
|
reads: ["plans", "research", "goal", "acceptance"],
|
|
681
913
|
}),
|
|
682
914
|
"code-fix": produces({
|
|
@@ -692,7 +924,7 @@ const buildWorkflow = defineWorkflow({
|
|
|
692
924
|
// Snapshot the graded plan BEFORE code-fix amends it — the code-gate twin
|
|
693
925
|
// of `plan-snapshot` (code-grade/code-confirm → code-snapshot → code-fix),
|
|
694
926
|
// publishing the prior on the `code-snapshot` channel.
|
|
695
|
-
"code-snapshot": produces.script({ reads: ["plans"], run: codeSnapshot }),
|
|
927
|
+
"code-snapshot": produces.script({ reads: ["plans"], run: codeSnapshot, progress: CODE_PANEL_PROGRESS }),
|
|
696
928
|
implement: acts({ loop: IMPLEMENT_DAG_FANOUT, reads: ["plans"] }),
|
|
697
929
|
// Lane-level scope floor — the structural backstop beneath the quality
|
|
698
930
|
// gates. After the (now concurrent) implement lane lands, judge the working
|
|
@@ -703,21 +935,31 @@ const buildWorkflow = defineWorkflow({
|
|
|
703
935
|
// (threaded via --scope); missing verdict ⇒ STOP. No schema is declared
|
|
704
936
|
// (matching slice-check/plan-cite-check — the route reads the channel).
|
|
705
937
|
// Reads `goal` for the run-start baseline that subtracts pre-existing dirt.
|
|
938
|
+
// On a validate-fix re-entry the floor additionally accepts the latest
|
|
939
|
+
// report's blockers-named writes as declared scope — a validate-fix hop's
|
|
940
|
+
// targeted repair is the one writer the plan cannot declare (it predates
|
|
941
|
+
// the report); fail-closed on missing/older remediation (see
|
|
942
|
+
// validateReportAcceptance).
|
|
706
943
|
"implement-scope-check": produces.script({ reads: ["plans", "goal"], run: implementScopeCheck }),
|
|
707
944
|
// Deterministic remedy arm for the untracked-only tier: move (never
|
|
708
945
|
// delete) run-created untracked excess under .rpiv/tmp/scope-quarantine/
|
|
709
946
|
// and publish a manifest, then re-enter the floor — see scopeQuarantine.
|
|
710
947
|
"scope-quarantine": produces.script({ reads: ["implement-scope-check"], run: scopeQuarantine }),
|
|
711
948
|
// Deterministic post-implement reconciliation (no LLM): applies every
|
|
712
|
-
// `#### Reconciliation` directive (find→replace, write-restricted to
|
|
713
|
-
//
|
|
714
|
-
//
|
|
715
|
-
// needs (a phase's correct change can invalidate a sibling's test, and the
|
|
949
|
+
// `#### Reconciliation` directive (find→replace, write-restricted to the
|
|
950
|
+
// plan's declared write-set), fail-soft — a coherence backstop the parallel
|
|
951
|
+
// implement lane needs (a phase's correct change can invalidate a sibling's test, and the
|
|
716
952
|
// combined tree can break in ways no single phase's checks surface). Pass ⇒
|
|
717
|
-
// validate; fail
|
|
718
|
-
// run-start goal baseline (the scope
|
|
719
|
-
//
|
|
953
|
+
// validate; fail ⇒ the reconcile-fix arm (see reconcileGate); missing ⇒
|
|
954
|
+
// STOP. `reads: ["plans"]` only — no run-start goal baseline (the scope
|
|
955
|
+
// floor already proved the write-set).
|
|
720
956
|
reconcile: produces.script({ reads: ["plans"], run: reconcile }),
|
|
957
|
+
// Repair arm for the reconciliation gate: /skill:amend over the plan's
|
|
958
|
+
// directives from the reconcile verdict (a prompt stage — see
|
|
959
|
+
// RECONCILE_FIX_PROMPT), re-emitting the plan latest-wins, then back
|
|
960
|
+
// through reconcile to apply. Bounded by the runner's per-destination
|
|
961
|
+
// backward-jump budget (the plan-fix precedent).
|
|
962
|
+
"reconcile-fix": produces.prompt({ prompt: RECONCILE_FIX_PROMPT, outcome: RECONCILE_FIX_OUTCOME }),
|
|
721
963
|
validate: produces({ prompt: VALIDATE_GOAL_PROMPT }),
|
|
722
964
|
// Repair arm the validate gate dispatches on a remediable `verdict: "fail"`.
|
|
723
965
|
// `acts()` (not `produces()`) because remediate is `side-effect`/`code-mutation`
|
|
@@ -747,34 +989,50 @@ const buildWorkflow = defineWorkflow({
|
|
|
747
989
|
// already passes, so re-grading would only re-roll a flappy judgment. Also
|
|
748
990
|
// skips after a fix for a `remedy: "cite"` fail once `slice-check` has
|
|
749
991
|
// deterministically verified the demanded seeds landed on a structurally
|
|
750
|
-
// unchanged map (the `citeDischarged` stamp — see `citeRemedyDischarged`)
|
|
751
|
-
//
|
|
992
|
+
// unchanged map (the `citeDischarged` stamp — see `citeRemedyDischarged`),
|
|
993
|
+
// and after a seed lift for the same reason.
|
|
994
|
+
// First pass (no verdict yet) ⇒ not satisfied ⇒ into `slice-grade`. A
|
|
995
|
+
// seed lift that already ran and left the gate red is STUCK — re-grading
|
|
996
|
+
// or re-lifting cannot change the outcome — so the fail branch routes
|
|
997
|
+
// the structural fix arm BEFORE the re-grade fallthrough.
|
|
752
998
|
"slice-check": defineRoute(
|
|
753
|
-
["slice-design", "slice-grade"],
|
|
754
|
-
({ state }) => (sliceGatePasses(state) ? "slice-design" : "slice-grade"),
|
|
755
|
-
{ readsData: false },
|
|
756
|
-
),
|
|
757
|
-
// Design-readiness gate BEFORE any design. Structure + design-readiness pass⇒ design; any fails ⇒
|
|
758
|
-
// slice-fix and loop back. Bounded by the runner's maxBackwardJumps (default 3).
|
|
759
|
-
"slice-grade": defineRoute(
|
|
760
|
-
["slice-design", "slice-fix"],
|
|
761
|
-
({ state }) => (sliceGatePasses(state) ? "slice-design" : "slice-fix"),
|
|
999
|
+
["slice-design", "slice-fix", "slice-grade"],
|
|
1000
|
+
({ state }) => (sliceGatePasses(state) ? "slice-design" : seedLiftStuck(state) ? "slice-fix" : "slice-grade"),
|
|
762
1001
|
{ readsData: false },
|
|
763
1002
|
),
|
|
1003
|
+
// Design-readiness gate BEFORE any design. Structure + design-readiness pass ⇒
|
|
1004
|
+
// design; a SEED-ONLY cite fail (every finding naming a concrete seed to add) ⇒
|
|
1005
|
+
// the deterministic `slice-seed-lift` arm, which appends the seeds and re-enters
|
|
1006
|
+
// `slice-check` for the discharge stamp — a full re-slice + re-grade for pure
|
|
1007
|
+
// citation bookkeeping repairs nothing the verdict flagged; anything else ⇒
|
|
1008
|
+
// slice-fix and loop back. (A dimension whose re-dispatch produced no verdict
|
|
1009
|
+
// takes the fix arm ahead of the seed-only check — a verdict-less dead
|
|
1010
|
+
// dimension is never seed-only.) Bounded by the runner's maxBackwardJumps
|
|
1011
|
+
// (default 3) under the absolute per-stage maxLaps ceiling (default 8;
|
|
1012
|
+
// both budgets fresh per invocation — a resume re-opens the loop).
|
|
1013
|
+
"slice-grade": sliceGradeRoute,
|
|
764
1014
|
"slice-fix": "slice-check",
|
|
1015
|
+
// Deterministic re-entry after the seed lift: the re-run structure check
|
|
1016
|
+
// stamps the discharge the gate folds on (a plain string edge — the
|
|
1017
|
+
// counted decision is the slice-grade route's lift pick).
|
|
1018
|
+
"slice-seed-lift": "slice-check",
|
|
765
1019
|
// Design fanout → consolidated human checkpoint → hierarchical synthesis.
|
|
766
1020
|
"slice-design": "design-review",
|
|
767
1021
|
"design-review": "subplan",
|
|
768
1022
|
// Route the cluster fanout through the deterministic coverage floor before
|
|
769
1023
|
// the root merge — the twin of `slice → slice-check`. A pass folds straight
|
|
770
1024
|
// to `plan`; a lost/clobbered cluster routes the backward edge to `subplan`,
|
|
771
|
-
// bounded by the runner's maxBackwardJumps
|
|
1025
|
+
// bounded by the runner's maxBackwardJumps (default 3) under the absolute
|
|
1026
|
+
// per-stage maxLaps ceiling (default 8; both budgets fresh per invocation
|
|
1027
|
+
// — a resume re-opens the loop).
|
|
772
1028
|
subplan: "subplan-check",
|
|
773
1029
|
// Subplan coverage gate. Pass ⇒ root merge. A fail (lost cluster, clobbered
|
|
774
1030
|
// ordinal, tokenless basename, or a slice design absent from every sources:)
|
|
775
1031
|
// routes the backward edge to `subplan` — re-dispatch the cluster fanout,
|
|
776
1032
|
// which re-supplies each cluster's '--cluster <k>'. Bounded by the runner's
|
|
777
|
-
// maxBackwardJumps
|
|
1033
|
+
// maxBackwardJumps (default 3) under the absolute per-stage maxLaps ceiling
|
|
1034
|
+
// (default 8; both budgets fresh per invocation — a resume re-opens the
|
|
1035
|
+
// loop). `readsData: false` — the route consults only the
|
|
778
1036
|
// deterministic verdict channel (mirrors the slice-check/plan-cite-check routes).
|
|
779
1037
|
"subplan-check": defineRoute(
|
|
780
1038
|
["plan", "subplan"],
|
|
@@ -808,16 +1066,7 @@ const buildWorkflow = defineWorkflow({
|
|
|
808
1066
|
// plan-fix, looping back THROUGH the citation floor so the amended plan
|
|
809
1067
|
// re-verifies. Route logic unchanged — merely shifted one hop later so the
|
|
810
1068
|
// demote write-back precedes it.
|
|
811
|
-
"plan-demote":
|
|
812
|
-
["code", "plan-confirm", "plan-snapshot"],
|
|
813
|
-
({ state }) =>
|
|
814
|
-
planGatePasses(state)
|
|
815
|
-
? "code"
|
|
816
|
-
: confirmDue(state, "plans", "plan-verdicts", PLAN_DIMENSIONS)
|
|
817
|
-
? "plan-confirm"
|
|
818
|
-
: "plan-snapshot",
|
|
819
|
-
{ readsData: false },
|
|
820
|
-
),
|
|
1069
|
+
"plan-demote": planDemoteRoute,
|
|
821
1070
|
// After the second judgment the gate re-folds on the latest verdicts: a
|
|
822
1071
|
// confirming pass overwrote the flap and clears the gate; a confirming
|
|
823
1072
|
// fail routes to the fix with two agreeing judgments behind it.
|
|
@@ -851,17 +1100,10 @@ const buildWorkflow = defineWorkflow({
|
|
|
851
1100
|
// back to `code`: the gate fails on plan-text defects (edit anchors, line
|
|
852
1101
|
// citations, naming) that a per-phase code rewrite cannot reach, so the
|
|
853
1102
|
// surgical arm is the one with authority over them. Route logic unchanged —
|
|
854
|
-
// merely shifted one hop later. Bounded by the runner's maxBackwardJumps
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
codeGatePasses(state)
|
|
859
|
-
? "implement"
|
|
860
|
-
: confirmDue(state, "plans", "code-verdicts", PLAN_DIMENSIONS)
|
|
861
|
-
? "code-confirm"
|
|
862
|
-
: "code-snapshot",
|
|
863
|
-
{ readsData: false },
|
|
864
|
-
),
|
|
1103
|
+
// merely shifted one hop later. Bounded by the runner's maxBackwardJumps
|
|
1104
|
+
// (default 3) under the absolute per-stage maxLaps ceiling (default 8;
|
|
1105
|
+
// both budgets fresh per invocation — a resume re-opens the loop).
|
|
1106
|
+
"code-demote": codeDemoteRoute,
|
|
865
1107
|
"code-confirm": defineRoute(
|
|
866
1108
|
["implement", "code-snapshot"],
|
|
867
1109
|
({ state }) => (codeGatePasses(state) ? "implement" : "code-snapshot"),
|
|
@@ -876,22 +1118,28 @@ const buildWorkflow = defineWorkflow({
|
|
|
876
1118
|
// validate adjudicates them via the --scope thread — the citation floor's
|
|
877
1119
|
// demote-and-adjudicate precedent); untracked-only ⇒ the deterministic
|
|
878
1120
|
// scope-quarantine arm; a missing/corrupt verdict ⇒ STOP (integrity
|
|
879
|
-
// clause).
|
|
1121
|
+
// clause). The excess pick attaches the pass-through note naming validate
|
|
1122
|
+
// (the recap's routingNotes surface the deferral). Sourced from the
|
|
1123
|
+
// scope-check's published verdict channel (the
|
|
880
1124
|
// stage key for an outcome-less `produces.script`, per
|
|
881
1125
|
// `resolvePublishName`); `readsData: false` suppresses the outputSchema lint.
|
|
882
|
-
"implement-scope-check": scopeFloorGate(),
|
|
1126
|
+
"implement-scope-check": scopeFloorGate({ deferredTo: "validate" }),
|
|
883
1127
|
// Deterministic re-entry after the quarantine arm: a plain string edge
|
|
884
1128
|
// (non-counted, mirroring validate-fix's hop) with guaranteed progress —
|
|
885
1129
|
// quarantined paths leave the dirty set, so the re-check either passes or
|
|
886
1130
|
// reveals tracked drift. At most one quarantine hop per gate entry; no new
|
|
887
1131
|
// loop budget.
|
|
888
1132
|
"scope-quarantine": "implement-scope-check",
|
|
889
|
-
// Reconciliation gate. Pass ⇒ validate; a `fail` (
|
|
890
|
-
//
|
|
891
|
-
// arm
|
|
892
|
-
//
|
|
893
|
-
// `verdict: "pass"`.
|
|
894
|
-
reconcile:
|
|
1133
|
+
// Reconciliation gate. Pass ⇒ validate; a `fail` (malformed directive /
|
|
1134
|
+
// absent find / non-test target — all plan-TEXT defects) ⇒ the
|
|
1135
|
+
// reconcile-fix amend arm; a missing verdict ⇒ STOP (integrity clause).
|
|
1136
|
+
// Safe by construction: the sole path onward to validate is an explicit
|
|
1137
|
+
// `verdict: "pass"`.
|
|
1138
|
+
reconcile: reconcileGate(),
|
|
1139
|
+
// Deterministic re-entry after the amend arm: reconcile re-parses the
|
|
1140
|
+
// repaired directives and applies them (a plain string edge — the
|
|
1141
|
+
// counted decision is the gate's reconcile-fix pick).
|
|
1142
|
+
"reconcile-fix": "reconcile",
|
|
895
1143
|
// Gate commit on validate's own verdict — see `validateGate`. `pass` ⇒
|
|
896
1144
|
// commit; a `fail` WITH remediable handles (a `pass: false` risk ruling or a
|
|
897
1145
|
// structured `blockers:` entry) ⇒ validate-fix, which re-enters at
|
|
@@ -922,7 +1170,8 @@ const buildWorkflow = defineWorkflow({
|
|
|
922
1170
|
* edges attach their own no-match diagnostics; only these two `defineRoute`
|
|
923
1171
|
* gates would otherwise stop silently. Best-effort DIAGNOSTICS, not gates:
|
|
924
1172
|
* `allDimensionsPass`/`shipGatePasses` stay the sole routing authorities, and
|
|
925
|
-
* these
|
|
1173
|
+
* these consult the shared `verdictBlocks` predicate — the same fold those
|
|
1174
|
+
* gates route on — only to NAME the blockers.
|
|
926
1175
|
*/
|
|
927
1176
|
const shipCiteStopNote = (state: RunView): string => {
|
|
928
1177
|
const data = state.named["plan-cite-check"]?.at(-1)?.data as { findings?: unknown } | undefined;
|
|
@@ -934,6 +1183,11 @@ const shipCiteStopNote = (state: RunView): string => {
|
|
|
934
1183
|
return n > 0 ? `plan citation check failed (${n} finding${n === 1 ? "" : "s"})` : "plan citation check failed";
|
|
935
1184
|
};
|
|
936
1185
|
const shipGradeStopNote = (state: RunView): string => {
|
|
1186
|
+
// A dead grade unit (post-re-dispatch) is the loudest blocker — name it
|
|
1187
|
+
// ahead of the severity blockers (ship's arm is stop + hand-repair +
|
|
1188
|
+
// resume, so the note IS the repair instruction).
|
|
1189
|
+
const unitFailed = unitFailedDimensions(state, "plans", "ship-verdicts", SHIP_DIMENSIONS);
|
|
1190
|
+
if (unitFailed.length > 0) return unitFailedNote(unitFailed);
|
|
937
1191
|
const fresh = freshVerdicts(state.named["ship-verdicts"], latestArtifactPath(state, "plans"));
|
|
938
1192
|
if (fresh.length === 0) return "no fresh verdicts for the current plan";
|
|
939
1193
|
const risks = planAuthoredRisks(state, "plans");
|
|
@@ -942,9 +1196,8 @@ const shipGradeStopNote = (state: RunView): string => {
|
|
|
942
1196
|
for (const d of SHIP_DIMENSIONS) {
|
|
943
1197
|
const o = latest.get(d);
|
|
944
1198
|
if (!o) continue;
|
|
945
|
-
const v = o.data as
|
|
946
|
-
|
|
947
|
-
if (!floored) blockers.push(`${d} failed (${v.severity ?? "unrated"})`);
|
|
1199
|
+
const v = o.data as VerdictRecord | undefined;
|
|
1200
|
+
if (verdictBlocks(v)) blockers.push(`${d} failed (${v?.severity ?? "unrated"})`);
|
|
948
1201
|
else if (verdictRiskRulings(o).some((r) => !rulingEffectivePass(r, risks.get(r.id))))
|
|
949
1202
|
blockers.push(`${d} risk flag failed`);
|
|
950
1203
|
}
|
|
@@ -1010,7 +1263,7 @@ const shipGradeGate: EdgeFn = defineRoute(
|
|
|
1010
1263
|
const shipWorkflow = defineWorkflow({
|
|
1011
1264
|
name: "ship",
|
|
1012
1265
|
description:
|
|
1013
|
-
"Ship, unsliced: capture the verbatim brief as a goal artifact → ground it with a brief-sized research pass (none or one verify-only codebase-analyzer dispatch when the brief names root cause, files, or fix; at most two targeted dispatches otherwise — no /skill:research) → derive a goal-anchored acceptance inventory (the executable standard of completion, frozen before planning; quick-plan records a per-item disposition, the completeness gate anchors on it, validate executes its evidence commands) → one lightweight quick-plan pass → deterministic citation floor (files: coverage gaps stop; citation-resolution findings are advisory and adjudicated by the grade panel) → single tier-independent quality gate (correctness/completeness/architecture-fit, stop-on-fail) → implement → implement-scope-check → reconcile → validate → commit. Every gate halts the run on fail (hand-repair, then resume with /wf @<runId> to re-run the gate) — except a validate fail carrying structured remediable handles, which buys ONE bounded remediation hop before halting.",
|
|
1266
|
+
"Ship, unsliced: capture the verbatim brief as a goal artifact → ground it with a brief-sized research pass (none or one verify-only codebase-analyzer dispatch when the brief names root cause, files, or fix; at most two targeted dispatches otherwise — no /skill:research) → derive a goal-anchored acceptance inventory (the executable standard of completion, frozen before planning; quick-plan records a per-item disposition, the completeness gate anchors on it, validate executes its evidence commands) → one lightweight quick-plan pass → deterministic citation floor (files: coverage gaps stop; citation-resolution findings are advisory and adjudicated by the grade panel) → single tier-independent quality gate (correctness/completeness/architecture-fit, stop-on-fail) → implement → implement-scope-check → reconcile → validate → commit. Every gate halts the run on fail (hand-repair, then resume with /wf @<runId> to re-run the gate) — except a reconcile fail (a plan-text directive defect), which buys ONE bounded amend hop over the plan's directives, and a validate fail carrying structured remediable handles, which buys ONE bounded remediation hop before halting.",
|
|
1014
1267
|
start: "goal",
|
|
1015
1268
|
stages: {
|
|
1016
1269
|
// build's verbatim goal capture — the brief on its own channel, plus the
|
|
@@ -1067,6 +1320,10 @@ const shipWorkflow = defineWorkflow({
|
|
|
1067
1320
|
skill: "grade",
|
|
1068
1321
|
loop: SHIP_DIMENSION_FANOUT,
|
|
1069
1322
|
outcome: shipVerdictOutcome,
|
|
1323
|
+
// Whole-lap progress: declared for uniformity — ship's grade gate
|
|
1324
|
+
// routes implement or stop, so no edge ever re-enters this stage and
|
|
1325
|
+
// the hook never fires.
|
|
1326
|
+
progress: SHIP_PANEL_PROGRESS,
|
|
1070
1327
|
reads: ["plans", "research", "goal", "acceptance"],
|
|
1071
1328
|
}),
|
|
1072
1329
|
// Dep-gated DAG implement — build's lane verbatim.
|
|
@@ -1074,10 +1331,21 @@ const shipWorkflow = defineWorkflow({
|
|
|
1074
1331
|
// Lane-level scope floor — build's latest-only variant (vet uses the
|
|
1075
1332
|
// union variant for its fix loop; ship has no loop, so the latest plan's
|
|
1076
1333
|
// declared write-set is the whole contract). Pass ⇒ reconcile; fail ⇒ STOP.
|
|
1334
|
+
// The shared run function carries the validate-report acceptance: a
|
|
1335
|
+
// validate-fix hop's blocker-named writes are accepted as declared scope
|
|
1336
|
+
// (fail-closed on missing/older remediation) — ship's single bounded
|
|
1337
|
+
// validate-fix hop re-enters here, landing exactly that shape.
|
|
1077
1338
|
"implement-scope-check": produces.script({ reads: ["plans", "goal"], run: implementScopeCheck }),
|
|
1078
1339
|
// Deterministic post-implement reconciliation — build's run-function
|
|
1079
|
-
// verbatim. Pass ⇒ validate; fail
|
|
1340
|
+
// verbatim. Pass ⇒ validate; fail ⇒ ONE bounded reconcile-fix hop
|
|
1341
|
+
// (maxFixRounds: 1 — the validate-gate concession's twin); missing ⇒ STOP.
|
|
1080
1342
|
reconcile: produces.script({ reads: ["plans"], run: reconcile }),
|
|
1343
|
+
// Repair arm — build's prompt stage verbatim; ship's reconcile gate
|
|
1344
|
+
// dispatches it at most ONCE. Kept despite the stop-on-fail identity for
|
|
1345
|
+
// the same reason as validate-fix: a reconcile fail is a plan-TEXT defect
|
|
1346
|
+
// a hand-repair of the TREE can never clear, so the terminal stop was
|
|
1347
|
+
// unresumable without hand-editing the plan artifact.
|
|
1348
|
+
"reconcile-fix": produces.prompt({ prompt: RECONCILE_FIX_PROMPT, outcome: RECONCILE_FIX_OUTCOME }),
|
|
1081
1349
|
validate: produces({ prompt: VALIDATE_GOAL_PROMPT }),
|
|
1082
1350
|
// Repair arm — build's stage verbatim; ship's validate gate dispatches it
|
|
1083
1351
|
// at most ONCE (maxFixRounds: 1). Kept because the terminal gate is where
|
|
@@ -1106,9 +1374,15 @@ const shipWorkflow = defineWorkflow({
|
|
|
1106
1374
|
// the stage's own channel via the `from` form (suppresses the READS_DATA
|
|
1107
1375
|
// outputSchema lint).
|
|
1108
1376
|
"implement-scope-check": match("verdict", { reconcile: "pass" }, { from: "implement-scope-check" }),
|
|
1109
|
-
// Reconciliation gate — build's route
|
|
1110
|
-
//
|
|
1111
|
-
reconcile
|
|
1377
|
+
// Reconciliation gate — build's route, capped at ONE amend round (the
|
|
1378
|
+
// reconcile channel's entry count IS the rounds spent): pass ⇒ validate;
|
|
1379
|
+
// first fail ⇒ reconcile-fix; a fail after the spent round, or a missing
|
|
1380
|
+
// verdict ⇒ STOP with a route note naming the plan artifact as the
|
|
1381
|
+
// repair site.
|
|
1382
|
+
reconcile: reconcileGate({ maxFixRounds: 1 }),
|
|
1383
|
+
// Re-entry after the amend arm — reconcile re-parses and applies the
|
|
1384
|
+
// repaired directives; the spent round now stops any remaining fail.
|
|
1385
|
+
"reconcile-fix": "reconcile",
|
|
1112
1386
|
// Validate gate — build's classifying gate, capped at ONE remediation
|
|
1113
1387
|
// round: `pass` ⇒ commit; a `fail` WITH structured remediable handles and
|
|
1114
1388
|
// no remediation spent ⇒ validate-fix; every other fail (prose-only, or
|