@arbiterforge/ca-pi 0.6.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 (206) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +558 -0
  3. package/package.json +35 -0
  4. package/plugins/ca-pi/CHANGELOG.md +1030 -0
  5. package/plugins/ca-pi/COMMANDS.md +90 -0
  6. package/plugins/ca-pi/ORCHESTRATOR.md +159 -0
  7. package/plugins/ca-pi/SKILLS.md +47 -0
  8. package/plugins/ca-pi/SPRINT.md +142 -0
  9. package/plugins/ca-pi/agents/INDEX.md +31 -0
  10. package/plugins/ca-pi/agents/architecture-drift-reviewer.md +86 -0
  11. package/plugins/ca-pi/agents/auth-crypto-reviewer.md +60 -0
  12. package/plugins/ca-pi/agents/backend-author.md +60 -0
  13. package/plugins/ca-pi/agents/checkpoint-aggregator.md +111 -0
  14. package/plugins/ca-pi/agents/coverage-auditor.md +71 -0
  15. package/plugins/ca-pi/agents/decision-challenger.md +116 -0
  16. package/plugins/ca-pi/agents/dependency-reviewer.md +79 -0
  17. package/plugins/ca-pi/agents/design-quality-reviewer.md +80 -0
  18. package/plugins/ca-pi/agents/finding-triage.md +86 -0
  19. package/plugins/ca-pi/agents/frontend-author.md +64 -0
  20. package/plugins/ca-pi/agents/grader.md +173 -0
  21. package/plugins/ca-pi/agents/infra-author.md +64 -0
  22. package/plugins/ca-pi/agents/map-deps.md +35 -0
  23. package/plugins/ca-pi/agents/map-structure.md +37 -0
  24. package/plugins/ca-pi/agents/migration-reviewer.md +65 -0
  25. package/plugins/ca-pi/agents/scout.md +127 -0
  26. package/plugins/ca-pi/agents/security-reviewer.md +72 -0
  27. package/plugins/ca-pi/agents/tribunal-lens-reviewer.md +65 -0
  28. package/plugins/ca-pi/extensions/codearbiter-child.js +1885 -0
  29. package/plugins/ca-pi/extensions/codearbiter.js +9802 -0
  30. package/plugins/ca-pi/generated/command-catalog.json +197 -0
  31. package/plugins/ca-pi/generated/roles.json +213 -0
  32. package/plugins/ca-pi/helpers/windows-supervisor.js +205 -0
  33. package/plugins/ca-pi/hooks/_activationlib.py +196 -0
  34. package/plugins/ca-pi/hooks/_arbiterstatelib.py +208 -0
  35. package/plugins/ca-pi/hooks/_babysitlib.py +76 -0
  36. package/plugins/ca-pi/hooks/_bashguardlib.py +1667 -0
  37. package/plugins/ca-pi/hooks/_boxlib.py +131 -0
  38. package/plugins/ca-pi/hooks/_colorlib.py +304 -0
  39. package/plugins/ca-pi/hooks/_durabilitylib.py +186 -0
  40. package/plugins/ca-pi/hooks/_entrylib.py +41 -0
  41. package/plugins/ca-pi/hooks/_fmtlib.py +161 -0
  42. package/plugins/ca-pi/hooks/_gitexec.py +45 -0
  43. package/plugins/ca-pi/hooks/_githooks.py +920 -0
  44. package/plugins/ca-pi/hooks/_gitlib.py +110 -0
  45. package/plugins/ca-pi/hooks/_hooklib.py +595 -0
  46. package/plugins/ca-pi/hooks/_host.py +115 -0
  47. package/plugins/ca-pi/hooks/_intentlib.py +242 -0
  48. package/plugins/ca-pi/hooks/_ledgerlib.py +1035 -0
  49. package/plugins/ca-pi/hooks/_metricslib.py +709 -0
  50. package/plugins/ca-pi/hooks/_pathnorm.py +74 -0
  51. package/plugins/ca-pi/hooks/_planfilelib.py +664 -0
  52. package/plugins/ca-pi/hooks/_previewlib.py +193 -0
  53. package/plugins/ca-pi/hooks/_protectedlib.py +312 -0
  54. package/plugins/ca-pi/hooks/_protectedstatelib.py +411 -0
  55. package/plugins/ca-pi/hooks/_provenancelib.py +971 -0
  56. package/plugins/ca-pi/hooks/_prunelib.py +1398 -0
  57. package/plugins/ca-pi/hooks/_prunepolicy.py +235 -0
  58. package/plugins/ca-pi/hooks/_readinjectlib.py +1080 -0
  59. package/plugins/ca-pi/hooks/_releaselib.py +2657 -0
  60. package/plugins/ca-pi/hooks/_scopelib.py +262 -0
  61. package/plugins/ca-pi/hooks/_segmentslib.py +278 -0
  62. package/plugins/ca-pi/hooks/_sensitivelib.py +270 -0
  63. package/plugins/ca-pi/hooks/_sessionlib.py +78 -0
  64. package/plugins/ca-pi/hooks/_sloplib.py +244 -0
  65. package/plugins/ca-pi/hooks/_standuplib.py +214 -0
  66. package/plugins/ca-pi/hooks/_subagentslib.py +219 -0
  67. package/plugins/ca-pi/hooks/_taskboardlib.py +1088 -0
  68. package/plugins/ca-pi/hooks/_updatelib.py +278 -0
  69. package/plugins/ca-pi/hooks/babysit.py +47 -0
  70. package/plugins/ca-pi/hooks/boardsync.py +129 -0
  71. package/plugins/ca-pi/hooks/doctor.py +420 -0
  72. package/plugins/ca-pi/hooks/git-enforce.py +325 -0
  73. package/plugins/ca-pi/hooks/hostapi.py +460 -0
  74. package/plugins/ca-pi/hooks/init-codearbiter.py +225 -0
  75. package/plugins/ca-pi/hooks/metrics.py +62 -0
  76. package/plugins/ca-pi/hooks/migration-pass.py +129 -0
  77. package/plugins/ca-pi/hooks/pi-bridge.py +543 -0
  78. package/plugins/ca-pi/hooks/post-write-edit.py +231 -0
  79. package/plugins/ca-pi/hooks/pre-bash.py +90 -0
  80. package/plugins/ca-pi/hooks/pre-edit.py +284 -0
  81. package/plugins/ca-pi/hooks/pre-read.py +81 -0
  82. package/plugins/ca-pi/hooks/pre-write.py +217 -0
  83. package/plugins/ca-pi/hooks/preview.py +69 -0
  84. package/plugins/ca-pi/hooks/prune-transcript.py +232 -0
  85. package/plugins/ca-pi/hooks/releasehash.py +216 -0
  86. package/plugins/ca-pi/hooks/security-pass.py +139 -0
  87. package/plugins/ca-pi/hooks/session-start.py +1218 -0
  88. package/plugins/ca-pi/hooks/statusline.py +736 -0
  89. package/plugins/ca-pi/hooks/taskwrite.py +351 -0
  90. package/plugins/ca-pi/hooks/update-refresh.py +51 -0
  91. package/plugins/ca-pi/hooks/wire-statusline.py +435 -0
  92. package/plugins/ca-pi/includes/anti-slop-design/INDEX.md +55 -0
  93. package/plugins/ca-pi/includes/anti-slop-design/color.md +43 -0
  94. package/plugins/ca-pi/includes/anti-slop-design/core.md +244 -0
  95. package/plugins/ca-pi/includes/anti-slop-design/images.md +32 -0
  96. package/plugins/ca-pi/includes/anti-slop-design/layout.md +45 -0
  97. package/plugins/ca-pi/includes/anti-slop-design/medium-cli.md +39 -0
  98. package/plugins/ca-pi/includes/anti-slop-design/medium-dataviz.md +43 -0
  99. package/plugins/ca-pi/includes/anti-slop-design/medium-diagram.md +35 -0
  100. package/plugins/ca-pi/includes/anti-slop-design/medium-documents.md +70 -0
  101. package/plugins/ca-pi/includes/anti-slop-design/medium-slides.md +30 -0
  102. package/plugins/ca-pi/includes/anti-slop-design/medium-web.md +39 -0
  103. package/plugins/ca-pi/includes/anti-slop-design/typography.md +51 -0
  104. package/plugins/ca-pi/includes/author-tdd-workflow.md +14 -0
  105. package/plugins/ca-pi/includes/compaction-charter.md +16 -0
  106. package/plugins/ca-pi/includes/cut-docs.md +16 -0
  107. package/plugins/ca-pi/includes/dev-mode.md +30 -0
  108. package/plugins/ca-pi/includes/farm.md +237 -0
  109. package/plugins/ca-pi/includes/fresh-verification.md +14 -0
  110. package/plugins/ca-pi/includes/harvest.md +69 -0
  111. package/plugins/ca-pi/includes/maturity-coverage.md +102 -0
  112. package/plugins/ca-pi/includes/pi-host-notes.md +69 -0
  113. package/plugins/ca-pi/includes/redirect.md +69 -0
  114. package/plugins/ca-pi/includes/reference-map.md +22 -0
  115. package/plugins/ca-pi/includes/review-matrix.md +14 -0
  116. package/plugins/ca-pi/includes/reviewer-contract.md +53 -0
  117. package/plugins/ca-pi/includes/routing-table.md +47 -0
  118. package/plugins/ca-pi/includes/security-gate-record.md +22 -0
  119. package/plugins/ca-pi/includes/smarts/core.md +90 -0
  120. package/plugins/ca-pi/includes/smarts/decision-log-format.md +56 -0
  121. package/plugins/ca-pi/routines/INDEX.md +32 -0
  122. package/plugins/ca-pi/routines/brainstorming/SKILL.md +122 -0
  123. package/plugins/ca-pi/routines/commit-gate/SKILL.md +151 -0
  124. package/plugins/ca-pi/routines/context-check/SKILL.md +85 -0
  125. package/plugins/ca-pi/routines/context-creation/SKILL.md +171 -0
  126. package/plugins/ca-pi/routines/crypto-compliance/SKILL.md +41 -0
  127. package/plugins/ca-pi/routines/debug/SKILL.md +99 -0
  128. package/plugins/ca-pi/routines/decision-lifecycle/SKILL.md +104 -0
  129. package/plugins/ca-pi/routines/decision-lifecycle/references/adr-template.md +74 -0
  130. package/plugins/ca-pi/routines/decision-variance/SKILL.md +147 -0
  131. package/plugins/ca-pi/routines/decompose/SKILL.md +168 -0
  132. package/plugins/ca-pi/routines/dispatching-parallel-agents/SKILL.md +76 -0
  133. package/plugins/ca-pi/routines/executing-plans/SKILL.md +83 -0
  134. package/plugins/ca-pi/routines/finishing-a-development-branch/SKILL.md +91 -0
  135. package/plugins/ca-pi/routines/post-merge-cleanup/SKILL.md +233 -0
  136. package/plugins/ca-pi/routines/refactor/SKILL.md +91 -0
  137. package/plugins/ca-pi/routines/release/SKILL.md +315 -0
  138. package/plugins/ca-pi/routines/secret-handling/SKILL.md +67 -0
  139. package/plugins/ca-pi/routines/security-architecture/SKILL.md +63 -0
  140. package/plugins/ca-pi/routines/skill-author/SKILL.md +108 -0
  141. package/plugins/ca-pi/routines/skill-author/references/skill-template.md +58 -0
  142. package/plugins/ca-pi/routines/subagent-driven-development/SKILL.md +149 -0
  143. package/plugins/ca-pi/routines/subagent-driven-development/references/farm-dispatch.md +145 -0
  144. package/plugins/ca-pi/routines/tdd/SKILL.md +139 -0
  145. package/plugins/ca-pi/routines/tribunal/SKILL.md +109 -0
  146. package/plugins/ca-pi/routines/tribunal/references/ai-markers.md +29 -0
  147. package/plugins/ca-pi/routines/tribunal/references/cost-and-models.md +64 -0
  148. package/plugins/ca-pi/routines/tribunal/references/finding-record.md +27 -0
  149. package/plugins/ca-pi/routines/tribunal/references/issue-filing.md +47 -0
  150. package/plugins/ca-pi/routines/tribunal/references/lenses/appsec.md +22 -0
  151. package/plugins/ca-pi/routines/tribunal/references/lenses/architecture.md +23 -0
  152. package/plugins/ca-pi/routines/tribunal/references/lenses/coverage.md +20 -0
  153. package/plugins/ca-pi/routines/tribunal/references/lenses/infra.md +24 -0
  154. package/plugins/ca-pi/routines/tribunal/references/lenses/migration.md +22 -0
  155. package/plugins/ca-pi/routines/tribunal/references/lenses/observability.md +21 -0
  156. package/plugins/ca-pi/routines/tribunal/references/lenses/performance.md +22 -0
  157. package/plugins/ca-pi/routines/tribunal/references/lenses/reliability.md +23 -0
  158. package/plugins/ca-pi/routines/tribunal/references/lenses/secrets-supply.md +22 -0
  159. package/plugins/ca-pi/routines/tribunal/references/lenses/test-fidelity.md +24 -0
  160. package/plugins/ca-pi/routines/tribunal/references/lenses/typesafety.md +21 -0
  161. package/plugins/ca-pi/routines/tribunal/references/report.md +19 -0
  162. package/plugins/ca-pi/routines/tribunal/references/schemas.md +58 -0
  163. package/plugins/ca-pi/routines/tribunal/references/telemetry.md +28 -0
  164. package/plugins/ca-pi/routines/tribunal/references/triage.md +53 -0
  165. package/plugins/ca-pi/routines/using-git-worktrees/SKILL.md +85 -0
  166. package/plugins/ca-pi/routines/writing-plans/SKILL.md +129 -0
  167. package/plugins/ca-pi/routines/writing-plans/references/farm-plan.md +50 -0
  168. package/plugins/ca-pi/skills/ca-add-dep/SKILL.md +88 -0
  169. package/plugins/ca-pi/skills/ca-adr/SKILL.md +30 -0
  170. package/plugins/ca-pi/skills/ca-adr-status/SKILL.md +30 -0
  171. package/plugins/ca-pi/skills/ca-arbiter/SKILL.md +36 -0
  172. package/plugins/ca-pi/skills/ca-audit/SKILL.md +51 -0
  173. package/plugins/ca-pi/skills/ca-btw/SKILL.md +23 -0
  174. package/plugins/ca-pi/skills/ca-checkpoint/SKILL.md +50 -0
  175. package/plugins/ca-pi/skills/ca-chore/SKILL.md +58 -0
  176. package/plugins/ca-pi/skills/ca-cleanup/SKILL.md +55 -0
  177. package/plugins/ca-pi/skills/ca-commands/SKILL.md +21 -0
  178. package/plugins/ca-pi/skills/ca-commit/SKILL.md +27 -0
  179. package/plugins/ca-pi/skills/ca-conflict/SKILL.md +61 -0
  180. package/plugins/ca-pi/skills/ca-context-check/SKILL.md +32 -0
  181. package/plugins/ca-pi/skills/ca-create-context/SKILL.md +32 -0
  182. package/plugins/ca-pi/skills/ca-debug/SKILL.md +42 -0
  183. package/plugins/ca-pi/skills/ca-decompose/SKILL.md +30 -0
  184. package/plugins/ca-pi/skills/ca-dev/SKILL.md +42 -0
  185. package/plugins/ca-pi/skills/ca-doctor/SKILL.md +44 -0
  186. package/plugins/ca-pi/skills/ca-feature/SKILL.md +105 -0
  187. package/plugins/ca-pi/skills/ca-fix/SKILL.md +42 -0
  188. package/plugins/ca-pi/skills/ca-init/SKILL.md +56 -0
  189. package/plugins/ca-pi/skills/ca-metrics/SKILL.md +80 -0
  190. package/plugins/ca-pi/skills/ca-new-skill/SKILL.md +34 -0
  191. package/plugins/ca-pi/skills/ca-override/SKILL.md +72 -0
  192. package/plugins/ca-pi/skills/ca-pr/SKILL.md +61 -0
  193. package/plugins/ca-pi/skills/ca-preview/SKILL.md +86 -0
  194. package/plugins/ca-pi/skills/ca-prune/SKILL.md +100 -0
  195. package/plugins/ca-pi/skills/ca-reconcile/SKILL.md +43 -0
  196. package/plugins/ca-pi/skills/ca-refactor/SKILL.md +43 -0
  197. package/plugins/ca-pi/skills/ca-release/SKILL.md +57 -0
  198. package/plugins/ca-pi/skills/ca-review/SKILL.md +63 -0
  199. package/plugins/ca-pi/skills/ca-spike/SKILL.md +41 -0
  200. package/plugins/ca-pi/skills/ca-sprint/SKILL.md +44 -0
  201. package/plugins/ca-pi/skills/ca-standup/SKILL.md +112 -0
  202. package/plugins/ca-pi/skills/ca-status/SKILL.md +56 -0
  203. package/plugins/ca-pi/skills/ca-task/SKILL.md +61 -0
  204. package/plugins/ca-pi/skills/ca-threat-model/SKILL.md +45 -0
  205. package/plugins/ca-pi/skills/ca-tribunal/SKILL.md +44 -0
  206. package/plugins/ca-pi/skills/ca-watch/SKILL.md +78 -0
