hatch3r 2.1.1 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/README.md +3 -3
  2. package/dist/cli/index.js +77 -19
  3. package/dist/content/agents/hatch3r-fixer.md +20 -7
  4. package/dist/content/agents/hatch3r-handoff-loader.md +7 -2
  5. package/dist/content/agents/hatch3r-handoff-preparer.md +2 -1
  6. package/dist/content/agents/hatch3r-implementer.md +28 -2
  7. package/dist/content/agents/hatch3r-maintainability.md +2 -0
  8. package/dist/content/agents/hatch3r-researcher.md +1 -1
  9. package/dist/content/agents/hatch3r-reviewer.md +20 -12
  10. package/dist/content/agents/hatch3r-ui.md +1 -1
  11. package/dist/content/agents/hatch3r-ux.md +1 -1
  12. package/dist/content/agents/shared/cq-specialist-roster.md +2 -2
  13. package/dist/content/agents/shared/quality-charter.md +3 -2
  14. package/dist/content/agents/shared/quality-specialist-frame.md +1 -1
  15. package/dist/content/agents/shared/user-question-protocol.md +1 -0
  16. package/dist/content/checks/code-quality.md +11 -0
  17. package/dist/content/checks/security.md +5 -0
  18. package/dist/content/checks/testing.md +2 -0
  19. package/dist/content/commands/board/pickup-delegation-multi.md +18 -8
  20. package/dist/content/commands/board/pickup-delegation.md +5 -4
  21. package/dist/content/commands/hatch3r-api-spec.md +1 -1
  22. package/dist/content/commands/hatch3r-benchmark.md +1 -1
  23. package/dist/content/commands/hatch3r-board-fill.md +2 -2
  24. package/dist/content/commands/hatch3r-board-pickup.md +4 -3
  25. package/dist/content/commands/hatch3r-bug-pipeline.md +1 -1
  26. package/dist/content/commands/hatch3r-bug-plan.md +1 -1
  27. package/dist/content/commands/hatch3r-codebase-map.md +1 -1
  28. package/dist/content/commands/hatch3r-create.md +1 -1
  29. package/dist/content/commands/hatch3r-debug.md +1 -1
  30. package/dist/content/commands/hatch3r-design-system-create.md +254 -0
  31. package/dist/content/commands/hatch3r-feature-plan.md +1 -1
  32. package/dist/content/commands/hatch3r-handoff.md +1 -1
  33. package/dist/content/commands/hatch3r-healthcheck.md +1 -1
  34. package/dist/content/commands/hatch3r-migration-plan.md +1 -1
  35. package/dist/content/commands/hatch3r-onboard.md +1 -1
  36. package/dist/content/commands/hatch3r-pr-resolve.md +69 -29
  37. package/dist/content/commands/hatch3r-project-spec.md +1 -1
  38. package/dist/content/commands/hatch3r-quick-change.md +1 -1
  39. package/dist/content/commands/hatch3r-refactor-plan.md +1 -1
  40. package/dist/content/commands/hatch3r-release.md +1 -1
  41. package/dist/content/commands/hatch3r-revision.md +7 -7
  42. package/dist/content/commands/hatch3r-roadmap.md +1 -1
  43. package/dist/content/commands/hatch3r-security-audit.md +1 -1
  44. package/dist/content/commands/hatch3r-test-plan.md +1 -1
  45. package/dist/content/commands/hatch3r-workflow.md +12 -10
  46. package/dist/content/commands/revision/revision-quality.md +6 -5
  47. package/dist/content/rules/hatch3r-agent-orchestration-detail.md +2 -2
  48. package/dist/content/rules/hatch3r-agent-orchestration-detail.mdc +2 -2
  49. package/dist/content/rules/hatch3r-agent-orchestration.md +14 -14
  50. package/dist/content/rules/hatch3r-agent-orchestration.mdc +14 -14
  51. package/dist/content/rules/hatch3r-anti-duplication.md +10 -1
  52. package/dist/content/rules/hatch3r-anti-duplication.mdc +10 -1
  53. package/dist/content/rules/hatch3r-clarification-default.md +6 -5
  54. package/dist/content/rules/hatch3r-clarification-default.mdc +6 -5
  55. package/dist/content/rules/hatch3r-code-standards.md +1 -1
  56. package/dist/content/rules/hatch3r-code-standards.mdc +1 -1
  57. package/dist/content/rules/hatch3r-contract-census.md +160 -0
  58. package/dist/content/rules/hatch3r-contract-census.mdc +160 -0
  59. package/dist/content/rules/hatch3r-deep-context.md +1 -0
  60. package/dist/content/rules/hatch3r-deep-context.mdc +1 -0
  61. package/dist/content/rules/hatch3r-dynamic-stack-verification.md +114 -0
  62. package/dist/content/rules/hatch3r-dynamic-stack-verification.mdc +109 -0
  63. package/dist/content/rules/hatch3r-enhancability.md +1 -1
  64. package/dist/content/rules/hatch3r-enhancability.mdc +1 -1
  65. package/dist/content/rules/hatch3r-findings-ledger.md +129 -0
  66. package/dist/content/rules/hatch3r-findings-ledger.mdc +129 -0
  67. package/dist/content/rules/hatch3r-i18n.md +4 -0
  68. package/dist/content/rules/hatch3r-i18n.mdc +4 -0
  69. package/dist/content/rules/hatch3r-iteration-summary.md +2 -0
  70. package/dist/content/rules/hatch3r-iteration-summary.mdc +2 -0
  71. package/dist/content/rules/hatch3r-migrations.md +1 -1
  72. package/dist/content/rules/hatch3r-migrations.mdc +1 -1
  73. package/dist/content/rules/hatch3r-security-patterns.md +4 -0
  74. package/dist/content/rules/hatch3r-security-patterns.mdc +4 -0
  75. package/dist/content/rules/hatch3r-testing.md +14 -0
  76. package/dist/content/rules/hatch3r-testing.mdc +14 -0
  77. package/dist/content/skills/hatch3r-design-system-detect/SKILL.md +2 -0
  78. package/dist/content/skills/hatch3r-handoff-prepare/SKILL.md +1 -1
  79. package/package.json +1 -1
@@ -25,7 +25,7 @@ sub_agents_spawned:
25
25
 
26
26
  The `prepare` subcommand delegates to `hatch3r-handoff-preparer` via the Task tool. The other four subcommands (`resume`, `list`, `complete`, `prune`) run inline within this command — they read, list, transition status, or archive files and do not require a sub-agent.
27
27
 
28
- **Parallel-safety conditions** (per `rules/hatch3r-agent-orchestration.md` §Parallel Safety): any parallel fan-out holds all three — read-only or disjoint writes, deterministic aggregation, no shared mutable state.
28
+ **Parallel-safety conditions** (per `rules/hatch3r-agent-orchestration.md` §Parallel Safety): any parallel fan-out holds all three — read-only or disjoint writes (file- and contract-level), deterministic aggregation, no shared mutable state.
29
29
 
30
30
  ## Learnings Consultation
31
31
 
@@ -33,7 +33,7 @@ This command discovers the module taxonomy via static analysis, then delegates i
33
33
  | 4. Issue Creation | Orchestrator (GitHub MCP) | No | Yes |
34
34
  | 5. Board Sync | Orchestrator (Projects v2 sync) | No | Yes |
35
35
 
36
- **Parallel-safety conditions** (per `rules/hatch3r-agent-orchestration.md` §Parallel Safety): every parallel fan-out above holds all three — read-only or disjoint writes, deterministic aggregation, no shared mutable state.
36
+ **Parallel-safety conditions** (per `rules/hatch3r-agent-orchestration.md` §Parallel Safety): every parallel fan-out above holds all three — read-only or disjoint writes (file- and contract-level), deterministic aggregation, no shared mutable state.
37
37
 
38
38
  All issue operations MUST follow the Projects v2 Enforcement rules defined in `hatch3r-board-shared`.
39
39
 
@@ -29,7 +29,7 @@ sub_agents_spawned:
29
29
  | 2. Impact Analysis | `hatch3r-architect` | No | Yes |
30
30
  | 3. Plan Generation | `hatch3r-docs-writer` | No | Yes |
31
31
 
32
- **Parallel-safety conditions** (per `rules/hatch3r-agent-orchestration.md` §Parallel Safety): every parallel fan-out above holds all three — read-only or disjoint writes, deterministic aggregation, no shared mutable state.
32
+ **Parallel-safety conditions** (per `rules/hatch3r-agent-orchestration.md` §Parallel Safety): every parallel fan-out above holds all three — read-only or disjoint writes (file- and contract-level), deterministic aggregation, no shared mutable state.
33
33
 
34
34
  # Migration Plan — Dependency or Framework Upgrade from Assessment to Phased Execution
35
35
 
@@ -38,7 +38,7 @@ Acceptable to proceed without asking ONLY when scope is single-target, single-co
38
38
  | 2. Setup Verification | Orchestrator (inline) | No | Yes |
39
39
  | 3. Guide Generation | `hatch3r-docs-writer` | No | Yes |
40
40
 
41
- **Parallel-safety conditions** (per `rules/hatch3r-agent-orchestration.md` §Parallel Safety): every parallel fan-out above holds all three — read-only or disjoint writes, deterministic aggregation, no shared mutable state.
41
+ **Parallel-safety conditions** (per `rules/hatch3r-agent-orchestration.md` §Parallel Safety): every parallel fan-out above holds all three — read-only or disjoint writes (file- and contract-level), deterministic aggregation, no shared mutable state.
42
42
 
43
43
  # Onboarding Guide Generator — Tailored Developer Onboarding from Codebase Analysis to Ready-to-Work Guide
44
44
 
@@ -2,7 +2,7 @@
2
2
  id: hatch3r-pr-resolve
3
3
  type: command
4
4
  orchestrator: true
