@webpieces/ai-hook-rules 0.4.839 → 0.4.840

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 (390) hide show
  1. package/README.md +12 -140
  2. package/package.json +7 -15
  3. package/src/adapters/hook-app-fixtures.d.ts +1 -1
  4. package/src/adapters/hook-app-fixtures.js +0 -8
  5. package/src/adapters/hook-app-fixtures.js.map +1 -1
  6. package/src/adapters/hook-core.d.ts +1 -21
  7. package/src/adapters/hook-core.js +22 -341
  8. package/src/adapters/hook-core.js.map +1 -1
  9. package/src/core/load-rules.d.ts +4 -39
  10. package/src/core/load-rules.js +15 -127
  11. package/src/core/load-rules.js.map +1 -1
  12. package/src/core/rules/catch-error-pattern.d.ts +3 -3
  13. package/src/core/rules/catch-error-pattern.js +13 -13
  14. package/src/core/rules/catch-error-pattern.js.map +1 -1
  15. package/src/core/rules/index.d.ts +1 -14
  16. package/src/core/rules/index.js +1 -17
  17. package/src/core/rules/index.js.map +1 -1
  18. package/src/core/rules/match-rule.d.ts +3 -3
  19. package/src/core/rules/match-rule.js +6 -6
  20. package/src/core/rules/match-rule.js.map +1 -1
  21. package/src/core/rules/max-file-lines.d.ts +3 -3
  22. package/src/core/rules/max-file-lines.js +7 -7
  23. package/src/core/rules/max-file-lines.js.map +1 -1
  24. package/src/core/rules/no-any-unknown.d.ts +3 -3
  25. package/src/core/rules/no-any-unknown.js +6 -6
  26. package/src/core/rules/no-any-unknown.js.map +1 -1
  27. package/src/core/rules/no-custom-css.d.ts +3 -3
  28. package/src/core/rules/no-custom-css.js +7 -7
  29. package/src/core/rules/no-custom-css.js.map +1 -1
  30. package/src/core/rules/no-destructure.d.ts +3 -3
  31. package/src/core/rules/no-destructure.js +7 -7
  32. package/src/core/rules/no-destructure.js.map +1 -1
  33. package/src/core/rules/no-implicit-any.d.ts +3 -3
  34. package/src/core/rules/no-implicit-any.js +6 -6
  35. package/src/core/rules/no-implicit-any.js.map +1 -1
  36. package/src/core/rules/no-js-files.d.ts +3 -3
  37. package/src/core/rules/no-js-files.js +6 -6
  38. package/src/core/rules/no-js-files.js.map +1 -1
  39. package/src/core/rules/no-process-exit-outside-main.d.ts +3 -3
  40. package/src/core/rules/no-process-exit-outside-main.js +7 -7
  41. package/src/core/rules/no-process-exit-outside-main.js.map +1 -1
  42. package/src/core/rules/no-symbol-di-tokens.d.ts +3 -3
  43. package/src/core/rules/no-symbol-di-tokens.js +7 -7
  44. package/src/core/rules/no-symbol-di-tokens.js.map +1 -1
  45. package/src/core/rules/no-unmanaged-exceptions.d.ts +3 -3
  46. package/src/core/rules/no-unmanaged-exceptions.js +9 -9
  47. package/src/core/rules/no-unmanaged-exceptions.js.map +1 -1
  48. package/src/core/rules/require-return-type.d.ts +3 -3
  49. package/src/core/rules/require-return-type.js +6 -6
  50. package/src/core/rules/require-return-type.js.map +1 -1
  51. package/src/core/rules/throw-cause-required.d.ts +3 -3
  52. package/src/core/rules/throw-cause-required.js +9 -9
  53. package/src/core/rules/throw-cause-required.js.map +1 -1
  54. package/src/core/rules/validate-ts-in-src.d.ts +3 -3
  55. package/src/core/rules/validate-ts-in-src.js +7 -7
  56. package/src/core/rules/validate-ts-in-src.js.map +1 -1
  57. package/src/core/runner.d.ts +10 -19
  58. package/src/core/runner.js +24 -622
  59. package/src/core/runner.js.map +1 -1
  60. package/src/index.d.ts +2 -15
  61. package/src/index.js +4 -54
  62. package/src/index.js.map +1 -1
  63. package/openclaw.plugin.json +0 -15
  64. package/src/adapters/agent-adapters.d.ts +0 -13
  65. package/src/adapters/agent-adapters.js +0 -23
  66. package/src/adapters/agent-adapters.js.map +0 -1
  67. package/src/adapters/agent-payload.d.ts +0 -48
  68. package/src/adapters/agent-payload.js +0 -30
  69. package/src/adapters/agent-payload.js.map +0 -1
  70. package/src/adapters/agent-response.d.ts +0 -5
  71. package/src/adapters/agent-response.js +0 -86
  72. package/src/adapters/agent-response.js.map +0 -1
  73. package/src/adapters/claude-code-adapter.d.ts +0 -26
  74. package/src/adapters/claude-code-adapter.js +0 -69
  75. package/src/adapters/claude-code-adapter.js.map +0 -1
  76. package/src/adapters/codex-adapter.d.ts +0 -19
  77. package/src/adapters/codex-adapter.js +0 -48
  78. package/src/adapters/codex-adapter.js.map +0 -1
  79. package/src/adapters/codex-subagent-guard.d.ts +0 -45
  80. package/src/adapters/codex-subagent-guard.js +0 -88
  81. package/src/adapters/codex-subagent-guard.js.map +0 -1
  82. package/src/adapters/detect-ai.d.ts +0 -70
  83. package/src/adapters/detect-ai.js +0 -82
  84. package/src/adapters/detect-ai.js.map +0 -1
  85. package/src/adapters/guards-hook.d.ts +0 -3
  86. package/src/adapters/guards-hook.js +0 -30
  87. package/src/adapters/guards-hook.js.map +0 -1
  88. package/src/adapters/openclaw-plugin.d.ts +0 -14
  89. package/src/adapters/openclaw-plugin.js +0 -87
  90. package/src/adapters/openclaw-plugin.js.map +0 -1
  91. package/src/adapters/review-identity-stamper.d.ts +0 -20
  92. package/src/adapters/review-identity-stamper.js +0 -34
  93. package/src/adapters/review-identity-stamper.js.map +0 -1
  94. package/src/bin/codex-trust.d.ts +0 -105
  95. package/src/bin/codex-trust.js +0 -205
  96. package/src/bin/codex-trust.js.map +0 -1
  97. package/src/bin/dev-hook-install.d.ts +0 -1
  98. package/src/bin/dev-hook-install.js +0 -82
  99. package/src/bin/dev-hook-install.js.map +0 -1
  100. package/src/bin/dev-hook-uninstall.d.ts +0 -1
  101. package/src/bin/dev-hook-uninstall.js +0 -45
  102. package/src/bin/dev-hook-uninstall.js.map +0 -1
  103. package/src/bin/hook-registration.d.ts +0 -429
  104. package/src/bin/hook-registration.js +0 -661
  105. package/src/bin/hook-registration.js.map +0 -1
  106. package/src/bin/install-entry.d.ts +0 -19
  107. package/src/bin/install-entry.js +0 -128
  108. package/src/bin/install-entry.js.map +0 -1
  109. package/src/bin/l0-allowlist.d.ts +0 -49
  110. package/src/bin/l0-allowlist.js +0 -528
  111. package/src/bin/l0-allowlist.js.map +0 -1
  112. package/src/bin/l0-codex-read.d.ts +0 -21
  113. package/src/bin/l0-codex-read.js +0 -109
  114. package/src/bin/l0-codex-read.js.map +0 -1
  115. package/src/bin/l0-decide.d.ts +0 -50
  116. package/src/bin/l0-decide.js +0 -103
  117. package/src/bin/l0-decide.js.map +0 -1
  118. package/src/bin/l0-entry.d.ts +0 -103
  119. package/src/bin/l0-entry.js +0 -98
  120. package/src/bin/l0-entry.js.map +0 -1
  121. package/src/bin/l0-ignored-tools.d.ts +0 -38
  122. package/src/bin/l0-ignored-tools.js +0 -44
  123. package/src/bin/l0-ignored-tools.js.map +0 -1
  124. package/src/bin/managed-env.d.ts +0 -46
  125. package/src/bin/managed-env.js +0 -50
  126. package/src/bin/managed-env.js.map +0 -1
  127. package/src/bin/neighbour-hooks.d.ts +0 -42
  128. package/src/bin/neighbour-hooks.js +0 -177
  129. package/src/bin/neighbour-hooks.js.map +0 -1
  130. package/src/bin/reviewer-agent.d.ts +0 -19
  131. package/src/bin/reviewer-agent.js +0 -135
  132. package/src/bin/reviewer-agent.js.map +0 -1
  133. package/src/bin/settings-shape.d.ts +0 -37
  134. package/src/bin/settings-shape.js +0 -17
  135. package/src/bin/settings-shape.js.map +0 -1
  136. package/src/bin/setup-config.d.ts +0 -19
  137. package/src/bin/setup-config.js +0 -370
  138. package/src/bin/setup-config.js.map +0 -1
  139. package/src/bin/setup.d.ts +0 -78
  140. package/src/bin/setup.js +0 -400
  141. package/src/bin/setup.js.map +0 -1
  142. package/src/bin/shim-audit-log.d.ts +0 -119
  143. package/src/bin/shim-audit-log.js +0 -286
  144. package/src/bin/shim-audit-log.js.map +0 -1
  145. package/src/bin/shim-deny-reason.d.ts +0 -1
  146. package/src/bin/shim-deny-reason.js +0 -244
  147. package/src/bin/shim-deny-reason.js.map +0 -1
  148. package/src/bin/shim-drift-fix.d.ts +0 -1
  149. package/src/bin/shim-drift-fix.js +0 -72
  150. package/src/bin/shim-drift-fix.js.map +0 -1
  151. package/src/bin/shim-testkit.d.ts +0 -107
  152. package/src/bin/shim-testkit.js +0 -197
  153. package/src/bin/shim-testkit.js.map +0 -1
  154. package/src/bin/shim-version-drift.d.ts +0 -1
  155. package/src/bin/shim-version-drift.js +0 -164
  156. package/src/bin/shim-version-drift.js.map +0 -1
  157. package/src/bin/shim.d.ts +0 -16
  158. package/src/bin/shim.js +0 -636
  159. package/src/bin/shim.js.map +0 -1
  160. package/src/bin/upgrade-shim.d.ts +0 -18
  161. package/src/bin/upgrade-shim.js +0 -283
  162. package/src/bin/upgrade-shim.js.map +0 -1
  163. package/src/core/ai-type-context.d.ts +0 -36
  164. package/src/core/ai-type-context.js +0 -45
  165. package/src/core/ai-type-context.js.map +0 -1
  166. package/src/core/apply-patch-parse.d.ts +0 -36
  167. package/src/core/apply-patch-parse.js +0 -154
  168. package/src/core/apply-patch-parse.js.map +0 -1
  169. package/src/core/build-context.d.ts +0 -10
  170. package/src/core/build-context.js +0 -66
  171. package/src/core/build-context.js.map +0 -1
  172. package/src/core/command-scan.d.ts +0 -122
  173. package/src/core/command-scan.js +0 -282
  174. package/src/core/command-scan.js.map +0 -1
  175. package/src/core/custom-rule-adapter.d.ts +0 -22
  176. package/src/core/custom-rule-adapter.js +0 -50
  177. package/src/core/custom-rule-adapter.js.map +0 -1
  178. package/src/core/decision-log.d.ts +0 -190
  179. package/src/core/decision-log.js +0 -406
  180. package/src/core/decision-log.js.map +0 -1
  181. package/src/core/delete-scoped-rules.d.ts +0 -8
  182. package/src/core/delete-scoped-rules.js +0 -31
  183. package/src/core/delete-scoped-rules.js.map +0 -1
  184. package/src/core/disable-directives.d.ts +0 -8
  185. package/src/core/disable-directives.js +0 -80
  186. package/src/core/disable-directives.js.map +0 -1
  187. package/src/core/effective-tree.d.ts +0 -204
  188. package/src/core/effective-tree.js +0 -277
  189. package/src/core/effective-tree.js.map +0 -1
  190. package/src/core/excluded-path-escape.d.ts +0 -101
  191. package/src/core/excluded-path-escape.js +0 -236
  192. package/src/core/excluded-path-escape.js.map +0 -1
  193. package/src/core/excluded-paths.d.ts +0 -23
  194. package/src/core/excluded-paths.js +0 -54
  195. package/src/core/excluded-paths.js.map +0 -1
  196. package/src/core/fix-hint.d.ts +0 -40
  197. package/src/core/fix-hint.js +0 -53
  198. package/src/core/fix-hint.js.map +0 -1
  199. package/src/core/force-to-root.d.ts +0 -32
  200. package/src/core/force-to-root.js +0 -60
  201. package/src/core/force-to-root.js.map +0 -1
  202. package/src/core/guard-index-doc.d.ts +0 -63
  203. package/src/core/guard-index-doc.js +0 -172
  204. package/src/core/guard-index-doc.js.map +0 -1
  205. package/src/core/instruct-ai-writer.d.ts +0 -1
  206. package/src/core/instruct-ai-writer.js +0 -6
  207. package/src/core/instruct-ai-writer.js.map +0 -1
  208. package/src/core/l0-fault-codes.d.ts +0 -85
  209. package/src/core/l0-fault-codes.js +0 -121
  210. package/src/core/l0-fault-codes.js.map +0 -1
  211. package/src/core/l0-matrix.d.ts +0 -114
  212. package/src/core/l0-matrix.js +0 -416
  213. package/src/core/l0-matrix.js.map +0 -1
  214. package/src/core/l0-tooling-doc.d.ts +0 -45
  215. package/src/core/l0-tooling-doc.js +0 -258
  216. package/src/core/l0-tooling-doc.js.map +0 -1
  217. package/src/core/l1-doc.d.ts +0 -7
  218. package/src/core/l1-doc.js +0 -340
  219. package/src/core/l1-doc.js.map +0 -1
  220. package/src/core/l1-matrix-doc.d.ts +0 -31
  221. package/src/core/l1-matrix-doc.js +0 -111
  222. package/src/core/l1-matrix-doc.js.map +0 -1
  223. package/src/core/l1-rows.d.ts +0 -167
  224. package/src/core/l1-rows.js +0 -262
  225. package/src/core/l1-rows.js.map +0 -1
  226. package/src/core/l2-doc.d.ts +0 -7
  227. package/src/core/l2-doc.js +0 -385
  228. package/src/core/l2-doc.js.map +0 -1
  229. package/src/core/l2-matrix-doc.d.ts +0 -23
  230. package/src/core/l2-matrix-doc.js +0 -72
  231. package/src/core/l2-matrix-doc.js.map +0 -1
  232. package/src/core/l2-row.d.ts +0 -54
  233. package/src/core/l2-row.js +0 -75
  234. package/src/core/l2-row.js.map +0 -1
  235. package/src/core/l2-rows.d.ts +0 -56
  236. package/src/core/l2-rows.js +0 -272
  237. package/src/core/l2-rows.js.map +0 -1
  238. package/src/core/load-config.d.ts +0 -1
  239. package/src/core/load-config.js +0 -9
  240. package/src/core/load-config.js.map +0 -1
  241. package/src/core/log-stream.d.ts +0 -117
  242. package/src/core/log-stream.js +0 -156
  243. package/src/core/log-stream.js.map +0 -1
  244. package/src/core/log-streams.d.ts +0 -48
  245. package/src/core/log-streams.js +0 -55
  246. package/src/core/log-streams.js.map +0 -1
  247. package/src/core/log-target.d.ts +0 -21
  248. package/src/core/log-target.js +0 -29
  249. package/src/core/log-target.js.map +0 -1
  250. package/src/core/main-sync-log.d.ts +0 -16
  251. package/src/core/main-sync-log.js +0 -105
  252. package/src/core/main-sync-log.js.map +0 -1
  253. package/src/core/main-sync-refresh.d.ts +0 -39
  254. package/src/core/main-sync-refresh.js +0 -96
  255. package/src/core/main-sync-refresh.js.map +0 -1
  256. package/src/core/main-sync-timeout.d.ts +0 -32
  257. package/src/core/main-sync-timeout.js +0 -94
  258. package/src/core/main-sync-timeout.js.map +0 -1
  259. package/src/core/matrix-cures.d.ts +0 -12
  260. package/src/core/matrix-cures.js +0 -56
  261. package/src/core/matrix-cures.js.map +0 -1
  262. package/src/core/missing-directory.d.ts +0 -38
  263. package/src/core/missing-directory.js +0 -66
  264. package/src/core/missing-directory.js.map +0 -1
  265. package/src/core/read-only-inspection.d.ts +0 -34
  266. package/src/core/read-only-inspection.js +0 -88
  267. package/src/core/read-only-inspection.js.map +0 -1
  268. package/src/core/rejection-log.d.ts +0 -9
  269. package/src/core/rejection-log.js +0 -258
  270. package/src/core/rejection-log.js.map +0 -1
  271. package/src/core/report.d.ts +0 -21
  272. package/src/core/report.js +0 -73
  273. package/src/core/report.js.map +0 -1
  274. package/src/core/rule-base.d.ts +0 -39
  275. package/src/core/rule-base.js +0 -36
  276. package/src/core/rule-base.js.map +0 -1
  277. package/src/core/rules/branch-creation-guard.d.ts +0 -113
  278. package/src/core/rules/branch-creation-guard.js +0 -422
  279. package/src/core/rules/branch-creation-guard.js.map +0 -1
  280. package/src/core/rules/branch-switch-scan.d.ts +0 -43
  281. package/src/core/rules/branch-switch-scan.js +0 -132
  282. package/src/core/rules/branch-switch-scan.js.map +0 -1
  283. package/src/core/rules/build-output-pipe-guard.d.ts +0 -56
  284. package/src/core/rules/build-output-pipe-guard.js +0 -120
  285. package/src/core/rules/build-output-pipe-guard.js.map +0 -1
  286. package/src/core/rules/build-output-pipe-scan.d.ts +0 -47
  287. package/src/core/rules/build-output-pipe-scan.js +0 -84
  288. package/src/core/rules/build-output-pipe-scan.js.map +0 -1
  289. package/src/core/rules/cap-remedies.d.ts +0 -39
  290. package/src/core/rules/cap-remedies.js +0 -59
  291. package/src/core/rules/cap-remedies.js.map +0 -1
  292. package/src/core/rules/commit-message-substitution-guard.d.ts +0 -72
  293. package/src/core/rules/commit-message-substitution-guard.js +0 -134
  294. package/src/core/rules/commit-message-substitution-guard.js.map +0 -1
  295. package/src/core/rules/commit-message-substitution-scan.d.ts +0 -42
  296. package/src/core/rules/commit-message-substitution-scan.js +0 -145
  297. package/src/core/rules/commit-message-substitution-scan.js.map +0 -1
  298. package/src/core/rules/content-read-scan.d.ts +0 -76
  299. package/src/core/rules/content-read-scan.js +0 -176
  300. package/src/core/rules/content-read-scan.js.map +0 -1
  301. package/src/core/rules/cure-prefix-scan.d.ts +0 -64
  302. package/src/core/rules/cure-prefix-scan.js +0 -133
  303. package/src/core/rules/cure-prefix-scan.js.map +0 -1
  304. package/src/core/rules/feature-branch-guard.d.ts +0 -121
  305. package/src/core/rules/feature-branch-guard.js +0 -326
  306. package/src/core/rules/feature-branch-guard.js.map +0 -1
  307. package/src/core/rules/judged-tree.d.ts +0 -66
  308. package/src/core/rules/judged-tree.js +0 -97
  309. package/src/core/rules/judged-tree.js.map +0 -1
  310. package/src/core/rules/main-freshness.d.ts +0 -37
  311. package/src/core/rules/main-freshness.js +0 -61
  312. package/src/core/rules/main-freshness.js.map +0 -1
  313. package/src/core/rules/merge-in-progress-guard.d.ts +0 -17
  314. package/src/core/rules/merge-in-progress-guard.js +0 -122
  315. package/src/core/rules/merge-in-progress-guard.js.map +0 -1
  316. package/src/core/rules/merged-branch-bash-guard.d.ts +0 -62
  317. package/src/core/rules/merged-branch-bash-guard.js +0 -170
  318. package/src/core/rules/merged-branch-bash-guard.js.map +0 -1
  319. package/src/core/rules/merged-branch-message.d.ts +0 -59
  320. package/src/core/rules/merged-branch-message.js +0 -137
  321. package/src/core/rules/merged-branch-message.js.map +0 -1
  322. package/src/core/rules/pr-creation-or-push-guard.d.ts +0 -26
  323. package/src/core/rules/pr-creation-or-push-guard.js +0 -146
  324. package/src/core/rules/pr-creation-or-push-guard.js.map +0 -1
  325. package/src/core/rules/pr-merge-guard.d.ts +0 -36
  326. package/src/core/rules/pr-merge-guard.js +0 -86
  327. package/src/core/rules/pr-merge-guard.js.map +0 -1
  328. package/src/core/rules/read-stale-guard.d.ts +0 -136
  329. package/src/core/rules/read-stale-guard.js +0 -326
  330. package/src/core/rules/read-stale-guard.js.map +0 -1
  331. package/src/core/rules/recovery-allowlist.d.ts +0 -49
  332. package/src/core/rules/recovery-allowlist.js +0 -187
  333. package/src/core/rules/recovery-allowlist.js.map +0 -1
  334. package/src/core/rules/redirect-how-to-merge-main.d.ts +0 -16
  335. package/src/core/rules/redirect-how-to-merge-main.js +0 -157
  336. package/src/core/rules/redirect-how-to-merge-main.js.map +0 -1
  337. package/src/core/rules/shell-segment-scan.d.ts +0 -64
  338. package/src/core/rules/shell-segment-scan.js +0 -88
  339. package/src/core/rules/shell-segment-scan.js.map +0 -1
  340. package/src/core/rules/stale-main-bash-guard.d.ts +0 -198
  341. package/src/core/rules/stale-main-bash-guard.js +0 -361
  342. package/src/core/rules/stale-main-bash-guard.js.map +0 -1
  343. package/src/core/rules/stale-main-message.d.ts +0 -62
  344. package/src/core/rules/stale-main-message.js +0 -102
  345. package/src/core/rules/stale-main-message.js.map +0 -1
  346. package/src/core/rules/tree-recovery.d.ts +0 -92
  347. package/src/core/rules/tree-recovery.js +0 -165
  348. package/src/core/rules/tree-recovery.js.map +0 -1
  349. package/src/core/rules/wait-spin-guard.d.ts +0 -128
  350. package/src/core/rules/wait-spin-guard.js +0 -211
  351. package/src/core/rules/wait-spin-guard.js.map +0 -1
  352. package/src/core/rules/wait-spin-scan.d.ts +0 -118
  353. package/src/core/rules/wait-spin-scan.js +0 -203
  354. package/src/core/rules/wait-spin-scan.js.map +0 -1
  355. package/src/core/rules/whole-repo-build-guard.d.ts +0 -125
  356. package/src/core/rules/whole-repo-build-guard.js +0 -257
  357. package/src/core/rules/whole-repo-build-guard.js.map +0 -1
  358. package/src/core/rules/whole-repo-build-scan.d.ts +0 -28
  359. package/src/core/rules/whole-repo-build-scan.js +0 -198
  360. package/src/core/rules/whole-repo-build-scan.js.map +0 -1
  361. package/src/core/session-call-history.d.ts +0 -44
  362. package/src/core/session-call-history.js +0 -79
  363. package/src/core/session-call-history.js.map +0 -1
  364. package/src/core/shell-read-parity.d.ts +0 -56
  365. package/src/core/shell-read-parity.js +0 -155
  366. package/src/core/shell-read-parity.js.map +0 -1
  367. package/src/core/strip-ts-noise.d.ts +0 -1
  368. package/src/core/strip-ts-noise.js +0 -185
  369. package/src/core/strip-ts-noise.js.map +0 -1
  370. package/src/core/sync-main.d.ts +0 -46
  371. package/src/core/sync-main.js +0 -175
  372. package/src/core/sync-main.js.map +0 -1
  373. package/src/core/target-tree.d.ts +0 -84
  374. package/src/core/target-tree.js +0 -148
  375. package/src/core/target-tree.js.map +0 -1
  376. package/src/core/to-error.d.ts +0 -5
  377. package/src/core/to-error.js +0 -37
  378. package/src/core/to-error.js.map +0 -1
  379. package/src/core/types.d.ts +0 -152
  380. package/src/core/types.js +0 -200
  381. package/src/core/types.js.map +0 -1
  382. package/src/core/version-sync.d.ts +0 -219
  383. package/src/core/version-sync.js +0 -558
  384. package/src/core/version-sync.js.map +0 -1
  385. package/src/core/webpieces-versions.d.ts +0 -98
  386. package/src/core/webpieces-versions.js +0 -206
  387. package/src/core/webpieces-versions.js.map +0 -1
  388. package/templates/ai-hook.sh +0 -497
  389. package/templates/claude-settings-hook.json +0 -28
  390. package/templates/webpieces-reviewer.md +0 -60
