@juicesharp/rpiv-pi 2.7.0 → 2.8.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/README.md +2 -2
- package/docs/architecture.md +3 -3
- package/docs/skills.md +9 -7
- package/docs/workflows.md +3 -3
- package/extensions/rpiv-core/built-in-workflows.ts +273 -94
- package/extensions/rpiv-core/built-ins/gates.ts +38 -15
- package/extensions/rpiv-core/built-ins/goal-baseline.ts +43 -1
- package/extensions/rpiv-core/built-ins/grade-panel.ts +98 -29
- package/extensions/rpiv-core/built-ins/index.ts +2 -0
- package/extensions/rpiv-core/built-ins/priors.ts +208 -38
- package/extensions/rpiv-core/built-ins/remediation.ts +96 -0
- package/extensions/rpiv-core/built-ins/slices.ts +5 -1
- package/extensions/rpiv-core/lane-relay-ui.ts +25 -1
- package/extensions/rpiv-core/outcome-derivation.ts +1 -0
- package/extensions/rpiv-core/pipeline-pointer.ts +1 -1
- package/package.json +3 -3
- package/skills/acceptance/SKILL.md +123 -0
- package/skills/grade/SKILL.md +5 -4
- package/skills/quick-plan/SKILL.md +19 -2
- package/skills/remediate/SKILL.md +17 -15
- package/skills/research/SKILL.md +27 -0
- package/skills/slice/SKILL.md +2 -2
- package/skills/validate/SKILL.md +11 -4
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
latestVerdictPerDimension,
|
|
19
19
|
planAuthoredRisks,
|
|
20
20
|
procedureSatisfiesDuty,
|
|
21
|
+
type RiskRecord,
|
|
21
22
|
rulingEffectivePass,
|
|
22
23
|
verdictRiskRulings,
|
|
23
24
|
} from "./gates.js";
|
|
@@ -186,16 +187,31 @@ const sectionIndexOf = (lines: readonly string[]): string[] => {
|
|
|
186
187
|
const idx = new Array<string>(lines.length);
|
|
187
188
|
let current = "";
|
|
188
189
|
let inFrontmatter = lines[0]?.trim() === "---";
|
|
190
|
+
let inFence = false;
|
|
189
191
|
for (let i = 0; i < lines.length; i++) {
|
|
190
192
|
if (inFrontmatter) {
|
|
191
193
|
idx[i] = "frontmatter";
|
|
192
194
|
if (i > 0 && lines[i].trim() === "---") inFrontmatter = false;
|
|
193
195
|
continue;
|
|
194
196
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
197
|
+
// Fence-aware: a `## ` line INSIDE a fenced code block is content, not a
|
|
198
|
+
// heading — build plans routinely embed markdown edits (a CHANGELOG
|
|
199
|
+
// snippet's `## [Unreleased]`), and keying those as sections
|
|
200
|
+
// manufactured phantom touched keys no finding could ever cite
|
|
201
|
+
// (observed live: run b307's code-fix went broad on the phantom
|
|
202
|
+
// `[unreleased]` from an embedded changelog block). Fenced lines
|
|
203
|
+
// attribute to the enclosing section.
|
|
204
|
+
if (/^\s*```/.test(lines[i])) {
|
|
205
|
+
inFence = !inFence;
|
|
206
|
+
idx[i] = current;
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
if (!inFence) {
|
|
210
|
+
const m = /^##\s+(.*)$/.exec(lines[i]);
|
|
211
|
+
if (m) {
|
|
212
|
+
const ph = /^Phase\s+(\d+)/i.exec(m[1].trim());
|
|
213
|
+
current = ph ? `phase ${ph[1]}` : m[1].trim().toLowerCase();
|
|
214
|
+
}
|
|
199
215
|
}
|
|
200
216
|
idx[i] = current;
|
|
201
217
|
}
|
|
@@ -254,27 +270,78 @@ const sectionDiff = (prior: string, current: string): { touchedSections: Set<str
|
|
|
254
270
|
};
|
|
255
271
|
|
|
256
272
|
/**
|
|
257
|
-
* Plan sections cited by the FAILING dimensions'
|
|
258
|
-
*
|
|
259
|
-
* `
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
*
|
|
263
|
-
*
|
|
273
|
+
* Plan sections cited by the FAILING dimensions' verdicts, from THREE sources:
|
|
274
|
+
*
|
|
275
|
+
* 1. `Phase N` mentions anywhere in a finding's `where` or `detail`
|
|
276
|
+
* (`phase N`, the original extraction).
|
|
277
|
+
* 2. The `where`'s LEADING SEGMENT as a section heading: the grade skill's
|
|
278
|
+
* `where` convention is "`path:line` or a section heading", and panel
|
|
279
|
+
* wheres read "## Phase 1 > Success Criteria > …" — the text before the
|
|
280
|
+
* first `>` names the plan section, normalized exactly as
|
|
281
|
+
* `sectionIndexOf` keys it (leading `#`s stripped, `Phase N …` →
|
|
282
|
+
* `phase N`, else lowercased). A repo path (a `/` or a `.ext:NN` tail)
|
|
283
|
+
* is a code cite, never a plan section. Before this, `citedSections`
|
|
284
|
+
* could ONLY emit `phase N` keys while `touchedSections` emits every
|
|
285
|
+
* heading key — so a finding citing "Out of Scope" or "Risk Flags"
|
|
286
|
+
* contributed nothing and any amend touching those sections was
|
|
287
|
+
* structurally guaranteed non-surgical (the observed always-broad).
|
|
288
|
+
* 3. Failing risk RULINGS (the reason correctness re-grades when findings
|
|
289
|
+
* are empty): a ruling's repair edits the plan's `## Risk Flags` entry
|
|
290
|
+
* and, for a `verify-at-implement` deferral, the owner phase — cite
|
|
291
|
+
* both, so a risk-driven fix loop is not broad by construction.
|
|
292
|
+
*
|
|
293
|
+
* Still fail-closed: an empty cite set against any non-housekeeping touched
|
|
294
|
+
* section stays out-of-scope (non-surgical).
|
|
264
295
|
*/
|
|
265
|
-
const citedSections = (
|
|
296
|
+
const citedSections = (
|
|
297
|
+
latest: ReadonlyMap<string, Output>,
|
|
298
|
+
pending: readonly string[],
|
|
299
|
+
risks: ReadonlyMap<string, RiskRecord>,
|
|
300
|
+
): Set<string> => {
|
|
266
301
|
const cited = new Set<string>();
|
|
302
|
+
const addHeading = (raw: string): void => {
|
|
303
|
+
const cleaned = raw.replace(/^#+\s*/, "").trim();
|
|
304
|
+
if (cleaned.length === 0) return;
|
|
305
|
+
const ph = /^Phase\s+(\d+)/i.exec(cleaned);
|
|
306
|
+
if (ph) {
|
|
307
|
+
cited.add(`phase ${ph[1]}`);
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
// A code cite, not a section: a tight path segment (`a/b`) or an
|
|
311
|
+
// `ext:NN` tail. A SPACED slash is prose punctuation ("Synthesis Notes
|
|
312
|
+
// / 'Adopted rider' bullet" — run d5a9), not a path.
|
|
313
|
+
if (/\S\/\S/.test(cleaned) || /\.\w+:\d+/.test(cleaned)) return;
|
|
314
|
+
cited.add(headingCore(cleaned).toLowerCase());
|
|
315
|
+
};
|
|
267
316
|
for (const d of pending) {
|
|
268
|
-
const
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
317
|
+
const o = latest.get(d);
|
|
318
|
+
const findings = (o?.data as { findings?: unknown } | undefined)?.findings;
|
|
319
|
+
if (Array.isArray(findings)) {
|
|
320
|
+
for (const f of findings) {
|
|
321
|
+
if (f == null || typeof f !== "object") continue;
|
|
322
|
+
const where = typeof (f as { where?: unknown }).where === "string" ? (f as { where: string }).where : "";
|
|
323
|
+
const detail =
|
|
324
|
+
typeof (f as { detail?: unknown }).detail === "string" ? (f as { detail: string }).detail : "";
|
|
325
|
+
for (const text of [where, detail]) {
|
|
326
|
+
for (const m of text.matchAll(/Phase\s+(\d+)/gi)) cited.add(`phase ${m[1]}`);
|
|
327
|
+
// A `## Heading` mention ANYWHERE in the finding cites that
|
|
328
|
+
// section — the observed shape (opendots run d5a9) is a
|
|
329
|
+
// completeness finding whose remedy is CREATING a section,
|
|
330
|
+
// named only in a parenthetical ("... (missing ## Whole-Plan
|
|
331
|
+
// Verification section)"): the amend's creation of that very
|
|
332
|
+
// section must count as cited.
|
|
333
|
+
for (const m of text.matchAll(/##\s+([A-Za-z][^#>\n]*)/g)) addHeading(m[1]);
|
|
334
|
+
}
|
|
335
|
+
addHeading(where.split(">")[0] ?? "");
|
|
276
336
|
}
|
|
277
337
|
}
|
|
338
|
+
if (!o) continue;
|
|
339
|
+
for (const r of verdictRiskRulings(o)) {
|
|
340
|
+
if (rulingEffectivePass(r, risks.get(r.id))) continue;
|
|
341
|
+
cited.add("risk flags");
|
|
342
|
+
const owner = risks.get(r.id)?.owner;
|
|
343
|
+
if (typeof owner === "number") cited.add(`phase ${owner}`);
|
|
344
|
+
}
|
|
278
345
|
}
|
|
279
346
|
return cited;
|
|
280
347
|
};
|
|
@@ -308,45 +375,148 @@ const latestPriorContent = (state: RunView, priorChannel: string, cwd: string):
|
|
|
308
375
|
};
|
|
309
376
|
|
|
310
377
|
/**
|
|
311
|
-
*
|
|
312
|
-
*
|
|
313
|
-
*
|
|
314
|
-
*
|
|
315
|
-
*
|
|
316
|
-
*
|
|
317
|
-
* when a prior is present, or carries forward when none is). `pending` is
|
|
318
|
-
* consumed as-is: whatever `dimensionsToRegrade` ruled still-blocking (after
|
|
319
|
-
* phase 3's `rulingEffectivePass` clause-3 rewrite) is the set this guard
|
|
320
|
-
* narrows on.
|
|
378
|
+
* The heading CORE of a section reference — the text before the first
|
|
379
|
+
* descriptor separator (an em/en-dash clause, a spaced slash, a
|
|
380
|
+
* parenthetical). Real headings and finding wheres both carry descriptor
|
|
381
|
+
* suffixes ("Whole-Plan Verification (owned by validate — not any phase)",
|
|
382
|
+
* "Synthesis Notes — 'Adopted rider' bullet"); the core is the comparable
|
|
383
|
+
* identity.
|
|
321
384
|
*/
|
|
322
|
-
const
|
|
385
|
+
const headingCore = (s: string): string => s.split(/ \(|\s+—\s+|\s+–\s+|\s+\/\s+/)[0]?.trim() ?? s;
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* True when a touched section is covered by the cite set. `phase N` keys
|
|
389
|
+
* match EXACTLY (prefix matching would let "phase 1" cover "phase 10").
|
|
390
|
+
* Non-phase keys match on a word-boundary PREFIX in EITHER direction —
|
|
391
|
+
* observed both ways in run d5a9: a cited where carries a descriptor suffix
|
|
392
|
+
* ("synthesis notes — 'adopted rider' bullet") that must cover the bare
|
|
393
|
+
* touched heading key ("synthesis notes"), and a real heading carries its own
|
|
394
|
+
* suffix ("whole-plan verification (owned by validate — not any phase)") that
|
|
395
|
+
* a bare cite ("whole-plan verification") must cover. The boundary check
|
|
396
|
+
* (the next character must not be alphanumeric) keeps "notes" from covering
|
|
397
|
+
* "notes-extra".
|
|
398
|
+
*/
|
|
399
|
+
const sectionCovered = (section: string, cited: ReadonlySet<string>): boolean => {
|
|
400
|
+
if (cited.has(section)) return true;
|
|
401
|
+
if (/^phase \d+$/.test(section)) return false; // phase keys are exact-only
|
|
402
|
+
const core = headingCore(section);
|
|
403
|
+
const boundary = (long: string, short: string): boolean =>
|
|
404
|
+
short.length > 0 &&
|
|
405
|
+
long.startsWith(short) &&
|
|
406
|
+
(long.length === short.length || !/[a-z0-9]/i.test(long[short.length] ?? ""));
|
|
407
|
+
for (const c of cited) {
|
|
408
|
+
if (/^phase \d+$/.test(c)) continue;
|
|
409
|
+
if (boundary(c, section) || boundary(section, c) || boundary(c, core) || boundary(core, c)) return true;
|
|
410
|
+
}
|
|
411
|
+
return false;
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
/** The surgical-fix guard's decision, with the condition that decided it. */
|
|
415
|
+
interface SurgicalDecision {
|
|
416
|
+
surgical: boolean;
|
|
417
|
+
/** Prose naming the deciding condition — the instrumentation channel. */
|
|
418
|
+
reason: string;
|
|
419
|
+
changedLines?: number;
|
|
420
|
+
touchedSections?: string[];
|
|
421
|
+
citedSections?: string[];
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* Persist the guard's decision beside the prior sidecar as
|
|
426
|
+
* `<plan-basename>.decision.json` — the instrumentation the always-broad
|
|
427
|
+
* diagnosis lacked: real runs showed every observed fix loop re-grading the
|
|
428
|
+
* full roster, and the surviving artifacts could not say WHICH fail-closed
|
|
429
|
+
* condition tripped (the plan file is later mutated by splice/reconcile, so
|
|
430
|
+
* the decision is unreplayable post-hoc). Best-effort and idempotent: the
|
|
431
|
+
* guard is called from a fanout `units()` fn, which the resume fold re-runs
|
|
432
|
+
* under THE REPLAY CONTRACT — same replayed inputs ⇒ same bytes ⇒ the rewrite
|
|
433
|
+
* is a no-op; a write failure never affects the decision.
|
|
434
|
+
*/
|
|
435
|
+
const recordDecision = (cwd: string, target: string, decision: SurgicalDecision): void => {
|
|
436
|
+
try {
|
|
437
|
+
mkdirSync(join(cwd, PRIOR_DIR), { recursive: true });
|
|
438
|
+
writeFileSync(join(cwd, PRIOR_DIR, `${basename(target)}.decision.json`), JSON.stringify(decision, null, 2));
|
|
439
|
+
} catch {
|
|
440
|
+
// instrumentation only — never let a write failure change the routing
|
|
441
|
+
}
|
|
442
|
+
};
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* The guard body — every missing signal collapses to non-surgical with a
|
|
446
|
+
* `reason` naming the condition (see `isSurgicalFix` for the contract).
|
|
447
|
+
*/
|
|
448
|
+
const decideSurgicalFix = (
|
|
323
449
|
state: RunView,
|
|
324
450
|
priorChannel: string,
|
|
325
451
|
cwd: string,
|
|
326
452
|
target: string,
|
|
327
453
|
latest: ReadonlyMap<string, Output>,
|
|
328
454
|
pending: readonly string[],
|
|
329
|
-
|
|
455
|
+
risks: ReadonlyMap<string, RiskRecord>,
|
|
456
|
+
): SurgicalDecision => {
|
|
330
457
|
const prior = latestPriorContent(state, priorChannel, cwd);
|
|
331
|
-
if (prior === undefined) return false;
|
|
458
|
+
if (prior === undefined) return { surgical: false, reason: "no readable prior sidecar" };
|
|
332
459
|
let current: string;
|
|
333
460
|
try {
|
|
334
461
|
current = readArtifactFile(target, cwd);
|
|
335
462
|
} catch {
|
|
336
|
-
return false;
|
|
463
|
+
return { surgical: false, reason: "current plan unreadable" };
|
|
337
464
|
}
|
|
338
465
|
let diff: { touchedSections: Set<string>; changedLines: number };
|
|
339
466
|
try {
|
|
340
467
|
diff = sectionDiff(prior, current);
|
|
341
468
|
} catch {
|
|
342
|
-
return false;
|
|
469
|
+
return { surgical: false, reason: "section diff threw" };
|
|
343
470
|
}
|
|
344
|
-
const cited = citedSections(latest, pending);
|
|
471
|
+
const cited = citedSections(latest, pending, risks);
|
|
472
|
+
const base = {
|
|
473
|
+
changedLines: diff.changedLines,
|
|
474
|
+
touchedSections: [...diff.touchedSections].sort(),
|
|
475
|
+
citedSections: [...cited].sort(),
|
|
476
|
+
};
|
|
345
477
|
for (const section of diff.touchedSections) {
|
|
346
478
|
if (HOUSEKEEPING_SECTIONS.has(section)) continue;
|
|
347
|
-
if (!
|
|
479
|
+
if (!sectionCovered(section, cited)) {
|
|
480
|
+
return { surgical: false, reason: `touched section no failing verdict cited: ${section}`, ...base };
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
if (diff.changedLines > NON_SURGICAL_DIFF_LINE_THRESHOLD) {
|
|
484
|
+
return {
|
|
485
|
+
surgical: false,
|
|
486
|
+
reason: `changed lines ${diff.changedLines} over threshold ${NON_SURGICAL_DIFF_LINE_THRESHOLD}`,
|
|
487
|
+
...base,
|
|
488
|
+
};
|
|
348
489
|
}
|
|
349
|
-
return
|
|
490
|
+
return { surgical: true, reason: "touched sections all cited, within threshold", ...base };
|
|
491
|
+
};
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* True ONLY when a readable prior exists AND the current plan's diff from it
|
|
495
|
+
* touches ONLY sections a failing verdict cited (minus housekeeping) AND the
|
|
496
|
+
* changed-line count is within the coarse threshold. Every missing signal — no
|
|
497
|
+
* prior, unreadable sidecar, unreadable current plan, a diff/parse throw, a
|
|
498
|
+
* touched section no failing verdict cited, or an over-threshold diff —
|
|
499
|
+
* collapses to `false` (fail-closed ⇒ the caller re-grades the full roster
|
|
500
|
+
* when a prior is present, or carries forward when none is). `pending` is
|
|
501
|
+
* consumed as-is: whatever `dimensionsToRegrade` ruled still-blocking (after
|
|
502
|
+
* phase 3's `rulingEffectivePass` clause-3 rewrite) is the set this guard
|
|
503
|
+
* narrows on. `risks` is the plan-authored flag map — ruling-derived cites
|
|
504
|
+
* (see `citedSections`) need the owner phases. Every call persists its
|
|
505
|
+
* decision + tripped condition beside the prior (`recordDecision`), so a
|
|
506
|
+
* future always-broad report names the condition instead of guessing.
|
|
507
|
+
*/
|
|
508
|
+
const isSurgicalFix = (
|
|
509
|
+
state: RunView,
|
|
510
|
+
priorChannel: string,
|
|
511
|
+
cwd: string,
|
|
512
|
+
target: string,
|
|
513
|
+
latest: ReadonlyMap<string, Output>,
|
|
514
|
+
pending: readonly string[],
|
|
515
|
+
risks: ReadonlyMap<string, RiskRecord>,
|
|
516
|
+
): boolean => {
|
|
517
|
+
const decision = decideSurgicalFix(state, priorChannel, cwd, target, latest, pending, risks);
|
|
518
|
+
recordDecision(cwd, target, decision);
|
|
519
|
+
return decision.surgical;
|
|
350
520
|
};
|
|
351
521
|
|
|
352
522
|
export { codeDemote, codeSnapshot, isSurgicalFix, planDemote, planSnapshot, priorArtifact };
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remediation outcome — the deterministic did-anything-change signal for
|
|
3
|
+
* build's `validate-fix` repair arm.
|
|
4
|
+
*
|
|
5
|
+
* The arm dispatches the `remediate` skill (side-effect, code-mutation). Its
|
|
6
|
+
* printed sentinels ("remediation not localized: …") are prose the router
|
|
7
|
+
* cannot see, so a no-op remediation used to be indistinguishable from a fix
|
|
8
|
+
* and the loop re-validated an unchanged tree until the backward-jump guard
|
|
9
|
+
* halted the run (run 2026-08-22_12-14-12-64eb: four identical validate
|
|
10
|
+
* laps). This outcome closes that gap the way `gitCommitOutcome` reads a
|
|
11
|
+
* commit off git state: snapshot a git-only tree digest before the stage,
|
|
12
|
+
* recompute after, and publish `{ changed }` on the `remediation` channel for
|
|
13
|
+
* the `validate-fix` route to fold.
|
|
14
|
+
*
|
|
15
|
+
* Git-only (status --porcelain + diff HEAD) — deliberately NOT the runner's
|
|
16
|
+
* `computeWorktreeDigest`, which also hashes `.rpiv/artifacts/`: remediate is
|
|
17
|
+
* contractually forbidden from writing artifacts, and validate writes a new
|
|
18
|
+
* timestamped report every lap, so the artifacts component would flip the
|
|
19
|
+
* verdict on churn that is not a code fix. `diff HEAD` (not bare `diff`) for
|
|
20
|
+
* the same staged-content reason the runner's digest documents.
|
|
21
|
+
*
|
|
22
|
+
* Degrade posture mirrors worktree-digest.ts: an `undefined` digest on either
|
|
23
|
+
* side (non-repo / git missing / timeout) reports `changed: true` — a missing
|
|
24
|
+
* signal is NEVER a reason to stop the run.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
import { execFileSync } from "node:child_process";
|
|
28
|
+
import { createHash } from "node:crypto";
|
|
29
|
+
import {
|
|
30
|
+
type Artifact,
|
|
31
|
+
type CollectContext,
|
|
32
|
+
type Outcome,
|
|
33
|
+
opaque,
|
|
34
|
+
type SnapshotContext,
|
|
35
|
+
} from "@juicesharp/rpiv-workflow/registration";
|
|
36
|
+
|
|
37
|
+
/** Wall-clock ceiling per git subprocess — the digest runs synchronously at
|
|
38
|
+
* the stage seam, so a wedged git (contended index.lock) must be killed here;
|
|
39
|
+
* on expiry the throw degrades to `undefined` (proceed). */
|
|
40
|
+
const GIT_DIGEST_TIMEOUT_MS = 10_000;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Git-only content fingerprint of `cwd`'s working tree. Returns `undefined`
|
|
44
|
+
* on ANY failure so callers degrade to "proceed", never "stop".
|
|
45
|
+
*/
|
|
46
|
+
export const gitTreeDigest = (cwd: string): string | undefined => {
|
|
47
|
+
try {
|
|
48
|
+
const opts = {
|
|
49
|
+
cwd,
|
|
50
|
+
encoding: "utf-8" as const,
|
|
51
|
+
stdio: ["ignore", "pipe", "ignore"] as ["ignore", "pipe", "ignore"],
|
|
52
|
+
timeout: GIT_DIGEST_TIMEOUT_MS,
|
|
53
|
+
};
|
|
54
|
+
const status = execFileSync("git", ["status", "--porcelain"], opts);
|
|
55
|
+
const diff = execFileSync("git", ["diff", "HEAD"], opts);
|
|
56
|
+
return createHash("sha256").update(status).update("\0").update(diff).digest("hex");
|
|
57
|
+
} catch {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/** The `remediation` channel's data: did the repair arm mutate the tree? */
|
|
63
|
+
export interface RemediationData {
|
|
64
|
+
changed: boolean;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Snapshot the digest pre-stage, recompute post-stage, publish `{ changed }`.
|
|
69
|
+
* One sentinel opaque artifact carries the verdict in `meta` (the
|
|
70
|
+
* `gitCommitOutcome` shape) so the parser stays total.
|
|
71
|
+
*/
|
|
72
|
+
export const remediationOutcome: Outcome<string | undefined, "remediation", RemediationData> = {
|
|
73
|
+
name: "remediation",
|
|
74
|
+
collector: {
|
|
75
|
+
snapshot: ({ cwd }: SnapshotContext) => gitTreeDigest(cwd),
|
|
76
|
+
collect(ctx: CollectContext<string | undefined>) {
|
|
77
|
+
const after = gitTreeDigest(ctx.cwd);
|
|
78
|
+
// A missing digest on either side is a missing signal — report changed
|
|
79
|
+
// (proceed), never a fabricated "nothing happened".
|
|
80
|
+
const changed = ctx.snapshot === undefined || after === undefined || ctx.snapshot !== after;
|
|
81
|
+
const artifact: Artifact = {
|
|
82
|
+
handle: opaque(changed ? "remediation-changed" : "remediation-unchanged"),
|
|
83
|
+
role: "remediation",
|
|
84
|
+
meta: { changed },
|
|
85
|
+
};
|
|
86
|
+
return { kind: "ok", artifacts: [artifact] };
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
parser: {
|
|
90
|
+
parse(ctx) {
|
|
91
|
+
const changed = (ctx.artifacts[0]?.meta as { changed?: unknown } | undefined)?.changed;
|
|
92
|
+
// Only an explicit `false` reports unchanged — same degrade posture.
|
|
93
|
+
return { kind: "ok", payload: { kind: "remediation", data: { changed: changed !== false } } };
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
};
|
|
@@ -60,12 +60,16 @@ const sliceDeps = (entry: Record<string, unknown>): number[] => {
|
|
|
60
60
|
/** Fan `design-slice` out over the latest slice map's `slices:` array — one design
|
|
61
61
|
* session per slice, dependency-ordered. `deps` (slice-N unit ids) drive the wave
|
|
62
62
|
* scheduler; `depArtifactFlag` injects each completed dependency's design path as
|
|
63
|
-
* `--upstream <path>` so a dependent slice reads its dependency's decided Key
|
|
63
|
+
* `--upstream <path>` so a dependent slice reads its dependency's decided Key
|
|
64
|
+
* Interfaces. `haltWhenAllFailed` closes the observed dead-generation shape: when
|
|
65
|
+
* every design unit of a generation fails, the run halts at this stage instead of
|
|
66
|
+
* falling through to `design-review` over an empty `designs` channel. */
|
|
64
67
|
const SLICE_DESIGN_FANOUT = fanout({
|
|
65
68
|
source: "slices",
|
|
66
69
|
unit: { by: "frontmatter-array", pattern: "slices" },
|
|
67
70
|
max: MAX_PHASES,
|
|
68
71
|
depArtifactFlag: "--upstream",
|
|
72
|
+
haltWhenAllFailed: true,
|
|
69
73
|
units: ({ state, cwd }) => {
|
|
70
74
|
const doc = latestFsArtifact(state, "slices");
|
|
71
75
|
if (doc?.handle.kind !== "fs") return [];
|
|
@@ -37,7 +37,10 @@
|
|
|
37
37
|
* A Proxy (not a hand-written delegate) keeps the relay drift-proof. The relay is
|
|
38
38
|
* BRANDED (LANE_RELAY_BRAND) so the launcher's own session hooks
|
|
39
39
|
* (session-capture, lane-switcher) can detect a detached-child session_start and
|
|
40
|
-
* skip launcher-only work (isLaneRelayUiContext).
|
|
40
|
+
* skip launcher-only work (isLaneRelayUiContext). The brand is reported as an own
|
|
41
|
+
* enumerable key (ownKeys/getOwnPropertyDescriptor traps), so it SURVIVES a host
|
|
42
|
+
* that re-wraps ctx.ui by spread — pi ≥0.84.4's wrapUIPromptContext does exactly
|
|
43
|
+
* that, and a get-trap-only brand would silently un-gate every child.
|
|
41
44
|
*/
|
|
42
45
|
|
|
43
46
|
import type { ExtensionUIContext } from "@earendil-works/pi-coding-agent";
|
|
@@ -97,5 +100,26 @@ export function createLaneRelayUiContext(
|
|
|
97
100
|
const value = Reflect.get(target, prop, target);
|
|
98
101
|
return typeof value === "function" ? value.bind(target) : value;
|
|
99
102
|
},
|
|
103
|
+
// Spread survival — pi ≥0.84.4 wraps every extension's ctx.ui via `{...ui}`
|
|
104
|
+
// (wrapUIPromptContext, the ui_prompt_start/end feature; upstream #8829). A
|
|
105
|
+
// spread enumerates OWN keys, so a brand served only by the `get` trap would
|
|
106
|
+
// vanish from the copy, `isLaneRelayUiContext` would return false in every
|
|
107
|
+
// detached child, and the launcher-only session hooks (lane-switcher,
|
|
108
|
+
// session-capture) would run against the child's relay — hijacking the dock
|
|
109
|
+
// editor and foreground capture. Reporting the brand as an own ENUMERABLE key
|
|
110
|
+
// makes `{...relayProxy}` carry `[LANE_RELAY_BRAND]: true`; the relay's
|
|
111
|
+
// behavioral overrides need no help (the spread `get`s them through the proxy).
|
|
112
|
+
ownKeys(target) {
|
|
113
|
+
const keys = Reflect.ownKeys(target);
|
|
114
|
+
// A duplicate entry in an ownKeys result is a TypeError — guard the
|
|
115
|
+
// (never-expected) case of an already-branded target.
|
|
116
|
+
return keys.includes(LANE_RELAY_BRAND) ? keys : [...keys, LANE_RELAY_BRAND];
|
|
117
|
+
},
|
|
118
|
+
getOwnPropertyDescriptor(target, prop) {
|
|
119
|
+
// `configurable: true` is REQUIRED by the Proxy invariant for a key the
|
|
120
|
+
// target does not itself own.
|
|
121
|
+
if (prop === LANE_RELAY_BRAND) return { value: true, writable: false, enumerable: true, configurable: true };
|
|
122
|
+
return Reflect.getOwnPropertyDescriptor(target, prop);
|
|
123
|
+
},
|
|
100
124
|
});
|
|
101
125
|
}
|
|
@@ -28,6 +28,7 @@ import { isModuleNotFound } from "./utils.js";
|
|
|
28
28
|
export const BUCKET_BY_KIND: Readonly<Record<string, string>> = {
|
|
29
29
|
plan: "plans",
|
|
30
30
|
research: "research",
|
|
31
|
+
acceptance: "acceptance",
|
|
31
32
|
slices: "slices",
|
|
32
33
|
design: "designs",
|
|
33
34
|
elaboration: "elaborations",
|
|
@@ -36,7 +36,7 @@ export const PIPELINE_POINTER = [
|
|
|
36
36
|
"Other explicit-only commands: /skill:slice, /skill:revise, /skill:elaborate,",
|
|
37
37
|
"/skill:architecture-review, /skill:frontend-design",
|
|
38
38
|
"Workflow-internal (dispatched by lanes — never suggest): amend, design-slice,",
|
|
39
|
-
"design-review, synthesize, grade, remediate, quick-plan",
|
|
39
|
+
"design-review, synthesize, grade, remediate, quick-plan, acceptance",
|
|
40
40
|
].join("\n");
|
|
41
41
|
|
|
42
42
|
export function injectPipelinePointer(pi: ExtensionAPI): void {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juicesharp/rpiv-pi",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "A skill-based development workflow for Pi Agent.
|
|
3
|
+
"version": "2.8.0",
|
|
4
|
+
"description": "A skill-based development workflow for Pi Agent. 30 contract-carrying skills (discover → research → design → plan → implement → validate → code-review → commit, and more), the 15 named subagents they dispatch, and four built-in /wf workflows that chain them end to end in detached parallel runs.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
|
7
7
|
"pi-extension",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
]
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@juicesharp/rpiv-config": "^2.
|
|
53
|
+
"@juicesharp/rpiv-config": "^2.8.0",
|
|
54
54
|
"typebox": "^1.1.24"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: acceptance
|
|
3
|
+
description: "Derive an executable acceptance inventory from the verbatim goal — the ID'd observable outcomes the finished work must exhibit, each with a runnable evidence command where one can be derived — and write it to .rpiv/artifacts/acceptance/ in one non-interactive pass. Authored BEFORE any plan exists so the standard of completion cannot inherit the plan's scope: the plan later addresses or explicitly defers each item, the grade panel's completeness dimension anchors on the inventory, and validate executes the evidence commands against the finished tree. Dispatched by the ship and build presets between research and planning."
|
|
4
|
+
argument-hint: "--goal <path> [--research <path>]"
|
|
5
|
+
shell-timeout: 10
|
|
6
|
+
disable-model-invocation: true
|
|
7
|
+
contract:
|
|
8
|
+
produces:
|
|
9
|
+
kind: produces
|
|
10
|
+
meta:
|
|
11
|
+
artifactKind: acceptance
|
|
12
|
+
data:
|
|
13
|
+
type: object
|
|
14
|
+
required: [items, item_count]
|
|
15
|
+
properties:
|
|
16
|
+
status:
|
|
17
|
+
enum: [ready]
|
|
18
|
+
item_count:
|
|
19
|
+
type: integer
|
|
20
|
+
minimum: 1
|
|
21
|
+
maximum: 24
|
|
22
|
+
items:
|
|
23
|
+
type: array
|
|
24
|
+
minItems: 1
|
|
25
|
+
maxItems: 24
|
|
26
|
+
items:
|
|
27
|
+
type: object
|
|
28
|
+
required: [id, statement]
|
|
29
|
+
properties:
|
|
30
|
+
id: { type: string }
|
|
31
|
+
statement: { type: string }
|
|
32
|
+
command: { type: string }
|
|
33
|
+
expect: { type: string }
|
|
34
|
+
manual: { type: string }
|
|
35
|
+
consumes:
|
|
36
|
+
meta:
|
|
37
|
+
artifactKind: [research]
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
# Acceptance
|
|
41
|
+
|
|
42
|
+
You derive an **acceptance inventory** from the verbatim goal: the distinct observable outcomes the finished work must exhibit, each with a short stable id (`a1`, `a2`, …) and — wherever one can be derived — a **runnable evidence command** that will exit 0 once the outcome holds. One non-interactive pass, one Write. You do **not** plan, design, or judge feasibility — the inventory is the measure the later stages answer to, not a plan of how to get there.
|
|
43
|
+
|
|
44
|
+
The inventory exists to keep the standard of completion independent of the work: it is authored before any plan, from the goal alone, so a plan that silently narrows the brief is caught against enumerated items instead of prose re-reading. Downstream: the planner addresses or explicitly defers each item, the grade panel's completeness dimension receives the inventory as `--acceptance`, and validate runs the evidence commands against the finished tree — a failed item with a runnable command becomes a structured, remediable blocker.
|
|
45
|
+
|
|
46
|
+
## Input
|
|
47
|
+
|
|
48
|
+
`$ARGUMENTS` — flags (order-independent):
|
|
49
|
+
|
|
50
|
+
- `--goal <path>` (**required**) — the verbatim brief. Read it FULLY (no limit/offset). Missing/empty ⇒ print an error and stop — a dispatch error (the workflow runs `goal` before `acceptance`).
|
|
51
|
+
- `--research <path>` (optional) — the grounding doc. Read it FULLY. Research grounds only the **evidence procedures** (which command, which test path, which grep target); it NEVER adds, drops, or narrows items — the item set derives from the goal alone.
|
|
52
|
+
|
|
53
|
+
## Metadata
|
|
54
|
+
|
|
55
|
+
```!
|
|
56
|
+
node "${SKILL_DIR}/../_shared/now.mjs"
|
|
57
|
+
echo
|
|
58
|
+
node "${SKILL_DIR}/../_shared/git-context.mjs"
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Copy values verbatim. `<iso>` is the first tab-separated field (use as `date:`); `<slug>` is the second.
|
|
62
|
+
|
|
63
|
+
## What an item is
|
|
64
|
+
|
|
65
|
+
An acceptance item is one **observable outcome** the goal asks for — behavior a reader could check on the finished tree, not an implementation step. Good items are:
|
|
66
|
+
|
|
67
|
+
- **Goal-traceable** — the `statement` restates one explicit ask (or explicit constraint) from the goal in one line; quote or closely paraphrase the goal's own words. Never invent scope the goal doesn't name (the graders' anti-scope-inflation rule applies here first).
|
|
68
|
+
- **Observable** — phrased as a checkable end state ("`/wf ship` halts at the grade gate with a route note"), never as activity ("implement the gate").
|
|
69
|
+
- **Singular** — one outcome per item; a goal sentence naming two outcomes yields two items.
|
|
70
|
+
- **Right-sized set** — typically 3–12 items; every explicit ask is covered, and nothing is padded. A one-line goal may legitimately yield a single item. The schema's hard ceiling is 24 — deliberately tighter than the plan/slice family's 32, because an inventory that large is re-litigating scope, not enumerating a brief; a goal genuinely that broad belongs in `build`'s slice decomposition, with each slice's asks staying items here only at the observable-outcome grain.
|
|
71
|
+
|
|
72
|
+
Evidence, per item — exactly one of:
|
|
73
|
+
|
|
74
|
+
- `command` + `expect` — a **read-only, self-contained, repo-root-relative** command expected to exit 0 once the outcome holds (a test invocation, a grep invariant, a `tsc --noEmit`, a file-existence check), with `expect` naming the observable in one line. Ground it in the research/tree so paths and script names are real. It is **future-tense**: it may (and usually will) fail on today's tree — validate runs it after implement.
|
|
75
|
+
- `manual` — a one-line human procedure, ONLY when no read-only command can measure the outcome (visual appearance, real-terminal behavior). Prefer a command whenever one exists; a `manual` item is homework validate can record but not discharge.
|
|
76
|
+
|
|
77
|
+
## Flow
|
|
78
|
+
|
|
79
|
+
1. Read goal (+research) → 2. Enumerate items → 3. Attach evidence → 4. Write (`status: ready`)
|
|
80
|
+
|
|
81
|
+
## Steps
|
|
82
|
+
|
|
83
|
+
1. **Read.** The goal FULLY — it is the sole source of items. The research doc FULLY when given — it is the sole *grounding* for evidence commands (test layouts, script names, conventions). Spot-check any path a command will cite against the real tree.
|
|
84
|
+
2. **Enumerate.** Walk the goal sentence by sentence and extract every explicit ask and explicit constraint as an item (`a1`, `a2`, … in goal order). Ambiguity is resolved toward the goal's own words — restate, don't interpret. Do NOT consult the research for what belongs in the set: a research doc that narrowed the brief must not narrow the inventory.
|
|
85
|
+
3. **Attach evidence.** For each item, derive the strongest read-only command the tree supports and one `expect` line; fall back to `manual` only when nothing runnable can measure it. Never write a command that mutates the tree, reaches the network, or depends on state outside the repo.
|
|
86
|
+
4. **Write** the inventory in one pass to `.rpiv/artifacts/acceptance/<slug>_<description>.md` (`<description>` a brief kebab-case task summary), `status: ready` directly. Then print the path and `acceptance written: {N} item(s), {M} executable`.
|
|
87
|
+
|
|
88
|
+
Use this template:
|
|
89
|
+
|
|
90
|
+
```markdown
|
|
91
|
+
---
|
|
92
|
+
date: {<iso> from Metadata block}
|
|
93
|
+
topic: "{task name}"
|
|
94
|
+
tags: [acceptance]
|
|
95
|
+
status: ready
|
|
96
|
+
item_count: {N}
|
|
97
|
+
items:
|
|
98
|
+
- { id: a1, statement: "{one-line observable outcome}", command: "{read-only command}", expect: "{what exit 0 shows}" }
|
|
99
|
+
- { id: a2, statement: "{one-line observable outcome}", manual: "{one-line human procedure}" }
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
# Acceptance Inventory: {Task Name}
|
|
103
|
+
|
|
104
|
+
Derived from the verbatim goal ({goal path}). Items enumerate the goal's explicit asks; evidence commands are future-tense — run by validate against the finished tree.
|
|
105
|
+
|
|
106
|
+
## Items
|
|
107
|
+
|
|
108
|
+
### a1: {statement}
|
|
109
|
+
**Evidence**: `{command}` — {expect}
|
|
110
|
+
|
|
111
|
+
### a2: {statement}
|
|
112
|
+
**Evidence (manual)**: {procedure}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Important Notes
|
|
116
|
+
|
|
117
|
+
- **Consistently counted, always.** `item_count` == `items:` array length == the number of `### aN:` sections — the `phase_count`/`slice_count` discipline, applied here. Ids run `a1…aN` with no gaps or duplicates.
|
|
118
|
+
- **Items from the goal ALONE.** Research grounds evidence, never membership — the whole point of this stage is a standard the later narrowing cannot rewrite. If the goal names an ask the research argues against, the item still exists; the PLAN defers it legibly.
|
|
119
|
+
- **The inventory is frozen.** No downstream stage re-emits on the acceptance channel; deferral happens in the plan (visibly, per item id), never by editing this artifact.
|
|
120
|
+
- **Read-only, self-contained commands.** Validate runs them as written after implement — a command that mutates the tree or depends on external state corrupts the very measurement it exists to make.
|
|
121
|
+
- **Future-tense evidence.** Do not run the commands here and do not weaken one because it fails today — failing today is the expected state of a check on unbuilt work.
|
|
122
|
+
- **Non-interactive.** No `ask_user_question`, no subagents. Resolve ambiguity toward the goal's own words; the grade panel adjudicates a genuinely contestable reading.
|
|
123
|
+
- **NEVER edit source files.** This skill produces an inventory document only.
|