@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
@@ -29,13 +29,36 @@
29
29
  * correctness fact rather than a token fact, and it needs a different
30
30
  * remedy, so it is never folded into the overlap number.
31
31
  *
32
- * REPORT BY DEFAULT, ENFORCE ON REQUEST — and that is not timidity. The
33
- * invariant is not true yet: `road-to-single-delivery` Phase 2, which makes the
34
- * producers write disjoint layers, is HALTED on blocker
35
- * `partition-requires-global-layer`. A blocking default would therefore red every
36
- * run on a defect nobody can currently fix, which teaches readers to ignore it —
37
- * the exact failure this estate has recorded twice already. Pass `--enforce` once
38
- * Phase 2 lands.
32
+ * REPORT BY DEFAULT, ENFORCE ON REQUEST — and that is not timidity. A blocking
33
+ * default would red every run on a defect a given machine may not be able to
34
+ * fix, which teaches readers to ignore it — the exact failure this estate has
35
+ * recorded twice already.
36
+ *
37
+ * The reason used to be that `road-to-single-delivery` Phase 2 was HALTED on
38
+ * blocker `partition-current-layer-undecidable`. That is no longer true and the
39
+ * sentence is corrected rather than left standing: the blocker reads
40
+ * `**Status:** resolved`, its roadmap is archived, and the partition shipped
41
+ * under ADR-236 Phase 2. What replaced the halt is a per-machine activation —
42
+ * the partition withholds artefacts only where the host layer is verified
43
+ * against `installed.lock`, so a machine whose install predates the fingerprint
44
+ * keeps the full projection BY DESIGN and the overlap this gate reports there is
45
+ * the fail-safe working, not a regression.
46
+ *
47
+ * WHERE THIS CHECK IS MEANINGFUL — read this before quoting one of its numbers
48
+ * (road-to-session-closeout 3.3). It is a DEVELOPER-MACHINE check. It reads two
49
+ * host layers off the filesystem, and in CI both are absent: a fresh checkout
50
+ * carries no `<project>/.claude/**` (zero tracked files under `.claude/`) and no
51
+ * `~/.claude/**` because no CI leg installs at user scope. So in CI this gate
52
+ * finds zero layers and has nothing to compare — which is reported as `absent`
53
+ * rather than as a pass, per the paragraph below, but is still not a statement
54
+ * about any developer's machine.
55
+ *
56
+ * How large that gap is, measured on ONE tree in ONE session on 2026-08-20:
57
+ * `check_standing_rule_delivery` read the same repository twice and reported
58
+ * 115 781 tok with one layer installed and 209 767 tok with two — a 1.8x
59
+ * difference produced entirely by which layers existed where. Any figure from
60
+ * this gate or that one describes the machine it ran on. Cite it with the layer
61
+ * counts attached, never as a repository property.
39
62
  *
40
63
  * A LAYER THAT DOES NOT EXIST IS NOT A PASS. Where a layer is absent there is no
41
64
  * overlap to find, and saying "invariant holds" would be a gate reading nothing
@@ -51,13 +74,65 @@ import { fileURLToPath, pathToFileURL } from 'node:url';
51
74
 
52
75
  import { reportScanned } from './_lib/scan_scope.js';
53
76
 
77
+ // ledger-exempt: this gate has no skip semantics to account for. `_lib/gate_ledger`
78
+ // exists so a gate that PASSES OVER targets says which and why; here the target set
79
+ // is six fixed artefact types, every one of them appears in the output, and a type
80
+ // whose layer is missing is printed as `absent` rather than quietly dropped — see
81
+ // the `absent` field and the `types_compared=N of 6` ledger line, which together
82
+ // already carry what a per-target ledger would. Adding one would restate the render
83
+ // in a second format, and the gate's own docstring warns that the degenerate pass
84
+ // here is a marker with no argument behind it. If a future version gains a real skip
85
+ // path — a type it declines to compare for a reason — this exemption is void and the
86
+ // ledger is the right answer.
87
+
54
88
  const _HERE = fileURLToPath(import.meta.url);
55
89
  const REPO_ROOT = path.resolve(path.dirname(_HERE), '..', '..');
56
90
 