5
- agentPipeline: [hatch3r-implementer, hatch3r-lint-fixer, hatch3r-testability, hatch3r-reviewer, hatch3r-fixer, hatch3r-security, hatch3r-docs-writer, hatch3r-ui, hatch3r-performance]
5
+ agentPipeline: [hatch3r-implementer, hatch3r-lint-fixer, hatch3r-testability, hatch3r-reviewer, hatch3r-fixer, hatch3r-security, hatch3r-docs-writer, hatch3r-ui, hatch3r-ux, hatch3r-performance]
6
6
  description: "Read open PR comments, evaluate each against current code via the rigor contract, implement accepted findings, reply inline. Multi-platform."
7
7
  argument-hint: "[pr-number]"
8
8
  tags: [implementation, review, ctx:team-only]
@@ -14,8 +14,8 @@ efficiency_tier: standard
14
14
  triage_tiers: [1, 2, 3]
15
15
  supports_resume: true
16
16
  sub_agents_spawned:
17
- count: 9
18
- rationale: Per-PR fanout — implementer, lint-fixer, testability (CQ5, FIX NOW group, parallel), reviewer ↔ fixer review loop (max 3 iterations), then parallel Tier-3 final-quality specialists (security (CQ3), docs-writer, ui (CQ1), performance (CQ7)) per the Tier-3 specialist mandate. Cost-dominance per CONSTITUTION §2 P8 — token cost never serializes independent work.
17
+ count: 10
18
+ rationale: Per-PR fanout — implementer, lint-fixer, testability (CQ5, FIX NOW group, parallel), reviewer ↔ fixer review loop (max 3 iterations), then parallel Tier-3 final-quality specialists (security (CQ3), docs-writer, performance (CQ7), plus ui (CQ1) and ux (CQ2) as mandatory-on-match Tier 2/3 gates — a trigger-glob match requires a dedicated instance) per the Tier-3 specialist mandate. Cost-dominance per CONSTITUTION §2 P8 — token cost never serializes independent work.
19
19
  ---
20
20
 
21
21
  ## §0 Detect Ambiguity (P8 B1)
@@ -34,12 +34,13 @@ sub_agents_spawned:
34
34
  | 6. Fix implementation | `hatch3r-implementer`, `hatch3r-lint-fixer`, `hatch3r-testability` | Per finding group | When FIX NOW items exist |
35
35
  | 7a. Review loop | `hatch3r-reviewer` -> `hatch3r-fixer` (max 3 iterations) | No (sequential) | When code changed (Tier 2/3) |
36
36
  | 7b. Final quality — mandatory | `hatch3r-testability`, `hatch3r-security` | Yes | When code changed |
37
- | 7c. Final quality — conditional | `hatch3r-docs-writer`, `hatch3r-ui`, `hatch3r-performance`, `hatch3r-lint-fixer` | Yes | When triggered |
37
+ | 7c. Final quality — mandatory-on-match + conditional | `hatch3r-ui`, `hatch3r-ux` (mandatory-on-match); `hatch3r-docs-writer`, `hatch3r-performance`, `hatch3r-lint-fixer` (conditional) | Yes | When triggered (ui/ux non-skippable on trigger-glob match at Tier 2/3) |
38
38
  | 8. Post replies | Orchestrator (inline, platform CLI) | Per comment | Yes |
39
39
  | 9. Commit and push | Orchestrator (inline) | No | When code changed |
40
+ | 9.5. Re-poll gate | Orchestrator (inline) | No | When commit pushed |
40
41
  | 10. Iteration Summary | Orchestrator (inline) | No | Yes |
41
42
 
42
- **Parallel-safety conditions** (per `rules/hatch3r-agent-orchestration.md` §Parallel Safety): every parallel fan-out above holds all three — read-only or disjoint writes, deterministic aggregation, no shared mutable state.
43
+ **Parallel-safety conditions** (per `rules/hatch3r-agent-orchestration.md` §Parallel Safety): every parallel fan-out above holds all three — read-only or disjoint writes (file- and contract-level), deterministic aggregation, no shared mutable state.
43
44
 
44
45
  ---
45
46
 
@@ -85,8 +86,8 @@ If no `.hatch3r/hatch.json` exists, fall back to GitHub and proceed — the comm
85
86
 
86
87
  ## Token-Saving Directives
87
88
 
88
- 1. **One fetch per comment scope.** Issue exactly one paginated request per scope in Step 2; cache and reuse for Steps 3, 4, and 8.
89
- 2. **One diff computation.** Compute `git diff {defaultBranch}...HEAD` once in Step 1; reuse for Steps 4 (outdated detection) and 7 (review loop input).
89
+ 1. **One fetch per comment scope per round.** Issue exactly one paginated request per scope in Step 2; cache and reuse for Steps 3, 4, and 8. Step 9.5b poll attempts are the one sanctioned re-fetch path (max 5 per poll).
90
+ 2. **One diff computation per round.** Compute `git diff {defaultBranch}...HEAD` once in Step 1; reuse for Steps 4 (outdated detection) and 7 (review loop input). A Step 9.5 round re-entry refreshes it once against the new HEAD.
90
91
  3. **Targeted file reads.** In Step 4, read only the files referenced by a comment's `path`/`line` — not the full codebase.
91
92
  4. **No re-reading shared rules.** `scope: always` rules from `rules/` load once at session start; pass their content into sub-agent prompts (Step 6) rather than reloading.
92
93
  5. **Per-platform reference cache.** Load the matching `commands/board/shared-{platform}.md` once at run start (Shared Context). Step 8 reads templates from the cache, not from disk.
@@ -136,6 +137,11 @@ run_cache:
136
137
  reply_drafts: [{comment_id, body, endpoint}, ...]
137
138
  reply_post_results: [{comment_id, status: posted|failed, error?: <string>}, ...]
138
139
  deferred_findings: [<finding>, ...] # written to todo.md in Step 5c
140
+ ledger_file: <path of this run's findings-ledger JSONL> # .hatch3r/findings/<YYYY-MM-DD>-pr-resolve-<run8>.jsonl per rules/hatch3r-findings-ledger.md
141
+ round:
142
+ index: <int, 1-based> # initialized 1; incremented per Step 9.5 re-poll round
143
+ started_at: <iso> # run start; reset to now when a re-poll round begins (9.5b)
144
+ comments_per_round: [<int>, ...] # per-round comment count — [0] = Step 3 finding count, then 9.5b retained counts
139
145
  errors: [<error_record>, ...]
140
146
  ```
141
147
 
@@ -143,7 +149,7 @@ run_cache:
143
149
 
144
150
  ## Workflow
145
151
 
146
- Execute these steps in order. **Do not skip any step.** The only ASK gate is Step 5; after the user accepts triage, run autonomously through Step 10.
152
+ Execute these steps in order. **Do not skip any step.** Two ASK gate classes bound the run: Step 5 (triage routing, once per round) and Step 9.5 (re-poll consent, after each push). After the user accepts triage, each round runs autonomously through Step 9; Step 9.5 bounds the loop; Step 10 closes the run.
147
153
 
148
154
  ---
149
155
 
@@ -163,7 +169,7 @@ Before the Step 5 ASK gate (the only mutation gate, after which fan-out begins i
163
169
 
164
170
  ```yaml
165
171
  cost_estimate:
166
- expected_sa_count: <tier → Tier 1 ~1, Tier 2 ~4, Tier 3 up to 9; 0 when no unresolved comments>
172
+ expected_sa_count: <tier → Tier 1 ~1, Tier 2 ~4, Tier 3 up to 10; 0 when no unresolved comments>
167
173
  estimated_input_tokens_static_frame: <int>
168
174
  estimated_web_research_queries: <int>
169
175
  triage_tier: light | standard | deep
@@ -373,7 +379,7 @@ After Step 4 completes, recompute Step 0's tier using the now-known severities.
373
379
 
374
380
  ## Step 5: Triage Routing + ASK Checkpoint (only mutation gate)
375
381
 
376
- **Tier-3 specialist mandate (P8 B2).** For Tier 3 PRs (6+ findings OR any Critical severity), the post-fix specialist pass (`hatch3r-testability`, `hatch3r-security`, `hatch3r-docs-writer`) MUST run in parallel. Specialists may NOT be deferred via "Needs your call" for cost reasons. Cost-dominance principle applies: token cost of specialist sub-agents is dominated by the quality gain of catching defects pre-merge.
382
+ **Tier-3 specialist mandate (P8 B2).** For Tier 3 PRs (6+ findings OR any Critical severity), the post-fix specialist pass (`hatch3r-testability`, `hatch3r-security`, `hatch3r-docs-writer`) MUST run in parallel. A triggered mandatory-on-match specialist (`hatch3r-ui` CQ1 / `hatch3r-ux` CQ2) joins the pass as its own dedicated instance whenever the round's diff matches its trigger row (Step 7c). Specialists may NOT be deferred via "Needs your call" for cost reasons. Cost-dominance principle applies: token cost of specialist sub-agents is dominated by the quality gain of catching defects pre-merge.
377
383
 
378
384
  #### 5a. Apply Routing Heuristics
379
385
 
@@ -428,9 +434,9 @@ Tier: 2 (standard pipeline)
428
434
  Total: {N} comments • {fix_now_n} fix now • {decline_n} decline • {clarify_n} clarify • {needs_call_n} need your call • {defer_n} defer
