prizmkit 1.1.124 → 1.1.126

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 (32) hide show
  1. package/bundled/VERSION.json +3 -3
  2. package/bundled/adapters/claude/command-adapter.js +4 -6
  3. package/bundled/dev-pipeline/prizmkit_runtime/reset.py +49 -3
  4. package/bundled/dev-pipeline/prizmkit_runtime/runners.py +75 -14
  5. package/bundled/dev-pipeline/prizmkit_runtime/runtime_helper.py +37 -0
  6. package/bundled/dev-pipeline/prizmkit_runtime/task_checkout.py +267 -0
  7. package/bundled/dev-pipeline/scripts/generate-recovery-prompt.py +4 -4
  8. package/bundled/dev-pipeline/templates/bootstrap-prompt.md +1 -1
  9. package/bundled/dev-pipeline/templates/bootstrap-tier3.md +5 -16
  10. package/bundled/dev-pipeline/templates/bugfix-bootstrap-prompt.md +6 -14
  11. package/bundled/dev-pipeline/templates/refactor-bootstrap-prompt.md +8 -4
  12. package/bundled/dev-pipeline/templates/sections/bugfix-phase-review.md +9 -8
  13. package/bundled/dev-pipeline/templates/sections/phase-review-agent.md +12 -15
  14. package/bundled/dev-pipeline/templates/sections/phase-review-full.md +11 -16
  15. package/bundled/dev-pipeline/templates/sections/refactor-phase-review.md +9 -8
  16. package/bundled/dev-pipeline/tests/test_generate_bootstrap_prompt.py +8 -4
  17. package/bundled/dev-pipeline/tests/test_generate_bugfix_prompt.py +1 -1
  18. package/bundled/dev-pipeline/tests/test_generate_refactor_prompt.py +1 -1
  19. package/bundled/dev-pipeline/tests/test_python_runner_parity.py +206 -3
  20. package/bundled/dev-pipeline/tests/test_runtime_helper.py +36 -0
  21. package/bundled/dev-pipeline/tests/test_unified_cli.py +21 -12
  22. package/bundled/skills/_metadata.json +4 -4
  23. package/bundled/skills/prizmkit-code-review/SKILL.md +130 -103
  24. package/bundled/skills/prizmkit-code-review/assets/reviewer-role.json +3 -5
  25. package/bundled/skills/prizmkit-code-review/references/review-report-template.md +89 -38
  26. package/bundled/skills/prizmkit-code-review/references/reviewer-agent-prompt.md +44 -62
  27. package/bundled/skills/prizmkit-code-review/scripts/render_review_report.py +249 -143
  28. package/package.json +1 -1
  29. package/bundled/skills/prizmkit-code-review/references/reviewer-execution-protocol.md +0 -179
  30. package/bundled/skills/prizmkit-code-review/references/reviewer-workspace-protocol.md +0 -118
  31. package/bundled/skills/prizmkit-code-review/scripts/check_loop.py +0 -380
  32. package/bundled/skills/prizmkit-code-review/scripts/workspace_snapshot.py +0 -222
@@ -75,6 +75,42 @@ class TestArtifactAndTextHelpers:
75
75
  missing = run_helper("text", "contains", str(target), "--pattern", "gamma")
76
76
  assert first_line(missing) == "GATE:MISSING"
77
77
 
78
+ def test_final_verdict_requires_last_final_result_section(self, tmp_path):
79
+ report = tmp_path / "review-report.md"
80
+ report.write_text(
81
+ "# Review Report\n\n## Status: IN_PROGRESS\n\n"
82
+ "## Main Review Round 1\n\n- Note: incidental PASS text\n",
83
+ encoding="utf-8",
84
+ )
85
+ incomplete = run_helper("text", "final-verdict", str(report))
86
+ assert incomplete.returncode != 0
87
+ assert first_line(incomplete) == "REVIEW_INCOMPLETE"
88
+
89
+ report.write_text(
90
+ report.read_text(encoding="utf-8")
91
+ + "\n## Final Result\n\n- Verdict: PASS\n- Summary: done\n",
92
+ encoding="utf-8",
93
+ )
94
+ complete = run_helper("text", "final-verdict", str(report))
95
+ assert complete.returncode == 0
96
+ assert first_line(complete) == "REVIEW_PASS"
97
+ assert "verdict: PASS" in complete.stdout
98
+
99
+ def test_final_verdict_uses_last_final_result_and_rejects_unknown_value(self, tmp_path):
100
+ report = tmp_path / "review-report.md"
101
+ report.write_text(
102
+ "## Final Result\n- Verdict: PASS\n\n"
103
+ "## Final Result\n- Verdict: BLOCKED\n",
104
+ encoding="utf-8",
105
+ )
106
+ blocked = run_helper("text", "final-verdict", str(report))
107
+ assert first_line(blocked) == "REVIEW_BLOCKED"
108
+
109
+ report.write_text("## Final Result\n- Verdict: UNKNOWN\n", encoding="utf-8")
110
+ invalid = run_helper("text", "final-verdict", str(report))
111
+ assert invalid.returncode != 0
112
+ assert first_line(invalid) == "REVIEW_INVALID"
113
+
78
114
 