57
- /** Artefact types the host loads from both layers. */
58
- const TYPES = ['rules', 'skills', 'commands', 'agents'] as const;
91
+ /**
92
+ * Artefact types the host loads from both layers.
93
+ *
94
+ * ## The identity key, named because it is not the same for every row
95
+ *
96
+ * Every row below compares BASENAMES within one family directory. For `rules`,
97
+ * `personas`, `user-types` and `agents` that IS the host's unit, so basename
98
+ * equality is the right key. For `commands` it is not: the host-visible unit is
99
+ * the invocation name `/cluster:sub`, which the colon form encodes in the PATH
100
+ * (`commands/<cluster>/<sub>.md`), so this gate's `commands` row compares cluster
101
+ * DIRECTORY names — a coarser key than the thing the host registers.
102
+ *
103
+ * That gap is recorded rather than closed, and the reason is a measurement: since
104
+ * `commandsWithheld` gates the colon-form generator, a machine with a verified
105
+ * host layer projects ZERO commands, so there is no project-side name for the
106
+ * coarse key to be wrong about. On a machine WITHOUT one, the project layer is
107
+ * the only layer and there is nothing to compare. The key is therefore imprecise
108
+ * exactly where it has no work to do. Closing it would mean reading each command
109
+ * file's own slug — real work for a row whose overlap is 0 in both topologies.
110
+ *
111
+ * `personas` and `user-types` were added 2026-08-21 (closure correction). See
112
+ * `unknownProjectFamilies` for what now prevents the next omission.
113
+ */
114
+ const TYPES = ['rules', 'skills', 'commands', 'personas', 'user-types', 'agents'] as const;
59
115
  type ArtefactType = (typeof TYPES)[number];
60
116
 
117
+ /**
118
+ * Directory names under `<repo>/.claude/` that the HOST writes, not a generator.
119
+ *
120
+ * `unknownProjectFamilies` used to rest on the premise that `<repo>/.claude/` is
121
+ * "written by `condense.ts` generators and nothing else". That premise is false
122
+ * and the gate proved it on 2026-08-22, refusing a release push over
123
+ * `.claude/worktrees/` — the maintainer's git-worktree root, gitignored at
124
+ * `.gitignore:246`, named as a conventional worktree location by
125
+ * `worktree_cleanup_check.STANDARD_WORKTREE_DIRS`, and excluded from
126
+ * `inventory_abstraction_budget`. Nothing about it is an artefact family, so
127
+ * "add it to TYPES" was advice that could not be taken.
128
+ *
129
+ * The set is hand-written and stays independent of any producer registry, for
130
+ * the same reason `TYPES` is: a verifier that derives its scope from a producer
131
+ * inherits that producer's omissions. It grows only on tree evidence that a name
132
+ * is host state — never to silence a family a generator actually emits.
133
+ */
134
+ const HOST_OWNED = new Set(['worktrees']);
135
+
61
136
  /**
62
137
  * What a layer's entries physically ARE — symlinks, directories, or regular files.
63
138
  *
@@ -239,6 +314,54 @@ export interface Verdict {
239
314
  namesRead: number;
240
315
  /** True when no type had BOTH layers present — nothing was actually compared. */
241
316
  readNothing: boolean;
317
+ /**
318
+ * Family directories present in the PROJECT layer that `TYPES` does not name.
319
+ *
320
+ * The forcing function that makes this gate's own 2026-08-21 omission
321
+ * non-recurring: `personas` was written by a generator, shipped by the
322
+ * installer, and named by neither measurer, so it was invisible rather than
323
+ * reported — a gate cannot report a family it was never told exists.
324
+ *
325
+ * Only the PROJECT layer is scanned, and that is the whole reason this can be
326
+ * a hard refusal rather than a warning. Every entry in `<repo>/.claude/` is a
327
+ * family this repository chose to emit, EXCEPT the host-written names in
328
+ * `HOST_OWNED` — see that constant for why the unqualified version of this
329
+ * sentence was wrong. `~/.claude/` is the host's own directory —
330
+ * `plugins`, `projects`, `sessions`, `shell-snapshots`, `telemetry` and a
331
+ * dozen more live there — and treating an unrecognised name in it as a defect
332
+ * would be a false-positive generator, not a check.
333
+ */
334
+ unknownFamilies: string[];
335
+ }
336
+
337
+ /**
338
+ * Family directories the project layer holds that `TYPES` does not name.
339
+ *
340
+ * Deliberately NOT derived from the installer's `_CLAUDE_SKILL_BUNDLE` or from
341
+ * `check_generator_output_coverage`'s registry: a verifier whose scope comes from
342
+ * a producer inherits that producer's omissions, which is the exact defect this
343
+ * function exists to catch. `TYPES` stays hand-written and independent; this
344
+ * compares it against the filesystem the generators actually produced and refuses
345
+ * on disagreement.
346
+ */
347
+ function unknownProjectFamilies(projectRoot: string): string[] {
348
+ const known = new Set<string>(TYPES);
349
+ let entries: fs.Dirent[];
350
+ try {
351
+ entries = fs.readdirSync(projectRoot, { withFileTypes: true });
352
+ } catch {
353
+ return []; // no project layer at all — nothing emitted, nothing to miss
354
+ }
355
+ return entries
356
+ .filter(
357
+ (e) =>
358
+ e.isDirectory() &&
359
+ !e.name.startsWith('.') &&
360
+ !known.has(e.name) &&
361
+ !HOST_OWNED.has(e.name),
362
+ )
363
+ .map((e) => e.name)
364
+ .sort();
242
365
  }
