checkwright 0.21.0 → 0.22.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 (236) hide show
  1. package/README.md +385 -19
  2. package/lib/common/digest.sh +18 -0
  3. package/lib/common/lock.sh +11 -0
  4. package/lib/common/recipe.sh +8 -11
  5. package/lib/doctor.sh +49 -0
  6. package/lib/init.sh +152 -29
  7. package/package.json +2 -2
  8. package/payload/artifact/targets.list +30 -0
  9. package/payload/artifact/x86_64-unknown-linux-gnu/checkwright-gates +0 -0
  10. package/payload/artifact/x86_64-unknown-linux-gnu/checkwright-gates.sha256 +1 -0
  11. package/payload/canon-kit/README.md +1 -0
  12. package/payload/canon-kit/SPEC.md +279 -24
  13. package/payload/canon-kit/checks/check-comment-tier.sh +7 -2
  14. package/payload/canon-kit/checks/check-docs-link-convention.sh +11 -4
  15. package/payload/canon-kit/checks/check-payload-claim.sh +133 -0
  16. package/payload/canon-kit/checks/check-prose-enum.sh +1 -1
  17. package/payload/canon-kit/checks/check-spec-pointer.sh +9 -2
  18. package/payload/canon-kit/gate-tests/check-comment-tier/good/good.sh +3 -0
  19. package/payload/canon-kit/gate-tests/check-comment-tier.test.sh +26 -3
  20. package/payload/canon-kit/gate-tests/check-docs-link-convention/bad/OUTSIDE.md +4 -0
  21. package/payload/canon-kit/gate-tests/check-docs-link-convention/bad/docs/index.md +3 -0
  22. package/payload/canon-kit/gate-tests/check-docs-link-convention/good/OUTSIDE.md +4 -0
  23. package/payload/canon-kit/gate-tests/check-docs-link-convention/good/docs/methodology.md +8 -0
  24. package/payload/canon-kit/gate-tests/check-docs-link-convention.test.sh +94 -0
  25. package/payload/canon-kit/gate-tests/check-manifest-count.test.sh +5 -3
  26. package/payload/canon-kit/gate-tests/check-payload-claim/bad/README.md +15 -0
  27. package/payload/canon-kit/gate-tests/check-payload-claim/bad/expect.txt +2 -0
  28. package/payload/canon-kit/gate-tests/check-payload-claim/bad/install.md +19 -0
  29. package/payload/canon-kit/gate-tests/check-payload-claim/bad/posts/note.md +6 -0
  30. package/payload/canon-kit/gate-tests/check-payload-claim/bad/scripts/canon-config.sh +8 -0
  31. package/payload/canon-kit/gate-tests/check-payload-claim/bad/scripts/payload-claims.sh +7 -0
  32. package/payload/canon-kit/gate-tests/check-payload-claim/good/README.md +15 -0
  33. package/payload/canon-kit/gate-tests/check-payload-claim/good/expect.txt +2 -0
  34. package/payload/canon-kit/gate-tests/check-payload-claim/good/install.md +20 -0
  35. package/payload/canon-kit/gate-tests/check-payload-claim/good/posts/note.md +6 -0
  36. package/payload/canon-kit/gate-tests/check-payload-claim/good/scripts/canon-config.sh +8 -0
  37. package/payload/canon-kit/gate-tests/check-payload-claim/good/scripts/payload-claims.sh +7 -0
  38. package/payload/canon-kit/gate-tests/check-prose-enum.test.sh +24 -1
  39. package/payload/canon-kit/gate-tests/check-spec-pointer/bad/expect.txt +1 -0
  40. package/payload/canon-kit/gate-tests/check-spec-pointer/bad/widget.sh +1 -0
  41. package/payload/canon-kit/gate-tests/check-spec-pointer/good/widget.sh +1 -0
  42. package/payload/canon-kit/lib/spec.sh +22 -12
  43. package/payload/canon-kit/smoke/install.sh +20 -1
  44. package/payload/canon-kit/templates/SPEC-amendment.md +5 -1
  45. package/payload/context-kit/SPEC.md +25 -1
  46. package/payload/context-kit/lib/toolfloor.sh +1 -1
  47. package/payload/context-kit/smoke/install.sh +3 -1
  48. package/payload/delegation-kit/SPEC.md +383 -13
  49. package/payload/delegation-kit/bin/run-dispatch-guard-tests.sh +97 -0
  50. package/payload/delegation-kit/checks/check-gate-tamper.sh +1 -1
  51. package/payload/delegation-kit/lib/delegation.sh +1 -0
  52. package/payload/delegation-kit/smoke/install.sh +2 -1
  53. package/payload/delegation-kit/templates/agent-dispatch-guard.sh +61 -0
  54. package/payload/delegation-kit/templates/agent-execution.md +103 -12
  55. package/payload/delegation-kit/templates/delegation-config.sh +4 -0
  56. package/payload/delegation-kit/templates/dispatch-checklists.md +1 -1
  57. package/payload/delegation-kit/usage-tests/dispatch-guard-cases.tsv +30 -0
  58. package/payload/doctrine-kit/DOCTRINE.md +27 -0
  59. package/payload/doctrine-kit/README.md +5 -0
  60. package/payload/doctrine-kit/SPEC.md +62 -3
  61. package/payload/doctrine-kit/bin/install-doctrine.sh +84 -4
  62. package/payload/doctrine-kit/smoke/install.sh +77 -1
  63. package/payload/drift-kit/README.md +3 -2
  64. package/payload/drift-kit/SPEC.md +253 -20
  65. package/payload/drift-kit/bin/stage-economics.sh +157 -3
  66. package/payload/drift-kit/kpis/kpi-incident-recurrence.sh +42 -0
  67. package/payload/drift-kit/smoke/install.sh +155 -1
  68. package/payload/drift-kit/templates/economics.md +9 -0
  69. package/payload/drift-kit/templates/kpis.list +6 -1
  70. package/payload/evidence-kit/README.md +20 -6
  71. package/payload/evidence-kit/SPEC.md +355 -17
  72. package/payload/evidence-kit/bin/run-validate.sh +51 -9
  73. package/payload/evidence-kit/checks/check-battery-roster.sh +86 -0
  74. package/payload/evidence-kit/checks/check-producer-liveness.sh +34 -0
  75. package/payload/evidence-kit/gate-tests/check-battery-roster/bad/args +1 -0
  76. package/payload/evidence-kit/gate-tests/check-battery-roster/bad/expect.txt +1 -0
  77. package/payload/evidence-kit/gate-tests/check-battery-roster/bad/runner.md +14 -0
  78. package/payload/evidence-kit/gate-tests/check-battery-roster/bad/scripts/evidence-config.sh +7 -0
  79. package/payload/evidence-kit/gate-tests/check-battery-roster/good/args +1 -0
  80. package/payload/evidence-kit/gate-tests/check-battery-roster/good/expect.txt +1 -0
  81. package/payload/evidence-kit/gate-tests/check-battery-roster/good/runner.md +14 -0
  82. package/payload/evidence-kit/gate-tests/check-battery-roster/good/scripts/evidence-config.sh +7 -0
  83. package/payload/evidence-kit/gate-tests/check-battery-roster.test.sh +68 -0
  84. package/payload/evidence-kit/gate-tests/check-producer-liveness/bad/args +1 -0
  85. package/payload/evidence-kit/gate-tests/check-producer-liveness/bad/expect.txt +1 -0
  86. package/payload/evidence-kit/gate-tests/check-producer-liveness/bad/run-validate.lock +1 -0
  87. package/payload/evidence-kit/gate-tests/check-producer-liveness/good/args +1 -0
  88. package/payload/evidence-kit/gate-tests/check-producer-liveness/good/expect.txt +2 -0
  89. package/payload/evidence-kit/gate-tests/check-producer-liveness/good/run-validate.lock +1 -0
  90. package/payload/evidence-kit/gate-tests/producer-lock.test.sh +109 -0
  91. package/payload/evidence-kit/lib/evidence.sh +18 -0
  92. package/payload/evidence-kit/smoke/install.sh +17 -3
  93. package/payload/gate-sdk/README.md +4 -1
  94. package/payload/gate-sdk/SPEC.md +1949 -74
  95. package/payload/gate-sdk/bin/gen-pre-commit.sh +12 -2
  96. package/payload/gate-sdk/bin/run-consumer-smoke.sh +121 -1
  97. package/payload/gate-sdk/bin/run-gate-tests.sh +40 -9
  98. package/payload/gate-sdk/bin/run-gates.sh +31 -2
  99. package/payload/gate-sdk/bin/upgrade-smoke.sh +3 -3
  100. package/payload/gate-sdk/checks/check-action-gh-repo.gate +2 -0
  101. package/payload/gate-sdk/checks/check-action-pinning.gate +2 -0
  102. package/payload/gate-sdk/checks/check-action-run-shell.sh +3 -1
  103. package/payload/gate-sdk/checks/check-core-files.sh +27 -4
  104. package/payload/gate-sdk/checks/check-exec-bit.sh +20 -1
  105. package/payload/gate-sdk/checks/check-gate-binary-fresh.sh +106 -0
  106. package/payload/gate-sdk/checks/check-gate-exemption-tasks.sh +6 -7
  107. package/payload/gate-sdk/checks/check-gate-output.sh +9 -1
  108. package/payload/gate-sdk/checks/check-gate-substrate-parity.sh +302 -0
  109. package/payload/gate-sdk/checks/check-graph.sh +4 -5
  110. package/payload/gate-sdk/checks/check-readme-roster.sh +5 -0
  111. package/payload/gate-sdk/checks/check-reads-couples.sh +70 -21
  112. package/payload/gate-sdk/checks/check-template-registry-parity.sh +81 -0
  113. package/payload/gate-sdk/gate-tests/check-action-run-shell.test.sh +16 -1
  114. package/payload/gate-sdk/gate-tests/check-core-files.test.sh +64 -0
  115. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/bad/args +2 -0
  116. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/bad/expect.txt +5 -0
  117. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/bad/kitroot/checks/check-vendored.gate +2 -0
  118. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/bad/scripts/check-ported.gate +2 -0
  119. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/bad/scripts/gate-sdk-config.sh +2 -0
  120. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/bad/scripts/gates.list +4 -0
  121. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/bad/stamp.txt +1 -0
  122. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/bad/stub-bin +6 -0
  123. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/good/args +2 -0
  124. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/good/expect.txt +5 -0
  125. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/good/kitroot/checks/check-vendored.gate +2 -0
  126. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/good/scripts/check-ported.gate +2 -0
  127. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/good/scripts/gate-sdk-config.sh +2 -0
  128. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/good/scripts/gates.list +4 -0
  129. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/good/stamp.txt +1 -0
  130. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/good/stub-bin +5 -0
  131. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh.test.sh +81 -0
  132. package/payload/gate-sdk/gate-tests/check-gate-exemption-tasks/bad/TASK-QUEUE.md +3 -1
  133. package/payload/gate-sdk/gate-tests/check-gate-exemption-tasks/bad/expect.txt +3 -1
  134. package/payload/gate-sdk/gate-tests/check-gate-exemption-tasks/bad/gates/check-sample.sh +3 -1
  135. package/payload/gate-sdk/gate-tests/check-gate-exemption-tasks/good/expect.txt +1 -0
  136. package/payload/gate-sdk/gate-tests/check-gate-output/bad/check-sample.sh +1 -0
  137. package/payload/gate-sdk/gate-tests/check-gate-output/good/check-sample.sh +1 -0
  138. package/payload/gate-sdk/gate-tests/check-gate-output/good/expect.txt +1 -0
  139. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/args +2 -0
  140. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/conservation.md +7 -0
  141. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/expect.txt +12 -0
  142. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/impl/gate.rs +2 -0
  143. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/kitroot/check-orphan.rs +3 -0
  144. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/publish.yml +15 -0
  145. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/scripts/check-alpha.sh +3 -0
  146. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/scripts/check-dup.gate +1 -0
  147. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/scripts/check-dup.sh +3 -0
  148. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/scripts/check-orphan.gate +1 -0
  149. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/scripts/gate-sdk-config.sh +6 -0
  150. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/scripts/gates.list +3 -0
  151. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/stub-bin +3 -0
  152. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/targets.list +3 -0
  153. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/args +2 -0
  154. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/conservation.md +8 -0
  155. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/expect.txt +7 -0
  156. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/impl/gate.rs +2 -0
  157. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/kitroot/check-other.rs +3 -0
  158. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/publish.yml +15 -0
  159. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/scripts/check-alpha.sh +3 -0
  160. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/scripts/check-ported.gate +2 -0
  161. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/scripts/gate-sdk-config.sh +6 -0
  162. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/scripts/gates.list +2 -0
  163. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/stub-bin +3 -0
  164. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/targets.list +2 -0
  165. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity.test.sh +123 -0
  166. package/payload/gate-sdk/gate-tests/check-reads-couples.test.sh +139 -0
  167. package/payload/gate-sdk/gate-tests/check-template-registry-parity/bad/alpha-kit/templates/widgets.list +4 -0
  168. package/payload/gate-sdk/gate-tests/check-template-registry-parity/bad/alpha-kit/widgets/widget-one.sh +3 -0
  169. package/payload/gate-sdk/gate-tests/check-template-registry-parity/bad/alpha-kit/widgets/widget-two.sh +3 -0
  170. package/payload/gate-sdk/gate-tests/check-template-registry-parity/bad/args +4 -0
  171. package/payload/gate-sdk/gate-tests/check-template-registry-parity/bad/expect.txt +1 -0
  172. package/payload/gate-sdk/gate-tests/check-template-registry-parity/bad/scripts/gate-sdk-config.sh +5 -0
  173. package/payload/gate-sdk/gate-tests/check-template-registry-parity/good/alpha-kit/templates/widgets.list +4 -0
  174. package/payload/gate-sdk/gate-tests/check-template-registry-parity/good/alpha-kit/widgets/widget-one.sh +3 -0
  175. package/payload/gate-sdk/gate-tests/check-template-registry-parity/good/alpha-kit/widgets/widget-two.sh +3 -0
  176. package/payload/gate-sdk/gate-tests/check-template-registry-parity/good/args +8 -0
  177. package/payload/gate-sdk/gate-tests/check-template-registry-parity/good/beta-kit/templates/rules.list +5 -0
  178. package/payload/gate-sdk/gate-tests/check-template-registry-parity/good/beta-kit/templates/table.tsv +4 -0
  179. package/payload/gate-sdk/gate-tests/check-template-registry-parity/good/expect.txt +1 -0
  180. package/payload/gate-sdk/gate-tests/check-template-registry-parity/good/scripts/gate-sdk-config.sh +5 -0
  181. package/payload/gate-sdk/gate-tests/lib-declaration.test.sh +4 -4
  182. package/payload/gate-sdk/gate-tests/lib-gate.test.sh +41 -1
  183. package/payload/gate-sdk/gate-tests/run-gate-tests.test.sh +144 -0
  184. package/payload/gate-sdk/lib/consumer-smoke.sh +26 -1
  185. package/payload/gate-sdk/lib/gate.sh +75 -0
  186. package/payload/gate-sdk/lib/inject.sh +21 -1
  187. package/payload/gate-sdk/smoke/install.sh +19 -1
  188. package/payload/guard-kit/README.md +4 -3
  189. package/payload/guard-kit/SPEC.md +88 -10
  190. package/payload/guard-kit/bin/compare-settings-allow.sh +40 -7
  191. package/payload/guard-kit/gate-tests/compare-settings-allow.test.sh +64 -0
  192. package/payload/guard-kit/lib/guard.sh +1 -0
  193. package/payload/guard-kit/templates/close-triage.md +35 -7
  194. package/payload/guard-kit/templates/guard-config.sh +3 -0
  195. package/payload/lifecycle-kit/README.md +1 -0
  196. package/payload/lifecycle-kit/SPEC.md +575 -29
  197. package/payload/lifecycle-kit/bin/enter-stage.sh +13 -3
  198. package/payload/lifecycle-kit/bin/file-gap.sh +42 -1
  199. package/payload/lifecycle-kit/bin/file-survey.sh +50 -0
  200. package/payload/lifecycle-kit/checks/check-merge-attrs.sh +1 -1
  201. package/payload/lifecycle-kit/checks/check-skill-binding.sh +1 -1
  202. package/payload/lifecycle-kit/checks/check-survey-record.sh +102 -0
  203. package/payload/lifecycle-kit/gate-tests/check-merge-attrs/bad/.gitattributes +1 -0
  204. package/payload/lifecycle-kit/gate-tests/check-merge-attrs/good/.gitattributes +1 -0
  205. package/payload/lifecycle-kit/gate-tests/check-merge-attrs.test.sh +1 -0
  206. package/payload/lifecycle-kit/gate-tests/check-survey-record/bad/args +2 -0
  207. package/payload/lifecycle-kit/gate-tests/check-survey-record/bad/expect.txt +4 -0
  208. package/payload/lifecycle-kit/gate-tests/check-survey-record/bad/record.md +18 -0
  209. package/payload/lifecycle-kit/gate-tests/check-survey-record/good/args +2 -0
  210. package/payload/lifecycle-kit/gate-tests/check-survey-record/good/expect.txt +1 -0
  211. package/payload/lifecycle-kit/gate-tests/check-survey-record/good/record.md +13 -0
  212. package/payload/lifecycle-kit/gate-tests/check-survey-record.test.sh +84 -0
  213. package/payload/lifecycle-kit/gate-tests/file-gap-recurrence.test.sh +94 -0
  214. package/payload/lifecycle-kit/gate-tests/survey-record-entry.test.sh +102 -0
  215. package/payload/lifecycle-kit/lib/stages.sh +8 -2
  216. package/payload/lifecycle-kit/smoke/install.sh +17 -1
  217. package/payload/lifecycle-kit/templates/consult.md +73 -0
  218. package/payload/lifecycle-kit/templates/lead.md +103 -7
  219. package/payload/lifecycle-kit/templates/stages/align.md +12 -0
  220. package/payload/lifecycle-kit/templates/stages/build.md +8 -0
  221. package/payload/lifecycle-kit/templates/stages/close.md +25 -4
  222. package/payload/lifecycle-kit/templates/stages/scope.md +34 -0
  223. package/payload/lifecycle-kit/templates/stages/spec.md +8 -0
  224. package/payload/lifecycle-kit/templates/stages/validate.md +8 -0
  225. package/payload/queue-kit/README.md +4 -1
  226. package/payload/queue-kit/SPEC.md +230 -6
  227. package/payload/queue-kit/bin/queue-edges.sh +78 -0
  228. package/payload/queue-kit/checks/check-queue-entry-budget.sh +5 -3
  229. package/payload/queue-kit/gate-tests/check-queue-hygiene/good/TASK-QUEUE.md +5 -0
  230. package/payload/queue-kit/gate-tests/queue-edges.test.sh +130 -0
  231. package/payload/queue-kit/smoke/install.sh +4 -1
  232. package/payload/queue-kit/templates/TASK-QUEUE.md +3 -0
  233. package/payload/site-kit/SPEC.md +41 -27
  234. package/payload/site-kit/smoke/install.sh +9 -1
  235. package/payload/gate-sdk/checks/check-action-gh-repo.sh +0 -321
  236. package/payload/gate-sdk/checks/check-action-pinning.sh +0 -55