429
435
  ```
430
436
 
431
- #### 5c. ASK (only gate)
437
+ #### 5c. ASK (triage gate, once per round)
432
438
 
433
- > Found {N} comments on PR #{pr_number}. Evaluation done. Review the suggested routing. Adjustments:
439
+ > Found {N} comments on PR #{pr_number} (round {round.index}). Evaluation done. Review the suggested routing. Adjustments:
434
440
  > - `accept` — proceed with suggested routing
435
441
  > - `fix N` — promote a Decline/Clarify/NeedsCall item to FIX NOW
436
442
  > - `decline N` — demote a FIX NOW item to DECLINE
@@ -443,7 +449,7 @@ Total: {N} comments • {fix_now_n} fix now • {decline_n} decline • {clarify
443
449
 
444
450
  If the user attempts to defer a Critical finding, execute the Critical Deferral Protocol from `commands/hatch3r-revision.md` §5b Routing ASK → Critical Deferral Protocol: structured warning + required written rationale + `Critical-deferred` tag in todo.md + flag for elevated visibility in the next board-fill.
445
451
 
446
- After the user accepts, the run is autonomous until Step 10.
452
+ After the user accepts, the round is autonomous through Step 9; Step 9.5 then gates any further round.
447
453
 
448
454
  #### 5d. File Deferred Findings to todo.md
449
455
 
@@ -452,11 +458,11 @@ If any findings route to DEFER, append a single epic-context block to `todo.md`:
452
458
  ```markdown
453
459
  # Follow-ups from PR #{pr_number} pr-resolve ({date})
454
460
  # Epic: group all items below into one epic during board-fill
455
- - {comment author}: {finding description} (severity: {severity}, file: {file:line})
461
+ - {comment author}: {finding description} (severity: {severity}, file: {file:line}) [ledger: {finding_id}]
456
462
  - ...
457
463
  ```
458
464
 
459
- Cache the deferred list. Reply templates in Step 8 reference todo.md for these items.
465
+ Cache the deferred list. For each DEFER item, also append a `deferred` ledger row whose `closure_ref` is the item's todo.md anchor (`rules/hatch3r-findings-ledger.md`). Reply templates in Step 8 reference todo.md for these items.
460
466
 
461
467
  ---
462
468
 
@@ -509,12 +515,12 @@ If any gate fails, identify failures and either fix inline (single-line lint/typ
509
515
 
510
516
  #### 7b. Review Loop (Tier 2/3 only; Tier 1 skips)
511
517
 
512
- Spawn `hatch3r-reviewer` -> `hatch3r-fixer` per `commands/revision/revision-quality.md` Stage 1 (max 3 iterations, oscillation detection, confidence decay). The reviewer prompt MUST include:
518
+ Spawn `hatch3r-reviewer` -> `hatch3r-fixer` per `commands/revision/revision-quality.md` Stage 1 (max 3 iterations, oscillation detection, confidence decay) — append the W1 write-ahead rows before the fixer dispatch and the W2 disposition rows after the re-review (`rules/hatch3r-findings-ledger.md` → Write Points). The reviewer prompt MUST include:
513
519
  - The cached diff from Step 1e.
514
520
  - All `scope: always` rule directives.
515
521
  - Iteration number and prior findings.
516
522
  - The Confidence expression requirement (verbatim).
517
- - **Cross-PR Findings block (D13-SA13.1-F08).** Before the first reviewer spawn, scan `.hatch3r/review-findings/` (skip silently if the directory is absent) for entries whose `applies-to` glob matches any file in the cached diff; pass the 5 most-recent matches (by `created` descending) into the reviewer prompt as a `## Cross-PR Findings` block of `{id, applies-to, severity, pr, verdict, summary}` rows. The reviewer (which declares `consults_cross_pr_findings: true`) weighs these as prior organisational memory per its Cross-PR Finding Memory section. After the loop terminates clean, append one `.hatch3r/review-findings/<id>.md` entry per Critical/Warning finding resolved this run (atomic write via `src/merge/safeWrite.ts`), so the next PR on the same files inherits the memory.
523
+ - **Cross-PR Findings block (D13-SA13.1-F08).** Before the first reviewer spawn, scan `.hatch3r/review-findings/` (skip silently if the directory is absent) for entries whose `applies-to` glob matches any file in the cached diff; pass the 5 most-recent matches (by `created` descending) into the reviewer prompt as a `## Cross-PR Findings` block of `{id, applies-to, severity, pr, verdict, summary}` rows. The reviewer (which declares `consults_cross_pr_findings: true`) weighs these as prior organisational memory per its Cross-PR Finding Memory section. After the loop terminates clean, append one `.hatch3r/review-findings/<id>.md` entry per Critical/Warning finding resolved this run (atomic write via `src/merge/safeWrite.ts`), so the next PR on the same files inherits the memory — derive the entry from the ledger fold and cite its `finding_id` (`rules/hatch3r-findings-ledger.md` → Store Boundaries).
518
524
 
519
525
  The reviewer's output MUST include a top-level `confidence: high | medium | low` so the gate evaluates pass/second_pass/escalate per `src/pipeline/reviewLoop.ts` semantics.
520
526
 
@@ -528,9 +534,12 @@ After 7b is clean:
528
534
  - `hatch3r-testability` (CQ5) — verify tests for changed code paths meet the mandate map / coverage floor.
529
535
  - `hatch3r-security` (CQ3) — security review of all changes.
530
536
 
537
+ **Mandatory-on-match (Tier 2/3):** when the round's diff matches a specialist's trigger row in the Phase 4 Specialist Trigger Table (`rules/hatch3r-agent-orchestration.md`), a dedicated instance MUST spawn — never merged into another spawn. Skipping a triggered one at Tier 2/3 is a gate failure.
538
+ - `hatch3r-ui` (CQ1) — UI component / theme / token files in the diff (`*.{tsx,jsx,vue,svelte}`, `tailwind.config.*`, design-token registries).
539
+ - `hatch3r-ux` (CQ2) — flow / modal / route-transition / error-state files in the diff; microcopy or i18n strings changed.
540
+
531
541
  **Conditional:**
532
542
  - `hatch3r-docs-writer` — when fixes touched public APIs, architectural patterns, or user-facing behavior.
533
- - `hatch3r-ui` (CQ1) — when the diff includes UI component or style files.
534
543
  - `hatch3r-performance` (CQ7) — when the diff includes hot-path changes (DB queries, API handlers, render loops).
535
544
  - `hatch3r-lint-fixer` — when residual lint/type errors surfaced after Step 6.
536
545
 
