@danmoisan/drm-copilot-mcp 1.1.19 → 1.1.21

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 (170) hide show
  1. package/out/mcp-server.js +172 -11
  2. package/package.json +1 -1
  3. package/resources/claude-customizations/.claude/agents/atomic-executor.md +17 -6
  4. package/resources/claude-customizations/.claude/agents/atomic-planner.md +10 -2
  5. package/resources/claude-customizations/.claude/agents/epic-orchestrator.md +5 -0
  6. package/resources/claude-customizations/.claude/agents/orchestrator.md +4 -1
  7. package/resources/claude-customizations/.claude/agents/parallel-orchestrator.md +4 -0
  8. package/resources/claude-customizations/.claude/agents/task-researcher.md +8 -0
  9. package/resources/claude-customizations/.claude/hooks/enforce-epic-merge-gate-command.ps1 +190 -0
  10. package/resources/claude-customizations/.claude/hooks/enforce-epic-merge-gate.ps1 +22 -53
  11. package/resources/claude-customizations/.claude/hooks/hook-docs-only-diff.ps1 +5 -1
  12. package/resources/claude-customizations/.claude/hooks/premortem-section.ps1 +149 -0
  13. package/resources/claude-customizations/.claude/hooks/validate-executor-output.ps1 +210 -84
  14. package/resources/claude-customizations/.claude/hooks/validate-planner-output.ps1 +13 -1
  15. package/resources/claude-customizations/.claude/hooks/validate-task-researcher-output.ps1 +24 -5
  16. package/resources/claude-customizations/.claude/lib/ci-gate/Invoke-MergeConfirmationParser.ps1 +203 -0
  17. package/resources/claude-customizations/.claude/lib/codex-routing/CodexDeployment.psm1 +10 -10
  18. package/resources/claude-customizations/.claude/rules/plan-acceptance-gates.md +46 -10
  19. package/resources/claude-customizations/.claude/skills/atomic-plan-contract/SKILL.md +48 -16
  20. package/resources/claude-customizations/.claude/skills/cleanup-merged-worktrees/SKILL.md +7 -3
  21. package/resources/claude-customizations/.claude/skills/csharp-change-budget-router/SKILL.md +2 -2
  22. package/resources/claude-customizations/.claude/skills/epic-orchestrate/SKILL.md +12 -3
  23. package/resources/claude-customizations/.claude/skills/epic-plan/SKILL.md +4 -2
  24. package/resources/claude-customizations/.claude/skills/execution-environment/SKILL.md +134 -0
  25. package/resources/claude-customizations/.claude/skills/orchestrate/SKILL.md +22 -9
  26. package/resources/claude-customizations/.claude/skills/parallel-orchestrate/SKILL.md +29 -5
  27. package/resources/claude-customizations/.claude/skills/powershell-change-budget-router/SKILL.md +1 -1
  28. package/resources/claude-customizations/.claude/skills/python-change-budget-router/SKILL.md +1 -1
  29. package/resources/claude-customizations/.claude/skills/remediation-handoff-atomic-planner/SKILL.md +14 -6
  30. package/resources/claude-customizations/.claude/skills/research-issue/SKILL.md +6 -0
  31. package/resources/claude-customizations/config/orchestration-routing.json +7 -7
  32. package/resources/claude-customizations/pack-manifests/core.json +4 -0
  33. package/resources/codex-and-agents-customizations/.agents/skills/README.md +1 -0
  34. package/resources/codex-and-agents-customizations/.agents/skills/atomic-executor/SKILL.md +8 -7
  35. package/resources/codex-and-agents-customizations/.agents/skills/atomic-plan-contract/SKILL.md +39 -4
  36. package/resources/codex-and-agents-customizations/.agents/skills/atomic-planner/SKILL.md +8 -6
  37. package/resources/codex-and-agents-customizations/.agents/skills/codex-model-routing/SKILL.md +6 -6
  38. package/resources/codex-and-agents-customizations/.agents/skills/csharp-change-budget-router/SKILL.md +2 -2
  39. package/resources/codex-and-agents-customizations/.agents/skills/epic-orchestrate/SKILL.md +15 -8
  40. package/resources/codex-and-agents-customizations/.agents/skills/epic-plan/SKILL.md +2 -2
  41. package/resources/codex-and-agents-customizations/.agents/skills/execution-environment/SKILL.md +134 -0
  42. package/resources/codex-and-agents-customizations/.agents/skills/orchestrate/SKILL.md +16 -6
  43. package/resources/codex-and-agents-customizations/.agents/skills/orchestrator-workflow/SKILL.md +1 -1
  44. package/resources/codex-and-agents-customizations/.agents/skills/powershell-change-budget-router/SKILL.md +1 -1
  45. package/resources/codex-and-agents-customizations/.agents/skills/python-change-budget-router/SKILL.md +1 -1
  46. package/resources/codex-and-agents-customizations/.agents/skills/remediation-handoff-atomic-planner/SKILL.md +7 -3
  47. package/resources/codex-and-agents-customizations/.agents/skills/research-issue/SKILL.md +6 -0
  48. package/resources/codex-and-agents-customizations/.codex/agents/atomic-executor-c1.toml +11 -7
  49. package/resources/codex-and-agents-customizations/.codex/agents/atomic-executor-c2.toml +11 -7
  50. package/resources/codex-and-agents-customizations/.codex/agents/atomic-executor-c3-elevated.toml +11 -7
  51. package/resources/codex-and-agents-customizations/.codex/agents/atomic-executor-c3.toml +11 -7
  52. package/resources/codex-and-agents-customizations/.codex/agents/atomic-executor-c4.toml +11 -7
  53. package/resources/codex-and-agents-customizations/.codex/agents/atomic-executor.toml +11 -7
  54. package/resources/codex-and-agents-customizations/.codex/agents/atomic-planner-c1.toml +6 -3
  55. package/resources/codex-and-agents-customizations/.codex/agents/atomic-planner-c2.toml +6 -3
  56. package/resources/codex-and-agents-customizations/.codex/agents/atomic-planner-c3-elevated.toml +6 -3
  57. package/resources/codex-and-agents-customizations/.codex/agents/atomic-planner-c3.toml +6 -3
  58. package/resources/codex-and-agents-customizations/.codex/agents/atomic-planner-c4.toml +6 -3
  59. package/resources/codex-and-agents-customizations/.codex/agents/atomic-planner.toml +6 -3
  60. package/resources/codex-and-agents-customizations/.codex/agents/atomic-planning.toml +1 -1
  61. package/resources/codex-and-agents-customizations/.codex/agents/commit-steward-c1.toml +1 -1
  62. package/resources/codex-and-agents-customizations/.codex/agents/commit-steward-c2.toml +1 -1
  63. package/resources/codex-and-agents-customizations/.codex/agents/commit-steward-c3-elevated.toml +1 -1
  64. package/resources/codex-and-agents-customizations/.codex/agents/commit-steward-c3.toml +1 -1
  65. package/resources/codex-and-agents-customizations/.codex/agents/commit-steward-c4.toml +1 -1
  66. package/resources/codex-and-agents-customizations/.codex/agents/commit-steward.toml +1 -1
  67. package/resources/codex-and-agents-customizations/.codex/agents/csharp-atomic-planning.toml +1 -1
  68. package/resources/codex-and-agents-customizations/.codex/agents/csharp-typed-engineer-c1.toml +1 -1
  69. package/resources/codex-and-agents-customizations/.codex/agents/csharp-typed-engineer-c2.toml +1 -1
  70. package/resources/codex-and-agents-customizations/.codex/agents/csharp-typed-engineer-c3-elevated.toml +1 -1
  71. package/resources/codex-and-agents-customizations/.codex/agents/csharp-typed-engineer-c3.toml +1 -1
  72. package/resources/codex-and-agents-customizations/.codex/agents/csharp-typed-engineer-c4.toml +1 -1
  73. package/resources/codex-and-agents-customizations/.codex/agents/csharp-typed-engineer.toml +1 -1
  74. package/resources/codex-and-agents-customizations/.codex/agents/epic-orchestrator.toml +4 -2
  75. package/resources/codex-and-agents-customizations/.codex/agents/epic-planner.toml +2 -2
  76. package/resources/codex-and-agents-customizations/.codex/agents/feature-reviewer-c1.toml +1 -1
  77. package/resources/codex-and-agents-customizations/.codex/agents/feature-reviewer-c2.toml +1 -1
  78. package/resources/codex-and-agents-customizations/.codex/agents/feature-reviewer-c3-elevated.toml +1 -1
  79. package/resources/codex-and-agents-customizations/.codex/agents/feature-reviewer-c3.toml +1 -1
  80. package/resources/codex-and-agents-customizations/.codex/agents/feature-reviewer-c4.toml +1 -1
  81. package/resources/codex-and-agents-customizations/.codex/agents/feature-reviewer.toml +1 -1
  82. package/resources/codex-and-agents-customizations/.codex/agents/orchestrator-c1.toml +8 -5
  83. package/resources/codex-and-agents-customizations/.codex/agents/orchestrator-c2.toml +8 -5
  84. package/resources/codex-and-agents-customizations/.codex/agents/orchestrator-c3-elevated.toml +8 -5
  85. package/resources/codex-and-agents-customizations/.codex/agents/orchestrator-c3.toml +8 -5
  86. package/resources/codex-and-agents-customizations/.codex/agents/orchestrator-c4.toml +8 -5
  87. package/resources/codex-and-agents-customizations/.codex/agents/orchestrator.toml +8 -5
  88. package/resources/codex-and-agents-customizations/.codex/agents/powershell-atomic-planning.toml +1 -1
  89. package/resources/codex-and-agents-customizations/.codex/agents/powershell-typed-engineer-c1.toml +1 -1
  90. package/resources/codex-and-agents-customizations/.codex/agents/powershell-typed-engineer-c2.toml +1 -1
  91. package/resources/codex-and-agents-customizations/.codex/agents/powershell-typed-engineer-c3-elevated.toml +1 -1
  92. package/resources/codex-and-agents-customizations/.codex/agents/powershell-typed-engineer-c3.toml +1 -1
  93. package/resources/codex-and-agents-customizations/.codex/agents/powershell-typed-engineer-c4.toml +1 -1
  94. package/resources/codex-and-agents-customizations/.codex/agents/powershell-typed-engineer.toml +1 -1
  95. package/resources/codex-and-agents-customizations/.codex/agents/pr-author-c1.toml +1 -1
  96. package/resources/codex-and-agents-customizations/.codex/agents/pr-author-c2.toml +1 -1
  97. package/resources/codex-and-agents-customizations/.codex/agents/pr-author-c3-elevated.toml +1 -1
  98. package/resources/codex-and-agents-customizations/.codex/agents/pr-author-c3.toml +1 -1
  99. package/resources/codex-and-agents-customizations/.codex/agents/pr-author-c4.toml +1 -1
  100. package/resources/codex-and-agents-customizations/.codex/agents/pr-author.toml +1 -1
  101. package/resources/codex-and-agents-customizations/.codex/agents/prd-feature-c1.toml +1 -1
  102. package/resources/codex-and-agents-customizations/.codex/agents/prd-feature-c2.toml +1 -1
  103. package/resources/codex-and-agents-customizations/.codex/agents/prd-feature-c3-elevated.toml +1 -1
  104. package/resources/codex-and-agents-customizations/.codex/agents/prd-feature-c3.toml +1 -1
  105. package/resources/codex-and-agents-customizations/.codex/agents/prd-feature-c4.toml +1 -1
  106. package/resources/codex-and-agents-customizations/.codex/agents/prd-feature.toml +1 -1
  107. package/resources/codex-and-agents-customizations/.codex/agents/python-atomic-planning.toml +1 -1
  108. package/resources/codex-and-agents-customizations/.codex/agents/python-typed-engineer-c1.toml +1 -1
  109. package/resources/codex-and-agents-customizations/.codex/agents/python-typed-engineer-c2.toml +1 -1
  110. package/resources/codex-and-agents-customizations/.codex/agents/python-typed-engineer-c3-elevated.toml +1 -1
  111. package/resources/codex-and-agents-customizations/.codex/agents/python-typed-engineer-c3.toml +1 -1
  112. package/resources/codex-and-agents-customizations/.codex/agents/python-typed-engineer-c4.toml +1 -1
  113. package/resources/codex-and-agents-customizations/.codex/agents/python-typed-engineer.toml +1 -1
  114. package/resources/codex-and-agents-customizations/.codex/agents/task-researcher-c1.toml +7 -1
  115. package/resources/codex-and-agents-customizations/.codex/agents/task-researcher-c2.toml +7 -1
  116. package/resources/codex-and-agents-customizations/.codex/agents/task-researcher-c3-elevated.toml +7 -1
  117. package/resources/codex-and-agents-customizations/.codex/agents/task-researcher-c3.toml +7 -1
  118. package/resources/codex-and-agents-customizations/.codex/agents/task-researcher-c4.toml +7 -1
  119. package/resources/codex-and-agents-customizations/.codex/agents/task-researcher.toml +7 -1
  120. package/resources/codex-and-agents-customizations/.codex/agents/typescript-engineer-c1.toml +1 -1
  121. package/resources/codex-and-agents-customizations/.codex/agents/typescript-engineer-c2.toml +1 -1
  122. package/resources/codex-and-agents-customizations/.codex/agents/typescript-engineer-c3-elevated.toml +1 -1
  123. package/resources/codex-and-agents-customizations/.codex/agents/typescript-engineer-c3.toml +1 -1
  124. package/resources/codex-and-agents-customizations/.codex/agents/typescript-engineer-c4.toml +1 -1
  125. package/resources/codex-and-agents-customizations/.codex/agents/typescript-engineer.toml +1 -1
  126. package/resources/codex-and-agents-customizations/.codex/config.toml +1 -1
  127. package/resources/codex-and-agents-customizations/.codex/hooks/enforce-epic-merge-gate-command.ps1 +190 -0
  128. package/resources/codex-and-agents-customizations/.codex/hooks/enforce-epic-merge-gate.ps1 +17 -38
  129. package/resources/codex-and-agents-customizations/.codex/hooks/hook-docs-only-diff.ps1 +5 -1
  130. package/resources/codex-and-agents-customizations/.codex/hooks/record-subagent-routing-attestation.ps1 +82 -70
  131. package/resources/codex-and-agents-customizations/.codex/prompts/feature-review-remediate.md +6 -4
  132. package/resources/codex-and-agents-customizations/.codex-variants/csharp-legacy/agents/csharp-typed-engineer.toml +1 -1
  133. package/resources/codex-and-agents-customizations/pack-manifests/core.json +2 -0
  134. package/resources/config/orchestration-routing.json +7 -7
  135. package/resources/customizations/.github/agents/atomic_executor.agent.md +21 -11
  136. package/resources/customizations/.github/agents/atomic_planning.agent.md +8 -3
  137. package/resources/customizations/.github/agents/csharp-atomic-executor.agent.md +13 -9
  138. package/resources/customizations/.github/agents/csharp-atomic-planning.agent.md +2 -2
  139. package/resources/customizations/.github/agents/csharp-orchestrator.agent.md +2 -2
  140. package/resources/customizations/.github/agents/csharp-typed-engineer.agent.md +3 -3
  141. package/resources/customizations/.github/agents/orchestrator.agent.md +8 -5
  142. package/resources/customizations/.github/agents/powershell-atomic-executor.agent.md +13 -9
  143. package/resources/customizations/.github/agents/powershell-atomic-planning.agent.md +2 -2
  144. package/resources/customizations/.github/agents/powershell-orchestrator.agent.md +2 -2
  145. package/resources/customizations/.github/agents/powershell-typed-engineer.agent.md +3 -3
  146. package/resources/customizations/.github/agents/python-atomic-executor.agent.md +13 -9
  147. package/resources/customizations/.github/agents/python-atomic-planning.agent.md +2 -2
  148. package/resources/customizations/.github/agents/python-orchestrator.agent.md +2 -2
  149. package/resources/customizations/.github/agents/task-researcher.agent.md +6 -0
  150. package/resources/customizations/.github/prompts/generate-atomic-plan.prompt.md +16 -10
  151. package/resources/customizations/.github/prompts/orchestrate-csharp-work.prompt.md +2 -2
  152. package/resources/customizations/.github/prompts/orchestrate-powershell-work.prompt.md +1 -1
  153. package/resources/customizations/.github/prompts/orchestrate-python-work.prompt.md +1 -1
  154. package/resources/customizations/.github/prompts/orchestrate-work.prompt.md +2 -2
  155. package/resources/customizations/.github/skills/atomic-plan-contract/SKILL.md +39 -4
  156. package/resources/customizations/.github/skills/csharp-change-budget-router/SKILL.md +1 -1
  157. package/resources/customizations/.github/skills/execution-environment/SKILL.md +134 -0
  158. package/resources/customizations/.github/skills/powershell-change-budget-router/SKILL.md +1 -1
  159. package/resources/customizations/.github/skills/remediation-handoff-atomic-planner/SKILL.md +7 -3
  160. package/resources/feature-templates/bug/plan.yyyy-MM-ddTHH-mm.md +10 -0
  161. package/resources/feature-templates/feature/plan.yyyy-MM-ddTHH-mm.md +11 -0
  162. package/resources/feature-templates/refactor/plan.yyyy-MM-ddTHH-mm.md +11 -0
  163. package/resources/lib/codex-routing/CodexDeployment.psm1 +10 -10
  164. package/resources/powershell/PoshQC/PoshQC.CoverageMerge.psm1 +163 -0
  165. package/resources/powershell/PoshQC/PoshQC.Shard.psm1 +296 -0
  166. package/resources/powershell/PoshQC/PoshQC.Testing.psm1 +23 -4
  167. package/resources/powershell/PoshQC/PoshQC.psd1 +7 -1
  168. package/resources/powershell/PoshQC/PoshQC.psm1 +17 -5
  169. package/resources/powershell/PoshQC/README.md +13 -1
  170. package/resources/powershell/PoshQC/settings/pester.runsettings.psd1 +3 -0