@@ -1,60 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ForceToRootGuard = void 0;
4
- exports.gitFromSubdirBlock = gitFromSubdirBlock;
5
- const tslib_1 = require("tslib");
6
- const path = tslib_1.__importStar(require("path"));
7
- const effective_tree_1 = require("./effective-tree");
8
- const types_1 = require("./types");
9
- /**
10
- * L1 row 5: git/gh commands must run from the repo root of the tree they act on, where the guards can
11
- * reason about git state coherently. guards/L1-location.md carries the table and the use cases; change
12
- * this predicate and that file is stale until you update it.
13
- *
14
- * ONE variable decides it: `tree.effectiveCwd` — the directory the command actually runs in, which is
15
- * the shell's cwd unless the command leads with `cd <dir> &&`. Root or not-root, nothing else.
16
- *
17
- * It used to be `shellAtRoot || cdsToRoot`, two variables OR'd, and that produced opposite verdicts for
18
- * the same destination: `git status` with the shell in packages/http/ was BLOCKED, while
19
- * `cd packages/http && git status` from the root was ALLOWED, because shellAtRoot short-circuited before
20
- * the destination was ever considered. An agent that cd's INTO a subdir has the same broken mental model
21
- * as one stranded there, so it gets the same answer now.
22
- *
23
- * The remedy is ONE runnable line, `cd <root> && <the work>`, not "cd first, then re-run" — that advice
24
- * made this guard print the very command it had just rejected, and a `cd` is unreliable in both
25
- * directions (INTO this repo it sticks; OUT of it the harness resets it).
26
- *
27
- * It goes through remedyAtRoot(), NOT bare atRoot(), and that is load-bearing: A REMEDY MUST SATISFY THE
28
- * PREDICATE THAT PRINTED IT. Prefixing `cd '<root>' &&` onto a command already leading with
29
- * `cd <elsewhere> &&` left effectiveCwd in `<elsewhere>`, so the identical block fired on the remedy with
30
- * the prefix doubled, then tripled. remedyAtRoot REPLACES the leading `cd` run instead, and
31
- * effective-tree.spec.ts asserts that property for every L1 remedy, not just this one.
32
- */
33
- class ForceToRootGuard {
34
- resolver = new effective_tree_1.EffectiveTreeResolver();
35
- /** The deny report, or null to allow. */
36
- block(command, tree, isGitOrGh) {
37
- const targetAtRoot = path.resolve(tree.effectiveCwd) === path.resolve(tree.root);
38
- if (!isGitOrGh || targetAtRoot)
39
- return null;
40
- return [
41
- '❌ Run git/gh commands from the repo root, not a subdirectory.',
42
- ` Command runs in: ${tree.effectiveCwd}`,
43
- ` Judged against: ${tree.root}`,
44
- ' Run EXACTLY this instead, as ONE line (a bare `cd` in a separate call is not equivalent —',
45
- ' a `cd` inside this repo STICKS for later calls, and a `cd` out of it is reset by the harness):',
46
- ` ${this.resolver.remedyAtRoot(tree.root, command)}`,
47
- ' A leading `cd <path> &&` is ACCEPTED by the guards — it cannot change what the command',
48
- " does to the repo. (The webpieces guards evaluate the repo's git state at its root.)",
49
- ].join('\n');
50
- }
51
- }
52
- exports.ForceToRootGuard = ForceToRootGuard;
53
- // L1 row 5's dispatch entry, beside the guard it wraps — see missing-directory.ts for why these live
54
- // with their guard rather than in runner.ts.
55
- // webpieces-disable no-function-outside-class -- the one-line runner entry point for the class above, beside it
56
- function gitFromSubdirBlock(command, tree, isGitOrGh) {
57
- const report = new ForceToRootGuard().block(command, tree, isGitOrGh);
58
- return report === null ? null : new types_1.BlockedResult(report);
59
- }
60
- //# sourceMappingURL=force-to-root.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"force-to-root.js","sourceRoot":"","sources":["../../../../../../packages/tooling/ai-hook-rules/src/core/force-to-root.ts"],"names":[],"mappings":";;;AAoDA,gDAGC;;AAvDD,mDAA6B;AAE7B,qDAAwE;AACxE,mCAAwC;AAExC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAa,gBAAgB;IACR,QAAQ,GAAG,IAAI,sCAAqB,EAAE,CAAC;IAExD,yCAAyC;IACzC,KAAK,CAAC,OAAe,EAAE,IAAmB,EAAE,SAAkB;QAC1D,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjF,IAAI,CAAC,SAAS,IAAI,YAAY;YAAE,OAAO,IAAI,CAAC;QAC5C,OAAO;YACH,+DAA+D;YAC/D,uBAAuB,IAAI,CAAC,YAAY,EAAE;YAC1C,sBAAsB,IAAI,CAAC,IAAI,EAAE;YACjC,8FAA8F;YAC9F,mGAAmG;YACnG,QAAQ,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE;YACxD,2FAA2F;YAC3F,wFAAwF;SAC3F,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjB,CAAC;CACJ;AAlBD,4CAkBC;AAED,qGAAqG;AACrG,6CAA6C;AAC7C,gHAAgH;AAChH,SAAgB,kBAAkB,CAAC,OAAe,EAAE,IAAmB,EAAE,SAAkB;IACvF,MAAM,MAAM,GAAG,IAAI,gBAAgB,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;IACtE,OAAO,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,qBAAa,CAAC,MAAM,CAAC,CAAC;AAC9D,CAAC","sourcesContent":["import * as path from 'path';\n\nimport { EffectiveTree, EffectiveTreeResolver } from './effective-tree';\nimport { BlockedResult } from './types';\n\n/**\n * L1 row 5: git/gh commands must run from the repo root of the tree they act on, where the guards can\n * reason about git state coherently. guards/L1-location.md carries the table and the use cases; change\n * this predicate and that file is stale until you update it.\n *\n * ONE variable decides it: `tree.effectiveCwd` — the directory the command actually runs in, which is\n * the shell's cwd unless the command leads with `cd <dir> &&`. Root or not-root, nothing else.\n *\n * It used to be `shellAtRoot || cdsToRoot`, two variables OR'd, and that produced opposite verdicts for\n * the same destination: `git status` with the shell in packages/http/ was BLOCKED, while\n * `cd packages/http && git status` from the root was ALLOWED, because shellAtRoot short-circuited before\n * the destination was ever considered. An agent that cd's INTO a subdir has the same broken mental model\n * as one stranded there, so it gets the same answer now.\n *\n * The remedy is ONE runnable line, `cd <root> && <the work>`, not \"cd first, then re-run\" — that advice\n * made this guard print the very command it had just rejected, and a `cd` is unreliable in both\n * directions (INTO this repo it sticks; OUT of it the harness resets it).\n *\n * It goes through remedyAtRoot(), NOT bare atRoot(), and that is load-bearing: A REMEDY MUST SATISFY THE\n * PREDICATE THAT PRINTED IT. Prefixing `cd '<root>' &&` onto a command already leading with\n * `cd <elsewhere> &&` left effectiveCwd in `<elsewhere>`, so the identical block fired on the remedy with\n * the prefix doubled, then tripled. remedyAtRoot REPLACES the leading `cd` run instead, and\n * effective-tree.spec.ts asserts that property for every L1 remedy, not just this one.\n */\nexport class ForceToRootGuard {\n private readonly resolver = new EffectiveTreeResolver();\n\n /** The deny report, or null to allow. */\n block(command: string, tree: EffectiveTree, isGitOrGh: boolean): string | null {\n const targetAtRoot = path.resolve(tree.effectiveCwd) === path.resolve(tree.root);\n if (!isGitOrGh || targetAtRoot) return null;\n return [\n '❌ Run git/gh commands from the repo root, not a subdirectory.',\n ` Command runs in: ${tree.effectiveCwd}`,\n ` Judged against: ${tree.root}`,\n ' Run EXACTLY this instead, as ONE line (a bare `cd` in a separate call is not equivalent —',\n ' a `cd` inside this repo STICKS for later calls, and a `cd` out of it is reset by the harness):',\n ` ${this.resolver.remedyAtRoot(tree.root, command)}`,\n ' A leading `cd <path> &&` is ACCEPTED by the guards — it cannot change what the command',\n \" does to the repo. (The webpieces guards evaluate the repo's git state at its root.)\",\n ].join('\\n');\n }\n}\n\n// L1 row 5's dispatch entry, beside the guard it wraps — see missing-directory.ts for why these live\n// with their guard rather than in runner.ts.\n// webpieces-disable no-function-outside-class -- the one-line runner entry point for the class above, beside it\nexport function gitFromSubdirBlock(command: string, tree: EffectiveTree, isGitOrGh: boolean): BlockedResult | null {\n const report = new ForceToRootGuard().block(command, tree, isGitOrGh);\n return report === null ? null : new BlockedResult(report);\n}\n"]}
@@ -1,63 +0,0 @@
1
- /** Opening marker of the generated block, as it appears in GUARD_MATRIX.md. */
2
- export declare const GUARD_INDEX_BEGIN = "<!-- BEGIN GENERATED \u2014 GuardIndexDoc.render() in ai-hook-rules/src/core/guard-index-doc.ts; run `pnpm guards:generate` -->";
3
- /** Closing marker. Everything between the two is machine-owned; everything outside is prose. */
4
- export declare const GUARD_INDEX_END = "<!-- END GENERATED \u2014 hand-written prose resumes here -->";
5
- /** How much of a layer's doc is rendered from code. Data-only → a class, per CLAUDE.md. */
6
- export declare class LayerGeneration {
7
- /** `L0`, `L1`, … as the doc prints it. */
8
- readonly layer: string;
9
- /** The question this layer answers, for the layer table. */
10
- readonly goal: string;
11
- /** The `webpieces.config.json` key, or '' when the layer has none on purpose. */
12
- readonly configKey: string;
13
- /** Repo-relative path of the layer's doc. */
14
- readonly doc: string;
15
- /** The array the doc is rendered FROM, or '' when nothing is generated yet. */
16
- readonly source: string;
17
- /** The status cell, verbatim. */
18
- readonly status: string;
19
- constructor(
20
- /** `L0`, `L1`, … as the doc prints it. */
21
- layer: string,
22
- /** The question this layer answers, for the layer table. */
23
- goal: string,
24
- /** The `webpieces.config.json` key, or '' when the layer has none on purpose. */
25
- configKey: string,
26
- /** Repo-relative path of the layer's doc. */
27
- doc: string,
28
- /** The array the doc is rendered FROM, or '' when nothing is generated yet. */
29
- source: string,
30
- /** The status cell, verbatim. */
31
- status: string);
32
- /** The config-key cell — layers with no key say so, and say it is deliberate. */
33
- keyCell(): string;
34
- sourceCell(): string;
35
- }
36
- /**
37
- * THE FIVE LAYERS, and how much of each doc is machine-owned.
38
- *
39
- * Adding a layer, or converting one to generated, is an edit HERE and nowhere else — the index table,
40
- * the layer table and the one-command sentence all render from this array, so they cannot disagree
41
- * with each other the way the hand-written version did.
42
- */
43
- export declare const LAYER_GENERATION: readonly LayerGeneration[];
44
- /**
45
- * The generated block of GUARD_MATRIX.md, and the splice that puts it there.
46
- *
47
- * Same class shape as L0ToolingDoc — renderer, extractor and splicer as one unit, driven by one spec.
48
- */
49
- export declare class GuardIndexDoc {
50
- /** The whole generated block, WITHOUT the markers — those belong to the file, not the renderer. */
51
- render(): string;
52
- /**
53
- * The generated text of `doc`, exactly as committed. Throws when a marker is missing or doubled —
54
- * a silently-unspliced doc is the drift this arrangement exists to end.
55
- */
56
- extract(doc: string): string;
57
- /** `doc` with the generated block replaced by today's render. Preserves every byte outside it. */
58
- splice(doc: string): string;
59
- private preamble;
60
- private statusTable;
61
- private layerTable;
62
- private generatedWholeCount;
63
- }
@@ -1,172 +0,0 @@
1
- "use strict";
2
- // ---------------------------------------------------------------------------
3
- // GUARD_MATRIX.md's generation-status block, rendered from the one array that knows.
4
- //
5
- // THE BUG THIS FIXES IS IN THE FILE ITSELF. GUARD_MATRIX.md is the INDEX — the page that tells you
6
- // which layer docs are generated and which are hand-written — and it was hand-written, so it went out
7
- // of date about generation. It ended up contradicting itself inside ten lines: a blockquote asserting
8
- // "L1's table ... generated" and "EVERY REMAINING LAYER FILE IS HAND-WRITTEN TODAY", directly above a
9
- // table listing L2 as generated and byte-locked. Both were once true; L2 was converted and only one of
10
- // the two places was updated.
11
- //
12
- // A doc that describes generation is exactly the doc that must be generated, because it is the one
13
- // place a reader goes to find out whether to trust the others. So the STATUS is data here, the block
14
- // between the markers is spliced from it, and a spec byte-locks the result — the same treatment
15
- // guards/L0-tooling.md gets, and for the same reason: everything outside the markers stays
16
- // hand-written prose that the splice preserves byte for byte.
17
- //
18
- // WHAT IS DELIBERATELY NOT GENERATED: the rest of GUARD_MATRIX.md — the action codebook, the launch
19
- // guarantee, the two rules that constrain guard changes. Those are prose about DESIGN, not facts about
20
- // the code, and a generator that owns them would be inventing a schema for essays.
21
- // ---------------------------------------------------------------------------
22
- Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.GuardIndexDoc = exports.LAYER_GENERATION = exports.LayerGeneration = exports.GUARD_INDEX_END = exports.GUARD_INDEX_BEGIN = void 0;
24
- /** Opening marker of the generated block, as it appears in GUARD_MATRIX.md. */
25
- exports.GUARD_INDEX_BEGIN = '<!-- BEGIN GENERATED — GuardIndexDoc.render() in ai-hook-rules/src/core/guard-index-doc.ts; run `pnpm guards:generate` -->';
26
- /** Closing marker. Everything between the two is machine-owned; everything outside is prose. */
27
- exports.GUARD_INDEX_END = '<!-- END GENERATED — hand-written prose resumes here -->';
28
- /** How much of a layer's doc is rendered from code. Data-only → a class, per CLAUDE.md. */
29
- class LayerGeneration {
30
- layer;
31
- goal;
32
- configKey;
33
- doc;
34
- source;
35
- status;
36
- // eslint-disable-next-line @typescript-eslint/max-params -- the five cells of one status row
37
- constructor(
38
- /** `L0`, `L1`, … as the doc prints it. */
39
- layer,
40
- /** The question this layer answers, for the layer table. */
41
- goal,
42
- /** The `webpieces.config.json` key, or '' when the layer has none on purpose. */
43
- configKey,
44
- /** Repo-relative path of the layer's doc. */
45
- doc,
46
- /** The array the doc is rendered FROM, or '' when nothing is generated yet. */
47
- source,
48
- /** The status cell, verbatim. */
49
- status) {
50
- this.layer = layer;
51
- this.goal = goal;
52
- this.configKey = configKey;
53
- this.doc = doc;
54
- this.source = source;
55
- this.status = status;
56
- }
57
- /** The config-key cell — layers with no key say so, and say it is deliberate. */
58
- keyCell() {
59
- return this.configKey === '' ? '*(none — deliberate, see below)*' : `\`${this.configKey}\``;
60
- }
61
- sourceCell() {
62
- return this.source === '' ? '—' : `\`${this.source}\``;
63
- }
64
- }
65
- exports.LayerGeneration = LayerGeneration;
66
- /**
67
- * THE FIVE LAYERS, and how much of each doc is machine-owned.
68
- *
69
- * Adding a layer, or converting one to generated, is an edit HERE and nowhere else — the index table,
70
- * the layer table and the one-command sentence all render from this array, so they cannot disagree
71
- * with each other the way the hand-written version did.
72
- */
73
- exports.LAYER_GENERATION = [
74
- new LayerGeneration('L0', 'Is webpieces itself trustworthy right now?', '', 'guards/L0-tooling.md', 'L0_FAULTS + L0_ALLOWLIST', '**PARTLY generated, byte-locked** — only the block between the `L0_DOC_BEGIN` / `L0_DOC_END` markers; every byte outside it is hand-written prose the splice preserves'),
75
- new LayerGeneration('L1', 'Is this call ours to judge, are the versions in sync, and is git run from the root?', '', 'guards/L1-location.md', 'L1_ROWS', '**generated whole, byte-locked** — table, use cases and cures all render from the array the runner dispatches on'),
76
- new LayerGeneration('L2', 'May I work here, and is what I read current?', 'branch-state-guard', 'guards/L2-branch-state.md', 'L2_ROWS', '**generated whole, byte-locked** — table, use cases and the "Not done" gaps all render from the rows'),
77
- new LayerGeneration('L3', 'Which dead branches and worktrees get reaped?', 'branch-creation-guard', 'guards/L3-branch-cleanup.md', '', '**hand-written** — not yet converted, so it CAN go out of date; the code is the authority'),
78
- new LayerGeneration('L4', 'Does every merge and PR go through the gated flow?', 'pr-lifecycle-guard', 'guards/L4-pr-lifecycle.md', '', '**hand-written** — not yet converted, so it CAN go out of date; the code is the authority'),
79
- ];
80
- /**
81
- * The generated block of GUARD_MATRIX.md, and the splice that puts it there.
82
- *
83
- * Same class shape as L0ToolingDoc — renderer, extractor and splicer as one unit, driven by one spec.
84
- */
85
- class GuardIndexDoc {
86
- /** The whole generated block, WITHOUT the markers — those belong to the file, not the renderer. */
87
- render() {
88
- return [
89
- ...this.preamble(),
90
- ...this.statusTable(),
91
- ...this.layerTable(),
92
- ].join('\n');
93
- }
94
- /**
95
- * The generated text of `doc`, exactly as committed. Throws when a marker is missing or doubled —
96
- * a silently-unspliced doc is the drift this arrangement exists to end.
97
- */
98
- extract(doc) {
99
- const opens = doc.split(exports.GUARD_INDEX_BEGIN).length - 1;
100
- const closes = doc.split(exports.GUARD_INDEX_END).length - 1;
101
- if (opens !== 1 || closes !== 1) {
102
- throw new Error(`GUARD_MATRIX.md must carry exactly one BEGIN/END marker pair, found ${String(opens)}/${String(closes)}`);
103
- }
104
- const afterBegin = doc.slice(doc.indexOf(exports.GUARD_INDEX_BEGIN) + exports.GUARD_INDEX_BEGIN.length);
105
- return afterBegin.slice(0, afterBegin.indexOf(exports.GUARD_INDEX_END)).replace(/^\n/, '').replace(/\n$/, '');
106
- }
107
- /** `doc` with the generated block replaced by today's render. Preserves every byte outside it. */
108
- splice(doc) {
109
- const head = doc.slice(0, doc.indexOf(exports.GUARD_INDEX_BEGIN) + exports.GUARD_INDEX_BEGIN.length);
110
- const tail = doc.slice(doc.indexOf(exports.GUARD_INDEX_END));
111
- // extract() is called for its VALIDATION — one marker pair — before anything is rewritten.
112
- this.extract(doc);
113
- return `${head}\n${this.render()}\n${tail}`;
114
- }
115
- preamble() {
116
- return [
117
- '> **GENERATED — do not hand-edit between the markers.** Rendered by `GuardIndexDoc.render()`',
118
- '> from `LAYER_GENERATION` (`ai-hook-rules/src/core/guard-index-doc.ts`); regenerate with',
119
- '> `pnpm guards:generate`. A spec byte-locks it.',
120
- '>',
121
- '> This block used to be prose, and it drifted about the one subject it exists to report: it',
122
- '> claimed every layer but L0 and L1 was hand-written, ten lines above a table listing L2 as',
123
- '> generated. The index that tells you which docs to trust is the last place that can afford',
124
- '> to be wrong, so it is data now.',
125
- '',
126
- '## Generation status',
127
- '',
128
- ];
129
- }
130
- statusTable() {
131
- return [
132
- '| layer | source of truth | doc |',
133
- '|---|---|---|',
134
- ...exports.LAYER_GENERATION.map((entry) => `| ${entry.layer} | ${entry.sourceCell()} | ${entry.status} |`),
135
- '',
136
- `One command regenerates every generated artifact: \`pnpm guards:generate\`. It rewrites the`,
137
- `${this.generatedWholeCount()} whole-file docs, SPLICES the marked blocks in L0's doc and in this file, writes the`,
138
- 'AI-facing copy of the L2 matrix, and renders the POSIX-sh shim template.',
139
- '',
140
- 'For a WHOLE-file layer the split is: **row data** lives in the array, **prose** lives as literal',
141
- 'lines inside the renderer, there is no third place, and the byte-lock spec fails on any hand',
142
- 'edit. **The two SPLICED files are the exception**: everything outside their marker pairs is',
143
- 'hand-written prose the splice preserves byte for byte, and the spec deliberately permits you to',
144
- 'edit it.',
145
- '',
146
- '**L1 and L2 differ in one way worth knowing.** L1 DISPATCHES from its rows — the runner takes the',
147
- 'first matching row and switches on its `blockId`, so deleting a row deletes a block. L2\'s four',
148
- 'guard classes each own their own ladder (they diverge in polarity, quantifier and empty-command',
149
- 'handling, deliberately), so L2 joins to its rows by REASON instead: every decision-log line carries',
150
- '`row=<n>` derived from the reason the guard logged, plus the `cure=` that row prescribed, and a spec',
151
- 'asserts the reason map is exhaustive against the guard sources.',
152
- '',
153
- ];
154
- }
155
- layerTable() {
156
- return [
157
- '## The layers',
158
- '',
159
- '| layer | goal — the question it answers | config key | doc |',
160
- '|---|---|---|---|',
161
- ...exports.LAYER_GENERATION.map((entry) => `| **${entry.layer}** | ${entry.goal} | ${entry.keyCell()} | [${entry.layer}](${entry.doc}) |`),
162
- '',
163
- ];
164
- }
165
- // Rendered into the prose so the sentence cannot claim a count the array disagrees with — the exact
166
- // failure mode this file is fixing ("One command regenerates all three" survived L2's conversion).
167
- generatedWholeCount() {
168
- return String(exports.LAYER_GENERATION.filter((entry) => entry.status.includes('generated whole')).length);
169
- }
170
- }
171
- exports.GuardIndexDoc = GuardIndexDoc;
172
- //# sourceMappingURL=guard-index-doc.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"guard-index-doc.js","sourceRoot":"","sources":["../../../../../../packages/tooling/ai-hook-rules/src/core/guard-index-doc.ts"],"names":[],"mappings":";AAAA,8EAA8E;AAC9E,qFAAqF;AACrF,EAAE;AACF,mGAAmG;AACnG,sGAAsG;AACtG,sGAAsG;AACtG,sGAAsG;AACtG,uGAAuG;AACvG,8BAA8B;AAC9B,EAAE;AACF,mGAAmG;AACnG,qGAAqG;AACrG,gGAAgG;AAChG,2FAA2F;AAC3F,8DAA8D;AAC9D,EAAE;AACF,oGAAoG;AACpG,uGAAuG;AACvG,mFAAmF;AACnF,8EAA8E;;;AAE9E,+EAA+E;AAClE,QAAA,iBAAiB,GAAG,4HAA4H,CAAC;AAE9J,gGAAgG;AACnF,QA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,CAAC,OAAO,EAAE,OAAO,KAAK,CAAC,KAAK,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC;YACnG,EAAE;SACL,CAAC;IACN,CAAC;IAED,oGAAoG;IACpG,mGAAmG;IAC3F,mBAAmB;QACvB,OAAO,MAAM,CAAC,wBAAgB,CAAC,MAAM,CAAC,CAAC,KAAsB,EAAW,EAAE,CACtE,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IAC1D,CAAC;CACJ;AA9FD,sCA8FC","sourcesContent":["// ---------------------------------------------------------------------------\n// GUARD_MATRIX.md's generation-status block, rendered from the one array that knows.\n//\n// THE BUG THIS FIXES IS IN THE FILE ITSELF. GUARD_MATRIX.md is the INDEX — the page that tells you\n// which layer docs are generated and which are hand-written — and it was hand-written, so it went out\n// of date about generation. It ended up contradicting itself inside ten lines: a blockquote asserting\n// \"L1's table ... generated\" and \"EVERY REMAINING LAYER FILE IS HAND-WRITTEN TODAY\", directly above a\n// table listing L2 as generated and byte-locked. Both were once true; L2 was converted and only one of\n// the two places was updated.\n//\n// A doc that describes generation is exactly the doc that must be generated, because it is the one\n// place a reader goes to find out whether to trust the others. So the STATUS is data here, the block\n// between the markers is spliced from it, and a spec byte-locks the result — the same treatment\n// guards/L0-tooling.md gets, and for the same reason: everything outside the markers stays\n// hand-written prose that the splice preserves byte for byte.\n//\n// WHAT IS DELIBERATELY NOT GENERATED: the rest of GUARD_MATRIX.md — the action codebook, the launch\n// guarantee, the two rules that constrain guard changes. Those are prose about DESIGN, not facts about\n// the code, and a generator that owns them would be inventing a schema for essays.\n// ---------------------------------------------------------------------------\n\n/** Opening marker of the generated block, as it appears in GUARD_MATRIX.md. */\nexport const GUARD_INDEX_BEGIN = '<!-- BEGIN GENERATED — GuardIndexDoc.render() in ai-hook-rules/src/core/guard-index-doc.ts; run `pnpm guards:generate` -->';\n\n/** Closing marker. Everything between the two is machine-owned; everything outside is prose. */\nexport const GUARD_INDEX_END = '<!-- END GENERATED — hand-written prose resumes here -->';\n\n/** How much of a layer's doc is rendered from code. Data-only → a class, per CLAUDE.md. */\nexport class LayerGeneration {\n // eslint-disable-next-line @typescript-eslint/max-params -- the five cells of one status row\n constructor(\n /** `L0`, `L1`, … as the doc prints it. */\n readonly layer: string,\n /** The question this layer answers, for the layer table. */\n readonly goal: string,\n /** The `webpieces.config.json` key, or '' when the layer has none on purpose. */\n readonly configKey: string,\n /** Repo-relative path of the layer's doc. */\n readonly doc: string,\n /** The array the doc is rendered FROM, or '' when nothing is generated yet. */\n readonly source: string,\n /** The status cell, verbatim. */\n readonly status: string,\n ) {}\n\n /** The config-key cell — layers with no key say so, and say it is deliberate. */\n keyCell(): string {\n return this.configKey === '' ? '*(none — deliberate, see below)*' : `\\`${this.configKey}\\``;\n }\n\n sourceCell(): string {\n return this.source === '' ? '—' : `\\`${this.source}\\``;\n }\n}\n\n/**\n * THE FIVE LAYERS, and how much of each doc is machine-owned.\n *\n * Adding a layer, or converting one to generated, is an edit HERE and nowhere else — the index table,\n * the layer table and the one-command sentence all render from this array, so they cannot disagree\n * with each other the way the hand-written version did.\n */\nexport const LAYER_GENERATION: readonly LayerGeneration[] = [\n new LayerGeneration('L0', 'Is webpieces itself trustworthy right now?', '', 'guards/L0-tooling.md',\n 'L0_FAULTS + L0_ALLOWLIST',\n '**PARTLY generated, byte-locked** — only the block between the `L0_DOC_BEGIN` / `L0_DOC_END` markers; every byte outside it is hand-written prose the splice preserves'),\n new LayerGeneration('L1', 'Is this call ours to judge, are the versions in sync, and is git run from the root?', '', 'guards/L1-location.md',\n 'L1_ROWS',\n '**generated whole, byte-locked** — table, use cases and cures all render from the array the runner dispatches on'),\n new LayerGeneration('L2', 'May I work here, and is what I read current?', 'branch-state-guard', 'guards/L2-branch-state.md',\n 'L2_ROWS',\n '**generated whole, byte-locked** — table, use cases and the \"Not done\" gaps all render from the rows'),\n new LayerGeneration('L3', 'Which dead branches and worktrees get reaped?', 'branch-creation-guard', 'guards/L3-branch-cleanup.md',\n '',\n '**hand-written** — not yet converted, so it CAN go out of date; the code is the authority'),\n new LayerGeneration('L4', 'Does every merge and PR go through the gated flow?', 'pr-lifecycle-guard', 'guards/L4-pr-lifecycle.md',\n '',\n '**hand-written** — not yet converted, so it CAN go out of date; the code is the authority'),\n];\n\n/**\n * The generated block of GUARD_MATRIX.md, and the splice that puts it there.\n *\n * Same class shape as L0ToolingDoc — renderer, extractor and splicer as one unit, driven by one spec.\n */\nexport class GuardIndexDoc {\n /** The whole generated block, WITHOUT the markers — those belong to the file, not the renderer. */\n render(): string {\n return [\n ...this.preamble(),\n ...this.statusTable(),\n ...this.layerTable(),\n ].join('\\n');\n }\n\n /**\n * The generated text of `doc`, exactly as committed. Throws when a marker is missing or doubled —\n * a silently-unspliced doc is the drift this arrangement exists to end.\n */\n extract(doc: string): string {\n const opens = doc.split(GUARD_INDEX_BEGIN).length - 1;\n const closes = doc.split(GUARD_INDEX_END).length - 1;\n if (opens !== 1 || closes !== 1) {\n throw new Error(`GUARD_MATRIX.md must carry exactly one BEGIN/END marker pair, found ${String(opens)}/${String(closes)}`);\n }\n const afterBegin = doc.slice(doc.indexOf(GUARD_INDEX_BEGIN) + GUARD_INDEX_BEGIN.length);\n return afterBegin.slice(0, afterBegin.indexOf(GUARD_INDEX_END)).replace(/^\\n/, '').replace(/\\n$/, '');\n }\n\n /** `doc` with the generated block replaced by today's render. Preserves every byte outside it. */\n splice(doc: string): string {\n const head = doc.slice(0, doc.indexOf(GUARD_INDEX_BEGIN) + GUARD_INDEX_BEGIN.length);\n const tail = doc.slice(doc.indexOf(GUARD_INDEX_END));\n // extract() is called for its VALIDATION — one marker pair — before anything is rewritten.\n this.extract(doc);\n return `${head}\\n${this.render()}\\n${tail}`;\n }\n\n private preamble(): string[] {\n return [\n '> **GENERATED — do not hand-edit between the markers.** Rendered by `GuardIndexDoc.render()`',\n '> from `LAYER_GENERATION` (`ai-hook-rules/src/core/guard-index-doc.ts`); regenerate with',\n '> `pnpm guards:generate`. A spec byte-locks it.',\n '>',\n '> This block used to be prose, and it drifted about the one subject it exists to report: it',\n '> claimed every layer but L0 and L1 was hand-written, ten lines above a table listing L2 as',\n '> generated. The index that tells you which docs to trust is the last place that can afford',\n '> to be wrong, so it is data now.',\n '',\n '## Generation status',\n '',\n ];\n }\n\n private statusTable(): string[] {\n return [\n '| layer | source of truth | doc |',\n '|---|---|---|',\n ...LAYER_GENERATION.map((entry: LayerGeneration): string =>\n `| ${entry.layer} | ${entry.sourceCell()} | ${entry.status} |`),\n '',\n `One command regenerates every generated artifact: \\`pnpm guards:generate\\`. It rewrites the`,\n `${this.generatedWholeCount()} whole-file docs, SPLICES the marked blocks in L0's doc and in this file, writes the`,\n 'AI-facing copy of the L2 matrix, and renders the POSIX-sh shim template.',\n '',\n 'For a WHOLE-file layer the split is: **row data** lives in the array, **prose** lives as literal',\n 'lines inside the renderer, there is no third place, and the byte-lock spec fails on any hand',\n 'edit. **The two SPLICED files are the exception**: everything outside their marker pairs is',\n 'hand-written prose the splice preserves byte for byte, and the spec deliberately permits you to',\n 'edit it.',\n '',\n '**L1 and L2 differ in one way worth knowing.** L1 DISPATCHES from its rows — the runner takes the',\n 'first matching row and switches on its `blockId`, so deleting a row deletes a block. L2\\'s four',\n 'guard classes each own their own ladder (they diverge in polarity, quantifier and empty-command',\n 'handling, deliberately), so L2 joins to its rows by REASON instead: every decision-log line carries',\n '`row=<n>` derived from the reason the guard logged, plus the `cure=` that row prescribed, and a spec',\n 'asserts the reason map is exhaustive against the guard sources.',\n '',\n ];\n }\n\n private layerTable(): string[] {\n return [\n '## The layers',\n '',\n '| layer | goal — the question it answers | config key | doc |',\n '|---|---|---|---|',\n ...LAYER_GENERATION.map((entry: LayerGeneration): string =>\n `| **${entry.layer}** | ${entry.goal} | ${entry.keyCell()} | [${entry.layer}](${entry.doc}) |`),\n '',\n ];\n }\n\n // Rendered into the prose so the sentence cannot claim a count the array disagrees with — the exact\n // failure mode this file is fixing (\"One command regenerates all three\" survived L2's conversion).\n private generatedWholeCount(): string {\n return String(LAYER_GENERATION.filter((entry: LayerGeneration): boolean =>\n entry.status.includes('generated whole')).length);\n }\n}\n"]}
@@ -1 +0,0 @@
1
- export { writeTemplateIfMissing } from '@webpieces/rules-config';
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.writeTemplateIfMissing = void 0;
4
- var rules_config_1 = require("@webpieces/rules-config");
5
- Object.defineProperty(exports, "writeTemplateIfMissing", { enumerable: true, get: function () { return rules_config_1.writeTemplateIfMissing; } });
6
- //# sourceMappingURL=instruct-ai-writer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"instruct-ai-writer.js","sourceRoot":"","sources":["../../../../../../packages/tooling/ai-hook-rules/src/core/instruct-ai-writer.ts"],"names":[],"mappings":";;;AAAA,wDAAiE;AAAxD,sHAAA,sBAAsB,OAAA","sourcesContent":["export { writeTemplateIfMissing } from '@webpieces/rules-config';\n"]}
@@ -1,85 +0,0 @@
1
- /** `D` — version drift: the root package.json pin != the installed version. Decided in `sh`. */
2
- export declare const L0_FAULT_DRIFT = "D";
3
- /** `X` — the guard bin is missing (fresh clone, new worktree, package removed). Decided in `sh`. */
4
- export declare const L0_FAULT_BIN_MISSING = "X";
5
- /** `U` — the bin is missing AND nothing declares the package, so an install is a no-op. `sh`. */
6
- export declare const L0_FAULT_UNDECLARED = "U";
7
- /** `K` — the bin is present but CRASHED (corrupt node_modules). Decided in `sh`. */
8
- export declare const L0_FAULT_BIN_BROKEN = "K";
9
- /** `S` — the committed `.claude/webpieces/ai-hook.sh` != `renderShim()`. Decided in the bin, in JS. */
10
- export declare const L0_FAULT_SHIM_STALE = "S";
11
- /** `C` — `webpieces.config.json` is missing. Decided in the bin, in JS. */
12
- export declare const L0_FAULT_CONFIG_MISSING = "C";
13
- /** `Y` — a loaded rule has no `webpieces.config.json` key. Decided in the bin, in JS. */
14
- export declare const L0_FAULT_CONFIG_OUT_OF_SYNC = "Y";
15
- /**
16
- * No fault AT THIS LAYER — the value every audit line carries when nothing fired.
17
- *
18
- * Never a claim that nothing was wrong: a `fault=-` line from the `sh` shim only says the sh half found
19
- * nothing, and the bin it then exec'd may still have blocked on S/C/Y and stamped its own line.
20
- */
21
- export declare const L0_FAULT_NONE = "-";
22
- /**
23
- * The faults decided in POSIX `sh`, BEFORE the bin runs — a stale, missing or broken validator cannot
24
- * be trusted to validate itself. In first-match-wins order.
25
- */
26
- export declare const L0_SH_FAULT_CODES: readonly ["D", "X", "U", "K"];
27
- /**
28
- * The faults decided INSIDE the guard bin, in JS. These reached the audit trail with no fault label at
29
- * all until the JS emitters started stamping them: an `S` storm that blocked an agent for ~20 tool
30
- * calls left two lines in the `rejections/` stream, both attributed to a downstream rule, and nothing
31
- * anywhere identifying L0.
32
- */
33
- export declare const L0_JS_FAULT_CODES: readonly ["S", "C", "Y"];
34
- /**
35
- * EVERY L0 fault code, as a type. The two arrays above are the halves; this is their union, and it is
36
- * what makes `L0_FAULT_NAMES` TOTAL — a `Record<string, …>` would have forced a `?? 'unknown'` fallback
37
- * at every read, which is shim shape #4 (a runtime default standing in for a type that could have
38
- * expressed the invariant). With the union, a new fault added without a name is a COMPILE error, and
39
- * neither reader needs a defensive branch.
40
- */
41
- export type L0FaultCode = typeof L0_SH_FAULT_CODES[number] | typeof L0_JS_FAULT_CODES[number];
42
- /**
43
- * The stable, human-readable GUARD NAME per fault code — what goes in the deny's `[…]` header, in the
44
- * matrix doc's own `guard` column, and nowhere else in a second spelling.
45
- *
46
- * L1 prints `[stale-main-bash-guard] (1 violation)` and L0 printed nothing comparable; the names below
47
- * are deliberately in that same kebab shape so the two layers read as one system. They are IDENTITY, not
48
- * prose: renaming one silently breaks a grep that spans all three artifacts, exactly as renumbering an
49
- * L1 row would (see L1_ROWS' header).
50
- */
51
- export declare const L0_FAULT_NAMES: Readonly<Record<L0FaultCode, string>>;
52
- /**
53
- * The LAYER token — the other half of every join key, spelled once. The deny header, the matrix
54
- * citation, the sh audit line and guards/L0-tooling.md all read it from here, so `grep layer=L0` cannot
55
- * miss an artifact that typed the token itself.
56
- */
57
- export declare const L0_LAYER = "L0";
58
- /**
59
- * The three rows of L0's decision matrix, by number — the numbers `renderGuardMatrixDoc` prints, the
60
- * numbers the audit line's `row=` carries, and the numbers a deny cites. L0's matrix has no genuine
61
- * second dimension: every branch reduces to `fault present?` x `on the allowlist?`.
62
- *
63
- * All three are named because all three are LOGGED: the sh half writes a line for the healthy hand-down
64
- * too (`PASS-BIN-ALLOW`), which is the line that tells "the guard ran and found nothing" apart from
65
- * "the guard never ran".
66
- */
67
- export declare const L0_ROW_HANDED_DOWN = "1";
68
- /** Row 2: a fault is present but the call is on the L0 allowlist — a cure, a Read, or the config edit. */
69
- export declare const L0_ROW_ALLOWLISTED = "2";
70
- /** Row 3: a fault is present and the call is NOT on the allowlist. The one row that ever BLOCKS. */
71
- export declare const L0_ROW_BLOCKED = "3";
72
- /**
73
- * The `[guard-name] (layer=L0 fault=<code> row=<n>)` header every L0 deny opens with, after the ❌ line.
74
- *
75
- * ONE builder, called by the JS denies directly and interpolated into the POSIX-sh denies at render
76
- * time by renderShim() — so the sh half cannot spell the coordinates differently from the JS half even
77
- * though it cannot import anything at runtime. `detail` is the per-fault count that mirrors
78
- * formatReport's `(N violations)`.
79
- */
80
- export declare function l0GuardHeader(fault: L0FaultCode, detail: string): string;
81
- /**
82
- * The one-line citation of WHICH matrix row was taken and on what dimension values — L1's pattern
83
- * (its deny cites "`w` / `n` / `n` - row 8"), in L0's own two columns.
84
- */
85
- export declare function l0MatrixCitation(fault: L0FaultCode): string;
@@ -1,121 +0,0 @@
1
- "use strict";
2
- // ---------------------------------------------------------------------------
3
- // THE L0 FAULT CODEBOOK — one letter per fault, declared HERE and nowhere else.
4
- //
5
- // Both halves of L0 stamp `fault=<code>` onto their audit lines: the POSIX `sh` shim writes D/X/U/K
6
- // (shim-audit-log.ts), and the guard bin writes S/C/Y in JS (decision-log.ts, via runner.ts and
7
- // hook-core.ts). The whole value of that field is that ONE grep — `grep 'fault=S'` — spans the entire
8
- // trail, and that the faults actually observed can be diffed against `L0_FAULTS`. Both properties hold
9
- // only while every emitter spells the letters the SAME way, and a hand-retyped 'S' in one emitter is
10
- // exactly the drift this module exists to make impossible.
11
- //
12
- // It used to be retyped: the shim assigned `WP_FAULT=X` as a literal, SHIM_LOG_FAULTS listed the four
13
- // sh-side letters again, and L0_FAULTS listed all seven a third time. Three spellings of one
14
- // vocabulary, held together by a unit test that could only notice AFTER they diverged.
15
- //
16
- // This module is a LEAF — no imports at all — on purpose. `l0-matrix.ts` (core) builds `L0_FAULTS`
17
- // from these constants and `shim-audit-log.ts` / `shim.ts` (bin) render them into the shim; parking the
18
- // constants in either of those two would make the other one a core↔bin import cycle. It also keeps the
19
- // shim renderer dependency-light, which it must be: it has to work on a tree too broken to load the
20
- // rule engine.
21
- // ---------------------------------------------------------------------------
22
- Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.L0_ROW_BLOCKED = exports.L0_ROW_ALLOWLISTED = exports.L0_ROW_HANDED_DOWN = exports.L0_LAYER = exports.L0_FAULT_NAMES = exports.L0_JS_FAULT_CODES = exports.L0_SH_FAULT_CODES = exports.L0_FAULT_NONE = exports.L0_FAULT_CONFIG_OUT_OF_SYNC = exports.L0_FAULT_CONFIG_MISSING = exports.L0_FAULT_SHIM_STALE = exports.L0_FAULT_BIN_BROKEN = exports.L0_FAULT_UNDECLARED = exports.L0_FAULT_BIN_MISSING = exports.L0_FAULT_DRIFT = void 0;
24
- exports.l0GuardHeader = l0GuardHeader;
25
- exports.l0MatrixCitation = l0MatrixCitation;
26
- /** `D` — version drift: the root package.json pin != the installed version. Decided in `sh`. */
27
- exports.L0_FAULT_DRIFT = 'D';
28
- /** `X` — the guard bin is missing (fresh clone, new worktree, package removed). Decided in `sh`. */
29
- exports.L0_FAULT_BIN_MISSING = 'X';
30
- /** `U` — the bin is missing AND nothing declares the package, so an install is a no-op. `sh`. */
31
- exports.L0_FAULT_UNDECLARED = 'U';
32
- /** `K` — the bin is present but CRASHED (corrupt node_modules). Decided in `sh`. */
33
- exports.L0_FAULT_BIN_BROKEN = 'K';
34
- /** `S` — the committed `.claude/webpieces/ai-hook.sh` != `renderShim()`. Decided in the bin, in JS. */
35
- exports.L0_FAULT_SHIM_STALE = 'S';
36
- /** `C` — `webpieces.config.json` is missing. Decided in the bin, in JS. */
37
- exports.L0_FAULT_CONFIG_MISSING = 'C';
38
- /** `Y` — a loaded rule has no `webpieces.config.json` key. Decided in the bin, in JS. */
39
- exports.L0_FAULT_CONFIG_OUT_OF_SYNC = 'Y';
40
- /**
41
- * No fault AT THIS LAYER — the value every audit line carries when nothing fired.
42
- *
43
- * Never a claim that nothing was wrong: a `fault=-` line from the `sh` shim only says the sh half found
44
- * nothing, and the bin it then exec'd may still have blocked on S/C/Y and stamped its own line.
45
- */
46
- exports.L0_FAULT_NONE = '-';
47
- /**
48
- * The faults decided in POSIX `sh`, BEFORE the bin runs — a stale, missing or broken validator cannot
49
- * be trusted to validate itself. In first-match-wins order.
50
- */
51
- exports.L0_SH_FAULT_CODES = [
52
- exports.L0_FAULT_DRIFT, exports.L0_FAULT_BIN_MISSING, exports.L0_FAULT_UNDECLARED, exports.L0_FAULT_BIN_BROKEN,
53
- ];
54
- /**
55
- * The faults decided INSIDE the guard bin, in JS. These reached the audit trail with no fault label at
56
- * all until the JS emitters started stamping them: an `S` storm that blocked an agent for ~20 tool
57
- * calls left two lines in the `rejections/` stream, both attributed to a downstream rule, and nothing
58
- * anywhere identifying L0.
59
- */
60
- exports.L0_JS_FAULT_CODES = [
61
- exports.L0_FAULT_SHIM_STALE, exports.L0_FAULT_CONFIG_MISSING, exports.L0_FAULT_CONFIG_OUT_OF_SYNC,
62
- ];
63
- /**
64
- * The stable, human-readable GUARD NAME per fault code — what goes in the deny's `[…]` header, in the
65
- * matrix doc's own `guard` column, and nowhere else in a second spelling.
66
- *
67
- * L1 prints `[stale-main-bash-guard] (1 violation)` and L0 printed nothing comparable; the names below
68
- * are deliberately in that same kebab shape so the two layers read as one system. They are IDENTITY, not
69
- * prose: renaming one silently breaks a grep that spans all three artifacts, exactly as renumbering an
70
- * L1 row would (see L1_ROWS' header).
71
- */
72
- exports.L0_FAULT_NAMES = {
73
- [exports.L0_FAULT_DRIFT]: 'version-drift',
74
- [exports.L0_FAULT_BIN_MISSING]: 'guard-bin-missing',
75
- [exports.L0_FAULT_UNDECLARED]: 'guard-pkg-undeclared',
76
- [exports.L0_FAULT_BIN_BROKEN]: 'guard-bin-crashed',
77
- [exports.L0_FAULT_SHIM_STALE]: 'managed-hook-surface',
78
- [exports.L0_FAULT_CONFIG_MISSING]: 'config-missing',
79
- [exports.L0_FAULT_CONFIG_OUT_OF_SYNC]: 'config-out-of-sync',
80
- };
81
- /**
82
- * The LAYER token — the other half of every join key, spelled once. The deny header, the matrix
83
- * citation, the sh audit line and guards/L0-tooling.md all read it from here, so `grep layer=L0` cannot
84
- * miss an artifact that typed the token itself.
85
- */
86
- exports.L0_LAYER = 'L0';
87
- /**
88
- * The three rows of L0's decision matrix, by number — the numbers `renderGuardMatrixDoc` prints, the
89
- * numbers the audit line's `row=` carries, and the numbers a deny cites. L0's matrix has no genuine
90
- * second dimension: every branch reduces to `fault present?` x `on the allowlist?`.
91
- *
92
- * All three are named because all three are LOGGED: the sh half writes a line for the healthy hand-down
93
- * too (`PASS-BIN-ALLOW`), which is the line that tells "the guard ran and found nothing" apart from
94
- * "the guard never ran".
95
- */
96
- exports.L0_ROW_HANDED_DOWN = '1';
97
- /** Row 2: a fault is present but the call is on the L0 allowlist — a cure, a Read, or the config edit. */
98
- exports.L0_ROW_ALLOWLISTED = '2';
99
- /** Row 3: a fault is present and the call is NOT on the allowlist. The one row that ever BLOCKS. */
100
- exports.L0_ROW_BLOCKED = '3';
101
- /**
102
- * The `[guard-name] (layer=L0 fault=<code> row=<n>)` header every L0 deny opens with, after the ❌ line.
103
- *
104
- * ONE builder, called by the JS denies directly and interpolated into the POSIX-sh denies at render
105
- * time by renderShim() — so the sh half cannot spell the coordinates differently from the JS half even
106
- * though it cannot import anything at runtime. `detail` is the per-fault count that mirrors
107
- * formatReport's `(N violations)`.
108
- */
109
- // webpieces-disable no-function-outside-class -- pure string builder over this leaf module's own constants; it must stay importable by the dependency-free shim renderer.
110
- function l0GuardHeader(fault, detail) {
111
- return `[${exports.L0_FAULT_NAMES[fault]}] (layer=${exports.L0_LAYER} fault=${fault} row=${exports.L0_ROW_BLOCKED}, ${detail})`;
112
- }
113
- /**
114
- * The one-line citation of WHICH matrix row was taken and on what dimension values — L1's pattern
115
- * (its deny cites "`w` / `n` / `n` - row 8"), in L0's own two columns.
116
- */
117
- // webpieces-disable no-function-outside-class -- sibling of l0GuardHeader in this leaf codebook module.
118
- function l0MatrixCitation(fault) {
119
- return `matrix row ${exports.L0_ROW_BLOCKED}: fault=${fault} present / on the allowlist? no -> BLOCK. Those are the same coordinates the audit line carries (layer=${exports.L0_LAYER} row=${exports.L0_ROW_BLOCKED} fault=${fault}) and the same row webpieces.guard-matrix.md prints.`;
120
- }
121
- //# sourceMappingURL=l0-fault-codes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"l0-fault-codes.js","sourceRoot":"","sources":["../../../../../../packages/tooling/ai-hook-rules/src/core/l0-fault-codes.ts"],"names":[],"mappings":";AAAA,8EAA8E;AAC9E,gFAAgF;AAChF,EAAE;AACF,oGAAoG;AACpG,gGAAgG;AAChG,sGAAsG;AACtG,uGAAuG;AACvG,qGAAqG;AACrG,2DAA2D;AAC3D,EAAE;AACF,sGAAsG;AACtG,6FAA6F;AAC7F,uFAAuF;AACvF,EAAE;AACF,mGAAmG;AACnG,wGAAwG;AACxG,uGAAuG;AACvG,oGAAoG;AACpG,eAAe;AACf,8EAA8E;;;AAgI9E,sCAEC;AAOD,4CAEC;AAzID,gGAAgG;AACnF,QAAA,cAAc,GAAG,GAAG,CAAC;AAElC,oGAAoG;AACvF,QAAA,oBAA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KAAK,CAAC,YAAY,gBAAQ,UAAU,KAAK,QAAQ,sBAAc,KAAK,MAAM,GAAG,CAAC;AAC5G,CAAC;AAED;;;GAGG;AACH,wGAAwG;AACxG,SAAgB,gBAAgB,CAAC,KAAkB;IAC/C,OAAO,cAAc,sBAAc,WAAW,KAAK,0GAA0G,gBAAQ,QAAQ,sBAAc,UAAU,KAAK,sDAAsD,CAAC;AACrQ,CAAC","sourcesContent":["// ---------------------------------------------------------------------------\n// THE L0 FAULT CODEBOOK — one letter per fault, declared HERE and nowhere else.\n//\n// Both halves of L0 stamp `fault=<code>` onto their audit lines: the POSIX `sh` shim writes D/X/U/K\n// (shim-audit-log.ts), and the guard bin writes S/C/Y in JS (decision-log.ts, via runner.ts and\n// hook-core.ts). The whole value of that field is that ONE grep — `grep 'fault=S'` — spans the entire\n// trail, and that the faults actually observed can be diffed against `L0_FAULTS`. Both properties hold\n// only while every emitter spells the letters the SAME way, and a hand-retyped 'S' in one emitter is\n// exactly the drift this module exists to make impossible.\n//\n// It used to be retyped: the shim assigned `WP_FAULT=X` as a literal, SHIM_LOG_FAULTS listed the four\n// sh-side letters again, and L0_FAULTS listed all seven a third time. Three spellings of one\n// vocabulary, held together by a unit test that could only notice AFTER they diverged.\n//\n// This module is a LEAF — no imports at all — on purpose. `l0-matrix.ts` (core) builds `L0_FAULTS`\n// from these constants and `shim-audit-log.ts` / `shim.ts` (bin) render them into the shim; parking the\n// constants in either of those two would make the other one a core↔bin import cycle. It also keeps the\n// shim renderer dependency-light, which it must be: it has to work on a tree too broken to load the\n// rule engine.\n// ---------------------------------------------------------------------------\n\n/** `D` — version drift: the root package.json pin != the installed version. Decided in `sh`. */\nexport const L0_FAULT_DRIFT = 'D';\n\n/** `X` — the guard bin is missing (fresh clone, new worktree, package removed). Decided in `sh`. */\nexport const L0_FAULT_BIN_MISSING = 'X';\n\n/** `U` — the bin is missing AND nothing declares the package, so an install is a no-op. `sh`. */\nexport const L0_FAULT_UNDECLARED = 'U';\n\n/** `K` — the bin is present but CRASHED (corrupt node_modules). Decided in `sh`. */\nexport const L0_FAULT_BIN_BROKEN = 'K';\n\n/** `S` — the committed `.claude/webpieces/ai-hook.sh` != `renderShim()`. Decided in the bin, in JS. */\nexport const L0_FAULT_SHIM_STALE = 'S';\n\n/** `C` — `webpieces.config.json` is missing. Decided in the bin, in JS. */\nexport const L0_FAULT_CONFIG_MISSING = 'C';\n\n/** `Y` — a loaded rule has no `webpieces.config.json` key. Decided in the bin, in JS. */\nexport const L0_FAULT_CONFIG_OUT_OF_SYNC = 'Y';\n\n/**\n * No fault AT THIS LAYER — the value every audit line carries when nothing fired.\n *\n * Never a claim that nothing was wrong: a `fault=-` line from the `sh` shim only says the sh half found\n * nothing, and the bin it then exec'd may still have blocked on S/C/Y and stamped its own line.\n */\nexport const L0_FAULT_NONE = '-';\n\n/**\n * The faults decided in POSIX `sh`, BEFORE the bin runs — a stale, missing or broken validator cannot\n * be trusted to validate itself. In first-match-wins order.\n */\nexport const L0_SH_FAULT_CODES = [\n L0_FAULT_DRIFT, L0_FAULT_BIN_MISSING, L0_FAULT_UNDECLARED, L0_FAULT_BIN_BROKEN,\n] as const;\n\n/**\n * The faults decided INSIDE the guard bin, in JS. These reached the audit trail with no fault label at\n * all until the JS emitters started stamping them: an `S` storm that blocked an agent for ~20 tool\n * calls left two lines in the `rejections/` stream, both attributed to a downstream rule, and nothing\n * anywhere identifying L0.\n */\nexport const L0_JS_FAULT_CODES = [\n L0_FAULT_SHIM_STALE, L0_FAULT_CONFIG_MISSING, L0_FAULT_CONFIG_OUT_OF_SYNC,\n] as const;\n\n// ---------------------------------------------------------------------------\n// THE JOIN KEYS — the three artifacts that describe one L0 event, and the coordinates that line them up.\n//\n// There are three, and until now they could not be grepped together:\n// 1. THE DENY the agent reads in the moment (shim-deny-reason.ts for S; DENY_REASON_SH for D/X/U/K)\n// 2. THE AUDIT LINE (`.webpieces/logs/**`), which carries `layer=` `row=` `fault=`\n// 3. THE MATRIX DOC (webpieces.guard-matrix.md, rendered from L0_FAULTS + L0_ALLOWLIST)\n//\n// The deny had NONE of them: no fault letter, no row, and — the highest-value omission — no guard NAME,\n// while every L1/L2 deny opens `[<rule-name>] (N violations)`. So a transcript could not be debugged\n// against the log after the fact, and a reader could not find the matrix row by eye.\n//\n// These constants are that vocabulary, declared HERE for the same reason the letters are: this module is\n// a LEAF with no imports, so `core/l0-matrix.ts` (the doc), `bin/shim*.ts` (the denies) and\n// `core/decision-log.ts` (the log) can all reach it without an import cycle. Retyping a name in any one\n// of them is the drift this file exists to make impossible.\n// ---------------------------------------------------------------------------\n\n/**\n * EVERY L0 fault code, as a type. The two arrays above are the halves; this is their union, and it is\n * what makes `L0_FAULT_NAMES` TOTAL — a `Record<string, …>` would have forced a `?? 'unknown'` fallback\n * at every read, which is shim shape #4 (a runtime default standing in for a type that could have\n * expressed the invariant). With the union, a new fault added without a name is a COMPILE error, and\n * neither reader needs a defensive branch.\n */\nexport type L0FaultCode = typeof L0_SH_FAULT_CODES[number] | typeof L0_JS_FAULT_CODES[number];\n\n/**\n * The stable, human-readable GUARD NAME per fault code — what goes in the deny's `[…]` header, in the\n * matrix doc's own `guard` column, and nowhere else in a second spelling.\n *\n * L1 prints `[stale-main-bash-guard] (1 violation)` and L0 printed nothing comparable; the names below\n * are deliberately in that same kebab shape so the two layers read as one system. They are IDENTITY, not\n * prose: renaming one silently breaks a grep that spans all three artifacts, exactly as renumbering an\n * L1 row would (see L1_ROWS' header).\n */\nexport const L0_FAULT_NAMES: Readonly<Record<L0FaultCode, string>> = {\n [L0_FAULT_DRIFT]: 'version-drift',\n [L0_FAULT_BIN_MISSING]: 'guard-bin-missing',\n [L0_FAULT_UNDECLARED]: 'guard-pkg-undeclared',\n [L0_FAULT_BIN_BROKEN]: 'guard-bin-crashed',\n [L0_FAULT_SHIM_STALE]: 'managed-hook-surface',\n [L0_FAULT_CONFIG_MISSING]: 'config-missing',\n [L0_FAULT_CONFIG_OUT_OF_SYNC]: 'config-out-of-sync',\n};\n\n/**\n * The LAYER token — the other half of every join key, spelled once. The deny header, the matrix\n * citation, the sh audit line and guards/L0-tooling.md all read it from here, so `grep layer=L0` cannot\n * miss an artifact that typed the token itself.\n */\nexport const L0_LAYER = 'L0';\n\n/**\n * The three rows of L0's decision matrix, by number — the numbers `renderGuardMatrixDoc` prints, the\n * numbers the audit line's `row=` carries, and the numbers a deny cites. L0's matrix has no genuine\n * second dimension: every branch reduces to `fault present?` x `on the allowlist?`.\n *\n * All three are named because all three are LOGGED: the sh half writes a line for the healthy hand-down\n * too (`PASS-BIN-ALLOW`), which is the line that tells \"the guard ran and found nothing\" apart from\n * \"the guard never ran\".\n */\nexport const L0_ROW_HANDED_DOWN = '1';\n\n/** Row 2: a fault is present but the call is on the L0 allowlist — a cure, a Read, or the config edit. */\nexport const L0_ROW_ALLOWLISTED = '2';\n\n/** Row 3: a fault is present and the call is NOT on the allowlist. The one row that ever BLOCKS. */\nexport const L0_ROW_BLOCKED = '3';\n\n/**\n * The `[guard-name] (layer=L0 fault=<code> row=<n>)` header every L0 deny opens with, after the ❌ line.\n *\n * ONE builder, called by the JS denies directly and interpolated into the POSIX-sh denies at render\n * time by renderShim() — so the sh half cannot spell the coordinates differently from the JS half even\n * though it cannot import anything at runtime. `detail` is the per-fault count that mirrors\n * formatReport's `(N violations)`.\n */\n// webpieces-disable no-function-outside-class -- pure string builder over this leaf module's own constants; it must stay importable by the dependency-free shim renderer.\nexport function l0GuardHeader(fault: L0FaultCode, detail: string): string {\n return `[${L0_FAULT_NAMES[fault]}] (layer=${L0_LAYER} fault=${fault} row=${L0_ROW_BLOCKED}, ${detail})`;\n}\n\n/**\n * The one-line citation of WHICH matrix row was taken and on what dimension values — L1's pattern\n * (its deny cites \"`w` / `n` / `n` - row 8\"), in L0's own two columns.\n */\n// webpieces-disable no-function-outside-class -- sibling of l0GuardHeader in this leaf codebook module.\nexport function l0MatrixCitation(fault: L0FaultCode): string {\n return `matrix row ${L0_ROW_BLOCKED}: fault=${fault} present / on the allowlist? no -> BLOCK. Those are the same coordinates the audit line carries (layer=${L0_LAYER} row=${L0_ROW_BLOCKED} fault=${fault}) and the same row webpieces.guard-matrix.md prints.`;\n}\n"]}