prizmkit 1.1.93 → 1.1.95

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 (34) hide show
  1. package/bundled/VERSION.json +3 -3
  2. package/bundled/agents/prizm-dev-team-critic.md +57 -29
  3. package/bundled/agents/prizm-dev-team-dev.md +2 -14
  4. package/bundled/agents/prizm-dev-team-reviewer.md +40 -24
  5. package/bundled/dev-pipeline/assets/prizm-dev-team-integration.md +3 -2
  6. package/bundled/dev-pipeline/lib/heartbeat.sh +4 -50
  7. package/bundled/dev-pipeline/run-bugfix.sh +2 -20
  8. package/bundled/dev-pipeline/run-feature.sh +2 -20
  9. package/bundled/dev-pipeline/run-refactor.sh +2 -20
  10. package/bundled/dev-pipeline/templates/bootstrap-tier2.md +53 -7
  11. package/bundled/dev-pipeline/templates/bootstrap-tier3.md +9 -6
  12. package/bundled/dev-pipeline/templates/sections/phase-critic-plan-full.md +1 -1
  13. package/bundled/dev-pipeline/templates/sections/phase-review-full.md +1 -3
  14. package/bundled/dev-pipeline-windows/assets/prizm-dev-team-integration.md +3 -2
  15. package/bundled/dev-pipeline-windows/lib/pipeline.ps1 +6 -58
  16. package/bundled/dev-pipeline-windows/templates/bootstrap-tier2.md +5 -6
  17. package/bundled/dev-pipeline-windows/templates/bootstrap-tier3.md +9 -6
  18. package/bundled/dev-pipeline-windows/templates/sections/phase-critic-plan-full.md +1 -1
  19. package/bundled/dev-pipeline-windows/templates/sections/phase-review-full.md +1 -3
  20. package/bundled/rules/_rules-metadata.json +9 -3
  21. package/bundled/rules/general/agent-operational-rules.md +68 -0
  22. package/bundled/skills/_metadata.json +1 -1
  23. package/bundled/skills/feature-planner/SKILL.md +2 -2
  24. package/bundled/skills/feature-planner/references/error-recovery.md +1 -1
  25. package/bundled/skills/feature-planner/references/incremental-feature-planning.md +1 -1
  26. package/bundled/skills/feature-planner/references/new-project-planning.md +1 -1
  27. package/bundled/skills/feature-planner/scripts/validate-and-generate.py +17 -26
  28. package/bundled/skills-windows/feature-planner/SKILL.md +2 -2
  29. package/bundled/skills-windows/feature-planner/references/error-recovery.md +1 -1
  30. package/bundled/skills-windows/feature-planner/references/incremental-feature-planning.md +1 -1
  31. package/bundled/skills-windows/feature-planner/references/new-project-planning.md +1 -1
  32. package/bundled/skills-windows/feature-planner/scripts/validate-and-generate.py +17 -26
  33. package/bundled/team/prizm-dev-team.json +6 -6
  34. package/package.json +1 -1
@@ -184,7 +184,7 @@ Wait for Reviewer to return.
184
184
  **CP-2**: No CRITICAL issues.
185
185
 
186
186
  {{IF_CRITIC_ENABLED}}
187
- ### Phase 3.5: Plan Challenge — Critic Agent
187
+ ### Phase 3.5: Plan Challenge — Critic Agent(s)
188
188
 
189
189
  **Guard**: Verify critic agent file exists before spawning:
190
190
  ```bash
@@ -192,9 +192,13 @@ ls {{CRITIC_SUBAGENT_PATH}} 2>/dev/null && echo "CRITIC:READY" || echo "CRITIC:M
192
192
  ```
193
193
  If CRITIC:MISSING — skip Phase 3.5 entirely and proceed to Phase 4. Log: "Critic agent not installed — skipping Plan Challenge."
194
194
 
195
+ **Choose ONE path based on `{{CRITIC_COUNT}}`:**
196
+
197
+ **If {{CRITIC_COUNT}} = 1 → Single Critic** (skip to CP-2.5 after this):
198
+
195
199
  Spawn Critic agent (Agent tool, subagent_type="prizm-dev-team-critic", mode="plan", run_in_background=false).
196
200
 
197
- Spawn failure cap: for team/config/lock errors, retry at most once for this Critic spawn. If the second attempt fails, do not poll for `challenge-report.md`; perform the plan challenge inline and record the fallback.
201
+ Spawn failure cap: for team/config/lock errors, retry at most once for this Critic spawn. If the second attempt fails, do not poll for challenge reports; perform the plan challenge inline and record the fallback.
198
202
 
199
203
  Prompt:
200
204
  > "Read {{CRITIC_SUBAGENT_PATH}}. For feature {{FEATURE_ID}} (slug: {{FEATURE_SLUG}}):
@@ -209,6 +213,49 @@ Wait for Critic to return.
209
213
  - Read challenge-report.md. For items marked CRITICAL/HIGH: decide whether to adjust plan.md or document why the plan stands.
210
214
  - Max 1 plan revision round.
211
215
 