@@ -118,8 +118,10 @@ A preparation-mode `orchestrator` run:
118
118
  `feature-promotion-lifecycle`, and `atomic-plan-contract`, and the promotion plus validator
119
119
  MCP tools.
120
120
  - Runs promotion via the MCP surface, research, feature documents, atomic planning, and the
121
- atomic-executor preflight (precondition validation only, per the orchestrate skill's R2
122
- semantics), iterating plan revisions until `PREFLIGHT: ALL CLEAR`.
121
+ atomic-executor preflight (precondition validation only), under the orchestrate skill's
122
+ single-pass preflight rule in `## Delegation Model`: trivial defects are fixed in place, a
123
+ plan returns to the planner at most once, and a second substantive result halts with
124
+ `blocked_reason: "validator_failed"`.
123
125
  - Terminates with `completed_steps` containing `S3_promotion` and `S4_atomic_planning`,
124
126
  `next_step: "S5_atomic_execution"`, out-of-scope step statuses `not-applicable`, and
125
127
  `blocked_reason: "none"`. The route's `requires_ci_gate: false` means the completion validator
@@ -0,0 +1,134 @@
1
+ ---
2
+ name: execution-environment
3
+ description: 'Execution-environment brief for research, planning, preflight, execution, and orchestration. Use before planning or delegating work so tool routes, command-text restrictions, the batch budget, hook context, CI shape, contract tests, evidence rules, coverage and file-size gates, and test-isolation checks are known and are not restated in plans.'
4
+ ---
5
+
6
+ # Execution-Environment Brief
7
+
8
+ ## Purpose and Maintenance
9
+
10
+ This brief states the environment facts that every researcher, planner, preflight executor, executor, and orchestrator needs before work starts. Plans reference this brief instead of restating its content; a plan that restates a tool route, a launcher, or a command-text restriction duplicates text that goes stale when this brief changes.
11
+
12
+ Maintenance rule: this brief is updated in the same change that alters any fact it states. It carries no line numbers and no commit identifiers; it cites files, symbols, headings, job names, and test names. The same text is byte-identical in six locations: `.claude/skills/execution-environment/SKILL.md`, `.agents/skills/execution-environment/SKILL.md`, `.github/skills/execution-environment/SKILL.md`, and their bundled copies under `extensions/drm-copilot/resources/`. Where the Claude and Codex runtimes differ, both paths are named (`.claude/hooks/...` and `.codex/hooks/...`).
13
+
14
+ ## Tool Routes by Agent
15
+
16
+ - `atomic-executor` has no PowerShell tool. Its `tools:` list is Read, Grep, Glob, Edit, Write, several `Bash(...)` entries, the four `mcp__drm-copilot__run_poshqc_*` tools, and `mcp__drm-copilot__validate_orchestration_artifacts`. A `(pattern)` suffix on a `tools:` entry admits the bare tool, so the executor has Bash, subject to the repository hooks and the runtime guard described under Command-Text Restrictions.
17
+ - `atomic-planner` has no Bash. It has Read, Grep, Glob, Edit, Write, and `mcp__drm-copilot__validate_orchestration_artifacts`, so it can validate a plan with the installed validator before handoff but cannot run any toolchain command.
18
+ - `task-researcher` has Read, Grep, Glob, WebFetch, and Write. It cannot run `git show` or `gh`; facts that need either are marked for the orchestrator to confirm.
19
+ - `orchestrator` and the main session running the `orchestrate` skill have Bash, the PoshQC and validation MCP tools, and the `Agent` tool. Only they can delegate, so any step that needs a further agent run is orchestrator-owned.
20
+ - PowerShell for the executor therefore runs through the `mcp__drm-copilot__run_poshqc_*` tools or through a `sh` launcher script stored under `SCRATCH` that invokes PowerShell 7 from inside the script file.
21
+
22
+ ## Command-Text Restrictions
23
+
24
+ Two separate mechanisms restrict Bash command text. They are kept apart here because they have different causes and different fixes.
25
+
26
+ - **Worktree isolation guard (Claude Code runtime behavior, not a repository hook).** Inside an agent-isolated worktree, the Claude Code runtime refuses Bash command text it cannot show stays inside the worktree. Observed refusals include text containing `pwsh`, `bash`, or `wsl`, heredocs, `printf --`, a `cd <path> &&` prefix before `git`, `git -C <other worktree>`, embedded `jq` filter strings, an unquoted shell variable in an option position, and loops or other compound constructs around `sh`. Text that passes includes `sh <file>.sh` with a literal path, `npx`, `poetry run python <script>`, `gh`, worktree-scoped `git`, and `git commit -F <file>`. No file under `.claude/hooks/` implements this guard, and no settings file registers it.
27
+ - **Repository hooks.** `.claude/hooks/validate-bash.ps1` (`.codex/hooks/validate-bash.ps1` for Codex; functions `Get-BlockedBashPattern`, `Get-CdChainedReadCommandMatch`, `Get-BashBlockReason`) denies destructive patterns (`rm -rf`, forced pushes, `git reset --hard`, recursive forced removal) and a `cd` followed later in the same command by a file-reading command such as `grep`, `cat`, `head`, `tail`, `less`, `more`, `awk`, or `sed -n`. `.claude/hooks/enforce-parallel-worktree-removal-gate.ps1` denies the literal worktree-removal command anywhere in a command.
28
+ - A multi-line `poetry run python -c` program exits 0 without running. Put Python helpers in a file under `SCRATCH` and run the file.
29
+
30
+ ## PowerShell Route and PoshQC MCP Limits
31
+
32
+ - PoshQC MCP results carry no output. The summary string is composed from a fixed template before the child process runs (`runPoshQcWorkflow` in `extensions/drm-copilot/src/repo-automation-service.ts`), and `RepoAutomationExecutionResult` has no exit-code or output field. An `ok: true` result proves only that the tool was invoked.
33
+ - Counts, percentages, and findings therefore come from files or direct runs: pass and fail counts from `artifacts/pester/pester-junit.xml`, line coverage from `artifacts/pester/powershell-coverage.xml`, and analyzer findings from a direct `Invoke-ScriptAnalyzer` run with `scripts/powershell/PoshQC/settings/pssa.settings.psd1`.
34
+ - The MCP test tool reads the installed extension's settings. Branch-current Pester runs import `scripts/powershell/PoshQC/PoshQC.psd1` and call `Invoke-PoshQCTest` from a `sh`-launched PowerShell 7. The coverage population is derived by `Invoke-PoshQCTest` from `config/poshqc-coverage.json`; there is no hand-maintained coverage path list.
35
+ - `Invoke-Pester` without `-EnableExit` (or `Run.Exit`) exits 0 when tests fail; read the JUnit file rather than the exit code of such a run.
36
+
37
+ ## Batch Budget
38
+
39
+ - In direct mode the batch-budget hooks allow at most three distinct production files per kind in one session: the fourth distinct non-test PowerShell file is denied with `POWERSHELL_LARGE_PATH_REQUIRED` and the fourth distinct non-test Python file with `PYTHON_LARGE_PATH_REQUIRED` (`.claude/hooks/enforce-powershell-batch-budget.ps1` and `.claude/hooks/enforce-python-batch-budget.ps1`; Codex copies under `.codex/hooks/`). Test files never count.
40
+ - Exemption: the cap does not apply when `artifacts/orchestration/orchestrator-state.json` in the worktree that holds the hook script selects the `large`, `remediation`, or `preparation` route and is not terminal (`Test-BatchBudgetLargePathRoute` in `.claude/hooks/enforce-batch-budget-route.ps1`). An isolated subagent worktree has no checkpoint, because `artifacts/` is gitignored, so direct mode applies there.
41
+ - Bundle mirror copies under `extensions/drm-copilot/resources/` are production files and count against the cap.
42
+ - A scratch `.ps1` file counts when it resolves inside the worktree root. Files under `SCRATCH`, which is outside the worktree root, are discarded without consuming a slot.
43
+ - Only `Write` and `Edit` calls are seen (the hook matcher is `Write|Edit`). Files written by Bash, by a copy script, or by a generator are not seen.
44
+ - Budget state is kept per session under `.claude/state/`; there is no automatic reset.
45
+
46
+ ## Hook Execution Context
47
+
48
+ - Hooks for an isolated subagent run inside the subagent's worktree with that worktree's hook scripts, which are `main`'s copies. A hook change on a branch is not exercised by isolated subagents until it merges.
49
+ - Hook behavior on a branch is therefore proven by Pester suites, not by a live subagent run. A live check of a branch hook needs a non-isolated delegation from the item worktree.
50
+ - Enforcement hooks do not invoke Python; bash is preferred and PowerShell is acceptable (`tests/scripts/claude-runtime/enforcement-hooks-no-python-invocation.Tests.ps1`).
51
+
52
+ ## MCP Surfaces Run the Installed Extension
53
+
54
+ - Every `mcp__drm-copilot__*` tool runs the installed extension, not the branch. `validate_orchestration_artifacts` applies the installed rule set, so validator rules added on a branch apply through MCP only after the extension release that carries them is installed.
55
+ - Branch-current plan validation runs the repository's Python CLI `scripts/dev_tools/validate_orchestration_artifacts.py` with its `plan` subcommand, through Poetry in module form.
56
+ - A push-down served by the MCP tools writes the installed extension's bundled payload; a repository-side edit under `extensions/drm-copilot/resources/` changes that payload only after a rebuild and reinstall.
57
+
58
+ ## CI Shape and Required Checks
59
+
60
+ - `.github/workflows/ci.yml` triggers on `push` to `main` and `development`, on `pull_request` to `main`, `development`, and `epic/**`, on `workflow_dispatch`, and on `merge_group` (`types: [checks_requested]`, added by issue #952), with no path filters. When the merge queue on `main` is enabled, every required check is produced by a `merge_group` run of `ci.yml` as well as by the pull-request run; `.github/workflows/README.md` (`## Triggers`) records the trigger set.
61
+ - Jobs in `ci.yml` and their check names: `Change scope` (job `changes`, the change-scope decision below); `CI full run` (job `full-run-marker`, which runs only on a full run, marks that run as a valid base for later decisions, and is not a required check); `quality-checks7 / Code Quality & Tests (<python-version>)` on Python 3.10, 3.11, 3.12, and 3.13 (`_quality-checks.yml`: Black check, Ruff, Pyright, the Codex generator `--check`, the tier classification, Pytest with line and branch coverage, and the coverage-threshold check on the JSON report totals); `security-scan / Security Scanning` (its `safety check` step carries `continue-on-error: true` and does not fail the check); `docs-validation / Documentation Validation`; `build-check / Build Package`; `shell-coverage / Shell Coverage (Bats + kcov)`; `drm-copilot-extension-tests / drm-copilot Extension Tests (<os>)` on `ubuntu-latest` and `windows-latest`; `root-typescript-tests / Root TypeScript Tests (<os>)` on `ubuntu-latest` and `windows-latest`; `NPM Audit Gate / npm audit (<manifest>)` (the calling job carries the name `NPM Audit Gate`); and the `poshqc` group below.
62
+ - PowerShell CI (`_poshqc.yml`): `poshqc / PowerShell QC static` (format and analyze on `windows-latest`); the shard matrix `poshqc / PowerShell QC shard 1`, `shard 2`, and `shard 3` (`Invoke-PoshQCTest -ShardIndex -ShardCount` over the scan folders of `config/poshqc-scan.json`, with coverage, on `windows-latest`); the aggregator `poshqc / PowerShell QC`, which requires the static and shard jobs to succeed, verifies shard completeness against a Pester discovery count, and merges shard coverage; and `poshqc / PowerShell hook suites (Linux)`, which runs only `tests/scripts/claude-hooks` and `tests/scripts/codex-hooks` on `ubuntu-latest` with coverage disabled. A new test file under a scanned folder is assigned to a shard automatically and is counted by the completeness check.
63
+ - Change-scope decision (issue #962): the `Change scope` job runs `scripts/ci/Invoke-CiChangeScope.ps1` and publishes the job output `code`. The decision is `code=false` (docs-only) only on a `pull_request` event from this repository, through one of two comparisons. Green-run base: every file changed since the newest successful `ci.yml` run on the pull-request branch whose `CI full run` job succeeded, and whose head commit is present and an ancestor of the current head, is on the allowlist `config/ci-docs-only-paths.json`; the reason is `DOCS_ONLY_SINCE_<green head sha>`. Merge-base fallback (issue #973): when the green-run step ends with no earlier full green run (`NO_FULL_GREEN_RUN`), a missing base (`BASE_NOT_PRESENT`), or a non-ancestor base (`BASE_NOT_ANCESTOR`), and the pull request's base ref is exactly `main`, the script computes `git merge-base` of the payload base SHA (`BASE_SHA`, from `github.event.pull_request.base.sha`; the base ref arrives as `BASE_REF`) and the head, lists the files changed since that merge base with the same diff arguments, and decides `DOCS_ONLY_SINCE_MERGE_BASE_<merge base sha>` when every changed file is allowlisted. Both comparisons run the diff with rename detection off, so both the old and the new path of a rename are classified. A path is allowlisted when it starts with `docs/features/active/`, `docs/features/archive/`, `docs/features/completed/`, `docs/features/epics/`, `docs/features/parallel/`, `docs/features/potential/`, or `docs/research/`, does not start with `docs/features/templates/` or `docs/features/potential/template.md`, and ends in `.md`, `.txt`, `.log`, `.json`, or `.xml`; the allowlist file itself is not allowlisted. Every other case is a full run (`code=true`): `push`, `merge_group`, and `workflow_dispatch` events, a fork pull request, unreadable run or job data, no earlier full green run or a missing or non-ancestor base when the base ref is not `main`, a merge base that cannot be resolved (`MERGE_BASE_UNRESOLVED`, for example a blank base SHA or a base commit missing from the checkout), a failed ancestry check, an empty diff, any path outside the allowlist, and any error. The decision step carries `continue-on-error: true` and the callers compare the output with `!= 'false'`, so a failed or missing decision also gives a full run.
64
+ - Docs-only behavior (`code=false`): `ci.yml` passes `run-heavy: false` to `_quality-checks.yml`, `_security-scan.yml`, `_build-check.yml`, `_poshqc.yml`, `_shell-coverage.yml`, and `_drm-copilot-extension-tests.yml`. Each required job still starts under its full-run check name with every step skipped, so every required context reports `success` without running its suite. In `_poshqc.yml` the aggregator `poshqc / PowerShell QC` runs with every step gated, and `poshqc / PowerShell QC static`, the shard jobs, and `poshqc / PowerShell hook suites (Linux)` are skipped at job level. `docs-validation / Documentation Validation` runs in full. `root-typescript-tests`, `NPM Audit Gate`, and `CI full run` are skipped at job level. A `success` on a docs-only commit is therefore not evidence that the heavy suites pass for that commit; that evidence is the newest run whose `CI full run` job succeeded.
65
+ - A commit that changes any path outside the allowlist (any code, workflow, configuration, script, test, or customization file) runs the full set of jobs, and its `CI full run` job marks it as a base for later docs-only decisions. A standalone `workflow_dispatch` of a reusable workflow, or a caller that omits `run-heavy`, also runs in full. `.github/workflows/README.md` (`## Change-Scope Decision (Issue #962)`) records the reason codes and the per-context behavior table.
66
+ - Required contexts of ruleset 15241672, confirmed by the orchestrator through `gh api` on 2026-10-16: `drm-copilot-extension-tests / drm-copilot Extension Tests (ubuntu-latest)`, `drm-copilot-extension-tests / drm-copilot Extension Tests (windows-latest)`, `docs-validation / Documentation Validation`, `poshqc / PowerShell QC`, `shell-coverage / Shell Coverage (Bats + kcov)`, `security-scan / Security Scanning`, `quality-checks7 / Code Quality & Tests (3.10)`, `quality-checks7 / Code Quality & Tests (3.11)`, `quality-checks7 / Code Quality & Tests (3.12)`, `quality-checks7 / Code Quality & Tests (3.13)`, `build-check / Build Package`.
67
+ - Refresh rule: a change that renames a job, adds or removes a matrix entry, or changes the ruleset refreshes this list in the same change, and the orchestrator re-confirms the contexts with a read-only `gh api repos/drmoisan/drm-copilot/rulesets/15241672` call before relying on them.
68
+ - Skipped-check semantics: a job skipped by an `if:` condition reports success to a required check; a workflow that does not run at all reports nothing, which leaves the required check pending.
69
+ - A pull request into a branch other than `main`, `development`, or `epic/**` gets no CI run; dispatch `ci.yml` manually for it.
70
+
71
+ ## CI-Only Failure Classes
72
+
73
+ - A test that reads gitignored `artifacts/` state passes only on a worktree that holds that state; CI has none.
74
+ - A fixture rooted at a drive letter or a `C:/workspace` path fails `path.isAbsolute` and path joins on Linux.
75
+ - `_shell-coverage.yml` checks out at depth one, so `origin/main` does not exist in that job; no test may diff against it.
76
+ - The Linux hook-suite job runs `tests/scripts/claude-hooks` and `tests/scripts/codex-hooks` on a case-sensitive file system: use `Join-Path`, forward-slash relative paths, exact file-name case, and no drive letters or backslash literals.
77
+ - The `.gitattributes` rule `* text=auto eol=lf` normalizes line endings on checkout, so a CRLF fixture committed as text is not CRLF in CI.
78
+ - Shard and single-process Pester runs expose module-scope import visibility and leaked state that per-suite local runs hide.
79
+
80
+ ## Contract Tests That Pin Mirrored Files
81
+
82
+ Run these after editing any mirrored or bundled file; each is under `tests/scripts/dev_tools/` unless named otherwise.
83
+
84
+ - `test_push_down_claude_resource_contracts.py` and `test_push_down_codex_and_agents_resource_contracts.py`: every distributable `.claude`, `.agents`, and `.codex` file exists in the bundle with equal text.
85
+ - `test_push_down_claude_pack_manifest_completeness.py` and `test_push_down_codex_and_agents_pack_manifest_completeness.py`: every bundled file is listed in a pack manifest.
86
+ - The Codex generator check: `scripts/dev_tools/generate_codex_agent_variants.py` run in module form with `--check` (base agents are hand-edited; variants, bundle copies, and the Codex `core.json` are generated).
87
+ - `test_codex_agent_wrapper_contracts.py` and `test_codex_handoff_contract_parity.py`: pinned Codex agent fragments and handoff parity.
88
+ - `test_claude_rules_frontmatter.py`: rule `paths:` scopes and that every preloaded skill exists.
89
+ - `parallel_orchestrator_surface_expectations.py` (`PINNED_FROZEN_SURFACE_HASHES`): byte hashes of frozen orchestration surfaces, including `.claude/skills/epic-orchestrate/SKILL.md` and `.claude/agents/epic-orchestrator.md`.
90
+ - `test_quality_checks_workflow_contracts.py`: workflow step conditions.
91
+ - `test_push_down_issue_824_follow_ups.py`: pushed rules and skills name no consuming product.
92
+ - `test_typescript_toolchain_instruction_contracts.py`: no reference to another test framework, and every backticked npm script token in the pinned mirrors exists in the root `package.json`.
93
+ - `tests/scripts/claude-runtime/claude-architecture-doc.Tests.ps1` and `tests/scripts/claude-runtime/hook-dependency-guard-completeness.Tests.ps1`: agent tool names in the architecture document and the guarded dot-source pattern in hooks.
94
+
95
+ ## Preflight Defect Classes the Validator Cannot See
96
+
97
+ These pass every validator rule and are found only by reading the plan against the tree:
98
+
99
+ - `git grep` against a file the plan creates (untracked, so invisible to `git grep`); a search pattern beginning with `-` that is not passed through `-e`.
100
+ - A checkbox diff-pair assertion against a file the plan adds, and a CRLF fixture under the `eol=lf` attribute rule.
101
+ - A new TypeScript production file without its own `coverageThreshold` entry in `extensions/drm-copilot/jest.config.cjs`, whose threshold map has per-file entries only and no `global` key.
102
+ - A per-file coverage floor asserted for code that the tests replace with blanket mocks.
103
+ - Batch-budget exhaustion across a session, and an acceptance condition that depends on a branch hook being exercised by an isolated subagent.
104
+ - `origin/main` advancing during planning: scope diffs anchor on the merge base of `origin/main` and `HEAD`, never on `origin/main` itself.
105
+ - `Measure-Object -Line` counts non-empty lines only; physical line counts use `wc -l` or `@(Get-Content -LiteralPath <path>).Count`.
106
+ - A coverage argument written as a filesystem path measures nothing; the dotted module form is required, and branch figures come from the JSON report, not the combined terminal column.
107
+ - A task that changes the observable behavior of an existing function, script, fixture, or test stub (signature, argv, output, exit status, or written files) while the tests that assert that behavior are outside the task's file set: those tests fail once the change lands, and the plan's own acceptance cannot be met. Preflight searches the test tree for the changed symbol, the file name, and the asserted output, and confirms that the task names each matching test with its disposition (unchanged because unaffected, or updated with the reason).
108
+ - A plan that alters a fact this brief states (it adds or renames a CI job, changes a required status context, a tool route, or a batch-budget rule) with no task that updates the brief in the same change, in all six byte-identical copies: the plan then breaks the maintenance rule in `## Purpose and Maintenance`. Preflight compares each task's changes against the facts this brief states and confirms that a brief-update task exists and that the plan's `Mirror parity` Pre-Mortem bullet names it.
109
+
110
+ ## Evidence and Documentation Rules
111
+
112
+ - Evidence lives under `<FEATURE>/evidence/<kind>/` with kinds `baseline`, `regression-testing`, `qa-gates`, `other`, `issue-updates`, and `remediation-baseline` (`.claude/skills/evidence-and-timestamp-conventions/SKILL.md`; enforced by `.claude/hooks/enforce-evidence-locations.ps1`).
113
+ - Evidence filenames carry the UTC time of the write, read from the clock, in the `yyyy-MM-ddTHH-mm` shape; a consumer selects the lexicographically greatest `<name>.*.md`. Plan files are stamped by the feature-folder tooling in America/New_York.
114
+ - Every command-step artifact carries `Timestamp:`, `Command:`, `EXIT_CODE:`, and `Output Summary:`. No artifact records an absolute path, a host name, or a session scratchpad path; scratch locations are recorded as the token `SCRATCH`.
115
+ - `SCRATCH` is `<session scratchpad>/issue-<issue-num>/`, and scratch file names start with `issue-<issue-num>-`.
116
+ - `.github/workflows/_docs-validation.yml` checks only that `README.md` is present and non-empty and that `LICENSE` exists, and it warns when two instruction files are missing. There is no Markdown lint or link check in CI.
117
+
118
+ ## Coverage and File-Size Gates
119
+
120
+ - Line coverage of at least 85% and branch coverage of at least 75% apply per changed production file in Python and TypeScript. PowerShell has a line threshold of 85% and no branch gate, because Pester does not measure branch coverage. No production file may be excluded from measurement.
121
+ - Python: measure a module with `--cov=<dotted.module>`, `--cov-branch`, `--cov-report=term-missing`, and `--cov-report=json:<path>`; read branch figures from the JSON report.
122
+ - TypeScript: a new production file needs its own entry in the `coverageThreshold` map of `extensions/drm-copilot/jest.config.cjs`; Jest runs through `node run-jest.cjs` in `extensions/drm-copilot/`.
123
+ - PowerShell: per-file line coverage is read from `artifacts/pester/powershell-coverage.xml` written by the self-hosted PoshQC module.
124
+ - No production, test, or reusable script file exceeds 500 physical lines; Markdown is exempt. Files at or near the limit are not extended; new logic goes into a new module and a new test file.
125
+
126
+ ## Test Isolation Checks
127
+
128
+ - Tests create no temporary files; file and transcript reads go through injected seams with in-memory content.
129
+ - Before review, run each isolation check and record it under `<FEATURE>/evidence/regression-testing/`:
130
+ - a seeded shuffled Jest run (`node run-jest.cjs --randomize --seed=<n>` in `extensions/drm-copilot/`) with the seed recorded;
131
+ - a reversed-order run of the new or changed Python test modules in one process;
132
+ - a seeded shuffled file-order run of the touched Pester suites in one process, with at least three seeds and each seed and its file order recorded;
133
+ - a fresh single-process Pester run over `tests/scripts`, which is the CI shape.
134
+ - An order dependence found by any run is fixed on both sides: the suite that leaves state behind (globals, functions, environment variables, mocks, imported modules, script-scope state) and the suite that assumes prior state. Every seed is then re-run.
@@ -25,6 +25,7 @@ Before proceeding, the orchestrator must:
25
25
  1. Read `CLAUDE.md` for repository tone policy and architectural context.
26
26
  2. Read applicable `.claude/rules/` files for the languages in scope.
27
27
  3. Read the policy files listed in the compliance reading order section of `CLAUDE.md`.
28
+ 4. Read the `execution-environment` skill (`.claude/skills/execution-environment/SKILL.md`) before delegating any worker. Delegation prompts and plans reference that brief instead of restating tool routes, command-text restrictions, the batch budget, hook context, or CI shape.
28
29
 
29
30
  ## Checkpoint Handling
30
31
 
@@ -131,12 +132,18 @@ After reading `artifacts/orchestration/orchestrator-state.json`, the main sessio
131
132
 
132
133
  The orchestrator does not perform deep implementation itself. It coordinates, tracks state, and enforces completion.
133
134
 
135
+ Single-pass preflight for S4 planning (and for preparation mode). The directive `DIRECTIVE: PREFLIGHT VALIDATION ONLY` goes in the `atomic-executor` delegation prompt only, never in the plan file. Preflight follows `### Single-Pass Preflight` in the `atomic-plan-contract` skill: the preflight executor fixes trivial defects in place and returns only substantive defects as `PREFLIGHT-DEFECT:` lines. The at-most-one-return rule applies:
136
+
137
+ 1. Preflight round one returns `PREFLIGHT: ALL CLEAR` (in-place `PREFLIGHT-FIX:` lines permitted) or `PREFLIGHT: REVISIONS REQUIRED` with every substantive defect listed.
138
+ 2. On `PREFLIGHT: REVISIONS REQUIRED`, delegate one `atomic-planner` revision of the same plan file carrying the full `PREFLIGHT-DEFECT:` list, then run preflight round two. A plan returns to the planner at most once.
139
+ 3. If round two still returns a substantive defect, halt with `blocked_reason: "validator_failed"` and record both preflight returns in the checkpoint. Do not open a third round.
140
+
134
141
  ## Preparation Mode
135
142
 
136
143
  A delegation prompt carrying the literal marker `Preparation mode: true` (issued by `epic-planner` per the `.claude/skills/epic-plan/SKILL.md` kickoff line) scopes the run to planning only:
137
144
 
138
145
  - **Route.** Select `route_id: preparation`. The route's routing-matrix entry requires receipts for `task-researcher`, `prd-feature`, `atomic-planner`, and `atomic-executor`; the skills `orchestrate`, `feature-promotion-lifecycle`, and `atomic-plan-contract`; and the promotion plus validator MCP tools.
139
- - **Scope.** Run promotion (MCP surface), research, feature documents (`spec.md`, `user-story.md`), atomic planning, and the atomic-executor preflight (precondition validation only, R2 semantics: iterate plan revisions until `PREFLIGHT: ALL CLEAR`). Atomic execution, PR authoring, CI monitoring, and feature review are out of scope and are executed later by `epic-orchestrator`.
146
+ - **Scope.** Run promotion (MCP surface), research, feature documents (`spec.md`, `user-story.md`), atomic planning, and the atomic-executor preflight (precondition validation only, under the single-pass preflight and at-most-one-return rule stated under `## Delegation Model`). Atomic execution, PR authoring, CI monitoring, and feature review are out of scope and are executed later by `epic-orchestrator`.
140
147
  - **Terminal checkpoint.** Stop with `completed_steps` containing `S3_promotion` and `S4_atomic_planning`, `next_step: "S5_atomic_execution"`, out-of-scope step statuses set to `not-applicable`, and `blocked_reason: "none"`. Do NOT assert completion (`next_step: "complete"`, `S12_complete`, or a `completed` step8/9/10 status): the run has no PR or CI evidence, and the route's `requires_ci_gate: false` exempts it from `ci_gate` at the completion validator instead.
141
148
  - **Premise-falsified halt.** Use `blocked_reason: "premise_falsified"` when every delegation and validator succeeded but evidence gathered during execution falsified the plan's premise. Still record the evidence path in free-form checkpoint keys; `blocked_reason` carries only the classification. The preparation terminal checkpoint above still sets `blocked_reason: "none"`. The full `blocked_reason` vocabulary and its partition are in `.claude/rules/orchestrator-state.md`.
142
149
  - **Commit.** Commit the prepared feature folder and plan to the current branch (the worktree branch created off the epic integration branch) before stopping, and report the `plan-path` and preflight status in the final output.
@@ -228,10 +235,11 @@ The orchestrator must not report completion until:
228
235
 
229
236
  Before delegating to the `feature-review` subagent, the orchestrator must:
230
237
 
231
- 1. Stage all modified and new files: `git add -A`.
232
- 2. Delegate to `Agent(commit-message)` to generate a conventional commit message from the staged diff. The agent is read-only and returns message text only; it does not commit.
233
- 3. Commit using the generated message: `git commit -m "<generated message>"`. The `git add` and `git commit` actions remain on the orchestrator.
234
- 4. Only after a successful commit may the orchestrator proceed to the `feature-review` delegation.
238
+ 1. Confirm the self-review: the lexicographically greatest `self-review.*.md` under `<FEATURE>/evidence/qa-gates/` exists and records no FAIL row. If it is missing or records a FAIL row, run a proportionate correction (one planner delegation and one combined preflight-and-execute executor delegation, as under `## Remediation Loop (R1–R5)`) that fixes the failing items and rewrites the self-review, then repeat this check before the commit.
239
+ 2. Stage all modified and new files: `git add -A`.
240
+ 3. Delegate to `Agent(commit-message)` to generate a conventional commit message from the staged diff. The agent is read-only and returns message text only; it does not commit.
241
+ 4. Commit using the generated message: `git commit -m "<generated message>"`. The `git add` and `git commit` actions remain on the orchestrator.
242
+ 5. Only after a successful commit may the orchestrator proceed to the `feature-review` delegation.
235
243
 
236
244
  The review subagent compares against a base branch; uncommitted changes are invisible to the diff tool and cannot be audited.
237
245
 
@@ -259,8 +267,13 @@ A bounded loop consisting of five steps. The attempt count is `remediation_loop.
259
267
 
260
268
  Cycle accounting: a remediation attempt is complete when R3 execution finished (`execution_status: "complete"`) and the pre-R4 commit recorded a non-empty change set; only then set `candidate_applied: true` on that cycle and increment `completed_attempts`. A cycle that ends without a candidate (execution not started, execution failed, or an empty staged change set) records `candidate_applied: false` and consumes no number. It is followed by at most one re-plan under the same number when the executor output identifies an autonomous plan defect; otherwise reclassify the blocker (typically `external_dependency`) and halt. Two consecutive no-candidate cycles halt with `step6_status: "blocked_remediation_loop_limit"`. Local, CI-failure, merge-conflict, and parallel-drift cycles share the one count.
261
269
 
270
+ Remediation mode. Before R1, the orchestrator writes exactly one line into the cycle's `remediation-inputs.<timestamp>.md`: `Remediation-Mode: proportionate` or `Remediation-Mode: design`. The classification rule: a cycle is proportionate when every `autonomous` finding can be fixed without changing a spec acceptance criterion, a public interface, or the item's file inventory beyond the files already in the branch diff plus their tests and mirrors; otherwise the cycle is design. CI-failure findings are normally proportionate.
271
+
272
+ - **Proportionate cycle.** R1 is one `atomic-planner` delegation that writes a short remediation plan carrying a `## Pre-Mortem` section and a final self-review task. R2 and R3 run as one `atomic-executor` delegation: the executor runs single-pass preflight with in-place trivial fixes (`### Single-Pass Preflight` in `atomic-plan-contract`) and then executes the plan. Record `preflight: {iterations: 1, final_status: "clear"}` on the cycle before `execution_status`. If preflight finds a substantive defect, the executor stops with `BLOCKED at preflight (before [P0-T1])`, a plan delta, and no checked task; the orchestrator rewrites the mode line to `Remediation-Mode: design` and the cycle continues as a design cycle with one planner revision. The pre-R4 commit, R4, and R5 are unchanged.
273
+ - **Design cycle.** R1 to R5 run as listed below, and R2 follows the single-pass preflight and at-most-one-return rule.
274
+
262
275
  - **R1 — Remediation planning:** Delegate to `atomic-planner` with `remediation-inputs.<timestamp>.md` path as primary context. Receive `remediation-plan.<timestamp>.md` in the active feature folder.
263
- - **R2 — Preflight clearance:** Delegate to `atomic-executor` for precondition validation only (no implementation). If the executor does not return `PREFLIGHT: ALL CLEAR`, return to R1 and re-delegate to `atomic-planner` with the required-changes output from the executor. Only after `PREFLIGHT: ALL CLEAR` may the orchestrator advance to R3.
276
+ - **R2 — Preflight clearance:** Delegate to `atomic-executor` for precondition validation only (no implementation), with the preflight directive in the delegation prompt. Trivial defects are fixed in place. If the executor returns `PREFLIGHT: REVISIONS REQUIRED`, return to R1 once and re-delegate to `atomic-planner` with the full `PREFLIGHT-DEFECT:` list; if the following preflight still reports a substantive defect, record `final_status: "blocked_preflight_iteration_limit"` on the cycle and halt per `.claude/skills/remediation-handoff-atomic-planner/SKILL.md`. Only after `PREFLIGHT: ALL CLEAR` may the orchestrator advance to R3.
264
277
  - **R3 — Remediation execution:** Delegate to `atomic-executor` with full execution authorization. Each task's toolchain loop (format → lint → type-check → test) is mandatory; no skipping.
265
278
  - **Pre-R4 commit:** Stage all changes (`git add -A`), delegate to `Agent(commit-message)` to generate a commit message from the staged diff (the agent returns message text only and does not commit), then commit with the generated message. The `git commit` action remains on the orchestrator. Advance to R4 only after a successful commit.
266
279
  - **R4 — Re-audit:** Delegate to `feature-review` with the same inputs as the original review (resolved base branch, feature folder, refreshed PR context artifacts, acceptance-criteria source). No scope narrowing. The canonical issue number line must be included.
@@ -298,7 +311,7 @@ S9 procedure:
298
311
  3. Parse the JSON by running `pwsh -NoProfile -File .claude/lib/ci-gate/Invoke-CiGateParser.ps1 -ChecksJson <checks-json> -HeadSha <head-sha>`, appending `-RequireWorkflow CI` when `epic_mode` is `true`. The parser emits the `ci_gate` object defined below and derives `ci_gate.conclusion` over the queried checks (every check on the PR head SHA, for every PR): `success` when every queried check passed or was skipped, `failure` when any queried check failed or was cancelled, and `pending` when any queried check is still in progress. With `-RequireWorkflow CI`, the parser returns `pending` instead of `success` until at least one check whose `workflow` is `CI` has passed.
299
312
  4. Poll with a bounded interval and a documented total timeout while `conclusion == "pending"`. When the timeout is exhausted, record the timeout as a finding with `Remediability: awaiting_ci` in `remediation-inputs.<timestamp>.md` and follow the wait branch in Post-Review Outcome Evaluation (`blocked_reason: "awaiting_ci"`, `next_step: "S9_ci_green"`); `step9_status` stays `pending`. A poll timeout does not enter the remediation loop.
300
313
  5. Write the `ci_gate` object and `last_verified_ci_sha` to the checkpoint, and set `step9_status` to `passed` only when `ci_gate.conclusion == "success"` AND `ci_gate.head_sha` equals the current PR head SHA.
301
- 6. If the checkpoint's `epic_mode` is `true`, execute `gh pr merge --merge <PR>` merging the feature branch into `epic_context.integration_branch` (already the PR's base branch per the epic-mode `--base` override applied at S8). On success, record `epic_merge: { merge_commit_sha, target_branch, merged_at }` in the checkpoint. On failure due to merge conflict (non-mergeable PR), do not retry blindly: convert the conflict into a synthetic Blocking finding per "Merge-Conflict Remediation" below and re-enter the standard R1–R5 remediation loop; do not proceed to DONE.
314
+ 6. If the checkpoint's `epic_mode` is `true`, execute `gh pr merge --merge <PR>` merging the feature branch into `epic_context.integration_branch` (already the PR's base branch per the epic-mode `--base` override applied at S8). On success, record `epic_merge: { merge_commit_sha, target_branch, merged_at }` in the checkpoint. On failure due to merge conflict (non-mergeable PR), do not retry blindly: convert the conflict into a synthetic Blocking finding per "Merge-Conflict Remediation" below and re-enter the standard R1–R5 remediation loop; do not proceed to DONE. Merge confirmation (issue #952): a zero exit from `gh pr merge` does not prove a merge when the base branch uses a merge queue, so `epic_merge.merge_commit_sha` is recorded only after the merge is confirmed by polling and ancestry check. Read the pull-request state every 30 seconds, for at most 90 minutes, with the `gh api graphql` query and `.claude/lib/ci-gate/Invoke-MergeConfirmationParser.ps1` exactly as step 3 of `## Per-Item Merge to Main (Merge-on-Green)` in `.claude/skills/parallel-orchestrate/SKILL.md` defines them; on `merged`, run `git fetch origin <integration_branch>` and confirm that `git merge-base --is-ancestor <merge-commit-oid> origin/<integration_branch>` exits 0 before recording `epic_merge`. When the 90 minutes are exhausted, record a finding naming `awaiting_merge_queue` with `Remediability: awaiting_ci` in `remediation-inputs.<timestamp>.md` and follow the wait branch (`blocked_reason: "awaiting_ci"`, `next_step: "S9_ci_green"`). A `not_queued` outcome whose `mergeable` value is `CONFLICTING` follows "Merge-Conflict Remediation"; any other `not_queued` outcome enters `## Remediation Loop — CI-Failure Handling`; a `closed` outcome halts the run with a failure. `gh pr merge` is never re-issued in a loop after `not_queued`.
302
315
 
303
316
  CI-dependent acceptance criteria: when the item has acceptance criteria whose verification requires the result of CI on the PR head, the item's own orchestrator run owns their check-off, and a parent or coordinating session never commits them from its own root. After step 5 records `ci_gate.conclusion == "success"`, check off each CI-dependent criterion in the item's own worktree, commit, push to the PR branch, and re-run S9 from step 1 against the new head SHA, so that `ci_gate.head_sha` equals the final PR head before DONE. In epic mode this completes before step 6 merges. A failed re-run enters `## Remediation Loop — CI-Failure Handling` below; the shared `remediation_loop.completed_attempts` count and its halt after three completed attempts are unchanged.
304
317
 
@@ -348,7 +361,7 @@ When S9 records `step9_status: "failed_remediation_required"` (a failed check; a
348
361
 
349
362
  1. The failed-check log from `gh run view <run-id> --log-failed` is written as `remediation-inputs.<timestamp>.md` in the active feature folder.
350
363
  2. The failure is converted to a synthetic finding with severity `Blocking` that identifies the failing check by name and the failing job by URL.
351
- 3. The existing R1-R5 remediation loop processes that finding exactly as it processes a local blocking finding. No new loop is introduced.
364
+ 3. The existing R1-R5 remediation loop processes that finding exactly as it processes a local blocking finding. No new loop is introduced. The inputs file carries `Remediation-Mode: proportionate` unless the fix requires changing a spec acceptance criterion, a public interface, or the file inventory beyond the branch diff plus tests and mirrors, in which case it carries `Remediation-Mode: design`.
352
365
  4. CI-failure cycles share `remediation_loop.completed_attempts` with local-finding cycles; a CI-failure finding stays `autonomous`, and the active cycle number is `completed_attempts + 1`.
353
366
  5. The shared guard applies: after three completed attempts without a passing result, the orchestrator records `step9_status: "blocked_ci_loop_limit"`, does not write DONE, and halts. No further automation is attempted.
354
367
 
@@ -363,7 +376,7 @@ The orchestrator must not create a PR, push a branch for PR purposes, or report
363
376
  4. The checkpoint `next_step` is `S8_create_pr` (precondition to entering S9).
364
377
  5. PR body produced via the pr-author handoff: `artifacts/pr_body_<N>.md` exists with a matching `artifacts/pr_body_<N>.receipt.json`, created with `--body-file`.
365
378
  6. `ci_gate.conclusion == "success"` AND `ci_gate.head_sha == current head SHA of the PR branch`. DONE is not written while either sub-condition is false.
366
- 7. `epic_mode` is `false`, OR (`epic_mode` is `true` AND the integration-branch merge (`gh pr merge --merge`) has completed and `epic_merge.merge_commit_sha` is recorded in the checkpoint).
379
+ 7. `epic_mode` is `false`, OR (`epic_mode` is `true` AND the integration-branch merge (`gh pr merge --merge`) has completed and `epic_merge.merge_commit_sha` is recorded in the checkpoint). `epic_merge.merge_commit_sha` is recorded only after the merge is confirmed by polling and ancestry check (S9 step 6).
367
380
 
368
381
  This gate is non-negotiable. Each condition is independently verified before PR creation proceeds. Conditions 1-4 are unchanged from the prior contract; conditions 5-7 (receipt handoff, CI-green gate, and epic-mode merge-on-green gate) are additive.
369
382
 
@@ -389,12 +389,32 @@ Procedure, per item:
389
389
  `merge_status: ci_green` and do not run `gh pr merge`; the item waits until its child pushes
390
390
  the check-off and re-runs S9, and the parent does not commit the check-off itself.
391
391
  3. Execute `gh pr merge --merge <PR>` for that item's pull request, whose base is `main`.
392
- 4. On success, record `merge_commit_sha`, `merged_at`, and `merge_status: merged`, then regenerate
392
+ Do not pass `--delete-branch` or `--auto`. A zero exit status does not prove a merge: when
393
+ `main` uses a merge queue, `gh pr merge` exits 0 after it enqueues the pull request or enables
394
+ auto-merge (issue #952). Confirm the merge before step 4. Every 30 seconds, for at most 90
395
+ minutes, read the pull-request state with
396
+ `gh api graphql -f query='query($owner:String!,$name:String!,$number:Int!){repository(owner:$owner,name:$name){pullRequest(number:$number){state mergedAt isInMergeQueue mergeCommit{oid} autoMergeRequest{enabledAt}}}}' -F owner='{owner}' -F name='{repo}' -F number=<PR> --jq .data.repository.pullRequest`
397
+ and classify it with
398
+ `pwsh -NoProfile -File .claude/lib/ci-gate/Invoke-MergeConfirmationParser.ps1 -PrJson <snapshot-json> -AsJson`.
399
+ On `pending`, read again. When the 90 minutes are exhausted, report the item as
400
+ `awaiting_merge_queue`, leave its `merge_status` at `ci_green`, and do not record `merged`.
401
+ On `merged`, run `git fetch origin main` and
402
+ `git merge-base --is-ancestor <merge-commit-oid> origin/main`; the merge is confirmed only
403
+ when that command exits 0. On `not_queued`, read `gh pr view <PR> --json mergeable`: a
404
+ `CONFLICTING` value enters `## Per-Item Merge-Conflict Handling`, and any other value is a
405
+ merge-group CI failure that re-delegates the item's child to merge `origin/main` and re-run
406
+ S9 as one CI-failure remediation cycle, consuming a remediation attempt. On `closed`, stop
407
+ and report a failure for the item. Never re-issue `gh pr merge` in a loop after a
408
+ `not_queued` outcome.
409
+ 4. Record `merge_commit_sha`, `merged_at`, and `merge_status: merged` only after the merge is
410
+ confirmed by polling and ancestry check, then regenerate
393
411
  `docs/features/parallel/<slug>/parallel-status.md`.
394
412
  5. On a merge failure caused by a conflict, follow `## Per-Item Merge-Conflict Handling`.
395
413
 
396
414
  **Merge-gate authorization.** `.claude/hooks/enforce-epic-merge-gate.ps1` is a project-wide
397
- `PreToolUse` Bash-matcher hook that denies any `gh pr merge --merge` unless a checkpoint satisfies
415
+ `PreToolUse` Bash-matcher hook that denies every merge or merge-queue enqueue action (any
416
+ `gh pr merge` spelling except a pure `--disable-auto`, and every `gh api` merge or enqueue
417
+ mutation; issue #952) unless a checkpoint satisfies
398
418
  one of its allow conditions; its block reason is `EPIC_MERGE_GATE_BLOCKED`. The gate has
399
419
  four allow conditions
400
420
  which it evaluates in this order: a per-feature checkpoint with `epic_mode == true` and
@@ -436,7 +456,9 @@ security control; see the Standalone-Merge-Authorization section of
436
456
  Branch protection on `main` affects only the pacing of step 3, not its ownership: if `main`
437
457
  requires branches to be up to date, an automated `gh pr update-branch` plus re-green cycle is
438
458
  inserted between same-cohort merges, which serializes those merges in practice while remaining
439
- unattended.
459
+ unattended. When `main` uses a merge queue, the queue replaces that `gh pr update-branch` cycle:
460
+ step 3 enqueues each green pull request, the queue validates it against the latest `main`
461
+ together with the entries ahead of it, and step 3's confirmation polling waits for the merge.
440
462
 
441
463
  ## Per-Item Merge-Conflict Handling
442
464
 
@@ -447,7 +469,8 @@ this surface.
447
469
  Project-file conflicts are resolved by the parent first (issue #643); the numbered steps below are
448
470
  the escalation path.
449
471
 
450
- - (a) On a conflicted `gh pr merge --merge`, the parent runs the two commands
472
+ - (a) On a conflicted `gh pr merge --merge`, or a `not_queued` merge confirmation whose
473
+ `mergeable` value is `CONFLICTING`, the parent runs the two commands
451
474
  `git -C <worktree_path> fetch origin main` and
452
475
  `git -C <worktree_path> merge --no-commit origin/main`.
453
476
  - (b) The parent then runs
@@ -467,7 +490,8 @@ the escalation path.
467
490
  item, sets `merge_status: pr_open`, regenerates `parallel-status.md`, and re-enters
468
491
  `## Per-Item Merge to Main (Merge-on-Green)` at the durable `gh pr checks` confirmation step.
469
492
 
470
- 1. On a conflicted `gh pr merge --merge`, the parent detects the failure and re-delegates that item's
493
+ 1. On a conflicted `gh pr merge --merge`, or a `not_queued` merge confirmation whose `mergeable`
494
+ value is `CONFLICTING`, the parent detects the failure and re-delegates that item's
471
495
  child orchestration, passing the conflict signal and the instruction to resolve against
472
496
  `origin/main`. The conflict capture and the finding write both belong to the child's
473
497
  `atomic-executor`, which works inside the item's own worktree, the only working tree holding the
@@ -28,7 +28,7 @@ When routed through `/orchestrate`, small path still requires lifecycle scaffold
28
28
  - promote potential item to GitHub issue with `--work-mode minor-audit`,
29
29
  - create active feature folder with `--work-mode minor-audit`,
30
30
  - delegate minimal-audit plan creation to `atomic_planner` with `DIRECTIVE: MINIMAL-AUDIT PLAN REQUIRED`,
31
- - require `atomic_executor` preflight until `PREFLIGHT: ALL CLEAR`,
31
+ - require single-pass `atomic_executor` preflight ending in `PREFLIGHT: ALL CLEAR` (at most one return to the planner),
32
32
  - execute Phase 0 only via `atomic_executor` before branching,
33
33
  - run reduced small-audit after implementation and QC.
34
34
 
@@ -40,7 +40,7 @@ When routed through `/orchestrate`, the small path still requires lifecycle scaf
40
40
  - promote the potential item to a GitHub issue with `--work-mode minor-audit`,
41
41
  - create the active feature folder with `--work-mode minor-audit`,
42
42
  - delegate minimal-audit plan creation to `atomic_planner` with `DIRECTIVE: MINIMAL-AUDIT PLAN REQUIRED`,
43
- - require `atomic_executor` preflight until `PREFLIGHT: ALL CLEAR`,
43
+ - require single-pass `atomic_executor` preflight ending in `PREFLIGHT: ALL CLEAR` (at most one return to the planner),
44
44
  - execute Phase 0 only via `atomic_executor` before branching,
45
45
  - run the reduced small-audit after implementation and QC.
46
46
 
@@ -5,7 +5,7 @@ description: 'Remediation handoff chain from orchestrator through atomic-planner
5
5
 
6
6
  # Remediation Handoff to atomic-planner
7
7
 
8
- Strict handoff chain for orchestrator-initiated remediation cycles. The chain enforces that an `atomic-planner`-authored plan is preflighted by `atomic-executor`, revised through a preflight sub-loop if needed, executed by `atomic-executor` task-by-task, and reaudited by `feature-review`. Workers are never invoked directly by the orchestrator.
8
+ Strict handoff chain for orchestrator-initiated remediation cycles. The chain enforces that an `atomic-planner`-authored plan is preflighted by `atomic-executor`, revised at most once through the preflight sub-loop if needed, executed by `atomic-executor` task-by-task, and reaudited by `feature-review`. Workers are never invoked directly by the orchestrator.
9
9
 
10
10
  ## When to Use This Skill
11
11
 
@@ -30,7 +30,7 @@ orchestrator
30
30
  PREFLIGHT: ALL CLEAR -> proceed to execution
31
31
  PREFLIGHT: REVISIONS REQUIRED -> route back to atomic-planner
32
32
  with a precise plan delta; planner revises in place and
33
- orchestrator re-runs preflight (sub-loop until clear)
33
+ orchestrator re-runs preflight once (at most one return)
34
34
  -> atomic-executor executes the cleared plan task-by-task
35
35
  (workers are invoked by atomic-executor only)
36
36
  -> orchestrator delegates to feature-review
@@ -63,6 +63,11 @@ The orchestrator authors `remediation/<entry-ts>/remediation-inputs.md` with:
63
63
  - Enumerated fix list with file paths, expected behavior, and verification commands.
64
64
  - A "do not do" list (no scope creep, no policy weakening, no silent skips).
65
65
  - A pointer to the audit artifacts that produced the findings.
66
+ - Exactly one mode line, `Remediation-Mode: proportionate` or `Remediation-Mode: design`. The cycle is proportionate when every `autonomous` finding can be fixed without changing a spec acceptance criterion, a public interface, or the item's file inventory beyond the files already in the branch diff plus their tests and mirrors; otherwise it is design. CI-failure findings are normally proportionate.
67
+
68
+ Proportionate cycle. One `atomic-planner` delegation writes a short plan; one `atomic-executor` delegation then runs single-pass preflight with in-place trivial fixes and executes the plan in the same run. The orchestrator records `preflight: {iterations: 1, final_status: "clear"}` on the cycle before `execution_status`. When that preflight finds a substantive defect, the executor stops with `BLOCKED at preflight (before [P0-T1])`, a plan delta, and no checked task, and the orchestrator converts the cycle to design mode by rewriting the mode line to `Remediation-Mode: design` before one planner revision.
69
+
70
+ Design cycle. The full chain above runs with the preflight sub-loop below, bounded by the at-most-one-return rule.
66
71
 
67
72
  ## Required Artifacts
68
73
 
@@ -96,25 +101,28 @@ A comprehensive or final sweep in a remediation cycle covers that cycle's own pl
96
101
  - Phase 0 captures policy reads and baseline toolchain results per `policy-compliance-order` and `evidence-and-timestamp-conventions`.
97
102
  - Final phase runs the full toolchain QA loop in the order specified by `atomic-plan-contract` and records numeric coverage values where the repository policy requires coverage.
98
103
  - Evidence paths resolve to `<FEATURE>/evidence/<kind>/` per the non-overridable evidence path clause.
104
+ - The plan is design-level per `## Design-Level Plan Contract (Mandatory)` in `atomic-plan-contract`, carries a `## Pre-Mortem` section, and ends with the final-phase self-review task. A proportionate plan covers only the listed findings and stays short.
99
105
 
100
106
  The plan must pass the `mcp__drm-copilot__validate_orchestration_artifacts` MCP tool with `artifact_type: "plan"` and `artifact_path: <plan-path>` before `atomic-executor` runs preflight against it.
101
107
 
102
108
  ## Preflight Sub-Loop
103
109
 
104
- After the plan is authored, `atomic-executor` runs preflight under the directive `DIRECTIVE: PREFLIGHT VALIDATION ONLY`. The exact signal returned is either:
110
+ After the plan is authored, `atomic-executor` runs preflight under the directive `DIRECTIVE: PREFLIGHT VALIDATION ONLY`, which the orchestrator places in the delegation prompt and never in the plan file. Preflight is single-pass: trivial defects are fixed in place and recorded as `PREFLIGHT-FIX:` lines with a `preflight-fix-record:` path. The exact signal returned is either:
105
111
 
106
112
  - `PREFLIGHT: ALL CLEAR` — the plan proceeds to execution.
107
- - `PREFLIGHT: REVISIONS REQUIRED` — `atomic-executor` returns a precise plan delta. The orchestrator routes the delta to `atomic-planner` for revision. `atomic-planner` updates the same plan file in place (per the plan-path continuity contract in `atomic-plan-contract`). The orchestrator then re-runs preflight. The sub-loop repeats until `PREFLIGHT: ALL CLEAR` is returned.
113
+ - `PREFLIGHT: REVISIONS REQUIRED` — `atomic-executor` returns a precise plan delta with one `PREFLIGHT-DEFECT:` line per substantive defect. The orchestrator routes the full defect list to `atomic-planner` for one revision. `atomic-planner` updates the same plan file in place (per the plan-path continuity contract in `atomic-plan-contract`). The orchestrator then re-runs preflight once.
114
+
115
+ At most one return. The sub-loop returns to `atomic-planner` at most once per cycle: when the second preflight still reports a substantive defect, the iteration ceiling below applies.
108
116
 
109
117
  The orchestrator records the preflight outcome in `remediation_loop.cycles[current_cycle].preflight` with `iterations` (counter) and `final_status` (`clear|changes_requested|pending`).
110
118
 
111
119
  For a well-scoped item where `preflight.iterations > 1`, record a process-defect investigation that identifies the incomplete planner internal-review dimension. Treat excess rounds as a process signal, not routine iteration.
112
120
 
113
- The exhaustive-pass, defect-enumeration, and delta-self-check rules that govern how `atomic-executor` conducts preflight are defined in the `## Preflight Validation (Planner ↔ Executor)` section of `.claude/skills/atomic-plan-contract/SKILL.md` and are not restated here.
121
+ The exhaustive-pass, defect-classification, in-place-fix, and fix-self-check rules that govern how `atomic-executor` conducts preflight are defined in the `## Preflight Validation (Planner ↔ Executor)` section of `.claude/skills/atomic-plan-contract/SKILL.md` and are not restated here.
114
122
 
115
123
  Alongside `iterations` and `final_status`, the orchestrator also records in `remediation_loop.cycles[current_cycle].preflight` the convergence line `atomic-executor` returned on that round, which is one of `CONVERGENCE: NO FURTHER ROUNDS EXPECTED` or `CONVERGENCE: FURTHER ROUNDS LIKELY`. This convergence field extends the field set already recorded at `remediation_loop.cycles[current_cycle].preflight` rather than replacing it: `iterations` and `final_status` continue to be recorded exactly as stated above, and the convergence field is written in addition to them.
116
124
 
117
- Iteration ceiling. When a cycle's `iterations` would exceed 2, the orchestrator records `final_status: "blocked_preflight_iteration_limit"`, halts the preflight sub-loop, and escalates to the caller, rather than continuing the sub-loop indefinitely. `blocked_preflight_iteration_limit` is a fourth `final_status` value extending the `clear|changes_requested|pending` enumeration stated above. This ceiling bounds the repeat-until-clear behavior stated above it: the sub-loop still repeats until `PREFLIGHT: ALL CLEAR` is returned, and the ceiling supplies the terminating condition for the case where that signal is not reached within two iterations.
125
+ Iteration ceiling. When a cycle's `iterations` would exceed 2, the orchestrator records `final_status: "blocked_preflight_iteration_limit"`, halts the preflight sub-loop, and escalates to the caller. `blocked_preflight_iteration_limit` is a fourth `final_status` value extending the `clear|changes_requested|pending` enumeration stated above. Under the at-most-one-return rule the ceiling is reached after one planner revision: the first preflight and the confirming preflight are the two permitted iterations.
118
126
 
119
127
  ## Execution and Reaudit
120
128
 
@@ -63,6 +63,12 @@ Create or update a single research file at one of the two tracked research roots
63
63
  - Propose a test strategy consistent with repository policy (unit tests for pure logic, integration seams).
64
64
  - Do not write test code; describe the strategy only.
65
65
 
66
+ ### 6. Pre-Mortem
67
+
68
+ - Feature-associated research (a research path under `docs/features/`) MUST carry a `## Pre-Mortem` section with one bullet beginning with each of the seven labels `Review checklists`, `Coverage`, `Mirror parity`, `File size`, `Test isolation`, `CI-only behavior`, and `Evidence`. Each bullet states how the next review or CI run could fail on that dimension and the mitigation the plan must carry; a label that does not apply is written as "not applicable" followed by the reason.
69
+ - One-off research under `docs/research/` is exempt.
70
+ - The researcher SubagentStop hook blocks feature research without a complete section. The `execution-environment` skill states the CI shape, contract tests, and isolation checks the section accounts for.
71
+
66
72
  ## Constraints
67
73
 
68
74
  - Research only. Do not implement changes.
@@ -289,28 +289,28 @@
289
289
  "complexity_to_profile": {
290
290
  "C1": {
291
291
  "suffix": "c1",
292
- "model": "gpt-5.6-luna",
292
+ "model": "gpt-6-luna",
293
293
  "model_reasoning_effort": "low"
294
294
  },
295
295
  "C2": {
296
296
  "suffix": "c2",
297
- "model": "gpt-5.6-terra",
297
+ "model": "gpt-6.1-sol",
298
298
  "model_reasoning_effort": "medium"
299
299
  },
300
300
  "C3": {
301
301
  "suffix": "c3",
302
- "model": "gpt-5.6-terra",
302
+ "model": "gpt-6.1-sol",
303
303
  "model_reasoning_effort": "high"
304
304
  },
305
305
  "C4": {
306
306
  "suffix": "c4",
307
- "model": "gpt-5.6-sol",
307
+ "model": "gpt-6-astra",
308
308
  "model_reasoning_effort": "max"
309
309
  }
310
310
  },
311
311
  "c3_elevated_profile": {
312
312
  "suffix": "c3-elevated",
313
- "model": "gpt-5.6-sol",
313
+ "model": "gpt-6-astra",
314
314
  "model_reasoning_effort": "high",
315
315
  "activation": {
316
316
  "operator": "any",
@@ -329,12 +329,12 @@
329
329
  "forced_personas": {
330
330
  "epic-planner": {
331
331
  "suffix": "",
332
- "model": "gpt-5.6-sol",
332
+ "model": "gpt-6-astra",
333
333
  "model_reasoning_effort": "ultra"
334
334
  },
335
335
  "epic-orchestrator": {
336
336
  "suffix": "",
337
- "model": "gpt-5.6-sol",
337
+ "model": "gpt-6-astra",
338
338
  "model_reasoning_effort": "ultra"
339
339
  }
340
340
  },
@@ -30,6 +30,7 @@
30
30
  ".claude/hooks/enforce-epic-merge-gate.ps1",
31
31
  ".claude/hooks/enforce-epic-merge-gate-authorization.ps1",
32
32
  ".claude/hooks/enforce-epic-merge-gate-resolution.ps1",
33
+ ".claude/hooks/enforce-epic-merge-gate-command.ps1",
33
34
  ".claude/hooks/enforce-epic-wave-barrier.ps1",
34
35
  ".claude/hooks/enforce-epic-worktree-removal-gate.ps1",
35
36
  ".claude/hooks/enforce-epic-worktree-removal-gate-resolution.ps1",
@@ -67,6 +68,7 @@
67
68
  ".claude/hooks/hook-dependency-guard.ps1",
68
69
  ".claude/hooks/hook-docs-only-diff.ps1",
69
70
  ".claude/hooks/persist-session-id.ps1",
71
+ ".claude/hooks/premortem-section.ps1",
70
72
  ".claude/hooks/subagentstop-envelope.ps1",
71
73
  ".claude/hooks/validate-bash.ps1",
72
74
  ".claude/hooks/validate-discovery-artifact-gate.ps1",
@@ -117,6 +119,7 @@
117
119
  ".claude/skills/epic-run/SKILL.md",
118
120
  ".claude/skills/evidence-and-timestamp-conventions/SKILL.md",
119
121
  ".claude/skills/execute-hard-lock/SKILL.md",
122
+ ".claude/skills/execution-environment/SKILL.md",
120
123
  ".claude/skills/feature-promotion-lifecycle/SKILL.md",
121
124
  ".claude/skills/feature-review-workflow/SKILL.md",
122
125
  ".claude/skills/fill-feature-docs/SKILL.md",
@@ -181,6 +184,7 @@
181
184
  ".claude/lib/project-file-merge/ProjectFileMerge.psm1",
182
185
  ".claude/lib/project-file-merge/Resolve-MergeableConflict.ps1",
183
186
  ".claude/lib/ci-gate/Invoke-CiGateParser.ps1",
187
+ ".claude/lib/ci-gate/Invoke-MergeConfirmationParser.ps1",
184
188
  ".claude/lib/parallel-drift/ParallelDriftHalt.psm1",
185
189
  ".claude/lib/parallel-drift/ParallelDrift.psm1",
186
190
  ".claude/lib/parallel-drift/Invoke-ParallelDriftDetection.ps1",
@@ -9,6 +9,7 @@ Repository-local Codex skills live under `.agents/skills/<skill-name>/SKILL.md`.
9
9
  - `atomic-plan-contract`
10
10
  - `acceptance-criteria-tracking`
11
11
  - `evidence-and-timestamp-conventions`
12
+ - `execution-environment`
12
13
  - `skill-canonical-location-audit`
13
14
 
14
15
  - Integration
@@ -13,6 +13,7 @@ Always apply:
13
13
  - `policy-compliance-order`
14
14
  - `atomic-plan-contract`
15
15
  - `acceptance-criteria-tracking`
16
+ - `execution-environment`
16
17
 
17
18
  ## Role
18
19
 
@@ -33,17 +34,17 @@ Blocking is allowed only during preflight.
33
34
 
34
35
  ### Validation-Only Mode Contract
35
36
 
36
- If the incoming handoff includes the exact directive `DIRECTIVE: PREFLIGHT VALIDATION ONLY`:
37
+ If the incoming handoff includes the exact directive `DIRECTIVE: PREFLIGHT VALIDATION ONLY` (the directive belongs in the delegation prompt, never in a plan file):
37
38
 
38
- 1. Perform preflight validation only.
39
+ 1. Perform preflight validation only, in one pass over the entire plan, under `### Single-Pass Preflight` in `atomic-plan-contract`.
39
40
  2. Do not execute tasks, establish execution state, or run implementation commands.
40
- 3. Return exactly one of:
41
+ 3. Fix trivial defects in place in task text only (never add, remove, or reorder tasks), record each fix in `<FEATURE>/evidence/other/preflight-fixes.<timestamp>.md`, and report it as a `PREFLIGHT-FIX:` line with a `preflight-fix-record:` path.
42
+ 4. Return exactly one of:
41
43
  - `PREFLIGHT: ALL CLEAR`
42
44
  - `PREFLIGHT: REVISIONS REQUIRED`
43
- 4. If revisions are required, include a precise plan delta that `atomic-planner` can apply to the same plan file.
44
- 5. If revisions are required, automatically hand off back to `atomic-planner` and request that it apply the delta to the same plan file and resubmit that file for validation-only again.
45
- 6. Continue the validate -> delta -> planner-revise -> validate loop until preflight can return `PREFLIGHT: ALL CLEAR`.
46
- 7. If the planner-return handoff cannot be started or completed, stop and report blocked state; do not convert the failure into `PREFLIGHT: ALL CLEAR`.
45
+ 5. If revisions are required, include a precise plan delta that `atomic-planner` can apply to the same plan file, with one `PREFLIGHT-DEFECT:` line per substantive defect and every substantive defect listed.
46
+ 6. Return the result to the caller. A plan returns to the planner at most once; the orchestrator routes the defect list for one revision and runs one confirming preflight.
47
+ 7. If the required handoff cannot be started or completed, stop and report blocked state; do not convert the failure into `PREFLIGHT: ALL CLEAR`.
47
48
 
48
49
  ## Execution Rules
49
50