@@ -8,6 +8,8 @@ SDK="$SMOKE_KIT_ROOT/../gate-sdk" # the vendored gate-sdk beside this kit
8
8
  cat >> scripts/gates.list <<'EOF'
9
9
  # context-kit
10
10
  check-brevity
11
+ check-memory-off
12
+ check-settings-pins
11
13
  EOF
12
14
 
13
15
  cp "$SMOKE_KIT_ROOT/templates/context-config.sh" scripts/context-config.sh
@@ -35,7 +37,7 @@ qtpl="$SMOKE_KIT_ROOT/../queue-kit/templates/TASK-QUEUE.md"
35
37
  [[ -f TASK-QUEUE.md || ! -f "$qtpl" ]] || cp "$qtpl" TASK-QUEUE.md
36
38
 
37
39
  bash "$SDK/bin/gen-pre-commit.sh" --write >/dev/null
38
- bash "$SDK/checks/check-graph.sh" --emit > .workflow/CHECK-GRAPH.html
40
+ bash "$SDK/checks/check-graph.sh" --emit > scripts/CHECK-GRAPH.html
39
41
 
40
42
  hook_out="$(bash scripts/session-context.sh 2>/dev/null)"; rc=$?
41
43
  if [[ "$rc" -ne 0 ]]; then