216
+ **If {{CRITIC_COUNT}} = 3 → Multi-Critic Voting** (skip Single Critic above):
217
+
218
+ **IMPORTANT**: Spawn all 3 Critics in PARALLEL (issue all 3 Agent tool calls in the SAME message turn). Do NOT wait for one before spawning the next.
219
+
220
+ Spawn Critic-A, Critic-B, Critic-C simultaneously (each with mode="plan", run_in_background=false):
221
+
222
+ Critic-A prompt:
223
+ > "Read {{CRITIC_SUBAGENT_PATH}}. For feature {{FEATURE_ID}} (slug: {{FEATURE_SLUG}}):
224
+ > **MODE: Plan Challenge — Lens: Architecture & Scalability**
225
+ > Focus on: architectural pattern fit, scalability implications, over-engineering risks, component boundary design.
226
+ > 1. Read `.prizmkit/specs/{{FEATURE_SLUG}}/context-snapshot.md` FIRST — Section 3 has TRAPS/RULES, Section 4 has file manifest.
227
+ > 2. Read `.prizmkit/prizm-docs/root.prizm` and relevant L1/L2 docs for affected modules.
228
+ > 3. Read existing source files in the modules this plan touches.
229
+ > 4. Challenge plan.md through your architecture lens.
230
+ > Write `.prizmkit/specs/{{FEATURE_SLUG}}/challenge-report-A.md`."
231
+
232
+ Critic-B prompt:
233
+ > "Read {{CRITIC_SUBAGENT_PATH}}. For feature {{FEATURE_ID}} (slug: {{FEATURE_SLUG}}):
234
+ > **MODE: Plan Challenge — Lens: Data Model & Edge Cases**
235
+ > Focus on: data model design fit, entity relationships, edge cases in business logic, missing boundary conditions.
236
+ > 1. Read `.prizmkit/specs/{{FEATURE_SLUG}}/context-snapshot.md` FIRST — Section 3 has TRAPS/RULES, Section 4 has file manifest.
237
+ > 2. Read `.prizmkit/prizm-docs/root.prizm` and relevant L1/L2 docs for affected modules.
238
+ > 3. Read existing source files in the modules this plan touches.
239
+ > 4. Challenge plan.md through your data/edge-case lens.
240
+ > Write `.prizmkit/specs/{{FEATURE_SLUG}}/challenge-report-B.md`."
241
+
242
+ Critic-C prompt:
243
+ > "Read {{CRITIC_SUBAGENT_PATH}}. For feature {{FEATURE_ID}} (slug: {{FEATURE_SLUG}}):
244
+ > **MODE: Plan Challenge — Lens: Security & Performance**
245
+ > Focus on: security attack surface, authentication/authorization gaps, performance bottlenecks, resource leaks.
246
+ > 1. Read `.prizmkit/specs/{{FEATURE_SLUG}}/context-snapshot.md` FIRST — Section 3 has TRAPS/RULES, Section 4 has file manifest.
247
+ > 2. Read `.prizmkit/prizm-docs/root.prizm` and relevant L1/L2 docs for affected modules.
248
+ > 3. Read existing source files in the modules this plan touches.
249
+ > 4. Challenge plan.md through your security/performance lens.
250
+ > Write `.prizmkit/specs/{{FEATURE_SLUG}}/challenge-report-C.md`."
251
+
252
+ Spawn failure cap: for team/config/lock errors, each Critic retries at most once. If 2 or more Critics fail to spawn after retry, perform the plan challenge inline and record the fallback.
253
+
254
+ After all critics return, read all 3 reports:
255
+ - Challenge raised by **2/3 or more** critics → **must respond** (adjust plan or justify why not)
256
+ - Challenge raised by **1/3 only** → logged in context-snapshot but not blocking
257
+ - Max 1 plan revision round.
258
+
212
259
  **CP-2.5**: Plan challenges reviewed and resolved.
213
260
  {{END_IF_CRITIC_ENABLED}}
214
261
 
@@ -254,7 +301,7 @@ Gate requirements:
254
301
  - Only after a valid `PASS`, write the report path to `.prizmkit/specs/{{FEATURE_SLUG}}/test-report-path.txt` and append a 3-5 bullet `## PrizmKit Test Gate` summary to `context-snapshot.md`.
255
302
  - If the report verdict is `NEEDS_FIXES`, fix in-scope implementation/test issues and rerun `/prizmkit-test`. If the report is `BLOCKED`, missing, stale, or for the wrong scope/artifact dir, write `failure-log.md` and stop for recovery.
256
303
 
257
- ### Phase 5: Review + Test — Reviewer Subagent
304
+ ### Phase 5: Review — Reviewer Subagent
258
305
 
259
306
  Spawn Reviewer subagent (Agent tool, subagent_type="prizm-dev-team-reviewer", run_in_background=false).
260
307
 
@@ -266,8 +313,7 @@ Prompt:
266
313
  > 2. Read `.prizmkit/specs/{{FEATURE_SLUG}}/plan.md` for architecture decisions and completed tasks
267
314
  > 3. Read `.prizmkit/specs/{{FEATURE_SLUG}}/test-report-path.txt`, then read the referenced `/prizmkit-test` report. Review generated/updated tests, `In-Scope Failures`, `Baseline Failures`, `Out of Scope Gaps`, boundary coverage if present, and the report verdict.
268
315
  > 4. Run /prizmkit-code-review with artifact_dir=.prizmkit/specs/{{FEATURE_SLUG}}/. The skill runs an internal review-fix loop (Reviewer → filter → Dev fix, max 3 rounds) and writes review-report.md.
269
- > 5. Run the full test suite using `{{TEST_CMD}}`. When running: `({{TEST_CMD}}) 2>&1 | tee /tmp/review-test-out.txt | tail -20`, then grep the file for details — do NOT re-run the suite multiple times.
270
- > 6. review-report.md will be written to .prizmkit/specs/{{FEATURE_SLUG}}/ by prizmkit-code-review.
316
+ > 5. Do NOT run test suites the Orchestrator already ran prizmkit-test. Focus on code review and fix strategy.
271
317
  > Report: verdict (PASS/NEEDS_FIXES), number of rounds, findings fixed/rejected."
272
318
 
273
319
  Wait for Reviewer to return.
@@ -287,7 +333,7 @@ Read `review-report.md` and check the Verdict:
287
333
  - `PASS` → proceed to next phase
288
334
  - `NEEDS_FIXES` → the skill exhausted its max rounds; log the remaining findings and proceed
289
335
 
290
- **CP-3**: Tests pass, review complete.
336
+ **CP-3**: Review complete.
291
337
 
292
338
  {{IF_BROWSER_INTERACTION}}
