@juicesharp/rpiv-pi 2.6.4 → 2.7.1

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.
Files changed (33) hide show
  1. package/docs/skills.md +1 -1
  2. package/extensions/rpiv-core/agents.ts +10 -13
  3. package/extensions/rpiv-core/artifact-collector.ts +111 -6
  4. package/extensions/rpiv-core/bash-timeout.ts +12 -2
  5. package/extensions/rpiv-core/built-in-workflows.ts +329 -3528
  6. package/extensions/rpiv-core/built-ins/citations.ts +357 -0
  7. package/extensions/rpiv-core/built-ins/gates.ts +613 -0
  8. package/extensions/rpiv-core/built-ins/goal-baseline.ts +269 -0
  9. package/extensions/rpiv-core/built-ins/grade-panel.ts +199 -0
  10. package/extensions/rpiv-core/built-ins/index.ts +47 -0
  11. package/extensions/rpiv-core/built-ins/plan-cite.ts +219 -0
  12. package/extensions/rpiv-core/built-ins/plan-phases.ts +424 -0
  13. package/extensions/rpiv-core/built-ins/priors.ts +352 -0
  14. package/extensions/rpiv-core/built-ins/reconcile.ts +283 -0
  15. package/extensions/rpiv-core/built-ins/remediation.ts +96 -0
  16. package/extensions/rpiv-core/built-ins/scope-checks.ts +378 -0
  17. package/extensions/rpiv-core/built-ins/shared.ts +17 -1
  18. package/extensions/rpiv-core/built-ins/slice-checks.ts +420 -0
  19. package/extensions/rpiv-core/built-ins/slices.ts +288 -0
  20. package/extensions/rpiv-core/constants.ts +5 -1
  21. package/extensions/rpiv-core/lane-console.ts +9 -2
  22. package/extensions/rpiv-core/lane-list.ts +10 -1
  23. package/extensions/rpiv-core/question-lifecycle.ts +2 -2
  24. package/extensions/rpiv-core/register-built-in-workflows.ts +2 -2
  25. package/extensions/rpiv-core/run-lane-registry.ts +83 -83
  26. package/package.json +2 -2
  27. package/skills/elaborate/SKILL.md +1 -1
  28. package/skills/implement/SKILL.md +1 -0
  29. package/skills/plan/SKILL.md +3 -1
  30. package/skills/remediate/SKILL.md +18 -15
  31. package/skills/synthesize/SKILL.md +1 -0
  32. package/skills/validate/SKILL.md +26 -19
  33. package/skills/validate/templates/validation.md +1 -1
@@ -404,6 +404,8 @@ Success Criteria are **authored upstream in `/skill:design` Step 6.1** and verif
404
404
 
405
405
  **Write-scope rule (per-phase, mandatory before parallel implement):** every command in a phase's `#### Automated Verification:` block must be **write-scoped to that phase's own `files:` set** — running it must not modify anything outside the phase's `files:`. Phases run concurrently under build's parallel implement lane, so a command that rewrites the wider tree corrupts a sibling phase's in-flight edit; narrow any formatter or auto-fixer to the phase's paths (take the project's command vocabulary from its guidance `# Commands` table — where the table gives only an unscoped form, narrow it to the phase's paths rather than substituting a different tool). Read-only repo-wide commands (a type check, a non-fixing lint, a scoped test selection) are permitted. Whole-repo build/test verification belongs to the plan's final whole-plan block, owned by `validate` — never to a phase.
406
406
 
407
+ **Whole-plan gate achievability rule:** every command promised in the plan's final whole-plan block must be able to pass on the base tree plus this plan's own changes — validate judges criteria literally, so a criterion that is red at base for files the plan never touches converts pre-existing debt into a permanent `verdict: fail`. For repo-wide *style* gates (lint, format checks) default to the delta-scoped form — run the tool over the plan's file union (e.g. `npx eslint <plan files>` exits 0) — and promise an absolute repo-wide "exits 0" only for build/test commands, or when there is evidence the gate is green at base (the research artifact or project guidance says so). Known base debt the plan won't repair is recorded under Notes as a deferral, never as a criterion. (Mirrored in synthesize/SKILL.md — edit both together.)
408
+
407
409
  **Who runs AV lines:** `implement` runs each phase's own `#### Automated Verification:` commands in its shell and flips the checkboxes; `validate` re-runs them agent-side over the whole finished plan. Both are agents with a real shell and judgment — no deterministic harness re-executes these lines. Still prefer ONE self-contained command per line that exits 0 when the criterion holds, with the target path inside the backtick span; prose around the span is context for the agent, not executed syntax. Remember AV lines are written before sibling phases land: a check asserting another phase's rename target or source may be true at phase time and false on the final tree — scope each line to what YOUR phase owns.
