checkwright 0.21.0 → 0.23.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 (489) hide show
  1. package/README.md +1013 -50
  2. package/lib/common/digest.sh +18 -0
  3. package/lib/common/lock.sh +40 -0
  4. package/lib/common/profile.sh +33 -0
  5. package/lib/common/recipe.sh +56 -43
  6. package/lib/diff.sh +64 -0
  7. package/lib/doctor.sh +81 -7
  8. package/lib/init.sh +167 -52
  9. package/lib/uninstall.sh +212 -0
  10. package/lib/update.sh +34 -0
  11. package/package.json +2 -2
  12. package/payload/artifact/targets.list +30 -0
  13. package/payload/artifact/x86_64-unknown-linux-gnu/checkwright-gates +0 -0
  14. package/payload/artifact/x86_64-unknown-linux-gnu/checkwright-gates.sha256 +1 -0
  15. package/payload/canon-kit/README.md +2 -0
  16. package/payload/canon-kit/SPEC.md +666 -59
  17. package/payload/canon-kit/checks/check-amendment-queue.sh +1 -0
  18. package/payload/canon-kit/checks/check-comment-tier.gate +3 -0
  19. package/payload/canon-kit/checks/check-deprecation-task.gate +3 -0
  20. package/payload/canon-kit/checks/check-docs-cmd.gate +3 -0
  21. package/payload/canon-kit/checks/check-docs-link-convention.sh +12 -4
  22. package/payload/canon-kit/checks/check-install-claim.gate +3 -0
  23. package/payload/canon-kit/checks/check-knob-citation.gate +3 -0
  24. package/payload/canon-kit/checks/check-knob-default-coupling.sh +1 -0
  25. package/payload/canon-kit/checks/check-manifest-count.gate +3 -0
  26. package/payload/canon-kit/checks/check-manifest-temporal.gate +3 -0
  27. package/payload/canon-kit/checks/check-md-refs.gate +3 -0
  28. package/payload/canon-kit/checks/check-measured-claim.gate +3 -0
  29. package/payload/canon-kit/checks/check-payload-claim.gate +3 -0
  30. package/payload/canon-kit/checks/check-prose-enum.gate +3 -0
  31. package/payload/canon-kit/checks/check-prose-tells.sh +1 -0
  32. package/payload/canon-kit/checks/check-spec-derivable-section.gate +3 -0
  33. package/payload/canon-kit/checks/check-spec-dod-singleton.gate +3 -0
  34. package/payload/canon-kit/checks/check-spec-embedded-source.sh +1 -0
  35. package/payload/canon-kit/checks/check-spec-fence-balance.gate +3 -0
  36. package/payload/canon-kit/checks/check-spec-pointer.gate +3 -0
  37. package/payload/canon-kit/checks/check-surface-duplication.sh +1 -0
  38. package/payload/canon-kit/checks/check-todo-task-liveness.gate +3 -0
  39. package/payload/canon-kit/checks/check-tracking-claim.gate +3 -0
  40. package/payload/canon-kit/gate-tests/check-comment-tier/bad/.workflow/fixture-state.txt +4 -0
  41. package/payload/canon-kit/gate-tests/check-comment-tier/bad/bad.gate +4 -0
  42. package/payload/canon-kit/gate-tests/check-comment-tier/bad/bad.rs +5 -0
  43. package/payload/canon-kit/gate-tests/check-comment-tier/bad/expect.txt +4 -0
  44. package/payload/canon-kit/gate-tests/check-comment-tier/bad/templates/bad-tmpl.sh +4 -0
  45. package/payload/canon-kit/gate-tests/check-comment-tier/good/.workflow/fixture-state.txt +3 -0
  46. package/payload/canon-kit/gate-tests/check-comment-tier/good/expect.txt +1 -1
  47. package/payload/canon-kit/gate-tests/check-comment-tier/good/good.gate +4 -0
  48. package/payload/canon-kit/gate-tests/check-comment-tier/good/good.rs +5 -0
  49. package/payload/canon-kit/gate-tests/check-comment-tier/good/good.sh +3 -0
  50. package/payload/canon-kit/gate-tests/check-comment-tier/good/templates/good-tmpl.sh +5 -0
  51. package/payload/canon-kit/gate-tests/check-comment-tier.test.sh +29 -5
  52. package/payload/canon-kit/gate-tests/check-deprecation-task/bad/.workflow/fixture-state.txt +3 -0
  53. package/payload/canon-kit/gate-tests/check-deprecation-task/bad/bad.gate +2 -0
  54. package/payload/canon-kit/gate-tests/check-deprecation-task/bad/bad.rs +4 -0
  55. package/payload/canon-kit/gate-tests/check-deprecation-task/bad/expect.txt +3 -0
  56. package/payload/canon-kit/gate-tests/check-deprecation-task/bad/scripts/canon-config.sh +6 -5
  57. package/payload/canon-kit/gate-tests/check-deprecation-task/bad/templates/tmpl.sh +5 -0
  58. package/payload/canon-kit/gate-tests/check-deprecation-task/good/.workflow/fixture-state.txt +3 -0
  59. package/payload/canon-kit/gate-tests/check-deprecation-task/good/expect.txt +1 -1
  60. package/payload/canon-kit/gate-tests/check-deprecation-task/good/good.gate +2 -0
  61. package/payload/canon-kit/gate-tests/check-deprecation-task/good/good.rs +4 -0
  62. package/payload/canon-kit/gate-tests/check-deprecation-task/good/scripts/canon-config.sh +6 -5
  63. package/payload/canon-kit/gate-tests/check-deprecation-task/good/templates/tmpl.sh +5 -0
  64. package/payload/canon-kit/gate-tests/check-deprecation-task.test.sh +4 -3
  65. package/payload/canon-kit/gate-tests/check-docs-link-convention/bad/OUTSIDE.md +4 -0
  66. package/payload/canon-kit/gate-tests/check-docs-link-convention/bad/docs/index.md +3 -0
  67. package/payload/canon-kit/gate-tests/check-docs-link-convention/good/OUTSIDE.md +4 -0
  68. package/payload/canon-kit/gate-tests/check-docs-link-convention/good/docs/methodology.md +8 -0
  69. package/payload/canon-kit/gate-tests/check-docs-link-convention.test.sh +94 -0
  70. package/payload/canon-kit/gate-tests/check-knob-citation.test.sh +2 -2
  71. package/payload/canon-kit/gate-tests/check-manifest-count/good/SPEC.md +4 -0
  72. package/payload/canon-kit/gate-tests/check-manifest-count.test.sh +32 -8
  73. package/payload/canon-kit/gate-tests/check-md-refs.test.sh +61 -9
  74. package/payload/canon-kit/gate-tests/check-measured-claim/bad/SPEC.md +12 -0
  75. package/payload/canon-kit/gate-tests/check-measured-claim/bad/expect.txt +3 -0
  76. package/payload/canon-kit/gate-tests/check-measured-claim/bad/scripts/canon-config.sh +6 -0
  77. package/payload/canon-kit/gate-tests/check-measured-claim/good/SPEC.md +23 -0
  78. package/payload/canon-kit/gate-tests/check-measured-claim/good/expect.txt +1 -0
  79. package/payload/canon-kit/gate-tests/check-measured-claim/good/scripts/canon-config.sh +6 -0
  80. package/payload/canon-kit/gate-tests/check-measured-claim.test.sh +90 -0
  81. package/payload/canon-kit/gate-tests/check-payload-claim/bad/README.md +15 -0
  82. package/payload/canon-kit/gate-tests/check-payload-claim/bad/expect.txt +2 -0
  83. package/payload/canon-kit/gate-tests/check-payload-claim/bad/install.md +19 -0
  84. package/payload/canon-kit/gate-tests/check-payload-claim/bad/posts/note.md +6 -0
  85. package/payload/canon-kit/gate-tests/check-payload-claim/bad/scripts/canon-config.sh +8 -0
  86. package/payload/canon-kit/gate-tests/check-payload-claim/bad/scripts/payload-claims.sh +7 -0
  87. package/payload/canon-kit/gate-tests/check-payload-claim/good/README.md +15 -0
  88. package/payload/canon-kit/gate-tests/check-payload-claim/good/expect.txt +2 -0
  89. package/payload/canon-kit/gate-tests/check-payload-claim/good/install.md +20 -0
  90. package/payload/canon-kit/gate-tests/check-payload-claim/good/posts/note.md +6 -0
  91. package/payload/canon-kit/gate-tests/check-payload-claim/good/scripts/canon-config.sh +8 -0
  92. package/payload/canon-kit/gate-tests/check-payload-claim/good/scripts/payload-claims.sh +7 -0
  93. package/payload/canon-kit/gate-tests/check-prose-enum.test.sh +27 -4
  94. package/payload/canon-kit/gate-tests/check-spec-dod-singleton.test.sh +21 -7
  95. package/payload/canon-kit/gate-tests/check-spec-pointer/bad/.workflow/fixture-state.txt +2 -0
  96. package/payload/canon-kit/gate-tests/check-spec-pointer/bad/bad.gate +2 -0
  97. package/payload/canon-kit/gate-tests/check-spec-pointer/bad/bad.rs +4 -0
  98. package/payload/canon-kit/gate-tests/check-spec-pointer/bad/expect.txt +4 -0
  99. package/payload/canon-kit/gate-tests/check-spec-pointer/bad/templates/tmpl.sh +5 -0
  100. package/payload/canon-kit/gate-tests/check-spec-pointer/bad/widget.sh +1 -0
  101. package/payload/canon-kit/gate-tests/check-spec-pointer/good/.workflow/fixture-state.txt +2 -0
  102. package/payload/canon-kit/gate-tests/check-spec-pointer/good/expect.txt +1 -1
  103. package/payload/canon-kit/gate-tests/check-spec-pointer/good/good.gate +2 -0
  104. package/payload/canon-kit/gate-tests/check-spec-pointer/good/good.rs +4 -0
  105. package/payload/canon-kit/gate-tests/check-spec-pointer/good/templates/tmpl.sh +5 -0
  106. package/payload/canon-kit/gate-tests/check-spec-pointer/good/widget.sh +1 -0
  107. package/payload/canon-kit/gate-tests/check-todo-task-liveness/bad/.workflow/fixture-state.txt +3 -0
  108. package/payload/canon-kit/gate-tests/check-todo-task-liveness/bad/bad.gate +2 -0
  109. package/payload/canon-kit/gate-tests/check-todo-task-liveness/bad/bad.rs +4 -0
  110. package/payload/canon-kit/gate-tests/check-todo-task-liveness/bad/expect.txt +3 -0
  111. package/payload/canon-kit/gate-tests/check-todo-task-liveness/bad/templates/tmpl.sh +5 -0
  112. package/payload/canon-kit/gate-tests/check-todo-task-liveness/good/.workflow/fixture-state.txt +3 -0
  113. package/payload/canon-kit/gate-tests/check-todo-task-liveness/good/expect.txt +1 -1
  114. package/payload/canon-kit/gate-tests/check-todo-task-liveness/good/good.gate +2 -0
  115. package/payload/canon-kit/gate-tests/check-todo-task-liveness/good/good.rs +4 -0
  116. package/payload/canon-kit/gate-tests/check-todo-task-liveness/good/templates/tmpl.sh +5 -0
  117. package/payload/canon-kit/gate-tests/check-tracking-claim.test.sh +1 -2
  118. package/payload/canon-kit/lib/spec.sh +109 -70
  119. package/payload/canon-kit/smoke/install.sh +21 -1
  120. package/payload/canon-kit/templates/SPEC-amendment.md +9 -2
  121. package/payload/context-kit/README.md +4 -1
  122. package/payload/context-kit/SPEC.md +166 -9
  123. package/payload/context-kit/bin/env-probe.sh +19 -6
  124. package/payload/context-kit/checks/check-brevity.sh +1 -0
  125. package/payload/context-kit/checks/check-footprint-fresh.sh +1 -0
  126. package/payload/context-kit/checks/check-memory-off.sh +1 -0
  127. package/payload/context-kit/checks/check-settings-paths.sh +94 -0
  128. package/payload/context-kit/checks/check-settings-pins.sh +1 -0
  129. package/payload/context-kit/gate-tests/check-settings-paths/bad/args +1 -0
  130. package/payload/context-kit/gate-tests/check-settings-paths/bad/expect.txt +3 -0
  131. package/payload/context-kit/gate-tests/check-settings-paths/bad/settings.json +12 -0
  132. package/payload/context-kit/gate-tests/check-settings-paths/bad/tools/real-tool.sh +4 -0
  133. package/payload/context-kit/gate-tests/check-settings-paths/good/args +1 -0
  134. package/payload/context-kit/gate-tests/check-settings-paths/good/expect.txt +1 -0
  135. package/payload/context-kit/gate-tests/check-settings-paths/good/settings.json +16 -0
  136. package/payload/context-kit/gate-tests/check-settings-paths/good/tools/real-tool.sh +4 -0
  137. package/payload/context-kit/index-tests/expected/toolfloor.txt +9 -0
  138. package/payload/context-kit/index-tests/toolfloor-cases.sh +20 -0
  139. package/payload/context-kit/lib/toolfloor.sh +15 -4
  140. package/payload/context-kit/smoke/agents-md.sh +12 -1
  141. package/payload/context-kit/smoke/install.sh +4 -1
  142. package/payload/delegation-kit/README.md +3 -3
  143. package/payload/delegation-kit/SPEC.md +499 -26
  144. package/payload/delegation-kit/bin/run-dispatch-guard-tests.sh +97 -0
  145. package/payload/delegation-kit/checks/check-agent-tier-explicit.sh +1 -0
  146. package/payload/delegation-kit/checks/check-gate-tamper.sh +2 -1
  147. package/payload/delegation-kit/checks/check-rule-citation.sh +1 -0
  148. package/payload/delegation-kit/lib/delegation.sh +1 -0
  149. package/payload/delegation-kit/smoke/install.sh +2 -1
  150. package/payload/delegation-kit/templates/agent-dispatch-guard.sh +61 -0
  151. package/payload/delegation-kit/templates/agent-execution.md +127 -12
  152. package/payload/delegation-kit/templates/delegation-config.sh +4 -0
  153. package/payload/delegation-kit/templates/dispatch-checklists.md +1 -1
  154. package/payload/delegation-kit/templates/statusline-usage.sh +23 -1
  155. package/payload/delegation-kit/usage-tests/dispatch-guard-cases.tsv +30 -0
  156. package/payload/doctrine-kit/DOCTRINE.md +112 -11
  157. package/payload/doctrine-kit/README.md +12 -3
  158. package/payload/doctrine-kit/SPEC.md +163 -11
  159. package/payload/doctrine-kit/bin/install-doctrine.sh +167 -17
  160. package/payload/doctrine-kit/checks/check-doctrine-registration.sh +41 -11
  161. package/payload/doctrine-kit/gate-tests/check-doctrine-registration/bad/DOCTRINE.md +3 -0
  162. package/payload/doctrine-kit/gate-tests/check-doctrine-registration/good/DOCTRINE.md +3 -0
  163. package/payload/doctrine-kit/gate-tests/check-doctrine-registration.test.sh +82 -2
  164. package/payload/doctrine-kit/smoke/install.sh +167 -1
  165. package/payload/drift-kit/README.md +3 -2
  166. package/payload/drift-kit/SPEC.md +264 -22
  167. package/payload/drift-kit/bin/kfric.sh +21 -2
  168. package/payload/drift-kit/bin/stage-economics.sh +157 -3
  169. package/payload/drift-kit/kpis/kpi-incident-recurrence.sh +42 -0
  170. package/payload/drift-kit/smoke/install.sh +183 -1
  171. package/payload/drift-kit/templates/economics.md +9 -0
  172. package/payload/drift-kit/templates/kpis.list +6 -1
  173. package/payload/evidence-kit/README.md +20 -6
  174. package/payload/evidence-kit/SPEC.md +355 -17
  175. package/payload/evidence-kit/bin/run-validate.sh +51 -9
  176. package/payload/evidence-kit/checks/check-battery-roster.sh +87 -0
  177. package/payload/evidence-kit/checks/check-evidence-baseline.sh +1 -0
  178. package/payload/evidence-kit/checks/check-evidence-manifest.sh +1 -0
  179. package/payload/evidence-kit/checks/check-producer-liveness.sh +35 -0
  180. package/payload/evidence-kit/gate-tests/check-battery-roster/bad/args +1 -0
  181. package/payload/evidence-kit/gate-tests/check-battery-roster/bad/expect.txt +1 -0
  182. package/payload/evidence-kit/gate-tests/check-battery-roster/bad/runner.md +14 -0
  183. package/payload/evidence-kit/gate-tests/check-battery-roster/bad/scripts/evidence-config.sh +7 -0
  184. package/payload/evidence-kit/gate-tests/check-battery-roster/good/args +1 -0
  185. package/payload/evidence-kit/gate-tests/check-battery-roster/good/expect.txt +1 -0
  186. package/payload/evidence-kit/gate-tests/check-battery-roster/good/runner.md +14 -0
  187. package/payload/evidence-kit/gate-tests/check-battery-roster/good/scripts/evidence-config.sh +7 -0
  188. package/payload/evidence-kit/gate-tests/check-battery-roster.test.sh +68 -0
  189. package/payload/evidence-kit/gate-tests/check-producer-liveness/bad/args +1 -0
  190. package/payload/evidence-kit/gate-tests/check-producer-liveness/bad/expect.txt +1 -0
  191. package/payload/evidence-kit/gate-tests/check-producer-liveness/bad/run-validate.lock +1 -0
  192. package/payload/evidence-kit/gate-tests/check-producer-liveness/good/args +1 -0
  193. package/payload/evidence-kit/gate-tests/check-producer-liveness/good/expect.txt +2 -0
  194. package/payload/evidence-kit/gate-tests/check-producer-liveness/good/run-validate.lock +1 -0
  195. package/payload/evidence-kit/gate-tests/producer-lock.test.sh +109 -0
  196. package/payload/evidence-kit/lib/evidence.sh +18 -0
  197. package/payload/evidence-kit/smoke/install.sh +17 -3
  198. package/payload/gate-sdk/README.md +17 -1
  199. package/payload/gate-sdk/SPEC.md +4427 -92
  200. package/payload/gate-sdk/bin/build-native.sh +38 -0
  201. package/payload/gate-sdk/bin/enforcement-map.sh +2 -1
  202. package/payload/gate-sdk/bin/gen-pre-commit.sh +32 -2
  203. package/payload/gate-sdk/bin/port-blockers.sh +445 -0
  204. package/payload/gate-sdk/bin/run-consumer-smoke.sh +129 -2
  205. package/payload/gate-sdk/bin/run-gate-tests.sh +61 -9
  206. package/payload/gate-sdk/bin/run-gates.sh +37 -2
  207. package/payload/gate-sdk/bin/upgrade-smoke.sh +55 -7
  208. package/payload/gate-sdk/checks/check-action-gh-repo.gate +3 -0
  209. package/payload/gate-sdk/checks/check-action-pinning.gate +3 -0
  210. package/payload/gate-sdk/checks/check-action-run-shell.sh +4 -1
  211. package/payload/gate-sdk/checks/check-assertion-strength.gate +3 -0
  212. package/payload/gate-sdk/checks/check-commit-msg.sh +1 -0
  213. package/payload/gate-sdk/checks/check-commit-subject.sh +1 -0
  214. package/payload/gate-sdk/checks/check-core-files.sh +28 -4
  215. package/payload/gate-sdk/checks/check-crate-arms.sh +61 -0
  216. package/payload/gate-sdk/checks/check-enforcement-fresh.sh +1 -0
  217. package/payload/gate-sdk/checks/check-exec-bit.sh +21 -1
  218. package/payload/gate-sdk/checks/check-gate-assertions.sh +31 -6
  219. package/payload/gate-sdk/checks/check-gate-binary-fresh.sh +107 -0
  220. package/payload/gate-sdk/checks/check-gate-exemption-tasks.sh +7 -7
  221. package/payload/gate-sdk/checks/check-gate-fail-closed.sh +1 -0
  222. package/payload/gate-sdk/checks/check-gate-fixture-coverage.sh +1 -0
  223. package/payload/gate-sdk/checks/check-gate-output.sh +41 -3
  224. package/payload/gate-sdk/checks/check-gate-substrate-parity.sh +333 -0
  225. package/payload/gate-sdk/checks/check-graph.sh +5 -5
  226. package/payload/gate-sdk/checks/check-hook-exec-bit.sh +1 -0
  227. package/payload/gate-sdk/checks/check-identity.sh +1 -0
  228. package/payload/gate-sdk/checks/check-install-disposition.sh +92 -0
  229. package/payload/gate-sdk/checks/check-kit-enum.sh +1 -0
  230. package/payload/gate-sdk/checks/check-kit-registration.gate +3 -0
  231. package/payload/gate-sdk/checks/check-readme-roster.sh +6 -0
  232. package/payload/gate-sdk/checks/check-reads-couples.sh +71 -21
  233. package/payload/gate-sdk/checks/check-root-tiering.sh +1 -0
  234. package/payload/gate-sdk/checks/check-shellcheck.sh +1 -0
  235. package/payload/gate-sdk/checks/check-smoke-entry-guard.gate +3 -0
  236. package/payload/gate-sdk/checks/check-template-copy-parity.sh +1 -0
  237. package/payload/gate-sdk/checks/check-template-registry-parity.gate +3 -0
  238. package/payload/gate-sdk/checks/check-test-hermetic.gate +3 -0
  239. package/payload/gate-sdk/checks/check-tree-terms.sh +1 -0
  240. package/payload/gate-sdk/checks/check-workflow-tiering.sh +2 -1
  241. package/payload/gate-sdk/gate-tests/check-action-run-shell.test.sh +16 -1
  242. package/payload/gate-sdk/gate-tests/check-core-files.test.sh +64 -0
  243. package/payload/gate-sdk/gate-tests/check-crate-arms/bad/crate/Cargo.toml +7 -0
  244. package/payload/gate-sdk/gate-tests/check-crate-arms/bad/crate/src/lib.rs +12 -0
  245. package/payload/gate-sdk/gate-tests/check-crate-arms/bad/expect.txt +5 -0
  246. package/payload/gate-sdk/gate-tests/check-crate-arms/bad/scripts/gate-sdk-config.sh +2 -0
  247. package/payload/gate-sdk/gate-tests/check-crate-arms/good/crate/Cargo.toml +7 -0
  248. package/payload/gate-sdk/gate-tests/check-crate-arms/good/crate/src/lib.rs +11 -0
  249. package/payload/gate-sdk/gate-tests/check-crate-arms/good/expect.txt +2 -0
  250. package/payload/gate-sdk/gate-tests/check-crate-arms/good/scripts/gate-sdk-config.sh +2 -0
  251. package/payload/gate-sdk/gate-tests/check-gate-assertions/good/expect.txt +1 -1
  252. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/bad/args +2 -0
  253. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/bad/expect.txt +5 -0
  254. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/bad/kitroot/checks/check-vendored.gate +2 -0
  255. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/bad/scripts/check-ported.gate +2 -0
  256. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/bad/scripts/gate-sdk-config.sh +2 -0
  257. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/bad/scripts/gates.list +4 -0
  258. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/bad/stamp.txt +1 -0
  259. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/bad/stub-bin +6 -0
  260. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/good/args +2 -0
  261. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/good/expect.txt +5 -0
  262. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/good/kitroot/checks/check-vendored.gate +2 -0
  263. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/good/scripts/check-ported.gate +2 -0
  264. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/good/scripts/gate-sdk-config.sh +2 -0
  265. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/good/scripts/gates.list +4 -0
  266. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/good/stamp.txt +1 -0
  267. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/good/stub-bin +5 -0
  268. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh.test.sh +81 -0
  269. package/payload/gate-sdk/gate-tests/check-gate-exemption-tasks/bad/TASK-QUEUE.md +3 -1
  270. package/payload/gate-sdk/gate-tests/check-gate-exemption-tasks/bad/expect.txt +3 -1
  271. package/payload/gate-sdk/gate-tests/check-gate-exemption-tasks/bad/gates/check-sample.sh +3 -1
  272. package/payload/gate-sdk/gate-tests/check-gate-exemption-tasks/good/expect.txt +1 -0
  273. package/payload/gate-sdk/gate-tests/check-gate-output/bad/check-native-sample.gate +3 -0
  274. package/payload/gate-sdk/gate-tests/check-gate-output/bad/check-sample.sh +1 -0
  275. package/payload/gate-sdk/gate-tests/check-gate-output/bad/expect.txt +3 -0
  276. package/payload/gate-sdk/gate-tests/check-gate-output/bad/gates.list +1 -0
  277. package/payload/gate-sdk/gate-tests/check-gate-output/bad/native/Cargo.toml +4 -0
  278. package/payload/gate-sdk/gate-tests/check-gate-output/bad/native/src/gates/native_sample.rs +7 -0
  279. package/payload/gate-sdk/gate-tests/check-gate-output/good/check-native-sample.gate +3 -0
  280. package/payload/gate-sdk/gate-tests/check-gate-output/good/check-sample.sh +1 -0
  281. package/payload/gate-sdk/gate-tests/check-gate-output/good/expect.txt +1 -0
  282. package/payload/gate-sdk/gate-tests/check-gate-output/good/gates.list +1 -0
  283. package/payload/gate-sdk/gate-tests/check-gate-output/good/native/Cargo.toml +4 -0
  284. package/payload/gate-sdk/gate-tests/check-gate-output/good/native/src/gates/native_sample.rs +11 -0
  285. package/payload/gate-sdk/gate-tests/check-gate-output.test.sh +111 -0
  286. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/args +2 -0
  287. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/conservation.md +7 -0
  288. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/expect.txt +12 -0
  289. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/impl/gate.rs +2 -0
  290. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/kitroot/check-orphan.rs +3 -0
  291. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/publish.yml +15 -0
  292. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/scripts/check-alpha.sh +3 -0
  293. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/scripts/check-dup.gate +1 -0
  294. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/scripts/check-dup.sh +3 -0
  295. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/scripts/check-orphan.gate +1 -0
  296. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/scripts/gate-sdk-config.sh +6 -0
  297. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/scripts/gates.list +3 -0
  298. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/stub-bin +3 -0
  299. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/targets.list +3 -0
  300. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/args +2 -0
  301. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/conservation.md +8 -0
  302. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/expect.txt +7 -0
  303. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/impl/gate.rs +2 -0
  304. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/kitroot/check-other.rs +3 -0
  305. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/publish.yml +15 -0
  306. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/scripts/check-alpha.sh +3 -0
  307. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/scripts/check-ported.gate +2 -0
  308. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/scripts/gate-sdk-config.sh +6 -0
  309. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/scripts/gates.list +2 -0
  310. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/stub-bin +3 -0
  311. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/targets.list +2 -0
  312. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity.test.sh +184 -0
  313. package/payload/gate-sdk/gate-tests/check-install-disposition/bad/alpha-kit/checks/check-alpha.sh +6 -0
  314. package/payload/gate-sdk/gate-tests/check-install-disposition/bad/alpha-kit/checks/check-delta.sh +5 -0
  315. package/payload/gate-sdk/gate-tests/check-install-disposition/bad/alpha-kit/checks/check-epsilon.sh +6 -0
  316. package/payload/gate-sdk/gate-tests/check-install-disposition/bad/alpha-kit/smoke/install.sh +7 -0
  317. package/payload/gate-sdk/gate-tests/check-install-disposition/bad/args +6 -0
  318. package/payload/gate-sdk/gate-tests/check-install-disposition/bad/expect.txt +1 -0
  319. package/payload/gate-sdk/gate-tests/check-install-disposition/bad/installer/lib/common/recipe.sh +9 -0
  320. package/payload/gate-sdk/gate-tests/check-install-disposition/bad/scripts/gate-sdk-config.sh +5 -0
  321. package/payload/gate-sdk/gate-tests/check-install-disposition/good/alpha-kit/checks/check-alpha.sh +6 -0
  322. package/payload/gate-sdk/gate-tests/check-install-disposition/good/alpha-kit/checks/check-beta.gate +3 -0
  323. package/payload/gate-sdk/gate-tests/check-install-disposition/good/alpha-kit/checks/check-gamma.sh +6 -0
  324. package/payload/gate-sdk/gate-tests/check-install-disposition/good/alpha-kit/smoke/install.sh +8 -0
  325. package/payload/gate-sdk/gate-tests/check-install-disposition/good/args +6 -0
  326. package/payload/gate-sdk/gate-tests/check-install-disposition/good/expect.txt +1 -0
  327. package/payload/gate-sdk/gate-tests/check-install-disposition/good/installer/lib/common/recipe.sh +10 -0
  328. package/payload/gate-sdk/gate-tests/check-install-disposition/good/scripts/gate-sdk-config.sh +5 -0
  329. package/payload/gate-sdk/gate-tests/check-kit-registration.test.sh +6 -5
  330. package/payload/gate-sdk/gate-tests/check-reads-couples.test.sh +139 -0
  331. package/payload/gate-sdk/gate-tests/check-template-registry-parity/bad/alpha-kit/templates/widgets.list +4 -0
  332. package/payload/gate-sdk/gate-tests/check-template-registry-parity/bad/alpha-kit/widgets/widget-one.sh +3 -0
  333. package/payload/gate-sdk/gate-tests/check-template-registry-parity/bad/alpha-kit/widgets/widget-two.sh +3 -0
  334. package/payload/gate-sdk/gate-tests/check-template-registry-parity/bad/args +4 -0
  335. package/payload/gate-sdk/gate-tests/check-template-registry-parity/bad/expect.txt +1 -0
  336. package/payload/gate-sdk/gate-tests/check-template-registry-parity/bad/scripts/gate-sdk-config.sh +5 -0
  337. package/payload/gate-sdk/gate-tests/check-template-registry-parity/good/alpha-kit/templates/widgets.list +4 -0
  338. package/payload/gate-sdk/gate-tests/check-template-registry-parity/good/alpha-kit/widgets/widget-one.sh +3 -0
  339. package/payload/gate-sdk/gate-tests/check-template-registry-parity/good/alpha-kit/widgets/widget-two.sh +3 -0
  340. package/payload/gate-sdk/gate-tests/check-template-registry-parity/good/args +8 -0
  341. package/payload/gate-sdk/gate-tests/check-template-registry-parity/good/beta-kit/templates/rules.list +5 -0
  342. package/payload/gate-sdk/gate-tests/check-template-registry-parity/good/beta-kit/templates/table.tsv +4 -0
  343. package/payload/gate-sdk/gate-tests/check-template-registry-parity/good/expect.txt +1 -0
  344. package/payload/gate-sdk/gate-tests/check-template-registry-parity/good/scripts/gate-sdk-config.sh +5 -0
  345. package/payload/gate-sdk/gate-tests/check-test-hermetic-smoke.test.sh +2 -3
  346. package/payload/gate-sdk/gate-tests/lib-declaration.test.sh +4 -4
  347. package/payload/gate-sdk/gate-tests/lib-gate.test.sh +151 -1
  348. package/payload/gate-sdk/gate-tests/run-dispatch-streams.test.sh +73 -0
  349. package/payload/gate-sdk/gate-tests/run-gate-tests.test.sh +144 -0
  350. package/payload/gate-sdk/lib/consumer-smoke.sh +41 -4
  351. package/payload/gate-sdk/lib/gate.sh +208 -9
  352. package/payload/gate-sdk/lib/inject.sh +46 -1
  353. package/payload/gate-sdk/lib/test-hermetic.sh +26 -0
  354. package/payload/gate-sdk/smoke/install.sh +61 -1
  355. package/payload/guard-kit/README.md +18 -14
  356. package/payload/guard-kit/SPEC.md +366 -72
  357. package/payload/guard-kit/bin/compare-settings-allow.sh +40 -7
  358. package/payload/guard-kit/bin/run-guard-tests.sh +1 -0
  359. package/payload/guard-kit/gate-tests/compare-settings-allow.test.sh +64 -0
  360. package/payload/guard-kit/gate-tests/guard-read-path.test.sh +52 -0
  361. package/payload/guard-kit/guard-tests/cases.tsv +49 -7
  362. package/payload/guard-kit/lib/guard.sh +277 -54
  363. package/payload/guard-kit/templates/close-triage.md +38 -10
  364. package/payload/guard-kit/templates/guard-config.sh +3 -0
  365. package/payload/guard-kit/templates/settings-hooks.json +7 -1
  366. package/payload/lifecycle-kit/README.md +12 -1
  367. package/payload/lifecycle-kit/SPEC.md +991 -41
  368. package/payload/lifecycle-kit/bin/cite-survey.sh +81 -0
  369. package/payload/lifecycle-kit/bin/enter-stage.sh +139 -13
  370. package/payload/lifecycle-kit/bin/file-gap.sh +60 -2
  371. package/payload/lifecycle-kit/bin/file-survey.sh +69 -0
  372. package/payload/lifecycle-kit/checks/check-close-surfaces.sh +1 -0
  373. package/payload/lifecycle-kit/checks/check-gap-inbox-neutrality.gate +3 -0
  374. package/payload/lifecycle-kit/checks/check-lesson-disposition.gate +3 -0
  375. package/payload/lifecycle-kit/checks/check-lifecycle-registration.gate +3 -0
  376. package/payload/lifecycle-kit/checks/check-merge-attrs.gate +3 -0
  377. package/payload/lifecycle-kit/checks/check-scratch-citation.gate +3 -0
  378. package/payload/lifecycle-kit/checks/check-shim-restatement.gate +3 -0
  379. package/payload/lifecycle-kit/checks/check-skill-binding.gate +3 -0
  380. package/payload/lifecycle-kit/checks/check-stage-entry.sh +1 -0
  381. package/payload/lifecycle-kit/checks/check-stage-evidence.gate +3 -0
  382. package/payload/lifecycle-kit/checks/check-stage-skill-coverage.gate +3 -0
  383. package/payload/lifecycle-kit/checks/check-survey-record.gate +3 -0
  384. package/payload/lifecycle-kit/gate-tests/check-close-surfaces.test.sh +1 -2
  385. package/payload/lifecycle-kit/gate-tests/check-gap-inbox-neutrality/bad/args +2 -0
  386. package/payload/lifecycle-kit/gate-tests/check-gap-inbox-neutrality/bad/expect.txt +3 -0
  387. package/payload/lifecycle-kit/gate-tests/check-gap-inbox-neutrality/bad/gap-inbox.md +5 -0
  388. package/payload/lifecycle-kit/gate-tests/check-gap-inbox-neutrality/good/args +2 -0
  389. package/payload/lifecycle-kit/gate-tests/check-gap-inbox-neutrality/good/expect.txt +1 -0
  390. package/payload/lifecycle-kit/gate-tests/check-gap-inbox-neutrality/good/gap-inbox.md +4 -0
  391. package/payload/lifecycle-kit/gate-tests/check-lesson-disposition.test.sh +2 -3
  392. package/payload/lifecycle-kit/gate-tests/check-lifecycle-registration.test.sh +2 -3
  393. package/payload/lifecycle-kit/gate-tests/check-merge-attrs/bad/.gitattributes +1 -0
  394. package/payload/lifecycle-kit/gate-tests/check-merge-attrs/good/.gitattributes +1 -0
  395. package/payload/lifecycle-kit/gate-tests/check-merge-attrs.test.sh +3 -3
  396. package/payload/lifecycle-kit/gate-tests/check-scratch-citation/bad/expect.txt +1 -0
  397. package/payload/lifecycle-kit/gate-tests/check-scratch-citation/bad/scripts/lifecycle-config.sh +4 -0
  398. package/payload/lifecycle-kit/gate-tests/check-scratch-citation/bad/surfaces/queue.md +13 -0
  399. package/payload/lifecycle-kit/gate-tests/check-scratch-citation/good/expect.txt +1 -0
  400. package/payload/lifecycle-kit/gate-tests/check-scratch-citation/good/scripts/lifecycle-config.sh +4 -0
  401. package/payload/lifecycle-kit/gate-tests/check-scratch-citation/good/surfaces/queue.md +31 -0
  402. package/payload/lifecycle-kit/gate-tests/check-shim-restatement.test.sh +2 -3
  403. package/payload/lifecycle-kit/gate-tests/check-skill-binding.test.sh +2 -3
  404. package/payload/lifecycle-kit/gate-tests/check-stage-entry.test.sh +2 -3
  405. package/payload/lifecycle-kit/gate-tests/check-stage-evidence.test.sh +9 -5
  406. package/payload/lifecycle-kit/gate-tests/check-survey-record/bad/args +2 -0
  407. package/payload/lifecycle-kit/gate-tests/check-survey-record/bad/expect.txt +4 -0
  408. package/payload/lifecycle-kit/gate-tests/check-survey-record/bad/record.md +18 -0
  409. package/payload/lifecycle-kit/gate-tests/check-survey-record/good/args +2 -0
  410. package/payload/lifecycle-kit/gate-tests/check-survey-record/good/expect.txt +1 -0
  411. package/payload/lifecycle-kit/gate-tests/check-survey-record/good/record.md +13 -0
  412. package/payload/lifecycle-kit/gate-tests/check-survey-record.test.sh +83 -0
  413. package/payload/lifecycle-kit/gate-tests/file-gap-recurrence.test.sh +122 -0
  414. package/payload/lifecycle-kit/gate-tests/rename-iteration.test.sh +142 -0
  415. package/payload/lifecycle-kit/gate-tests/survey-record-entry.test.sh +102 -0
  416. package/payload/lifecycle-kit/gate-tests/workflow-state-guard.test.sh +100 -0
  417. package/payload/lifecycle-kit/lib/stages.sh +12 -2
  418. package/payload/lifecycle-kit/smoke/install.sh +83 -4
  419. package/payload/lifecycle-kit/templates/consult.md +73 -0
  420. package/payload/lifecycle-kit/templates/lead.md +139 -7
  421. package/payload/lifecycle-kit/templates/stages/align.md +12 -0
  422. package/payload/lifecycle-kit/templates/stages/build.md +8 -0
  423. package/payload/lifecycle-kit/templates/stages/close.md +45 -5
  424. package/payload/lifecycle-kit/templates/stages/scope.md +42 -3
  425. package/payload/lifecycle-kit/templates/stages/spec.md +13 -1
  426. package/payload/lifecycle-kit/templates/stages/validate.md +8 -0
  427. package/payload/lifecycle-kit/templates/workflow-state-guard.sh +29 -0
  428. package/payload/queue-kit/README.md +6 -1
  429. package/payload/queue-kit/SPEC.md +350 -6
  430. package/payload/queue-kit/bin/queue-counts.sh +35 -0
  431. package/payload/queue-kit/bin/queue-edges.sh +78 -0
  432. package/payload/queue-kit/checks/check-queue-entry-budget.gate +3 -0
  433. package/payload/queue-kit/checks/check-queue-hygiene.gate +3 -0
  434. package/payload/queue-kit/checks/check-queue-prose-precondition.sh +1 -0
  435. package/payload/queue-kit/checks/check-queue-sections.gate +3 -0
  436. package/payload/queue-kit/checks/check-queue-slug-liveness.gate +3 -0
  437. package/payload/queue-kit/checks/check-queue-wrap.gate +3 -0
  438. package/payload/queue-kit/checks/check-roadmap-fresh.sh +1 -0
  439. package/payload/queue-kit/checks/check-tag-lead-line.gate +3 -0
  440. package/payload/queue-kit/checks/check-task-conservation.gate +4 -0
  441. package/payload/queue-kit/checks/check-task-names.gate +3 -0
  442. package/payload/queue-kit/gate-tests/check-queue-hygiene/good/TASK-QUEUE.md +5 -0
  443. package/payload/queue-kit/gate-tests/queue-counts.test.sh +116 -0
  444. package/payload/queue-kit/gate-tests/queue-edges.test.sh +130 -0
  445. package/payload/queue-kit/gate-tests/queue-lib-parity.test.sh +215 -0
  446. package/payload/queue-kit/lib/queue.sh +4 -19
  447. package/payload/queue-kit/smoke/install.sh +4 -1
  448. package/payload/queue-kit/templates/TASK-QUEUE.md +3 -0
  449. package/payload/site-kit/SPEC.md +64 -27
  450. package/payload/site-kit/checks/check-docs-cname-parity.sh +1 -0
  451. package/payload/site-kit/checks/check-docs-render-fidelity.sh +1 -0
  452. package/payload/site-kit/smoke/install.sh +9 -1
  453. package/profiles.list +36 -8
  454. package/payload/canon-kit/checks/check-comment-tier.sh +0 -211
  455. package/payload/canon-kit/checks/check-deprecation-task.sh +0 -90
  456. package/payload/canon-kit/checks/check-docs-cmd.sh +0 -153
  457. package/payload/canon-kit/checks/check-install-claim.sh +0 -146
  458. package/payload/canon-kit/checks/check-knob-citation.sh +0 -117
  459. package/payload/canon-kit/checks/check-manifest-count.sh +0 -46
  460. package/payload/canon-kit/checks/check-manifest-temporal.sh +0 -83
  461. package/payload/canon-kit/checks/check-md-refs.sh +0 -128
  462. package/payload/canon-kit/checks/check-prose-enum.sh +0 -115
  463. package/payload/canon-kit/checks/check-spec-derivable-section.sh +0 -69
  464. package/payload/canon-kit/checks/check-spec-dod-singleton.sh +0 -45
  465. package/payload/canon-kit/checks/check-spec-fence-balance.sh +0 -42
  466. package/payload/canon-kit/checks/check-spec-pointer.sh +0 -180
  467. package/payload/canon-kit/checks/check-todo-task-liveness.sh +0 -80
  468. package/payload/canon-kit/checks/check-tracking-claim.sh +0 -136
  469. package/payload/gate-sdk/checks/check-action-gh-repo.sh +0 -321
  470. package/payload/gate-sdk/checks/check-action-pinning.sh +0 -55
  471. package/payload/gate-sdk/checks/check-assertion-strength.sh +0 -134
  472. package/payload/gate-sdk/checks/check-kit-registration.sh +0 -68
  473. package/payload/gate-sdk/checks/check-smoke-entry-guard.sh +0 -53
  474. package/payload/gate-sdk/checks/check-test-hermetic.sh +0 -119
  475. package/payload/lifecycle-kit/checks/check-lesson-disposition.sh +0 -98
  476. package/payload/lifecycle-kit/checks/check-lifecycle-registration.sh +0 -54
  477. package/payload/lifecycle-kit/checks/check-merge-attrs.sh +0 -69
  478. package/payload/lifecycle-kit/checks/check-shim-restatement.sh +0 -97
  479. package/payload/lifecycle-kit/checks/check-skill-binding.sh +0 -59
  480. package/payload/lifecycle-kit/checks/check-stage-evidence.sh +0 -81
  481. package/payload/lifecycle-kit/checks/check-stage-skill-coverage.sh +0 -47
  482. package/payload/queue-kit/checks/check-queue-entry-budget.sh +0 -104
  483. package/payload/queue-kit/checks/check-queue-hygiene.sh +0 -81
  484. package/payload/queue-kit/checks/check-queue-sections.sh +0 -44
  485. package/payload/queue-kit/checks/check-queue-slug-liveness.sh +0 -63
  486. package/payload/queue-kit/checks/check-queue-wrap.sh +0 -56
  487. package/payload/queue-kit/checks/check-tag-lead-line.sh +0 -70
  488. package/payload/queue-kit/checks/check-task-conservation.sh +0 -50
  489. package/payload/queue-kit/checks/check-task-names.sh +0 -128