@@ -182,6 +182,144 @@ than left out — an omitted `model:` resolves to the literal `inherit`, so
182
182
  omission spells the dispatcher's tier rather than a neutral absence, and
183
183
  `check-agent-tier-explicit` is that clause's oracle over the tracked surface.
184
184
 
185
+ **The dispatch-shape rules are one mechanism, seen from several sides.** The template's **Never dispatch
186
+ a fork to narrow a child**, **A read-only claim is made by isolation, not by
187
+ sentence**, and **A child's only upward route is a durable artifact** rules are
188
+ one defect seen from three sides: each governs the *shape of a dispatch call*,
189
+ and each failed the same way — the prose did not reach the reader it binds.
190
+ One attested surface per rule: a fork dispatched as a read-only audit completed
191
+ a whole stage, commits included; four forks dispatched with prose-only
192
+ "read-only, no edits" briefs, one of which committed unreviewed on the shared
193
+ branch; and repeated fan-outs, across stages and across iterations, messaged the top-level
194
+ session instead of their dispatcher, which no prompt wording could have fixed.
195
+
196
+ **Why an oracle is owed here and not for the turn-ending rule.** §Operative
197
+ residency closes on the finding that a restated rule is reachable, not obeyed,
198
+ and owes no gate because no check can read a session's choice to end a turn —
199
+ the act leaves no tracked artifact. A dispatch leaves no tracked artifact
200
+ either, so the distinguishing axis is not durability but interception:
201
+
202
+ > Where a rule binds an act that leaves no tracked artifact, the enforcement
203
+ > question is whether the act passes a **chokepoint** — not whether it reaches
204
+ > the tree. A dispatch does. A turn-end does not.
205
+
206
+ **The chokepoint — what a `PreToolUse` hook can actually read.** The payload
207
+ carries `session_id`, `prompt_id`, `transcript_path`, `cwd`, `permission_mode`,
208
+ `hook_event_name`, `tool_name`, `tool_input`, and `tool_use_id`; and, **only
209
+ when the hook fires inside a subagent**, `agent_id` and `agent_type`. For the
210
+ dispatch tool, `tool_input` carries the dispatch's own parameters —
211
+ `subagent_type`, `isolation`, `model`, `description`, `prompt`. Three
212
+ consequences carry the guard below: the fork ban has an exact trigger
213
+ (`tool_input.subagent_type`), the read-only claim has an exact trigger
214
+ (`tool_input.isolation`), and depth has an exact, *documented* discriminator —
215
+ `agent_id` is present iff the dispatching session is itself a subagent, so its
216
+ presence means the call about to be made creates a grandchild.
217
+
218
+ **Honest limit on that roster.** It is sourced from the harness's own published
219
+ hook contract, fetched rather than recalled, and from nothing in this tree —
220
+ the same footing as `CLAUDE_CODE_CHILD_SESSION`'s "verified, not trusted"
221
+ treatment (lifecycle-kit/SPEC.md §bin/session-id.sh). A future harness revision
222
+ reshaping the payload is drift this SPEC cannot self-detect; only re-reading the
223
+ hook contract catches it.
224
+
225
+ **Two depth routes ruled out**, both being the obvious move.
226
+ `CLAUDE_CODE_CHILD_SESSION` is set in top-level sessions too, and
227
+ `CLAUDE_CODE_SESSION_ID` carries the *root* id for a child, so a depth-1 and a
228
+ depth-2 dispatcher are indistinguishable by environment alone — that route
229
+ ships a rule silently mis-firing at the top level. The meta record beside a
230
+ transcript does carry an exact spawn depth, and that route works and is
231
+ deliberately not taken: it couples a hook to an *uncontracted* harness artifact
232
+ to answer a question one *contracted* boolean already answers. The
233
+ stage-economics meter accepts that same coupling (drift-kit/SPEC.md §The
234
+ stage-economics meter, the fan-out row) because it needs the whole spawn forest
235
+ and no contracted field supplies it; a hook needs one bit and gets it under
236
+ contract. The axis is what the contract supplies, not appetite for risk.
237
+
238
+ `templates/agent-dispatch-guard.sh` is that oracle — a second `PreToolUse` hook
239
+ on matcher `Agent`, beside the budget guard, composed from
240
+ `guard-kit/lib/guard.sh` primitives. It reads the payload once and runs the
241
+ rules below, in order:
242
+
243
+ | # | rule | trigger | decision |
244
+ | --- | --- | --- | --- |
245
+ | D1 | fork ban | `tool_input.subagent_type` is `fork` | block |
246
+ | D2 | isolation claim | `tool_input.subagent_type` ∈ `DELEGATION_KIT_READONLY_TYPES` and `tool_input.isolation` is not `worktree` | block |
247
+ | D3 | depth advisory | payload carries `agent_id` | advise |
248
+
249
+ Order is load-bearing only between D1/D2 and D3 — a blocked dispatch needs no
250
+ advisory, so D3 runs last. D1 precedes D2 because the fork ban is unconditional
251
+ and its message is the more specific one for a dispatch violating both.
252
+
253
+ **Why a second guard rather than more rules in the budget guard.** Four
254
+ reasons, each independently sufficient: the budget guard blocks on a
255
+ **transient** condition and is deliberately knob-overridable, while these block
256
+ on a **permanent** doctrine violation that must not be per-dispatch
257
+ overridable; the budget guard reads no stdin at all; a consumer may want either
258
+ enforcement without the other, and hook registration is the only opt-in valve
259
+ there is; and their test lanes take different payload grammars. The harness
260
+ fires every hook registered on a matcher and any exit 2 blocks, so the two
261
+ compose with no dispatcher between them.
262
+
263
+ **D1 blocks unconditionally**, which the template's own boundary does not — a
264
+ fork stays correct where the child does the same job at the same authority, and
265
+ a hook cannot read intent. The block is ruled unconditional on the ground that
266
+ no sanctioned fork use exists in this doctrine, and the valve is **unwiring the
267
+ hook**, never a knob: a per-dispatch override is exactly the honour system
268
+ these rules exist to end, and a knob would restore it under a better
269
+ name. The block message names the two lawful alternatives, as guard-kit
270
+ requires of every block message.
271
+
272
+ **D2 is inert until configured**, by construction — the default roster is empty
273
+ and the kit ships no agent-type names. An inert D2 reports nothing; it is a
274
+ hook, not a gate, so there is no clean line to print. Stated here so a consumer
275
+ does not infer coverage it has not configured.
276
+
277
+ **D3 advises rather than blocks**, and both halves are deliberate. It cannot
278
+ block: a nested dispatch is legitimate and common — a stage session's own
279
+ read-only fan-out *is* a grandchild dispatch — so blocking would remove a
280
+ capability rather than confine one. It must not be silent: this is the one rule
281
+ whose bound reader provably never loads the protocol template (§One template, a
282
+ resident pointer), so the advisory is the *only* delivery of it, which is
283
+ §Operative residency's (a)–(c) shape applied at a hook instead of a doc. Ruled
284
+ out for D3: keying on whether the prompt text "names a path" — that fires on
285
+ the word and teaches dispatchers to game the wording, buying a green hook and
286
+ no channel. The `agent_id` trigger is exact and unforgeable; the message
287
+ carries the judgment the trigger cannot.
288
+
289
+ **Degradation — fail-open, but loud**, the posture guard-kit/SPEC.md §The guard
290
+ framework names for a deny-guard whose matcher proves the tool but whose rule
291
+ turns on a payload field:
292
+
293
+ | what is missing | behavior |
294
+ | --- | --- |
295
+ | `jq` absent | allow; one advisory naming the unenforced rules |
296
+ | payload unparseable, or `tool_input` absent | allow; same advisory |
297
+ | `subagent_type` absent from a parseable payload | D1 and D2 do not fire (nothing to match); D3 unaffected |
298
+ | `DELEGATION_KIT_READONLY_TYPES` unset or empty | D2 inert, and silently so; D1 and D3 unaffected |
299
+ | `DELEGATION_KIT_CONFIG_FILE` set but naming no file | allow; advisory naming D2 unenforced |
300
+ | `guard-kit/lib/guard.sh` not vendored | the guard exits 0 before sourcing, as both shipped guards already do |
301
+
302
+ Two implementation facts those rows force, recorded because the obvious build
303
+ gets each of them wrong:
304
+
305
+ - **The `jq`-absent arm cannot deliver through `guard_advise`.** That primitive
306
+ is itself jq-backed, and measuring it rather than assuming settles what
307
+ happens: with `jq` off `PATH` it writes an empty stdout and leaves a shell
308
+ "command not found" on stderr, which names none of the unenforced rules — the
309
+ silent success these rules exist to end, arriving inside the mechanism meant
310
+ to prevent it. The guard therefore emits the advisory envelope itself on that
311
+ arm, and every advisory literal it carries is kept free of the characters
312
+ JSON must escape, since that fallback carries no escaper.
313
+ - **The guard does not source delegation-kit's validating config loader**, only
314
+ the consumer config file, for the one array it reads. The loader exits 2 on
315
+ any malformed knob and a hook that exits 2 blocks, so routing the fork ban
316
+ through a validator for `DELEGATION_KIT_FAN_WIDTH` would let an unrelated
317
+ typo wedge every dispatch in the consumer whose primary token lever is
318
+ delegation — the fail-closed posture this guard is specified against,
319
+ arriving through the config door. The distinction the last two table rows
320
+ draw is this kit's standing one: a roster **configured to nothing** is
321
+ silent, a roster that **could not be read** is loud.
322
+
185
323
  ### One template, a resident pointer