79
115
  class TestPlatformExecutableAndPortHelpers:
80
116
  def test_platform_detection_and_skill_lookup_follow_config(self, tmp_path, monkeypatch):
@@ -811,7 +811,7 @@ def test_session_preamble_writes_redacted_start_command_for_all_launch_profiles(
811
811
  assert str(prompt) not in "\n".join(lines[:6])
812
812
 
813
813
 
814
- def test_headless_review_guidance_uses_workspace_and_execution_protocols():
814
+ def test_headless_review_guidance_uses_risk_routed_dual_layer_loop():
815
815
  headless_guidance_files = [
816
816
  REPO_ROOT / "dev-pipeline" / "templates" / "sections" / "phase-review-full.md",
817
817
  REPO_ROOT / "dev-pipeline" / "templates" / "bootstrap-tier3.md",
@@ -827,25 +827,32 @@ def test_headless_review_guidance_uses_workspace_and_execution_protocols():
827
827
 
828
828
  for path in headless_guidance_files:
829
829
  text = path.read_text(encoding="utf-8")
830
- assert "platform-supported" in text, path
831
- assert "snapshot" in text and "equivalent" in text, path
832
830
  assert "Main-Agent self-review" in text, path
831
+ assert "low=0" in text and "medium=1" in text and "high=2" in text, path
832
+ assert "Reviewer 3 is forbidden" in text, path
833
+ assert "text final-verdict" in text, path
834
+ assert "workspace-equivalent" not in text, path
835
+ assert "workspace protocol" not in text, path
833
836
  assert "current-workspace / active-checkout / no-worktree" not in text, path
834
837
  assert ".claude/worktrees/..." not in text, path
835
838
  assert ".prizmkit/state/worktrees/..." not in text, path
836
839
  assert "USE_WORKTREE" not in text, path
837
840
  assert "isolation:" not in text, path
838
- assert "Read existing source files in the modules this plan touches" not in text, path
839
841
 
840
842
  skill_text = skill_path.read_text(encoding="utf-8")
841
- assert "reviewer-workspace-protocol.md" in skill_text
842
- assert "reviewer-execution-protocol.md" in skill_text
843
- assert "staged, unstaged, untracked, deleted, and renamed" in skill_text
844
- assert "content-equivalent" in skill_text
845
- assert "WORKSPACE_MISMATCH" in skill_text
846
- assert "REVIEW_INFRASTRUCTURE_BLOCKED" in skill_text
847
- assert "do not substitute Main-Agent self-review" in skill_text
848
- assert "platform-specific role" in skill_text
843
+ assert "staged and unstaged tracked changes" in skill_text
844
+ assert "untracked files" in skill_text
845
+ assert "accepted = 0" in skill_text
846
+ assert "low: 0" in skill_text and "medium: 1" in skill_text and "high: 2" in skill_text
847
+ assert "accepted high-severity finding" in skill_text
848
+ assert "Do not launch Reviewer 3" in skill_text
849
+ assert "## Final Result" in skill_text
850
+ assert "BLOCKED" in skill_text
851
+ assert "Do not substitute Main-Agent self-review" in skill_text
852
+ assert "reviewer-workspace-protocol.md" not in skill_text
853
+ assert "reviewer-execution-protocol.md" not in skill_text
854
+ assert "WORKSPACE_MISMATCH" not in skill_text
855
+ assert "REVIEW_INFRASTRUCTURE_BLOCKED" not in skill_text
849
856
 
850
857
 
851
858
  def test_progress_parser_adds_required_metadata(tmp_path):
@@ -2227,6 +2234,7 @@ def test_materialize_worktree_support_assets_copies_ignored_assets_without_retir
2227
2234
  (repo / ".prizmkit" / "dev-pipeline" / "prizmkit_runtime").mkdir(parents=True)
2228
2235
  (repo / ".prizmkit" / "dev-pipeline" / "prizmkit_runtime" / "__init__.py").write_text("", encoding="utf-8")
2229
2236
  (repo / ".prizmkit" / "dev-pipeline" / "prizmkit_runtime" / "runtime_helper.py").write_text("# helper", encoding="utf-8")
2237
+ (repo / ".prizmkit" / "dev-pipeline" / "prizmkit_runtime" / "task_checkout.py").write_text("# checkout", encoding="utf-8")
2230
2238
  (repo / ".prizmkit" / "dev-pipeline" / "run-feature.sh").write_text("retired", encoding="utf-8")
2231
2239
 
2232
2240
  runtime = worktree_runtime_context(
@@ -2247,6 +2255,7 @@ def test_materialize_worktree_support_assets_copies_ignored_assets_without_retir
2247
2255
  assert (runtime.worktree_path / ".prizmkit" / "dev-pipeline" / "scripts" / "update-checkpoint.py").is_file()
2248
2256
  assert (runtime.worktree_path / ".prizmkit" / "dev-pipeline" / "prizmkit_runtime" / "__init__.py").is_file()
2249
2257
  assert (runtime.worktree_path / ".prizmkit" / "dev-pipeline" / "prizmkit_runtime" / "runtime_helper.py").is_file()
2258
+ assert (runtime.worktree_path / ".prizmkit" / "dev-pipeline" / "prizmkit_runtime" / "task_checkout.py").is_file()
2250
2259
  assert not (runtime.worktree_path / ".prizmkit" / "dev-pipeline" / "run-feature.sh").exists()
2251
2260
 
2252
2261
  assert guarded_worktree_remove(runtime, delete_branch=False).ok
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.1.124",
2
+ "version": "1.1.126",
3
3
  "skills": {
4
4
  "prizmkit": {
5
5
  "description": "Full-lifecycle dev toolkit. Covers spec-driven development, Prizm context docs, code quality, debugging, deployment, and knowledge management.",
@@ -30,11 +30,11 @@
30
30
  "hasScripts": false
31
31
  },
32
32
  "prizmkit-code-review": {
33
- "description": "Code review with fix strategy formulation. Diagnoses issues, then produces structured Fix Instructions with root cause, impact analysis, and verification criteria.",
33
+ "description": "Independent read-only review with Main-Agent finding adjudication, direct repairs, bounded convergence, and a minimal final report.",
34
34
  "tier": "1",
35
35
  "category": "prizmkit-skill",
36
- "hasAssets": false,
37
- "hasScripts": false
36
+ "hasAssets": true,
37
+ "hasScripts": true
38
38
  },
39
39
  "prizmkit-committer": {
40
40
  "description": "Pure git commit workflow with safety checks. Does NOT modify .prizmkit/prizm-docs/.",
@@ -1,175 +1,202 @@
1
1
  ---
2
2
  name: "prizmkit-code-review"
3
- description: "Run a fail-closed, convergence-driven independent code review against the current spec, plan, complete workspace snapshot, applicable rules, contracts, and test evidence. Use after /prizmkit-implement, before commit when review is required, or whenever the user asks to review code, validate an implementation, find defects, assess regressions, or decide whether changes are ready. Each round launches exactly one fresh read-only non-delegating Reviewer, validates execution and workspace compliance, then has the Main Agent filter and directly fix accepted findings until PASS or the internal safety fuse stops review. (project)"
3
+ description: "Run a risk-routed dual-layer code review against the current spec, plan, workspace changes, applicable rules, contracts, and test evidence. The Main Agent first self-reviews and repairs for up to ten rounds, then semantic risk determines whether zero, one, or two fresh read-only independent Reviewers are required. Findings remain Main-Agent adjudicated, Reviewer 3 is forbidden, and one append-only progress report records the execution through PASS, NEEDS_FIXES, or BLOCKED. (project)"
4
4
  ---
5
5
 
6
6
  # PrizmKit Code Review
7
7
 
8
- Run an independent review-fix loop until the current implementation converges. One fresh Reviewer performs each complete review; the Main Agent alone controls rounds, filters findings, and applies accepted fixes.
9
-
10
- The safety boundary is fail-closed. A Reviewer may run only when its execution environment makes workspace mutation, downstream execution creation, delegation-equivalent behavior, and orchestration re-entry unavailable. Prompt promises alone do not establish this boundary.
8
+ Use a dual-layer review loop: the Main Agent owns iterative review and repair, while fresh independent Reviewers act only as semantic-risk gates.
11
9
 
12
10
  ## When to Use
13
11
 
14
12
  - After `/prizmkit-implement` as the Full path quality gate
15
- - For Fast path when scope, risk, or the user warrants review
16
- - When the user asks to review code, validate implementation, find defects, check regressions, or assess commit readiness
17
- - Before `/prizmkit-committer` when the selected lifecycle requires review
18
-
19
- ## When Not to Use
20
-
21
- - Direct edit or low-risk Fast path where review is intentionally skipped
22
- - No task goal, specification, plan, or other review contract can be identified
23
- - Trivial changes the user explicitly wants committed without review
13
+ - For Fast path when behavior, risk, or the user warrants review
14
+ - When the user asks to validate implementation, find defects, assess regressions, or decide commit readiness
24
15
 
25
16
  ## Input
26
17
 
27
18
  | Parameter | Required | Description |
28
19
  |---|---|---|
29
- | `artifact_dir` | No | Directory containing `spec.md` and `plan.md`. Reuse a caller-provided directory. Otherwise locate the most recently modified completed change artifact under `.prizmkit/`. |
20
+ | `artifact_dir` | No | Directory containing `spec.md` and `plan.md`. Reuse a caller-provided directory; otherwise locate the current completed change artifact. |
30
21
 
31
- ## Authoritative Protocols
22
+ ## Required Assets
32
23
 
33
- Read these references before starting Phase 1:
24
+ - `${SKILL_DIR}/references/reviewer-agent-prompt.md`: independent Reviewer input and output contract
25
+ - `${SKILL_DIR}/references/review-report-template.md`: report lifecycle and append contract
26
+ - `${SKILL_DIR}/assets/reviewer-role.json`: semantic read-only and non-delegating Reviewer boundary
34
27
 
35
- - `${SKILL_DIR}/references/reviewer-execution-protocol.md`: mandatory execution topology, capability attestation, fail-closed behavior, and convergence rules
36
- - `${SKILL_DIR}/references/reviewer-workspace-protocol.md`: deterministic complete snapshots, content identities, transport reuse, and mismatch handling
37
- - `${SKILL_DIR}/references/reviewer-agent-prompt.md`: complete Reviewer prompt contract; fill placeholders without summarizing or omitting normative sections
38
- - `${SKILL_DIR}/assets/reviewer-role.json`: canonical semantic capability manifest used by platform adapters to construct enforceable Reviewer roles
28
+ Do not weaken or summarize the Reviewer prompt. The protocol specifies semantic capabilities rather than platform-specific tool names.
39
29
 
40
- The protocol describes semantic capabilities rather than a platform-specific command or tool denylist. Current platform names in references are non-normative recognition examples only.
30
+ ## Phase 0: Initialize Report and Collect Context
41
31
 
42
- ## Phase 0: Context and Initial Snapshot
32
+ 1. Resolve `{artifact_dir}` and `{artifact_dir}/review-report.md`.
33
+ 2. replace any prior report with a new execution header using the report template. The new report begins with `## Status: IN_PROGRESS` and contains no prior Final Result.
34
+ 3. Read `spec.md`, `plan.md`, relevant `/prizmkit-test` evidence, `.prizmkit/prizm-docs/root.prizm`, applicable progressive docs, and project rules.
35
+ 4. Inspect and capture the complete current Git change:
36
+ - staged and unstaged tracked changes;
37
+ - untracked files;
38
+ - deleted and renamed files;
39
+ - relevant unchanged callers, dependents, contracts, and tests.
40
+ 5. Preserve the existing Reviewer input behavior: staged and unstaged Git diffs, full content of every untracked file, and explicit deleted/renamed states.
41
+ 6. If no changes exist, append risk `low` and exactly one final result with `PASS`, then finish without a Reviewer.
43
42
 
44
- 1. Read `spec.md` and extract goals plus acceptance criteria.
45
- 2. Read `plan.md` and extract architecture decisions plus completed tasks.
46
- 3. Read scoped `/prizmkit-test` evidence when `{artifact_dir}/test-report-path.txt` exists. Preserve scope, generated or updated tests, in-scope failures, baseline failures, gaps, boundary evidence, and verdict.
47
- 4. Read `.prizmkit/prizm-docs/root.prizm` and applicable project rules. Load only relevant progressive documentation.
48
- 5. Capture a content-equivalent complete current logical workspace according to the workspace protocol, including staged, unstaged, untracked, deleted, and renamed states. Prefer `${SKILL_DIR}/scripts/workspace_snapshot.py` when Python is available.
49
- 6. If no changes exist, skip Reviewer launch and write a no-change `PASS` report with execution metadata `NOT_APPLICABLE`.
43
+ ### Checkout Access
50
44
 
51
- ## Phase 1: Convergence Loop
45
+ Prefer direct access to the active checkout. If the platform forces an isolated worktree, provide the same staged and unstaged diffs, untracked file contents, and changed-path states; use the worktree only for baseline and surrounding-context reads. Do not require workspace-equivalence proof.
52
46
 
53
- ### Loop State
47
+ ## Phase 1: Semantic Risk Assessment
54
48
 
55
- Track:
49
+ Classify the current change from behavior and failure impact, not changed-file count or a fixed path allowlist:
56
50
 
57
- ```yaml
58
- round: 1
59
- reviewers_started_total: 0
60
- completed_rounds: 0
61
- structured_result_state: <artifact_dir>/review-result-state.json
62
- ```
51
+ - `low: 0` independent Reviewers — documentation, test text, mechanical change, local low-impact configuration, or trivially verifiable behavior.
52
+ - `medium: 1` independent Reviewer — general business behavior, internal interface changes, or non-critical data processing with user-visible regression potential.
53
+ - `high: 2` independent Reviewers maximum — payments, financial ledgers, authentication, authorization, security, migration, concurrent transactions, irreversible data operations, or public contracts.
54
+
55
+ Mixed risks use the highest applicable level. A large mechanical diff is not automatically high; a small money or authorization change is high.
63
56
 
64
- The internal safety fuse is fixed at ten rounds. It is not caller-configurable, is not a quality target, and never converts unresolved review into `PASS`.
57
+ Append `## Risk Assessment` with the selected risk and concrete reasons before review begins.
65
58
 
66
- ### Step 1: Establish the Reviewer Boundary
59
+ ## Phase 2: Main-Agent Self-Review Loop
67
60
 
68
- 1. Select a fresh Reviewer execution mechanism that satisfies every invariant in the execution protocol.
69
- 2. Establish launch-time capability attestation. Verify that mutation, delegation-equivalent behavior, downstream execution creation, and orchestration re-entry are unavailable.
70
- 3. Ensure the Reviewer receives the complete authoritative prompt template and current snapshot, but no prior findings, verdicts, filtering decisions, Reviewer reasoning, or fix explanations.
71
- 4. In script mode, authorize launch through the strict preflight gate:
61
+ The Main Agent reviews and repairs in the current context. Track Main-Agent rounds independently from Reviewer launch attempts:
72
62
 
73
- ```bash
74
- python3 ${SKILL_DIR}/scripts/check_loop.py < preflight-payload.json
63
+ ```yaml
64
+ main_review_rounds: 0
65
+ independent_reviewers_started: 0
66
+ reviewer_1_accepted_high: false
75
67
  ```
76
68
 
77
- 5. Launch exactly one foreground Reviewer only when the gate returns `launchAuthorized: true`.
69
+ Every Reviewer Agent launch attempt increments `independent_reviewers_started`, including a retry that starts a new Agent. The total may never exceed the semantic-risk limit.
78
70
 
79
- A platform-specific role may be used only when its actual launch configuration proves the semantic boundary. For example, an installed project role whose capability allowlist contains only observational file-inspection capabilities can establish the boundary; a generic subagent with prompt-only restrictions cannot.
71
+ ### Main-Agent Self-Review Loop
80
72
 
81
- If the boundary cannot be established or attested, do not launch a weaker Reviewer and do not substitute Main-Agent self-review. Stop with `NEEDS_FIXES` and blocker `REVIEW_INFRASTRUCTURE_BLOCKED`.
73
+ Each round examines the complete current change against goals, contracts, rules, callers, dependents, regression risks, and test evidence.
82
74
 
83
- ### Step 2: Complete Independent Review
75
+ 1. Identify concrete candidate findings.
76
+ 2. Classify each as:
77
+ - `accepted`: evidence supports the failure scenario;
78
+ - `rejected`: code or governing evidence disproves it or its regression path.
79
+ 3. Append `## Main Review Round N` with findings, accepted, rejected, and next action.
80
+ 4. Apply these rules:
84
81
 
85
- The fresh Reviewer performs the complete review itself. Every round evaluates the complete current change against all applicable requirements, contracts, rules, callers, dependents, regression risks, and test evidence.
82
+ ```text
83
+ accepted = 0 -> self-review converged
84
+ accepted > 0 and round < 10 -> Main Agent directly repairs, verifies, and continues
85
+ accepted > 0 at ten completed Main-Agent rounds -> NEEDS_FIXES
86
+ repair cannot be completed safely -> NEEDS_FIXES
87
+ unresolved new in-scope test failure -> NEEDS_FIXES
88
+ ```
89
+
90
+ When all findings are rejected, `accepted = 0` and the phase converges. Main-Agent rounds never increase the independent Reviewer counter. The fixed limit is ten completed Main-Agent rounds.
91
+
92
+ After each repair batch, append `## Repair Verification` with fixed findings, verification evidence, and next phase.
86
93
 
87
- Later rounds are not historical fix verification. They remain complete independent reviews of current code and receive no previous-round finding context.
94
+ ## Phase 3: Independent Reviewer 1
88
95
 
89
- The Reviewer uses two-direction inspection inside the same execution:
96
+ After Main-Agent self-review and required tests converge:
90
97
 
91
- - Code-forward: changed code affected symbols → callers and dependents concrete failure scenarios
92
- - Requirement-backward: requirements and contracts required behavior → implementation path → side effects → test evidence
98
+ - low risk: skip all independent Reviewers and proceed to final verification;
99
+ - medium or high risk: launch Reviewer 1.
93
100
 
94
- Prefer direct read-only inspection, existing valid evidence, and the narrowest verification that can establish or refute a concrete issue. Broad verification is allowed when a concrete cross-cutting risk requires it and narrower evidence is insufficient.
101
+ Before launch, append:
95
102
 
96
- ### Step 3: Validate Reviewer Output Before Consumption
103
+ ```markdown
104
+ ## Independent Reviewer 1
97
105
 
98
- Before reading, filtering, or acting on any finding, run the result gate with `filtering_done: false`.
106
+ - Status: RUNNING
107
+ - Risk Trigger: <medium|high>
108
+ ```
109
+
110
+ Launch exactly one fresh foreground Reviewer using the unchanged prompt and role. Do not provide previous review findings, filtering decisions, rejection reasons, or repair explanations.
99
111
 
100
- The result is usable only when all of these are proven:
112
+ ### Reviewer Infrastructure Failure
101
113
 
102
- - exactly one fresh Reviewer started in the round;
103
- - capability attestation remains verified;
104
- - descendant execution-unit count is zero;
105
- - delegation depth is zero;
106
- - orchestration status is compliant;
107
- - workspace identity is matched;
108
- - output is complete and structurally valid.
114
+ If the Reviewer cannot start, exits abnormally, returns unusable output, or lacks essential context:
109
115
 
110
- On orchestration violation or unverifiable topology:
116
+ 1. append the observable failure;
117
+ 2. count the failed launch attempt against the semantic-risk Reviewer limit;
118
+ 3. allow at most one infrastructure retry at this same Reviewer position only when the risk limit still has an unused launch;
119
+ 4. append a new RUNNING retry section before retrying and increment the Reviewer launch counter;
120
+ 5. if the retry fails or the risk limit is exhausted, append Final Result `BLOCKED` and stop;
121
+ 6. do not convert infrastructure failure into a code finding;
122
+ 7. Do not substitute Main-Agent self-review for a required independent result.
111
123
 
112
- 1. Stop the Reviewer and identifiable descendants on a best-effort basis.
113
- 2. Discard all Reviewer output without consuming findings.
114
- 3. Do not count the round as completed, retry it, or launch another Reviewer.
115
- 4. Stop Code Review with `NEEDS_FIXES` and `REVIEW_ORCHESTRATION_VIOLATION`.
124
+ ### Finding Adjudication
116
125
 
117
- On post-launch workspace mismatch, discard the output and stop with `NEEDS_FIXES` and `WORKSPACE_MISMATCH`. Do not launch a replacement Reviewer in that round.
126
+ For a usable Reviewer result, append `## Independent Reviewer 1 Result`, then classify every finding as accepted or rejected with evidence.
118
127
 
119
- ### Step 4: Main Agent Filters Findings
128
+ ```text
129
+ accepted = 0 -> Reviewer 1 converged
130
+ accepted > 0 -> Main Agent repairs, verifies, and reruns its self-review loop
131
+ ```
120
132
 
121
- Only after the pre-filter result gate authorizes consumption, classify every finding:
133
+ Accepted findings do not automatically trigger another independent Reviewer.
122
134
 
123
- - `accepted`: a concrete issue that cannot be refuted with current evidence;
124
- - `rejected`: not a defect, out of scope under the governing contract, or disproven with concrete evidence.
135
+ ## Phase 4: Reviewer 2 Eligibility
125
136
 
126
- Do not reject a finding because it is inconvenient, uncertain, or low confidence. If a potentially valid defect cannot be concretely refuted, accept it for repair or leave it unresolved with `NEEDS_FIXES` when repair is unsafe.
137
+ Reviewer 2 is allowed only when every condition is true:
127
138
 
128
- Call the result gate again with `filtering_done: true`, `accepted_count`, and `rejected_count`. Its internal action controls the loop:
139
+ - risk is `high`;
140
+ - Reviewer 1 contained at least one accepted high-severity finding;
141
+ - all accepted high findings were repaired;
142
+ - targeted verification passed;
143
+ - Main-Agent self-review reconverged.
129
144
 
130
- - `PASS`: no accepted findings remain;
131
- - `CONTINUE`: accepted findings remain before the safety limit;
132
- - `STOP`: a blocker exists or round ten remains non-converged.
145
+ Accepted medium or low findings alone never trigger Reviewer 2. Medium risk never starts Reviewer 2.
133
146
 
134
- `CONTINUE` and `STOP` are orchestration actions, not external verdicts.
147
+ When eligible, append a RUNNING section and launch one fresh Reviewer 2 with the unchanged complete-review prompt and current change input.
135
148
 
136
- ### Step 5: Main Agent Applies Accepted Fixes
149
+ After Reviewer 2:
137
150
 
138
- When the gate returns `CONTINUE`:
151
+ - accepted = 0: proceed to final verification;
152
+ - accepted > 0: Main Agent repairs, verifies, and runs its final self-review loop;
153
+ - unresolved repair: `NEEDS_FIXES`;
154
+ - Do not launch Reviewer 3 under any condition.
139
155
 
140
- 1. The Main Agent directly applies the accepted batch in the current workspace. Do not launch a separate Fixer or Dev Agent.
141
- 2. If a repair cannot be completed safely within scope, stop with `NEEDS_FIXES` and record the unresolved finding.
142
- 3. Capture a fresh complete snapshot after fixes.
143
- 4. Increment `round`, create a new execution identity, and return to Step 1.
156
+ ## Phase 5: Append-Only Reporting
144
157
 
145
- Do not send the next Reviewer any prior finding, filtering, or repair history.
158
+ `{artifact_dir}/review-report.md` is the only required persisted review artifact.
146
159
 
147
- ### Text Fallback
160
+ Within one execution, append new sections only. Do not rewrite an earlier progress section. Append after:
148
161
 
149
- When Python is unavailable, manually enforce the same protocol and state transitions. Text fallback removes only script automation; it does not weaken capability attestation, one-Reviewer topology, result validation, output-discard rules, workspace matching, convergence, or the ten-round safety fuse.
162
+ - risk assessment;
163
+ - every Main-Agent review round;
164
+ - every repair and verification batch;
165
+ - every Reviewer launch;
166
+ - every Reviewer result and adjudication;
167
+ - every infrastructure retry;
168
+ - final verification.
150
169
 
151
- If exact validation cannot be performed manually, fail closed with `REVIEW_INFRASTRUCTURE_BLOCKED` rather than guessing compliance.
170
+ A RUNNING section is not edited after completion; append a separate result section. An interrupted execution remains `IN_PROGRESS` and shows its latest running or completed phase.
152
171
 
153
- ## Phase 2: Persist and Report
172
+ ## Phase 6: Final Result
154
173
 
155
- Persist the minimum structured result needed to regenerate the report before rendering Markdown. Include final verdict, blocker code, completed rounds, Reviewers started, execution metadata, snapshot identities, and accepted, rejected, fixed, or unresolved findings.
174
+ Append exactly one final result:
156
175
 
157
- Write `{artifact_dir}/review-report.md` using `${SKILL_DIR}/references/review-report-template.md`. Prefer deterministic rendering:
176
+ ```markdown
177
+ ## Final Result
158
178
 
159
- ```bash
160
- python3 ${SKILL_DIR}/scripts/render_review_report.py \
161
- {artifact_dir}/review-result-state.json \
162
- {artifact_dir}/review-report.md
179
+ - Verdict: PASS | NEEDS_FIXES | BLOCKED
180
+ - Risk: low | medium | high
181
+ - Main Review Rounds: <count>
182
+ - Independent Reviewers Started: <count>
183
+ - Accepted Findings: <count>
184
+ - Fixed Findings: <count>
185
+ - Rejected Findings: <count>
186
+ - Unresolved Findings: <count>
187
+ - Summary: <concise conclusion>
163
188
  ```
164
189
 
165
- If report rendering or path verification fails after review completed, regenerate the report from `review-result-state.json`. Do not rerun Code Review.
190
+ Final outcomes:
166
191
 
167
- External verdicts are limited to:
192
+ - `PASS`: Main-Agent review converged, every required independent review completed, and no accepted finding remains unresolved.
193
+ - `NEEDS_FIXES`: Main-Agent round ten still has accepted findings, a repair is unsafe, or verification remains unresolved.
194
+ - `BLOCKED`: a required independent Reviewer position failed and either its one permitted retry failed or the semantic-risk launch limit left no retry capacity; essential independent-review context is unavailable.
168
195
 
169
- - `PASS`: a usable completed round leaves zero accepted findings, or no workspace changes existed;
170
- - `NEEDS_FIXES`: code findings remain unresolved or any review infrastructure, execution, workspace, result, or safety blocker prevents valid completion.
196
+ Exactly one final result is allowed. Do not append progress after Final Result.
171
197
 
172
198
  Completion handoff:
173
199
 
174
200
  - `PASS`: run `/prizmkit-retrospective` when structural docs or durable knowledge changed; otherwise proceed to `/prizmkit-committer`.
175
- - `NEEDS_FIXES`: report unresolved findings or the diagnostic blocker and stop.
201
+ - `NEEDS_FIXES`: report unresolved findings and stop.
202
+ - `BLOCKED`: report infrastructure evidence and permit recovery.
@@ -1,7 +1,7 @@
1
1
  {
2
- "protocol_version": 1,
2
+ "protocol_version": 2,
3
3
  "role_name": "prizmkit-code-reviewer",
4
- "description": "Use only as the single fresh independent Reviewer launched by /prizmkit-code-review after its strict preflight gate authorizes the round.",
4
+ "description": "Use only as the one fresh independent read-only Reviewer for a completed /prizmkit-code-review round.",
5
5
  "observational_capabilities": [
6
6
  "read-files",
7
7
  "search-content",
@@ -15,7 +15,5 @@
15
15
  "orchestration-reentry",
16
16
  "skill-invocation"
17
17
  ],
18
- "execution_mode": "foreground-single-authority",
19
- "max_descendant_execution_units": 0,
20
- "max_delegation_depth": 0
18
+ "execution_mode": "foreground-independent-review"
21
19
  }
@@ -1,53 +1,104 @@
1
- # Review Report Output Template
1
+ # Review Report Lifecycle Template
2
2
 
3
- Use this template to render `{artifact_dir}/review-report.md` from the persisted structured result. Report regeneration must not rerun Reviewer execution.
3
+ `{artifact_dir}/review-report.md` is the only required persisted review artifact.
4
+
5
+ ## Execution Start
6
+
7
+ Every `/prizmkit-code-review` execution replaces any prior report with:
4
8
 
5
9
  ```markdown
6
10
  # Review Report
7
11
 
8
- ## Verdict: <PASS|NEEDS_FIXES>
9
- ## Rounds Completed: <number>
10
- ## Reviewers Started: <number>
11
- ## Review Mode: <independent-reviewer-verified-snapshot|not-run-no-changes>
12
- ## Reviewer Strategy: <semantic strategy summary|not-applicable>
13
- ## Execution Protocol: <COMPLIANT|BLOCKED|VIOLATION|NOT_APPLICABLE>
14
- ## Capability Attestation: <VERIFIED|FAILED|NOT_APPLICABLE>
15
- ## Descendant Execution Units Observed: <number>
16
- ## Delegation Depth Observed: <number>
17
- ## Snapshot Verification: <VERIFIED|FAILED|NOT_APPLICABLE>
18
- ## Snapshot Identity: <identity|failure reason|not-applicable>
19
- ## Blocker Code: <REVIEW_INFRASTRUCTURE_BLOCKED|REVIEW_ORCHESTRATION_VIOLATION|WORKSPACE_MISMATCH|REVIEW_SAFETY_LIMIT_REACHED|INVALID_REVIEW_RESULT|NONE>
20
- ## Total Findings: <total> → Fixed: <fixed>, Rejected: <rejected>, Unresolved: <unresolved>
21
-
22
- ## Round <N>
23
-
24
- - Snapshot Identity: <identity>
25
- - Reviewer Execution Identity: <identity>
26
- - Result: <PASS|NEEDS_FIXES>
12
+ ## Status: IN_PROGRESS
13
+ ```
14
+
15
+ Within that execution, append sections only. Never edit or replace an earlier progress section.
16
+
17
+ ## Progress Sections
18
+
19
+ ### Risk Assessment
20
+
21
+ ```markdown
22
+ ## Risk Assessment
23
+
24
+ - Risk: <low|medium|high>
25
+ - Independent Reviewer Limit: <0|1|2>
26
+ - Reasons:
27
+ - <concrete behavioral reason>
28
+ ```
29
+
30
+ ### Main-Agent Review Round
31
+
32
+ ```markdown
33
+ ## Main Review Round <N>
34
+
35
+ - Status: COMPLETED
36
+ - Findings: <count>
37
+ - Accepted: <count>
38
+ - Rejected: <count>
39
+ - Next: <next action>
40
+ ```
41
+
42
+ ### Repair Verification
43
+
44
+ ```markdown
45
+ ## Repair Verification
46
+
47
+ - Source: <main|reviewer-1|reviewer-2>
48
+ - Fixed Findings: <count>
49
+ - Verification: <evidence summary>
50
+ - Next: <next action>
51
+ ```
52
+
53
+ ### Independent Reviewer Running
54
+
55
+ ```markdown
56
+ ## Independent Reviewer <N>
57
+
58
+ - Status: RUNNING
59
+ - Risk Trigger: <medium|high>
60
+ - Attempt: <1|2>
61
+ ```
62
+
63
+ ### Independent Reviewer Result
64
+
65
+ ```markdown
66
+ ## Independent Reviewer <N> Result
67
+
68
+ - Status: <COMPLETED|BLOCKED>
69
+ - Result: <PASS|FINDINGS|BLOCKED>
27
70
  - Findings: <count>
28
71
  - Accepted: <count>
29
72
  - Rejected: <count>
73
+ - Accepted High: <count>
74
+ - Next: <next action>
75
+ ```
30
76
 
31
- ### Finding <N>: <short title>
77
+ ## Final Result
32
78
 
33
- - Severity: <high|medium|low>
34
- - Dimension: <dimension>
35
- - Location: <filepath:line|project-level>
36
- - Problem: <what was wrong and why it mattered>
37
- - Failure Scenario: <concrete input or state>
38
- - Status: <fixed in round N|rejected — concrete evidence|unresolved — reason>
79
+ Exactly one Final Result terminates a completed execution:
39
80
 
40
- ## Final Summary
81
+ ```markdown
82
+ ## Final Result
41
83
 
42
- <One to three sentences covering the valid review outcome and any remaining blocker. Do not expose Reviewer reasoning traces.>
84
+ - Verdict: <PASS|NEEDS_FIXES|BLOCKED>
85
+ - Risk: <low|medium|high>
86
+ - Main Review Rounds: <count>
87
+ - Independent Reviewers Started: <count>
88
+ - Accepted Findings: <count>
89
+ - Fixed Findings: <count>
90
+ - Rejected Findings: <count>
91
+ - Unresolved Findings: <count>
92
+ - Summary: <concise conclusion>
43
93
  ```
44
94
 
45
- ## Report Rules
95
+ ## Rules
46
96
 
47
- - No-change review starts no Reviewer, uses zero completed rounds, and records execution plus snapshot metadata as `NOT_APPLICABLE`.
48
- - Findings from a violating or mismatched Reviewer are discarded and excluded from totals.
49
- - A violating or mismatched round is not completed.
50
- - `PASS` requires no workspace changes or a usable complete Reviewer result with zero accepted findings.
51
- - The ten-round safety fuse with accepted findings is `NEEDS_FIXES`, never `PASS`.
52
- - Only `PASS` and `NEEDS_FIXES` are external verdicts. Blocker codes are diagnostic metadata.
53
- - Persist structured state before Markdown rendering so a report-only failure can be recovered without repeating review.
97
+ - Start of a new execution removes stale progress and terminal results from prior executions.
98
+ - A phase appends its result before the next phase starts.
99
+ - Append RUNNING before each independent Reviewer launch or retry.
100
+ - Do not modify a RUNNING section after completion; append its Result section.
101
+ - An IN_PROGRESS report without Final Result is incomplete.
102
+ - Generic or incidental verdict text outside the last Final Result does not prove completion.
103
+ - Do not append any section after Final Result.
104
+ - Do not persist a separate review-state JSON file.