checkwright 0.23.0 → 0.25.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 (375) hide show
  1. package/README.md +175 -13
  2. package/lib/common/lock.sh +7 -0
  3. package/lib/common/recipe.sh +1 -1
  4. package/lib/diff.sh +2 -0
  5. package/lib/init.sh +40 -16
  6. package/lib/uninstall.sh +2 -0
  7. package/package.json +2 -2
  8. package/payload/artifact/x86_64-unknown-linux-gnu/checkwright-gates +0 -0
  9. package/payload/artifact/x86_64-unknown-linux-gnu/checkwright-gates.sha256 +1 -1
  10. package/payload/canon-kit/README.md +2 -0
  11. package/payload/canon-kit/SPEC.md +454 -28
  12. package/payload/canon-kit/checks/check-amendment-queue.gate +3 -0
  13. package/payload/canon-kit/checks/check-amendment-update-target.gate +3 -0
  14. package/payload/canon-kit/checks/check-docs-link-convention.gate +3 -0
  15. package/payload/canon-kit/checks/check-knob-default-coupling.gate +3 -0
  16. package/payload/canon-kit/checks/check-prose-tells.gate +3 -0
  17. package/payload/canon-kit/checks/check-spec-embedded-source.gate +3 -0
  18. package/payload/canon-kit/checks/check-unmarked-claim.gate +3 -0
  19. package/payload/canon-kit/gate-tests/check-amendment-queue/bad/SPEC-orphan.md +6 -0
  20. package/payload/canon-kit/gate-tests/check-amendment-queue/bad/TASK-QUEUE.md +7 -2
  21. package/payload/canon-kit/gate-tests/check-amendment-queue/bad/expect.txt +8 -0
  22. package/payload/canon-kit/gate-tests/check-amendment-update-target/bad/SPEC-thing.md +26 -0
  23. package/payload/canon-kit/gate-tests/check-amendment-update-target/bad/expect.txt +8 -0
  24. package/payload/canon-kit/gate-tests/check-amendment-update-target/good/SPEC-widget.md +47 -0
  25. package/payload/canon-kit/gate-tests/check-amendment-update-target/good/expect.txt +1 -0
  26. package/payload/canon-kit/gate-tests/check-amendment-update-target.test.sh +82 -0
  27. package/payload/canon-kit/gate-tests/check-comment-tier/bad/bad.sh +3 -0
  28. package/payload/canon-kit/gate-tests/check-comment-tier/bad/expect.txt +1 -0
  29. package/payload/canon-kit/gate-tests/check-comment-tier/good/good.sh +3 -0
  30. package/payload/canon-kit/gate-tests/check-docs-link-convention.test.sh +4 -4
  31. package/payload/canon-kit/gate-tests/check-knob-default-coupling.test.sh +2 -2
  32. package/payload/canon-kit/gate-tests/check-spec-embedded-source/bad/SPEC-wire.md +18 -0
  33. package/payload/canon-kit/gate-tests/check-spec-embedded-source/bad/expect.txt +3 -1
  34. package/payload/canon-kit/gate-tests/check-spec-embedded-source/bad/widget.proto +13 -0
  35. package/payload/canon-kit/gate-tests/check-spec-embedded-source/good/SPEC-wire.md +22 -0
  36. package/payload/canon-kit/gate-tests/check-spec-embedded-source/good/SPEC.md +17 -0
  37. package/payload/canon-kit/gate-tests/check-spec-embedded-source/good/widget.proto +13 -0
  38. package/payload/canon-kit/gate-tests/check-unmarked-claim/bad/SPEC.md +11 -0
  39. package/payload/canon-kit/gate-tests/check-unmarked-claim/bad/expect.txt +3 -0
  40. package/payload/canon-kit/gate-tests/check-unmarked-claim/bad/scripts/canon-config.sh +6 -0
  41. package/payload/canon-kit/gate-tests/check-unmarked-claim/good/SPEC.md +18 -0
  42. package/payload/canon-kit/gate-tests/check-unmarked-claim/good/expect.txt +1 -0
  43. package/payload/canon-kit/gate-tests/check-unmarked-claim/good/scripts/canon-config.sh +6 -0
  44. package/payload/canon-kit/gate-tests/check-unmarked-claim.test.sh +85 -0
  45. package/payload/canon-kit/lib/spec.sh +16 -0
  46. package/payload/canon-kit/smoke/install.sh +3 -1
  47. package/payload/canon-kit/templates/SPEC-amendment.md +17 -2
  48. package/payload/context-kit/README.md +6 -4
  49. package/payload/context-kit/SPEC.md +256 -76
  50. package/payload/context-kit/bin/always-loaded.sh +5 -21
  51. package/payload/context-kit/bin/env-probe.sh +2 -17
  52. package/payload/context-kit/checks/check-brevity.gate +3 -0
  53. package/payload/context-kit/checks/check-footprint-fresh.gate +3 -0
  54. package/payload/context-kit/checks/check-memory-off.gate +3 -0
  55. package/payload/context-kit/checks/check-settings-paths.gate +3 -0
  56. package/payload/context-kit/checks/check-settings-pins.gate +3 -0
  57. package/payload/context-kit/gate-tests/check-brevity.test.sh +3 -2
  58. package/payload/context-kit/gate-tests/check-memory-off/bad/scripts/context-config.sh +4 -0
  59. package/payload/context-kit/gate-tests/check-memory-off/good/scripts/context-config.sh +4 -0
  60. package/payload/context-kit/gate-tests/check-memory-off.test.sh +18 -4
  61. package/payload/context-kit/gate-tests/check-settings-pins.test.sh +70 -0
  62. package/payload/context-kit/index-tests/expected/toolfloor.txt +5 -5
  63. package/payload/context-kit/index-tests/toolfloor-cases.sh +5 -5
  64. package/payload/context-kit/lib/context.sh +56 -0
  65. package/payload/context-kit/lib/toolfloor.sh +1 -1
  66. package/payload/context-kit/smoke/agents-md.sh +16 -4
  67. package/payload/context-kit/smoke/install.sh +3 -2
  68. package/payload/context-kit/templates/session-context.sh +5 -5
  69. package/payload/delegation-kit/README.md +11 -1
  70. package/payload/delegation-kit/SPEC.md +652 -11
  71. package/payload/delegation-kit/bin/wait-probe.sh +184 -0
  72. package/payload/delegation-kit/checks/check-agent-tier-explicit.gate +3 -0
  73. package/payload/delegation-kit/checks/check-gate-tamper.gate +3 -0
  74. package/payload/delegation-kit/checks/check-rule-citation.gate +3 -0
  75. package/payload/delegation-kit/gate-tests/check-gate-tamper/bad/added-exemptions +5 -0
  76. package/payload/delegation-kit/gate-tests/check-gate-tamper/bad/expect.txt +2 -0
  77. package/payload/delegation-kit/gate-tests/check-gate-tamper.test.sh +108 -0
  78. package/payload/delegation-kit/gate-tests/subagent-stop-liveness.test.sh +99 -0
  79. package/payload/delegation-kit/smoke/install.sh +21 -1
  80. package/payload/delegation-kit/templates/agent-execution.md +88 -4
  81. package/payload/delegation-kit/templates/subagent-stop-liveness.sh +56 -0
  82. package/payload/doctrine-kit/SPEC.md +1 -1
  83. package/payload/doctrine-kit/checks/check-doctrine-registration.gate +3 -0
  84. package/payload/doctrine-kit/gate-tests/check-doctrine-registration.test.sh +2 -3
  85. package/payload/doctrine-kit/smoke/install.sh +17 -4
  86. package/payload/drift-kit/README.md +2 -2
  87. package/payload/drift-kit/SPEC.md +71 -7
  88. package/payload/drift-kit/bin/stage-economics.sh +1 -1
  89. package/payload/drift-kit/lib/drift.sh +43 -0
  90. package/payload/drift-kit/smoke/install.sh +21 -14
  91. package/payload/evidence-kit/README.md +3 -1
  92. package/payload/evidence-kit/SPEC.md +160 -19
  93. package/payload/evidence-kit/checks/check-battery-roster.gate +3 -0
  94. package/payload/evidence-kit/checks/check-evidence-baseline.gate +3 -0
  95. package/payload/evidence-kit/checks/check-evidence-manifest.gate +3 -0
  96. package/payload/evidence-kit/checks/check-producer-liveness.sh +42 -2
  97. package/payload/evidence-kit/gate-tests/check-battery-roster.test.sh +4 -3
  98. package/payload/evidence-kit/gate-tests/check-evidence-baseline.test.sh +8 -5
  99. package/payload/evidence-kit/gate-tests/check-evidence-manifest/bad/WORKFLOW-STATE.txt +1 -1
  100. package/payload/evidence-kit/gate-tests/check-evidence-manifest/bad/scripts/evidence-config.sh +9 -0
  101. package/payload/evidence-kit/gate-tests/check-evidence-manifest/good/WORKFLOW-STATE.txt +1 -1
  102. package/payload/evidence-kit/gate-tests/check-evidence-manifest/good/scripts/evidence-config.sh +9 -0
  103. package/payload/evidence-kit/gate-tests/check-evidence-manifest.test.sh +6 -4
  104. package/payload/evidence-kit/gate-tests/producer-lock.test.sh +42 -1
  105. package/payload/evidence-kit/lib/evidence.sh +2 -0
  106. package/payload/evidence-kit/smoke/install.sh +1 -1
  107. package/payload/gate-sdk/README.md +17 -9
  108. package/payload/gate-sdk/SPEC.md +4680 -295
  109. package/payload/gate-sdk/bin/build-native.sh +66 -1
  110. package/payload/gate-sdk/bin/install-hooks.sh +14 -2
  111. package/payload/gate-sdk/bin/port-blockers.sh +37 -9
  112. package/payload/gate-sdk/bin/run-gate-tests.sh +1 -2
  113. package/payload/gate-sdk/bin/run-gates.sh +137 -13
  114. package/payload/gate-sdk/bin/upgrade-smoke.sh +21 -16
  115. package/payload/gate-sdk/checks/check-action-run-shell.sh +2 -1
  116. package/payload/gate-sdk/checks/check-commit-msg.gate +3 -0
  117. package/payload/gate-sdk/checks/check-commit-subject.gate +3 -0
  118. package/payload/gate-sdk/checks/check-core-files.gate +3 -0
  119. package/payload/gate-sdk/checks/check-crate-arms.sh +1 -0
  120. package/payload/gate-sdk/checks/check-enforcement-fresh.gate +3 -0
  121. package/payload/gate-sdk/checks/check-exec-bit.gate +3 -0
  122. package/payload/gate-sdk/checks/check-gate-assertions.gate +3 -0
  123. package/payload/gate-sdk/checks/check-gate-binary-fresh.gate +3 -0
  124. package/payload/gate-sdk/checks/check-gate-exemption-tasks.gate +3 -0
  125. package/payload/gate-sdk/checks/check-gate-fail-closed.gate +3 -0
  126. package/payload/gate-sdk/checks/check-gate-fixture-coverage.gate +3 -0
  127. package/payload/gate-sdk/checks/check-gate-output.gate +3 -0
  128. package/payload/gate-sdk/checks/check-gate-substrate-parity.sh +132 -15
  129. package/payload/gate-sdk/checks/check-graph.gate +3 -0
  130. package/payload/gate-sdk/checks/check-hook-exec-bit.gate +3 -0
  131. package/payload/gate-sdk/checks/check-identity.gate +3 -0
  132. package/payload/gate-sdk/checks/check-install-disposition.sh +1 -0
  133. package/payload/gate-sdk/checks/check-kit-enum.gate +3 -0
  134. package/payload/gate-sdk/checks/check-readme-roster.gate +3 -0
  135. package/payload/gate-sdk/checks/check-reads-couples.gate +3 -0
  136. package/payload/gate-sdk/checks/check-root-tiering.gate +3 -0
  137. package/payload/gate-sdk/checks/check-shellcheck.sh +1 -0
  138. package/payload/gate-sdk/checks/check-template-copy-parity.gate +3 -0
  139. package/payload/gate-sdk/checks/check-tree-terms.gate +3 -0
  140. package/payload/gate-sdk/checks/check-workflow-tiering.gate +3 -0
  141. package/payload/gate-sdk/gate-tests/check-commit-subject.test.sh +17 -12
  142. package/payload/gate-sdk/gate-tests/check-core-files.test.sh +4 -5
  143. package/payload/gate-sdk/gate-tests/check-exec-bit/bad/dump.txt +2 -1
  144. package/payload/gate-sdk/gate-tests/check-exec-bit/bad/expect.txt +2 -1
  145. package/payload/gate-sdk/gate-tests/check-exec-bit/good/dump.txt +3 -0
  146. package/payload/gate-sdk/gate-tests/check-exec-bit/good/expect.txt +1 -1
  147. package/payload/gate-sdk/gate-tests/check-exec-bit.test.sh +3 -4
  148. package/payload/gate-sdk/gate-tests/check-gate-assertions/bad/expect.txt +5 -1
  149. package/payload/gate-sdk/gate-tests/check-gate-assertions/bad/scripts/SPEC.md +22 -0
  150. package/payload/gate-sdk/gate-tests/check-gate-assertions/bad/scripts/check-count.sh +11 -0
  151. package/payload/gate-sdk/gate-tests/check-gate-assertions/bad/scripts/check-extra.sh +14 -0
  152. package/payload/gate-sdk/gate-tests/check-gate-assertions/bad/scripts/check-zero.sh +7 -0
  153. package/payload/gate-sdk/gate-tests/check-gate-assertions/good/expect.txt +1 -1
  154. package/payload/gate-sdk/gate-tests/check-gate-assertions/good/scripts/SPEC.md +27 -0
  155. package/payload/gate-sdk/gate-tests/check-gate-assertions/good/scripts/check-qux.sh +13 -0
  156. package/payload/gate-sdk/gate-tests/check-gate-assertions.test.sh +117 -0
  157. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh.test.sh +26 -4
  158. package/payload/gate-sdk/gate-tests/check-gate-exemption-tasks/bad/args +6 -1
  159. package/payload/gate-sdk/gate-tests/check-gate-exemption-tasks/bad/expect.txt +2 -0
  160. package/payload/gate-sdk/gate-tests/check-gate-exemption-tasks/bad/kitroot/checks/check-vendored-descriptor.gate +4 -0
  161. package/payload/gate-sdk/gate-tests/check-gate-exemption-tasks/bad/kitroot/checks/check-vendored.sh +14 -0
  162. package/payload/gate-sdk/gate-tests/check-gate-exemption-tasks/bad/scripts/check-descriptor.gate +4 -0
  163. package/payload/gate-sdk/gate-tests/check-gate-exemption-tasks/bad/scripts/check-held.sh +8 -0
  164. package/payload/gate-sdk/gate-tests/check-gate-exemption-tasks/good/args +8 -1
  165. package/payload/gate-sdk/gate-tests/check-gate-exemption-tasks/good/expect.txt +3 -0
  166. package/payload/gate-sdk/gate-tests/check-gate-exemption-tasks/good/kitroot/checks/check-vendored-descriptor.gate +4 -0
  167. package/payload/gate-sdk/gate-tests/check-gate-exemption-tasks/good/kitroot/checks/check-vendored.sh +14 -0
  168. package/payload/gate-sdk/gate-tests/check-gate-exemption-tasks/good/scripts/check-descriptor.gate +4 -0
  169. package/payload/gate-sdk/gate-tests/check-gate-exemption-tasks/good/scripts/check-held.sh +8 -0
  170. package/payload/gate-sdk/gate-tests/check-gate-exemption-tasks.test.sh +77 -0
  171. package/payload/gate-sdk/gate-tests/check-gate-output.test.sh +4 -5
  172. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/expect.txt +9 -0
  173. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/kit-spec.md +6 -0
  174. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/scripts/check-alpha.sh +1 -0
  175. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/scripts/check-bare.sh +4 -0
  176. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/scripts/check-both.sh +5 -0
  177. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/scripts/check-heldtwice.sh +5 -0
  178. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/scripts/check-nospec.sh +4 -0
  179. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/scripts/check-orphan.gate +2 -0
  180. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/scripts/check-twice.sh +5 -0
  181. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/scripts/check-ungrounded.sh +5 -0
  182. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/scripts/gates.list +6 -0
  183. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/expect.txt +2 -1
  184. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/kit-spec.md +12 -0
  185. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/scripts/check-alpha.sh +1 -0
  186. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/scripts/check-held.sh +5 -0
  187. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/scripts/gates.list +1 -0
  188. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity.test.sh +49 -4
  189. package/payload/gate-sdk/gate-tests/check-graph/bad/SPEC-example-gate.md +15 -5
  190. package/payload/gate-sdk/gate-tests/check-graph/bad/expect.txt +12 -0
  191. package/payload/gate-sdk/gate-tests/check-graph/good/SPEC-example-gate.md +27 -5
  192. package/payload/gate-sdk/gate-tests/check-graph/good/SPEC-second-gate.md +12 -0
  193. package/payload/gate-sdk/gate-tests/check-graph-cap.test.sh +5 -4
  194. package/payload/gate-sdk/gate-tests/check-graph-refs.test.sh +14 -12
  195. package/payload/gate-sdk/gate-tests/check-graph-theme.test.sh +43 -17
  196. package/payload/gate-sdk/gate-tests/check-graph-tree.test.sh +190 -0
  197. package/payload/gate-sdk/gate-tests/check-identity/bad/gh-hosts.yml +9 -0
  198. package/payload/gate-sdk/gate-tests/check-identity/bad/identity.conf +4 -2
  199. package/payload/gate-sdk/gate-tests/check-identity/bad/scripts/gate-sdk-config.sh +10 -0
  200. package/payload/gate-sdk/gate-tests/check-identity/good/gh-hosts.yml +11 -0
  201. package/payload/gate-sdk/gate-tests/check-identity/good/identity.conf +5 -1
  202. package/payload/gate-sdk/gate-tests/check-identity/good/scripts/gate-sdk-config.sh +10 -0
  203. package/payload/gate-sdk/gate-tests/check-identity.test.sh +114 -0
  204. package/payload/gate-sdk/gate-tests/check-kit-enum/bad/check-native-sample.gate +3 -0
  205. package/payload/gate-sdk/gate-tests/check-kit-enum/bad/gates.list +4 -1
  206. package/payload/gate-sdk/gate-tests/check-kit-enum/good/check-native-sample.gate +3 -0
  207. package/payload/gate-sdk/gate-tests/check-kit-enum/good/expect.txt +1 -1
  208. package/payload/gate-sdk/gate-tests/check-kit-enum/good/gates.list +5 -2
  209. package/payload/gate-sdk/gate-tests/check-readme-roster/bad/args +3 -1
  210. package/payload/gate-sdk/gate-tests/check-readme-roster/bad/delta-kit/README.md +15 -0
  211. package/payload/gate-sdk/gate-tests/check-readme-roster/bad/delta-kit/checks/check-delta-one.gate +2 -0
  212. package/payload/gate-sdk/gate-tests/check-readme-roster/bad/delta-kit/checks/check-delta-two.sh +3 -0
  213. package/payload/gate-sdk/gate-tests/check-readme-roster/bad/expect.txt +3 -1
  214. package/payload/gate-sdk/gate-tests/check-readme-roster/bad/scripts/gate-sdk-config.sh +1 -1
  215. package/payload/gate-sdk/gate-tests/check-readme-roster/good/args +3 -1
  216. package/payload/gate-sdk/gate-tests/check-readme-roster/good/delta-kit/README.md +13 -0
  217. package/payload/gate-sdk/gate-tests/check-readme-roster/good/delta-kit/checks/check-delta-one.gate +2 -0
  218. package/payload/gate-sdk/gate-tests/check-readme-roster/good/epsilon-kit/README.md +14 -0
  219. package/payload/gate-sdk/gate-tests/check-readme-roster/good/epsilon-kit/checks/check-eps-one.sh +3 -0
  220. package/payload/gate-sdk/gate-tests/check-readme-roster/good/epsilon-kit/checks/check-eps-two.gate +2 -0
  221. package/payload/gate-sdk/gate-tests/check-readme-roster/good/scripts/gate-sdk-config.sh +1 -1
  222. package/payload/gate-sdk/gate-tests/check-reads-couples.test.sh +87 -89
  223. package/payload/gate-sdk/gate-tests/check-template-copy-parity/good/scripts/agent-budget-guard.sh +4 -0
  224. package/payload/gate-sdk/gate-tests/check-template-copy-parity.test.sh +56 -0
  225. package/payload/gate-sdk/gate-tests/check-tree-terms/bad/expect.txt +5 -0
  226. package/payload/gate-sdk/gate-tests/check-tree-terms/bad/tree/multi.txt +4 -0
  227. package/payload/gate-sdk/gate-tests/check-tree-terms/bad/tree/second-leak.txt +2 -0
  228. package/payload/gate-sdk/gate-tests/check-tree-terms/good/expect.txt +1 -1
  229. package/payload/gate-sdk/gate-tests/check-tree-terms/good/patterns.list +3 -0
  230. package/payload/gate-sdk/gate-tests/check-tree-terms/good/tree/anchored.txt +4 -0
  231. package/payload/gate-sdk/gate-tests/check-tree-terms/good/tree/msg-patterns.list +2 -0
  232. package/payload/gate-sdk/gate-tests/check-tree-terms/good/tree/msg-patterns.local.list +3 -0
  233. package/payload/gate-sdk/gate-tests/check-tree-terms/good/tree/worktrees/vendored-note.txt +3 -0
  234. package/payload/gate-sdk/gate-tests/check-tree-terms.test.sh +94 -0
  235. package/payload/gate-sdk/gate-tests/declaration-lib-parity.test.sh +211 -0
  236. package/payload/gate-sdk/gate-tests/enforcement-map.test.sh +16 -15
  237. package/payload/gate-sdk/gate-tests/lib-gate.test.sh +94 -1
  238. package/payload/gate-sdk/lib/gate.sh +232 -25
  239. package/payload/gate-sdk/smoke/install.sh +28 -1
  240. package/payload/guard-kit/README.md +4 -3
  241. package/payload/guard-kit/SPEC.md +578 -47
  242. package/payload/guard-kit/bin/compare-settings-allow.sh +36 -12
  243. package/payload/guard-kit/bin/run-guard-tests.sh +27 -4
  244. package/payload/guard-kit/gate-tests/compare-settings-allow.test.sh +46 -1
  245. package/payload/guard-kit/gate-tests/git-mutation-under-producer.test.sh +105 -0
  246. package/payload/guard-kit/guard-tests/background-cases.tsv +14 -0
  247. package/payload/guard-kit/guard-tests/cases.tsv +67 -9
  248. package/payload/guard-kit/lib/guard.sh +361 -18
  249. package/payload/guard-kit/templates/bash-guard.sh +2 -0
  250. package/payload/guard-kit/templates/close-triage.md +10 -3
  251. package/payload/guard-kit/templates/guard-config.sh +3 -0
  252. package/payload/lifecycle-kit/README.md +3 -2
  253. package/payload/lifecycle-kit/SPEC.md +509 -77
  254. package/payload/lifecycle-kit/bin/enter-stage.sh +72 -33
  255. package/payload/lifecycle-kit/bin/file-gap.sh +2 -2
  256. package/payload/lifecycle-kit/checks/check-close-surfaces.gate +3 -0
  257. package/payload/lifecycle-kit/checks/check-stage-entry.gate +3 -0
  258. package/payload/lifecycle-kit/gate-tests/boundary-scratch-wipe.test.sh +4 -4
  259. package/payload/lifecycle-kit/gate-tests/check-close-surfaces.test.sh +1 -1
  260. package/payload/lifecycle-kit/gate-tests/check-stage-entry/bad/.workflow/WORKFLOW-STATE.txt +3 -3
  261. package/payload/lifecycle-kit/gate-tests/check-stage-entry/good/.workflow/WORKFLOW-STATE.txt +3 -3
  262. package/payload/lifecycle-kit/gate-tests/check-stage-entry.test.sh +22 -22
  263. package/payload/lifecycle-kit/gate-tests/check-stage-evidence/bad/.workflow/WORKFLOW-STATE.txt +2 -2
  264. package/payload/lifecycle-kit/gate-tests/check-stage-evidence/good/.workflow/WORKFLOW-STATE.txt +2 -2
  265. package/payload/lifecycle-kit/gate-tests/check-stage-evidence.test.sh +120 -10
  266. package/payload/lifecycle-kit/gate-tests/gap-inbox-route.test.sh +123 -0
  267. package/payload/lifecycle-kit/gate-tests/rename-iteration.test.sh +11 -11
  268. package/payload/lifecycle-kit/gate-tests/survey-record-entry.test.sh +16 -5
  269. package/payload/lifecycle-kit/lib/stages.sh +5 -0
  270. package/payload/lifecycle-kit/smoke/install.sh +29 -15
  271. package/payload/lifecycle-kit/templates/lead.md +32 -0
  272. package/payload/lifecycle-kit/templates/stages/align.md +20 -2
  273. package/payload/lifecycle-kit/templates/stages/build.md +3 -3
  274. package/payload/lifecycle-kit/templates/stages/close.md +20 -6
  275. package/payload/lifecycle-kit/templates/stages/scope.md +20 -1
  276. package/payload/lifecycle-kit/templates/stages/spec.md +1 -1
  277. package/payload/lifecycle-kit/templates/stages/validate.md +1 -1
  278. package/payload/lifecycle-kit/templates/workflow-state-guard.sh +1 -1
  279. package/payload/queue-kit/README.md +10 -10
  280. package/payload/queue-kit/SPEC.md +379 -84
  281. package/payload/queue-kit/bin/queue-counts.sh +1 -1
  282. package/payload/queue-kit/checks/check-queue-entry-budget.gate +1 -1
  283. package/payload/queue-kit/checks/check-queue-prose-precondition.gate +3 -0
  284. package/payload/queue-kit/checks/check-roadmap-fresh.gate +3 -0
  285. package/payload/queue-kit/gate-tests/check-queue-entry-budget/bad/TASK-QUEUE.md +15 -0
  286. package/payload/queue-kit/gate-tests/check-queue-entry-budget/bad/expect.txt +2 -0
  287. package/payload/queue-kit/gate-tests/check-queue-entry-budget/good/TASK-QUEUE.md +7 -0
  288. package/payload/queue-kit/gate-tests/check-queue-entry-budget/good/expect.txt +4 -0
  289. package/payload/queue-kit/gate-tests/check-roadmap-fresh/bad/expect.txt +1 -1
  290. package/payload/queue-kit/gate-tests/queue-counts.test.sh +1 -1
  291. package/payload/queue-kit/gate-tests/queue-index.test.sh +55 -119
  292. package/payload/queue-kit/gate-tests/roadmap.test.sh +22 -12
  293. package/payload/queue-kit/lib/queue.sh +0 -49
  294. package/payload/queue-kit/smoke/install.sh +1 -1
  295. package/payload/site-kit/SPEC.md +41 -2
  296. package/payload/site-kit/checks/check-docs-cname-parity.gate +3 -0
  297. package/payload/site-kit/checks/check-docs-render-fidelity.sh +1 -0
  298. package/payload/site-kit/gate-tests/check-docs-cname-parity/bad/args +5 -4
  299. package/payload/site-kit/gate-tests/check-docs-cname-parity/good/args +6 -5
  300. package/payload/site-kit/gate-tests/check-docs-cname-parity/good/checks/check-sample.gate +3 -0
  301. package/payload/site-kit/gate-tests/check-docs-cname-parity/good/expect.txt +1 -1
  302. package/payload/site-kit/smoke/install.sh +1 -1
  303. package/payload/canon-kit/checks/check-amendment-queue.sh +0 -117
  304. package/payload/canon-kit/checks/check-docs-link-convention.sh +0 -79
  305. package/payload/canon-kit/checks/check-knob-default-coupling.sh +0 -240
  306. package/payload/canon-kit/checks/check-prose-tells.sh +0 -208
  307. package/payload/canon-kit/checks/check-spec-embedded-source.sh +0 -134
  308. package/payload/context-kit/bin/footprint.sh +0 -144
  309. package/payload/context-kit/checks/check-brevity.sh +0 -124
  310. package/payload/context-kit/checks/check-footprint-fresh.sh +0 -39
  311. package/payload/context-kit/checks/check-memory-off.sh +0 -113
  312. package/payload/context-kit/checks/check-settings-paths.sh +0 -94
  313. package/payload/context-kit/checks/check-settings-pins.sh +0 -111
  314. package/payload/context-kit/gate-tests/check-memory-off/bad/args +0 -1
  315. package/payload/context-kit/gate-tests/check-memory-off/good/args +0 -1
  316. package/payload/delegation-kit/checks/check-agent-tier-explicit.sh +0 -62
  317. package/payload/delegation-kit/checks/check-gate-tamper.sh +0 -140
  318. package/payload/delegation-kit/checks/check-rule-citation.sh +0 -77
  319. package/payload/doctrine-kit/checks/check-doctrine-registration.sh +0 -246
  320. package/payload/drift-kit/bin/trajectory.sh +0 -242
  321. package/payload/evidence-kit/checks/check-battery-roster.sh +0 -87
  322. package/payload/evidence-kit/checks/check-evidence-baseline.sh +0 -104
  323. package/payload/evidence-kit/checks/check-evidence-manifest.sh +0 -105
  324. package/payload/evidence-kit/gate-tests/check-evidence-manifest/bad/args +0 -3
  325. package/payload/evidence-kit/gate-tests/check-evidence-manifest/good/args +0 -3
  326. package/payload/gate-sdk/bin/enforcement-map.sh +0 -273
  327. package/payload/gate-sdk/checks/check-commit-msg.sh +0 -51
  328. package/payload/gate-sdk/checks/check-commit-subject.sh +0 -44
  329. package/payload/gate-sdk/checks/check-core-files.sh +0 -76
  330. package/payload/gate-sdk/checks/check-enforcement-fresh.sh +0 -38
  331. package/payload/gate-sdk/checks/check-exec-bit.sh +0 -96
  332. package/payload/gate-sdk/checks/check-gate-assertions.sh +0 -148
  333. package/payload/gate-sdk/checks/check-gate-binary-fresh.sh +0 -107
  334. package/payload/gate-sdk/checks/check-gate-exemption-tasks.sh +0 -106
  335. package/payload/gate-sdk/checks/check-gate-fail-closed.sh +0 -85
  336. package/payload/gate-sdk/checks/check-gate-fixture-coverage.sh +0 -93
  337. package/payload/gate-sdk/checks/check-gate-output.sh +0 -103
  338. package/payload/gate-sdk/checks/check-graph.sh +0 -632
  339. package/payload/gate-sdk/checks/check-hook-exec-bit.sh +0 -46
  340. package/payload/gate-sdk/checks/check-identity.sh +0 -135
  341. package/payload/gate-sdk/checks/check-kit-enum.sh +0 -95
  342. package/payload/gate-sdk/checks/check-readme-roster.sh +0 -108
  343. package/payload/gate-sdk/checks/check-reads-couples.sh +0 -200
  344. package/payload/gate-sdk/checks/check-root-tiering.sh +0 -67
  345. package/payload/gate-sdk/checks/check-template-copy-parity.sh +0 -127
  346. package/payload/gate-sdk/checks/check-tree-terms.sh +0 -66
  347. package/payload/gate-sdk/checks/check-workflow-tiering.sh +0 -85
  348. package/payload/gate-sdk/gate-tests/check-gate-fixture-coverage/bad/args +0 -1
  349. package/payload/gate-sdk/gate-tests/check-gate-fixture-coverage/good/args +0 -1
  350. package/payload/gate-sdk/gate-tests/check-identity/bad/args +0 -1
  351. package/payload/gate-sdk/gate-tests/check-identity/good/args +0 -1
  352. package/payload/lifecycle-kit/bin/close-surfaces.sh +0 -94
  353. package/payload/lifecycle-kit/checks/check-close-surfaces.sh +0 -64
  354. package/payload/lifecycle-kit/checks/check-stage-entry.sh +0 -198
  355. package/payload/queue-kit/bin/queue-index.sh +0 -182
  356. package/payload/queue-kit/bin/roadmap.sh +0 -76
  357. package/payload/queue-kit/checks/check-queue-prose-precondition.sh +0 -64
  358. package/payload/queue-kit/checks/check-roadmap-fresh.sh +0 -111
  359. package/payload/site-kit/checks/check-docs-cname-parity.sh +0 -81
  360. /package/payload/gate-sdk/gate-tests/check-gate-exemption-tasks/bad/{gates → scripts}/check-sample.sh +0 -0
  361. /package/payload/gate-sdk/gate-tests/check-gate-exemption-tasks/good/{gates → scripts}/check-sample.sh +0 -0
  362. /package/payload/gate-sdk/gate-tests/check-gate-fixture-coverage/bad/{check-gamma.sh → scripts/check-gamma.sh} +0 -0
  363. /package/payload/gate-sdk/gate-tests/check-gate-fixture-coverage/bad/{gate-tests → scripts/gate-tests}/check-alpha/bad/.keep +0 -0
  364. /package/payload/gate-sdk/gate-tests/check-gate-fixture-coverage/bad/{gate-tests → scripts/gate-tests}/check-alpha/good/.keep +0 -0
  365. /package/payload/gate-sdk/gate-tests/check-gate-fixture-coverage/bad/{gates.list → scripts/gates.list} +0 -0
  366. /package/payload/gate-sdk/gate-tests/check-gate-fixture-coverage/good/{check-beta.sh → scripts/check-beta.sh} +0 -0
  367. /package/payload/gate-sdk/gate-tests/check-gate-fixture-coverage/good/{gate-tests → scripts/gate-tests}/check-alpha/bad/.keep +0 -0
  368. /package/payload/gate-sdk/gate-tests/check-gate-fixture-coverage/good/{gate-tests → scripts/gate-tests}/check-alpha/good/.keep +0 -0
  369. /package/payload/gate-sdk/gate-tests/check-gate-fixture-coverage/good/{gates.list → scripts/gates.list} +0 -0
  370. /package/payload/site-kit/gate-tests/check-docs-cname-parity/bad/{site-config.sh → scripts/site-config.sh} +0 -0
  371. /package/payload/site-kit/gate-tests/check-docs-cname-parity/good/{tree → docs}/CNAME +0 -0
  372. /package/payload/site-kit/gate-tests/check-docs-cname-parity/good/{tree → docs}/index.md +0 -0
  373. /package/payload/site-kit/gate-tests/check-docs-cname-parity/good/{tree/docs → docs}/posts/2026-01-01-legacy.md +0 -0
  374. /package/payload/site-kit/gate-tests/check-docs-cname-parity/good/{tree/pkg → pkg}/gate-tests/fixture.md +0 -0
  375. /package/payload/site-kit/gate-tests/check-docs-cname-parity/good/{site-config.sh → scripts/site-config.sh} +0 -0