186
324
 
187
325
  `templates/agent-execution.md` is the single source for the protocol — a
@@ -217,11 +355,112 @@ The consumer's CLAUDE.md carries no digest of the bullets, only a resident
217
355
  pointer: the pre-authorization sentence (consumer judgment on what delegation
218
356
  needs no ask) and `/agent-execution`. Rationale: a rule is resident only when it
219
357
  has no load trigger (the load-trigger-residency doctrine), and every protocol
220
- bullet triggers at `Agent` dispatch — which already has a mechanical seam, the
358
+ bullet triggers at `Agent` dispatch **for the role that dispatches** — which
359
+ already has a mechanical seam, the
221
360
  per-dispatch budget guard, whose block message names `/agent-execution`. The
222
- doctrine lives behind the trigger, not in the always-loaded file. Honest limit:
223
- the guard enforces budget mechanically, not protocol literacy — a session that
224
- dispatches without invoking the skill carries only the resident pointer.
361
+ doctrine lives behind the trigger, not in the always-loaded file. Honest limit,
362
+ tightened now that a second hook rides the same matcher: the guards enforce
363
+ mechanically exactly the rules that pass a chokepoint — the budget check, and
364
+ the dispatch-shape rules (§The delegation model) — and protocol literacy
365
+ beyond those stays unenforced. A session that dispatches without invoking the
366
+ skill still carries only the resident pointer for everything else.
367
+
368
+ **That role qualifier is load-bearing rather than hedging.** Stated without it,
369
+ the rationale is role-blind: a *dispatched* role fires no such trigger — it is
370
+ not dispatching at all, it is executing a stage, and no stage skill or stage
371
+ template loads this protocol — so for that reader the pointer posture leaves the
372
+ rule unreached, which is how a posture nobody disputes produced three incidents.
373
+ §Operative residency governs that case, and the bounded imperative it sanctions
374
+ in a consumer's always-loaded agent definition is this same doctrine applied at a
375
+ different reader, not an exception carved out of this paragraph.
376
+
377
+ ### Operative residency
378
+
379
+ A rule may be **restated as an imperative in a surface that does not own it**
380
+ when all three of these hold:
381
+
382
+ - **(a) Unreachable trigger.** The actor the rule binds never fires a trigger
383
+ that loads the rule's owning doc. This is a property of the *reader*, settled
384
+ by asking which triggers that reader actually fires.
385
+ - **(b) Imperative only.** What is restated is the instruction. The reasoning,
386
+ the failure analysis, and the mechanism stay with the owner.
387
+ - **(c) Adjacent citation.** The restatement names the owning surface beside
388
+ itself, so the owner stays the single place the rule is explained and changed.
389
+
390
+ Each condition has a reader at a transition rather than being self-evident: (a)
391
+ and (b) are read by whoever authors a restatement, at authoring, and again by a
392
+ reviewer or an authoring stage assessing an existing one; (c) is the pointer any
393
+ later reader — and any content-tiering check — follows back to the owner. The
394
+ reader the sanction exists for is the third and never inspects a condition at
395
+ all: the bound actor, which receives the imperative at the tier it always loads,
396
+ which is the whole point.
397
+
398
+ **The anti-licence clause is part of the rule, not commentary.** The sanction is
399
+ keyed on (a): a rule that the bound actor's own skill or template already loads
400
+ fails (a) and stays a pointer. Without that clause this reads as "duplicate when
401
+ it feels important", which is the failure content-tiering exists to prevent and
402
+ would cost more than the gap it closes.
403
+
404
+ **This is load-trigger residency's own logic, not an exception to it.** That
405
+ doctrine earns a rule a place in an always-loaded file only when no stage, skill,
406
+ or tool-call trigger exists to load it, and the decisive question is *exists for
407
+ whom*. A trigger that exists but that the bound actor never fires is, for that
408
+ actor, no trigger. The doctrine's stated justification — a rule a stage or a tool
409
+ call would load anyway costs nothing to defer and everything to keep resident —
410
+ does not merely fail for such an actor, it inverts: nothing loads it anyway, so
411
+ deferring costs everything.
412
+
413
+ **Content-tiering is satisfied by bounding what is copied, which is what (b) is
414
+ for.** The restatement is still a restatement, which is why it needs this
415
+ sanction rather than an argument; but its drift surface is one instruction rather
416
+ than a slab, and the place the rule is explained and changed stays single.
417
+
418
+ The attested subjects are the template's **Background + notification, never
419
+ poll** rule and its **Findings you will act on are durable before you act on
420
+ them** rule, both of which bind a dispatched session. Three such sessions read a
421
+ *descriptive* pointer to them at the always-loaded tier and derived no constraint
422
+ from it. The derivations were easy, which is what makes the failure instructive:
423
+ under load a descriptive sentence reads as background about one's situation
424
+ rather than as a constraint on the next action. The defect this rule names is
425
+ therefore pointer-versus-operative-statement, never absence.
426
+
427
+ **Operative is not obeyed, and a fourth firing is the attestation.** A dispatched
428
+ session ended its turn on work still running while the waiting rule sat in that
429
+ session's own agent definition as a bare imperative, restated under (a)–(c) —
430
+ the compliant form this sanction licenses. So the diagnosis above names a cause
431
+ *removed*, not the defect *closed*: residency makes a rule reachable at the point
432
+ of use, and reachable is not obeyed. Every restatement this sanction licenses is
433
+ a request delivered where it is read. Weigh it as one — worth its small drift
434
+ surface for the failure mode it does remove, and never a substitute for an
435
+ oracle where one is buildable. In the attested instance what caught the
436
+ consequence was the artifact-side oracle below, with the prose already in its
437
+ strengthened form.
438
+
439
+ **No gate is owed, and not for budget.** No check can read a session's choice to
440
+ end a turn — the act leaves no tracked artifact. The anti-restatement gates were
441
+ checked against a sanctioned restatement rather than assumed inert, since a
442
+ sanction that required weakening a gate would be the wrong sanction:
443
+ `check-shim-restatement` scans binding shims under the skills directory against a
444
+ corpus of the consumer's always-loaded file plus kit templates, so a consumer's
445
+ agent definition is neither its scanned surface nor its corpus, and
446
+ `check-surface-duplication`'s predicate is a glossary term's definition on a
447
+ canonical SPEC surface, which reaches no agent definition either. The sanction
448
+ therefore ships with **no gate exemption** — and the honest converse ships with
449
+ it: nothing in the battery would catch a *non*-compliant restatement, so (a)–(c)
450
+ are review-enforced. The nearest buildable oracle detects a *consequence* rather
451
+ than the act — `check-producer-liveness` reads a producer still running at the
452
+ next stage's entry (evidence-kit/SPEC.md §check-producer-liveness).
453
+
454
+ **A case where an oracle *was* buildable now sits beside this one, and the two
455
+ are not each other's contradiction.** The dispatch-shape rules bind acts
456
+ that leave no tracked artifact either, yet they are gated. The axis that
457
+ separates them is **interception, not durability**: a dispatch passes a
458
+ chokepoint the harness fires a hook on, and a turn-end passes none (§The
459
+ delegation model, which owns the generalization). So "no tracked artifact" is
460
+ why neither rule gets a *gate* over the tree, and it is not by itself a reason
461
+ to stop looking for an oracle. Recorded here for the same reason §The
462
+ delegation model records the durability rule beside the read-only-fan-out
463
+ caveat: otherwise the next reader re-litigates one of the two paragraphs.
225
464
 