@@ -0,0 +1,83 @@
1
+ ---
2
+ name: executing-plans
3
+ description: The checkpoint coordinator for /feature. Routed to by /feature once a writing-plans plan exists. Groups tasks into batches, delegates each batch to subagent-driven-development (fresh author agent per task, full review chain, fresh verification), then stops for a human checkpoint before the next batch. The checkpointed counterpart to /sprint's autonomous run.
4
+ disable-model-invocation: true
5
+ ---
6
+
7
+ # executing-plans
8
+
9
+ Coordinate the plan in small, user-acknowledged batches. Routed to by `/feature` after
10
+ `writing-plans` has produced a plan. Each batch is executed by `subagent-driven-development` — fresh
11
+ author agent per task, spec-compliance review, quality review, fresh verification — and the user
12
+ checkpoints between batches. The orchestrator never implements; it schedules and checkpoints.
13
+
14
+ ## Pre-flight
15
+
16
+ Read these, or STOP and surface the gap — never guess a path, a command, or a task boundary:
17
+
18
+ - `<project-root>/.codearbiter/plans/<slug>.md` — the approved plan. The ordered task list and each task's verification command are the contract. No plan, no execution.
19
+ - `<project-root>/.codearbiter/specs/<slug>.md` — the spec the plan implements.
20
+ - `<project-root>/.codearbiter/CONTEXT.md` — the `stage:` frontmatter (the maturity value) and project context.
21
+ - `<project-root>/.codearbiter/tech-stack.md` — the exact verification, test, and build invocations.
22
+
23
+ ## Phase 1 — Batch plan · gate: BLOCK
24
+
25
+ Group the plan's tasks into small batches. Keep batches tight — three to five tasks is a ceiling, not
26
+ a target. Respect the plan's ordering and dependencies: a task never lands before the task it depends on.
27
+
28
+ **Resume is the normal re-entry.** A task already `ACCEPTED` in the plan's status column was verified
29
+ before an earlier interruption — exclude it from batching and say so ("resuming: T-01–T-03 already
30
+ ACCEPTED"). Batch only the non-`ACCEPTED` tasks, starting at the first. Never re-execute an `ACCEPTED`
31
+ task, and never restart the pipeline at brainstorming because the session died mid-plan.
32
+
33
+ For each task, confirm the plan names its exact target paths and its verification command. A task
34
+ missing either is underspecified — return it to `writing-plans`, do not improvise the gap.
35
+
36
+ Present the batch breakdown to the user as information, not a question: which tasks land in batch 1,
37
+ and what follows. Do NOT stop for a separate acknowledgment — the user approved the plan in
38
+ `writing-plans`, and the first Phase 3 checkpoint arrives after batch 1; a breakdown objection
39
+ surfaces there (or the user interrupts). Each unresolved unknown is a `[CONFIRM-NN]` in
40
+ `open-questions.md` — surface it, do not guess past it.
41
+
42
+ Gate: a batch sequence exists and every task has a target path and a verification command. A
43
+ `[CONFIRM-NN]` that blocks batch 1 is the only reason to stop here.
44
+
45
+ ## Phase 2 — Execute batch · gate: BLOCK
46
+
47
+ Invoke `subagent-driven-development` (`<plugin-root>/routines/subagent-driven-development/SKILL.md`) with `scope = [current batch task IDs]`. Pass the plan slug and
48
+ spec slug so it can read its own pre-flight files. Do not implement anything here — the author agents,
49
+ review chain, and verification all run inside that skill.
50
+
51
+ `subagent-driven-development` returns when every task in the scope is `ACCEPTED` (Phase 3–5 green,
52
+ verification passed on a fresh run). A `tdd` BLOCK, a security CRITICAL finding, or an unresolved
53
+ `[CONFIRM-NN]` surfaced inside that skill halts the loop — surface it to the user and do not proceed.
54
+
55
+ Gate: `subagent-driven-development` signals batch complete with all scoped tasks `ACCEPTED`. Any
56
+ unresolved halt from inside the skill is a gate failure here.
57
+
58
+ ## Phase 3 — Checkpoint · gate: STOP
59
+
60
+ Every task in the batch is done and verified. STOP and checkpoint with the user before any further
61
+ work:
62
+
63
+ - **Landed** — the tasks completed this batch, each verified by `subagent-driven-development` Phase 5.
64
+ - **Next** — the tasks in the upcoming batch.
65
+ - **Open** — any `[NEEDS-TRIAGE]` marker raised inside the batch, any `[CONFIRM-NN]` still blocking.
66
+
67
+ Do not begin the next batch until the user acknowledges. This gate is the point of `/feature` — the
68
+ human checkpoint that separates it from `/sprint`'s autonomous run.
69
+
70
+ Gate: the user has acknowledged the checkpoint. On acknowledgement, loop to Phase 2 for the next
71
+ batch. When the final batch is acknowledged and the plan is fully verified, route to `commit-gate` —
72
+ do not commit from here.
73
+
74
+ ## Hard rules
75
+
76
+ - MUST NOT execute tasks inline — delegate every batch to `subagent-driven-development` with an explicit `scope`.
77
+ - MUST NOT advance past a checkpoint the user has not acknowledged.
78
+ - MUST NOT call `commit-gate` until all batches are acknowledged and every plan task is `ACCEPTED`.
79
+ - MUST surface any halt from `subagent-driven-development` (tdd BLOCK, CRITICAL, CONFIRM-NN) to the user — do not swallow it or re-dispatch around it.
80
+ - MUST NOT absorb scope the plan does not name — mark it `[NEEDS-TRIAGE]`.
81
+ - MUST NOT commit; route to `commit-gate` when the plan is fully verified.
82
+ - MUST return an underspecified task (missing path or verification command) to `writing-plans` — do not improvise the gap.
83
+ - MUST surface a plan-versus-code conflict via `/conflict`, never silently reconcile it.
@@ -0,0 +1,91 @@
1
+ ---
2
+ name: finishing-a-development-branch
3
+ description: The terminal step of /feature and /sprint. Routed to once commit-gate has cleared, to decide the branch's fate — merge via PR, open a PR, or discard. Direct merge to the default branch is forbidden; every change lands through a PR. Under /sprint the skill auto-selects "open PR" and surfaces the merge decision to the user.
4
+ ---
5
+
6
+ # finishing-a-development-branch
7
+
8
+ The work is committed and green. Now decide where it goes. Routed to by `/feature` and `/sprint`
9
+ after `commit-gate` clears — never before.
10
+
11
+ ## Pre-flight
12
+
13
+ Read these, or STOP and surface the gap — never guess the branch name or the default branch:
14
+
15
+ - `<project-root>/.codearbiter/CONTEXT.md` — the default-branch name and project context.
16
+ - `<project-root>/.codearbiter/plans/<slug>.md` — the plan this branch executed, when `/feature` or `/sprint` produced one. The yardstick for "is the work complete."
17
+ - `<project-root>/.codearbiter/last-checkpoint` — the most recent gate results; confirms `commit-gate` cleared on this branch.
18
+
19
+ `commit-gate` MUST have cleared on the current HEAD. If it has not, this skill does not run — return to it.
20
+
21
+ ## Phase 1 — State assembly · gate: BLOCK
22
+
23
+ Assemble the facts the decision needs. Nothing is presented until all are in hand:
24
+
25
+ - **Branch** — the current branch name and its base. Confirm it is NOT the default branch; if HEAD is the default branch, STOP — there is nothing to finish and merge-to-default is forbidden.
26
+ - **Diff summary** — files changed, insertions/deletions, and the commit list since the base. Read it, do not paraphrase from memory.
27
+ - **Gate results** — `commit-gate` outcome and the `last-checkpoint` record. Surface any open `[NEEDS-TRIAGE]` markers left in the diff as out-of-scope findings.
28
+ - **Plan delta** — when a plan exists, state which plan items the branch satisfied and which remain open. Open items are surfaced, not hidden.
29
+
30
+ Gate: branch confirmed non-default, diff summary read, gate results and plan delta in hand.
31
+
32
+ ## Phase 2 — Present terminal options · gate: STOP
33
+
34
+ Present exactly three terminal options with the Phase 1 state attached, then STOP for the choice:
35
+
36
+ 1. **Open a PR** — push the branch and open a pull request against the default branch, then stop. The PR stays open; the merge happens later, by the user or reviewers.
37
+ 2. **Merge via PR** — push the branch, open the PR, and once its checks are green, merge it **through the PR** so the work lands on the default branch now. Distinct from option 1: this one completes the merge. Still PR-only — no direct push to the default branch, no force-push.
38
+ 3. **Discard** — abandon the branch.
39
+
40
+ Under `/feature`: STOP and let the user pick.
41
+
42
+ Under `/sprint`: auto-select **option 1 (open PR)** and surface the merge decision to the user — `/sprint`
43
+ autonomy ends at the PR boundary. It MUST NOT merge (option 2) and MUST NOT discard.
44
+
45
+ Gate: a single terminal option is chosen — by the user under `/feature`, or auto-selected as "open PR" under `/sprint`.
46
+
47
+ ## Phase 3 — Execute the choice · gate: BLOCK
48
+
49
+ Carry out the chosen option, and only that one:
50
+
51
+ - **Open a PR** — push the branch and open the PR against the default branch. The reviewer path-matrix, the anti-slop PR-body composition (description citing the plan items satisfied, the gate results, the §2 conflict level of any non-obvious tradeoff), and the babysitter attach are the steps documented in the `/ca-pr` command flow (`<plugin-root>/skills/ca-pr/SKILL.md`) — **execute those steps here; do not re-invoke `/ca-pr`** (under `/sprint` this skill is reached via `commit-gate`, without the `/pr` command ever running, so a route back would loop). Leave the PR open; the merge is not yours to take.
52
+ - **Merge via PR** — open the PR as above, confirm its checks are green, then merge it through the PR (squash or merge per project convention) so the work lands. Never push to the default branch directly, never force-push.
53
+ - **Discard** — requires explicit user confirmation naming the branch. Before discarding, verify the branch is fully pushed; if any commit is un-pushed, STOP and report exactly what would be lost — never delete un-pushed work silently. Discard proceeds only after the user confirms with that loss in view.
54
+
55
+ Gate: the chosen option completed — for open-PR a PR exists against the default branch; for merge the work landed through that PR; for discard the user confirmed against a stated loss summary.
56
+
57
+ ## Phase 4 — Receipt · gate: BLOCK
58
+
59
+ The loop has been a chain of gates the user watched clear. End it on its most rewarding beat, not in
60
+ silence. Emit a tight **Receipt** — a win summary that reflects the prevention back, drawn ONLY from
61
+ the state Phase 1 already assembled plus `<project-root>/.codearbiter/last-checkpoint`. This is
62
+ **not a fresh audit-trail crawl** — no new log scan, no `git` archaeology. If a field has no data in
63
+ hand, omit the line rather than go digging.
64
+
65
+ Report only what the assembled state supports:
66
+
67
+ - **Obligations covered** — the count of `tdd` obligations that reached `COVERED` on this branch.
68
+ - **Gates that fired and what each caught** — the gates that BLOCKed and then cleared, named with the
69
+ specific thing caught (an untested seam, a scope-creep file set aside), not a bare gate name.
70
+ - **SMARTS decisions the user made** — the architectural forks the user resolved, one line each.
71
+ - **Secrets / regressions prevented** — credential findings and behavioral-proof mismatches the gates
72
+ stopped before they shipped.
73
+ - **Suite time** — the wall-clock of the verifying run, from the gate results in hand.
74
+
75
+ Close with **exactly one** warm, synthesizing sentence (per the orchestrator register) that reflects
76
+ the run back — synthesized for this branch, not the register's canned example. One sentence, earned,
77
+ never on a no-op close.
78
+
79
+ Gate: the Receipt is emitted from in-hand state (no fresh crawl), and the close carries at most one
80
+ warm sentence.
81
+
82
+ ## Hard rules
83
+
84
+ - MUST NOT merge directly to the default branch or force-push — every change lands through a PR.
85
+ - MUST NOT auto-merge under `/sprint`; auto-select "open PR" and surface the merge decision to the user.
86
+ - MUST NOT discard a branch without explicit user confirmation that names the branch.
87
+ - MUST NOT delete un-pushed commits silently — STOP and report the loss before any discard.
88
+ - MUST NOT run before `commit-gate` has cleared on the current HEAD.
89
+ - MUST NOT guess the branch or default-branch name — read `CONTEXT.md` or STOP.
90
+ - MUST draw the Receipt only from Phase 1 state + `last-checkpoint` — never a fresh audit-trail crawl — and never build a rolling cross-branch "saves" tally.
91
+ - MUST keep the close to at most one warm sentence; never on a no-op close.
@@ -0,0 +1,233 @@
1
+ ---
2
+ name: post-merge-cleanup
3
+ description: Finish an already-merged branch. Proves the branch is contained in the fetched default, classifies leftover artifacts as unique / redundant / superseded, returns to a clean --ff-only default checkout, and deletes the merged local branch — every discard confirmed per item. Routed to by /ca-cleanup.
4
+ ---
5
+
6
+ # post-merge-cleanup
7
+
8
+ The walk back from a merged PR. Routed to by `/ca-cleanup`.
9
+
10
+ The work has landed on the default branch. What is left is local: the branch you
11
+ are standing on, and whatever the run left in the tree. This skill returns you to
12
+ a clean, fast-forwarded default checkout without losing anything you have not
13
+ explicitly agreed to lose.
14
+
15
+ **It is ordinary lifecycle work and never needs `/ca-override`.** When it
16
+ cannot proceed, it names the gate that stopped it. Issue #308 recorded the
17
+ alternative: with no owner for this transition, the routing loop reached for
18
+ `/ca-chore`, then for `/ca-override` — a bypass manufactured to cover a
19
+ coverage hole.
20
+
21
+ ## Pre-flight
22
+
23
+ Read this, or STOP and surface the gap — never guess the default-branch name:
24
+
25
+ - `<project-root>/.codearbiter/CONTEXT.md` — the default-branch name.
26
+
27
+ If HEAD is already the default branch, there is no transition to make. Report the
28
+ dirty state read-only and exit; branch pruning across *other* branches belongs to
29
+ `/ca-standup`.
30
+
31
+ ## Phase 1 — Prove the merge · gate: BLOCK
32
+
33
+ A branch that looks merged is not merged. Establish it against the network, not
34
+ against a stale local ref. This repo squash-merges by default, so SHA-ancestry
35
+ alone is the wrong instrument for most landings: it holds for a fast-forward or
36
+ a merge-commit landing, but a squash merge writes a new commit with no SHA
37
+ lineage back to the branch, and `--is-ancestor` will report non-zero for a
38
+ branch that landed cleanly. The gate is **content-containment**, proven by
39
+ whichever instrument fits the landing, always reported as a fact:
40
+
41
+ 1. `git fetch` the remote holding the default branch. A fetch that fails STOPs —
42
+ an unfetched comparison proves nothing.
43
+ 2. Prove containment with two primary instruments plus a fallback, tried in
44
+ order:
45
+ 1. **Ancestry** — `git merge-base --is-ancestor HEAD origin/<default>`. Holds
46
+ for a fast-forward or merge-commit landing. If it holds, that is the
47
+ proof: report it and move on.
48
+ 2. **Squash-merge proof via the PR record** — if ancestry fails, run
49
+ `gh pr list --head "$(git branch --show-current)" --state merged --json number,state,headRefOid,mergeCommit`.
50
+ A `MERGED` PR whose `headRefOid` equals local `git rev-parse HEAD` proves
51
+ every commit on this branch rode that PR's squash into the default
52
+ branch. Report the PR number, that `headRefOid == HEAD`, the merge
53
+ commit (`mergeCommit.oid` in that JSON), **and** the ancestry check's
54
+ negative result — all as facts, not as a failure. Corroborate with
55
+ `git diff --quiet origin/<default> HEAD` when it happens to hold; a
56
+ **non-empty** diff alongside a valid PR proof is normal (the default
57
+ branch advanced since the merge landed) and is reported as a fact, never
58
+ treated as a failure. The PR-record identity — `MERGED` plus
59
+ `headRefOid == HEAD` — is the load-bearing proof; the diff is
60
+ corroboration only when it happens to be fresh, never a requirement.
61
+ 3. **Fallback when `gh` is unavailable or no PR record exists** —
62
+ `git diff --quiet origin/<default> HEAD` (the tree is byte-identical to
63
+ the fetched default) is an acceptable fallback proof. Report it as such.
64
+ 3. Report whichever instrument held as a fact — the default branch, the fetched
65
+ SHA, and which of the three proofs established containment.
66
+
67
+ If none of the three hold, STOP exactly as today. Name the un-landed commits
68
+ and route to `/ca-pr`; nothing is deleted here.
69
+
70
+ > Deliberate deviation from issue #586's suggested contract: that suggestion
71
+ > required the squash-merge proof's diff to be empty. That requirement
72
+ > re-breaks this gate the moment any later PR merges to the default branch —
73
+ > the common state, not an edge case. The PR-record identity is what proves
74
+ > containment; the diff is corroboration, demoted from requirement to fact.
75
+
76
+ Gate: the remote is fetched and HEAD is proven contained in the fetched default
77
+ branch — by ancestry, by the PR-record squash proof, or by the byte-identical
78
+ fallback — or the skill has stopped.
79
+
80
+ ## Phase 2 — Classify the residue · gate: BLOCK
81
+
82
+ List every dirty tracked change, every untracked file, and every stash reachable
83
+ from this branch. Classify each into exactly one of three, and say *why* for each:
84
+
85
+ - **Redundant** — byte-identical to content already on the default branch, or a
86
+ regenerated build artifact whose generator is committed and rerunnable. Safe to
87
+ remove because removing it loses no information.
88
+ - **Superseded** — an earlier form of something the merged PR already landed in a
89
+ better shape. Name what supersedes it.
90
+ - **Unique** — anything else. This is the default: an artifact that cannot be
91
+ proven redundant or superseded IS unique. Uncertainty classifies as unique, not
92
+ as redundant.
93
+
94
+ Present the classification before touching anything. A file whose class you
95
+ cannot establish is reported as unique with the reason you could not classify it.
96
+
97
+ Gate: every dirty, untracked, and stashed artifact carries a class and a stated
98
+ reason, with unclassifiable items counted as unique.
99
+
100
+ ## Phase 3 — Resolve the residue · gate: STOP
101
+
102
+ Per item, in the order Phase 2 listed them. Never batch:
103
+
104
+ - **Unique** — offer to keep it: `/ca-commit` it on this branch before the
105
+ transition, move it aside, or leave it in place and stop the cleanup. It is
106
+ discarded only if the user explicitly confirms *that item by name*, with the
107
+ Phase 2 reasoning in view.
108
+ - **Redundant / superseded** — offer removal, one confirmation each, stating what
109
+ it is and why it is safe. Declining leaves it exactly where it is.
110
+
111
+ A stash is never dropped here. Stashes are reported with `git stash show` as the
112
+ suggested next step, the same report-and-route contract `/ca-standup` holds.
113
+
114
+ If anything the user chose to keep would block the checkout, STOP and say so
115
+ rather than removing it anyway — but distinguish the two causes before naming
116
+ the artifact as the blocker:
117
+
118
+ - **The kept artifact genuinely conflicts** — its content collides with what
119
+ checking out the default branch would need to change or remove. This is the
120
+ user's to resolve, as today.
121
+ - **The local default ref lags the fetched one** — git refuses a checkout when
122
+ a locally-modified tracked file differs between HEAD and the target ref, and
123
+ a stale local `<default>` makes that difference larger than reality: content
124
+ the kept artifact never actually touches can still collide with what a
125
+ *current* default branch would carry. That gap is not the user's problem and
126
+ not the kept artifact's fault. It is resolved by Phase 4's fast-forward-first
127
+ step, not by discarding anything here. Issue #586 recorded the observed
128
+ failure mode: a stale local `main` — 513 lines behind on
129
+ `.codearbiter/gate-events.log` alone — made this STOP name a correctly-kept
130
+ 38-line artifact as the blocker, which invites exactly the silent discard
131
+ this phase exists to prevent.
132
+
133
+ Gate: every item is resolved by an explicit per-item decision, and the working
134
+ tree is clean enough to check out the default branch — or the skill has stopped
135
+ with the blocker named, correctly attributed to a genuine conflict or a stale
136
+ local ref.
137
+
138
+ ## Phase 4 — Transition · gate: BLOCK
139
+
140
+ Only after Phase 3 leaves the tree safe:
141
+
142
+ 1. **Fast-forward the local default ref BEFORE checking it out:**
143
+ `git fetch origin <default>:<default>`. Git refuses a non-fast-forward
144
+ update of a ref that is not currently checked out, so the `--ff-only`
145
+ guarantee is preserved by the instrument itself — this cannot silently
146
+ rewrite the local default ref, only advance it or refuse. This is what
147
+ keeps a stale local default from blocking (or worse, misattributing) the
148
+ checkout below. This step can itself be refused for the same reason a
149
+ checkout can be — `<default>` checked out in another worktree — in which
150
+ case report that as the (correctly attributed) blocker, per Phase 3, and
151
+ stop; do not treat the refusal as license to skip ahead.
152
+ 2. Check out the default branch, then **verify the checkout actually happened**
153
+ (`git branch --show-current`). A checkout silently fails when another worktree
154
+ holds the branch, and every step after this one would otherwise run against
155
+ the wrong branch.
156
+ 3. Fast-forward with `--ff-only` (belt over the braces of step 1 — a no-op when
157
+ the pre-checkout fetch already brought the local ref current). A divergence
158
+ means the default branch moved in a way this skill will not reconcile:
159
+ report it and stop. Never a merge commit, never a rebase, never a reset.
160
+
161
+ Gate: the local default ref was fast-forwarded before the checkout — or the
162
+ fast-forward's refusal was itself reported as a fact and the skill stopped —
163
+ HEAD is confirmed on the default branch by re-read, and the belt-and-braces
164
+ `--ff-only` pull either succeeded (typically a no-op) or was reported as a
165
+ refused divergence.
166
+
167
+ ## Phase 5 — Delete the merged local branch · gate: STOP
168
+
169
+ Offer deletion of the now-merged local branch, with the Phase 1 containment
170
+ proof restated. One confirmation, naming the branch.
171
+
172
+ - `git branch -d` first, always. Never reach for `-D` on the assumption that a
173
+ refusal means `-d` can't handle a squash merge — it often can. `git branch
174
+ -d`'s safety check accepts a branch merged into its **upstream**, not only
175
+ into HEAD: with an upstream still configured and equal to the tip, `-d`
176
+ succeeds (with a warning) even for a squash merge that `--is-ancestor` alone
177
+ would call unmerged. Do not conclude a refusal here means `-D` is required —
178
+ check the reason first.
179
+ - **The sanctioned `-D` path.** `-d` typically refuses once the remote branch
180
+ has been auto-deleted and pruned, because there is then no upstream left for
181
+ `-d` to test reachability against. When that happens, `git branch -D` is
182
+ permitted, but ONLY when both hold:
183
+ 1. Phase 1's proof, established this run, was the PR-record squash proof
184
+ (`MERGED` and `headRefOid == HEAD`) — not a bare ancestry pass, not a
185
+ stale or assumed proof.
186
+ 2. The confirmation restates that Phase-1 proof and explicitly names the
187
+ branch.
188
+ Frame this precisely: `-d`'s safety check tests SHA-reachability, and the
189
+ squash proof has already shown that instrument is the wrong one for this
190
+ repo's merge mode. The PR-record proof plus a named confirmation **replaces**
191
+ the check that `-d` can no longer run — it does not bypass it. Everywhere
192
+ else, `-D` stays forbidden exactly as before: if `-d` refuses and Phase 1's
193
+ proof was anything other than the PR-record squash proof, report both and
194
+ stop.
195
+ - The **remote** branch is never touched. If the user wants it gone, that is
196
+ theirs to do or the platform's auto-delete-on-merge to do.
197
+
198
+ Declining leaves the branch in place. That is a normal outcome, not a failure.
199
+
200
+ Gate: the branch is deleted only after an explicit confirmation naming it, via
201
+ `-d`, or via `-D` restricted to the sanctioned path above with the proof
202
+ restated, with the remote untouched.
203
+
204
+ ## Phase 6 — Receipt
205
+
206
+ One short summary: what landed, what was removed, what was kept, and where HEAD
207
+ is now. State declines as declines — a cleanup the user stopped halfway is a
208
+ correct outcome reported plainly, not an error.
209
+
210
+ ## Hard rules
211
+
212
+ - MUST fetch and prove `HEAD` is **contained** in the fetched default branch
213
+ before any deletion — via ancestry, via the PR-record squash proof (`MERGED`
214
+ and `headRefOid == HEAD`), or, without `gh`, via a byte-identical tree diff.
215
+ MUST NOT infer merge state from a `: gone]` upstream alone.
216
+ - MUST classify every artifact, and MUST treat anything not provably redundant or
217
+ superseded as unique.
218
+ - MUST NOT discard a unique or unclassifiable artifact without an explicit
219
+ confirmation naming that item.
220
+ - MUST confirm every removal and the branch deletion individually — no batched or
221
+ implied yes.
222
+ - MUST fast-forward the local default ref (`git fetch origin <default>:<default>`)
223
+ before checking it out, or report the fast-forward's own refusal (e.g.
224
+ `<default>` checked out in another worktree) as the blocker and stop. MUST
225
+ re-read the current branch after checkout before acting on it.
226
+ - MUST use `--ff-only`, and MUST NOT merge, rebase, or reset to reach the default
227
+ branch.
228
+ - MUST use `git branch -d`, and MAY use `-D` ONLY when the Phase-1 squash-merge
229
+ proof held this run and `-d` refused, with that proof restated and the branch
230
+ named in the confirmation. Everywhere else `-D` is forbidden. MUST NOT delete a
231
+ remote branch, force-push, or write to the default branch.
232
+ - MUST NOT drop a stash — report and route, as `/ca-standup` does.
233
+ - MUST NOT route to `/ca-override` when blocked. Name the gate instead.
@@ -0,0 +1,91 @@
1
+ ---
2
+ name: refactor
3
+ description: The behavior-preserving restructure gate. Routed to by /refactor for a rename, extract, inline, move, dedup, or internal-implementation swap. Six gated phases prove behavioral parity through unmodified pre-existing tests; any diff that classifies as `feat` is not a refactor and is routed to tdd. A modified pre-existing test is rejected as evidence — it is a behavior change in disguise.
4
+ ---
5
+
6
+ # refactor
7
+
8
+ Restructure, do not rewrite. Externally observable behavior before equals after — proven by mechanism, not inspection. Routed to by `/refactor`.
9
+
10
+ ## Pre-flight
11
+
12
+ Read these, or STOP and surface the gap — never guess a command or a threshold:
13
+
14
+ - `<project-root>/.codearbiter/CONTEXT.md` — the `stage:` frontmatter (the maturity value) and project context.
15
+ - `<project-root>/.codearbiter/tech-stack.md` — the test, coverage, lint, and type-check invocations; file layout.
16
+ - `<project-root>/.codearbiter/coding-standards.md` — style, structure, naming. Required for Phase 4.
17
+
18
+ The working tree MUST be clean over the named surface before Phase 1. A dirty surface conflates the refactor diff with unrelated edits and breaks parity verification — STOP and surface it.
19
+
20
+ ## Phase 1 — Surface identification · gate: BLOCK
21
+
22
+ Enumerate the exact blast radius before any other work. Restate the planned refactor in one sentence and confirm it back to the user, then record a surface table:
23
+
24
+ - Files (repo-relative paths).
25
+ - Top-level symbols touched — function, class, and exported member names.
26
+ - Public method signatures within those symbols.
27
+ - External consumers — call sites in other modules.
28
+
29
+ Reject vague surfaces. "the auth module", "the user service", "some helpers in utils" are categories, not surfaces. A surface is acceptable only when a reader could grep the repo for the listed symbols and arrive at the same file set. The table is the parity contract for Phases 2–6.
30
+
31
+ Gate: a precise, complete surface table, user-signed-off. A vague or category-level surface does not pass — "the functions `signToken`, `verifyToken`, and `rotateKey` in `src/auth/tokens.ts`" passes; "the auth module" does not.
32
+
33
+ ## Phase 2 — Behavioral parity coverage proof · gate: BLOCK
34
+
35
+ Prove pre-existing tests already exercise the named surface well enough to detect a behavior change, before any production code is touched. Locate every test that exercises a symbol in the surface table. Run the coverage command from `tech-stack.md` scoped to the surface files; record line, branch, and per-symbol coverage.
36
+
37
+ Coverage scales with the maturity value (`stage:` in `CONTEXT.md`) — the same knob as `tdd` Phase 5,
38
+ using the shared threshold table `<plugin-root>/includes/maturity-coverage.md`.
39
+
40
+ Every public method in the surface table MUST have at least one direct test — transitive coverage through a higher-level integration test does not count. A public method with zero direct tests is uncovered for this gate.
41
+
42
+ **Lines and branches must both clear the threshold** (issue #507); a surface satisfying one and not
43
+ the other is not proven. Where the surface has no coverage tooling, take the no-tooling exemption in
44
+ `<plugin-root>/includes/maturity-coverage.md` — it requires QUOTING the `tech-stack.md` Coverage
45
+ section that omits a command for this surface — and the per-symbol direct-test proof stands alone.
46
+ Without that citation the phase STOPs rather than passing on an unverifiable claim.
47
+
48
+ If surface coverage is below the maturity threshold on either metric, OR any public method has zero direct tests, halt and route to the `tdd` skill (`<plugin-root>/routines/tdd/SKILL.md`) Phase 1 to backfill obligations and red tests for the uncovered surface. Resume Phase 2 only after the backfill is green.
49
+
50
+ Gate: surface coverage at or above the maturity threshold on BOTH lines and branches AND every public method backed by a direct test. Otherwise backfill via `tdd` Phase 1 before retrying.
51
+
52
+ ## Phase 3 — Red parity tests (conditional) · gate: BLOCK
53
+
54
+ Pin any new test seam the refactor exposes before implementation. A new seam is one of: a newly exported symbol that did not exist; a new public method signature on an existing class; a previously private function promoted to module-public.
55
+
56
+ If the refactor exposes no new seam, record "No new seams" and skip to Phase 4. Otherwise, for each seam write one or more tests that pin its contract. These tests MUST be red before implementation, and every pre-existing test MUST stay green. A seam test is scoped strictly to the restructure — it MUST NOT require behavior beyond what the original code already produced. A seam test that needs new behavior to pass means the work is a feature: route it to `tdd` and abort.
57
+
58
+ Gate: either "No new seams", or failing seam tests with all pre-existing tests still green. BLOCK if a proposed seam test requires new behavior, or if any pre-existing test breaks as a side effect of writing the seam tests.
59
+
60
+ ## Phase 4 — Implementation · gate: BLOCK
61
+
62
+ Apply the restructure with zero behavior change, to the conventions in `coding-standards.md`. Confine every edit to the surface table. Acceptable edits: rename symbols (with consumer updates); extract or inline functions and methods; move symbols between files; replace an internal implementation with an equivalent one; collapse or split modules where the public interface is preserved.
63
+
64
+ Unacceptable inside a refactor: adding a behavior, branch, error path, or side effect; changing the value any public method returns for any pre-existing input; adding a public method beyond a Phase 3 seam; changing observable order of operations (event emission, logging, IO). Classify the resulting staged diff against `commit-gate` classification criteria — a diff that classifies as `feat` is not a refactor; halt and route to `tdd`.
65
+
66
+ Gate: the refactor confined to the surface table, with any Phase 3 seam tests now green. BLOCK if the diff classifies as `feat`, or if any edit falls outside the Phase 1 surface table without an explicit user-approved amendment.
67
+
68
+ ## Phase 5 — Parity verification · gate: BLOCK
69
+
70
+ Run the full project test suite from `tech-stack.md`. Every pre-existing test from Phase 2 MUST pass with NO modification to its source — inspect the diff and confirm zero edits to any pre-existing test file. A modified pre-existing test is, by definition, evidence the surface's observable behavior changed: revert it. If it cannot pass after revert, the refactor introduced a behavior change and is routed to `tdd` as a feature or fix. Phase 3 seam tests (if any) MUST pass. Record the pass/fail tally and any modified-test detection.
71
+
72
+ Gate: full suite green with zero pre-existing tests modified. BLOCK if any pre-existing test was modified to pass, or if any test fails.
73
+
74
+ ## Phase 6 — Lint and coverage · gate: BLOCK
75
+
76
+ Run lint, the type-check if the project is statically typed, and coverage, all from `tech-stack.md`. Resolve every lint and type error. Confirm surface coverage remains at or above the maturity threshold on both lines and branches — a refactor MUST NOT reduce coverage of the surface it touched on either metric.
77
+
78
+ Where the surface has no coverage tooling, the same clause as Phase 2 applies — the no-tooling exemption in `<plugin-root>/includes/maturity-coverage.md`, citation included — and parity is verified through Phase 5's unmodified pre-existing tests alone. Phase 2 and Phase 6 MUST NOT give different answers about the same surface, which is why both defer to the one shared clause rather than restating its conditions.
79
+
80
+ Gate: clean lint and type-check, zero errors, and no coverage regression on the named surface. "Mostly passes" is not passing — this is what clears the path to `commit-gate`.
81
+
82
+ ## Hard rules
83
+
84
+ - MUST NOT begin Phase 2 without a precise, user-signed-off surface table.
85
+ - MUST NOT proceed past Phase 2 if surface coverage is below the maturity threshold or any public method has zero direct tests — route to `tdd` Phase 1 to backfill.
86
+ - MUST NOT introduce new behavior in Phase 4. A diff that classifies as `feat` under `commit-gate` is not a refactor.
87
+ - MUST NOT modify any pre-existing test to make it pass. A modified test is a behavior change.
88
+ - MUST NOT reduce coverage of the named surface during the refactor.
89
+ - MUST NOT extend the surface mid-flight without an explicit user-approved amendment to the Phase 1 table.
90
+ - MUST NOT inline-suppress a lint rule to clear Phase 6, and never to bypass a security-relevant rule.
91
+ - MUST NOT guess the test, coverage, lint, or type-check command — read `tech-stack.md` or STOP.