293
339
  ### Phase 5.5: Browser Verification — MANDATORY
@@ -551,7 +597,7 @@ If you encounter an unrecoverable error, context overflow, or are about to exit
551
597
 
552
598
  ## Reminders
553
599
 
554
- - Tier 2: orchestrator builds context+plan, Analyzer checks consistency, Dev implements, Reviewer reviews+tests — use direct Agent spawn for agents
600
+ - Tier 2: orchestrator builds context+plan, Analyzer checks consistency, Dev implements, Reviewer reviews — use direct Agent spawn for agents
555
601
  - Build context-snapshot.md FIRST; all subagents read it instead of re-reading source files
556
602
  - context-snapshot.md is append-only: orchestrator writes Sections 1-4, Dev appends Implementation Log, Reviewer appends Review Notes
557
603
  - Gate checks enforce Implementation Log and Review Notes are written before proceeding
@@ -234,7 +234,9 @@ Prompt:
234
234
 
235
235
  **If {{CRITIC_COUNT}} = 3 → Multi-Critic Voting** (skip Single Critic above):
236
236
 
237
- Spawn 3 Critic agents sequentially (each with mode="plan", run_in_background=false), each with a different focus lens:
237
+ **IMPORTANT**: Spawn all 3 Critics in PARALLEL (issue all 3 Agent tool calls in the SAME message turn). Do NOT wait for one before spawning the next.
238
+
239
+ Spawn Critic-A, Critic-B, Critic-C simultaneously (each with mode="plan", run_in_background=false):
238
240
 
239
241
  Critic-A prompt (append to base prompt above):
240
242
  > "**Focus Lens: Architecture & Scalability.** Prioritize: architectural pattern fit, scalability implications, over-engineering risks, component boundary design.
@@ -248,6 +250,8 @@ Critic-C prompt (append to base prompt above):
248
250
  > "**Focus Lens: Security & Performance.** Prioritize: security attack surface, authentication/authorization gaps, performance bottlenecks, resource leaks.
249
251
  > Write `.prizmkit/specs/{{FEATURE_SLUG}}/challenge-report-C.md`."
250
252
 
253
+ Spawn failure cap: for team/config/lock errors, each Critic retries at most once. If 2 or more Critics fail to spawn after retry, perform the plan challenge inline and record the fallback.
254
+
251
255
  After all critics return, read all 3 reports:
252
256
  - Challenge raised by **2/3 or more** critics → **must respond** (adjust plan or justify why not)
253
257
  - Challenge raised by **1/3 only** → logged in context-snapshot but not blocking
@@ -315,7 +319,7 @@ Gate requirements:
315
319
  - Only after a valid `PASS`, write the report path to `.prizmkit/specs/{{FEATURE_SLUG}}/test-report-path.txt` and append a 3-5 bullet `## PrizmKit Test Gate` summary to `context-snapshot.md`.
316
320
  - If the report verdict is `NEEDS_FIXES`, fix in-scope implementation/test issues and rerun `/prizmkit-test`. If the report is `BLOCKED`, missing, stale, or for the wrong scope/artifact dir, write `failure-log.md` and stop for recovery.
317
321
 
318
- ### Phase 5: Review + Test — Reviewer Agent
322
+ ### Phase 5: Review — Reviewer Agent
319
323
 
320
324
  Spawn Reviewer agent (Agent tool, subagent_type="prizm-dev-team-reviewer", run_in_background=false).
321
325
 
@@ -327,8 +331,7 @@ Prompt:
327
331
  > 2. Read `.prizmkit/specs/{{FEATURE_SLUG}}/plan.md` for architecture decisions and completed tasks
328
332
  > 3. Read `.prizmkit/specs/{{FEATURE_SLUG}}/test-report-path.txt`, then read the referenced `/prizmkit-test` report. Review generated/updated tests, `In-Scope Failures`, `Baseline Failures`, `Out of Scope Gaps`, boundary coverage if present, and the report verdict.
329
333
  > 4. Run /prizmkit-code-review with artifact_dir=.prizmkit/specs/{{FEATURE_SLUG}}/. The skill runs an internal review-fix loop (Reviewer → filter → Dev fix, max 3 rounds) and writes review-report.md.
330
- > 5. Run the full test suite using `{{TEST_CMD}}`. When running tests: `({{TEST_CMD}}) 2>&1 | tee /tmp/review-test-out.txt | tail -20`, then grep `/tmp/review-test-out.txt` for details — do NOT re-run the suite multiple times.
331
- > 6. review-report.md will be written to .prizmkit/specs/{{FEATURE_SLUG}}/ by prizmkit-code-review.
334
+ > 5. Do NOT run test suites the Orchestrator already ran prizmkit-test. Focus on code review and fix strategy.
332
335
  > Report: verdict (PASS/NEEDS_FIXES), number of rounds, findings fixed/rejected."
333
336
 
334
337
  Wait for Reviewer to return.
@@ -348,7 +351,7 @@ Read `review-report.md` and check the Verdict:
348
351
  - `PASS` → proceed to next phase
349
352
  - `NEEDS_FIXES` → the skill exhausted its max rounds; log the remaining findings and proceed
350
353
 
351
- **CP-3**: Integration tests pass, review complete.
354
+ **CP-3**: Review complete.
352
355
 
353
356
  {{IF_BROWSER_INTERACTION}}
354
357
  ### Phase 5.5: Browser Verification — MANDATORY
@@ -629,7 +632,7 @@ If you encounter an unrecoverable error, context overflow, or are about to exit
629
632
 
630
633
  ## Reminders
631
634
 
632
- - Tier 3: full team — Dev (implementation) → Reviewer (review + test) — spawn agents directly via Agent tool
635
+ - Tier 3: full team — Dev (implementation) → Reviewer (review) — spawn agents directly via Agent tool
633
636
  - context-snapshot.md is append-only: orchestrator writes Sections 1-4, Dev appends Implementation Log, Reviewer appends Review Notes