@@ -23,10 +23,11 @@ unset _frik_cfg
23
23
  : "${GUARD_KIT_WAKEUP_LOG:=${GATE_SDK_WORKFLOW_DIR:-.workflow}/wakeup-attempts.log}"
24
24
  : "${GUARD_KIT_SETTINGS:=.claude/settings.json}"
25
25
  : "${GUARD_KIT_SETTINGS_LOCAL:=.claude/settings.local.json}"
26
+ declare -p GUARD_KIT_BREADTH_PROBES >/dev/null 2>&1 || GUARD_KIT_BREADTH_PROBES=()
26
27
  declare -p GUARD_KIT_RO_SCRIPTS >/dev/null 2>&1 || GUARD_KIT_RO_SCRIPTS=("check-*.sh")
27
28
  declare -p GUARD_KIT_SCRATCH_DIRS >/dev/null 2>&1 || GUARD_KIT_SCRATCH_DIRS=(".tmp")
28
29
  declare -p GUARD_KIT_RO_BINS >/dev/null 2>&1 || GUARD_KIT_RO_BINS=(
29
- grep egrep fgrep rg head tail cat wc sort uniq cut tr nl rev tac paste comm column diff jq find ls
30
+ grep egrep fgrep rg head tail cat wc sort uniq cut tr nl rev tac paste comm column diff jq find ls xargs
30
31
  )