226
465
  ## Resume journal — agent writes, scratch reset sweeps
227
466
 
@@ -244,7 +483,7 @@ break when the supervisor deletes on its own schedule instead, and both appear
244
483
  only once a dispatched agent is **resumable** rather than one-shot: a resumed
245
484
  agent is still writing to the file, and a supervisor treating the journal as
246
485
  its **pull channel** (lifecycle-kit/templates/lead.md §Channel design)
247
- destroys at the first validated commit the channel it is supposed to keep
486
+ destroys at the first verified commit the channel it is supposed to keep
248
487
  reading. A one-shot sweep hides both, which is why an eager deletion chore
249
488
  read as correct for as long as it did.
250
489
 
@@ -266,7 +505,7 @@ file's last line**, since a session resumed past its own marker appends after
266
505
  it, and a mid-file `DONE` claims a completion the later content contradicts.
267
506
  Whether a *missing* marker signals interruption still turns on whether the
268
507
  supervisor consumed the agent's return. On the ordinary completion path it
269
- did, and that return plus its post-commit verification (§Validate after every
508
+ did, and that return plus its post-commit verification (§Verify after every
270
509
  agent commit) *is* the recovery contract, so the marker is redundant there.
271
510
  Only in a **cold read** — a journal found with no return ever consumed, the
272
511
  agent's session having died before returning (a background sandbox died, a
@@ -293,7 +532,25 @@ rule's duty falls on **the parent**, which has already demonstrated it can
293
532
  write, being the session that granted the path. The two are disjoint
294
533
  readings of one contract, not each other's contradiction.
295
534
 
296
- ## Validate after every agent commit
535
+ **Journalling is a discharge path, not a dispatched session's privilege.** The
536
+ template's durability rule turns on **capability, never role** — a session
537
+ journals when it cannot commit and commits when it can — and this section owns
538
+ why the earlier role-keyed reading failed. That reading granted the journal to a
539
+ dispatched session and denied it to a top-level one, on the premise that a
540
+ top-level session is by construction able to commit. The premise is false
541
+ whenever another session holds the shared index, which is the *normal* condition
542
+ while a work unit is in flight rather than an edge case: the supervising role
543
+ improvised scratch notes on three separate occasions in one iteration, each time
544
+ because a live dispatched session held the index. Improvised scratch is the
545
+ journal mechanism with none of its contract — no granted path inside the sweep's
546
+ reach, no inline landing, no marker — so the failure was silent and the
547
+ reconstruction cost was paid per occurrence. Widening by capability rather than
548
+ carving out a second surface per role is what keeps the reclaim story unchanged:
549
+ every discharge path still lands in the same scratch directory the consumer's
550
+ own work-unit boundary already sweeps, so no new lifetime, keep-list entry, or
551
+ inbound-triage surface is created by the widening.
552
+
553
+ ## Verify after every agent commit
297
554
 
298
555
  Re-run the relevant gates plus the consumer's validate battery (for this
299
556
  repo and any gate-sdk consumer: `bash gate-sdk/bin/run-gates.sh` and the
@@ -304,8 +561,49 @@ agent commit before accepting**: an agent blocked by a gate will weaken it
304
561
  (a false exemption) rather than fix the code — "the gate is in my way"
305
562
  almost always means the code doesn't fit the convention.
306
563
 
307
- `check-gate-tamper` is the mechanical floor under that duty. Two
308
- assertions, blocking the two attested tamper shapes:
564
+ **The act is `verify`; the artifact stays the `validate battery`.** The
565
+ discipline is an act a supervisor performs; the battery is the command set
566
+ that act runs. One word for both made *completing the act* read as completing
567
+ whatever else the consumer names with that word — attested where a consumer's
568
+ stage roster carries it, and the near-miss was a skipped stage. Renaming the
569
+ act rather than the artifact is the cheap side: the battery is a binding-slot
570
+ name every consumer's shim carries (§One template, a resident pointer, read by
571
+ `check-skill-binding`), while the act is named only in prose. The result reads
572
+ coherently — *you verify an agent's commit by re-running the relevant gates and
573
+ the consumer's validate battery* — and the act and the artifact having
574
+ different names is the distinction that was missing.
575
+
576
+ **A verify step never runs the producer of what it is verifying.** Re-running
577
+ is safe and idempotent exactly when the dispatched unit's output is *work* and
578
+ the check's output is *a verdict about that work*; it stops being safe the
579
+ moment those coincide. Where a unit's deliverable **is** an evidence artifact,
580
+ the verify is a **read of the committed artifact**, never a re-execution of
581
+ what wrote it: re-running the producer mutates or duplicates the very record
582
+ the check exists to confirm.
583
+
584
+ **The two wrong re-runs are not equally harmful, and a supervisor needs the
585
+ split.** A check that writes nothing the artifact depends on is *inert* on it —
586
+ misrouted and wasted work, with nothing lost. Re-running the artifact's **sole
587
+ writer** is *destructive*. The routing defect is the same in both; only the
588
+ second leaves evidence to restore, and the supervisor that has already run the
589
+ wrong one reads this split to learn which one it is holding. Collapsing them
590
+ would either overstate the harm of a wasteful re-run or understate the harm of
591
+ the destructive one.
592
+
593
+ **Honest limit — this rule installs no oracle**, and recurrence is what
594
+ establishes it matters rather than a projection: the misrouting fired in two
595
+ consecutive iterations and an operator caught it both times. The check class
596
+ that would catch it is a gate over a *supervisor's choice of command*, and no
597
+ scanner is buildable — the choice leaves no tracked artifact to read, the same
598
+ structural reason §Operative residency owes no gate. A consumer whose evidence
599
+ producer claims a liveness lock has a partial artifact-side proxy; its coverage
600
+ boundary is that consumer's own mechanism to state, not this section's. So
601
+ detection stays human, and it is stated here rather than left implicit because
602
+ an unstated limit reads as an oversight for a later session to close with a
603
+ gate that cannot exist.
604
+
605
+ `check-gate-tamper` is the mechanical floor under the diff-every-gate-change
606
+ duty. Two assertions, blocking the two attested tamper shapes:
309
607
 