634
637
  - Gate checks enforce Implementation Log and Review Notes are written before proceeding
635
638
  - Do NOT use `run_in_background=true` when spawning agents
@@ -32,7 +32,7 @@ If CRITIC:MISSING — skip this phase entirely and proceed. Log: "Critic agent n
32
32
 
33
33
  **If {{CRITIC_COUNT}} = 3 → Multi-Critic Voting** (skip Single Critic above):
34
34
 
35
- Spawn 3 Critic agents sequentially (each with mode="plan", run_in_background=false), each with a different focus lens:
35
+ Spawn 3 Critic agents in PARALLEL (issue all 3 Agent tool calls in the SAME message turn). Do NOT wait for one before spawning the next. Each with mode="plan", run_in_background=false:
36
36
 
37
37
  Critic-A prompt (append to base prompt above):
38
38
  > "**Focus Lens: Architecture & Scalability.** Prioritize: architectural pattern fit, scalability implications, over-engineering risks, component boundary design.
@@ -23,9 +23,7 @@ Read `review-report.md` and check the Verdict:
23
23
  - `PASS` → proceed to next phase
24
24
  - `NEEDS_FIXES` → the skill exhausted its max rounds; log the remaining findings and proceed (do not retry externally)
25
25
 
26
- Run the full test suite: `({{TEST_CMD}}) 2>&1 | tee /tmp/review-test-out.txt | tail -20`
27
-
28
- **CP-3**: Review complete, report written, and the Test Failure Recovery Protocol's Success Rule is satisfied.
26
+ **CP-3**: Review complete, report written.
29
27
 
30
28
 
31
29
  **Checkpoint update**: Run the update script to set step `prizmkit-code-review` to `"completed"`:
@@ -18,9 +18,10 @@ dev-pipeline (outer loop)
18
18
  ├── Phase 0: Init (Orchestrator)
19
19
  ├── Phase 1-2: Context snapshot + Specify + Plan (Orchestrator)
20
20
  ├── Phase 3: Analyze (Reviewer agent) [tier2] / Phase 4: Analyze [tier3]
21
+ ├── Phase 3.5: Plan Challenge (Critic agent(s), 1 or 3 parallel) [tier2+]
21
22
  ├── Phase 4: Implement (Dev agent) [tier2] / Phase 5: Implement [tier3]
22
- ├── Phase 4.5/6: Review (Reviewer agent)
23
- └── Phase 5/7: Retrospective & Commit (Orchestrator)
23
+ ├── Phase 5: Review (Reviewer agent)
24
+ └── Phase 6: Retrospective & Commit (Orchestrator)
24
25
 
25
26
  └── Write session-status.json → exit