@@ -24,15 +24,38 @@ unset _frik_cfg
24
24
  : "${GUARD_KIT_SETTINGS:=.claude/settings.json}"
25
25
  : "${GUARD_KIT_SETTINGS_LOCAL:=.claude/settings.local.json}"
26
26
  declare -p GUARD_KIT_BREADTH_PROBES >/dev/null 2>&1 || GUARD_KIT_BREADTH_PROBES=()
27
+ declare -p GUARD_KIT_BREADTH_DECLARED >/dev/null 2>&1 || declare -A GUARD_KIT_BREADTH_DECLARED=()
27
28
  declare -p GUARD_KIT_RO_SCRIPTS >/dev/null 2>&1 || GUARD_KIT_RO_SCRIPTS=("check-*.sh")
28
29
  declare -p GUARD_KIT_SCRATCH_DIRS >/dev/null 2>&1 || GUARD_KIT_SCRATCH_DIRS=(".tmp")
29
30
  declare -p GUARD_KIT_RO_BINS >/dev/null 2>&1 || GUARD_KIT_RO_BINS=(
30
31
  grep egrep fgrep rg head tail cat wc sort uniq cut tr nl rev tac paste comm column diff jq find ls xargs
31
32
  )
33
+ declare -p GUARD_KIT_APPEND_BINS >/dev/null 2>&1 || GUARD_KIT_APPEND_BINS=(cat printf echo)
32
34
 