31
32
 
32
33
  guard_read_command() {
@@ -37,6 +38,15 @@ guard_read_command() {
37
38
  printf '%s' "$cmd"
38
39
  }
39
40
 
41
+ # spec: guard-kit/SPEC.md §The guard framework — the path counterpart of guard_read_command; a call carrying no file_path returns non-zero so a matcher covering it falls through instead of blocking
42
+ guard_read_path() {
43
+ local input path
44
+ input="$(cat 2>/dev/null)" || return 1
45
+ path="$(printf '%s' "$input" | jq -r '.tool_input.file_path // empty' 2>/dev/null)" || return 1
46
+ [[ -z "$path" ]] && return 1
47
+ printf '%s' "$path"
48
+ }
49
+
40
50
  guard_block() {
41
51
  printf '%s\n' "${GUARD_NAME:-guard}: $1" >&2
42
52
  exit 2
@@ -71,35 +81,212 @@ guard_allow_match() {
71
81
  [[ "$s" == $glob ]]
72
82
  }
73
83
 
74
- # spec: guard-kit/SPEC.md §The guard framework — one splitter for every consumer that reasons per compound segment (rules 8/14/16, the read-compound carve-out, scan-prompts), fed a quote-stripped skeleton so the harness's per-segment boundary set never drifts
84
+ # spec: guard-kit/SPEC.md §The guard framework — the one context-aware normalizer; a rule names the classes inert for it and every lexical view in the file comes from here
85
+ guard_skeleton() {
86
+ local cmd="$1"
87
+ shift
88
+ local c want_sq=0 want_dq=0 want_hd=0 want_hdq=0
89
+ for c in "$@"; do
90
+ case "$c" in
91
+ sq) want_sq=1 ;;
92
+ dq) want_dq=1 ;;
93
+ hd) want_hd=1 ;;
94
+ hdq) want_hdq=1 ;;
95
+ esac
96
+ done
97
+
98
+ # comment-tier-exempt: measured local fact — jumping between significant characters rather than stepping per character took a 355-char command from 2.3ms to 0.17ms, at fourteen call sites per guarded call
99
+ local nl=$'\n'
100
+ local live_class="[\"'\\\\<${nl}]*" dq_class="[\"\\\\]*"
101
+ local n=${#cmd} i=0 out='' span='' state=none ch rest chunk line term body quoted
102
+ local -a pending=() pending_q=()
103
+ while ((i < n)); do
104
+ rest="${cmd:i}"
105
+ if [[ "$state" == sq ]]; then
106
+ chunk="${rest%%\'*}"
107
+ if [[ "$chunk" == "$rest" ]]; then
108
+ span+="$rest"
109
+ i=$n
110
+ continue
111
+ fi
112
+ span+="$chunk'"
113
+ ((i += ${#chunk} + 1))
114
+ if ((want_sq)); then out+='SQ'; else out+="$span"; fi
115
+ span=''
116
+ state=none
117
+ continue
118
+ fi
119
+ if [[ "$state" == dq ]]; then
120
+ chunk="${rest%%$dq_class}"
121
+ span+="$chunk"
122
+ ((i += ${#chunk}))
123
+ if ((i >= n)); then continue; fi
124
+ if [[ "${cmd:i:1}" == '\' ]]; then
125
+ span+="${cmd:i:2}"
126
+ ((i += 2))
127
+ continue
128
+ fi
129
+ span+='"'
130
+ ((i++))
131
+ if ((want_dq)); then out+='DQ'; else out+="$span"; fi
132
+ span=''
133
+ state=none
134
+ continue
135
+ fi
136
+ chunk="${rest%%$live_class}"
137
+ if [[ -n "$chunk" ]]; then
138
+ out+="$chunk"
139
+ ((i += ${#chunk}))
140
+ ((i >= n)) && continue
141
+ fi
142
+ ch="${cmd:i:1}"
143
+ case "$ch" in
144
+ "'")
145
+ state=sq
146
+ span="'"
147
+ ((i++))
148
+ continue ;;
149
+ '"')
150
+ state=dq
151
+ span='"'
152
+ ((i++))
153
+ continue ;;
154
+ '\')
155
+ out+="${cmd:i:2}"
156
+ ((i += 2))
157
+ continue ;;
158
+ '<')
159
+ if [[ "${cmd:i:3}" == '<<<' ]]; then
160
+ out+='<<<'
161
+ ((i += 3))
162
+ continue
163
+ fi
164
+ if [[ "${cmd:i}" =~ ^\<\<-?[[:space:]]*(\"[^\"]*\"|\'[^\']*\'|[A-Za-z_][A-Za-z0-9_]*) ]]; then
165
+ out+="${BASH_REMATCH[0]}"
166
+ ((i += ${#BASH_REMATCH[0]}))
167
+ term="${BASH_REMATCH[1]}"
168
+ case "$term" in
169
+ \"*\" | \'*\') pending_q+=(1) ;;
170
+ *) pending_q+=(0) ;;
171
+ esac
172
+ term="${term#[\"\']}"
173
+ term="${term%[\"\']}"
174
+ pending+=("$term")
175
+ continue
176
+ fi
177
+ ;;
178
+ $'\n')
179
+ out+=$'\n'
180
+ ((i++))
181
+ while ((${#pending[@]} > 0)); do
182
+ term="${pending[0]}"
183
+ quoted="${pending_q[0]}"
184
+ pending=("${pending[@]:1}")
185
+ pending_q=("${pending_q[@]:1}")
186
+ body=''
187
+ while ((i < n)); do
188
+ rest="${cmd:i}"
189
+ line="${rest%%$'\n'*}"
190
+ [[ "${line#"${line%%[![:space:]]*}"}" == "$term" ]] && break
191
+ body+="$line"$'\n'
192
+ ((i += ${#line} + 1))
193
+ ((i > n)) && i=$n
194
+ done
195
+ if [[ -n "$body" ]]; then
196
+ if ((want_hd)) || { ((want_hdq)) && ((quoted)); }; then
197
+ out+='HD'$'\n'
198
+ else
199
+ out+="$body"
200
+ fi
201
+ fi
202
+ if ((i < n)); then
203
+ rest="${cmd:i}"
204
+ line="${rest%%$'\n'*}"
205
+ out+="$line"
206
+ ((i += ${#line}))
207
+ if ((i < n)); then
208
+ out+=$'\n'
209
+ ((i++))
210
+ fi
211
+ fi
212
+ done
213
+ continue ;;
214
+ esac
215
+ out+="$ch"
216
+ ((i++))
217
+ done
218
+ [[ -n "$span" ]] && out+="$span"
219
+ printf '%s' "$out"
220
+ }
221
+
222
+ # spec: guard-kit/SPEC.md §The guard framework — one splitter for every consumer that reasons per compound segment (rules 8/13/14/16, the read-compound carve-out, scan-prompts), fed a guard_skeleton view so the harness's per-segment boundary set never drifts
75
223
  guard_split_compound() {
76
224
  sed -E 's/\|\||&&|;|\|/\n/g' <<<"$1"
77
225
  }
78
226
 
227
+ # spec: guard-kit/SPEC.md §The generic ruleset — the committed Bash(...) allow inners, one per line; the fail-open read rules 13 and 14 share, so a missing jq or settings file emits nothing and every reader declines
228
+ _guard_allow_inners() {
229
+ command -v jq >/dev/null 2>&1 || return 0
230
+ [[ -f "$GUARD_KIT_SETTINGS" ]] || return 0
231
+ local e inner
232
+ while IFS= read -r e; do
233
+ case "$e" in
234
+ Bash\(*\)) inner="${e#Bash(}"; inner="${inner%)}" ;;
235
+ *) continue ;;
236
+ esac
237
+ [[ -n "$inner" ]] && printf '%s\n' "$inner"
238
+ done < <(jq -r '.permissions.allow[]?' "$GUARD_KIT_SETTINGS" 2>/dev/null)
239
+ }
240
+
241
+ # spec: guard-kit/SPEC.md §The generic ruleset — a segment with its redirects removed and trimmed: what rules 13 and 14 compare against a committed bare allow entry
242
+ _guard_segment_core() {
243
+ local seg
244
+ seg="$(sed -E 's/[[:space:]]*[0-9]*(>>?|<)[[:space:]]*(&?[0-9-]+|[^[:space:]]+)?//g' <<<"$1")"
245
+ seg="${seg#"${seg%%[![:space:]]*}"}"
246
+ seg="${seg%"${seg##*[![:space:]]}"}"
247
+ printf '%s' "$seg"
248
+ }
249
+
250
+ # spec: guard-kit/SPEC.md §The generic ruleset — true when the segment exactly matches a committed *bare* allow entry (no glob): the reviewed-lead half of rule 13's predicate and rule 14's lead test
251
+ _guard_is_bare_allow() {
252
+ local core bl
253
+ core="$(_guard_segment_core "$1")"
254
+ [[ -n "$core" ]] || return 1
255
+ while IFS= read -r bl; do
256
+ case "$bl" in *'*'*) continue ;; esac
257
+ [[ "$core" == "$bl" ]] && return 0
258
+ done < <(_guard_allow_inners)
259
+ return 1
260
+ }
261
+
79
262
  # spec: guard-kit/SPEC.md §The generic ruleset — the guard_rule_* run below; order is load-bearing
80
263
  guard_rule_cd_compound() {
81
- local cmd="$1"
264
+ local cmd
265
+ cmd="$(guard_skeleton "$1" sq dq hd)"
82
266
  if grep -qE '(^|[;&|(])[[:space:]]*cd[[:space:]]' <<<"$cmd" && grep -qE '[;&|]' <<<"$cmd"; then
83
- guard_block "don't use 'cd' in a compound command (permission prompts / cwd drift). Pass absolute paths, or 'git -C <dir>' for git."
267
+ guard_block "don't use 'cd' in a compound command (cwd drift, and the allowlist can't match the compound — the call costs an out-of-band permission decision). Pass absolute paths, or 'git -C <dir>' for git."
84
268
  fi
85
269
  }
86
270
 
87
271
  guard_rule_git_c_root() {
88
- local cmd="$1"
272
+ local cmd
273
+ cmd="$(guard_skeleton "$1" sq dq hd)"
89
274
  if grep -qF "git -C $PWD " <<<"$cmd"; then
90
- guard_block "drop 'git -C $PWD ' — cwd is the repo root, so the bare 'git <subcommand>' form is allowlisted and won't re-prompt. Reserve 'git -C <dir>' for a different repo."
275
+ guard_block "drop 'git -C $PWD ' — cwd is the repo root, so the bare 'git <subcommand>' form is allowlisted and resolves on the match; the absolute '-C' spelling matches nothing and costs an out-of-band permission decision. Reserve 'git -C <dir>' for a different repo."
91
276
  fi
92
277
  }
93
278
 
94
279
  guard_rule_scratch_redirect() {
95
- local cmd="$1"
280
+ local cmd
281
+ cmd="$(guard_skeleton "$1" sq dq hd)"
96
282
  if grep -qE '(^|[[:space:]])([0-9]*|&)>>?[[:space:]]*[^[:space:]/|&]+\.(err|out|log)([[:space:]]|$)' <<<"$cmd"; then
97
283
  guard_block "don't redirect scratch to a bare repo-root filename (e.g. 2> op.err) — it pollutes cwd and risks a 'git add -A'. Send it to a gitignored scratch dir (e.g. ${GUARD_KIT_SCRATCH_DIRS[0]}/<name>.err)."
98
284
  fi
99
285
  }
100
286
 
101
287
  guard_rule_abs_script() {
102
- local cmd="$1" rest base g relcmd
288
+ local raw="$1" cmd rest base g relcmd
289
+ cmd="$(guard_skeleton "$raw" sq dq hd)"
103
290
  case "$cmd" in
104
291
  "bash $PWD/"*) rest="${cmd#bash "$PWD/"}" ;;
105
292
  "$PWD/"*) rest="${cmd#"$PWD/"}" ;;
@@ -108,39 +295,44 @@ guard_rule_abs_script() {
108
295
  rest="${rest%%[[:space:]]*}" # first token = repo-relative script path
109
296
  case "$rest" in *.sh) ;; *) return 0 ;; esac # only .sh scripts; rule 5 handles the rest
110
297
  base="${rest##*/}"
111
- relcmd="${cmd//"$PWD/"/}" # strip every repo-root prefix
298
+ relcmd="${raw//"$PWD/"/}" # the rewrite carries the real command, not its skeleton
112
299
  for g in "${GUARD_KIT_RO_SCRIPTS[@]}"; do
113
300
  # shellcheck disable=SC2053 # intentional glob match: $g is a pattern, not a literal
114
301
  if [[ "$base" == $g || "$rest" == $g ]]; then
115
302
  guard_rewrite "$relcmd" "abs repo read-only script normalized to relative (${GUARD_NAME:-guard})"
116
303
  fi
117
304
  done
118
- guard_block "use the repo-relative form '$rest' (cwd is the repo root) — it's allowlisted and won't re-prompt; the absolute spelling isn't. If you truly need the absolute path, run it yourself with !<command>."
305
+ guard_block "use the repo-relative form '$rest' (cwd is the repo root) — it's allowlisted and resolves on the match; the absolute spelling matches nothing and costs an out-of-band permission decision. If you truly need the absolute path, run it yourself with !<command>."
119
306
  }
120
307
 
121
308
  guard_rule_abs_prefix() {
122
- local cmd="$1"
309
+ local cmd
310
+ cmd="$(guard_skeleton "$1" sq dq hd)"
123
311
  [[ "$cmd" == git\ * ]] && return 0
124
312
  if grep -qF "$PWD/" <<<"$cmd"; then
125
- guard_block "drop the repo-root absolute prefix '$PWD/' — cwd is the repo root, so the repo-relative path is allowlisted and won't re-prompt; the absolute spelling isn't. If you truly need the absolute path, run it yourself with !<command>."
313
+ guard_block "drop the repo-root absolute prefix '$PWD/' — cwd is the repo root, so the repo-relative path is allowlisted and resolves on the match; the absolute spelling matches nothing and costs an out-of-band permission decision. If you truly need the absolute path, run it yourself with !<command>."
126
314
  fi
127
315
  }
128
316
 
129
317
  guard_rule_expansion() {
130
318
  local cmd="$1" sqexp expn
131
- sqexp="$(sed -E "s/'[^']*'//g" <<<"$cmd")"
319
+ # spec: guard-kit/SPEC.md §The generic ruleset — a double-quoted "$x" still expands, so 'dq'
320
+ # stays live; a quoted-delimiter heredoc body cannot, which is what 'hdq' names
321
+ sqexp="$(guard_skeleton "$cmd" sq hdq)"
132
322
  if grep -qE '\$\{|\$\(|<\(|\$[A-Za-z_]' <<<"$sqexp"; then
133
- guard_block "avoid shell variables/expansions (\$VAR, \${...}, \$(...), <(...)) — the harness prompts on every expansion and no allowlist entry can suppress it. Inline the literal path, use a relative path, or 'git -C <dir>'. If you genuinely need the expansion, run it yourself with !<command>."
323
+ guard_block "avoid shell variables/expansions (\$VAR, \${...}, \$(...), <(...)) — the harness's matcher refuses every expansion, so no allowlist entry can match the command and it costs an out-of-band permission decision. Inline the literal path, use a relative path, or 'git -C <dir>'. If you genuinely need the expansion, run it yourself with !<command>."
134
324
  fi
135
- expn="$(sed -E "s/'[^']*'//g; s/\"[^\"]*\"//g" <<<"$cmd")"
325
+ expn="$(guard_skeleton "$cmd" sq dq hdq)"
136
326
  if grep -qE '(^|[;(]|&&|\|\|)[[:space:]]*[A-Za-z_][A-Za-z0-9_]*=[^[:space:];|&]*[[:space:]]*($|;)' <<<"$expn"; then
137
- guard_block "avoid shell variable assignments (NAME=value; ... \$NAME) — they force a permission prompt that can't be allowlisted. Inline the literal value/path at each use site, or 'git -C <dir>'. If you genuinely need it, run it yourself with !<command>."
327
+ guard_block "avoid shell variable assignments (NAME=value; ... \$NAME) — they defeat allowlist matching, so the call costs an out-of-band permission decision no allowlist entry can pre-empt. Inline the literal value/path at each use site, or 'git -C <dir>'. If you genuinely need it, run it yourself with !<command>."
138
328
  fi
139
329
  }
140
330
 
141
331
  guard_rule_brace_glyph() {
142
332
  local cmd="$1" sqstripped resid ph='{}' q="'{}'"
143
- sqstripped="$(sed -E "s/'[^']*'//g" <<<"$cmd")"
333
+ # spec: guard-kit/SPEC.md §The generic ruleset — 'sq dq hd': '{' is a matcher glyph, not a
334
+ # shell expansion, so rule 6's reason to keep double-quoted spans live does not carry here.
335
+ sqstripped="$(guard_skeleton "$cmd" sq dq hd)"
144
336
  case "$sqstripped" in *'{'*) ;; *) return 0 ;; esac
145
337
  resid="${sqstripped//"$ph"/}"
146
338
  case "$resid" in
@@ -149,12 +341,12 @@ guard_rule_brace_glyph() {
149
341
  "bare {} placeholder single-quoted so the harness matcher passes it (${GUARD_NAME:-guard})" ;;
150
342
  esac
151
343
  if grep -qF '@{' <<<"$sqstripped"; then
152
- guard_block "spell out the git-ref shorthand '@{...}' — the harness prompts on the '{' glyph. Use 'origin/<branch>..HEAD' for '@{u}..', or the resolved ref/hash for a reflog form."
344
+ guard_block "spell out the git-ref shorthand '@{...}' — the harness's matcher refuses the '{' glyph, so the call costs an out-of-band permission decision. Use 'origin/<branch>..HEAD' for '@{u}..', or the resolved ref/hash for a reflog form."
153
345
  fi
154
346
  if grep -qE '\{[^}]*(,|\.\.)[^}]*\}' <<<"$sqstripped"; then
155
- guard_block "write out the brace expansion '{a,b}'/'{a..b}' — the harness prompts on the '{' glyph and no allowlist entry suppresses it. Spell the members (e.g. 'mkdir -p a/b a/c') or use a loop for a long range."
347
+ guard_block "write out the brace expansion '{a,b}'/'{a..b}' — the harness's matcher refuses the '{' glyph and no allowlist entry can match around it, so the call costs an out-of-band permission decision. Spell the members (e.g. 'mkdir -p a/b a/c') or use a loop for a long range."
156
348
  fi
157
- guard_block "single-quote the '{' if it's literal (an awk/sed program in double quotes), or write it out if it expands — the harness prompts on every bare '{' glyph before allowlist matching."
349
+ guard_block "quote the '{' if it's literal (an unquoted awk/sed program), or write it out if it expands — the harness's matcher refuses every bare '{' glyph before allowlist matching, so the call is decided out of band. A brace inside quotes of either kind, or in a heredoc body, is already inert and never reaches this block."
158
350
  }
159
351
 
160
352
  _guard_sed_segment() {
@@ -186,7 +378,7 @@ _guard_sed_segment() {
186
378
 
187
379
  guard_rule_sed_file() {
188
380
  local cmd="$1" s seg
189
- s="$(sed -E "s/'[^']*'/SQ/g; s/\"[^\"]*\"/DQ/g" <<<"$cmd")"
381
+ s="$(guard_skeleton "$cmd" sq dq hd)"
190
382
  while IFS= read -r seg; do
191
383
  seg="${seg#"${seg%%[![:space:]]*}"}"
192
384
  case "$seg" in
@@ -214,6 +406,34 @@ _guard_is_cat_read() {
214
406
  [[ "$operands" == 1 ]]
215
407
  }
216
408
 
409
+ # spec: guard-kit/SPEC.md §The generic ruleset — rule 13's xargs discriminator: xargs runs a command rather than filtering text, so the segment is read-only only when the command it runs is itself on the roster
410
+ _guard_is_ro_xargs() {
411
+ local seg="${1#"${1%%[![:space:]]*}"}" tok want_arg=0 cmdtok='' b i n
412
+ local -a toks
413
+ read -ra toks <<<"$seg"
414
+ [[ "${toks[0]:-}" == xargs ]] || return 1
415
+ n=${#toks[@]}
416
+ for ((i = 1; i < n; i++)); do
417
+ tok="${toks[i]}"
418
+ if [[ "$want_arg" == 1 ]]; then want_arg=0; continue; fi
419
+ case "$tok" in
420
+ -0 | -t | -r | -x | -p | --null | --no-run-if-empty | --verbose | --exit | --interactive | --open-tty) ;;
421
+ -I | -L | -n | -P | -s | -E | -d | -a) want_arg=1 ;;
422
+ -[0ILnPsEdae]*) ;;
423
+ --*=*) ;;
424
+ -*) return 1 ;;
425
+ *) cmdtok="$tok"; break ;;
426
+ esac
427
+ done
428
+ [[ -z "$cmdtok" ]] && return 0
429
+ [[ "$cmdtok" == xargs ]] && return 1
430
+ case "$cmdtok" in echo | printf) return 0 ;; esac
431
+ for b in "${GUARD_KIT_RO_BINS[@]}"; do
432
+ [[ "$cmdtok" == "$b" ]] && return 0
433
+ done
434
+ return 1
435
+ }
436
+
217
437
  # spec: guard-kit/SPEC.md §The generic ruleset — one segment is a bare find listing: leads with find, carries no action predicate
218
438
  _guard_is_find_listing() {
219
439
  local seg="${1#"${1%%[![:space:]]*}"}"
@@ -241,27 +461,27 @@ guard_rule_find_glob() {
241
461
  local cmd="$1" s
242
462
  grep -qE '\$\(|<\(|>\(' <<<"$cmd" && return 0
243
463
  case "$cmd" in *'`'*) return 0 ;; esac
244
- s="$(sed -E "s/'[^']*'//g; s/\"[^\"]*\"//g" <<<"$cmd")"
464
+ s="$(guard_skeleton "$cmd" sq dq hd)"
245
465
  grep -qE '(&&|\|\||\||&|<|>)' <<<"$s" && return 0
246
466
  _guard_is_read_batch "$s" _guard_is_find_listing || return 0
247
- guard_block "don't list files with a bare 'find' — use the Glob tool: it returns matching paths (registered for a later Read) with no shell prompt. This fires on a lone listing and on a ';'-sequence of them (a literal echo/printf banner between them is fine); a 'find' carrying an action predicate (-exec/-delete/…), piped into a consumer, or redirected is untouched. If you genuinely need find, run it yourself with !<command>."
467
+ guard_block "don't list files with a bare 'find' — use the Glob tool: it returns matching paths (registered for a later Read) and needs no permission decision at all. This fires on a lone listing and on a ';'-sequence of them (a literal echo/printf banner between them is fine); a 'find' carrying an action predicate (-exec/-delete/…), piped into a consumer, or redirected is untouched. If you genuinely need find, run it yourself with !<command>."
248
468
  }
249
469
 
250
470
  guard_rule_cat_file() {
251
471
  local cmd="$1" s
252
472
  grep -qE '\$\(|<\(|>\(' <<<"$cmd" && return 0
253
473
  case "$cmd" in *'`'*) return 0 ;; esac
254
- s="$(sed -E "s/'[^']*'/SQ/g; s/\"[^\"]*\"/DQ/g" <<<"$cmd")"
474
+ s="$(guard_skeleton "$cmd" sq dq hd)"
255
475
  grep -qE '(&&|\|\||\||&|<|>)' <<<"$s" && return 0
256
476
  _guard_is_read_batch "$s" _guard_is_cat_read || return 0
257
- guard_block "don't read files with a bare 'cat' — use the Read tool: it returns numbered lines registered for a later Edit, with no shell prompt. This fires on a lone 'cat <file>' and on a ';'-sequence of them (a literal echo/printf banner between reads is fine — batch them into one Read); a 'cat' feeding a pipe or heredoc, redirecting, or concatenating multiple files in one command is composition and untouched. If you genuinely need cat, run it yourself with !<command>."
477
+ guard_block "don't read files with a bare 'cat' — use the Read tool: it returns numbered lines registered for a later Edit, and needs no permission decision at all. This fires on a lone 'cat <file>' and on a ';'-sequence of them (a literal echo/printf banner between reads is fine — batch them into one Read); a 'cat' feeding a pipe or heredoc, redirecting, or concatenating multiple files in one command is composition and untouched. If you genuinely need cat, run it yourself with !<command>."
258
478
  }
259
479
 
260
480
  guard_rule_git_grep() {
261
481
  local cmd="$1" s tok i n positionals=0 want_arg=0 pat_opt=0 working_tree=0
262
482
  grep -qE '\$\(|<\(|>\(' <<<"$cmd" && return 0
263
483
  case "$cmd" in *'`'*) return 0 ;; esac
264
- s="$(sed -E "s/'[^']*'/SQ/g; s/\"[^\"]*\"/DQ/g" <<<"$cmd")"
484
+ s="$(guard_skeleton "$cmd" sq dq hd)"
265
485
  grep -qE '(&&|\|\||;|\||&|<|>)' <<<"$s" && return 0
266
486
  local -a toks
267
487
  read -ra toks <<<"$s"
@@ -286,11 +506,12 @@ guard_rule_git_grep() {
286
506
  [[ "$positionals" == 1 ]] && working_tree=1
287
507
  fi
288
508
  [[ "$working_tree" == 1 ]] || return 0
289
- guard_block "don't search with 'git grep' over the working tree — use the Grep tool: it returns matching lines (files registered for a later Read) with no shell prompt. A 'git grep' naming a revision, searching the index (--cached), or piped into a consumer is untouched — those reach beyond the working tree the Grep tool sees. If you genuinely need git grep, run it yourself with !<command>."
509
+ guard_block "don't search with 'git grep' over the working tree — use the Grep tool: it returns matching lines (files registered for a later Read) and needs no permission decision at all. A 'git grep' naming a revision, searching the index (--cached), or piped into a consumer is untouched — those reach beyond the working tree the Grep tool sees. If you genuinely need git grep, run it yourself with !<command>."
290
510
  }
291
511
 
292
512
  guard_rule_truncate_scratch() {
293
- local cmd="$1"
513
+ local cmd
514
+ cmd="$(guard_skeleton "$1" sq dq hd)"
294
515
  if [[ "$cmd" =~ ^[[:space:]]*:([[:space:]]+[0-9]*\>\>?[[:space:]]*[^[:space:]\&\|\;\<]+)+[[:space:]]*$ ]]; then
295
516
  local all_ignored=1 tgt
296
517
  while read -r tgt; do
@@ -306,10 +527,11 @@ guard_rule_truncate_scratch() {
306
527
 
307
528
  guard_rule_ro_pipeline() {
308
529
  local raw="$1"
530
+ # spec: guard-kit/SPEC.md §The guard framework — the raw-command carve-out these two tests take
309
531
  grep -qE '\$\(|<\(|>\(' <<<"$raw" && return 0
310
532
  case "$raw" in *'`'*) return 0 ;; esac
311
533
  local s
312
- s="$(sed -E "s/'[^']*'//g; s/\"[^\"]*\"//g" <<<"$raw")"
534
+ s="$(guard_skeleton "$raw" sq dq hd)"
313
535
  grep -q "['\"]" <<<"$s" && return 0
314
536
  grep -qE '(&&|\|\||;|&)' <<<"$s" && return 0
315
537
  local tgt
@@ -319,47 +541,49 @@ guard_rule_ro_pipeline() {
319
541
  /dev/null | '&'[0-9]*) ;;
320
542
  *) return 0 ;;
321
543
  esac
322
- done < <(grep -oE '[0-9]*>>?[[:space:]]*[^[:space:]|]+' <<<"$s" \
544
+ done < <(grep -oE '[0-9]*>>?[[:space:]]*[^[:space:]|;&]+' <<<"$s" \
323
545
  | sed -E 's/^[0-9]*>>?[[:space:]]*//')
324
546
  if grep -qE '(^|[[:space:]])find([[:space:]]|$)' <<<"$s" \
325
547
  && grep -qE '\-(exec|execdir|ok|delete)\b' <<<"$s"; then
326
548
  return 0
327
549
  fi
328
- local seg first b matched
329
- while IFS= read -r seg; do
550
+ local -a segs
551
+ mapfile -t segs < <(guard_split_compound "$s")
552
+ local seg first b i matched reads=0
553
+ for ((i = 0; i < ${#segs[@]}; i++)); do
554
+ seg="${segs[i]}"
330
555
  seg="${seg#"${seg%%[![:space:]]*}"}"
331
556
  [[ -z "$seg" ]] && continue
557
+ _guard_is_banner "$seg" && continue
332
558
  first="${seg%%[[:space:]]*}"
559
+ [[ "$first" == xargs ]] && { _guard_is_ro_xargs "$seg" || return 0; }
333
560
  matched=0
334
561
  for b in "${GUARD_KIT_RO_BINS[@]}"; do
335
562
  [[ "$first" == "$b" ]] && { matched=1; break; }
336
563
  done
337
- [[ "$matched" == 1 ]] || return 0
338
- done < <(tr '|' '\n' <<<"$s")
564
+ if [[ "$matched" == 0 ]]; then
565
+ # spec: guard-kit/SPEC.md §The generic ruleset — rule 13's widened lead: a bare
566
+ # committed allow entry qualifies, but only where something decorates it
567
+ [[ "$i" == 0 && "${#segs[@]}" -gt 1 ]] || return 0
568
+ _guard_is_bare_allow "$seg" || return 0
569
+ fi
570
+ reads=$((reads + 1))
571
+ done
572
+ [[ "$reads" -ge 1 ]] || return 0
339
573
  guard_allow "read-only search pipeline (${GUARD_NAME:-guard} auto-allow)"
340
574
  }
341
575
 
342
576
  guard_rule_allowlist_chain() {
343
- local cmd="$1"
344
- command -v jq >/dev/null 2>&1 || return 0
345
- [[ -f "$GUARD_KIT_SETTINGS" ]] || return 0
346
-
347
- local -a allow_entries
348
- mapfile -t allow_entries < <(jq -r '.permissions.allow[]?' "$GUARD_KIT_SETTINGS" 2>/dev/null) || return 0
349
- [[ ${#allow_entries[@]} -gt 0 ]] || return 0
350
-
351
- local e inner
352
- local -a bare_leads pattern_inners
353
- for e in "${allow_entries[@]}"; do
354
- case "$e" in Bash\(*\)) inner="${e#Bash(}"; inner="${inner%)}" ;; *) continue ;; esac
355
- [[ -z "$inner" ]] && continue
577
+ local cmd="$1" inner
578
+ local -a bare_leads=() pattern_inners=()
579
+ while IFS= read -r inner; do
356
580
  pattern_inners+=("$inner")
357
581
  case "$inner" in *'*'*) ;; *) bare_leads+=("$inner") ;; esac
358
- done
582
+ done < <(_guard_allow_inners)
359
583
  [[ ${#bare_leads[@]} -gt 0 ]] || return 0
360
584
 
361
585
  local skel
362
- skel="$(sed -E "s/'[^']*'//g; s/\"[^\"]*\"//g" <<<"$cmd")"
586
+ skel="$(guard_skeleton "$cmd" sq dq hd)"
363
587
 
364
588
  local -a segs
365
589
  mapfile -t segs < <(guard_split_compound "$skel")
@@ -368,8 +592,7 @@ guard_rule_allowlist_chain() {
368
592
  lead="${lead#"${lead%%[![:space:]]*}"}"; lead="${lead%"${lead##*[![:space:]]}"}"
369
593
 
370
594
  local lead_core
371
- lead_core="$(sed -E 's/[[:space:]]*[0-9]*(>>?|<)[[:space:]]*(&?[0-9-]+|[^[:space:]]+)?//g' <<<"$lead")"
372
- lead_core="${lead_core#"${lead_core%%[![:space:]]*}"}"; lead_core="${lead_core%"${lead_core##*[![:space:]]}"}"
595
+ lead_core="$(_guard_segment_core "$lead")"
373
596
 
374
597
  local bl matched_lead=0
375
598
  for bl in "${bare_leads[@]}"; do
@@ -377,7 +600,7 @@ guard_rule_allowlist_chain() {
377
600
  done
378
601
  [[ "$matched_lead" == 1 ]] || return 0
379
602
 
380
- local steer="run '$lead_core' bare — it's a statically allowlisted command, but the decoration (chaining or a redirect) forces a permission prompt no allowlist entry suppresses. Run the allowlisted command on its own; issue the rest as separate calls."
603
+ local steer="run '$lead_core' bare — it's a statically allowlisted command, but the decoration (chaining or a redirect) leaves a segment nothing grants, so the whole call falls off the match path and costs an out-of-band permission decision. Run the allowlisted command on its own; issue the rest as separate calls."
381
604
 
382
605
  [[ "$lead" != "$lead_core" ]] && guard_block "$steer"
383
606
 
@@ -399,7 +622,7 @@ guard_rule_allowlist_chain() {
399
622
 
400
623
  guard_rule_git_rewrite() {
401
624
  local cmd="$1" s
402
- s="$(sed -E "s/'[^']*'//g; s/\"[^\"]*\"//g" <<<"$cmd")"
625
+ s="$(guard_skeleton "$cmd" sq dq hd)"
403
626
  if { grep -qE '(^|[[:space:]])git[[:space:]]+commit([[:space:]]|$)' <<<"$s" \
404
627
  && grep -qE '(^|[[:space:]])(-F|--file|--amend)\b' <<<"$s"; } \
405
628
  || { grep -qE '(^|[[:space:]])git[[:space:]]+reset([[:space:]]|$)' <<<"$s" \
@@ -412,7 +635,7 @@ guard_rule_rm_tracked() {
412
635
  local raw="$1" s
413
636
  grep -qE '\$\(|<\(|>\(|\$\{|\$[A-Za-z_]' <<<"$raw" && return 0
414
637
  case "$raw" in *'`'*) return 0 ;; esac
415
- s="$(sed -E "s/'[^']*'//g; s/\"[^\"]*\"//g" <<<"$raw")"
638
+ s="$(guard_skeleton "$raw" sq dq hd)"
416
639
  local seg lead arg
417
640
  while IFS= read -r seg; do
418
641
  seg="${seg#"${seg%%[![:space:]]*}"}"
@@ -2,7 +2,7 @@
2
2
  permission-friction loop a habit, not a one-off cleanup. Splice this in place
3
3
  of lifecycle-kit's `tooling-friction triage` placeholder (close skill, step 2).
4
4
 
5
- 1. **Rank what prompted.** Run `bash guard-kit/bin/scan-prompts.sh` — it
5
+ 1. **Rank what nothing granted.** Run `bash guard-kit/bin/scan-prompts.sh` — it
6
6
  filters the friction log against the committed allowlist and the harness's
7
7
  built-in read-only auto-allows, then ranks the survivors by command pattern.
8
8
  2. **Resolve each recurring pattern by the triage criterion** — never default
@@ -14,18 +14,46 @@ of lifecycle-kit's `tooling-friction triage` placeholder (close skill, step 2).
14
14
  - **Habit change** (a noted convention) for a true one-off.
15
15
  Caution: an allowlist entry can *mask* a steering opportunity — before
16
16
  blessing a form, confirm it is the one to reinforce.
17
+ **Diagnose before you reach for the allowlist.** A pattern can rank high while
18
+ already being granted: an allowlist entry matches a *bare* command, so a call
19
+ that chains (`&&`, `;`), redirects, or expands breaks the match and is decided
20
+ out of band anyway. Check a ranked pattern against the committed allowlist first — if it is
21
+ already there, the finding is (c) habit change, and adding coverage buys
22
+ nothing while reading as a fix.
17
23
  3. **Review the wakeup log** if the wakeup-guard is wired: read
18
24
  `.workflow/wakeup-attempts.log`, act on any surfaced intent, then delete it.
19
- 4. **Prune the local overlay.** Run
20
- `bash guard-kit/bin/compare-settings-allow.sh` and remove every listed
21
- `settings.local.json` entry (a committed glob already grants it). Then, by
22
- judgment, prune the remaining one-off exact-string local entries and promote
23
- recurring safe patterns to the committed `settings.json` as globs.
25
+ 4. **Prune and narrow the local overlay.** Run
26
+ `bash guard-kit/bin/compare-settings-allow.sh` — it reports two sets, and
27
+ each has its own disposition.
28
+ - **Redundant**: remove every listed `settings.local.json` entry (a committed
29
+ glob already grants it).
30
+ - **Too broad**: for every entry the breadth report names, either narrow the
31
+ glob or record that its breadth is intended. The probe printed beside it is
32
+ the witness — the command that glob auto-allows. An empty breadth report is
33
+ not a proof of narrowness: probes are witnesses, and no completeness is
34
+ claimed (the section is absent entirely when no probes are declared).
35
+
36
+ - **Not content-pinned**: an entry naming a *script path* rather than a fixed
37
+ command grants whatever that file says at run time, so its meaning changes
38
+ whenever the file does — and a path under the gitignored scratch dir is
39
+ rewritable by any session. Read the shape, not the literal: it reads as a
40
+ specific command until one notices the target is writable. Such a run has a
41
+ sanctioned form already — `bin/scratch-run.sh`, whose echo-at-execution is
42
+ the compensating control (§scratch-run) — so route the run through the
43
+ runner and remove the direct-path grant. Removing instances without applying
44
+ this criterion re-arms for the next one.
45
+
46
+ Then, by judgment, prune the remaining one-off exact-string local entries and
47
+ promote recurring safe patterns to the committed `settings.json` as globs.
48
+ Widening the committed set is the **consumer's** call, not the session's: an
49
+ agent may propose a standing grant and may prune, but it does not widen its
50
+ own auto-allow set on its own say-so.
24
51
  5. **Clear the friction log** — its named reclaim path:
25
52
  `: > .workflow/prompt-friction.log`. Run each clear as its own bare command:
26
53
  the allowlist entry is an exact string, so compounding it (`&&`, `;`, a
27
- trailing `echo`/`wc`) breaks the match and forces the very prompt this step
28
- just triaged away.
54
+ trailing `echo`/`wc`) breaks the match and buys the very out-of-band decision
55
+ this step just triaged away.
29
56
 
30
- Goal: the local set stays small, and every durable pattern lives in the
31
- committed, reviewable allowlist.
57
+ Goal: the local set stays small, every durable pattern lives in the
58
+ committed, reviewable allowlist, and no local glob auto-allows a command you
59
+ declared bad.
@@ -1,2 +1,5 @@
1
1
  # shellcheck shell=bash
2
2
  # spec: guard-kit/SPEC.md §Layout and configuration — the knob table (every knob, its default, when to set it) and how to install this config; set only what you override
3
+
4
+ # spec: guard-kit/SPEC.md §compare-settings-allow — declare your own probes; the kit ships none
5
+ # GUARD_KIT_BREADTH_PROBES=("Bash(rm -rf /)")
@@ -1,5 +1,5 @@
1
1
  {
2
- "//": "guard-kit hook wiring — merge into .claude/settings.json. The bash-guard is the PreToolUse(Bash) hook; the wakeup-guard is optional (drop the second block to skip it). Paths assume the guards were copied into scripts/.",
2
+ "//": "guard-kit hook wiring — merge into .claude/settings.json. The bash-guard is the PreToolUse(Bash) hook; the wakeup-guard and the path-guard block are optional (drop a block to skip it). The third block shows the path-shaped guard shape guard_read_path serves — lifecycle-kit's workflow-state-guard is the shipped instance. Paths assume the guards were copied into scripts/.",
3
3
  "hooks": {
4
4
  "PreToolUse": [
5
5
  {
@@ -13,6 +13,12 @@
13
13
  "hooks": [
14
14
  { "type": "command", "command": "bash scripts/wakeup-guard.sh" }
15
15
  ]
16
+ },
17
+ {
18
+ "matcher": "Write|Edit",
19
+ "hooks": [
20
+ { "type": "command", "command": "bash scripts/workflow-state-guard.sh" }
21
+ ]
16
22
  }
17
23
  ]
18
24
  }