26
27
  ```
@@ -291,12 +291,12 @@ function Invoke-PrizmPipeline {
291
291
  }
292
292
 
293
293
  function Write-PrizmStaleKillMarker {
294
- param([string]$MarkerPath, [int]$StaleSeconds, [int]$Threshold, [string]$Reason = 'stale_session')
294
+ param([string]$MarkerPath, [int]$StaleSeconds, [int]$Threshold)
295
295
  $markerDir = Split-Path $MarkerPath -Parent
296
296
  if ($markerDir) { New-Item -ItemType Directory -Force -Path $markerDir | Out-Null }
297
297
  [ordered]@{
298
298
  killed_at = (Get-Date).ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ssZ')
299
- reason = $Reason
299
+ reason = 'stale_session'
300
300
  stale_seconds = $StaleSeconds
301
301
  threshold = $Threshold
302
302
  } | ConvertTo-Json -Compress | Set-Content -Path $MarkerPath -Encoding UTF8
@@ -726,11 +726,9 @@ function Invoke-PrizmPipeline {
726
726
 
727
727
  $elapsedSeconds = 0
728
728
  $staleSeconds = 0
729
- $staleReason = 'stale_session'
730
729
  $previousLogSize = 0
731
730
  $previousProgressSignature = ''
732
731
  $previousChildActivitySignature = ''
733
- $previousErrorLoopSignature = ''
734
732
  $staleKillMarker = Join-Path $logsDir 'stale-kill.json'
735
733
  $wasStaleKilled = $false
736
734
  while ($true) {
@@ -755,42 +753,9 @@ function Invoke-PrizmPipeline {
755
753
 
756
754
  $effectiveStaleKillThreshold = Get-PrizmEffectiveStaleKillThreshold -ProgressFile $progressJson -BaseThreshold $staleKillThreshold
757
755
 
758
- # Check for error-loop: agent is actively producing output but results are
759
- # all read-offset errors or wasted calls. Only a newly advancing error
760
- # signature counts; stale historical errors must not turn later normal output
761
- # into a stale kill.
762
- $errorLoopDetected = $false
763
- $errorLoopSignature = ''
764
- if ($effectiveStaleKillThreshold -gt 0 -and $growth -gt 0 -and (Test-Path $progressJson)) {
765
- try {
766
- $progress = Get-Content $progressJson -Raw | ConvertFrom-Json
767
- $errors = $progress.errors
768
- if ($errors -is [array] -and $errors.Count -ge 5) {
769
- $recent = $errors[-5..-1]
770
- $allBad = ($recent | Where-Object {
771
- $_.type -in @("read_offset_overflow", "wasted_call")
772
- }).Count -eq 5
773
- if ($allBad) {
774
- $errorLoopSignature = ($recent | ConvertTo-Json -Compress)
775
- if ($previousErrorLoopSignature -and $errorLoopSignature -ne $previousErrorLoopSignature) {
776
- $errorLoopDetected = $true
777
- }
778
- }
779
- }
780
- } catch {
781
- # Ignore JSON parse errors — progress file may be incomplete or malformed
782
- }
783
- }
784
- $previousErrorLoopSignature = $errorLoopSignature
785
-
786
- if ($errorLoopDetected) {
787
- $staleReason = 'error_loop'
788
- $staleSeconds = $effectiveStaleKillThreshold
789
- } elseif ($growth -gt 0 -or $childAdvanced -or $progressAdvanced) {
790
- $staleReason = 'stale_session'
756
+ if ($growth -gt 0 -or $childAdvanced -or $progressAdvanced) {
791
757
  $staleSeconds = 0
792
758
  } else {
793
- $staleReason = 'stale_session'
794
759
  $staleSeconds += $heartbeatInterval
795
760
  }
796
761
 
@@ -807,12 +772,8 @@ function Invoke-PrizmPipeline {
807
772
  }
808
773
  if ($effectiveStaleKillThreshold -gt 0 -and $staleSeconds -ge $effectiveStaleKillThreshold) {
809
774
  $wasStaleKilled = $true
810
- if ($staleReason -eq 'error_loop') {
811
- Write-PrizmWarn "Session stale-killed due to repeated read-offset/wasted-call error loop"
812
- } else {
813
- Write-PrizmWarn "Session stale-killed (no progress for ${effectiveStaleKillThreshold}s)"
814
- }
815
- Write-PrizmStaleKillMarker $staleKillMarker $staleSeconds $effectiveStaleKillThreshold $staleReason
775
+ Write-PrizmWarn "Session stale-killed (no progress for ${effectiveStaleKillThreshold}s)"
776
+ Write-PrizmStaleKillMarker $staleKillMarker $staleSeconds $effectiveStaleKillThreshold
816
777
  Stop-PrizmSessionProcess $pidPath
817
778
  if ($staleKillGraceSeconds -gt 0) { Start-Sleep -Seconds $staleKillGraceSeconds }
818
779
  break
@@ -835,15 +796,6 @@ function Invoke-PrizmPipeline {
835
796
  }
836
797
  Stop-PrizmProgressParser $parserProcess
837
798
 
838
- $staleKillReason = ''
839
- if (Test-Path $staleKillMarker) {
840
- try {
841
- $staleKillData = Get-Content $staleKillMarker -Raw | ConvertFrom-Json
842
- if ($staleKillData.PSObject.Properties['reason']) { $staleKillReason = [string]$staleKillData.reason }
843
- } catch {
844
- $staleKillReason = ''
845
- }
846
- }
847
799
  $wasInfraError = ($exitCode -ne 0 -and (Test-PrizmInfraError -SessionLog $sessionLog -ProgressJson $progressJson))
848
800
  $wasAiRuntimeError = Test-PrizmAiRuntimeError -SessionLog $sessionLog -ProgressJson $progressJson
849
801
  $semanticCompletion = if ($Kind -eq 'feature' -and $isGitRepository) {
@@ -866,11 +818,7 @@ function Invoke-PrizmPipeline {
866
818
  Write-PrizmWarn "AI session failed due to AI CLI/provider infrastructure error"
867
819
  Write-PrizmWarn "Infrastructure errors are retried without consuming code retry budget"
868
820
  } elseif ($wasStaleKilled -or (Test-Path $staleKillMarker)) {
869
- if ($staleKillReason -eq 'error_loop') {
870
- Write-PrizmWarn "Session was killed by heartbeat monitor due to repeated read-offset/wasted-call errors"
871
- } else {
872
- Write-PrizmWarn "Session was stale-killed by heartbeat monitor (no progress for too long)"
873
- }
821
+ Write-PrizmWarn "Session was stale-killed by heartbeat monitor (no progress for too long)"
874
822
  Write-PrizmWarn "Heartbeat-killed sessions are treated as failed; dev branch is preserved for inspection"
875
823
  } elseif ($exitCode -ne 0) {
876
824
  Write-PrizmWarn "AI session exited with code $exitCode"
@@ -220,7 +220,7 @@ Wait for Reviewer to return.
220
220
  **CP-2**: No CRITICAL issues.
221
221
 
222
222
  {{IF_CRITIC_ENABLED}}
223
- ### Phase 3.5: Plan Challenge — Critic Agent
223
+ ### Phase 3.5: Plan Challenge — Critic Agent(s)
224
224
 
225
225
  **Guard**: Verify critic agent file exists before spawning:
226
226
  ```powershell
@@ -290,7 +290,7 @@ Gate requirements:
290
290
  - Only after a valid `PASS`, write the report path to `.prizmkit/specs/{{FEATURE_SLUG}}/test-report-path.txt` and append a 3-5 bullet `## PrizmKit Test Gate` summary to `context-snapshot.md`.
291
291
  - If the report verdict is `NEEDS_FIXES`, fix in-scope implementation/test issues and rerun `/prizmkit-test`. If the report is `BLOCKED`, missing, stale, or for the wrong scope/artifact dir, write `failure-log.md` and stop for recovery.
292
292
 
293
- ### Phase 5: Review + Test — Reviewer Subagent
293
+ ### Phase 5: Review — Reviewer Subagent
294
294
 
295
295
  Spawn Reviewer subagent (Agent tool, subagent_type="prizm-dev-team-reviewer", run_in_background=false).
296
296
 
@@ -302,8 +302,7 @@ Prompt:
302
302
  > 2. Read `.prizmkit/specs/{{FEATURE_SLUG}}/plan.md` for architecture decisions and completed tasks
303
303
  > 3. Read `.prizmkit/specs/{{FEATURE_SLUG}}/test-report-path.txt`, then read the referenced `/prizmkit-test` report. Review generated/updated tests, `In-Scope Failures`, `Baseline Failures`, `Out of Scope Gaps`, boundary coverage if present, and the report verdict.
304
304
  > 4. Run /prizmkit-code-review with artifact_dir=.prizmkit/specs/{{FEATURE_SLUG}}/. The skill runs an internal review-fix loop (Reviewer → filter → Dev fix, max 3 rounds) and writes review-report.md.