243
366
 
244
367
  export function evaluate(globalRoot: string, projectRoot: string): Verdict {
@@ -265,6 +388,7 @@ export function evaluate(globalRoot: string, projectRoot: string): Verdict {
265
388
  0,
266
389
  ),
267
390
  readNothing: compared === 0,
391
+ unknownFamilies: unknownProjectFamilies(projectRoot),
268
392
  };
269
393
  }
270
394
 
@@ -320,12 +444,24 @@ export function render(v: Verdict, globalRoot: string, projectRoot: string): str
320
444
  out.push('');
321
445
  out.push(` layers not present (nothing to compare there): ${v.absent.join(', ')}`);
322
446
  }
447
+ if (v.unknownFamilies.length > 0) {
448
+ out.push('');
449
+ out.push(
450
+ ` ❌ unknown family in the project layer: ${v.unknownFamilies.join(', ')}` +
451
+ ' — add it to TYPES in this gate AND in _lib/layer_overlap_notice.ts,',
452
+ );
453
+ out.push(
454
+ ' or the next family shipped from two layers is invisible the way `personas`' +
455
+ ' was until 2026-08-21.',
456
+ );
457
+ }
323
458
  out.push('');
324
459
  out.push(
325
460
  `check_single_delivery ledger: duplicated=${v.duplicated}` +
326
461
  ` name_overlap_different_shape=${v.nameOverlapDifferentShape}` +
327
462
  ` scope_defeat=${v.defeated}` +
328
463
  ` types_compared=${v.typesCompared} of ${v.readings.length}` +
464
+ ` unknown_families=${v.unknownFamilies.length}` +
329
465
  ` names_read=${v.namesRead}`,
330
466
  );
331
467
  return out.join('\n');