408
410
 
409
411
  **Format example:**
@@ -413,7 +415,7 @@ Success Criteria are **authored upstream in `/skill:design` Step 6.1** and verif
413
415
  #### Automated Verification:
414
416
  - [ ] Database migration runs successfully: `make migrate`
415
417
  - [ ] All unit tests pass: `go test ./...`
416
- - [ ] No linting errors: `golangci-lint run`
418
+ - [ ] No linting errors in this plan's files: `golangci-lint run internal/auth/... internal/api/...`
417
419
  - [ ] API endpoint returns 200: `curl localhost:8080/api/new-endpoint`
418
420
 
419
421
  #### Manual Verification:
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: remediate
3
- description: Surgically repair a working tree whose validate run returned a failing verdict — re-run each failed verify-at-implement risk ruling's prescribed procedure, apply the minimal localized code fix grounded in the validation report, then confirm the procedure passes. Single-pass, no subagents, no self-review, no questions. Workflow-gated repair arm dispatched after a failing validate; use as a gate's repair stage.
3
+ description: Surgically repair a working tree whose validate run returned a failing verdict — re-run each failed verify-at-implement risk ruling's prescribed procedure and each structured blocker's failing command, apply the minimal localized code fix grounded in the validation report, then confirm it passes. Single-pass, no subagents, no self-review, no questions. Workflow-gated repair arm dispatched after a failing validate; use as a gate's repair stage.
4
4
  argument-hint: "--plans <plan-path> --validation <report-path>"
5
5
  allowed-tools: Read, Edit, Write, Bash(*), Glob, Grep
6
6
  shell-timeout: 10
@@ -22,7 +22,7 @@ contract:
22
22
 
23
23
  # Remediate
24
24
 
25
- You surgically repair a **working tree** that a validate stage judged `verdict: fail`. You do **not** re-validate the whole plan, re-run the project's full build/test suite, or rewrite anything broadly — you clear exactly the localized defects the failing risk rulings prescribe, and re-run each ruling's own `procedure` to confirm it now passes. One pass, non-interactive, side-effect only: you mutate code, never emit an artifact. The workflow loops you straight back to the validate gate, which re-judges; that is the only validation, so you do **not** self-review or ask for approval.
25
+ You surgically repair a **working tree** that a validate stage judged `verdict: fail`. You do **not** re-validate the whole plan, re-run the project's full build/test suite, or rewrite anything broadly — you clear exactly the localized defects the failing risk rulings and structured blockers prescribe, and re-run each item's own `procedure`/`command` to confirm it now passes. One pass, non-interactive, side-effect only: you mutate code, never emit an artifact. The workflow loops you straight back to the validate gate, which re-judges; that is the only validation, so you do **not** self-review or ask for approval.
26
26
 
27
27
  You are the tools/contract twin of `implement` (`Bash(*)` + `code-mutation`, side-effect, not an artifact) and the body-discipline twin of `amend` (single-pass, surgical, no subagents, no self-review, no questions).
28
28
 
