@juicesharp/rpiv-pi 2.7.1 → 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.
@@ -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
- const m = /^##\s+(.*)$/.exec(lines[i]);
196
- if (m) {
197
- const ph = /^Phase\s+(\d+)/i.exec(m[1].trim());
198
- current = ph ? `phase ${ph[1]}` : m[1].trim().toLowerCase();
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' findings — extracted from each
258
- * finding's `where` and `detail` (`Phase N` → `phase N`, lowercased). Preferred
259
- * `where: "Phase 1 > lane-dock-editor.ts Edit 1"` → `phase 1`; a repo
260
- * `path:line`-only `where` (and a detail with no `Phase N`) contributes NO plan
261
- * section. Empty when no failing finding carries an extractable plan-section
262
- * reference — fail-closed: the caller treats an empty cite set against any
263
- * non-housekeeping touched section as out-of-scope (non-surgical).
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 = (latest: ReadonlyMap<string, Output>, pending: readonly string[]): Set<string> => {
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 findings = (latest.get(d)?.data as { findings?: unknown } | undefined)?.findings;
269
- if (!Array.isArray(findings)) continue;
270
- for (const f of findings) {
271
- if (f == null || typeof f !== "object") continue;
272
- const where = typeof (f as { where?: unknown }).where === "string" ? (f as { where: string }).where : "";
273
- const detail = typeof (f as { detail?: unknown }).detail === "string" ? (f as { detail: string }).detail : "";
274
- for (const text of [where, detail]) {
275
- for (const m of text.matchAll(/Phase\s+(\d+)/gi)) cited.add(`phase ${m[1]}`);
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
- * True ONLY when a readable prior exists AND the current plan's diff from it
312
- * touches ONLY sections a failing finding cited (minus housekeeping) AND the
313
- * changed-line count is within the coarse threshold. Every missing signal — no
314
- * prior, unreadable sidecar, unreadable current plan, a diff/parse throw, a
315
- * touched section no failing finding cited, or an over-threshold diff —
316
- * collapses to `false` (fail-closed ⇒ the caller re-grades the full roster
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 isSurgicalFix = (
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
- ): boolean => {
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 (!cited.has(section)) return false;
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 diff.changedLines <= NON_SURGICAL_DIFF_LINE_THRESHOLD;
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 };
@@ -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 Interfaces. */
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.7.1",
4
- "description": "A skill-based development workflow for Pi Agent. 29 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.",
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.7.1",
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.
@@ -66,8 +66,9 @@ You grade ONE artifact against ONE quality dimension and emit a verdict JSON. Yo
66
66
  - `--artifact <path>` **(required)** — the artifact under review.
67
67
  - `--context <path>` *(optional)* — a supporting artifact (e.g. the research doc). **Required for `architecture-fit`.**
68
68
  - `--goal <path>` *(optional)* — the user's original brief, captured verbatim at run start. **Read it only for `completeness` and `correctness`** — every other dimension ignores it. Absent, or the file is empty → grade the artifact on its own content as usual.
69
+ - `--acceptance <path>` *(optional, `completeness` only)* — the goal-derived acceptance inventory (`items:` frontmatter, ids `a1…`), frozen before planning. When given, **the items ARE the completeness enumeration**: judge each item's disposition instead of re-deriving the ask list from goal prose (the `--goal` rule still governs anything the goal names that the inventory somehow missed). Every other dimension ignores this flag. Missing or unreadable path → grade normally without it.
69
70
  - `--prior <path>` *(optional)* — a prior round's verdict JSON for this same `(artifact, dimension)`, passed by a CONFIRM panel. Its presence puts you in **confirm mode** (see "Prior-round adjudication" below). If the path is missing or unreadable, grade normally without it — a stale prior is not a wiring error.
70
- - `--cite-check <path>` *(optional, `correctness` only)* — the deterministic citation floor's verdict JSON for the same artifact, passed when the floor recorded advisory findings (an unresolved path, citation ambiguity, or line drift — mechanical resolution results, not verdicts). Treat its `findings[]` as **leads to fold into your spot-check sample**, not conclusions — the Citation-resolution rule (step 4) alone decides whether any becomes a finding of yours (an "unresolved" lead whose file genuinely does not exist anywhere IS one). Every other dimension ignores this flag; it never triggers confirm mode and never produces `finding_rulings`. Missing or unreadable path → grade normally without it.
71
+ - `--cite-check <path>` *(optional, `correctness` only)* — the deterministic citation floor's verdict JSON for the same artifact. It carries SETTLED FACTS in both directions. A clean verdict (empty `findings`) means every citation in the artifact **mechanically resolves** — file exists, reference locates — so do NOT re-resolve citations file-by-file: spend your spot-check entirely on the **semantic** half the floor cannot judge (does the cited code do what the artifact claims it does). A findings-bearing verdict lists the citations the floor could NOT settle (an unresolved path, citation ambiguity, or line drift — mechanical resolution results, not verdicts): treat its `findings[]` as **leads to fold into your spot-check sample**, not conclusions — the Citation-resolution rule (step 4) alone decides whether any becomes a finding of yours (an "unresolved" lead whose file genuinely does not exist anywhere IS one) — and citations the floor did NOT flag are resolution-settled exactly as in the clean case. Every other dimension ignores this flag; it never triggers confirm mode and never produces `finding_rulings`. Missing or unreadable path → grade normally without it (full mechanical + semantic spot-check).
71
72
 
72
73
  **Plan-authored risk flags (the `correctness` dimension only).** When your `--dimension` is `correctness` and the `--artifact` carries a `risks:` frontmatter array (each `{ id, claim }`, described in the plan's `## Risk Flags` section), you are REQUIRED to rule on every flag — this is a first-class channel, not an optional prose aside. For each flag, verify its `claim` against the real codebase / the plan (Read/Grep the relevant `file:line`) and decide `pass` (the concern is unfounded or already handled) or `fail` (the risk is real and unaddressed). A `fail` ruling blocks the gate (the workflow folds these across the panel), so an assumption the plan flagged for review cannot ride a green pass into commit. Other dimensions ignore `risks:`.
73
74
 
@@ -104,7 +105,7 @@ Grade against the row matching `--dimension`. "Pass bar" is the line; meet it
104
105
 
105
106
  | Dimension | What it checks | Where to look | Pass bar |
106
107
  |---|---|---|---|
107
- | `completeness` | The artifact covers the whole brief — no unresolved `TODO`/`TBD`/`?`/"unknown"/"figure out later" markers; every area it names is addressed; open questions are resolved or explicitly deferred with a reason. **When `--goal` is given, the brief IS the goal file**: every explicit ask and constraint in it is addressed or explicitly deferred with a reason — a requirement present in the goal but absent from the artifact is a blocking gap. | The artifact's own content, cross-checked against `--goal` when given. | No blocking gap — nothing a downstream stage would need is left undefined, and no explicit `--goal` ask is silently dropped. |
108
+ | `completeness` | The artifact covers the whole brief — no unresolved `TODO`/`TBD`/`?`/"unknown"/"figure out later" markers; every area it names is addressed; open questions are resolved or explicitly deferred with a reason. **When `--goal` is given, the brief IS the goal file**: every explicit ask and constraint in it is addressed or explicitly deferred with a reason — a requirement present in the goal but absent from the artifact is a blocking gap. **When `--acceptance` is also given, walk its `items:` id by id**: each is genuinely covered by the artifact (an `acceptance:` disposition naming a phase must be honest — the phase's work would actually make the item's evidence hold) or explicitly deferred with a reason; an item neither covered nor deferred, a dishonest `implemented` claim, or a silently dropped/reworded item is a blocking gap. | The artifact's own content, cross-checked against `--goal` and the `--acceptance` items when given. | No blocking gap — nothing a downstream stage would need is left undefined, no explicit `--goal` ask is silently dropped, and every `--acceptance` item is honestly disposed. |
108
109
  | `correctness` | Claims match reality — cited files and symbols exist and the code does what the artifact claims; described current behavior matches the actual code; no internal contradictions. When `--goal` is given, no claim or decision contradicts an explicit constraint stated in it. | **Spot-check the live codebase**: resolve a sample of the artifact's references with Read/Grep — by file + named symbol, NOT by exact line number (line numbers are navigation hints); check decisions against `--goal` when given. | No false claim found in the sample; cited files/symbols exist; no explicit `--goal` constraint contradicted. |
109
110
  | `actionability` | A competent implementer could execute it without guessing — concrete steps, named files/symbols, explicit success criteria; no hand-waving ("somehow", "handle appropriately", "etc."). | The artifact's own content. | Every section/slice is executable as written. |
110
111
  | `architecture-fit` | The approach fits the existing architecture and the constraints surfaced in `--context` — respects module boundaries, dependency direction, established layering; introduces no boundary violation. | The artifact **and** `--context`, cross-checked against real module boundaries via Grep/Read. | No architectural conflict with the codebase or the research's constraints. |
@@ -114,9 +115,9 @@ Grade against the row matching `--dimension`. "Pass bar" is the line; meet it
114
115
  ## Steps
115
116
 
116
117
  1. **Parse + validate flags.** Bail per the Input rules above if malformed.
117
- 2. **Read fully** (no limit/offset): `--artifact`, and `--context` / `--goal` / `--prior` / `--cite-check` if given (skip `--goal` unless your dimension is `completeness` or `correctness`; skip `--cite-check` unless your dimension is `correctness`).
118
+ 2. **Read fully** (no limit/offset): `--artifact`, and `--context` / `--goal` / `--acceptance` / `--prior` / `--cite-check` if given (skip `--goal` unless your dimension is `completeness` or `correctness`; skip `--acceptance` unless your dimension is `completeness`; skip `--cite-check` unless your dimension is `correctness`).
118
119
  3. **Select the single rubric row** for `--dimension`. Ignore every problem outside it.
119
- 4. **Evaluate.** For `correctness` / `architecture-fit` / `pattern-following` / `design-readiness`, spot-check against the real codebase — resolve references, compare conventions, check boundaries, expand each slice's true touch + dependency fan-out from its cited seeds to gauge whether the footing is bounded AND complete, and check each shared contract has a single owning slice. **Citation-resolution rule: resolve every `path:line` citation by opening the file and locating the named symbol/content — the line number is a navigation hint, not a claim. A line number that points near but not exactly at the cited symbol is NEVER a finding, at any severity — do not report it, do not mention it in feedback: downstream stages locate code by symbol, so drift wastes fix rounds without ever blocking anything. The only citation findings that exist: the file does not exist, the named symbol/content does not exist in it, or the code does not do what the artifact claims it does.** For `completeness` / `actionability`, judge the artifact's own content. **On `correctness`, also rule every plan-authored risk flag** (see "Plan-authored risk flags" above) — verify each `risks:` claim against the code and record a `risk_rulings` entry. **On `correctness` with `--cite-check`, fold each of its findings into your spot-check sample** — the citation-resolution rule decides what, if anything, you report. **With `--prior`, also adjudicate every prior finding** (see "Prior-round adjudication" above) — verify each against artifact + code and record a `finding_rulings` entry. Collect findings — each is `{ detail, where }` (`where` = `path:line` or a section heading; for slice dimensions, cite the offending `## Slice N`). Where a `design-readiness` finding fires, the `feedback` must name the exact re-cut (which slice to split and along which seam, which under-cited grounding to add, or which overlap to separate) so the re-slice can act on it.
120
+ 4. **Evaluate.** For `correctness` / `architecture-fit` / `pattern-following` / `design-readiness`, spot-check against the real codebase — resolve references, compare conventions, check boundaries, expand each slice's true touch + dependency fan-out from its cited seeds to gauge whether the footing is bounded AND complete, and check each shared contract has a single owning slice. **Citation-resolution rule: resolve every `path:line` citation by opening the file and locating the named symbol/content — the line number is a navigation hint, not a claim. A line number that points near but not exactly at the cited symbol is NEVER a finding, at any severity — do not report it, do not mention it in feedback: downstream stages locate code by symbol, so drift wastes fix rounds without ever blocking anything. The only citation findings that exist: the file does not exist, the named symbol/content does not exist in it, or the code does not do what the artifact claims it does.** For `completeness` / `actionability`, judge the artifact's own content. **On `correctness`, also rule every plan-authored risk flag** (see "Plan-authored risk flags" above) — verify each `risks:` claim against the code and record a `risk_rulings` entry. **On `correctness` with `--cite-check`, citation RESOLUTION is settled by the floor — do not re-resolve unflagged citations; sample them only for the semantic claim** (open the file, check the code does what the artifact says — never to re-check that it exists), **and fold each of the floor's findings into your spot-check sample** — the citation-resolution rule decides what, if anything, you report. **With `--prior`, also adjudicate every prior finding** (see "Prior-round adjudication" above) — verify each against artifact + code and record a `finding_rulings` entry. Collect findings — each is `{ detail, where }` (`where` = `path:line` or a section heading; for slice dimensions, cite the offending `## Slice N`). Where a `design-readiness` finding fires, the `feedback` must name the exact re-cut (which slice to split and along which seam, which under-cited grounding to add, or which overlap to separate) so the re-slice can act on it.
120
121
  5. **Decide** `pass` (against the pass bar), `score` (0–100), `severity` (`none` | `low` | `medium` | `high` = the worst finding), and `feedback`. **`severity` is gate-load-bearing: the workflow treats any verdict whose worst finding is `low`/`none` as passing, even on `pass: false`, and only a `medium`+ finding blocks the gate.** So set `severity` to honestly reflect blocking weight — `low`/`none` for a cosmetic nit (a stylistic phrasing, a naming quibble that doesn't change behavior; line-number drift is not even a nit — per the citation-resolution rule it is never a finding), `medium`+ for a finding a downstream stage genuinely cannot proceed past (a cited file or symbol that does not exist, a missing step, an executable edit that would fail as written, a boundary violation), **or for a claim about behavior you verified is false that sits in text the implementer copies verbatim (a code block, JSDoc, or comment) — behavior that happens to be correct anyway does not make it a nit; the shipped false claim is itself the defect**. Do **not** mark a real blocker `low` to be lenient, and do **not** mark a cosmetic nit `medium`+ to force a re-run — the gate reads `severity`, so mis-rating it either ships a defect or stalls the loop. **Every string you emit (`feedback` and each `findings[].detail` / `where`) MUST be JSON-safe: a single line, no literal newlines or tabs, no backticks or code fences, double-quotes escaped as `\"`. Put `path:line` citations in `findings[].where` — never paste code snippets into `feedback`.**
121
122
  - `pass: false` → `feedback` is a **surgical, concrete instruction set** telling `amend` exactly what to change to clear this dimension, citing `where`. This field is the only thing `amend` reads — make it sufficient but concise (≤ ~500 chars; lean on `findings[]` for specifics).
122
123
  - `pass: false` on `design-readiness` where **every** finding's remedy is pure citation bookkeeping — add a named seed to a slice's `Draws on`, or move a named item to `Out of scope`, with **no** split/merge/renumber/re-fence needed: additionally emit top-level `"remedy": "cite"` and give **each** finding a `"requires": "<path>:<lines>"` naming the exact seed. The slice gate then verifies deterministically that the re-cut map satisfies every finding with the slice structure unchanged, and skips the re-grade panel. Emit `remedy` ONLY when those citation edits alone would flip your verdict to pass — any structural doubt, or any finding without a concrete `requires` seed, → omit it and the normal re-grade runs. (There is no "refresh a drifted line number" remedy — per the citation-resolution rule, drifted line numbers are not findings.)