@event4u/agent-config 14.6.0 → 14.8.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 (258) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/CHANGELOG.md +255 -145
  3. package/README.md +1 -1
  4. package/dist/agent-src/commands/analyze/inbox.md +264 -10
  5. package/dist/agent-src/commands/analyze.md +1 -1
  6. package/dist/agent-src/commands/evals/git-pr-merge.json +13 -0
  7. package/dist/agent-src/commands/evals/roadmap.json +17 -1
  8. package/dist/agent-src/commands/pr/create.md +14 -2
  9. package/dist/agent-src/commands/pr/merge.md +379 -0
  10. package/dist/agent-src/commands/roadmap/process-full.md +272 -32
  11. package/dist/agent-src/commands/roadmap.md +1 -1
  12. package/dist/agent-src/contexts/execution/auto-dispatch-classification.md +46 -36
  13. package/dist/agent-src/contexts/execution/autonomy-mechanics.md +37 -2
  14. package/dist/agent-src/contexts/execution/roadmap-execution-contract.md +95 -2
  15. package/dist/agent-src/contexts/execution/roadmap-process-loop.md +289 -106
  16. package/dist/agent-src/rules/artifact-drafting-protocol.md +5 -1
  17. package/dist/agent-src/rules/context-hygiene.md +2 -0
  18. package/dist/agent-src/rules/decision-revisit-gate.md +67 -32
  19. package/dist/agent-src/rules/fix-what-you-see.md +108 -0
  20. package/dist/agent-src/rules/no-roadmap-references.md +0 -5
  21. package/dist/agent-src/rules/recurring-criticism.md +110 -0
  22. package/dist/agent-src/rules/roadmap-progress-sync.md +20 -1
  23. package/dist/agent-src/rules/rule-type-governance.md +0 -2
  24. package/dist/agent-src/rules/self-repair-loop.md +17 -0
  25. package/dist/agent-src/rules/skill-quality.md +0 -2
  26. package/dist/agent-src/rules/source-confidentiality.md +37 -7
  27. package/dist/agent-src/scripts/archival_sweep.ts +117 -0
  28. package/dist/agent-src/scripts/archive_completed_roadmaps.ts +26 -7
  29. package/dist/agent-src/scripts/dashboard_mode.ts +212 -0
  30. package/dist/agent-src/scripts/gate_budget.ts +282 -0
  31. package/dist/agent-src/scripts/gate_execute.ts +72 -31
  32. package/dist/agent-src/scripts/roadmap_gates.ts +74 -3
  33. package/dist/agent-src/scripts/update_roadmap_progress.ts +296 -53
  34. package/dist/agent-src/skills/adr-create/SKILL.md +124 -5
  35. package/dist/agent-src/skills/ai-council/SKILL.md +48 -807
  36. package/dist/agent-src/skills/ai-council/references/advanced-modes.md +320 -0
  37. package/dist/agent-src/skills/ai-council/references/cost-and-redaction.md +99 -0
  38. package/dist/agent-src/skills/ai-council/references/execution-modes.md +162 -0
  39. package/dist/agent-src/skills/ai-council/references/output-and-synthesis.md +125 -0
  40. package/dist/agent-src/skills/ai-council/references/procedure.md +143 -0
  41. package/dist/agent-src/skills/decision-record/SKILL.md +61 -3
  42. package/dist/agent-src/skills/decision-review/SKILL.md +65 -0
  43. package/dist/agent-src/skills/merge-conflicts/SKILL.md +26 -0
  44. package/dist/agent-src/skills/quality-tools/SKILL.md +34 -326
  45. package/dist/agent-src/skills/quality-tools/references/js-ts-tools.md +113 -0
  46. package/dist/agent-src/skills/quality-tools/references/php-tools.md +222 -0
  47. package/dist/agent-src/skills/roadmap-management/SKILL.md +15 -409
  48. package/dist/agent-src/skills/roadmap-management/references/archival.md +226 -0
  49. package/dist/agent-src/skills/roadmap-management/references/authoring.md +107 -0
  50. package/dist/agent-src/skills/roadmap-management/references/dashboard.md +47 -0
  51. package/dist/agent-src/skills/roadmap-management/references/lifecycle.md +58 -0
  52. package/dist/agent-src/skills/security/SKILL.md +8 -0
  53. package/dist/agent-src/skills/security-audit/SKILL.md +12 -1
  54. package/dist/agent-src/skills/skill-writing/SKILL.md +34 -570
  55. package/dist/agent-src/skills/skill-writing/references/procedure.md +275 -0
  56. package/dist/agent-src/skills/skill-writing/references/read-only-scripts.md +18 -0
  57. package/dist/agent-src/skills/skill-writing/references/section-patterns.md +298 -0
  58. package/dist/agent-src/templates/agents/agent-project-settings.example.yml +1 -1
  59. package/dist/agent-src/templates/roadmaps.md +65 -4
  60. package/dist/agent-src/templates/scripts/telemetry/flush_sender.mjs +163 -0
  61. package/dist/agent-src/templates/scripts/telemetry/remote.ts +160 -7
  62. package/dist/agent-src/templates/scripts/telemetry/transport.ts +169 -0
  63. package/dist/cli/registry.js +2 -1
  64. package/dist/cli/registry.js.map +1 -1
  65. package/dist/cli-delegate/chunk-2GNWGMAL.js +172 -0
  66. package/dist/cli-delegate/{chunk-P6LQDIWK.js → chunk-7PRE6ZV2.js} +338 -0
  67. package/dist/cli-delegate/{chunk-BKO2AZ7Z.js → chunk-B2ERU2VA.js} +1 -1
  68. package/dist/cli-delegate/chunk-E4XIZDIB.js +402 -0
  69. package/dist/cli-delegate/{chunk-3UCJWMMP.js → chunk-EEJUMCDZ.js} +16 -16
  70. package/dist/cli-delegate/{chunk-NXFWFAYV.js → chunk-G23AT6GD.js} +1 -0
  71. package/dist/cli-delegate/{chunk-XURJ4AQC.js → chunk-H4VIVD4C.js} +385 -284
  72. package/dist/cli-delegate/chunk-I3EIN2YG.js +36 -0
  73. package/dist/cli-delegate/{chunk-RLN73PR5.js → chunk-LPPWO5CE.js} +12 -8
  74. package/dist/cli-delegate/chunk-MWRD5YOH.js +100 -0
  75. package/dist/cli-delegate/{chunk-UEZ7D35A.js → chunk-N7CDDGI3.js} +4 -23
  76. package/dist/cli-delegate/{chunk-63WSP6YZ.js → chunk-PMEKGDED.js} +74 -167
  77. package/dist/cli-delegate/{chunk-GRRPEPRN.js → chunk-T7L2QK3K.js} +24 -5
  78. package/dist/cli-delegate/{chunk-EVTY7ISR.js → chunk-YM4GZDJG.js} +9 -1
  79. package/dist/cli-delegate/cmd_adr_effective.js +1162 -0
  80. package/dist/cli-delegate/cmd_conformance.js +466 -716
  81. package/dist/cli-delegate/cmd_converge.js +3 -3
  82. package/dist/cli-delegate/cmd_doctor.js +10 -10
  83. package/dist/cli-delegate/cmd_explain.js +1 -1
  84. package/dist/cli-delegate/cmd_export.js +10 -9
  85. package/dist/cli-delegate/cmd_handoff.js +10 -9
  86. package/dist/cli-delegate/cmd_memory_get.js +2 -1
  87. package/dist/cli-delegate/cmd_migrate.js +2 -2
  88. package/dist/cli-delegate/cmd_packs_active.js +1 -1
  89. package/dist/cli-delegate/cmd_preflight.js +5 -5
  90. package/dist/cli-delegate/cmd_prune.js +11 -10
  91. package/dist/cli-delegate/cmd_route_audit.js +6 -5
  92. package/dist/cli-delegate/cmd_route_explain.js +3 -3
  93. package/dist/cli-delegate/cmd_session_recycle.js +840 -30
  94. package/dist/cli-delegate/cmd_settings_get.js +3 -3
  95. package/dist/cli-delegate/cmd_settings_migrate.js +10 -9
  96. package/dist/cli-delegate/cmd_settings_set.js +1 -1
  97. package/dist/cli-delegate/cmd_sync.js +11 -10
  98. package/dist/cli-delegate/cmd_uninstall.js +13 -11
  99. package/dist/cli-delegate/cmd_update.js +4 -4
  100. package/dist/cli-delegate/cmd_upgrade.js +4 -4
  101. package/dist/cli-delegate/cmd_validate.js +11 -10
  102. package/dist/cli-delegate/cmd_versions.js +3 -3
  103. package/dist/discovery/deprecation-report.md +1 -1
  104. package/dist/discovery/discovery-manifest.json +111 -37
  105. package/dist/discovery/discovery-manifest.json.sha256 +1 -1
  106. package/dist/discovery/discovery-manifest.summary.md +5 -5
  107. package/dist/discovery/dormancy-report.md +1 -1
  108. package/dist/discovery/orphan-report.md +1 -1
  109. package/dist/discovery/packs.json +15 -12
  110. package/dist/discovery/trust-report.md +3 -3
  111. package/dist/discovery/workspaces.json +11 -8
  112. package/dist/hooks/dispatch.js +3165 -2192
  113. package/dist/install/claudePathsPlan.js +187 -0
  114. package/dist/install/claudePathsPlan.js.map +1 -0
  115. package/dist/install/globalRuleLayers.js +169 -0
  116. package/dist/install/globalRuleLayers.js.map +1 -0
  117. package/dist/install/hostLayerFingerprint.js +136 -0
  118. package/dist/install/hostLayerFingerprint.js.map +1 -0
  119. package/dist/install/install.mjs +553 -425
  120. package/dist/install/partitionEligibility.js +432 -0
  121. package/dist/install/partitionEligibility.js.map +1 -0
  122. package/dist/install/ruleLayerPartition.js +157 -0
  123. package/dist/install/ruleLayerPartition.js.map +1 -0
  124. package/dist/mcp/registry-manifest.json +3 -3
  125. package/dist/mcp/server.json +2 -2
  126. package/dist/mcp/server.mjs +1863 -1234
  127. package/dist/router.json +1 -1
  128. package/dist/scripts/_lib/agent_src.js +41 -0
  129. package/dist/scripts/_lib/agent_src.js.map +1 -1
  130. package/dist/scripts/_lib/install_layout.js +83 -0
  131. package/dist/scripts/_lib/install_layout.js.map +1 -0
  132. package/dist/scripts/_lib/installed_lock.js +444 -0
  133. package/dist/scripts/_lib/installed_lock.js.map +1 -0
  134. package/dist/scripts/_lib/prune_empty_dirs.js +85 -0
  135. package/dist/scripts/_lib/prune_empty_dirs.js.map +1 -0
  136. package/dist/scripts/condense.js +63 -251
  137. package/dist/scripts/condense.js.map +1 -1
  138. package/dist/server/schemas/settings.js +4 -0
  139. package/dist/server/schemas/settings.js.map +1 -1
  140. package/docs/contracts/settings-classes.md +12 -6
  141. package/docs/guidelines/agent-infra/agent-interaction-and-decision-quality.md +8 -3
  142. package/docs/guidelines/agent-infra/artifact-drafting-protocol-mechanics.md +45 -1
  143. package/docs/guidelines/agent-infra/context-hygiene-mechanics.md +26 -0
  144. package/docs/guidelines/agent-infra/false-green.md +47 -1
  145. package/docs/guidelines/agent-infra/memory-access.md +17 -0
  146. package/docs/guidelines/agent-infra/recurring-criticism-mechanics.md +96 -0
  147. package/package.json +1 -1
  148. package/src/agent-src/scripts/archival_sweep.ts +117 -0
  149. package/src/agent-src/scripts/archive_completed_roadmaps.ts +26 -7
  150. package/src/agent-src/scripts/dashboard_mode.ts +212 -0
  151. package/src/agent-src/scripts/gate_budget.ts +282 -0
  152. package/src/agent-src/scripts/gate_execute.ts +72 -31
  153. package/src/agent-src/scripts/roadmap_gates.ts +74 -3
  154. package/src/agent-src/scripts/update_roadmap_progress.ts +296 -53
  155. package/src/agent-src/templates/scripts/telemetry/flush_sender.mjs +163 -0
  156. package/src/agent-src/templates/scripts/telemetry/remote.ts +160 -7
  157. package/src/agent-src/templates/scripts/telemetry/transport.ts +169 -0
  158. package/src/config/agent-settings.template.yml +27 -2
  159. package/src/config/ci-local-parity.yml +39 -0
  160. package/src/config/estate-count-budget.json +612 -3
  161. package/src/config/evaluator-budgets.json +3 -3
  162. package/src/config/gate-coverage.yml +220 -12
  163. package/src/config/gate-violation-baselines.json +73 -63
  164. package/src/config/gitignore-block.txt +15 -2
  165. package/src/config/hook-latency-budget.json +5 -0
  166. package/src/config/rule-activation-census.json +14 -6
  167. package/src/config/rule-stub-ceilings.json +34 -7
  168. package/src/install/claudePathsPlan.ts +196 -0
  169. package/src/install/globalRuleLayers.ts +197 -0
  170. package/src/install/hostLayerFingerprint.ts +145 -0
  171. package/src/install/partitionEligibility.ts +502 -0
  172. package/src/install/ruleLayerPartition.ts +212 -0
  173. package/src/scripts/_cli/cmd_adr_effective.ts +484 -0
  174. package/src/scripts/_cli/cmd_session_recycle.ts +9 -1
  175. package/src/scripts/_dispatch.bash +17 -1
  176. package/src/scripts/_lib/ac_heading.ts +30 -0
  177. package/src/scripts/_lib/adr_frontmatter.test.ts +365 -0
  178. package/src/scripts/_lib/adr_frontmatter.ts +459 -0
  179. package/src/scripts/_lib/agent_src.ts +42 -0
  180. package/src/scripts/_lib/bench_ab_pinned_repo.ts +162 -0
  181. package/src/scripts/_lib/bench_ab_workspace.ts +10 -1
  182. package/src/scripts/_lib/envelope_grounding.ts +49 -9
  183. package/src/scripts/_lib/installed_lock.ts +50 -5
  184. package/src/scripts/_lib/layer_overlap_notice.ts +11 -2
  185. package/src/scripts/_lib/md_section.ts +129 -0
  186. package/src/scripts/_lib/prune_empty_dirs.ts +80 -0
  187. package/src/scripts/_lib/scope_guard.sh +26 -3
  188. package/src/scripts/_lib/self_repair.ts +19 -0
  189. package/src/scripts/_lib/self_repair_class_b.ts +171 -0
  190. package/src/scripts/adr/evidence_census.ts +899 -0
  191. package/src/scripts/adr/regenerate_index.ts +12 -32
  192. package/src/scripts/adr_cite_check.ts +540 -39
  193. package/src/scripts/ai_council/cli_help.ts +55 -0
  194. package/src/scripts/audit_adr_coverage.ts +103 -17
  195. package/src/scripts/before_complete_hook.ts +153 -28
  196. package/src/scripts/bench_ab_v2_complexity.ts +27 -7
  197. package/src/scripts/bench_hook_latency.ts +204 -0
  198. package/src/scripts/build_archive_index.ts +34 -0
  199. package/src/scripts/check_adr_frontmatter.ts +574 -39
  200. package/src/scripts/check_hook_bundle_content.ts +219 -0
  201. package/src/scripts/check_new_adr_evidence.ts +529 -0
  202. package/src/scripts/check_references.ts +78 -0
  203. package/src/scripts/check_release_published.ts +32 -11
  204. package/src/scripts/check_rule_layer_partition.ts +531 -0
  205. package/src/scripts/check_single_delivery.ts +194 -17
  206. package/src/scripts/check_standing_rule_delivery.ts +8 -2
  207. package/src/scripts/ci_settle.ts +170 -0
  208. package/src/scripts/condense.ts +79 -259
  209. package/src/scripts/council_cli.ts +3 -3
  210. package/src/scripts/dispatch_r2_reviewer.ts +6 -14
  211. package/src/scripts/external_sources_denylist.json +4 -1
  212. package/src/scripts/hook_manifest.json +1 -1
  213. package/src/scripts/hook_manifest.yaml +77 -14
  214. package/src/scripts/hooks/block_no_verify.ts +61 -10
  215. package/src/scripts/hooks/block_unauthorized_git.ts +21 -1
  216. package/src/scripts/hooks/concern_registry.ts +4 -0
  217. package/src/scripts/hooks/dispatch_hook.ts +154 -187
  218. package/src/scripts/hooks/dispatch_issues.ts +38 -19
  219. package/src/scripts/hooks/fallback_yaml.ts +66 -0
  220. package/src/scripts/hooks/host_semantics.ts +21 -0
  221. package/src/scripts/hooks/injection_budget.ts +13 -3
  222. package/src/scripts/hooks/py_json_dumps.ts +103 -0
  223. package/src/scripts/hooks/rtk_wrap_hook.ts +8 -3
  224. package/src/scripts/hooks/run_continuation_hook.ts +8 -5
  225. package/src/scripts/hooks/ship_diff_volume_hook.ts +81 -15
  226. package/src/scripts/hooks/source_first_gate_hook.ts +464 -0
  227. package/src/scripts/hooks/state_io.ts +870 -21
  228. package/src/scripts/hooks/stdin_failure_policy.ts +96 -0
  229. package/src/scripts/hooks/subagent_ledger_hook.ts +44 -15
  230. package/src/scripts/hooks/telemetry_flush_hook.ts +139 -0
  231. package/src/scripts/hooks/telemetry_self_repair.ts +128 -0
  232. package/src/scripts/hooks/telemetry_usage_hook.ts +22 -4
  233. package/src/scripts/hooks/turn_end_gate_hook.ts +81 -15
  234. package/src/scripts/injection_scan_hook.ts +137 -5
  235. package/src/scripts/install.ts +16 -11
  236. package/src/scripts/language_mirror_hook.ts +561 -25
  237. package/src/scripts/lint_framework_leakage_allowlist.json +2 -2
  238. package/src/scripts/lint_hook_manifest.ts +49 -0
  239. package/src/scripts/lint_plan_risk_register.ts +4 -3
  240. package/src/scripts/lint_provenance_vocabulary.ts +472 -4
  241. package/src/scripts/lint_skill_router_head.ts +4 -4
  242. package/src/scripts/mcp_server/tools.ts +2 -2
  243. package/src/scripts/new_roadmap.ts +136 -0
  244. package/src/scripts/pack_mcp_content.ts +20 -5
  245. package/src/scripts/release.ts +37 -38
  246. package/src/scripts/report_layer_overlap.ts +6 -0
  247. package/src/scripts/routing_doctor.ts +5 -1
  248. package/src/scripts/self_repair_hook.ts +37 -5
  249. package/src/scripts/session_register_hook.ts +11 -0
  250. package/src/scripts/skill_usage_collect.ts +11 -1
  251. package/src/scripts/skill_usage_report.ts +278 -8
  252. package/src/scripts/sync_pr_branch.ts +170 -20
  253. package/src/server/schemas/settings.ts +8 -0
  254. package/dist/cli-delegate/chunk-EJITJBJX.js +0 -172
  255. package/dist/cli-delegate/chunk-PZWRPRWP.js +0 -38
  256. package/dist/cli-delegate/{chunk-PPQO4NGR.js → chunk-6RJA2F5A.js} +3 -3
  257. package/dist/cli-delegate/{chunk-RYNADUFG.js → chunk-LWTYTX6F.js} +0 -0
  258. package/dist/cli-delegate/{chunk-FBKL6JWT.js → chunk-MMSGVZKV.js} +3 -3