35
+ # spec: guard-kit/SPEC.md §The guard framework — the payload cache: called directly (never in a substitution, which would kill the global with its subshell) so a rule needing a second field can have one
36
+ guard_read_input() {
37
+ GUARD_INPUT="$(cat 2>/dev/null)" || return 1
38
+ [[ -n "$GUARD_INPUT" ]] || return 1
39
+ return 0
40
+ }
41
+
42
+ # spec: guard-kit/SPEC.md §The guard framework — one field of the cached payload by jq path; an unset or empty GUARD_INPUT and an absent path alike print nothing, which is what keeps a guard that never opted in working unchanged
43
+ guard_input_field() {
44
+ local v
45
+ [[ -n "${GUARD_INPUT:-}" ]] || return 0
46
+ v="$(printf '%s' "$GUARD_INPUT" | jq -r "$1" 2>/dev/null)" || return 0
47
+ [[ "$v" == "null" ]] && return 0
48
+ printf '%s' "$v"
49
+ }
50
+
51
+ # spec: guard-kit/SPEC.md §The guard framework — GUARD_INPUT first, stdin otherwise: the fallback is what keeps every consumer copy that never opted in byte-identical
33
52
  guard_read_command() {
34
53
  local input cmd
35
- input="$(cat 2>/dev/null)" || return 1
54
+ if [[ -n "${GUARD_INPUT:-}" ]]; then
55
+ input="$GUARD_INPUT"
56
+ else
57
+ input="$(cat 2>/dev/null)" || return 1
58
+ fi
36
59
  cmd="$(printf '%s' "$input" | jq -r '.tool_input.command // empty' 2>/dev/null)" || return 1
37
60
  [[ -z "$cmd" ]] && return 1
38
61
  printf '%s' "$cmd"
@@ -41,7 +64,11 @@ guard_read_command() {
41
64
  # 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
65
  guard_read_path() {
43
66
  local input path
44
- input="$(cat 2>/dev/null)" || return 1
67
+ if [[ -n "${GUARD_INPUT:-}" ]]; then
68
+ input="$GUARD_INPUT"
69
+ else
70
+ input="$(cat 2>/dev/null)" || return 1
71
+ fi
45
72
  path="$(printf '%s' "$input" | jq -r '.tool_input.file_path // empty' 2>/dev/null)" || return 1
46
73
  [[ -z "$path" ]] && return 1
47
74
  printf '%s' "$path"
@@ -219,12 +246,12 @@ guard_skeleton() {
219
246
  printf '%s' "$out"
220
247
  }
221
248
 
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
249
+ # spec: guard-kit/SPEC.md §The guard framework — one splitter for every consumer that reasons per compound segment (rules 8/12/14/15/17/18/19/21, the read-compound carve-out, scan-prompts), fed a guard_skeleton view so the harness's per-segment boundary set never drifts
223
250
  guard_split_compound() {
224
251
  sed -E 's/\|\||&&|;|\|/\n/g' <<<"$1"
225
252
  }
226
253
 
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
254
+ # spec: guard-kit/SPEC.md §The generic ruleset — the committed Bash(...) allow inners, one per line; the fail-open read rules 18 and 19 share, so a missing jq or settings file emits nothing and every reader declines
228
255
  _guard_allow_inners() {
229
256
  command -v jq >/dev/null 2>&1 || return 0
230
257
  [[ -f "$GUARD_KIT_SETTINGS" ]] || return 0
@@ -238,7 +265,7 @@ _guard_allow_inners() {
238
265
  done < <(jq -r '.permissions.allow[]?' "$GUARD_KIT_SETTINGS" 2>/dev/null)
239
266
  }
240
267
 
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
268
+ # spec: guard-kit/SPEC.md §The generic ruleset — a segment with its redirects removed and trimmed: what rules 18 and 19 compare against a committed bare allow entry
242
269
  _guard_segment_core() {
243
270
  local seg
244
271
  seg="$(sed -E 's/[[:space:]]*[0-9]*(>>?|<)[[:space:]]*(&?[0-9-]+|[^[:space:]]+)?//g' <<<"$1")"
@@ -247,7 +274,7 @@ _guard_segment_core() {
247
274
  printf '%s' "$seg"
248
275
  }
249
276
 
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
277
+ # 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 18's predicate and rule 19's lead test
251
278
  _guard_is_bare_allow() {
252
279
  local core bl
253
280
  core="$(_guard_segment_core "$1")"
@@ -406,7 +433,7 @@ _guard_is_cat_read() {
406
433
  [[ "$operands" == 1 ]]
407
434
  }
408
435
 
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
436
+ # spec: guard-kit/SPEC.md §The generic ruleset — rule 18'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
437
  _guard_is_ro_xargs() {
411
438
  local seg="${1#"${1%%[![:space:]]*}"}" tok want_arg=0 cmdtok='' b i n
412
439
  local -a toks
@@ -509,6 +536,252 @@ guard_rule_git_grep() {
509
536
  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>."
510
537
  }
511
538
 
539
+ # spec: guard-kit/SPEC.md §The generic ruleset — rule 12's lead test: a leading shell keyword or negation does not change which binary the segment runs, so the loop-headed spelling the rule exists for is reached
540
+ _guard_command_word() {
541
+ local seg="${1#"${1%%[![:space:]]*}"}" tok
542
+ while [[ -n "$seg" ]]; do
543
+ tok="${seg%%[[:space:]]*}"
544
+ case "$tok" in
545
+ '!' | until | while | if | then | else | elif | do) ;;
546
+ *) break ;;
547
+ esac
548
+ seg="${seg#"$tok"}"
549
+ seg="${seg#"${seg%%[![:space:]]*}"}"
550
+ done
551
+ printf '%s' "$seg"
552
+ }
553
+
554
+ # spec: guard-kit/SPEC.md §The generic ruleset — rule 12's pattern operand: the literal '-f' will scan argv for, or non-zero where the segment's options cannot be walked without guessing
555
+ _guard_pgrep_pattern() {
556
+ local seg="$1" tok rest k pat='' have_f=0 skip=0
557
+ local -a toks
558
+ read -ra toks <<<"$seg"
559
+ for tok in "${toks[@]:1}"; do
560
+ if [[ "$skip" == 1 ]]; then skip=0; continue; fi
561
+ case "$tok" in
562
+ --full) have_f=1 ;;
563
+ --exact | --inverse | --count | --newest | --oldest | --ignore-case | --list-name | --list-full | --lightweight) ;;
564
+ --signal | --parent | --pgroup | --group | --session | --terminal | --euid | --uid | --delimiter) skip=1 ;;
565
+ --*) return 1 ;;
566
+ -[0-9]*) ;;
567
+ -d | -P | -g | -G | -s | -t | -u | -U) skip=1 ;;
568
+ -*)
569
+ rest="${tok#-}"
570
+ for ((k = 0; k < ${#rest}; k++)); do
571
+ case "${rest:k:1}" in
572
+ f) have_f=1 ;;
573
+ a | c | i | l | n | o | v | x | w) ;;
574
+ *) return 1 ;;
575
+ esac
576
+ done ;;
577
+ *) [[ -z "$pat" ]] || return 1; pat="$tok" ;;
578
+ esac
579
+ done
580
+ [[ "$have_f" == 1 && -n "$pat" ]] || return 1
581
+ case "$pat" in
582
+ \'*\') pat="${pat#\'}"; pat="${pat%\'}" ;;
583
+ \"*\") pat="${pat#\"}"; pat="${pat%\"}" ;;
584
+ esac
585
+ [[ -n "$pat" ]] || return 1
586
+ case "$pat" in *\'* | *\"*) return 1 ;; esac
587
+ printf '%s' "$pat"
588
+ }
589
+
590
+ guard_rule_pgrep_self_match() {
591
+ local raw="$1" seg cmdseg pat occurrences
592
+ grep -qE '\$\(|<\(|>\(|\$\{|\$[A-Za-z_]' <<<"$raw" && return 0
593
+ case "$raw" in *'`'*) return 0 ;; esac
594
+ while IFS= read -r seg; do
595
+ cmdseg="$(_guard_command_word "$seg")"
596
+ case "${cmdseg%%[[:space:]]*}" in pgrep | pkill) ;; *) continue ;; esac
597
+ pat="$(_guard_pgrep_pattern "$cmdseg")" || continue
598
+ occurrences="$(grep -oF -- "$pat" <<<"$raw" | wc -l)"
599
+ [[ "$occurrences" -ge 2 ]] || continue
600
+ guard_block "don't wait on process liveness with 'pgrep -f $pat' — '-f' matches full argv, and this command's own argv (the harness's wrapper included) carries that same literal, so the predicate is permanently true and the loop never exits. Nothing reds: the work finishes and the only symptom is the foreground cap absorbing an unbounded wait. Wait on the work's own artifact instead (an evidence file, a lock, an exit marker the work itself writes), or — where liveness genuinely is the condition — 'kill -0 <pid>' against a PID you recorded, whoever started that producer: a child you backgrounded yourself counts, and its PID is the one you recorded at launch, one line 'pid=<n> run=<key>' in a '<key>.run' file under your gitignored scratch dir. A pattern is a guess about a process table that includes the guesser; a PID is an identity. If you genuinely need pgrep, run it yourself with !<command>."
601
+ done < <(guard_split_compound "$raw" | tr '&' '\n')
602
+ }
603
+
604
+ # spec: guard-kit/SPEC.md §The generic ruleset — the ruleset's one shell-keyword walk, shared by rules 13 and 15: emits '<depth> <cmdpos> <token>' per skeleton token and returns non-zero on an unbalanced do/done so both callers decline rather than guess
605
+ _guard_loop_span() {
606
+ local s tok depth=0 cmdpos=1
607
+ s="$(tr '\n' ';' <<<"$1" | sed -E 's/(\|\||&&|;|\||&|\(|\)|\{|\})/ \1 /g')"
608
+ local -a toks
609
+ read -ra toks <<<"$s"
610
+ for tok in "${toks[@]}"; do
611
+ case "$tok" in
612
+ ';' | '|' | '||' | '&&' | '&' | '(' | ')' | '{' | '}' | \
613
+ '!' | until | while | if | then | else | elif | for)
614
+ printf '%s %s %s\n' "$depth" "$cmdpos" "$tok"
615
+ cmdpos=1 ;;
616
+ do)
617
+ depth=$((depth + 1))
618
+ printf '%s %s %s\n' "$depth" "$cmdpos" "$tok"
619
+ cmdpos=1 ;;
620
+ done)
621
+ depth=$((depth - 1))
622
+ [[ "$depth" -lt 0 ]] && return 1
623
+ printf '%s %s %s\n' "$depth" "$cmdpos" "$tok"
624
+ cmdpos=1 ;;
625
+ *)
626
+ printf '%s %s %s\n' "$depth" "$cmdpos" "$tok"
627
+ cmdpos=0 ;;
628
+ esac
629
+ done
630
+ [[ "$depth" -eq 0 ]]
631
+ }
632
+
633
+ # spec: guard-kit/SPEC.md §The generic ruleset — rule 13's loop-wrapper span: 'until <cond>; do sleep N; done' is the sanctioned wait, so only a sleep outside every do…done span fires, and an unresolvable span declines
634
+ guard_rule_bare_sleep() {
635
+ local raw="$1" s span depth cmdpos tok bare=0
636
+ grep -qE '\$\(|<\(|>\(|\$\{|\$[A-Za-z_]' <<<"$raw" && return 0
637
+ case "$raw" in *'`'*) return 0 ;; esac
638
+ s="$(guard_skeleton "$raw" sq dq hd)"
639
+ span="$(_guard_loop_span "$s")" || return 0
640
+ while read -r depth cmdpos tok; do
641
+ [[ "$tok" == sleep && "$cmdpos" == 1 && "$depth" == 0 ]] && bare=1
642
+ done <<<"$span"
643
+ [[ "$bare" == 1 ]] || return 0
644
+ guard_block "don't wait by sleeping in the foreground — a wait must end when its condition goes true, not when a duration expires, and a foreground sleep spends a full-price turn doing nothing. Background a command that *exits* on the condition ('run_in_background' wrapping 'until <cond>; do sleep N; done') and take its completion notification: it fires the moment the condition holds and then ends. A dispatched agent is awaited by its own completion notification and never by a path on disk. The harness's event-stream form stays armed to its deadline after its event fires when the command it was armed with is unbounded, so it is the second choice for a single completion. Mind the polarity: 'until' takes a done predicate ('until [ -f marker ]'), while a PID's liveness is a still-running one and takes 'while' ('while kill -0 \"\$pid\" 2>/dev/null; do sleep N; done') — inverted, the loop exits at once with the producer still running. A sleep inside a condition loop is untouched — that is the sanctioned form. If you genuinely need the settle, run it yourself with !<command>."
645
+ }
646
+
647
+ # spec: guard-kit/SPEC.md §The generic ruleset — rule 14's record reader: the one-line 'pid=<n> run=<key>' grammar is evidence-kit/SPEC.md §The producer-liveness lock's and is read rather than sourced, because a PreToolUse hook cannot depend on a sibling kit being vendored; a record that does not parse yields nothing, so the rule declines on one
648
+ _guard_live_run_records() {
649
+ local d rec line pid
650
+ for d in ${GUARD_KIT_SCRATCH_DIRS[@]+"${GUARD_KIT_SCRATCH_DIRS[@]}"}; do
651
+ [[ -d "$d" ]] || continue
652
+ for rec in "$d"/*.run; do
653
+ [[ -f "$rec" ]] || continue
654
+ IFS= read -r line <"$rec" || continue
655
+ [[ "$line" =~ ^pid=([1-9][0-9]*)[[:space:]]run=([^[:space:]]+)$ ]] || continue
656
+ pid="${BASH_REMATCH[1]}"
657
+ { kill -0 "$pid" 2>/dev/null || ps -p "$pid" >/dev/null 2>&1; } \
658
+ && printf "'%s' (pid %s, recorded in %s)\n" "${BASH_REMATCH[2]}" "$pid" "$rec"
659
+ done
660
+ done
661
+ }
662
+
663
+ # spec: guard-kit/SPEC.md §The generic ruleset — rule 14's subcommand walk: git's global options are consumed so 'git -C dir commit' is reached, and any option this list does not recognize returns non-zero so the segment declines rather than guessing which token is the subcommand
664
+ _guard_git_subcommand() {
665
+ local seg="$1" tok first=1 expect_arg=0
666
+ for tok in $seg; do
667
+ if [[ "$first" == 1 ]]; then
668
+ [[ "$tok" == git ]] || return 1
669
+ first=0
670
+ continue
671
+ fi
672
+ if [[ "$expect_arg" == 1 ]]; then expect_arg=0; continue; fi
673
+ case "$tok" in
674
+ -C | -c | --git-dir | --work-tree | --namespace | --exec-path | --config-env)
675
+ expect_arg=1 ;;
676
+ --git-dir=* | --work-tree=* | --namespace=* | --exec-path=* | --config-env=*) ;;
677
+ -p | -P | --paginate | --no-pager | --bare | --no-replace-objects | \
678
+ --literal-pathspecs | --no-literal-pathspecs | --glob-pathspecs | \
679
+ --noglob-pathspecs | --icase-pathspecs | --no-optional-locks) ;;
680
+ -*) return 1 ;;
681
+ *) printf '%s' "$tok"; return 0 ;;
682
+ esac
683
+ done
684
+ return 1
685
+ }
686
+
687
+ guard_rule_git_mutation_under_producer() {
688
+ local raw="$1" s seg cmdseg sub
689
+ case "$raw" in *git*) ;; *) return 0 ;; esac
690
+ grep -qE '\$\(|<\(|>\(|\$\{|\$[A-Za-z_]' <<<"$raw" && return 0
691
+ case "$raw" in *'`'*) return 0 ;; esac
692
+ s="$(guard_skeleton "$raw" sq dq hd)"
693
+ local -a writes=()
694
+ while IFS= read -r seg; do
695
+ cmdseg="$(_guard_command_word "$seg")"
696
+ sub="$(_guard_git_subcommand "$cmdseg")" || continue
697
+ case "$sub" in
698
+ add | commit | rm | mv | restore | checkout | switch | reset | stash | \
699
+ merge | rebase | cherry-pick | revert | apply | am | clean) ;;
700
+ *) continue ;;
701
+ esac
702
+ writes+=("git $sub")
703
+ done < <(guard_split_compound "$s")
704
+ [[ "${#writes[@]}" -gt 0 ]] || return 0
705
+
706
+ local -a runs=()
707
+ mapfile -t runs < <(_guard_live_run_records)
708
+ [[ "${#runs[@]}" -gt 0 ]] || return 0
709
+
710
+ local list
711
+ list="$(printf '%s; ' "${runs[@]}")"
712
+ guard_block "don't run '${writes[0]}' while a producer you recorded is still running — ${list%; } names a live pid, and a tracked-tree mutation under a live producer is what the wait rule exists to prevent: the run is still writing, so a commit taken now dirties the worktree underneath it and its verdict has to be discarded and re-run. Two exits, both cheap: wait for that producer on its own artifact (loop on the recorded pid's liveness, 'until ! kill -0 <pid> 2>/dev/null; do sleep 5; done', backgrounded so its completion notifies you), or — if the producer has already exited — delete its .run file, which is not a workaround but the statement of fact becoming false and being retracted. Read-only git ('status', 'log', 'diff', 'show') is untouched. If you genuinely need this mutation now, run it yourself with !<command>."
713
+ }
714
+
715
+ # spec: guard-kit/SPEC.md §The generic ruleset — every redirect target in a skeleton, one per line: the corpus rules 15 and 18 both read
716
+ _guard_redirect_targets() {
717
+ grep -oE '[0-9]*>>?[[:space:]]*[^[:space:]|;&]+' <<<"$1" \
718
+ | sed -E 's/^[0-9]*>>?[[:space:]]*//'
719
+ }
720
+
721
+ # spec: guard-kit/SPEC.md §The generic ruleset — the read-only-segment test rules 15 and 18 share, xargs discriminator included because xargs runs a command rather than filtering text
722
+ _guard_is_ro_segment() {
723
+ local seg="${1#"${1%%[![:space:]]*}"}" first b
724
+ first="${seg%%[[:space:]]*}"
725
+ [[ -n "$first" ]] || return 1
726
+ [[ "$first" == xargs ]] && { _guard_is_ro_xargs "$seg" || return 1; }
727
+ for b in "${GUARD_KIT_RO_BINS[@]}"; do
728
+ [[ "$first" == "$b" ]] && return 0
729
+ done
730
+ return 1
731
+ }
732
+
733
+ # spec: guard-kit/SPEC.md §The generic ruleset — rule 15's shell arm: a statement-ending bare '&' in the skeleton, never the '&&' operator and never a redirect's fd-dup
734
+ _guard_shell_backgrounds() {
735
+ grep -qE '(^|[^&>])&([[:space:]]|;|$)' <<<"$1"
736
+ }
737
+
738
+ # spec: guard-kit/SPEC.md §The generic ruleset — rule 15's record-writing test: at PreToolUse the child has not started and no record can exist yet, so the only observable is whether the launch is going to write one
739
+ _guard_writes_run_record() {
740
+ local d tgt
741
+ while read -r tgt; do
742
+ case "$tgt" in *.run) ;; *) continue ;; esac
743
+ for d in ${GUARD_KIT_SCRATCH_DIRS[@]+"${GUARD_KIT_SCRATCH_DIRS[@]}"}; do
744
+ case "$tgt" in "$d"/*) return 0 ;; esac
745
+ done
746
+ done < <(_guard_redirect_targets "$1")
747
+ return 1
748
+ }
749
+
750
+ # spec: guard-kit/SPEC.md §The generic ruleset — rule 15's exemption 3: a child that writes nothing has nothing for a later commit to corrupt, so it owes no record
751
+ _guard_is_ro_background() {
752
+ local s="$1" tgt seg reads=0
753
+ while read -r tgt; do
754
+ case "$tgt" in
755
+ /dev/null | '&'[0-9]*) ;;
756
+ *) return 1 ;;
757
+ esac
758
+ done < <(_guard_redirect_targets "$s")
759
+ while IFS= read -r seg; do
760
+ seg="${seg#"${seg%%[![:space:]]*}"}"
761
+ [[ -z "$seg" ]] && continue
762
+ _guard_is_banner "$seg" && continue
763
+ _guard_is_ro_segment "$seg" || return 1
764
+ reads=$((reads + 1))
765
+ done < <(guard_split_compound "$s")
766
+ [[ "$reads" -ge 1 ]]
767
+ }
768
+
769
+ guard_rule_background_no_record() {
770
+ local raw="$1" s span depth cmdpos tok
771
+ grep -qE '\$\(|<\(|>\(|\$\{|\$[A-Za-z_]' <<<"$raw" && return 0
772
+ case "$raw" in *'`'*) return 0 ;; esac
773
+ s="$(guard_skeleton "$raw" sq dq hd)"
774
+ [[ "$(guard_input_field '.tool_input.run_in_background')" == "true" ]] \
775
+ || _guard_shell_backgrounds "$s" || return 0
776
+ _guard_writes_run_record "$s" && return 0
777
+ span="$(_guard_loop_span "$s")" || return 0
778
+ while read -r depth cmdpos tok; do
779
+ [[ "$depth" -ge 1 ]] && return 0
780
+ done <<<"$span"
781
+ _guard_is_ro_background "$s" && return 0
782
+ guard_advise "this call backgrounds a child and writes no liveness record — write one at the launch, in the same command: a single line 'pid=<n> run=<key>' in a '<key>.run' file under your gitignored scratch dir (e.g. ${GUARD_KIT_SCRATCH_DIRS[0]}/<key>.run), naming the PID you just backgrounded. The record buys two things nothing else does: it is what gives the tracked-tree-mutation rule its reach, so a commit taken while this child is still writing is refused rather than silently taken; and it is what lets the next arrival tell whether the producer is still writing instead of guessing at a process table. Delete it once the producer has exited, and not before — a record naming a dead pid blocks nothing, and one deleted early buys the harm back. A backgrounded wait loop and a backgrounded read-only pipeline own no work a commit could corrupt and owe no record."
783
+ }
784
+
512
785
  guard_rule_truncate_scratch() {
513
786
  local cmd
514
787
  cmd="$(guard_skeleton "$1" sq dq hd)"
@@ -525,6 +798,77 @@ guard_rule_truncate_scratch() {
525
798
  fi
526
799
  }
527
800
 
801
+ # spec: guard-kit/SPEC.md §The generic ruleset — rule 17's redirect scan, operator and target together and fd-dups included: _guard_redirect_targets' target class excludes '&', so it drops an fd-dup target entirely and a rule that must exempt one cannot see it there
802
+ _guard_redirect_pairs() {
803
+ grep -oE '[0-9]*>>?[[:space:]]*(&[0-9-]+|[^[:space:]|;&<>]+)' <<<"$1"
804
+ }
805
+
806
+ # spec: guard-kit/SPEC.md §The generic ruleset — rule 17's single-statement test: guard_skeleton leaves a heredoc's body placeholder and terminator on lines of their own and guard_split_compound emits per line, so one statement is one segment plus exactly the residue that segment's own openers produce, never one segment
807
+ _guard_only_heredoc_residue() {
808
+ local -a segs=() terms=()
809
+ local t seg i=1
810
+ mapfile -t segs < <(guard_split_compound "$1")
811
+ [[ "${#segs[@]}" -ge 1 ]] || return 1
812
+ while IFS= read -r t; do
813
+ t="${t#*<<}"
814
+ t="${t#-}"
815
+ t="${t#"${t%%[![:space:]]*}"}"
816
+ t="${t#[\"\']}"
817
+ t="${t%[\"\']}"
818
+ terms+=("$t")
819
+ done < <(grep -oE '<<-?[[:space:]]*("[^"]*"|'\''[^'\'']*'\''|[A-Za-z_][A-Za-z0-9_]*)' <<<"${segs[0]}")
820
+ for t in ${terms[@]+"${terms[@]}"}; do
821
+ seg="${segs[i]:-}"
822
+ seg="${seg#"${seg%%[![:space:]]*}"}"
823
+ if [[ "$seg" == HD ]]; then
824
+ ((i++))
825
+ seg="${segs[i]:-}"
826
+ seg="${seg#"${seg%%[![:space:]]*}"}"
827
+ fi
828
+ [[ "$seg" == "$t" ]] || return 1
829
+ ((i++))
830
+ done
831
+ [[ "$i" -eq "${#segs[@]}" ]]
832
+ }
833
+
834
+ guard_rule_append_scratch() {
835
+ local raw="$1" s
836
+ # spec: guard-kit/SPEC.md §The guard framework — the raw-command carve-out every auto-allow rule takes; rule 6 blocks three of the four substitution spellings and exits 2 first, but not the output-process-substitution one, and a grant may not rest on a coverage claim that is only mostly true
837
+ grep -qE '\$\(|<\(|>\(' <<<"$raw" && return 0
838
+ case "$raw" in *'`'*) return 0 ;; esac
839
+ s="$(guard_skeleton "$raw" sq dq hd)"
840
+ _guard_shell_backgrounds "$s" && return 0
841
+ _guard_only_heredoc_residue "$s" || return 0
842
+
843
+ local lead b on_roster=0
844
+ lead="${s%%$'\n'*}"
845
+ lead="${lead#"${lead%%[![:space:]]*}"}"
846
+ lead="${lead%%[[:space:]]*}"
847
+ for b in "${GUARD_KIT_APPEND_BINS[@]}"; do
848
+ [[ "$lead" == "$b" ]] && { on_roster=1; break; }
849
+ done
850
+ [[ "$on_roster" == 1 ]] || return 0
851
+
852
+ local pair op tgt
853
+ local -a targets=()
854
+ while IFS= read -r pair; do
855
+ [[ -z "$pair" ]] && continue
856
+ pair="${pair#"${pair%%[!0-9]*}"}"
857
+ if [[ "$pair" == '>>'* ]]; then op='>>'; tgt="${pair#>>}"; else op='>'; tgt="${pair#>}"; fi
858
+ tgt="${tgt#"${tgt%%[![:space:]]*}"}"
859
+ case "$tgt" in /dev/null | '&'[0-9-]*) continue ;; esac
860
+ case "$tgt" in *[\"\']*) return 0 ;; esac
861
+ [[ "$op" == '>>' ]] || return 0
862
+ targets+=("$tgt")
863
+ done < <(_guard_redirect_pairs "$s")
864
+ [[ "${#targets[@]}" -ge 1 ]] || return 0
865
+
866
+ for tgt in "${targets[@]}"; do
867
+ git check-ignore --quiet -- "$tgt" || return 0
868
+ done
869
+ guard_allow "append to gitignored scratch (${GUARD_NAME:-guard} auto-allow)"
870
+ }
871
+
528
872
  guard_rule_ro_pipeline() {
529
873
  local raw="$1"
530
874
  # spec: guard-kit/SPEC.md §The guard framework — the raw-command carve-out these two tests take
@@ -541,28 +885,22 @@ guard_rule_ro_pipeline() {
541
885
  /dev/null | '&'[0-9]*) ;;
542
886
  *) return 0 ;;
543
887
  esac
544
- done < <(grep -oE '[0-9]*>>?[[:space:]]*[^[:space:]|;&]+' <<<"$s" \
545
- | sed -E 's/^[0-9]*>>?[[:space:]]*//')
888
+ done < <(_guard_redirect_targets "$s")
546
889
  if grep -qE '(^|[[:space:]])find([[:space:]]|$)' <<<"$s" \