310
608
  - **A — gate-edit isolation.** A commit that touches a gate file (the
311
609
  `DELEGATION_KIT_GATE_FILES` globs) may touch only meta-layer paths
@@ -680,9 +978,12 @@ delegation-kit/
680
978
  bin/usage-trend.sh # footprint trend reporter over the history log
681
979
  bin/run-usage-tests.sh # verdict decision-table runner
682
980
  bin/run-budget-guard-tests.sh # budget-guard decision-table runner
981
+ bin/run-dispatch-guard-tests.sh # dispatch-guard decision-table runner (D1/D2/D3)
683
982
  bin/run-trend-tests.sh # trend-reporter assertion runner
983
+ lib/delegation.sh # shared helpers for the usage tools and the kit's gates
684
984
  usage-tests/cases.tsv # expected-verdict <TAB> scenario knobs
685
985
  usage-tests/budget-guard-cases.tsv # expected-action <TAB> scenario knobs
986
+ usage-tests/dispatch-guard-cases.tsv # expected-outcome <TAB> scenario knobs
686
987
  usage-tests/trend-history.log # fixture history for the trend runner
687
988
  checks/check-gate-tamper.sh
688
989
  checks/check-rule-citation.sh
@@ -693,6 +994,7 @@ delegation-kit/
693
994
  templates/agent-execution.md # full protocol, bound as a skill shim
694
995
  templates/dispatch-checklists.md # deletion/rename/audit pre-flight, reached by a pointer
695
996
  templates/agent-budget-guard.sh # PreToolUse(Agent) budget guard
997
+ templates/agent-dispatch-guard.sh # PreToolUse(Agent) dispatch-shape guard (D1/D2/D3)
696
998
  templates/statusline-usage.sh # push usage.txt producer (statusline hook) + status bar
697
999
  templates/usage-poller.sh # poll usage.txt producer (timer-driven, fail-soft)
698
1000
  templates/delegation-config.sh # knob overrides (arrays live here)
@@ -762,13 +1064,23 @@ layout as defaults):
762
1064
  reports its counted-inert clean line (§check-agent-tier-explicit).
763
1065
  - `DELEGATION_KIT_GATE_FILES` — globs naming gate files for tamper
764
1066
  assertion A; default