@@ -0,0 +1,379 @@
1
+ ---
2
+ model_tier: medium
3
+ name: git-pr-merge
4
+ disable-model-invocation: true
5
+ argument-hint: "[all|<pr-number>] [--no-merge]"
6
+ pack: git
7
+ intent: "Prepare an open PR to mergeable — sync the base in, resolve conflicts semantically, drive required checks green — merging itself is gated and inert"
8
+ routes_to: [git-workflow, github-ci]
9
+ replaces: []
10
+ visibility: advanced
11
+ cluster: git-pr-merge
12
+ skills: [git-workflow, github-ci]
13
+ description: Prepare one open PR to mergeable, or the whole open-PR queue with `all` — merging is specified but gated, so today every invocation stops at mergeable-and-open
14
+ suggestion:
15
+ eligible: false
16
+ rationale: "Merging is irreversible and gated on the user's own word in the invocation — a suggested merge would manufacture the authorization the Hard Floor requires the user to give."
17
+ workspaces:
18
+ - agent-config-maintainer
19
+ packs:
20
+ - git
21
+ ---
22
+
23
+ # /git-pr-merge
24
+
25
+ Prepare an open pull request until it is genuinely mergeable — its base merged
26
+ in, its conflicts resolved by class rather than by taste, its required checks
27
+ green on the head that will actually be merged — and then merge it, if and only
28
+ if the invocation authorised that.
29
+
30
+ ```
31
+ THE MERGE STEP (§ 9) IS SPECIFIED AND NOT YET ACTIVE. `--no-merge` IS THE
32
+ OPERATIVE PATH TODAY, AND A BARE INVOCATION BEHAVES AS IF IT CARRIED IT.
33
+ ACTIVATION NEEDS THE OWNER DECISION IN THE `merge-authority` BLOCKER OF
34
+ `road-to-drain-commands` — NEVER A COMMAND EDIT, AND NEVER A GUARD EDIT.
35
+ ```
36
+
37
+ **The invocation is the authorization, and nothing else is.** `pr-merge` is a
38
+ `BLOCK_OPS` member in `block_unauthorized_git.ts` because it is irreversible.
39
+ This command would consume the authorization the user's own prompt text already
40
+ wrote to the per-session ledger on `UserPromptSubmit`; it introduces no second
41
+ authorization store, and it never writes one. When that window closes the run
42
+ stops and reports (§ 7) — the window never grows.
43
+
44
+ Why it ships inert rather than not at all: everything before § 9 — the target
45
+ manifest, the four conflict classes, the superseded check, the bounded CI
46
+ repair, the cutoff — is the expensive, error-prone half, it is what the live
47
+ runs actually proved, and none of it merges anything. `--no-merge` delivers all
48
+ of it today.
49
+
50
+ ## Sub-commands
51
+
52
+ | Sub-command | Routes to | Purpose |
53
+ |---|---|---|
54
+
55
+ *(none, deliberately.)* `all` changes **cardinality**, not lifecycle, so it is
56
+ an argument rather than a second command — the locked registry's rule that
57
+ "sibling variants become a flag, never a second command"
58
+ ([`command-clusters`](../../../../../docs/contracts/command-clusters.md)) applied
59
+ to this cluster. A future sub belongs here only if it has a materially
60
+ different lifecycle, not a different count.
61
+
62
+ ## Dispatch
63
+
64
+ Every row below **prepares** — the merge step is gated (see the banner above),
65
+ so today every row ends at mergeable-and-open. The column says what each row
66
+ selects, not that it merges.
67
+
68
+ | Invocation | Selects | Prepares | Merges |
69
+ |---|---|---|---|
70
+ | `/pr:merge <N>` | exactly PR N | yes | only once the gate opens |
71
+ | `/pr:merge` | ONE PR: green first, then infrastructure/tooling before content, then smallest diff (`changedFiles`, then additions+deletions), tiebreak ascending number | yes | only once the gate opens |
72
+ | `/pr:merge all` | the whole open-PR list, under § 6's cutoff | yes | only once the gate opens |
73
+ | `… --no-merge` | as above | yes | **never**, explicitly. This is the form [`/roadmap:process-full`](../../../product-basic/roadmap/process-full/command.md) calls for its delivery loop. |
74
+
75
+ **Bare invocation** (`/pr:merge` with no argument) is a **documented default
76
+ flow**, not a menu: it runs the auto-selection in row 2 and says which PR it
77
+ picked and why, before touching it. A menu would be the wrong shape here —
78
+ selection is deterministic from the queue-order rule in § 1, so asking the user
79
+ to pick would hand back a decision the command can compute. When the open-PR
80
+ list is empty there is nothing to select and the command reports that and
81
+ stops.
82
+
83
+ ## 1. Snapshot the target — an immutable manifest
84
+
85
+ Compute the queue ONCE at invocation and record it as a manifest of
86
+ `(PR number, head SHA)` pairs:
87
+
88
+ ```bash
89
+ gh pr list --state open --limit 100 \
90
+ --json number,title,headRefName,headRefOid,baseRefName,additions,deletions,changedFiles,mergeable,updatedAt
91
+ gh api repos/:owner/:repo/git/ref/heads/<baseRefName> --jq .object.sha # per distinct base
92
+ ```
93
+
94
+ `baseRefName` and the base SHA are part of the record, not incidental: § 2 and
95
+ § 4 both consume `<base>`, and § 8's kill switch "the base advanced by an actor
96
+ other than this run" is undetectable without a base SHA to compare against.
97
+
98
+ `--limit 100` caps the manifest. A queue above 100 open PRs is drained
99
+ **partially**, and the run must say so rather than reporting completion — the
100
+ § 6 bound reads "initial manifest + one batch", and the manifest is what the
101
+ cap truncated.
102
+
103
+ The manifest is the authorization's target set and is **never silently
104
+ refreshed by a third party's push**. It is, by design, advanced by *this run's
105
+ own* commits — § 2 merges the base in and § 5 pushes, so a prepared PR's head
106
+ is never the snapshot head, and a naive "refuse when the SHA moved" check would
107
+ fire on every PR the run touches.
108
+
109
+ So the record carries **two** SHAs per PR and they mean different things:
110
+
111
+ | Field | Set at | Meaning |
112
+ |---|---|---|
113
+ | `pr_number` | snapshot | Immutable. A change is branch substitution — refuse. |
114
+ | `observed_head` | snapshot, then **updated by this run after each of its own pushes** | The head this run last produced. |
115
+ | `base_ref` + `base_sha` | snapshot | The base the PR was prepared against; § 8's "base advanced by another actor" compares against it. |
116
+
117
+ Before every merge, re-read the PR and refuse when the live head is **neither**
118
+ the snapshot head **nor** the head this run last pushed. That is the
119
+ force-push-after-authorization case, and it is the only one the check exists
120
+ for. A PR that appeared after the snapshot is not in scope for this run — § 6
121
+ says what happens to it.
122
+
123
+ ## 2. Sync with the base
124
+
125
+ ```bash
126
+ git fetch origin
127
+ gh pr checkout <N>
128
+ git merge origin/<base> --no-edit
129
+ ```
130
+
131
+ Merge the base **into** the branch. Never rebase a branch that is already
132
+ pushed ([`git-history-discipline`](../../../../rules/git-history-discipline.md)).
133
+
134
+ ## 3. Resolve conflicts by class, never by taste
135
+
136
+ Conflicts between queued PRs are expected, not exceptional: in this repository
137
+ every roadmap PR touches `agents/roadmaps-progress.md` and
138
+ `src/config/estate-count-budget.json`, so each merge re-conflicts every
139
+ remaining PR. Resolve semantically, by these enumerated classes:
140
+
141
+ | Class | Files | Resolution |
142
+ |---|---|---|
143
+ | Roadmap files | `agents/roadmaps/**` | Union of completions. Never un-check a box either side checked; never resurrect a roadmap either side archived or parked. |
144
+ | Generated artefacts | `agents/roadmaps-progress.md` · `src/config/estate-count-budget.json` · `docs/catalog.md` · `docs/command-flows.md` · `agents/index.md` · any file whose first three lines say generated / do-not-edit | Never hand-merge. Take either side, then **regenerate** with the repo's own task and commit the regenerated output. |
145
+ | Archive move vs. edit | `agents/roadmaps/{archive,later,skipped}/**` — one side renamed or deleted, the other edited | The archived end-state wins. Re-apply the edit at the new path if it still matters; otherwise drop it and record the drop in the summary. |
146
+ | Evidence files | `agents/evidence/**` | Append-only. Keep both sides. |
147
+
148
+ ```
149
+ A CONFLICT OUTSIDE THESE FOUR CLASSES HALTS THE RUN.
150
+ IT IS NOT RESOLVED BY JUDGEMENT AND NOT ESCALATED TO A WARNING.
151
+ ```
152
+
153
+ The classes exist so a merge resolution is reproducible by a second reader. An
154
+ unenumerated conflict is a case nobody has decided yet, and deciding it silently
155
+ inside a drain loop is how work disappears.
156
+
157
+ ## 4. Superseded check — before any CI is spent
158
+
159
+ If the effective diff against the base is empty after syncing, the PR's content
160
+ already landed elsewhere. Distinguish genuinely empty from generated-artefact
161
+ churn that regeneration on the base would produce anyway — the latter is not
162
+ emptiness.
163
+
164
+ The probe is **not** a bare diff: taken literally, a bare diff closes every
165
+ roadmap PR in this repository, because after a base sync and a regenerate the
166
+ only remaining hunks are exactly the generated-artefact churn § 3 tells you to
167
+ regenerate. Exclude those paths before deciding:
168
+
169
+ ```bash
170
+ git diff origin/<base>...HEAD --stat -- . \
171
+ ':(exclude)agents/roadmaps-progress.md' \
172
+ ':(exclude)src/config/estate-count-budget.json' \
173
+ ':(exclude)docs/catalog.md' ':(exclude)agents/index.md'
174
+ ```
175
+
176
+ Empty **after that exclusion** ⇒ superseded. **Never merge an empty PR to make
177
+ the queue count fall — and never close one on a bare diff.**
178
+
179
+ ```
180
+ CLOSING SOMEONE ELSE'S PR IS AN IRREVERSIBLE EXTERNAL ACTION AND IS NOT
181
+ GUARDED: `pr-close` IS NOT A `GitOp` AT ALL — NOT IN `BLOCK_OPS`, NOT EVEN
182
+ IN `WARN_OPS`. NOTHING WILL STOP IT, WHICH IS WHY THIS COMMAND MUST.
183
+
184
+ THE RUN NEVER CLOSES A PR ON ITS OWN HEURISTIC. IT STOPS AND ASKS, NAMING
185
+ THE EXACT OBJECT: THE PR NUMBER, ITS TITLE, ITS AUTHOR, AND THE PRs THE
186
+ CONTENT LANDED VIA. ONE CONFIRMATION PER PR, THIS TURN, PER
187
+ non-destructive-by-default. NEVER A BATCH APPROVAL FOR "THE SUPERSEDED ONES".
188
+ IT CANNOT NAME WHERE THE CONTENT LANDED → DO NOT EVEN ASK; LEAVE THE PR OPEN
189
+ AND RECORD IT AS `blocked-external`.
190
+ ```
191
+
192
+ The asymmetry is deliberate and worth stating, because it looks inconsistent:
193
+ merging is gated on an owner *decision* recorded once in a blocker, while
194
+ closing is gated on a *per-object* confirmation every time. Merging this run's
195
+ own PR is an action the run's whole design is about; closing a PR someone else
196
+ opened is not, it destroys their work in progress, and no guard in this tree
197
+ sees it happen. The cheaper gate goes on the action nothing else watches.
198
+
199
+ ## 5. Drive CI green — bounded
200
+
201
+ Push, then wait for the verdict on the pushed head. Green means **the required
202
+ checks succeeded for the exact head SHA that will be merged** — never a local
203
+ run, never an earlier commit ([`/git-pr-create` § 4d](../create/command.md)).
204
+
205
+ - **Root-cause fixes only**, inside the PR's own scope.
206
+ - **One rerun for a known flake class** (`gh run rerun <id> --failed`) before
207
+ red counts as real.
208
+ - **N=3 per validation target, six touches per PR per pass — two different
209
+ units, and the smaller one binds first.** The always-loaded
210
+ [`autonomous-execution`](../../../../rules/autonomous-execution.md) cap is
211
+ three consecutive failed attempts on ONE target (a named failing test, a lint
212
+ rule id, one CI job) and it is not lifted here. The six is a per-PR ceiling
213
+ across *distinct* targets: a PR whose CI peels one failure to reveal a
214
+ different one may be worked six times, never one target four times. Hitting
215
+ N=3 on a single target ends the PR's pass immediately, whatever the six says.
216
+ Exhaustion of either posts a diagnosis comment and moves the PR to the end of
217
+ the queue once; a second exhaustion is terminal.
218
+
219
+ ```
220
+ THESE ARE HALTS, NOT OPTIONS OF LAST RESORT:
221
+ DEPENDENCY CHANGES · WORKFLOW CHANGES · DELETING OR SKIPPING A TEST ·
222
+ LOOSENING A THRESHOLD · WEAKENING A GATE · AN EXPECTED-FAIL MARKER ·
223
+ A BRANCH-PROTECTION CHANGE.
224
+ "DRIVE CI GREEN" AUTHORIZES DIAGNOSIS AND REPAIR, NEVER REMOVING THE CHECK
225
+ THAT WOULD HAVE CAUGHT THE PROBLEM.
226
+ ```
227
+
228
+ ## 6. `all` — the queue, and the cutoff that ends it
229
+
230
+ Process the manifest in the order § 1 recorded it — the queue-order rule in the
231
+ Dispatch table's second row is the traversal for `all` too, not only for
232
+ single-PR selection, so two runs over the same queue agree.
233
+
234
+ After each merge the base has moved, so the next PR is re-synced against the
235
+ NEW base — that is the loop, and it is why pre-greening several PRs ahead of
236
+ their merges is wasted work.
237
+
238
+ **While the merge step is gated, that loop does not turn**, and the section
239
+ below is written for when it does. Nothing merges, so the base does not
240
+ advance, no PR leaves the open list, and an `all` run is a **preparation
241
+ sweep**: it syncs, classifies, greens and reports each PR once, then stops. It
242
+ does not re-prepare a PR its own predecessor invalidated, because it has no
243
+ predecessor that landed. The cutoff below still bounds it; the window below
244
+ still cannot close it, for the reason § 7 gives.
245
+
246
+ **Cutoff.** When the manifest is exhausted, recompute the open-PR list
247
+ **exactly once**. PRs that appeared during the run are drained as ONE final
248
+ straggler batch. After that batch the run ends unconditionally; anything
249
+ arriving during or after it is recorded as `arrived-after-cutoff` and is not
250
+ processed.
251
+
252
+ ```
253
+ THE CUTOFF IS THE TERMINATION PROOF.
254
+ WITHOUT IT, "THE QUEUE MUST SHRINK" DOES NOT TERMINATE AGAINST A SECOND
255
+ SESSION THAT KEEPS OPENING PRs — THE RECOMPUTE JUST REFILLS IT.
256
+ BOUND: INITIAL MANIFEST + ONE BATCH, WHATEVER ELSE IS HAPPENING IN THE REPO.
257
+ ```
258
+
259
+ **Window-aware scheduling.** A green, waiting PR is spent authorization window,
260
+ because the next merge re-conflicts it. When the projected remaining work
261
+ exceeds the remaining window, stop entering CI-fix loops and merge everything
262
+ already green first. Pre-greening several PRs ahead of their merge is forbidden
263
+ under window pressure.
264
+
265
+ **The signal, named — otherwise neither this rule nor § 7 is actionable.** The
266
+ window is the per-session authorization ledger's own freshness bound. Read it,
267
+ never write it:
268
+
269
+ ```bash
270
+ cat "agents/state/git-authorization/$(<session-slug>).json" # detected_at
271
+ ```
272
+
273
+ Remaining window = `detected_at + LEDGER_MAX_AGE_MS − now`. Take the constant
274
+ from the guard source **only after** `check_hook_bundle_content` says the
275
+ source and the executing bundle agree — reading the source alone is the
276
+ 2026-08-21 failure re-expressed as an instruction, since the bundle is what
277
+ enforces the value and a source edit without a rebuild is silently inert. Under
278
+ pressure means
279
+ the remaining window is shorter than one CI cycle on this repository. The read
280
+ is the whole interaction: the run never edits that file, the constant, or the
281
+ built bundle.
282
+
283
+ ## 7. Expiry is a reported state, never a stall
284
+
285
+ ```
286
+ WHEN THE AUTHORIZATION WINDOW CLOSES WITH WORK LEFT, THE RUN STOPS CLEANLY
287
+ AND REPORTS. IT NEVER RETRIES THE GUARD, AND IT NEVER EDITS THE GUARD,
288
+ ITS SOURCE, OR ITS BUNDLES — READ-ONLY VERIFICATION ONLY.
289
+ ```
290
+
291
+ **Unreachable while the merge step is gated**, and stated rather than left for
292
+ a reader to discover: with nothing merging, the run performs no `BLOCK_OPS`
293
+ operation (`push` and `commit` are `WARN_OPS`), so the window governs nothing
294
+ it does. This section is the contract for when the gate opens.
295
+
296
+ Write the summary as-is with a `window-expired` disposition per unprocessed PR
297
+ and name the exact re-authorization needed. Widening `LEDGER_MAX_AGE_MS` is
298
+ forbidden practice: on 2026-08-21 it was patched to six hours for a drain run
299
+ and the widening reached the trunk.
300
+
301
+ ## 8. Kill switches, and what happens after a merge
302
+
303
+ **Armed during preparation, not only before a merge** — otherwise every switch
304
+ below is unreachable while the merge step is gated, and a preparation sweep has
305
+ no way to stop at all. Each one aborts the current PR and ends the run on any
306
+ of:
307
+
308
+ - target number or head SHA differs from the manifest;
309
+ - the base advanced by an actor other than this run;
310
+ - a review was dismissed, or the required-check set changed;
311
+ - a conflict outside the four enumerated classes;
312
+ - guard or hook-bundle verification failed;
313
+ - the first unexplained CI-repair failure.
314
+
315
+ ```
316
+ A COMPLETED MERGE IS THE COMMIT POINT.
317
+ NEVER AUTO-REVERT AN EARLIER MERGE AS "ROLLBACK" — AFTER FIVE MERGES THERE IS
318
+ NO ROLLBACK, ONLY COMPENSATION, AND COMPENSATION IS A SEPARATELY AUTHORIZED
319
+ HUMAN DECISION. STOP, EMIT THE MERGE SHAs AND THE REASON, HAND OVER.
320
+ ```
321
+
322
+ ## 9. Merge, and the summary
323
+
324
+ ```bash
325
+ gh pr merge <N> --<detected-method> --delete-branch
326
+ ```
327
+
328
+ Detect the method once, at invocation, and reuse it for the whole queue:
329
+
330
+ ```bash
331
+ gh repo view --json mergeCommitAllowed,squashMergeAllowed,rebaseMergeAllowed
332
+ ```
333
+
334
+ The mapping is explicit, because `<detected-method>` has to be derivable from
335
+ the text: `mergeCommitAllowed` → `--merge`, `squashMergeAllowed` → `--squash`,
336
+ `rebaseMergeAllowed` → `--rebase`.
337
+
338
+ Exactly one allowed → that is the method. More than one → read the last twenty
339
+ merges on the base (`git log --first-parent origin/<base> -20 --format=%s`) and
340
+ take the shape they overwhelmingly share. **A mixed history with no clear
341
+ majority is not a tie to break — it is a stop:** report it and let the operator
342
+ name the method. Inventing one is what the next sentence forbids, and a wrong
343
+ merge shape is not revertible by this command (§ 8). Never force-merge past a
344
+ failing required check, never admin-bypass.
345
+
346
+ On queue empty or terminal-only, `all` writes
347
+ `agents/evidence/pr-drain-run-summary.md` <!-- ref-ignore --> (created by the
348
+ run, so it does not exist until one has happened): one row per PR with queue
349
+ position, the `base_ref@base_sha` it was prepared against — without it a
350
+ "prepared" row records nothing checkable, since mergeability is a fact about a
351
+ base and not about a queue —
352
+ conflict classes hit, CI iterations used, disposition, and any edits dropped in
353
+ conflict resolution. The disposition set is closed:
354
+
355
+ `merged <sha>` · `superseded-closed` · `blocked-external` · `twice-exhausted` ·
356
+ `window-expired` · `arrived-after-cutoff`
357
+
358
+ ## Rules
359
+
360
+ - **Never merge while the gate is closed.** Until the `merge-authority`
361
+ blocker resolves, every invocation stops at mergeable-and-open, `--no-merge`
362
+ or not. Once it opens, `--no-merge` is still the explicit way to say stop.
363
+ - **Never widen, patch, or rebuild-around the git guard.** Verification of the
364
+ authorization window is read-only.
365
+ - **Never rebase a pushed branch**; the base is merged in.
366
+ - **Never hand-merge a generated artefact**; regenerate it.
367
+ - **Never resolve a conflict outside the four classes**; halt instead.
368
+ - **Never call CI green off a local run**; re-verify on the pushed head.
369
+ - **Never auto-revert a completed merge.**
370
+ - **Mergeability is per-PR against a recorded base SHA**, never a property of
371
+ the queue: making PR *n* mergeable against base `M` says nothing about its
372
+ state once PR *n−1* advances the base.
373
+
374
+ ## See also
375
+
376
+ - [`/git-pr-create`](../create/command.md) — opens the PR this command finishes.
377
+ - [`/roadmap:process-full`](../../../product-basic/roadmap/process-full/command.md) — delegates here for its delivery loop.
378
+ - [`git-history-discipline`](../../../../rules/git-history-discipline.md) — never rewrite pushed history.
379
+ - [`non-destructive-by-default`](../../../../rules/non-destructive-by-default.md) — the Hard Floor a merge sits under.