@@ -336,6 +472,7 @@ export function main(argv?: readonly string[]): number {
336
472
  let globalRoot = path.join(os.homedir(), '.claude');
337
473
  let projectRoot = path.join(REPO_ROOT, '.claude');
338
474
  let enforce = false;
475
+ let quiet = false;
339
476
 
340
477
  const value = (i: number): string | null => {
341
478
  const v = args[i + 1];
@@ -354,13 +491,20 @@ export function main(argv?: readonly string[]): number {
354
491
  i += 1;
355
492
  } else if (a === '--enforce') {
356
493
  enforce = true;
494
+ } else if (a === '--quiet') {
495
+ // R2 finding: the full per-type table is ~30 lines, and preflight is a
496
+ // `silent: true` task. A gate that floods a quiet chain is a gate people
497
+ // learn to scroll past, which is the same end state as an unbound one.
498
+ quiet = true;
357
499
  } else if (a === '--help' || a === '-h') {
358
500
  process.stdout.write(
359
- 'usage: check_single_delivery [--global DIR] [--project DIR] [--enforce]\n' +
501
+ 'usage: check_single_delivery [--global DIR] [--project DIR] [--enforce] [--quiet]\n' +
360
502
  '\n' +
361
- 'Reports by default and exits 0: the invariant is not true yet, because\n' +
362
- 'road-to-single-delivery Phase 2 is halted on partition-requires-global-layer.\n' +
363
- '--enforce exits 1 on any overlap, and is what to register once Phase 2 lands.\n',
503
+ 'Reports by default and exits 0: the partition SHIPPED (ADR-236, Phase 2)\n' +
504
+ 'but activates per machine — only where a verified host layer exists, so a\n' +
505
+ 'checkout without one keeps the full projection BY DESIGN and reports overlap.\n' +
506
+ '--enforce exits 1 on any overlap; registering it would fail every machine\n' +
507
+ 'that has not re-run `agent-config install`, which is why it stays opt-in.\n',
364
508
  );
365
509
  return 0;
366
510
  } else if (a !== undefined) {
@@ -379,7 +523,7 @@ export function main(argv?: readonly string[]): number {
379
523
  }
380
524
 
381
525
  const v = evaluate(globalRoot, projectRoot);
382
- process.stdout.write(`${render(v, globalRoot, projectRoot)}\n`);
526
+ if (!quiet) process.stdout.write(`${render(v, globalRoot, projectRoot)}\n`);
383
527
  // Dead-scope assertion via the shared primitive rather than a hand-rolled
384
528
  // `scanned:` line: `check_gate_coverage`'s hardening ratchet accepts an
385
529
  // emitted line only from a gate registered in the enforced manifest, and this
@@ -417,6 +561,37 @@ export function main(argv?: readonly string[]): number {
417
561
  ' case (layers present but never paired) is refused separately.',
418
562
  });
419
563
 
564
+ // Refuses in both modes, unlike every other branch here — but ONLY over this
565
+ // repository's own generated tree, and that qualification was added by a
566
+ // neutral review (2026-08-21) rather than being there from the start.
567
+ //
568
+ // The asymmetry is the argument for the refusal: every other verdict here is
569
+ // a property of ONE MACHINE's two layers, which is why `--enforce` is opt-in.
570
+ // "this repository emits a family no measurer names" is true on every checkout
571
+ // and fixable in one line, so gating it behind `--enforce` would put the one
572
+ // topology-independent check behind the flag meant for topology-dependent
573
+ // ones.
574
+ //
575
+ // The qualification is the review's, and it is right: an unrecognised
576
+ // DIRECTORY does not by itself establish generator ownership. It does under
577
+ // `<repo>/.claude/`, which `condense.ts` writes and nothing else does. It does
578
+ // NOT under an arbitrary `--project` path, which may be a consumer tree with
579
+ // a host-native or project-only family that legitimately cannot overlap — and
580
+ // refusing there would make a nominal report exit 1 on a correct topology.
581
+ // So a repointed root REPORTS and does not refuse.
582
+ if (v.unknownFamilies.length > 0) {
583
+ const own = projectRoot === path.join(REPO_ROOT, '.claude');
584
+ process.stdout.write(
585
+ `${own ? '❌' : '⚠️ '} check_single_delivery: unknown family in the project` +
586
+ ` layer: ${v.unknownFamilies.join(', ')}. Add measurement before it can ship` +
587
+ ' — TYPES in this gate and in _lib/layer_overlap_notice.ts.' +
588
+ (own ? '' : ' Reported, not enforced: --project is repointed, so generator' +
589
+ ' ownership of this tree is not established.') +
590
+ '\n',
591
+ );
592
+ if (own) return 1;
593
+ }
594
+
420
595
  if (v.readNothing) {
421
596
  // Never a pass. A gate that compared nothing has not verified anything,
422
597
  // and saying "invariant holds" here is the false-green shape this repo
@@ -451,9 +626,11 @@ export function main(argv?: readonly string[]): number {
451
626
  }
452
627
  process.stdout.write(
453
628
  `⚠️ check_single_delivery: ${detail}. Reported, not enforced — ` +
454
- 'road-to-single-delivery Phase 2 is halted on `partition-requires-global-layer`, ' +
455
- 'so this is a known-open defect rather than a regression. Re-run with --enforce ' +
456
- 'once the partition ships.\n',
629
+ 'the partition shipped (ADR-236 Phase 2) but activates per machine: it withholds ' +
630
+ 'artefacts only where the host layer is verified against `installed.lock`, so a ' +
631
+ 'machine whose install predates the fingerprint keeps the full projection BY DESIGN ' +
632
+ 'and this overlap is the fail-safe working. Run `agent-config install` to enable it ' +
633
+ 'here; use --enforce where every machine is known to be verified.\n',
457
634
  );
458
635
  return 0;
459
636
  }
@@ -326,8 +326,14 @@ export function main(argv: readonly string[] = process.argv.slice(2)): number {
326
326
  if (pct > 1) {
327
327
  process.stderr.write(
328
328
  `❌ ${PROG}: ${total} tok of standing rule prose exceeds the ${budget.total_cap_tokens} cap. `
329
- + 'If two layers overlap, `agent-config install --layer=<global|project>` suppresses one '
330
- + 'without deleting a file; otherwise scope rules with `paths:` or move bodies into the digest.\n',
329
+ + 'If two layers overlap, that is the ADR-236 partition not yet armed on this '
330
+ + 'machine: run `agent-config install` so the host layer is fingerprinted in '
331
+ + 'installed.lock, and the next `task generate-tools` withholds the globally-owned '
332
+ + 'artefacts instead of writing a second copy. (Superseded advice: this line used to '
333
+ + 'name `install --layer=<global|project>`, the layer-suppression remedy ADR-226 '
334
+ + 'declined and ADR-236 replaced — a reader following it could not fix the '
335
+ + 'condition.) Otherwise the total is body length, not duplication: scope rules with '
336
+ + '`paths:` or move bodies into the digest.\n',
331
337
  );
332
338
  return 1;
333
339
  }
@@ -0,0 +1,170 @@
1
+ #!/usr/bin/env tsx
2
+ /**
3
+ * Wait for a PR's checks to settle, and never report a verdict it did not read.
4
+ *
5
+ * WHY THIS EXISTS. Agents write this loop by hand, and the exit condition is
6
+ * the part that is easy to get wrong. Measured 2026-08-20:
7
+ *
8
+ * until ! gh pr checks 1459 | grep -q "pending"; do sleep 60; done
9
+ *
10
+ * The API then failed. Its error text — `error connecting to api.github.com` —
11
+ * contains no `pending`, so the loop exited, the run reported a settle that had
12
+ * not happened, and the claim had to be retracted to the user in the next
13
+ * reply. The bug is not the sleep or the grep: it is that **absence of the word
14
+ * `pending` was treated as evidence of completion**, and an error is neither
15
+ * settled nor pending.
16
+ *
17
+ * The rule this encodes, and the reason it belongs in one place rather than in
18
+ * every agent's head: `not settled` and `settled` are different from `could not
19
+ * read`, and only the first two may end a wait.
20
+ *
21
+ * Exit codes: 0 = settled, every check succeeded (or was skipped) ·
22
+ * 1 = settled, at least one check failed ·
23
+ * 2 = did not settle within the budget, or the API could not be
24
+ * read — NEVER a verdict, and the reason is printed.
25
+ *
26
+ * Usage: ./scripts-run src/scripts/ci_settle <pr> [--timeout-min N] [--interval-sec N]
27
+ */
28
+
29
+ import { spawnSync } from 'node:child_process';
30
+
31
+ /** What one poll told us. `unreadable` is deliberately not a verdict. */
32
+ export type PollState =
33
+ | { kind: 'unreadable'; reason: string }
34
+ | { kind: 'pending'; total: number; done: number }
35
+ | { kind: 'settled'; failing: string[]; total: number };
36
+
37
+ /** Markers that mean the API did not answer — not that nothing is pending. */
38
+ const _UNREADABLE_MARKERS = [
39
+ 'error connecting to',
40
+ 'could not resolve host',
41
+ 'connection refused',
42
+ 'timeout',
43
+ 'timed out',
44
+ 'bad gateway',
45
+ 'service unavailable',
46
+ 'rate limit',
47
+ 'gh auth login',
48
+ 'not logged into',
49
+ 'HTTP 5',
50
+ ];
51
+
52
+ /**
53
+ * Classify one `gh pr view --json statusCheckRollup` result.
54
+ *
55
+ * Pure, so the failure this file exists to prevent is testable without a
56
+ * network: feed it an API error and it must answer `unreadable`, never
57
+ * `settled`.
58
+ */
59
+ export function classifyPoll(stdout: string, stderr: string, status: number | null): PollState {
60
+ const combined = `${stdout}\n${stderr}`.toLowerCase();
61
+ for (const marker of _UNREADABLE_MARKERS) {
62
+ if (combined.includes(marker.toLowerCase())) {
63
+ return { kind: 'unreadable', reason: marker };
64
+ }
65
+ }
66
+ if (status !== 0) {
67
+ return { kind: 'unreadable', reason: `gh exited ${String(status)}` };
68
+ }
69
+ let rows: { name?: string; conclusion?: string | null; status?: string | null }[];
70
+ try {
71
+ const parsed = JSON.parse(stdout) as { statusCheckRollup?: unknown };
72
+ const roll = parsed.statusCheckRollup;
73
+ if (!Array.isArray(roll)) {
74
+ return { kind: 'unreadable', reason: 'no statusCheckRollup in response' };
75
+ }
76
+ rows = roll as typeof rows;
77
+ } catch {
78
+ return { kind: 'unreadable', reason: 'unparseable JSON' };
79
+ }
80
+ if (rows.length === 0) {
81
+ // Zero checks is not "settled green" — a run that has not registered
82
+ // its checks yet looks exactly like this.
83
+ return { kind: 'pending', total: 0, done: 0 };
84
+ }
85
+ const terminal = (r: (typeof rows)[number]): boolean =>
86
+ typeof r.conclusion === 'string' && r.conclusion.length > 0;
87
+ const done = rows.filter(terminal).length;
88
+ if (done < rows.length) {
89
+ return { kind: 'pending', total: rows.length, done };
90
+ }
91
+ const bad = new Set(['FAILURE', 'TIMED_OUT', 'CANCELLED', 'ACTION_REQUIRED', 'STARTUP_FAILURE']);
92
+ const failing = rows
93
+ .filter((r) => bad.has(String(r.conclusion).toUpperCase()))
94
+ .map((r) => String(r.name ?? '?'));
95
+ return { kind: 'settled', failing, total: rows.length };
96
+ }
97
+
98
+ function poll(pr: string): PollState {
99
+ const r = spawnSync('gh', ['pr', 'view', pr, '--json', 'statusCheckRollup'], {
100
+ encoding: 'utf-8',
101
+ timeout: 60_000,
102
+ });
103
+ return classifyPoll(r.stdout ?? '', r.stderr ?? '', r.status);
104
+ }
105
+
106
+ function sleepSync(seconds: number): void {
107
+ // Deliberately synchronous: this is a CLI whose whole job is to block.
108
+ spawnSync(process.execPath, ['-e', `setTimeout(()=>{}, ${String(seconds * 1000)})`], {
109
+ timeout: (seconds + 5) * 1000,
110
+ });
111
+ }
112
+
113
+ export function main(argv: readonly string[]): number {
114
+ const positional = argv.filter((a) => !a.startsWith('--'));
115
+ const pr = positional[0];
116
+ if (pr === undefined) {
117
+ process.stderr.write('usage: ci_settle <pr> [--timeout-min N] [--interval-sec N]\n');
118
+ return 2;
119
+ }
120
+ const num = (flag: string, dflt: number): number => {
121
+ const i = argv.indexOf(flag);
122
+ if (i === -1) return dflt;
123
+ const v = argv[i + 1];
124
+ const n = v === undefined ? NaN : parseInt(v, 10);
125
+ return Number.isFinite(n) && n > 0 ? n : dflt;
126
+ };
127
+ const timeoutMin = num('--timeout-min', 45);
128
+ const intervalSec = num('--interval-sec', 60);
129
+
130
+ const deadline = Date.now() + timeoutMin * 60_000;
131
+ let unreadableStreak = 0;
132
+
133
+ for (;;) {
134
+ const state = poll(pr);
135
+ if (state.kind === 'settled') {
136
+ if (state.failing.length === 0) {
137
+ process.stdout.write(`ci_settle: SETTLED GREEN — ${String(state.total)} check(s)\n`);
138
+ return 0;
139
+ }
140
+ process.stdout.write(
141
+ `ci_settle: SETTLED RED — ${String(state.failing.length)} of ${String(state.total)} failing:\n` +
142
+ state.failing.map((f) => ` ${f}\n`).join(''),
143
+ );
144
+ return 1;
145
+ }
146
+ if (state.kind === 'unreadable') {
147
+ unreadableStreak += 1;
148
+ process.stdout.write(
149
+ `ci_settle: could not read the API (${state.reason}) — NOT a verdict, still waiting ` +
150
+ `[${String(unreadableStreak)}]\n`,
151
+ );
152
+ } else {
153
+ unreadableStreak = 0;
154
+ process.stdout.write(
155
+ `ci_settle: pending — ${String(state.done)}/${String(state.total)} settled\n`,
156
+ );
157
+ }
158
+ if (Date.now() >= deadline) {
159
+ process.stdout.write(
160
+ `ci_settle: DID NOT SETTLE within ${String(timeoutMin)} min — no verdict is claimed.\n`,
161
+ );
162
+ return 2;
163
+ }
164
+ sleepSync(intervalSec);
165
+ }
166
+ }
167
+
168
+ if (process.argv[1] !== undefined && process.argv[1].endsWith('ci_settle.ts')) {
169
+ process.exitCode = main(process.argv.slice(2));
170
+ }