305
- > 5. Run the full test suite using `{{TEST_CMD}}`. When running: `& { {{TEST_CMD}} } 2>&1 | Tee-Object (Join-Path $env:TEMP "review-test-out.txt") | Select-Object -Last 20`, then use Select-String on the file for details — do NOT re-run the suite multiple times.
306
- > 6. review-report.md will be written to .prizmkit/specs/{{FEATURE_SLUG}}/ by prizmkit-code-review.
305
+ > 5. Do NOT run test suites the Orchestrator already ran prizmkit-test. Focus on code review and fix strategy.
307
306
  > Report: verdict (PASS/NEEDS_FIXES), number of rounds, findings fixed/rejected."
308
307
 
309
308
  Wait for Reviewer to return.
@@ -323,7 +322,7 @@ Read `review-report.md` and check the Verdict:
323
322
  - `PASS` → proceed to next phase
324
323
  - `NEEDS_FIXES` → the skill exhausted its max rounds; log the remaining findings and proceed
325
324
 
326
- **CP-3**: Tests pass, review complete.
325
+ **CP-3**: Review complete.
327
326
 
328
327
  {{IF_BROWSER_INTERACTION}}
329
328
  ### Phase 5.5: Browser Verification — MANDATORY
@@ -696,7 +695,7 @@ Remove-Item -Force -ErrorAction SilentlyContinue .prizmkit/specs/{{FEATURE_SLUG}
696
695
 
697
696
  ## Reminders
698
697
 
699
- - Tier 2: orchestrator builds context+plan, Analyzer checks consistency, Dev implements, Reviewer reviews+tests — use direct Agent spawn for agents
698
+ - Tier 2: orchestrator builds context+plan, Analyzer checks consistency, Dev implements, Reviewer reviews — use direct Agent spawn for agents
700
699
  - Build context-snapshot.md FIRST; all subagents read it instead of re-reading source files
701
700
  - context-snapshot.md is append-only: orchestrator writes Sections 1-4, Dev appends Implementation Log, Reviewer appends Review Notes
702
701
  - Gate checks enforce Implementation Log and Review Notes are written before proceeding
@@ -266,7 +266,9 @@ Prompt:
266
266
 
267
267
  **If {{CRITIC_COUNT}} = 3 → Multi-Critic Voting** (skip Single Critic above):
268
268
 
269
- Spawn 3 Critic agents sequentially (each with mode="plan", run_in_background=false), each with a different focus lens:
269
+ **IMPORTANT**: Spawn all 3 Critics in PARALLEL (issue all 3 Agent tool calls in the SAME message turn). Do NOT wait for one before spawning the next.
270
+
271
+ Spawn Critic-A, Critic-B, Critic-C simultaneously (each with mode="plan", run_in_background=false):
270
272
 
271
273
  Critic-A prompt (append to base prompt above):
272
274
  > "**Focus Lens: Architecture & Scalability.** Prioritize: architectural pattern fit, scalability implications, over-engineering risks, component boundary design.
@@ -280,6 +282,8 @@ Critic-C prompt (append to base prompt above):
280
282
  > "**Focus Lens: Security & Performance.** Prioritize: security attack surface, authentication/authorization gaps, performance bottlenecks, resource leaks.
281
283
  > Write `.prizmkit/specs/{{FEATURE_SLUG}}/challenge-report-C.md`."
282
284
 
285
+ Spawn failure cap: for team/config/lock errors, each Critic retries at most once. If 2 or more Critics fail to spawn after retry, perform the plan challenge inline and record the fallback.
286
+
283
287
  After all critics return, read all 3 reports:
284
288
  - Challenge raised by **2/3 or more** critics → **must respond** (adjust plan or justify why not)
285
289
  - Challenge raised by **1/3 only** → logged in context-snapshot but not blocking
@@ -351,7 +355,7 @@ Gate requirements:
351
355
  - Only after a valid `PASS`, write the report path to `.prizmkit/specs/{{FEATURE_SLUG}}/test-report-path.txt` and append a 3-5 bullet `## PrizmKit Test Gate` summary to `context-snapshot.md`.
352
356
  - If the report verdict is `NEEDS_FIXES`, fix in-scope implementation/test issues and rerun `/prizmkit-test`. If the report is `BLOCKED`, missing, stale, or for the wrong scope/artifact dir, write `failure-log.md` and stop for recovery.
353
357
 
354
- ### Phase 5: Review + Test — Reviewer Agent
358
+ ### Phase 5: Review — Reviewer Agent
355
359
 
356
360
  Spawn Reviewer agent (Agent tool, subagent_type="prizm-dev-team-reviewer", run_in_background=false).
357
361
 
@@ -363,8 +367,7 @@ Prompt:
363
367
  > 2. Read `.prizmkit/specs/{{FEATURE_SLUG}}/plan.md` for architecture decisions and completed tasks
364
368
  > 3. Read `.prizmkit/specs/{{FEATURE_SLUG}}/test-report-path.txt`, then read the referenced `/prizmkit-test` report. Review generated/updated tests, `In-Scope Failures`, `Baseline Failures`, `Out of Scope Gaps`, boundary coverage if present, and the report verdict.
365
369
  > 4. Run /prizmkit-code-review with artifact_dir=.prizmkit/specs/{{FEATURE_SLUG}}/. The skill runs an internal review-fix loop (Reviewer → filter → Dev fix, max 3 rounds) and writes review-report.md.
366
- > 5. Run the full test suite using `{{TEST_CMD}}`. When running tests: `& { {{TEST_CMD}} } 2>&1 | Tee-Object (Join-Path $env:TEMP "review-test-out.txt") | Select-Object -Last 20`, then Select-String `(Join-Path $env:TEMP "review-test-out.txt")` for details — do NOT re-run the suite multiple times.
367
- > 6. review-report.md will be written to .prizmkit/specs/{{FEATURE_SLUG}}/ by prizmkit-code-review.
370
+ > 5. Do NOT run test suites the Orchestrator already ran prizmkit-test. Focus on code review and fix strategy.
368
371
  > Report: verdict (PASS/NEEDS_FIXES), number of rounds, findings fixed/rejected."
369
372
 
370
373
  Wait for Reviewer to return.
@@ -384,7 +387,7 @@ Read `review-report.md` and check the Verdict:
384
387
  - `PASS` → proceed to next phase
385
388
  - `NEEDS_FIXES` → the skill exhausted its max rounds; log the remaining findings and proceed
386
389
 
387
- **CP-3**: Integration tests pass, review complete.
390
+ **CP-3**: Review complete.
388
391
 
389
392
  {{IF_BROWSER_INTERACTION}}
390
393
  ### Phase 5.5: Browser Verification — MANDATORY
@@ -774,7 +777,7 @@ Remove-Item -Force -ErrorAction SilentlyContinue .prizmkit/specs/{{FEATURE_SLUG}
774
777
 
775
778
  ## Reminders
776
779
 
777
- - Tier 3: full team — Dev (implementation) → Reviewer (review + test) — spawn agents directly via Agent tool
780
+ - Tier 3: full team — Dev (implementation) → Reviewer (review) — spawn agents directly via Agent tool
778
781
  - context-snapshot.md is append-only: orchestrator writes Sections 1-4, Dev appends Implementation Log, Reviewer appends Review Notes
779
782
  - Gate checks enforce Implementation Log and Review Notes are written before proceeding
780
783
  - Do NOT use `run_in_background=true` when spawning agents
@@ -32,7 +32,7 @@ If CRITIC:MISSING — skip this phase entirely and proceed. Log: "Critic agent n
32
32
 
33
33
  **If {{CRITIC_COUNT}} = 3 → Multi-Critic Voting** (skip Single Critic above):
34
34
 
35
- Spawn 3 Critic agents sequentially (each with mode="plan", run_in_background=false), each with a different focus lens:
35
+ Spawn 3 Critic agents in PARALLEL (issue all 3 Agent tool calls in the SAME message turn). Do NOT wait for one before spawning the next. Each with mode="plan", run_in_background=false:
36
36
 
37
37
  Critic-A prompt (append to base prompt above):
38
38
  > "**Focus Lens: Architecture & Scalability.** Prioritize: architectural pattern fit, scalability implications, over-engineering risks, component boundary design.
@@ -23,9 +23,7 @@ Read `review-report.md` and check the Verdict:
23
23
  - `PASS` → proceed to next phase
24
24
  - `NEEDS_FIXES` → the skill exhausted its max rounds; log the remaining findings and proceed (do not retry externally)
25
25
 
26
- Run the full test suite: `& { {{TEST_CMD}} } 2>&1 | Tee-Object (Join-Path $env:TEMP "review-test-out.txt") | Select-Object -Last 20`
27
-
28
- **CP-3**: Review complete, report written, and the Test Failure Recovery Protocol's Success Rule is satisfied.
26
+ **CP-3**: Review complete, report written.
29
27
 
30
28
 
31
29
  **Checkpoint update**: Run the update script to set step `prizmkit-code-review` to `"completed"`:
@@ -20,6 +20,10 @@
20
20
  "general/cohesive-modeling": {
21
21
  "description": "Group co-occurring variables/fields/concepts into a cohesive unit (struct/class/interface)",
22
22
  "tags": ["general", "design"]
23
+ },
24
+ "general/agent-operational-rules": {
25
+ "description": "Framework-level operational rules for all agents — Edit failure recovery, Read offset safety, test output hygiene, incremental validation",
26
+ "tags": ["general", "agent", "operational"]
23
27
  }
24
28
  },
25
29
  "presets": {
@@ -30,14 +34,16 @@
30
34
  "prizm/prizm-commit-workflow",
31
35
  "prizm/prizm-progressive-loading",
32
36
  "general/prefer-linux-commands",
33
- "general/cohesive-modeling"
37
+ "general/cohesive-modeling",
38
+ "general/agent-operational-rules"
34
39
  ]
35
40
  },