@@ -547,7 +556,7 @@ For every finding in `run_cache.triage_decisions` (including DECLINE and DEFER b
547
556
  | Decision | Template |
548
557
  |----------|----------|
549
558
  | FIX NOW — implemented | `Implemented in {commit_sha}: {one-line summary}. Confidence: {high|medium}.` |
550
- | FIX NOW — failed (BLOCKED / PARTIAL) | `Attempted but blocked: {reason from sub-agent}. Surfaced as follow-up in todo.md.` |
559
+ | FIX NOW — failed (BLOCKED / PARTIAL) | `Attempted but blocked: {reason}. Tracked as {finding_id} in the findings ledger; follow-up in todo.md.` |
551
560
  | DECLINE — outdated | `The code at this location has changed since this comment; the original concern no longer applies. Current behavior: {one-line summary}.` |
552
561
  | DECLINE — disagree | `Considered, declining because: {reasoning from evaluation.causal_chain}. Counter-argument considered: {evaluation.counter_argument}. Happy to revisit if context differs.` |
553
562
  | DECLINE — already done | `Already addressed in {commit_sha}: {one-line summary}.` |
@@ -625,14 +634,44 @@ If `run_cache.fix_results.files_changed` is empty (every comment was DECLINE / D
625
634
 
626
635
  ---
627
636
 
637
+ ## Step 9.5: Re-Poll Gate (ask each round)
638
+
639
+ Runs after every Step 9 push. Skipped when Step 9 was skipped — no new HEAD means AI review tools have nothing new to review. Round state lives in `run_cache.round` and persists to the checkpoint (`roundIndex`, `roundStartedAt`).
640
+
641
+ #### 9.5a. ASK (re-poll consent)
642
+
643
+ > Pushed {sha} to PR #{N} (round {round.index}). AI review tools (CodeRabbit, Copilot code review, etc.) may post new comments on the new HEAD within a few minutes. Poll for comments created after {round.started_at} and resolve them in another round? (poll / done)
644
+
645
+ - `done` → proceed to Step 10.
646
+ - `poll` → run 9.5b.
647
+
648
+ #### 9.5b. Poll
649
+
650
+ Re-issue the Step 2 fetch (all scopes) every 60s, max 5 attempts (~300s budget). Retain only comments where ALL three hold:
651
+
652
+ 1. `created_at > round.started_at`.
653
+ 2. `comment_id` absent from checkpoint `postedCommentIds` — already-replied threads are never re-processed.
654
+ 3. Thread not resolved (the guardrail 9 filter).
655
+
656
+ **New comments retained:** increment `round.index`, reset `round.started_at` to now, append the retained count to `round.comments_per_round`, refresh the Step 1e diff against the new HEAD, and re-enter at Step 2 scoped to the retained set. The round runs Steps 2–9 in full — normalize, evaluate, Step 5 triage ASK, fix, verify, reply, commit + push — then returns to 9.5a.
657
+
658
+ **Zero retained after 5 attempts:** report "No new comments after 300s." and re-ask 9.5a (keep polling / done).
659
+
660
+ There is no automatic round cap — the 9.5a ASK is the bound; every round is user-approved.
661
+
662
+ ---
663
+
628
664
  ## Step 10: Resolution Summary
629
665
 
630
- Close the run with the recap-contract Iteration Summary per `rules/hatch3r-iteration-summary.md` a 1–2 line recap plus every exception line whose firing condition holds, using the closed Status enum. Disposition mapping: DEFER dispositions land on the `Not done:` line; NEEDS_CLARIFICATION items land on the `Blockers:` line. Worked example:
666
+ Reconcile the findings ledger to the run-exit invariant (W3, `rules/hatch3r-findings-ledger.md`): zero rows may fold `pending`/`in-fix`; open Critical/Warning force an ASK; unattended runs record them as `escalated` and exit PARTIAL.
667
+
668
+ Close the run with the recap-contract Iteration Summary per `rules/hatch3r-iteration-summary.md` — a 1–2 line recap plus every exception line whose firing condition holds, using the closed Status enum. Disposition mapping: DEFER dispositions land on the `Not done:` line; NEEDS_CLARIFICATION items land on the `Blockers:` line. Recap facets include `rounds {n}` (from `round.index`); when rounds > 1, a `Rounds:` exception line enumerates per-round counts sourced from `round.comments_per_round`. Worked example:
631
669
 
632
670
  ```markdown
633
671
  ## Iteration Summary
634
- **PARTIAL** — Resolved 8 of 10 comments on PR #142; replies posted; commit pushed.
635
- files 6 (+184/−42) · sa 7/9 · gates 6/6 · cost Δ−12% tok / Δ+8% min · tier 2
672
+ **PARTIAL** — Resolved 11 of 13 comments on PR #142 across 2 rounds; replies posted; commits pushed.
673
+ files 6 (+184/−42) · sa 7/10 · gates 6/6 · cost Δ−12% tok / Δ+8% min · tier 2 · rounds 2
674
+ Rounds: r1 10 comments (8 fixed) · r2 3 comments (3 fixed)
636
675
  Not done: c-214 @maya DEFER — deferred: tracked in todo.md for /hatch3r-board-fill
637
676
  Blockers: c-207 @jordan NEEDS_CLARIFICATION — awaiting reviewer response
638
677
  Confidence: medium — reviewer loop clean after 1 round; 2 comments unresolved. The fix required one round of corrections, which is normal for moderately complex changes. A brief human review is recommended.
@@ -649,9 +688,9 @@ Status decision rules:
649
688
 
650
689
  ## Resumability (Decision 27/30)
651
690
 
652
- pr-resolve is long-running — a Tier 3 PR with many open comments runs identity resolution (Step 1), full-platform comment fetch (Step 2), normalization + rigor-contract evaluation (Steps 3–4), the only mutation-gate ASK (Step 5), parallel-per-finding fix implementation (Step 6), the reviewer ↔ fixer review loop + Phase 4 specialist batch (Step 7), per-comment platform-API replies (Step 8), and commit + push (Step 9). Per hatch3r's workspace-checkpointed resumability contract, checkpoint progress so an interrupted run re-enters at the last completed step rather than re-fetching comments, re-evaluating findings, or re-posting platform-API replies that already shipped.
691
+ pr-resolve is long-running — a Tier 3 PR with many open comments runs identity resolution (Step 1), full-platform comment fetch (Step 2), normalization + rigor-contract evaluation (Steps 3–4), the only mutation-gate ASK (Step 5), parallel-per-finding fix implementation (Step 6), the reviewer ↔ fixer review loop + Phase 4 specialist batch (Step 7), per-comment platform-API replies (Step 8), commit + push (Step 9), and the Step 9.5 re-poll gate, which can add further full rounds. Per hatch3r's workspace-checkpointed resumability contract, checkpoint progress so an interrupted run re-enters at the last completed step rather than re-fetching comments, re-evaluating findings, or re-posting platform-API replies that already shipped.
653
692
 
654
- > Orchestration boilerplate: see `commands/shared/orchestration-frame.md` → Checkpoint Contract. Per-command slots: workspace `.pr-resolve-workspace/`; step range the Step 0 → Step 10 progression; `wave` = per-finding fix-batch index in Step 6 and review-loop iteration index in Step 7a; snapshot/rollback paths pre-commit working-tree state and the per-comment reply attempt log. Write points: after Step 1 PR identity resolves, after Step 2 comment fetch locks the normalizedFindings input, after Step 3 normalization, after Step 4 rigor-contract evaluation, after the Step 5 ASK checkpoint (only mutation gate — confirmed routing decisions persist so resume does not re-prompt), after each Step 6 per-finding implementer/lint-fixer/testability batch returns, after each Step 7a review-loop iteration, after each Step 7b–7c specialist batch returns, after each Step 8 platform-API reply records its commentId in `postedCommentIds` (the resume path skips replies with an entry there — no double-posts), and after Step 9 commit + push.
693
+ > Orchestration boilerplate: see `commands/shared/orchestration-frame.md` → Checkpoint Contract. Per-command slots: workspace `.pr-resolve-workspace/`; step range Step 0 → Step 10 with a Step 9.5 loop-back to Step 2; `wave` = per-finding fix-batch index in Step 6 and review-loop iteration index in Step 7a; snapshot/rollback paths pre-commit working-tree state and the per-comment reply attempt log; checkpoint meta gains `roundIndex` + `roundStartedAt`. Write points: after Step 1 PR identity resolves, after Step 2 comment fetch locks the normalizedFindings input, after Step 3 normalization, after Step 4 rigor-contract evaluation, after the Step 5 ASK checkpoint (only mutation gate — confirmed routing decisions persist so resume does not re-prompt), after each Step 6 per-finding implementer/lint-fixer/testability batch returns, after each Step 7a review-loop iteration, after each Step 7b–7c specialist batch returns, after each Step 8 platform-API reply records its commentId in `postedCommentIds` (the resume path skips replies with an entry there — no double-posts), after Step 9 commit + push, and after each Step 9.5 decision (round counter + `roundStartedAt` persist; the `postedCommentIds` filter carries across rounds).
655
694
 
656
695
  ---
657
696
 
@@ -675,10 +714,10 @@ Close the run with the recap-contract Iteration Summary per `rules/hatch3r-itera
675
714
 
676
715
  This command emits cost transparency per `rules/hatch3r-cost-visibility.md` and CONSTITUTION §6 Decision 24/29:
677
716
 
678
- - **Pre-execution `cost_estimate`** — emitted in Step 0.5 before the Step 5 ASK gate (the only mutation gate; fan-out begins in Step 6).
717
+ - **Pre-execution `cost_estimate`** — emitted in Step 0.5 before the Step 5 ASK gate (the only mutation gate; fan-out begins in Step 6). Each Step 9.5 re-poll round re-emits it before that round's Step 5 ASK — re-entry passes through Step 4e → Step 5, so the per-round estimate fires on the same path.
679
718
  - **Post-execution `cost_actuals` + `delta`** — appended to the Iteration Summary recap (cost facet; full blocks on the `Cost:` exception line beyond ±25%) per `rules/hatch3r-cost-visibility.md`.
680
719
 
681
- Per-tier `expected_sa_count` calibration (from frontmatter `sub_agents_spawned.count: 9` × tier heuristic in `rules/hatch3r-cost-visibility.md` Pre-Execution Estimate): Tier 1 ≈ 1 (one specialist, no review loop); Tier 2 ≈ 4 (FIX NOW fix group + review loop); Tier 3 up to 9 (full pipeline including the parallel Tier-3 final-quality specialist mandate). A no-comment short-circuit (Step 2d) emits `actual_sa_count: 0`. Deltas beyond 25% absolute value carry `flagged_for_review: true`. Token telemetry sources from `src/pipeline/observability.ts`; estimation primitives from `src/pipeline/costEstimator.ts`.
720
+ Per-tier `expected_sa_count` calibration (from frontmatter `sub_agents_spawned.count: 10` × tier heuristic in `rules/hatch3r-cost-visibility.md` Pre-Execution Estimate): Tier 1 ≈ 1 (one specialist, no review loop); Tier 2 ≈ 4 (FIX NOW fix group + review loop); Tier 3 up to 10 (full pipeline including the parallel Tier-3 final-quality specialist mandate and both mandatory-on-match specialists when triggered). A no-comment short-circuit (Step 2d) emits `actual_sa_count: 0`. Deltas beyond 25% absolute value carry `flagged_for_review: true`. Token telemetry sources from `src/pipeline/observability.ts`; estimation primitives from `src/pipeline/costEstimator.ts`.
682
721
 
683
722
  ---
684
723
 
@@ -696,21 +735,22 @@ Per-tier `expected_sa_count` calibration (from frontmatter `sub_agents_spawned.c
696
735
  | Review loop hits 3 iterations with findings remaining | ASK the user per `commands/revision/revision-quality.md` §Stage 1 Review Loop step 3 (3-iteration ASK). |
697
736
  | Quality gate fails 2 retries (Step 7a) | Record in `run_cache.errors`; Step 10 `Status: PARTIAL`. |
698
737
  | `git push` rejected (e.g., upstream changed mid-run) | Halt at Step 9 with: "Remote branch changed during run. Run `git pull --rebase`, resolve conflicts, then re-run /hatch3r-pr-resolve to repost any failed replies." |
738
+ | Step 9.5 poll budget exhausted (5 × 60s) with zero new comments | Report "No new comments after 300s."; re-ask 9.5a (keep polling / done). |
699
739
  | GraphQL `reviewThreads` query fails (GitHub resolution state) | Fall back to evaluating every inline comment (no resolution filter); record a Low-confidence note in `run_cache.errors`. |
700
740
 
701
741
  ---
702
742
 
703
743
  ## Guardrails
704
744
 
705
- 1. **One ASK gate.** Step 5 is the only user-facing checkpoint. After `accept`, the run proceeds through Steps 6–10 without further prompting (per user decision).
745
+ 1. **Two ASK gate classes.** Step 5 (triage routing, once per round) and Step 9.5 (re-poll consent, after each push) are the only user-facing checkpoints. Within a round, after `accept` Steps 6–9 run without further prompting (per user decision).
706
746
  2. **No thread closure.** Never mark a thread resolved (`isResolved: true`, Azure `status: fixed`, GitLab `resolved: true`). Thread resolution is reviewer-owned semantics.
707
747
  3. **No review verdicts.** Never approve, dismiss, or request changes on a PR review. Reply-only.
708
748
  4. **No labels or status checks.** PR labels and status checks are out of scope (handled by `hatch3r-board-fill` and CI integrations).
709
- 5. **No cross-PR work.** One PR per invocation. The `<pr-number>` argument is bound to a single PR.
749
+ 5. **No cross-PR work.** One PR per invocation. The `<pr-number>` argument is bound to a single PR. Step 9.5 rounds iterate on the same PR only — a re-poll never widens scope to another PR.
710
750
  6. **No base-branch push.** Step 9 pushes only to `pr.headRefName`. Refuse if the current branch differs.
711
751
  7. **Reply body hygiene.** Strip internal paths (`/Users/`, `/home/`, `.audit-workspace/`, `.hatch3r/`). Truncate over 60000 bytes.
712
752
  8. **Bot-comment parity.** Per user decision, comments from bot accounts are evaluated under the same rigor contract as human comments — no special-case skipping or downgrading.
713
- 9. **Skip resolved by default.** Step 2 filters resolved threads (`isResolved` for GitHub, `status: fixed/closed` for Azure, `resolved: true` for GitLab) unless a future flag explicitly opts in.
753
+ 9. **Skip resolved by default.** Step 2 filters resolved threads (`isResolved` for GitHub, `status: fixed/closed` for Azure, `resolved: true` for GitLab) unless a future flag explicitly opts in. Re-poll rounds (Step 9.5b) additionally exclude comments whose `comment_id` is in checkpoint `postedCommentIds`.
714
754
  10. **Confidence propagation.** Every reply body, every triage row, every Step 10 verdict carries a confidence rating from the upstream sub-agent or evaluation. Dropping the signal is a gate failure.
715
755
 
716
756
  ## References
@@ -33,7 +33,7 @@ Take a project idea or vision and produce complete project documentation across
33
33
  | 2. Document Generation | `hatch3r-docs-writer` (parallel: business spec, technical spec, ADRs) | Yes | Yes |
34
34
  | 3. AGENTS.md | `hatch3r-docs-writer` (AGENTS.md generation/rework) | No | Yes |
35
35
 
36
- **Parallel-safety conditions** (per `rules/hatch3r-agent-orchestration.md` §Parallel Safety): every parallel fan-out above holds all three — read-only or disjoint writes, deterministic aggregation, no shared mutable state.
36
+ **Parallel-safety conditions** (per `rules/hatch3r-agent-orchestration.md` §Parallel Safety): every parallel fan-out above holds all three — read-only or disjoint writes (file- and contract-level), deterministic aggregation, no shared mutable state.
37
37
 
38
38
  ---
39
39
 
@@ -30,7 +30,7 @@ Before any action, scan the user's change description for unresolved questions i
30
30
  | 4a. Review Loop | `hatch3r-reviewer` -> `hatch3r-fixer` (max 3 iterations) | No (sequential) | Nontrivial only |
31
31
  | 4b. Final Quality | `hatch3r-testability` + `hatch3r-security` | Yes | Nontrivial code changes |
32
32
 
33
- **Parallel-safety conditions** (per `rules/hatch3r-agent-orchestration.md` §Parallel Safety): every parallel fan-out above holds all three — read-only or disjoint writes, deterministic aggregation, no shared mutable state.
33
+ **Parallel-safety conditions** (per `rules/hatch3r-agent-orchestration.md` §Parallel Safety): every parallel fan-out above holds all three — read-only or disjoint writes (file- and contract-level), deterministic aggregation, no shared mutable state.
34
34
 
35
35
  ## Browser Automation
36
36
 
@@ -29,7 +29,7 @@ sub_agents_spawned:
29
29
  | 2. Document Generation | `hatch3r-docs-writer` (refactoring spec, ADRs) | Yes | Yes |
30
30
  | 3. Todo Generation | Orchestrator (inline) | No | Yes |
31
31
 
32
- **Parallel-safety conditions** (per `rules/hatch3r-agent-orchestration.md` §Parallel Safety): every parallel fan-out above holds all three — read-only or disjoint writes, deterministic aggregation, no shared mutable state.
32
+ **Parallel-safety conditions** (per `rules/hatch3r-agent-orchestration.md` §Parallel Safety): every parallel fan-out above holds all three — read-only or disjoint writes (file- and contract-level), deterministic aggregation, no shared mutable state.
33
33
 
34
34
  # Refactor Plan — Refactoring & Migration Specification from Problem to Phased Execution
35
35
 
@@ -55,7 +55,7 @@ This command is the delegating orchestrator around the single-pass `/h4tcher-rel
55
55
  | 9. Marketplace-lane handoff (STOP before publish/merge) | Orchestrator (inline, presents the human-approval gate) | No | Yes |
56
56
  | 10. Iteration Summary | Orchestrator (inline) | No | Yes |
57
57
 
58
- **Parallel-safety conditions** (per `rules/hatch3r-agent-orchestration.md` §Parallel Safety): every parallel fan-out above (Step 7b testability + security; Step 7c docs-writer alongside 7b) holds all three — read-only or disjoint writes, deterministic aggregation, no shared mutable state. Step 2 (version bump) and Step 3 (changelog) serialize on a dependency edge: the changelog header must match the bumped `package.json` version, so version-bump precedes changelog.
58
+ **Parallel-safety conditions** (per `rules/hatch3r-agent-orchestration.md` §Parallel Safety): every parallel fan-out above (Step 7b testability + security; Step 7c docs-writer alongside 7b) holds all three — read-only or disjoint writes (file- and contract-level), deterministic aggregation, no shared mutable state. Step 2 (version bump) and Step 3 (changelog) serialize on a dependency edge: the changelog header must match the bumped `package.json` version, so version-bump precedes changelog.
59
59
 
60
60
  ---
61
61
 
@@ -2,7 +2,7 @@
2
2
  id: hatch3r-revision
3
3
  type: command
4
4
  orchestrator: true
5
- agentPipeline: [hatch3r-researcher, hatch3r-implementer, hatch3r-lint-fixer, hatch3r-testability, hatch3r-reviewer, hatch3r-fixer, hatch3r-security, hatch3r-docs-writer, hatch3r-ui, hatch3r-performance]
5
+ agentPipeline: [hatch3r-researcher, hatch3r-implementer, hatch3r-lint-fixer, hatch3r-testability, hatch3r-reviewer, hatch3r-fixer, hatch3r-security, hatch3r-docs-writer, hatch3r-ui, hatch3r-ux, hatch3r-performance]
6
6
  description: User-guided revision of agent-implemented code in a fresh context window. Reconstructs what was done, interviews the user for feedback, fixes issues, cleans up leftovers, and drives toward merge readiness. Delegation, quality pipeline, modes, and board integration details are in commands/revision/.
7
7
  tags: [implementation, ctx:team-only]
8
8
  quality_charter: agents/shared/quality-charter.md
@@ -13,8 +13,8 @@ efficiency_tier: deep
13
13
  triage_tiers: [1, 2, 3]
14
14
  supports_resume: true
15
15
  sub_agents_spawned:
16
- count: 10
17
- rationale: Per-revision fanout — researcher (conditional, Tier 2/3 pre-implementation context per commands/revision/revision-delegation.md Step 6.pre), implementer, lint-fixer, testability (Stage 1 fix group), reviewer ↔ fixer review loop, then parallel Stage 2 final-quality CQ specialists (security, docs-writer, ui, performance) bounded by max_phase4_parallel. Tier 1 cleanup-only revisions spawn a subset. Cost-dominance per CONSTITUTION §2 P8 — token cost never serializes independent work.
16
+ count: 11
17
+ rationale: Per-revision fanout — researcher (conditional, Tier 2/3 pre-implementation context per commands/revision/revision-delegation.md Step 6.pre), implementer, lint-fixer, testability (Stage 1 fix group), reviewer ↔ fixer review loop, then parallel Stage 2 final-quality CQ specialists (security, docs-writer, ui, ux, performance — a triggered mandatory-on-match ui/ux each spawns as its own dedicated instance at Tier 2/3) bounded by max_phase4_parallel. Tier 1 cleanup-only revisions spawn a subset. Cost-dominance per CONSTITUTION §2 P8 — token cost never serializes independent work.
18
18
  ---
19
19
 
20
20
  ## §0 Detect Ambiguity (P8 B1)
@@ -33,9 +33,9 @@ sub_agents_spawned:
33
33
  | 5b. Final Quality — Testing | `hatch3r-testability` | Yes | Yes (code changes) |
34
34
  | 5c. Final Quality — Security | `hatch3r-security` | Yes | Yes (code changes) |
35
35
  | 5d. Final Quality — Docs | `hatch3r-docs-writer` | Yes | When APIs/architecture/UX affected |
36
- | 5e. Final Quality — Conditional | `hatch3r-lint-fixer`, `hatch3r-ui`, `hatch3r-performance` | Yes | When triggered |
36
+ | 5e. Final Quality — Triggered | `hatch3r-lint-fixer`, `hatch3r-performance` (conditional); `hatch3r-ui`, `hatch3r-ux` (mandatory-on-match — each triggered one MUST spawn as its own dedicated instance at Tier 2/3) | Yes | When triggered |
37
37
 
38
- **Parallel-safety conditions** (per `rules/hatch3r-agent-orchestration.md` §Parallel Safety): every parallel fan-out above holds all three — read-only or disjoint writes, deterministic aggregation, no shared mutable state.
38
+ **Parallel-safety conditions** (per `rules/hatch3r-agent-orchestration.md` §Parallel Safety): every parallel fan-out above holds all three — read-only or disjoint writes (file- and contract-level), deterministic aggregation, no shared mutable state.
39
39
 
40
40
  ## Browser Automation
41
41
 
@@ -403,7 +403,7 @@ If all findings were deferred (no [FIX NOW] items), skip Step 6 entirely and pro
403
403
 
404
404
  > Full details: see `commands/revision/revision-quality.md`
405
405
 
406
- Two-stage quality pipeline: Stage 1 runs a sequential review loop (`hatch3r-reviewer` -> `hatch3r-fixer`, max 3 iterations). Stage 2 spawns final quality CQ specialists in parallel — mandatory (`hatch3r-testability`, `hatch3r-security`), evaluated (`hatch3r-docs-writer`), and conditional (`hatch3r-ui`, `hatch3r-performance`, `hatch3r-lint-fixer`).
406
+ Two-stage quality pipeline: Stage 1 runs a sequential review loop (`hatch3r-reviewer` -> `hatch3r-fixer`, max 3 iterations). Stage 2 spawns final quality CQ specialists in parallel — mandatory (`hatch3r-testability`, `hatch3r-security`), evaluated (`hatch3r-docs-writer`), mandatory-on-match (`hatch3r-ui`, `hatch3r-ux` — each triggered one MUST spawn as its own dedicated instance at Tier 2/3), and conditional (`hatch3r-performance`, `hatch3r-lint-fixer`).
407
407
 
408
408
  ---
409
409
 
@@ -537,7 +537,7 @@ This command emits cost transparency per `rules/hatch3r-cost-visibility.md` and
537
537
  - **Pre-execution `cost_estimate`** — emitted in Step 0.5 before the first sub-agent dispatch (Step 6 fix delegation).
538
538
  - **Post-execution `cost_actuals` + `delta`** — appended to the Iteration Summary recap (cost facet; full blocks on the `Cost:` exception line beyond ±25%) per `rules/hatch3r-cost-visibility.md`.
539
539
 
540
- Per-tier `expected_sa_count` calibration (from frontmatter `sub_agents_spawned.count: 10` × tier heuristic in `rules/hatch3r-cost-visibility.md` Pre-Execution Estimate): Tier 1 cleanup-only ≈ 0 (inline fixes, no sub-agent); Tier 2 ≈ 5 (conditional researcher + implementer/lint-fixer/hatch3r-testability fix group + reviewer); Tier 3 up to 10 (conditional researcher + full pipeline including the parallel Stage 2 final-quality specialists bounded by `max_phase4_parallel`). Deltas beyond 25% absolute value carry `flagged_for_review: true`. Token telemetry sources from `src/pipeline/observability.ts`; estimation primitives from `src/pipeline/costEstimator.ts`.
540
+ Per-tier `expected_sa_count` calibration (from frontmatter `sub_agents_spawned.count: 11` × tier heuristic in `rules/hatch3r-cost-visibility.md` Pre-Execution Estimate): Tier 1 cleanup-only ≈ 0 (inline fixes, no sub-agent); Tier 2 ≈ 5 (conditional researcher + implementer/lint-fixer/hatch3r-testability fix group + reviewer); Tier 3 up to 11 (conditional researcher + full pipeline including the parallel Stage 2 final-quality specialists bounded by `max_phase4_parallel`). Deltas beyond 25% absolute value carry `flagged_for_review: true`. Token telemetry sources from `src/pipeline/observability.ts`; estimation primitives from `src/pipeline/costEstimator.ts`.
541
541
 
542
542
  ---
543
543
 
@@ -33,7 +33,7 @@ Generate a dependency-aware, priority-ordered roadmap with **two parallel dimens
33
33
  | 2. Document Generation | `hatch3r-docs-writer` (todo.md generation) | No | Yes |
34
34
  | 3. AGENTS.md | `hatch3r-docs-writer` (AGENTS.md generation/rework) | No | Yes |
35
35
 
36
- **Parallel-safety conditions** (per `rules/hatch3r-agent-orchestration.md` §Parallel Safety): every parallel fan-out above holds all three — read-only or disjoint writes, deterministic aggregation, no shared mutable state.
36
+ **Parallel-safety conditions** (per `rules/hatch3r-agent-orchestration.md` §Parallel Safety): every parallel fan-out above holds all three — read-only or disjoint writes (file- and contract-level), deterministic aggregation, no shared mutable state.
37
37
 
38
38
  ---
39
39
 
@@ -33,7 +33,7 @@ This command discovers the module taxonomy via static analysis, then delegates s
33
33
  | 4. Issue Creation | Orchestrator (GitHub MCP) | No | Yes |
34
34
  | 5. Board Sync | Orchestrator (Projects v2 sync) | No | Yes |
35
35
 
36
- **Parallel-safety conditions** (per `rules/hatch3r-agent-orchestration.md` §Parallel Safety): every parallel fan-out above holds all three — read-only or disjoint writes, deterministic aggregation, no shared mutable state.
36
+ **Parallel-safety conditions** (per `rules/hatch3r-agent-orchestration.md` §Parallel Safety): every parallel fan-out above holds all three — read-only or disjoint writes (file- and contract-level), deterministic aggregation, no shared mutable state.
37
37
 
38
38
  All issue operations MUST follow the Projects v2 Enforcement rules defined in `hatch3r-board-shared`.
39
39
 
@@ -29,7 +29,7 @@ sub_agents_spawned:
29
29
  | 2. Document Generation | `hatch3r-docs-writer` (test plan spec, ADRs) | Yes | Yes |
30
30
  | 3. Todo Generation | Orchestrator (inline) | No | Yes |
31
31
 
32
- **Parallel-safety conditions** (per `rules/hatch3r-agent-orchestration.md` §Parallel Safety): every parallel fan-out above holds all three — read-only or disjoint writes, deterministic aggregation, no shared mutable state.
32
+ **Parallel-safety conditions** (per `rules/hatch3r-agent-orchestration.md` §Parallel Safety): every parallel fan-out above holds all three — read-only or disjoint writes (file- and contract-level), deterministic aggregation, no shared mutable state.
33
33
 
34
34
  # Test Plan -- Comprehensive Test Strategy from Scope to Board-Ready Epic
35
35
 
@@ -37,9 +37,9 @@ Optional guided development lifecycle command that walks through structured phas
37
37
  | 3b. Final Quality — Testing | `hatch3r-testability` | Yes | Yes (code changes) |
38
38
  | 3c. Final Quality — Security | `hatch3r-security` | Yes | Yes (code changes) |
39
39
  | 3d. Final Quality — Docs | `hatch3r-docs-writer` | Yes | When APIs/architecture/UX affected |
40
- | 3e. Final Quality — Conditional | `hatch3r-lint-fixer` + all conditional CQ specialists (CQ1-CQ9: `hatch3r-ui`, `hatch3r-ux`, `hatch3r-reliability`, `hatch3r-scalability`, `hatch3r-performance`, `hatch3r-maintainability`, `hatch3r-enhancability`) per `SPECIALIST_TRIGGER_TABLE` | Yes | Spawn each whose trigger matches the diff |
40
+ | 3e. Final Quality — Triggered | `hatch3r-lint-fixer` + `hatch3r-ui` + `hatch3r-ux` (mandatory-on-match — each triggered one MUST spawn as its own dedicated instance at Tier 2/3) + the conditional CQ specialists (`hatch3r-reliability`, `hatch3r-scalability`, `hatch3r-performance`, `hatch3r-maintainability`, `hatch3r-enhancability`) per `SPECIALIST_TRIGGER_TABLE` | Yes | Spawn each whose trigger matches the diff |
41
41
 
42
- **Parallel-safety conditions** (per `rules/hatch3r-agent-orchestration.md` §Parallel Safety): every parallel fan-out above (multi-module implementers in Phase 3, the Phase-4b final-quality batch) holds all three — read-only or disjoint writes, deterministic aggregation, no shared mutable state.
42
+ **Parallel-safety conditions** (per `rules/hatch3r-agent-orchestration.md` §Parallel Safety): every parallel fan-out above (multi-module implementers in Phase 3, the Phase-4b final-quality batch) holds all three — read-only or disjoint writes (file- and contract-level), deterministic aggregation, no shared mutable state.
43
43
 
44
44
  ## Browser Automation
45
45
 
@@ -344,9 +344,10 @@ Spawn a `hatch3r-reviewer` sub-agent via the Task tool (`subagent_type: "general
344
344
  2. **Confidence-aware gate** (the second-pass trigger tightens with the `--confidence-floor` set in Step 0.7 — `any` = default below, `medium`/`high` raise the bar). First resolve the reviewer `confidence` field per the Confidence Propagation Contract absent-confidence clause: an absent or unparseable value is treated as `low` (it does NOT satisfy `!= low`), matching the code gate where `unknown` ranks below `low`.
345
345
  - **0 Critical + 0 Warning AND reviewer confidence == high or medium:** Review loop is clean. Proceed to 4b. (Floor `medium`: also force a second pass if any individual finding is `confidence == low`. Floor `high`: force a second pass if reviewer confidence `!= high` OR any finding is `!= high`, AND ASK on every low-confidence finding.)
346
346
  - **0 Critical + 0 Warning AND reviewer confidence == low (including absent/unparseable, resolved to `low` above):** Trigger a second reviewer pass before exiting. Do not proceed to 4b until the second pass returns high/medium confidence OR the user explicitly accepts the low-confidence PASS at the ASK checkpoint in step 5.
347
- 3. **If Critical or Warning findings exist:** Spawn a `hatch3r-fixer` sub-agent with the reviewer output. The fixer applies fixes for all Critical and Warning findings.
347
+ 3. **If Critical or Warning findings exist:** Spawn a `hatch3r-fixer` sub-agent with the reviewer output. The fixer applies fixes for all Critical and Warning findings — append the W1 write-ahead rows before the fixer dispatch and the W2 disposition rows after the re-review (`rules/hatch3r-findings-ledger.md` → Write Points).
348
348
  4. **Re-review:** After the fixer completes, spawn `hatch3r-reviewer` again to verify fixes.
349
- 5. **Repeat** steps 2-4 for a maximum of **3 iterations** (code-class cap). If still not clean after 3 iterations, **ASK** the user how to proceed (force continue / manual fix / abort).
349
+ 5. **Repeat** steps 2-4 for a maximum of **3 iterations** (code-class cap). If still not clean after 3 iterations, **ASK** the user how to proceed (force continue / manual fix / abort). The ASK lists each open `finding_id` with its legal closures (fix manually / defer → todo.md anchor / accept risk — user-attested only); on exit, reconcile the ledger to the run-exit invariant (W3, `rules/hatch3r-findings-ledger.md`); in `--auto` mode record open findings as `escalated` and exit PARTIAL.
350
+ - **Suggestion terminalization (W5):** every Suggestion row goes terminal at loop exit — `surfaced` (ID on the recap's `Open findings:` line), `deferred` (todo.md anchor), or `declined` (quoted user reply); unattended default is `surfaced` (`rules/hatch3r-findings-ledger.md`).
350
351
 
351
352
  > **Iteration-cap rationale (D10-SA10.7-F10.7.7).** Code reviews diverge faster than spec reviews — a code finding can spawn a regression the next iteration must catch — so the code-class loop here caps at 3. The spec-class loop in `hatch3r-board-fill` Step 7.9d caps at 4 because issue-spec reviews converge more slowly and deterministically (text refinement, no runtime regressions). Both are bounded below `DEFAULT_MAX_REVIEW_ITERATIONS` (4) in `src/pipeline/reviewLoop.ts`, which keeps the oscillation detector reachable in default config. Expected convergence is 1–2 iterations; the cap is the divergence backstop, not the target.
352
353
 
@@ -373,13 +374,13 @@ Each reviewer/fixer sub-agent prompt MUST include:
373
374
 
374
375
  3. **`hatch3r-docs-writer`** — spawn when changes affect public APIs, architectural patterns, user-facing behavior, or when specs/ADRs need updating. Skip silently if no documentation impact.
375
376
 
376
- **Conditional specialists (spawn each whose trigger matches the diff):**
377
+ **Triggered specialists (spawn each whose trigger matches the diff):**
377
378
 
378
- Spawn **all conditional CQ specialists (CQ1-CQ9) per `SPECIALIST_TRIGGER_TABLE`** plus `hatch3r-lint-fixer` — not the lint/ui/performance subset alone. Evaluate each via `shouldTriggerSpecialist(specialist, changedFiles, projectType)` (D6-M11); spawn the ones that return `{ triggered: true }`:
379
+ Spawn **all triggered CQ specialists (CQ1-CQ9) per `SPECIALIST_TRIGGER_TABLE`** plus `hatch3r-lint-fixer` — not the lint/ui/performance subset alone. Evaluate each via `shouldTriggerSpecialist(specialist, changedFiles, projectType)` (D6-M11); spawn the ones that return `{ triggered: true }`. A `mandatory: true` return (mode `mandatory-on-match`) is non-skippable at Tier 2/3 — that specialist MUST spawn as its own dedicated sub-agent instance:
379
380
 
380
381
  4. **`hatch3r-lint-fixer`** — lint or type errors present after implementation.
381
- 5. **`hatch3r-ui`** (CQ1) — UI component / design-token / theme files modified.
382
- 6. **`hatch3r-ux`** (CQ2) — flow / route-transition / modal / error-state files or microcopy/i18n strings modified.
382
+ 5. **`hatch3r-ui`** (CQ1, mandatory-on-match) — UI component / design-token / theme files modified. When triggered at Tier 2/3, a dedicated `hatch3r-ui` instance is a hard mandate.
383
+ 6. **`hatch3r-ux`** (CQ2, mandatory-on-match) — flow / route-transition / modal / error-state files or microcopy/i18n strings modified. When triggered at Tier 2/3, a dedicated `hatch3r-ux` instance is a hard mandate (never merged into the `hatch3r-ui` spawn).
383
384
  7. **`hatch3r-reliability`** (CQ4) — service/request handler, OTel/SLO, retry/circuit-breaker, or Kubernetes-probe code modified.
384
385
  8. **`hatch3r-scalability`** (CQ6) — request handler, queue client, connection-pool, cache, or background-job code modified.
385
386
  9. **`hatch3r-performance`** (CQ7) — ORM/data-access, UI-rendering, or bundle/hot-path code modified.
@@ -388,7 +389,7 @@ Spawn **all conditional CQ specialists (CQ1-CQ9) per `SPECIALIST_TRIGGER_TABLE`*
388
389
 
389
390
  (`hatch3r-architect` and `hatch3r-devops` are also conditional in `SPECIALIST_TRIGGER_TABLE` but are not CQ-vector specialists; spawn them too when their architectural / CI-CD triggers match.)
390
391
 
391
- > **Single source of truth for triggers (D6-M11):** the canonical trigger map lives in `src/pipeline/pipelineContext.ts::SPECIALIST_TRIGGER_TABLE` and the predicate `shouldTriggerSpecialist(specialist, changedFiles, projectType)` returns `{ triggered, reasons }` for any specialist. The brief prose list above is a quick reference only; for the authoritative trigger evaluation at runtime, call `shouldTriggerSpecialist` from the orchestrator harness (or the equivalent mirror in `rules/hatch3r-agent-orchestration.md` → Phase 4 Specialist Trigger Table). Adding a specialist to the prose without updating the TS table is rejected by `npm run validate:specialist-roster`.
392
+ > **Single source of truth for triggers (D6-M11):** the canonical trigger map lives in `src/pipeline/pipelineContext.ts::SPECIALIST_TRIGGER_TABLE` and the predicate `shouldTriggerSpecialist(specialist, changedFiles, projectType)` returns `{ triggered, reasons, mandatory? }` for any specialist. The brief prose list above is a quick reference only; for the authoritative trigger evaluation at runtime, call `shouldTriggerSpecialist` from the orchestrator harness (or the equivalent mirror in `rules/hatch3r-agent-orchestration.md` → Phase 4 Specialist Trigger Table). Adding a specialist to the prose without updating the TS table is rejected by `npm run validate:specialist-roster`.
392
393
 
393
394
  Each specialist sub-agent prompt MUST include:
394
395
  - The agent protocol to follow.
@@ -522,13 +523,14 @@ When invoked with `--auto` or `--unattended`, the workflow operates with reduced
522
523
  | Analysis review (Phase 1) | ASK user to proceed | Auto-proceed if no open questions |
523
524
  | Plan review (Phase 2) | ASK user to approve | Auto-proceed with plan |
524
525
  | Implementation review (Phase 3) | ASK user before Review | Auto-proceed if quality checks pass |
525
- | Review finalization (Phase 4) | ASK user to finalize | Auto-finalize if all AC met |
526
+ | Review finalization (Phase 4) | ASK user to finalize | Auto-finalize only when all AC met AND no unattested product decision is recorded (see Safety Guardrails) |
526
527
 
527
528
  ### Safety Guardrails (Always Active)
528
529
 
529
530
  These checkpoints are NEVER skipped, even in auto mode:
530
531
  - **Destructive operations**: Database migrations, file deletions, security rule changes always require confirmation
531
532
  - **Breaking changes**: API contract changes, public interface modifications always require confirmation
533
+ - **Product-behavior decisions:** a change that deletes or transforms user data, or alters user-visible behavior beyond the issue's acceptance criteria, always requires user confirmation — a code comment or PR sentence authored by this run is not user consent (`agents/shared/user-question-protocol.md` → Unattested product decision). Unattended: record the decision as `escalated` in the findings ledger and exit PARTIAL.
532
534
  - **Open questions**: If Phase 1 analysis surfaces unresolvable ambiguity, stop and ASK regardless of mode
533
535
  - **Quality gate failures**: If lint/typecheck/test fail after 2 fix attempts, stop and ASK
534
536
  - **Cost thresholds**: When the estimated cost for the selected tier exceeds the configured limit (default: $10 per task), do NOT abort silently. Call `proposeAlternativeTier(currentTier, currentEstimate, budget)` from `src/pipeline/costEstimator.ts` and surface a 3-option ASK: **(a) downgrade** to the suggested lower tier (saves the reported delta — drops the deep researcher modes / Phase-4 specialist depth that the lower tier omits), **(b) raise the budget** and proceed at the current tier, **(c) abort**. Default-if-no-response: abort (preserves the fail-closed contract). When `proposeAlternativeTier` returns `null` (current tier is already the cheapest, or no lower tier fits), present only raise-budget / abort.
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  id: hatch3r-revision-quality
3
3
  type: command
4
- description: Quality verification pipeline for revision Step 7. Covers review loop (Stage 1), final quality with conditional specialists (Stage 2), and failure handling.
4
+ description: Quality verification pipeline for revision Step 7. Covers review loop (Stage 1), final quality with triggered specialists (Stage 2), and failure handling.
5
5
  tags: [implementation, team]
6
6
  quality_charter: agents/shared/quality-charter.md
7
7
  cache_friendly: true
@@ -51,9 +51,9 @@ The reviewer prompt MUST include:
51
51
  - If **0 Critical + 0 Warning AND reviewer confidence != low:** review loop is clean. Proceed to Stage 2.
52
52
  - If **0 Critical + 0 Warning AND reviewer confidence == low:** trigger a second reviewer pass before exiting. Do not proceed to Stage 2 until the second pass returns non-low confidence OR the user explicitly accepts the low-confidence PASS.
53
53
  - **Floor tightening:** at floor `medium` the pass surface above is unchanged; at floor `high` a `medium`-confidence clean verdict also triggers a second pass (and any low-confidence finding triggers an ASK). Apply the floor-tier branches from the shared gate — do not collapse `medium`/`high` to the `any` row.
54
- - If Critical or Warning findings remain: spawn `hatch3r-fixer` sub-agent to address them. The fixer prompt MUST include `correlation_id` (UUID v4 generated per top-level task per `rules/hatch3r-agent-orchestration.md` → Correlation ID) — the sub-agent echoes it in logs, outputs, and status reports for cross-phase attribution. When fixes touch shared or public interfaces, include blast radius data and reference conventions in the fixer prompt. Then re-run the reviewer (next iteration).
54
+ - If Critical or Warning findings remain: spawn `hatch3r-fixer` sub-agent to address them — append the W1 write-ahead rows before the fixer dispatch (`rules/hatch3r-findings-ledger.md` → Write Points). The fixer prompt MUST include `correlation_id` (UUID v4 generated per top-level task per `rules/hatch3r-agent-orchestration.md` → Correlation ID) — the sub-agent echoes it in logs, outputs, and status reports for cross-phase attribution. When fixes touch shared or public interfaces, include blast radius data and reference conventions in the fixer prompt. Then re-run the reviewer (next iteration).
55
55
 
56
- 3. If 3 iterations complete and findings remain, **ASK** the user whether to proceed or fix manually.
56
+ 3. If 3 iterations complete and findings remain, **ASK** the user whether to proceed or fix manually — the ASK lists the open `finding_id`s with legal closures; reconcile the ledger to the run-exit invariant (W3, `rules/hatch3r-findings-ledger.md`) on exit.
57
57
 
58
58
  After each reviewer iteration, assess the reviewer's findings confidence: if the reviewer rates any finding as low-confidence, flag it separately in the ASK prompt so the user can prioritize human review of uncertain findings. The reviewer sub-agent output MUST include a top-level `confidence: high | medium | low` field (not just per-finding) so the gate in step 2 can evaluate it deterministically.
59
59
 
@@ -74,10 +74,11 @@ After the review loop is clean, spawn specialist agents in parallel via the Task
74
74
 
75
75
  - **`hatch3r-docs-writer`** — spawn when revision fixes affect public APIs, architectural patterns, or user-facing behavior. Skip silently when no documentation impact is detected (no API signature changes, no UX behavioral changes, no new configuration options).
76
76
 
77
- ### Conditional Specialists (Spawn When Triggered)
77
+ ### Triggered Specialists (Spawn When Triggered)
78
78
 
79
79
  - **`hatch3r-lint-fixer`** — spawn when lint errors are present after fix implementation (Step 6 lint-fixer may have missed errors introduced by other sub-agents).
80
- - **`hatch3r-ui`** (CQ1) — spawn when the diff includes UI component changes (`area:ui` or `area:a11y` label on linked issues, or component/style files in the diff).
80
+ - **`hatch3r-ui`** (CQ1, mandatory-on-match) — spawn when the diff includes UI component changes (`area:ui` or `area:a11y` label on linked issues, or component/style files in the diff). When triggered at Tier 2/3, a dedicated `hatch3r-ui` instance is a hard mandate — skipping it is a gate failure.
81
+ - **`hatch3r-ux`** (CQ2, mandatory-on-match) — spawn when the diff includes flow / route-transition / modal / error-state files or microcopy/i18n string changes. When triggered at Tier 2/3, a dedicated `hatch3r-ux` instance is a hard mandate (never merged into the `hatch3r-ui` spawn).
81
82
  - **`hatch3r-performance`** (CQ7) — spawn when the diff includes hot-path changes (`area:performance` label on linked issues, or changes to database queries, API handlers, rendering loops).
82
83
 
83
84
  ### Specialist Prompt Requirements
@@ -101,13 +101,13 @@ The TypeScript implementation of this schema with runtime validation is in `src/
101
101
  | Phase 3 (Review) | Max iterations (3) (code-class cap = `DEFAULT_MAX_REVIEW_ITERATIONS` - 1) | Surface unresolved findings to user. Do not merge. |
102
102
  | Phase 3 (Review) | DESIGN_OBJECTION verdict | Terminate review loop immediately. Surface the objection and alternative approaches to the user for an architectural decision. Do not spawn fixer. |
103
103
  | Phase 3 (Review) | Fixer introduces regressions | Revert fixer changes. Surface original findings + regression to user. |
104
- | Phase 4 (Quality) | Conditional-specialist timeout | Log timeout. Continue with available results. Flag in output. |
104
+ | Phase 4 (Quality) | Conditional or mandatory-on-match specialist timeout | Log timeout. Continue with available results. Flag in output (the mandatory-on-match Tier 2/3 mandate binds at dispatch — the instance was spawned; a post-dispatch timeout is a flagged result, not a skipped gate). |
105
105
  | Phase 4 (Quality) | Mandatory CQ3/CQ5 specialist non-completion (TIMEOUT / crash / no-output) | Fail closed. Surface `BLOCKED`. A mandatory always-mode specialist (`hatch3r-security` CQ3, `hatch3r-testability` CQ5 per `hatch3r-agent-orchestration.md` Phase 4 Specialist Trigger Table) that does not return `COMPLETE` leaves its gate absent; absence-of-finding is NOT an implicit pass. This row is the prose face of the typed gate `evaluatePhase4Completion` (`src/pipeline/pipelineContext.ts`): a non-SUCCESS floor specialist yields `mandatoryFloorsSatisfied: false` → `complete: false`. Do not merge/release. Require an explicit operator decision (re-run, accept-risk, or abort) before advancing. |
106
106
  | Phase 4 (Quality) | Validation pass fails | Spawn fixer (max 2 attempts). Surface if unresolved. |
107
107
 
108
108
  ### Subagent Error Recovery
109
109
 
110
- 1. **Timeout:** Forward partial output. Mark status `TIMEOUT`. Continue pipeline ONLY for conditional specialists. A mandatory always-mode CQ3/CQ5 specialist on TIMEOUT fails closed — surface `BLOCKED`, never treat the missing gate as a pass.
110
+ 1. **Timeout:** Forward partial output. Mark status `TIMEOUT`. Continue pipeline ONLY for conditional and mandatory-on-match specialists (their Tier 2/3 mandate binds at dispatch — the instance was spawned; flag the timeout in output). A mandatory always-mode CQ3/CQ5 specialist on TIMEOUT fails closed — surface `BLOCKED`, never treat the missing gate as a pass.
111
111
  2. **Crash/no output:** Mark status `FAILED`. Log reason. Continue if non-blocking. A mandatory always-mode CQ3/CQ5 specialist is blocking — a crash or no-output return fails closed (surface `BLOCKED`, explicit operator decision before merge/release), it is never "non-blocking".
112
112
  3. **Conflicting outputs:** When two specialists disagree (e.g., security vs performance), escalate to user with both positions.
113
113
  4. **Resource exhaustion:** Apply the Context-Degradation Policy (this file) — compress at `>50%` window, restart at `>75%`.
@@ -96,13 +96,13 @@ The TypeScript implementation of this schema with runtime validation is in `src/
96
96
  | Phase 3 (Review) | Max iterations (3) (code-class cap = `DEFAULT_MAX_REVIEW_ITERATIONS` - 1) | Surface unresolved findings to user. Do not merge. |
97
97
  | Phase 3 (Review) | DESIGN_OBJECTION verdict | Terminate review loop immediately. Surface the objection and alternative approaches to the user for an architectural decision. Do not spawn fixer. |
98
98
  | Phase 3 (Review) | Fixer introduces regressions | Revert fixer changes. Surface original findings + regression to user. |
99
- | Phase 4 (Quality) | Conditional-specialist timeout | Log timeout. Continue with available results. Flag in output. |
99
+ | Phase 4 (Quality) | Conditional or mandatory-on-match specialist timeout | Log timeout. Continue with available results. Flag in output (the mandatory-on-match Tier 2/3 mandate binds at dispatch — the instance was spawned; a post-dispatch timeout is a flagged result, not a skipped gate). |
100
100
  | Phase 4 (Quality) | Mandatory CQ3/CQ5 specialist non-completion (TIMEOUT / crash / no-output) | Fail closed. Surface `BLOCKED`. A mandatory always-mode specialist (`hatch3r-security` CQ3, `hatch3r-testability` CQ5 per `hatch3r-agent-orchestration.md` Phase 4 Specialist Trigger Table) that does not return `COMPLETE` leaves its gate absent; absence-of-finding is NOT an implicit pass. This row is the prose face of the typed gate `evaluatePhase4Completion` (`src/pipeline/pipelineContext.ts`): a non-SUCCESS floor specialist yields `mandatoryFloorsSatisfied: false` → `complete: false`. Do not merge/release. Require an explicit operator decision (re-run, accept-risk, or abort) before advancing. |
101
101
  | Phase 4 (Quality) | Validation pass fails | Spawn fixer (max 2 attempts). Surface if unresolved. |
102
102
 
103
103
  ### Subagent Error Recovery
104
104
 
105
- 1. **Timeout:** Forward partial output. Mark status `TIMEOUT`. Continue pipeline ONLY for conditional specialists. A mandatory always-mode CQ3/CQ5 specialist on TIMEOUT fails closed — surface `BLOCKED`, never treat the missing gate as a pass.
105
+ 1. **Timeout:** Forward partial output. Mark status `TIMEOUT`. Continue pipeline ONLY for conditional and mandatory-on-match specialists (their Tier 2/3 mandate binds at dispatch — the instance was spawned; flag the timeout in output). A mandatory always-mode CQ3/CQ5 specialist on TIMEOUT fails closed — surface `BLOCKED`, never treat the missing gate as a pass.
106
106
  2. **Crash/no output:** Mark status `FAILED`. Log reason. Continue if non-blocking. A mandatory always-mode CQ3/CQ5 specialist is blocking — a crash or no-output return fails closed (surface `BLOCKED`, explicit operator decision before merge/release), it is never "non-blocking".
107
107
  3. **Conflicting outputs:** When two specialists disagree (e.g., security vs performance), escalate to user with both positions.
108
108
  4. **Resource exhaustion:** Apply the Context-Degradation Policy (this file) — compress at `>50%` window, restart at `>75%`.