765
- `("${GATE_SDK_GATES_DIR:-scripts}/check-*.sh")` plus the gate-sdk lib and
766
- runners. A consumer declaration **replaces** this default outright rather
1067
+ `("${GATE_SDK_GATES_DIR:-scripts}/check-*.sh" "${GATE_SDK_GATES_DIR:-scripts}/check-*.gate")`
1068
+ plus the gate-sdk lib and
1069
+ runners. **Both declaration spellings are on the default**, because a gate's
1070
+ declaration path is `<name>.sh` *or* `<name>.gate`
1071
+ (gate-sdk/SPEC.md §The `# graph:` manifest)
1072
+ and a consumer on the default would otherwise receive a
1073
+ ported gate whose edits escape the isolation rule entirely — the widening the
1074
+ `check-gate-tamper` row of
1075
+ gate-sdk/SPEC.md §Meta-gate conservation for the binary substrate
1076
+ mandates, come due at the first live descriptor.
1077
+ A consumer declaration **replaces** this default outright rather
767
1078
  than extending it — the loader guards it with `declare -p … ||`, so the
768
1079
  default is the no-declaration fallback, not a base to append to. A consumer
769
1080
  adding kit-shipped globs must therefore restate any default glob it still
770
- wants covered (this repo's config names `*/checks/*.sh` **and**
771
- `scripts/check-*.sh`, because it has gates in both places). Contrast
1081
+ wants covered (this repo's config names `*/checks/*.sh` and `*/checks/*.gate`
1082
+ **and** their `scripts/check-*` counterparts, because it has gates in both
1083
+ places). Contrast
772
1084
  `DELEGATION_KIT_META_PATHS` below, whose kit-root union *is* additive — the
773
1085
  two knobs do not behave alike.
774
1086
  - `DELEGATION_KIT_META_PATHS` — prefixes counted as meta-layer for
@@ -782,6 +1094,23 @@ layout as defaults):
782
1094
  filter: a
783
1095
  prefix the consumer declared cannot be lost, and without `gate.sh` the config
784
1096
  is used exactly as written.
1097
+ - `DELEGATION_KIT_READONLY_TYPES` — agent-type names the consumer dispatches for
1098
+ read-only work; D2's only trigger (§The delegation model). Default empty, in
1099
+ which case D2 is inert by construction. Every entry is the consumer's own
1100
+ agent roster, never the kit's (CLAUDE.md §The provenance seam) — the same
1101
+ reasoning that ships `GUARD_KIT_BREADTH_PROBES` with no default probes.
1102
+ Deliberately not knobbed alongside it, each ruled out for a stated reason: a
1103
+ fork-type-name knob and an accepted-isolation-values knob — `fork` and
1104
+ `worktree` are the **harness's** dispatch vocabulary, and a guard template
1105
+ carries its harness's tool vocabulary as literals the same way
1106
+ `wakeup-guard.sh` matches `ScheduleWakeup`/`CronCreate` literally, so
1107
+ knobbing them would imply a portability the mechanism does not have; a
1108
+ warn-only or per-rule opt-out — a doctrine downgradable per session is the
1109
+ honour system these rules exist to end, so the valve stays the whole guard's
1110
+ registration, never a finer one; and accepting `isolation: remote` as
1111
+ satisfying D2 — plausibly correct (a remote agent cannot touch the local
1112
+ index) but unverified from here, and remote availability is gated, so it is
1113
+ excluded with its reason recorded rather than admitted on plausibility.
785
1114
 
786
1115
  `check-gate-tamper` registers in the consumer's `gates.list`
787
1116
  (tier: precommit) — in this repo's too; dogfooding is day-one, and agents
@@ -798,6 +1127,17 @@ its consumer session brief (`scripts/session-context.sh`) additionally prints
798
1127
  the verdict line at SessionStart for planning-time visibility — a consumer-side
799
1128
  edit; the context-kit template stays uncoupled from delegation-kit.
800
1129
 
1130
+ `agent-dispatch-guard.sh` is a second hook on that same matcher, registered the
1131
+ same way and **independently**: the harness fires every hook a matcher carries
1132
+ and any exit 2 blocks, so neither guard knows about the other and a consumer
1133
+ may wire either one alone (§The delegation model owns why they are two scripts
1134
+ rather than one). It resolves `guard-kit/lib/guard.sh` at its vendored path,
1135
+ overridable with `GUARD_KIT_LIB`, and reads the consumer's delegation config for
1136
+ D2's roster and nothing else. Registration is again the whole opt-in: unwired,
1137
+ it is inert — and an unwired dispatch guard is the exact failure shape it
1138
+ exists to catch, so wiring it is not optional dogfooding for a consumer that
1139
+ delegates.
1140
+
801
1141
  **An `OK` verdict is a floor, not a recommendation.** The guard answers one
802
1142
  question — is there headroom in the window *right now* — and blocks only on
803
1143
  `PAUSE`. Everything else a dispatch decision turns on sits outside its reach:
@@ -910,6 +1250,36 @@ its firing (PAUSE) and non-firing (the four advise cases) — the fixture-pair
910
1250
  discipline again — and every case asserts the live verdict text rides the
911
1251
  output so a memory-quoted percentage cannot be the acting source.
912
1252
 
1253
+ `agent-dispatch-guard.sh` takes its own decision-table lane rather than
1254
+ guard-kit's `guard-tests/` (keyed on a command, or a to+message — neither can
1255
+ express a dispatch's parameters, the same reason the budget guard has its own
1256
+ runner) or the budget guard's table (a different payload grammar again):
1257
+ `usage-tests/dispatch-guard-cases.tsv` pairs an expected outcome
1258
+ (`block`/`advise`/`fallthrough`) with `subagent_type isolation nested desc`,
1259
+ and `bin/run-dispatch-guard-tests.sh` drives the *template* with a built Agent
1260
+ hook payload — `tool_input.subagent_type`/`.isolation`, and, for a nested case,
1261
+ the top-level `agent_id`/`agent_type` the harness only sets inside a subagent —
1262
+ classifying block (exit 2) / advise (exit 0, `additionalContext` present) /
1263
+ fallthrough (exit 0, empty stdout). The table fixes one roster for its whole
1264
+ run, `DELEGATION_KIT_READONLY_TYPES=(ro-type)`, supplied through a generated
1265
+ config file and `DELEGATION_KIT_CONFIG_FILE`; a `subagent_type` prefixed
1266
+ `noroster:` runs instead with no config file at all (an empty declare),
1267
+ stripped before it reaches the guard — the row that proves D2 is inert on the
1268
+ roster's *absence*, not merely on this dispatch's type missing from a
1269
+ populated one. Every rule carries a firing and a non-firing case (the
1270
+ fixture-pair discipline, transplanted): D1 — a fork blocks, a typed dispatch
1271
+ under an empty roster does not; D2 — a rostered type without isolation blocks,
1272
+ the same type with `isolation: worktree` does not, an unrostered type under a
1273
+ populated roster does not, and the empty-roster case does not; D3 — a payload
1274
+ carrying `agent_id` advises, one without it falls through. The degradation
1275
+ posture gets its own case rather than being asserted only in prose: an
1276
+ unparseable payload (`subagent_type` `UNPARSEABLE`, sent as invalid JSON on
1277
+ stdin) advises rather than blocks — the assertion that makes delta 6's
1278
+ fail-open-but-loud posture testable, not merely stated, and the one case this
1279
+ lane must not drop for brevity. The runner strips ambient `DELEGATION_KIT_*` at
1280
+ every invocation, the discipline `run-budget-guard-tests.sh` already uses, so a
1281
+ consumer's live roster or config-file pointer cannot leak into the fixture.
1282
+
913
1283
  `smoke/install.sh` copies the templates and `bin/` tools into the scratch
914
1284
  consumer, registers the tamper gate, and drives one crafted snapshot