@@ -31,42 +31,45 @@ You are the tools/contract twin of `implement` (`Bash(*)` + `code-mutation`, sid
31
31
  `$ARGUMENTS` — flags the orchestrator wires from the gate's channels. Parse flag-style (order-agnostic), exactly like `amend`:
32
32
 
33
33
  - **`--plans <plan-path>`** — the plan under `.rpiv/artifacts/plans/`. Its frontmatter carries the `risks:` array; a ruling's `id` joins to a flag there.
34
- - **`--validation <report-path>`** — the failing validation report under `.rpiv/artifacts/validation/`. Its frontmatter carries `verdict` + `risk_rulings: [{ id, pass }]`.
34
+ - **`--validation <report-path>`** — the failing validation report under `.rpiv/artifacts/validation/`. Its frontmatter carries `verdict` + `risk_rulings: [{ id, pass }]` and, when whole-plan gates failed, `blockers: [{ id, command, file, line }]`.
35
35
 
36
36
  If `--plans` or `--validation` is missing, print an error and stop — it is a dispatch error, not a failing phase.
37
37
 
38
38
  ## Steps
39
39
 
40
- 1. **Read the plan and the report fully** (no limit/offset). From the report's frontmatter read `verdict` and the `risk_rulings: [{ id, pass }]` array; from the plan's frontmatter read the `risks:` array (each flag is `{ id, claim, … }`).
41
- 2. **Build the work-list — ONLY the report's failing risk rulings.** Take every `risk_rulings` entry with `pass === false`, and join each to the plan's `risks:` flag by `id`. A `pass: false` ruling whose `id` matches no plan flag has no `claim`/`procedure`/`owner` to ground a fix — treat it as a drift-escape (step 4). Never source work from the report body's Potential Issues / Deviations prose on its own: those tie to a ruling only when a `risk_rulings` entry names it.
40
+ 1. **Read the plan and the report fully** (no limit/offset). From the report's frontmatter read `verdict`, the `risk_rulings: [{ id, pass }]` array, and the `blockers: [{ id, command, file, line }]` array (absent ⇒ empty); from the plan's frontmatter read the `risks:` array (each flag is `{ id, claim, … }`).
41
+ 2. **Build the work-list — ONLY the report's failing risk rulings + structured blockers.** Take every `risk_rulings` entry with `pass === false`, and join each to the plan's `risks:` flag by `id`. A `pass: false` ruling whose `id` matches no plan flag has no `claim`/`procedure`/`owner` to ground a fix — treat it as a drift-escape (step 4). Then append every `blockers:` entry — each is a whole-plan/automated-command failure validate attributed with a runnable `command` and an in-delta `file`; its `command` plays the role of a ruling's `procedure` and it joins no plan flag. Never source work from the report body's Potential Issues / Deviations prose on its own: those tie to a work item only when a `risk_rulings` or `blockers` entry names it.
42
42
  3. **Partition the work-list into fixable vs drift-escape.** A failed ruling is **fixable** ONLY when its joined plan flag carries ALL of:
43
43
  - `disposition: verify-at-implement` — the ruling the plan deferred to this exact repair arm;
44
44
  - a concrete, non-empty `procedure` — the named command/test the ruling's own verification runs (the `owner` phase promised it);
45
45
  - a numeric `owner` phase.
46
46
 
47
47
  Every other failed ruling — a `claim_type: mechanics` flag (cited `file:line`, no `procedure`), a bare `{ id, claim }` flag, or a flag missing `owner` — is a **drift-escape**: it has no executable procedure a localized fix can discharge, so an open-ended repair would be guessing.
48
- 4. **Drift-escape gate (checked BEFORE any edit).** If the work-list is empty (`verdict: fail` with no `pass: false` risk ruling at all), print `remediation not localized: no-prescribed-rulings`, edit nothing, and stop. If ANY failed ruling is non-fixable, print `remediation not localized: <ruling-id>` for each non-fixable ruling, edit nothing, and stop. Either way, do NOT print the success closing block.
49
- 5. **Repair pass — one cycle per fixable ruling, single-pass (no in-skill retry loop).** For each fixable ruling, in turn:
50
- - **Run `flag.procedure`** via `Bash`, verbatim (the ruling's own verification command). Capture pass/fail.
51
- - **If it passes already** (the tree may have drifted since validate), the ruling is cleared — record it and move on (no edit).
52
- - **If it fails**, Read/Grep the report body items tied to that ruling `id` (Risk Flag Rulings, Potential Issues, Automated Verification Results) and the plan flag's `claim` + cited `file:line`, then apply the **minimal localized code fix** — the smallest edit grounded in the current tree that makes `flag.procedure` pass. Then **re-run `flag.procedure`** and record the result. One fix attempt per ruling; never loop, never widen the edit, never `ask_user_question`.
53
- 6. **Emit the result.** If every fixable ruling's `procedure` now passes, print the success closing block (below) — the run is fully cleared. If a ruling's `procedure` still fails after its one localized fix, it is not localized either: print `remediation not localized: <ruling-id>` for each un-cleared ruling and OMIT the success closing block; the fixes already applied to cleared rulings stand (single-pass), and re-validate will catch what remains.
48
+
49
+ A `blockers` entry is **fixable** when it carries a concrete, non-empty `command` AND a `file` — the command is its procedure, the file its localization. An entry missing either is a **drift-escape**.
50
+ 4. **Drift-escape gate (checked BEFORE any edit).** If the work-list is empty (`verdict: fail` with no `pass: false` risk ruling and no `blockers` entry at all), print `remediation not localized: no-prescribed-rulings`, edit nothing, and stop. If ANY failed ruling or blocker is non-fixable, print `remediation not localized: <item-id>` for each non-fixable item, edit nothing, and stop. Either way, do NOT print the success closing block.
51
+ 5. **Repair pass — one cycle per fixable item (ruling or blocker), single-pass (no in-skill retry loop).** For each fixable item, in turn:
52
+ - **Run its verification command** via `Bash`, verbatim — a ruling's `flag.procedure`, a blocker's `command`. Capture pass/fail.
53
+ - **If it passes already** (the tree may have drifted since validate), the item is cleared — record it and move on (no edit).
54
+ - **If it fails**, Read/Grep the report body items tied to that item's `id` (Risk Flag Rulings, Potential Issues, Automated Verification Results) and its grounding — a ruling's plan-flag `claim` + cited `file:line`, a blocker's own `file`/`line` — then apply the **minimal localized code fix** — the smallest edit grounded in the current tree that makes the command pass. Then **re-run the command** and record the result. One fix attempt per item; never loop, never widen the edit, never `ask_user_question`.
55
+ 6. **Emit the result.** If every fixable item's command now passes, print the success closing block (below) — the run is fully cleared. If an item's command still fails after its one localized fix, it is not localized either: print `remediation not localized: <item-id>` for each un-cleared item and OMIT the success closing block; the fixes already applied to cleared items stand (single-pass), and re-validate will catch what remains.
54
56
 
55
57
  ## Hard rules
56
58
 
57
- - **Drift-escape, never an open-ended repair.** A failed ruling with no executable `procedure` (a `claim_type: mechanics` flag, a bare `{ id, claim }` flag), an empty work-list when `verdict: fail` has no `pass: false` risk ruling, or a fixable ruling whose `procedure` won't clear in one localized fix — each emits `remediation not localized: <ruling-id>` (or `remediation not localized: no-prescribed-rulings` for the empty case), and the success closing block is withheld. The upfront gate (non-fixable / empty) edits nothing and stops. Never `ask_user_question`, never widen into an un-prescribed repair, never re-run the project's whole build/test suite — that is the downstream validate gate's job.
59
+ - **Drift-escape, never an open-ended repair.** A failed ruling with no executable `procedure` (a `claim_type: mechanics` flag, a bare `{ id, claim }` flag), a `blockers` entry missing its `command` or `file`, an empty work-list when `verdict: fail` has no `pass: false` risk ruling and no `blockers` entry, or a fixable item whose command won't clear in one localized fix — each emits `remediation not localized: <item-id>` (or `remediation not localized: no-prescribed-rulings` for the empty case), and the success closing block is withheld. The upfront gate (non-fixable / empty) edits nothing and stops. Never `ask_user_question`, never widen into an un-prescribed repair, never re-run the project's whole build/test suite — that is the downstream validate gate's job.
58
60
  - **Surgical, single-pass.** Touch only the code a fixable ruling's `procedure` gates; leave passing rulings' code and untouched files byte-for-byte. One fix attempt per ruling — no in-skill retry loop. The validate gate re-judges; that is the validation.
59
61
  - **Fix the code, never the plan or any `.rpiv/artifacts/` document.** Remediate mutates the working tree only. Reading the plan/report to locate a ruling is required; editing the plan, the report, or any artifact is out of scope (that is amend's / revise's authority). The embedded code blocks in a spliced plan are the plan's own content too — remediate does not edit them either; it edits the repo files the ruling's `procedure` exercises.
60
62
  - **Never touch code a passing ruling owns.** A `pass: true` ruling's cited area is verified-correct; editing it risks regressing a cleared dimension.
63
+ - **Repo-located scratch lives under `.rpiv/tmp/`, nowhere else.** Any file you create that is not a ruling's minimal code fix — a procedure driver script, a fixture, a captured payload — goes under `.rpiv/tmp/` (exempt from the workflow's scope floor) or outside the repo entirely. The floor counts **untracked** files too (`git status -uall`): a scratch file left at the repo root or in any undeclared directory is an undeclared write the next `implement-scope-check` flags. Delete repo-located scratch when its procedure is done regardless.
61
64
  - **No subagents. No self-review. No `ask_user_question`.** Apply the localized fixes and re-run the procedures; the validate gate is the validation.
62
65
 
63
66
  ## Closing block
64
67
 
65
- On a fully-cleared run (every failed ruling fixable, every `procedure` now passing), print:
68
+ On a fully-cleared run (every failed ruling/blocker fixable, every command now passing), print:
66
69
 
67
70
  ```
68
- Remediation complete: {N} failed ruling(s) addressed, {M} file(s) changed, {C} command(s) re-run (all pass).
69
- Rulings: {id1} ✓, {id2} ✓ …
71
+ Remediation complete: {N} failed item(s) addressed, {M} file(s) changed, {C} command(s) re-run (all pass).
72
+ Items: {id1} ✓, {id2} ✓ …
70
73
  Outstanding: none.
71
74
  ```
72
75
 
@@ -168,6 +168,7 @@ tags: [plan, synthesized]
168
168
  - Exactly one `## Phase N:` heading per `phases:` entry; `phase_count` == array length == heading count. Number `n` contiguously `1..N`.
169
169
  - **`files:` contract.** Every path a phase creates or edits MUST be listed in that phase's `files:` array (repo-root-relative, never a bare basename) — the same floor-backing reason body citations carry: the plan-time coverage floor (`plan-cite-check`/`code-cite-check`) flags a body edit path absent from `files:`, and a later dep-gated implement fanout derives phase edges from `files:` overlap. A `files:`-less entry degrades to "no check" (legacy-safe), but a `synthesize` plan always declares `files:`.
170
170
  - **Write-scope rule (per-phase, mandatory before parallel implement).** Every command in a phase's `#### Automated Verification:` block must be **write-scoped to that phase's own `files:` set** — running it must not modify anything outside the phase's `files:`. Phases run concurrently under build's parallel implement lane, so a command that rewrites the wider tree corrupts a sibling phase's in-flight edit; narrow any formatter or auto-fixer to the phase's paths (take the project's command vocabulary from its guidance `# Commands` table — where the table gives only an unscoped form, narrow it to the phase's paths rather than substituting a different tool). Read-only repo-wide commands (a type check, a non-fixing lint, a scoped test selection) are permitted. Whole-repo build/test verification belongs to the plan's final whole-plan block, owned by `validate` — never to a phase.
171
+ - **Whole-plan gate achievability rule.** Every command promised in the final whole-plan block must be able to pass on the base tree plus this plan's own changes — validate judges criteria literally, so a criterion that is red at base for files the plan never touches converts pre-existing debt into a permanent `verdict: fail` loop. For repo-wide *style* gates (lint, format checks) default to the delta-scoped form — run the tool over the plan's file union (e.g. `npx eslint <plan files>` exits 0), the same narrowing the per-phase write-scope rule applies. Promise an absolute repo-wide "exits 0" only for build/test commands, or when there is evidence the gate is green at base (the research artifact or project guidance says so). Known base debt the plan won't repair is recorded under Notes as a deferral, never as a criterion. (Mirrored in plan/SKILL.md — edit both together.)
171
172
  - **Who runs AV lines.** `implement` runs each phase's own `#### Automated Verification:` commands in its shell and flips the checkboxes; `validate` re-runs them agent-side over the whole finished plan. Both are agents with a real shell and judgment — no deterministic harness re-executes these lines. Still prefer ONE self-contained command per line that exits 0 when the criterion holds, with the target path inside the backtick span; prose around the span is context for the agent, not executed syntax. Remember AV lines are written before sibling phases land: a check asserting another phase's rename target or source may be true at phase time and false on the final tree — scope each line to what YOUR phase owns.
172
173
  - **Plan-compatible output.** Phases + Success Criteria in the standard plan shape so `implement` and `validate` consume it with no changes.
173
174
  - **No subagents. No self-review. No questions.** Merge, record open risks in Synthesis Notes, write.
@@ -1,8 +1,8 @@
1
1
  ---
2
2
  name: validate
3
3
  description: Verify that an implementation plan was correctly executed by running each phase's success criteria against the working tree and producing a validation report. Use after the implement skill completes, when the user asks to "validate the plan", wants a post-implementation audit, or needs to confirm a feature is fully shipped per its plan.
4
- argument-hint: "[plan-path] [--goal <path>] [--baseline <path>]"
5
- allowed-tools: Read, Bash(git *), Bash(make *), Glob, Grep, Agent
4
+ argument-hint: "[plan-path] [--goal <path>] [--baseline <path>] [--scope <path>]"
5
+ allowed-tools: Read, Bash(git *), Bash(make *), Glob, Grep
6
6
  shell-timeout: 10
7
7
  disable-model-invocation: true
8
8
  contract:
@@ -33,7 +33,7 @@ You are tasked with validating that an implementation plan was correctly execute
33
33
 
34
34
  User input (raw): `$ARGUMENTS`
35
35
 
36
- Expected shape: an optional plan path (usually under `.rpiv/artifacts/plans/`), optionally followed by `--goal <path>` (the user's original brief, captured verbatim at run start) and/or `--baseline <path>` (the run-start snapshot of paths that were ALREADY dirty before the run touched anything — a JSON file with a `paths` array). Peel the `--goal` and `--baseline` flags first; what remains is the plan path. Only if the user input above is empty, or no plan path remains after peeling, branch on the recent-plans list in the Metadata block.
36
+ Expected shape: an optional plan path (usually under `.rpiv/artifacts/plans/`), optionally followed by `--goal <path>` (the user's original brief, captured verbatim at run start), `--baseline <path>` (the run-start snapshot of paths that were ALREADY dirty before the run touched anything — a JSON file with a `paths` array), and/or `--scope <path>` (the workflow scope floor's verdict JSON — `{ verdict, findings: [{ detail, where }] }` — recording writes outside the plan's declared write-set for you to adjudicate). Peel the `--goal`, `--baseline`, and `--scope` flags first; what remains is the plan path. Only if the user input above is empty, or no plan path remains after peeling, branch on the recent-plans list in the Metadata block.
37
37
 
38
38
  ## Metadata
39
39
 
@@ -83,17 +83,10 @@ When invoked:
83
83
  - `git diff <base>..HEAD` — where `<base>` covers the implementation commits (determine from `git log` above). Scope to specific paths if the diff is large.
84
84
  - The plan's own `#### Automated Verification:` commands — read them out of the plan and run them as-written. Do NOT hardcode `make` or any project-specific build tool here; the plan encodes the right commands per project (e.g. `npm run check`, `npm test`, `cargo test`, `pytest`).
85
85
 
86
- 6. **Spawn parallel research agents** to verify implementation:
87
-
88
- Spawn the agents below in parallel using the Agent tool — all in a **single assistant message with multiple Agent calls** (concurrent, synchronous). **Never `run_in_background`**: its completion can't re-drive a workflow session, so the skill ends its turn before writing the validation report and the stage fails with no artifact. Wait for ALL agents to complete before proceeding.
89
-
90
- **Analyzer agent:**
91
- - subagent_type: `codebase-analyzer`
92
- - Prompt: "Analyze {component} and verify it implements {plan requirement} correctly."
93
-
94
- **Pattern finder agent:**
95
- - subagent_type: `codebase-pattern-finder`
96
- - Prompt: "Find patterns similar to {new code} and check if conventions are followed."
86
+ 6. **Check pattern conformance and drift**:
87
+ - For each new or substantially rewritten file, Read an established sibling (same directory or role) and compare shape: imports, naming, error handling, test structure. Record only genuine divergences.
88
+ - Grep for drift the change leaves behind: renamed or removed terms still appearing in comments, docs, or test descriptions; documentation the change makes untrue.
89
+ - Report convention notes under `#### Pattern Conformance:`; stale references and invalidated statements under `#### Deviations from Plan:` or `#### Potential Issues:` by severity.
97
90
 
98
91
  ### Step 2: Systematic Validation
99
92
 
@@ -123,12 +116,22 @@ For each phase in the plan:
123
116
  - Baseline paths are pre-existing, out-of-scope dirt — report them under a short "Pre-existing working-tree changes (baseline)" note for visibility, but NEVER count them as a scope violation or let them force `verdict: fail`.
124
117
  - A missing or unreadable baseline file: fall back to judging the whole tree (today's behavior) and say so in the report.
125
118
 
126
- 6. **Check goal conformance** (only when `--goal` was provided):
119
+ 6. **Attribute whole-plan command failures before they force the verdict.** When a whole-plan (not per-phase) command fails, attribute each failing finding to its file:
120
+ - If **every** failing file is outside the run's own delta — in the `--baseline` paths, or byte-identical to the merge base, verified per file with `git diff --quiet <base> -- <file>` (when the implementation is uncommitted — the workflow's normal case, validate runs before commit — `<base>` is simply `HEAD`) — the failure is pre-existing debt: the criterion was authored against an assumed-clean repo and is unachievable as written. Report it under `#### Potential Issues:` as "pre-existing at base — criterion unachievable as written", rule the criterion **not met, non-blocking**, and record it under `#### Deviations from Plan:` as a *plan* deviation (the criterion, not the implementation, deviated). Do NOT let such a failure alone force `verdict: fail`.
121
+ - The evidence bar is mandatory: no `git diff --quiet` proof for a failing file, no downgrade — the failure blocks as usual.
122
+ - Any failing finding inside the run's delta keeps normal behavior: the command fails, the verdict fails.
123
+
124
+ 7. **Adjudicate scope-floor findings** (only when `--scope` was provided):
125
+ - Read the verdict JSON. If `verdict` is `"pass"` or `findings` is empty, there are no floor findings to rule — but the quarantine-manifest check in the last bullet below **still applies**: a post-quarantine re-check threads a clean `pass` verdict, and the manifest is then the only surviving record of what the run's quarantine arm moved.
126
+ - Each finding names a write outside the plan's declared write-set that the deterministic floor could not classify. Rule each one: an out-of-scope tracked write you can **explain** — a lockfile or generated artifact a declared phase's own commands produce, churn already listed in the `--baseline` paths — is a non-blocking note under `#### Potential Issues:`, quoting the explanation. A write that is **demonstrably the run's own in-goal work** — it implements a named phase's stated change and that phase's verification covers it — is also explained: record it under `#### Deviations from Plan:` as a plan deviation (the owning phase's `files:` is incomplete), non-blocking. An out-of-scope write you **cannot explain forces `verdict: fail`** and is reported as a scope violation (a phase escaped its declared `files:` and may have overwritten sibling work — or the write is not the run's work at all).
127
+ - **Quarantine manifest — check unconditionally, whatever the verdict says.** Glob `.rpiv/artifacts/verdicts/scope-quarantine__*.json`. If a manifest exists, rule on **every** `moved` entry (the record accumulates across fix-loop rounds): each names a run-created undeclared file moved — never deleted — from `from` to `to` under `.rpiv/tmp/scope-quarantine/`. A moved **scratch** file (probe script, fixture, captured payload) is a non-blocking note. A moved file the **deliverable needs** — anything a phase's change references or a criterion exercises — means its phase forgot to declare it in `files:`: report it under `#### Deviations from Plan:`, name the quarantine path it can be restored from, and rule **`verdict: fail`** (the working tree is missing the file). Treat `refused` entries (paths the arm declined to move) the same way.
128
+
129
+ 8. **Check goal conformance** (only when `--goal` was provided):
127
130
  - Read the goal file fully — it is the user's brief in their own words.
128
131
  - Verify the delivered result honors every explicit ask and constraint in it. A goal requirement the plan never carried is still a gap — the plan, not just the implementation, can deviate from the user.
129
132
  - Report shortfalls under **Deviations from Plan**, quoting the goal's actual wording; never infer unstated scope from it.
130
133
 
131
- 7. **Rule every plan risk flag** (when the plan carries a `risks:` frontmatter array):
134
+ 9. **Rule every plan risk flag** (when the plan carries a `risks:` frontmatter array):
132
135
  - The plan's `risks:` array (each `{ id, claim }`, described under `## Risk Flags`) is the structured channel of decisions the planner asked to have checked. You are REQUIRED to rule on each one against the actual implementation — not skip it.
133
136
  - For each flag, verify its `claim` against the delivered code (Read/Grep the relevant `file:line`) and record a `risk_rulings: [{ id, pass }]` entry — `pass: true` when the risk is unfounded or handled, `pass: false` when it is real and unaddressed in the shipped code.
134
137
  - **For a `disposition: verify-at-implement` flag**, do not just Read/Grep — RUN its declared `procedure` (the named command/test the plan's `owner` phase promised) against the shipped code and rule `pass: false` if that procedure fails. This is the phase that discharges the deferral the plan-grade panel accepted on trust; a deferred risk whose procedure now fails is exactly the un-addressed-defect class this gate catches. A mechanics (`claim_type: mechanics`) flag is verified against its shipped `file:line` as above.
@@ -146,13 +149,14 @@ For each phase in the plan:
146
149
  - `topic:` ← `"Validation of <plan topic>"`.
147
150
 
148
151
  2. **Determine verdict** (`status` is always `ready` — written once):
149
- - `verdict: pass` — every phase marked `- [x]` in the plan is verified against the code, every automated command passes, no Deviations from Plan and no Potential Issues require action, and every plan `risks:` flag ruled `pass`.
150
- - `verdict: fail` — any phase fails verification, any automated command fails, any Deviations / Potential Issues list items that require action, **or any plan risk flag ruled `pass: false`** (a flagged risk shipped unaddressed).
152
+ - `verdict: pass` — every phase marked `- [x]` in the plan is verified against the code, every automated command passes (excluding whole-plan failures ruled pre-existing/non-blocking per Step 2.6), no Deviations from Plan and no Potential Issues require action, every plan `risks:` flag ruled `pass`, and every scope-floor finding and quarantine-manifest entry (Step 2.7) is explained.
153
+ - `verdict: fail` — any phase fails verification, any automated command fails (excluding whole-plan failures ruled pre-existing/non-blocking per Step 2.6), any Deviations / Potential Issues list items that require action, **any plan risk flag ruled `pass: false`** (a flagged risk shipped unaddressed), or **any scope-floor finding or quarantined/refused file you could not rule benign** (Step 2.7).
151
154
  - When the plan carried a `risks:` array, add a `risk_rulings: [{ id, pass }]` field to the report frontmatter — one ruling per flag.
155
+ - When any failure forcing `verdict: fail` is NOT already captured by a `pass: false` risk ruling — a whole-plan gate command, or a phase's automated command failing on files inside the run's delta — add a `blockers:` array to the report frontmatter, one entry per failing command: `blockers: [{ id: b1, command: "<the failing command, verbatim-runnable from the repo root>", file: "<in-delta file the failure attributes to>", line: <line> }]` (`file`/`line` come from Step 2.6's attribution; number ids `b1`, `b2`, …). These structured entries are the ONLY handles the workflow's remediation arm may act on — a blocking failure recorded only in the report prose is invisible to it, and the run stops at the validate gate instead of looping. Omit the field when every blocking failure already rides a failing ruling.
152
156
 
153
157
  3. **Write the artifact** using the Write tool (no Edit — this skill writes once per run). Read `templates/validation.md`, fill every `{placeholder}` with the values determined above and the observations gathered in Step 2, apply the section-omission rules in the template (omit `#### Pattern Conformance:` and `#### Potential Issues:` entirely when empty; keep all other sections and emit `None — …` literals when empty), and Write the result to the target path.
154
158
 
155
- **What is NOT emitted to the artifact**: per-agent dispatch logs, raw `git log` output, intermediate reasoning. The Findings subsections capture verified outcomes only — the agent trace stays in the skill run, not the artifact.
159
+ **What is NOT emitted to the artifact**: raw command or `git log` output, intermediate reasoning. The Findings subsections capture verified outcomes only.
156
160
 
157
161
  ### Step 4: Present Summary
158
162
 
@@ -195,12 +199,15 @@ If you were part of the implementation:
195
199
  3. **Document everything** - Both successes and issues
196
200
  4. **Think critically** - Question if the implementation truly solves the problem
197
201
  5. **Consider maintenance** - Will this be maintainable long-term?
202
+ 6. **Repo-located scratch lives under `.rpiv/tmp/`, nowhere else** - Any file you create while running a plan's commands or a risk ruling's `procedure` — a driver script, a fixture, a captured payload — goes under `.rpiv/tmp/` (exempt from the workflow's scope floor) or outside the repo entirely. The floor counts **untracked** files too (`git status -uall`): scratch left anywhere else is an undeclared write the next `implement-scope-check` flags. Delete repo-located scratch when its command is done regardless.
198
203
 
199
204
  ## Validation Checklist
200
205
 
201
206
  Always verify:
202
207
  - [ ] Goal conformance checked when `--goal` was provided
203
208
  - [ ] Working-tree scope criteria judged against tree-minus-baseline when `--baseline` was provided
209
+ - [ ] Scope-floor findings adjudicated AND the quarantine manifest checked (unconditionally) when `--scope` was provided
210
+ - [ ] Whole-plan command failures attributed (run's delta vs. pre-existing at base) before forcing the verdict
204
211
  - [ ] All phases marked complete are actually done
205
212
  - [ ] Automated tests pass
206
213
  - [ ] Code follows existing patterns
@@ -42,7 +42,7 @@ last_updated: {Same ISO timestamp as date: above}
42
42
 
43
43
  #### Pattern Conformance:
44
44
 
45
- _Optional subsection — include when codebase-pattern-finder surfaced observations worth recording. Omit the whole `#### Pattern Conformance:` block when there is nothing to say._
45
+ _Optional subsection — include when the pattern-conformance check surfaced observations worth recording. Omit the whole `#### Pattern Conformance:` block when there is nothing to say._
46
46
 
47
47
  - ✓ {Imports / test structure / naming / mock patterns / etc.} follow established codebase conventions
48
48
  - Minor observation: {non-blocking variation worth flagging — explicitly tag as "acceptable variation, not a deviation"}