36
41
  "minimal": {
37
- "description": "Minimal: progressive loading + general rules only",
42
+ "description": "Minimal: progressive loading + general rules + operational rules",
38
43
  "rules": [
39
44
  "prizm/prizm-progressive-loading",
40
- "general/prefer-linux-commands"
45
+ "general/prefer-linux-commands",
46
+ "general/agent-operational-rules"
41
47
  ]
42
48
  },
43
49
  "none": {
@@ -0,0 +1,68 @@
1
+ ---
2
+ name: agent-operational-rules
3
+ description: Framework-level operational rules for AI agents — handling Edit failures, Read offsets, test output hygiene, and escalation. These apply to all agents regardless of role.
4
+ tags: [general, agent, operational]
5
+ ---
6
+
7
+ # Agent Operational Rules
8
+
9
+ These rules apply to ALL agents in the PrizmKit ecosystem. They cover common operational patterns that prevent wasted context and infinite loops.
10
+
11
+ ## Edit Failure Recovery
12
+
13
+ When an Edit call fails with 'String to replace not found':
14
+ 1. STOP editing immediately — do NOT retry the same Edit.
15
+ 2. Run `grep -n` to locate the exact line of the target text.
16
+ 3. Read with offset = max(grep_line - 20, 0), limit = 50.
17
+ 4. Copy the exact text from the Read result into the Edit old_string.
18
+ 5. Never guess or extrapolate an offset — grep first, then read, then edit.
19
+
20
+ ## Read Offset Safety
21
+
22
+ Before any Read with offset + limit:
23
+ - Compute offset + limit. If the last tool_result for this file shows it has N lines, offset MUST be < N.
24
+ - Never request an offset >= known file length.
25
+
26
+ ## Stale Line Counts (Large Files)
27
+
28
+ Before editing a large file (>1000 lines), verify you know its current line count from the most recent tool_result. Old line counts from earlier turns may be stale if you have since edited the file.
29
+
30
+ ## Consecutive Read Failures
31
+
32
+ If 3 consecutive Read calls to the same file return 'shorter than provided offset' or 'Wasted call':
33
+ - STOP all work on that file.
34
+ - Send ESCALATION with the file path, current line count, and the offsets you attempted.
35
+ - The orchestrator will provide the correct content.
36
+
37
+ ## Test Output Hygiene
38
+
39
+ **Applies to: Dev Agent and any agent that runs tests.** Does NOT apply to Reviewer, Critic, or other agents that do not execute test commands.
40
+
41
+ When tests fail:
42
+ - Run the test command provided in your task assignment ONCE (e.g., `$TEST_CMD`, `npm test`, `pytest`, etc.).
43
+ - Capture output with `tee` (macOS/Linux) or `Tee-Object` (Windows/PowerShell) to a temp file.
44
+ - Then grep/Select-String that file for failure details.
45
+ - Never re-run the full test suite just to apply a different filter to its output.
46
+
47
+ **macOS/Linux**:
48
+ ```bash
49
+ ($TEST_CMD) 2>&1 | tee /tmp/test-out.txt | tail -20
50
+ grep -n "FAIL\|Error\|assert" /tmp/test-out.txt
51
+ ```
52
+
53
+ **Windows/PowerShell**:
54
+ ```powershell
55
+ & { {{TEST_CMD}} } 2>&1 | Tee-Object (Join-Path $env:TEMP "test-out.txt") | Select-Object -Last 20
56
+ Select-String -Path (Join-Path $env:TEMP "test-out.txt") -Pattern "FAIL|Error|assert"
57
+ ```
58
+
59
+ Note: `$TEST_CMD` / `{{TEST_CMD}}` is a placeholder set by the pipeline or orchestrator. Use whatever test command is provided in your task assignment. Do NOT hardcode a specific test tool — projects vary.
60
+
61
+ ## Incremental Validation
62
+
63
+ **Applies to: Dev Agent.** Does NOT apply to Reviewer, Critic, or read-only agents.
64
+
65
+ After every 3 successful Edit operations on a file:
66
+ - Run the relevant test command for that file once.
67
+ - Validate your changes compile and behave correctly.
68
+ - Do not defer all testing to the end.
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.1.93",
2
+ "version": "1.1.95",
3
3
  "skills": {
4
4
  "prizm-kit": {
5
5
  "description": "Full-lifecycle dev toolkit. Covers spec-driven development, Prizm context docs, code quality, debugging, deployment, and knowledge management.",
@@ -266,7 +266,7 @@ For simple incremental planning, skip detailed Phase 2-3 analysis:
266
266
  4. Draft features (title + description + acceptance_criteria + dependencies)
267
267
  5. Write draft to `.prizmkit/plans/feature-list.draft.json`, then call the generate script:
268
268
  ```bash
269
- python3 ${SKILL_DIR}/scripts/validate-and-generate.py generate --input .prizmkit/plans/feature-list.draft.json --output .prizmkit/plans/feature-list.json --mode incremental
269
+ python3 ${SKILL_DIR}/scripts/validate-and-generate.py generate --input .prizmkit/plans/feature-list.draft.json --output .prizmkit/plans/feature-list.json
270
270
  ```
271
271
  6. If valid → summarize and recommend next step
272
272
  7. If invalid → apply fixes to the draft, re-run generate (max 2 attempts, then escalate to full workflow)
@@ -317,7 +317,7 @@ Key requirements:
317
317
  1. Write a draft JSON to a temporary path (e.g., `.prizmkit/plans/feature-list.draft.json`)
318
318
  2. Call the generate script to validate and produce the final file:
319
319
  ```bash
320
- python3 ${SKILL_DIR}/scripts/validate-and-generate.py generate --input .prizmkit/plans/feature-list.draft.json --output .prizmkit/plans/feature-list.json --mode <new|incremental>
320
+ python3 ${SKILL_DIR}/scripts/validate-and-generate.py generate --input .prizmkit/plans/feature-list.draft.json --output .prizmkit/plans/feature-list.json
321
321
  ```
322
322
  The script fills in defaults (`$schema`, `created_at`, `created_by`), validates all fields, and writes the final file only if validation passes. If validation fails, fix the draft and retry.
323
323
 
@@ -4,7 +4,7 @@ Structured error handling for validation failures, interrupted sessions, and che
4
4
 
5
5
  ## Validation Failures
6
6
 
7
- When `python3 scripts/validate-and-generate.py validate --input <file> --mode <mode>` returns errors:
7
+ When `python3 scripts/validate-and-generate.py validate --input <file>` returns errors:
8
8
 
9
9
  ### Parse validation output
10
10
  Script returns JSON with `"valid": false`, `"errors": [...]`, `"warnings": [...]`
@@ -83,7 +83,7 @@ Keep dependency correctness as first constraint.
83
83
  ### Step 5: Validate
84
84
  Run:
85
85
  ```bash
86
- python3 ${SKILL_DIR}/scripts/validate-and-generate.py validate --input feature-list.json --mode incremental
86
+ python3 ${SKILL_DIR}/scripts/validate-and-generate.py validate --input feature-list.json
87
87
  ```
88
88
 
89
89
  Fix and re-run until pass.
@@ -55,7 +55,7 @@ Split into `sub_features` when:
55
55
  1. Write `feature-list.json`.
56
56
  2. Run:
57
57
  ```bash
58
- python3 ${SKILL_DIR}/scripts/validate-and-generate.py validate --input feature-list.json --mode new
58
+ python3 ${SKILL_DIR}/scripts/validate-and-generate.py validate --input feature-list.json
59
59
  ```
60
60
  3. Fix all errors, then re-run.
61
61