915
1285
  through `usage-verdict` asserting a verdict — self-verifying install. It opens
@@ -0,0 +1,97 @@
1
+ #!/usr/bin/env bash
2
+ # spec: delegation-kit/SPEC.md §Testing — decision-table runner for the Agent dispatch-shape guard (D1 fork ban, D2 read-only isolation claim, D3 nested-dispatch advisory)
3
+ #
4
+ # usage: run-dispatch-guard-tests.sh [cases.tsv]
5
+ set -uo pipefail
6
+
7
+ KIT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
8
+ GUARD="$KIT/templates/agent-dispatch-guard.sh"
9
+ LIB="$KIT/../guard-kit/lib/guard.sh"
10
+ CASES="${1:-$KIT/usage-tests/dispatch-guard-cases.tsv}"
11
+
12
+ for f in "$GUARD" "$LIB" "$CASES"; do
13
+ [[ -f "$f" ]] || { echo "run-dispatch-guard-tests: missing $f" >&2; exit 2; }
14
+ done
15
+ command -v jq >/dev/null 2>&1 || { echo "run-dispatch-guard-tests: jq not found on PATH" >&2; exit 2; }
16
+
17
+ # spec: delegation-kit/SPEC.md §Testing — strip ambient DELEGATION_KIT_* at every guard invocation, the discipline run-budget-guard-tests.sh already uses, so a consumer's live roster or config-file pointer cannot leak into the fixture
18
+ DK_UNSET=()
19
+ while IFS= read -r name; do DK_UNSET+=(-u "$name"); done < <(env | grep -o '^DELEGATION_KIT_[A-Za-z0-9_]*')
20
+
21
+ SANDBOX="$(mktemp -d)"
22
+ trap 'rm -rf "$SANDBOX"' EXIT
23
+ ROSTER_CFG="$SANDBOX/roster-config.sh"
24
+ ERR="$SANDBOX/err"
25
+ printf '%s\n' 'DELEGATION_KIT_READONLY_TYPES=(ro-type)' > "$ROSTER_CFG"
26
+
27
+ classify() {
28
+ local rc="$1" out="$2"
29
+ if [[ "$rc" -eq 2 ]]; then echo block; return; fi
30
+ if [[ "$rc" -ne 0 ]]; then echo "exit$rc"; return; fi
31
+ if grep -q '"additionalContext"' <<<"$out"; then echo advise; return; fi
32
+ if [[ -z "$out" ]]; then echo fallthrough; return; fi
33
+ echo unknown
34
+ }
35
+
36
+ # spec: delegation-kit/SPEC.md §Testing — builds a real hook payload (tool_input plus, for a nested case, the top-level agent_id/agent_type the harness only sets inside a subagent), so the guard's own jq extraction is exercised rather than a hand-rolled shortcut
37
+ build_payload() {
38
+ local type="$1" isolation="$2" nested="$3" nb='false'
39
+ [[ "$nested" == yes ]] && nb='true'
40
+ jq -nc --arg t "$type" --arg iso "$isolation" --argjson nested "$nb" '
41
+ {tool_name: "Agent",
42
+ tool_input: (
43
+ (if $t != "" then {subagent_type: $t} else {} end)
44
+ + (if $iso != "" then {isolation: $iso} else {} end)
45
+ )}
46
+ + (if $nested then {agent_id: "agent_child", agent_type: "stage-session"} else {} end)
47
+ '
48
+ }
49
+
50
+ fails=0
51
+ ran=0
52
+
53
+ while IFS=$'\t' read -r want rawtype isolation nested desc; do
54
+ [[ -z "${want// }" ]] && continue
55
+ [[ "$want" == \#* ]] && continue
56
+
57
+ type="$rawtype"
58
+ cfg_file="$ROSTER_CFG"
59
+ case "$rawtype" in
60
+ noroster:*) type="${rawtype#noroster:}"; cfg_file="" ;;
61
+ esac
62
+
63
+ iso="$isolation"; [[ "$iso" == "-" ]] && iso=""
64
+ nst="$nested"; [[ "$nst" != "yes" ]] && nst="no"
65
+
66
+ if [[ "$rawtype" == "UNPARSEABLE" ]]; then
67
+ payload='this is not { json'
68
+ else
69
+ payload="$(build_payload "$type" "$iso" "$nst")"
70
+ fi
71
+
72
+ envargs=(GUARD_KIT_LIB="$LIB")
73
+ [[ -n "$cfg_file" ]] && envargs+=(DELEGATION_KIT_CONFIG_FILE="$cfg_file")
74
+
75
+ out="$( cd "$SANDBOX" && printf '%s' "$payload" \
76
+ | env "${DK_UNSET[@]}" "${envargs[@]}" bash "$GUARD" 2>"$ERR" )"
77
+ rc=$?
78
+ err="$(cat "$ERR" 2>/dev/null)"
79
+ got="$(classify "$rc" "$out")"
80
+ ran=$((ran + 1))
81
+
82
+ if [[ "$got" != "$want" ]]; then
83
+ echo " FAIL [$desc]: want '$want', got '$got' (rc=$rc) -- out=$out err=$err"
84
+ fails=$((fails + 1))
85
+ fi
86
+ done < "$CASES"
87
+
88
+ if [[ "$ran" -eq 0 ]]; then
89
+ echo "run-dispatch-guard-tests: no cases parsed from $CASES" >&2
90
+ exit 2
91
+ fi
92
+ if [[ "$fails" -gt 0 ]]; then
93
+ echo "run-dispatch-guard-tests: $fails/$ran case(s) failed"
94
+ exit 1
95
+ fi
96
+ echo "run-dispatch-guard-tests: ok ($ran cases across D1/D2/D3 and the degradation posture)"
97
+ exit 0
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env bash
2
2
  # graph: couples=kit:*.sh dir=one valve=none tier=precommit
3
- # spec: delegation-kit/SPEC.md §Validate after every agent commit — a gate-weakening commit is blocked by shape (A gate edits stay meta-isolated; B a new path-exemption can't excuse a co-staged file)
3
+ # spec: delegation-kit/SPEC.md §Verify after every agent commit — a gate-weakening commit is blocked by shape (A gate edits stay meta-isolated; B a new path-exemption can't excuse a co-staged file)
4
4
  #
5
5
  # --fixture <dir> injects staged-files / added-exemptions lists; live mode reads git diff --cached.
6
6
  set -uo pipefail
@@ -31,6 +31,7 @@ unset _dk_cfg
31
31
 
32
32
  declare -p DELEGATION_KIT_GATE_FILES &>/dev/null || DELEGATION_KIT_GATE_FILES=(
33
33
  "${GATE_SDK_GATES_DIR:-scripts}/check-*.sh"
34
+ "${GATE_SDK_GATES_DIR:-scripts}/check-*.gate"
34
35
  "${GATE_SDK_GATES_DIR:-scripts}/lib/gate.sh"
35
36
  "${GATE_SDK_GATES_DIR:-scripts}/run-gate-tests.sh"
36
37
  )
@@ -15,6 +15,7 @@ cat >> scripts/gates.list <<'EOF'
15
15
  # delegation-kit
16
16
  check-gate-tamper
17
17
  check-agent-tier-explicit
18
+ check-rule-citation
18
19
  EOF
19
20
 
20
21
  snap="$(mktemp)"
@@ -59,4 +60,4 @@ cmp -s "$pp/usage.before" "$pp/usage.txt" || {
59
60
  rm -rf "$pp"
60
61
 
61
62
  bash "$SDK/bin/gen-pre-commit.sh" --write >/dev/null
62
- bash "$SDK/checks/check-graph.sh" --emit > .workflow/CHECK-GRAPH.html
63
+ bash "$SDK/checks/check-graph.sh" --emit > scripts/CHECK-GRAPH.html