547
890
  && grep -qE '\-(exec|execdir|ok|delete)\b' <<<"$s"; then
548
891
  return 0
549
892
  fi
550
893
  local -a segs
551
894
  mapfile -t segs < <(guard_split_compound "$s")
552
- local seg first b i matched reads=0
895
+ local seg i reads=0
553
896
  for ((i = 0; i < ${#segs[@]}; i++)); do
554
897
  seg="${segs[i]}"
555
898
  seg="${seg#"${seg%%[![:space:]]*}"}"
556
899
  [[ -z "$seg" ]] && continue
557
900
  _guard_is_banner "$seg" && continue
558
- first="${seg%%[[:space:]]*}"
559
- [[ "$first" == xargs ]] && { _guard_is_ro_xargs "$seg" || return 0; }
560
- matched=0
561
- for b in "${GUARD_KIT_RO_BINS[@]}"; do
562
- [[ "$first" == "$b" ]] && { matched=1; break; }
563
- done
564
- if [[ "$matched" == 0 ]]; then
565
- # spec: guard-kit/SPEC.md §The generic ruleset — rule 13's widened lead: a bare
901
+ [[ "${seg%%[[:space:]]*}" == xargs ]] && { _guard_is_ro_xargs "$seg" || return 0; }
902
+ if ! _guard_is_ro_segment "$seg"; then
903
+ # spec: guard-kit/SPEC.md §The generic ruleset — rule 18's widened lead: a bare
566
904
  # committed allow entry qualifies, but only where something decorates it
567
905
  [[ "$i" == 0 && "${#segs[@]}" -gt 1 ]] || return 0
568
906
  _guard_is_bare_allow "$seg" || return 0
@@ -663,7 +1001,12 @@ guard_generic_rules() {
663
1001
  guard_rule_find_glob "$cmd"
664
1002
  guard_rule_cat_file "$cmd"
665
1003
  guard_rule_git_grep "$cmd"
1004
+ guard_rule_pgrep_self_match "$cmd"
1005
+ guard_rule_bare_sleep "$cmd"
1006
+ guard_rule_git_mutation_under_producer "$cmd"
1007
+ guard_rule_background_no_record "$cmd"
666
1008
  guard_rule_truncate_scratch "$cmd"
1009
+ guard_rule_append_scratch "$cmd"
667
1010
  guard_rule_ro_pipeline "$cmd"
668
1011
  guard_rule_allowlist_chain "$cmd"
669
1012
  guard_rule_git_rewrite "$cmd"
@@ -9,6 +9,8 @@ GUARD_KIT_LIB="${GUARD_KIT_LIB:-guard-kit/lib/guard.sh}"
9
9
  # shellcheck source=/dev/null # vendored lib path is resolved at runtime; fail-open above if absent, but the lib's own exit 2 (set-but-missing config) must stay loud
10
10
  source "$GUARD_KIT_LIB"
11
11
 
12
+ # spec: guard-kit/SPEC.md §The guard framework — cache the payload before the first field is read, so a rule needing a tool-input field beyond the command can reach one
13
+ guard_read_input || exit 0
12
14
  cmd="$(guard_read_command)" || exit 0
13
15
 
14
16
  # spec: guard-kit/SPEC.md §Consumer rules — add project block/steer/allow rules here (compose guard.sh primitives), before the generic ruleset [EDIT ME]
@@ -27,11 +27,18 @@ of lifecycle-kit's `tooling-friction triage` placeholder (close skill, step 2).
27
27
  each has its own disposition.
28
28
  - **Redundant**: remove every listed `settings.local.json` entry (a committed
29
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
30
+ - **Too broad**: for every entry the report lists as a *narrowing candidate*,
31
+ either narrow the glob or record that its breadth is intended — as a
32
+ `GUARD_KIT_BREADTH_DECLARED` entry (glob plus reason) in the committed
33
+ `guard-config.sh`, which moves it into the report's *declared intended*
34
+ section and stops it re-reporting. A per-clone note does not: the ruling is
35
+ durable only where it is tracked. The probe printed beside an entry is the
36
+ witness — the command that glob auto-allows. An empty breadth report is
33
37
  not a proof of narrowness: probes are witnesses, and no completeness is
34
38
  claimed (the section is absent entirely when no probes are declared).
39
+ Read the declared section too — it is the record of what was ruled, and a
40
+ declaration whose glob is gone from the overlay is spent and should be
41
+ dropped.
35
42
 
36
43
  - **Not content-pinned**: an entry naming a *script path* rather than a fixed
37
44
  command grants whatever that file says at run time, so its meaning changes
@@ -3,3 +3,6 @@
3
3
 
4
4
  # spec: guard-kit/SPEC.md §compare-settings-allow — declare your own probes; the kit ships none
5
5
  # GUARD_KIT_BREADTH_PROBES=("Bash(rm -rf /)")
6
+
7
+ # spec: guard-kit/SPEC.md §compare-settings-allow — a breadth ruled intended, keyed on the exact local allow-rule string; the kit ships no declarations either
8
+ # declare -A GUARD_KIT_BREADTH_DECLARED=(["Bash(mytool *)"]="every subcommand is read-only")
@@ -2,8 +2,9 @@
2
2
 
3
3
  The iteration stage state machine for coding-agent-assisted delivery: a
4
4
  `## Iteration: <name>` header line in the task queue naming the iteration, an
5
- evidence file of `<iteration> <stage> <session-id> <date>` stamps whose **last
6
- stamp is the current stage**, stage
5
+ evidence file of `<iteration> <stage> <session-id> <date> <head>` stamps whose
6
+ **last stamp is the current stage** and whose `<head>` binds each stamp to the
7
+ commit it was taken at, stage
7
8
  skills (scope/align/build/validate/close by default — stages are config), and
8
9
  gates that make skipping a stage, or claiming one without running
9
10
  its skill, fail the commit.