checkwright 0.20.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 (250) 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 +281 -26
  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-md-refs.sh +22 -9
  16. package/payload/canon-kit/checks/check-payload-claim.sh +133 -0
  17. package/payload/canon-kit/checks/check-prose-enum.sh +1 -1
  18. package/payload/canon-kit/checks/check-spec-pointer.sh +15 -4
  19. package/payload/canon-kit/gate-tests/check-comment-tier/good/good.sh +3 -0
  20. package/payload/canon-kit/gate-tests/check-comment-tier.test.sh +26 -3
  21. package/payload/canon-kit/gate-tests/check-docs-link-convention/bad/OUTSIDE.md +4 -0
  22. package/payload/canon-kit/gate-tests/check-docs-link-convention/bad/docs/index.md +3 -0
  23. package/payload/canon-kit/gate-tests/check-docs-link-convention/good/OUTSIDE.md +4 -0
  24. package/payload/canon-kit/gate-tests/check-docs-link-convention/good/docs/methodology.md +8 -0
  25. package/payload/canon-kit/gate-tests/check-docs-link-convention.test.sh +94 -0
  26. package/payload/canon-kit/gate-tests/check-manifest-count.test.sh +5 -3
  27. package/payload/canon-kit/gate-tests/check-payload-claim/bad/README.md +15 -0
  28. package/payload/canon-kit/gate-tests/check-payload-claim/bad/expect.txt +2 -0
  29. package/payload/canon-kit/gate-tests/check-payload-claim/bad/install.md +19 -0
  30. package/payload/canon-kit/gate-tests/check-payload-claim/bad/posts/note.md +6 -0
  31. package/payload/canon-kit/gate-tests/check-payload-claim/bad/scripts/canon-config.sh +8 -0
  32. package/payload/canon-kit/gate-tests/check-payload-claim/bad/scripts/payload-claims.sh +7 -0
  33. package/payload/canon-kit/gate-tests/check-payload-claim/good/README.md +15 -0
  34. package/payload/canon-kit/gate-tests/check-payload-claim/good/expect.txt +2 -0
  35. package/payload/canon-kit/gate-tests/check-payload-claim/good/install.md +20 -0
  36. package/payload/canon-kit/gate-tests/check-payload-claim/good/posts/note.md +6 -0
  37. package/payload/canon-kit/gate-tests/check-payload-claim/good/scripts/canon-config.sh +8 -0
  38. package/payload/canon-kit/gate-tests/check-payload-claim/good/scripts/payload-claims.sh +7 -0
  39. package/payload/canon-kit/gate-tests/check-prose-enum.test.sh +24 -1
  40. package/payload/canon-kit/gate-tests/check-spec-pointer/bad/expect.txt +1 -0
  41. package/payload/canon-kit/gate-tests/check-spec-pointer/bad/widget.sh +1 -0
  42. package/payload/canon-kit/gate-tests/check-spec-pointer/good/widget.sh +1 -0
  43. package/payload/canon-kit/lib/spec.sh +22 -12
  44. package/payload/canon-kit/smoke/install.sh +20 -1
  45. package/payload/canon-kit/templates/SPEC-amendment.md +5 -1
  46. package/payload/context-kit/SPEC.md +38 -7
  47. package/payload/context-kit/lib/toolfloor.sh +1 -1
  48. package/payload/context-kit/smoke/install.sh +3 -1
  49. package/payload/delegation-kit/README.md +2 -1
  50. package/payload/delegation-kit/SPEC.md +590 -48
  51. package/payload/delegation-kit/bin/run-dispatch-guard-tests.sh +97 -0
  52. package/payload/delegation-kit/checks/check-agent-tier-explicit.sh +61 -0
  53. package/payload/delegation-kit/checks/check-gate-tamper.sh +1 -1
  54. package/payload/delegation-kit/gate-tests/check-agent-tier-explicit/bad/agents/silent.md +7 -0
  55. package/payload/delegation-kit/gate-tests/check-agent-tier-explicit/bad/args +1 -0
  56. package/payload/delegation-kit/gate-tests/check-agent-tier-explicit/bad/expect.txt +1 -0
  57. package/payload/delegation-kit/gate-tests/check-agent-tier-explicit/good/agents/explicit-cheap.md +7 -0
  58. package/payload/delegation-kit/gate-tests/check-agent-tier-explicit/good/agents/explicit-inherit.md +8 -0
  59. package/payload/delegation-kit/gate-tests/check-agent-tier-explicit/good/args +1 -0
  60. package/payload/delegation-kit/gate-tests/check-agent-tier-explicit/good/expect.txt +1 -0
  61. package/payload/delegation-kit/lib/delegation.sh +3 -0
  62. package/payload/delegation-kit/smoke/install.sh +3 -1
  63. package/payload/delegation-kit/templates/agent-dispatch-guard.sh +61 -0
  64. package/payload/delegation-kit/templates/agent-execution.md +171 -15
  65. package/payload/delegation-kit/templates/delegation-config.sh +4 -0
  66. package/payload/delegation-kit/templates/dispatch-checklists.md +1 -1
  67. package/payload/delegation-kit/usage-tests/dispatch-guard-cases.tsv +30 -0
  68. package/payload/doctrine-kit/DOCTRINE.md +27 -0
  69. package/payload/doctrine-kit/README.md +5 -0
  70. package/payload/doctrine-kit/SPEC.md +62 -3
  71. package/payload/doctrine-kit/bin/install-doctrine.sh +84 -4
  72. package/payload/doctrine-kit/smoke/install.sh +77 -1
  73. package/payload/drift-kit/README.md +3 -2
  74. package/payload/drift-kit/SPEC.md +253 -20
  75. package/payload/drift-kit/bin/stage-economics.sh +157 -3
  76. package/payload/drift-kit/kpis/kpi-incident-recurrence.sh +42 -0
  77. package/payload/drift-kit/smoke/install.sh +155 -1
  78. package/payload/drift-kit/templates/economics.md +9 -0
  79. package/payload/drift-kit/templates/kpis.list +6 -1
  80. package/payload/evidence-kit/README.md +20 -6
  81. package/payload/evidence-kit/SPEC.md +355 -17
  82. package/payload/evidence-kit/bin/run-validate.sh +51 -9
  83. package/payload/evidence-kit/checks/check-battery-roster.sh +86 -0
  84. package/payload/evidence-kit/checks/check-producer-liveness.sh +34 -0
  85. package/payload/evidence-kit/gate-tests/check-battery-roster/bad/args +1 -0
  86. package/payload/evidence-kit/gate-tests/check-battery-roster/bad/expect.txt +1 -0
  87. package/payload/evidence-kit/gate-tests/check-battery-roster/bad/runner.md +14 -0
  88. package/payload/evidence-kit/gate-tests/check-battery-roster/bad/scripts/evidence-config.sh +7 -0
  89. package/payload/evidence-kit/gate-tests/check-battery-roster/good/args +1 -0
  90. package/payload/evidence-kit/gate-tests/check-battery-roster/good/expect.txt +1 -0
  91. package/payload/evidence-kit/gate-tests/check-battery-roster/good/runner.md +14 -0
  92. package/payload/evidence-kit/gate-tests/check-battery-roster/good/scripts/evidence-config.sh +7 -0
  93. package/payload/evidence-kit/gate-tests/check-battery-roster.test.sh +68 -0
  94. package/payload/evidence-kit/gate-tests/check-producer-liveness/bad/args +1 -0
  95. package/payload/evidence-kit/gate-tests/check-producer-liveness/bad/expect.txt +1 -0
  96. package/payload/evidence-kit/gate-tests/check-producer-liveness/bad/run-validate.lock +1 -0
  97. package/payload/evidence-kit/gate-tests/check-producer-liveness/good/args +1 -0
  98. package/payload/evidence-kit/gate-tests/check-producer-liveness/good/expect.txt +2 -0
  99. package/payload/evidence-kit/gate-tests/check-producer-liveness/good/run-validate.lock +1 -0
  100. package/payload/evidence-kit/gate-tests/producer-lock.test.sh +109 -0
  101. package/payload/evidence-kit/lib/evidence.sh +18 -0
  102. package/payload/evidence-kit/smoke/install.sh +17 -3
  103. package/payload/gate-sdk/README.md +4 -1
  104. package/payload/gate-sdk/SPEC.md +1955 -79
  105. package/payload/gate-sdk/bin/gen-pre-commit.sh +13 -3
  106. package/payload/gate-sdk/bin/run-consumer-smoke.sh +121 -1
  107. package/payload/gate-sdk/bin/run-gate-tests.sh +40 -9
  108. package/payload/gate-sdk/bin/run-gates.sh +32 -3
  109. package/payload/gate-sdk/bin/upgrade-smoke.sh +3 -3
  110. package/payload/gate-sdk/checks/check-action-gh-repo.gate +2 -0
  111. package/payload/gate-sdk/checks/check-action-pinning.gate +2 -0
  112. package/payload/gate-sdk/checks/check-action-run-shell.sh +3 -1
  113. package/payload/gate-sdk/checks/check-core-files.sh +27 -4
  114. package/payload/gate-sdk/checks/check-exec-bit.sh +20 -1
  115. package/payload/gate-sdk/checks/check-gate-binary-fresh.sh +106 -0
  116. package/payload/gate-sdk/checks/check-gate-exemption-tasks.sh +6 -7
  117. package/payload/gate-sdk/checks/check-gate-output.sh +9 -1
  118. package/payload/gate-sdk/checks/check-gate-substrate-parity.sh +302 -0
  119. package/payload/gate-sdk/checks/check-graph.sh +7 -8
  120. package/payload/gate-sdk/checks/check-readme-roster.sh +5 -0
  121. package/payload/gate-sdk/checks/check-reads-couples.sh +73 -22
  122. package/payload/gate-sdk/checks/check-template-registry-parity.sh +81 -0
  123. package/payload/gate-sdk/checks/check-tree-terms.sh +11 -7
  124. package/payload/gate-sdk/gate-tests/check-action-run-shell.test.sh +16 -1
  125. package/payload/gate-sdk/gate-tests/check-core-files.test.sh +64 -0
  126. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/bad/args +2 -0
  127. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/bad/expect.txt +5 -0
  128. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/bad/kitroot/checks/check-vendored.gate +2 -0
  129. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/bad/scripts/check-ported.gate +2 -0
  130. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/bad/scripts/gate-sdk-config.sh +2 -0
  131. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/bad/scripts/gates.list +4 -0
  132. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/bad/stamp.txt +1 -0
  133. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/bad/stub-bin +6 -0
  134. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/good/args +2 -0
  135. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/good/expect.txt +5 -0
  136. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/good/kitroot/checks/check-vendored.gate +2 -0
  137. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/good/scripts/check-ported.gate +2 -0
  138. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/good/scripts/gate-sdk-config.sh +2 -0
  139. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/good/scripts/gates.list +4 -0
  140. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/good/stamp.txt +1 -0
  141. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh/good/stub-bin +5 -0
  142. package/payload/gate-sdk/gate-tests/check-gate-binary-fresh.test.sh +81 -0
  143. package/payload/gate-sdk/gate-tests/check-gate-exemption-tasks/bad/TASK-QUEUE.md +3 -1
  144. package/payload/gate-sdk/gate-tests/check-gate-exemption-tasks/bad/expect.txt +3 -1
  145. package/payload/gate-sdk/gate-tests/check-gate-exemption-tasks/bad/gates/check-sample.sh +3 -1
  146. package/payload/gate-sdk/gate-tests/check-gate-exemption-tasks/good/expect.txt +1 -0
  147. package/payload/gate-sdk/gate-tests/check-gate-output/bad/check-sample.sh +1 -0
  148. package/payload/gate-sdk/gate-tests/check-gate-output/good/check-sample.sh +1 -0
  149. package/payload/gate-sdk/gate-tests/check-gate-output/good/expect.txt +1 -0
  150. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/args +2 -0
  151. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/conservation.md +7 -0
  152. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/expect.txt +12 -0
  153. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/impl/gate.rs +2 -0
  154. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/kitroot/check-orphan.rs +3 -0
  155. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/publish.yml +15 -0
  156. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/scripts/check-alpha.sh +3 -0
  157. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/scripts/check-dup.gate +1 -0
  158. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/scripts/check-dup.sh +3 -0
  159. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/scripts/check-orphan.gate +1 -0
  160. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/scripts/gate-sdk-config.sh +6 -0
  161. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/scripts/gates.list +3 -0
  162. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/stub-bin +3 -0
  163. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/bad/targets.list +3 -0
  164. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/args +2 -0
  165. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/conservation.md +8 -0
  166. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/expect.txt +7 -0
  167. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/impl/gate.rs +2 -0
  168. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/kitroot/check-other.rs +3 -0
  169. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/publish.yml +15 -0
  170. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/scripts/check-alpha.sh +3 -0
  171. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/scripts/check-ported.gate +2 -0
  172. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/scripts/gate-sdk-config.sh +6 -0
  173. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/scripts/gates.list +2 -0
  174. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/stub-bin +3 -0
  175. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity/good/targets.list +2 -0
  176. package/payload/gate-sdk/gate-tests/check-gate-substrate-parity.test.sh +123 -0
  177. package/payload/gate-sdk/gate-tests/check-reads-couples.test.sh +139 -0
  178. package/payload/gate-sdk/gate-tests/check-template-registry-parity/bad/alpha-kit/templates/widgets.list +4 -0
  179. package/payload/gate-sdk/gate-tests/check-template-registry-parity/bad/alpha-kit/widgets/widget-one.sh +3 -0
  180. package/payload/gate-sdk/gate-tests/check-template-registry-parity/bad/alpha-kit/widgets/widget-two.sh +3 -0
  181. package/payload/gate-sdk/gate-tests/check-template-registry-parity/bad/args +4 -0
  182. package/payload/gate-sdk/gate-tests/check-template-registry-parity/bad/expect.txt +1 -0
  183. package/payload/gate-sdk/gate-tests/check-template-registry-parity/bad/scripts/gate-sdk-config.sh +5 -0
  184. package/payload/gate-sdk/gate-tests/check-template-registry-parity/good/alpha-kit/templates/widgets.list +4 -0
  185. package/payload/gate-sdk/gate-tests/check-template-registry-parity/good/alpha-kit/widgets/widget-one.sh +3 -0
  186. package/payload/gate-sdk/gate-tests/check-template-registry-parity/good/alpha-kit/widgets/widget-two.sh +3 -0
  187. package/payload/gate-sdk/gate-tests/check-template-registry-parity/good/args +8 -0
  188. package/payload/gate-sdk/gate-tests/check-template-registry-parity/good/beta-kit/templates/rules.list +5 -0
  189. package/payload/gate-sdk/gate-tests/check-template-registry-parity/good/beta-kit/templates/table.tsv +4 -0
  190. package/payload/gate-sdk/gate-tests/check-template-registry-parity/good/expect.txt +1 -0
  191. package/payload/gate-sdk/gate-tests/check-template-registry-parity/good/scripts/gate-sdk-config.sh +5 -0
  192. package/payload/gate-sdk/gate-tests/lib-declaration.test.sh +4 -4
  193. package/payload/gate-sdk/gate-tests/lib-gate.test.sh +41 -1
  194. package/payload/gate-sdk/gate-tests/run-gate-tests.test.sh +144 -0
  195. package/payload/gate-sdk/lib/consumer-smoke.sh +26 -1
  196. package/payload/gate-sdk/lib/gate.sh +104 -13
  197. package/payload/gate-sdk/lib/inject.sh +21 -1
  198. package/payload/gate-sdk/smoke/install.sh +19 -1
  199. package/payload/guard-kit/README.md +4 -3
  200. package/payload/guard-kit/SPEC.md +88 -10
  201. package/payload/guard-kit/bin/compare-settings-allow.sh +40 -7
  202. package/payload/guard-kit/gate-tests/compare-settings-allow.test.sh +64 -0
  203. package/payload/guard-kit/lib/guard.sh +1 -0
  204. package/payload/guard-kit/templates/close-triage.md +35 -7
  205. package/payload/guard-kit/templates/guard-config.sh +3 -0
  206. package/payload/lifecycle-kit/README.md +1 -0
  207. package/payload/lifecycle-kit/SPEC.md +589 -33
  208. package/payload/lifecycle-kit/bin/enter-stage.sh +13 -3
  209. package/payload/lifecycle-kit/bin/file-gap.sh +42 -1
  210. package/payload/lifecycle-kit/bin/file-survey.sh +50 -0
  211. package/payload/lifecycle-kit/checks/check-merge-attrs.sh +1 -1
  212. package/payload/lifecycle-kit/checks/check-skill-binding.sh +1 -1
  213. package/payload/lifecycle-kit/checks/check-survey-record.sh +102 -0
  214. package/payload/lifecycle-kit/gate-tests/check-merge-attrs/bad/.gitattributes +1 -0
  215. package/payload/lifecycle-kit/gate-tests/check-merge-attrs/good/.gitattributes +1 -0
  216. package/payload/lifecycle-kit/gate-tests/check-merge-attrs.test.sh +1 -0
  217. package/payload/lifecycle-kit/gate-tests/check-survey-record/bad/args +2 -0
  218. package/payload/lifecycle-kit/gate-tests/check-survey-record/bad/expect.txt +4 -0
  219. package/payload/lifecycle-kit/gate-tests/check-survey-record/bad/record.md +18 -0
  220. package/payload/lifecycle-kit/gate-tests/check-survey-record/good/args +2 -0
  221. package/payload/lifecycle-kit/gate-tests/check-survey-record/good/expect.txt +1 -0
  222. package/payload/lifecycle-kit/gate-tests/check-survey-record/good/record.md +13 -0
  223. package/payload/lifecycle-kit/gate-tests/check-survey-record.test.sh +84 -0
  224. package/payload/lifecycle-kit/gate-tests/file-gap-recurrence.test.sh +94 -0
  225. package/payload/lifecycle-kit/gate-tests/survey-record-entry.test.sh +102 -0
  226. package/payload/lifecycle-kit/lib/stages.sh +8 -2
  227. package/payload/lifecycle-kit/smoke/install.sh +17 -1
  228. package/payload/lifecycle-kit/templates/consult.md +73 -0
  229. package/payload/lifecycle-kit/templates/lead.md +141 -10
  230. package/payload/lifecycle-kit/templates/stages/align.md +12 -0
  231. package/payload/lifecycle-kit/templates/stages/build.md +8 -0
  232. package/payload/lifecycle-kit/templates/stages/close.md +25 -4
  233. package/payload/lifecycle-kit/templates/stages/scope.md +34 -0
  234. package/payload/lifecycle-kit/templates/stages/spec.md +8 -0
  235. package/payload/lifecycle-kit/templates/stages/validate.md +8 -0
  236. package/payload/queue-kit/README.md +4 -1
  237. package/payload/queue-kit/SPEC.md +230 -6
  238. package/payload/queue-kit/bin/queue-edges.sh +78 -0
  239. package/payload/queue-kit/checks/check-queue-entry-budget.sh +5 -3
  240. package/payload/queue-kit/gate-tests/check-queue-hygiene/good/TASK-QUEUE.md +5 -0
  241. package/payload/queue-kit/gate-tests/queue-edges.test.sh +130 -0
  242. package/payload/queue-kit/smoke/install.sh +4 -1
  243. package/payload/queue-kit/templates/TASK-QUEUE.md +3 -0
  244. package/payload/site-kit/SPEC.md +135 -29
  245. package/payload/site-kit/checks/check-docs-render-fidelity.sh +100 -27
  246. package/payload/site-kit/gate-tests/check-docs-render-fidelity-batch.test.sh +158 -0
  247. package/payload/site-kit/lib/site.sh +16 -2
  248. package/payload/site-kit/smoke/install.sh +9 -1
  249. package/payload/gate-sdk/checks/check-action-gh-repo.sh +0 -321
  250. package/payload/gate-sdk/checks/check-action-pinning.sh +0 -55
@@ -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
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env bash
2
+ # graph: couples=.claude/agents/*.md dir=one valve=none tier=precommit
3
+ # spec: delegation-kit/SPEC.md §check-agent-tier-explicit — every agent definition under the scanned directory declares a `model:` field in its frontmatter (an explicit `inherit` passes; only omission reds)
4
+ #
5
+ # usage: check-agent-tier-explicit.sh [agent-dir]
6
+ # defaults DELEGATION_KIT_AGENT_DIR; a fixture passes its own directory.
7
+ set -uo pipefail
8
+
9
+ KIT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
10
+ SDK="${GATE_SDK_ROOT:-$KIT/../gate-sdk}"
11
+ # shellcheck source=../../gate-sdk/lib/gate.sh
12
+ source "$SDK/lib/gate.sh"
13
+ # shellcheck source=../lib/delegation.sh
14
+ source "$KIT/lib/delegation.sh"
15
+
16
+ DIR="${1:-$DELEGATION_KIT_AGENT_DIR}"; DIR="${DIR%/}"
17
+
18
+ if [[ ! -d "$DIR" ]]; then
19
+ echo "AGENT-TIER-EXPLICIT: clean (0 agent definition(s) under $DIR; no agent-definition directory)"
20
+ exit 0
21
+ fi
22
+
23
+ listing="$(find "$DIR" -type f -name '*.md' | LC_ALL=C sort)"; st=$?
24
+ fail_closed "$st" AGENT-TIER-EXPLICIT find
25
+
26
+ files=()
27
+ while IFS= read -r path; do
28
+ [[ -n "$path" ]] || continue
29
+ gate_path_pruned "$path" && continue
30
+ files+=("$path")
31
+ done <<< "$listing"
32
+
33
+ if [[ ${#files[@]} -eq 0 ]]; then
34
+ echo "AGENT-TIER-EXPLICIT: clean (0 agent definition(s) under $DIR; nothing to check)"
35
+ exit 0
36
+ fi
37
+
38
+ bare="$(awk '
39
+ FNR == 1 { if (fname != "" && !seen) print fname; fname = FILENAME; seen = 0; open = 0; shut = 0; ln = 0 }
40
+ { ln++ }
41
+ ln == 1 { if ($0 == "---") open = 1; else shut = 1; next }
42
+ shut || !open { next }
43
+ $0 == "---" { shut = 1; next }
44
+ $0 ~ /^model:[[:space:]]*[^[:space:]]/ { seen = 1 }
45
+ END { if (fname != "" && !seen) print fname }
46
+ ' "${files[@]}")"; st=$?
47
+ fail_closed "$st" AGENT-TIER-EXPLICIT awk
48
+
49
+ if [[ -n "$bare" ]]; then
50
+ echo "check-agent-tier-explicit: agent definition(s) whose frontmatter omits the model: field:"
51
+ while IFS= read -r f; do
52
+ [[ -n "$f" ]] && echo " $f: no 'model:' field in frontmatter"
53
+ done <<< "$bare"
54
+ echo " help: state the tier in the definition's frontmatter — an omitted model: is not a neutral"
55
+ echo " default but the literal 'inherit' (the dispatcher's tier), so declare it even when"
56
+ echo " the answer is to inherit; 'model: inherit' passes."
57
+ exit 1
58
+ fi
59
+
60
+ echo "AGENT-TIER-EXPLICIT: clean (${#files[@]} agent definition(s) under $DIR, each declaring an explicit model:)"
61
+ 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
@@ -0,0 +1,7 @@
1
+ ---
2
+ name: silent
3
+ description: Fixture agent definition whose frontmatter omits the tier entirely.
4
+ ---
5
+
6
+ Fixture body. No `model:` field, so the definition resolves to the literal
7
+ `inherit` without anyone having chosen it — the state the gate reds on.
@@ -0,0 +1 @@
1
+ no 'model:' field in frontmatter
@@ -0,0 +1,7 @@
1
+ ---
2
+ name: explicit-cheap
3
+ description: Fixture agent definition naming a cheaper tier outright.
4
+ model: cheap-tier-placeholder
5
+ ---
6
+
7
+ Fixture body. The frontmatter states the tier, so the gate passes.
@@ -0,0 +1,8 @@
1
+ ---
2
+ name: explicit-inherit
3
+ description: Fixture agent definition choosing to ride its dispatcher's tier, and saying so.
4
+ model: inherit
5
+ ---
6
+
7
+ Fixture body. An explicit `inherit` is a legitimate answer — the gate polices
8
+ omission, not the choice — so this file passes too.
@@ -0,0 +1 @@
1
+ AGENT-TIER-EXPLICIT: clean (2 agent definition(s) under agents
@@ -27,9 +27,11 @@ unset _dk_cfg
27
27
  [[ -v DELEGATION_KIT_REFRESH_MIN_AGE ]] || DELEGATION_KIT_REFRESH_MIN_AGE=60
28
28
  [[ -v DELEGATION_KIT_USAGE_HISTORY ]] || DELEGATION_KIT_USAGE_HISTORY=""
29
29
  [[ -v DELEGATION_KIT_FAN_WIDTH ]] || DELEGATION_KIT_FAN_WIDTH=2
30
+ [[ -v DELEGATION_KIT_AGENT_DIR ]] || DELEGATION_KIT_AGENT_DIR=".claude/agents"
30
31
 
31
32
  declare -p DELEGATION_KIT_GATE_FILES &>/dev/null || DELEGATION_KIT_GATE_FILES=(
32
33
  "${GATE_SDK_GATES_DIR:-scripts}/check-*.sh"
34
+ "${GATE_SDK_GATES_DIR:-scripts}/check-*.gate"
33
35
  "${GATE_SDK_GATES_DIR:-scripts}/lib/gate.sh"
34
36
  "${GATE_SDK_GATES_DIR:-scripts}/run-gate-tests.sh"
35
37
  )
@@ -71,6 +73,7 @@ _dk_errs=()
71
73
  || _dk_errs+=("DELEGATION_KIT_REFRESH_MIN_AGE must be a non-negative integer (got '$DELEGATION_KIT_REFRESH_MIN_AGE')")
72
74
  [[ "$DELEGATION_KIT_FAN_WIDTH" =~ ^[0-9]+$ && "$DELEGATION_KIT_FAN_WIDTH" -gt 0 ]] \
73
75
  || _dk_errs+=("DELEGATION_KIT_FAN_WIDTH must be a positive integer (got '$DELEGATION_KIT_FAN_WIDTH')")
76
+ [[ -n "$DELEGATION_KIT_AGENT_DIR" ]] || _dk_errs+=("DELEGATION_KIT_AGENT_DIR is empty")
74
77
  [[ ${#DELEGATION_KIT_GATE_FILES[@]} -gt 0 ]] || _dk_errs+=("DELEGATION_KIT_GATE_FILES is empty")
75
78
  [[ ${#DELEGATION_KIT_META_PATHS[@]} -gt 0 ]] || _dk_errs+=("DELEGATION_KIT_META_PATHS is empty")
76
79
  if [[ ${#_dk_errs[@]} -gt 0 ]]; then
@@ -14,6 +14,8 @@ export DELEGATION_KIT_PAUSE_PCT_7D=95
14
14
  cat >> scripts/gates.list <<'EOF'
15
15
  # delegation-kit
16
16
  check-gate-tamper
17
+ check-agent-tier-explicit
18
+ check-rule-citation
17
19
  EOF
18
20
 
19
21
  snap="$(mktemp)"
@@ -58,4 +60,4 @@ cmp -s "$pp/usage.before" "$pp/usage.txt" || {
58
60
  rm -rf "$pp"
59
61
 
60
62
  bash "$SDK/bin/gen-pre-commit.sh" --write >/dev/null
61
- bash "$SDK/checks/check-graph.sh" --emit > .workflow/CHECK-GRAPH.html
63
+ bash "$SDK/checks/check-graph.sh" --emit > scripts/CHECK-GRAPH.html
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env bash
2
+ # spec: delegation-kit/SPEC.md §The delegation model — consumer-copy PreToolUse(Agent) dispatch-shape guard: D1 fork ban, D2 read-only isolation claim, D3 nested-dispatch advisory; register under matcher `Agent` beside the budget guard (§Layout and configuration)
3
+ set -uo pipefail
4
+
5
+ # shellcheck disable=SC2034 # consumed by the sourced lib/guard.sh (guard_block/guard_advise)
6
+ GUARD_NAME="agent-dispatch-guard"
7
+ GUARD_KIT_LIB="${GUARD_KIT_LIB:-guard-kit/lib/guard.sh}"
8
+ [[ -f "$GUARD_KIT_LIB" ]] || exit 0
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
+ source "$GUARD_KIT_LIB"
11
+
12
+ # spec: delegation-kit/SPEC.md §The delegation model — D2's roster is the only knob read here, so delegation-kit's validating loader is deliberately not sourced: a malformed *unrelated* knob must not wedge every dispatch
13
+ _adg_cfg="${DELEGATION_KIT_CONFIG_FILE:-${GATE_SDK_GATES_DIR:-scripts}/delegation-config.sh}"
14
+ _adg_roster_unreadable=""
15
+ if [[ -n "${DELEGATION_KIT_CONFIG_FILE:-}" && ! -f "$_adg_cfg" ]]; then
16
+ _adg_roster_unreadable="DELEGATION_KIT_CONFIG_FILE names no readable file"
17
+ elif [[ -f "$_adg_cfg" ]]; then
18
+ # shellcheck source=/dev/null # consumer-supplied config, path is config
19
+ source "$_adg_cfg"
20
+ fi
21
+ declare -p DELEGATION_KIT_READONLY_TYPES >/dev/null 2>&1 || DELEGATION_KIT_READONLY_TYPES=()
22
+
23
+ # spec: delegation-kit/SPEC.md §The delegation model — fail-open-but-loud: keep every advisory literal below free of any character JSON must escape, because the jq-absent arm hand-writes the envelope with no escaper
24
+ _adg_advise() {
25
+ local msg="agent-dispatch-guard: $1"
26
+ command -v jq >/dev/null 2>&1 && guard_advise "$msg"
27
+ printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","additionalContext":"%s"}}\n' "$msg"
28
+ exit 0
29
+ }
30
+
31
+ _adg_degraded() {
32
+ _adg_advise "allowed this dispatch WITHOUT enforcing the fork ban (D1) or the read-only isolation claim (D2) — $1. Check the dispatch by hand: no fork, and a child claimed read-only takes isolation: worktree (delegation-kit/SPEC.md §The delegation model)."
33
+ }
34
+
35
+ input="$(cat 2>/dev/null || true)"
36
+
37
+ command -v jq >/dev/null 2>&1 || _adg_degraded "jq is not on PATH, so the payload could not be read"
38
+
39
+ _adg_fields="$(printf '%s' "$input" | jq -r 'if (.tool_input | type) == "object" then [(.tool_input.subagent_type // ""), (.tool_input.isolation // ""), (if .agent_id then "nested" else "" end)] | @tsv else empty end' 2>/dev/null || true)"
40
+ [[ -n "$_adg_fields" ]] || _adg_degraded "the hook payload did not parse, or carried no tool_input object"
41
+
42
+ # spec: delegation-kit/SPEC.md §The delegation model — split on a non-whitespace separator: bash collapses runs of a *whitespace* IFS, so a tab split would silently shift an absent middle field onto the next name
43
+ IFS=$'\037' read -r _adg_type _adg_isolation _adg_nested <<<"${_adg_fields//$'\t'/$'\037'}"
44
+
45
+ # spec: delegation-kit/SPEC.md §The delegation model — D1 precedes D2 because the fork ban is unconditional and its message is the more specific one for a dispatch violating both
46
+ if [[ "$_adg_type" == "fork" ]]; then
47
+ guard_block "a fork inherits the dispatcher's whole context, toolset and model tier and disclaims nothing, so any narrowing this prompt states exists only as a sentence. Two lawful alternatives: dispatch a TYPED agent whose definition carries the narrower authority, brief and tier, so the narrowing is structural rather than requested; or, where the child does the same job at the same authority and you only want parallelism or its own index, dispatch that typed agent with isolation: worktree. There is no per-dispatch override — a knob here would restore the honour system this rule replaced, so the valve is unregistering the hook. The full protocol is /agent-execution (delegation-kit/SPEC.md §The delegation model)."
48
+ fi
49
+
50
+ if [[ -n "$_adg_type" && "$_adg_isolation" != "worktree" && ${#DELEGATION_KIT_READONLY_TYPES[@]} -gt 0 ]]; then
51
+ for _adg_ro in "${DELEGATION_KIT_READONLY_TYPES[@]}"; do
52
+ [[ "$_adg_type" == "$_adg_ro" ]] && guard_block "'$_adg_type' is declared a read-only dispatch type (DELEGATION_KIT_READONLY_TYPES), but this dispatch's shape grants write reach — a subagent inherits its toolset from its type whatever the prompt says, and a type carrying no Edit or Write still reaches git through its shell. Make the claim with the shape: add isolation: worktree, whose commits and index are the child's own, and which the harness auto-cleans when the child really was read-only. If this type is not in fact dispatched read-only, drop it from the roster rather than working around the rule here (delegation-kit/SPEC.md §The delegation model)."
53
+ done
54
+ fi
55
+
56
+ _adg_notes=""
57
+ [[ -n "$_adg_roster_unreadable" ]] && _adg_notes="D2 (the read-only isolation claim) went unenforced on this dispatch: $_adg_roster_unreadable. "
58
+ [[ "$_adg_nested" == "nested" ]] && _adg_notes="${_adg_notes}you are yourself a dispatched agent, so this call creates a grandchild with no upward channel to you: it cannot message you mid-run, and neither level knows its own address or its parent's. Give it return-value-only work, or grant it a durable path in the main checkout, named absolutely in its prompt, and read that path yourself (delegation-kit/SPEC.md §Operative residency)."
59
+
60
+ [[ -n "$_adg_notes" ]] || exit 0
61
+ _adg_advise "$_adg_notes"
@@ -11,16 +11,43 @@ For a **deletion, rename, or heavy cross-spec audit** dispatch, also load the
11
11
  mechanical pre-flight in [dispatch-checklists.md](dispatch-checklists.md) — a
12
12
  reach-through, not a change to this protocol; every rule below still applies.
13
13
 
14
+ Two bullets below — **Background + notification, never poll** and **Findings you
15
+ will act on are durable before you act on them** — bind a dispatched role that
16
+ fires no trigger loading this template, so each is also stated as a bare
17
+ imperative in the consumer's always-loaded agent definition under
18
+ delegation-kit/SPEC.md §Operative residency. That copy is sanctioned rather than
19
+ drift: do not delete it on sight, and when either rule changes here, propagate.
20
+
14
21
  - **Supervisor owns rulings; agents surface, never guess.** SECURITY and design
15
22
  rulings (e.g. a privileged caller set, a naming collision) are decided by the
16
23
  supervisor and handed down; an agent that hits anything its brief doesn't cover
17
24
  stops and reports rather than choosing.
18
25
  - **Background + notification, never poll.** Always `run_in_background`; wait for
19
26
  the completion notification; do not read the output file. Backgrounding keeps
20
- the main loop free to redirect.
27
+ the main loop free to redirect. Backgrounding survives a **turn**, not a
28
+ **session**. A supervisor's turn ends and its session lives on, so a
29
+ backgrounded dispatch wakes it by notification — that is the sanctioned
30
+ pattern just stated. A **dispatched agent's** turn end *is* its session end,
31
+ and what that reliably kills is the **observer, not the work**: an `Agent`
32
+ child is reaped with its parent, but a shell `run_in_background` child
33
+ survives — orphaned, still writing, with nothing left able to read it. The
34
+ survivor is the worse case, because it keeps mutating shared files while the
35
+ next actor moves against them. Either way the caller gets no result, so a
36
+ dispatched agent **never ends a turn on work still running** — it awaits its
37
+ own long-running work to completion, however long, and reports only results
38
+ it holds. Awaiting, not "dispatch in the foreground": foreground is a choice
39
+ for a shell command and not reliably one for an `Agent` dispatch, which the
40
+ harness may detach whether or not backgrounding was requested. And not by
41
+ ending the turn to wait for the completion notification — that is the one act
42
+ that revokes the channel, which is how a *careful* reader reaches this
43
+ failure. Wait **in-turn on a condition** instead: loop on the work's own
44
+ artifact (evidence file, lock, exit marker) with the harness's waiting
45
+ primitive. Never-poll governs waiting on an `Agent`'s completion notification,
46
+ a channel a supervisor has; condition-waiting is the only one a dispatched
47
+ role has.
21
48
  - **Serialize on shared files; ≤`DELEGATION_KIT_FAN_WIDTH`-wide otherwise.**
22
49
  Agents that edit a shared file (see the roster below) run one at a time —
23
- dispatch, await notification, validate, dispatch the next. Independent
50
+ dispatch, await notification, verify, dispatch the next. Independent
24
51
  read-only units may run ≤`DELEGATION_KIT_FAN_WIDTH`-wide. **The git index and
25
52
  HEAD are shared files for every agent that commits**, independent of
26
53
  source-file disjointness: two committing agents racing `git add`/`git commit`
@@ -29,6 +56,50 @@ reach-through, not a change to this protocol; every rule below still applies.
29
56
  `isolation: worktree` (own index); reserve the unlocked
30
57
  ≤`DELEGATION_KIT_FAN_WIDTH`-wide bound for **read-only** fan-outs. "No lockfile
31
58
  churn" is a false safety signal — the index is shared regardless.
59
+ Serialization is by **completion**, not by notification: the next dispatch
60
+ begins after the previous one has *returned and been verified*. A supervisor
61
+ reaches that point via the completion notification; a **dispatched agent**
62
+ reaches it in-turn, awaiting each child before dispatching the next (it cannot
63
+ end its turn to wait — see the backgrounding rule). The ordering requirement
64
+ is identical for both; only the waiting mechanism differs, and neither role
65
+ may overlap two agents on a shared file or the git index.
66
+ - **Never dispatch a fork to narrow a child.** A fork is wrong exactly when the
67
+ dispatch's purpose is that the child does *less* than the parent: a fork
68
+ inherits the parent's context, toolset and model tier whole and disclaims
69
+ nothing, so every narrowing survives only as a sentence in the prompt. Three
70
+ dispatching contexts, each with its own grounds. A **read-only audit or
71
+ survey** wants narrower *authority* — the fork carries the parent's full
72
+ reach, so the restriction is a request, and one such fork completed a whole
73
+ stage, commits included. A **tier-split oracle** wants narrower *cost* — the
74
+ fork inherits the dispatcher's model, which is exactly the split the posture
75
+ exists to make (a lead posture that dispatches its own oracle is the named
76
+ instance). A **rule-injection dispatch** wants a *different* brief — attested
77
+ where five sibling forks each carried a line explaining that the roster's
78
+ agent definitions do not carry it, so fork was chosen to inject rules the
79
+ types lack and every one still paid to re-materialize its parent's context.
80
+ The boundary, stated honestly: a fork stays correct where the child does the
81
+ **same job at the same authority** and only parallelism or isolation is
82
+ wanted. The dispatch guard blocks there too, because a hook cannot read
83
+ intent and no sanctioned fork use exists in this doctrine — the valve is
84
+ unregistering the hook, never a per-dispatch knob, which would restore the
85
+ honour system the rule replaced (delegation-kit/SPEC.md §The delegation
86
+ model). Grounds measured rather than asserted: in one audited iteration ten
87
+ of twenty-four dispatched agents were forks, carrying 20.90 USD of 158.70 USD
88
+ of priced burn.
89
+ - **A read-only claim is made by isolation, not by sentence.** A dispatch whose
90
+ brief says "read-only, no edits" and whose *shape* grants write reach has made
91
+ no claim at all: a subagent inherits its toolset from its **type**, never from
92
+ the instruction text, and every type available for audit-shaped work carries
93
+ write tools or at least a shell that reaches `git` — so "it has no Edit tool"
94
+ is not the safety property it reads as. The claim is made by
95
+ `isolation: worktree`, whose commits and index are the child's own. Isolation
96
+ serves two purposes and only the first was ever written down here: an **own
97
+ index**, for an agent that *will* commit (the **Serialize on shared files**
98
+ rule above), and **write confinement**, for an agent *claimed* read-only. The
99
+ cost objection does not land — the harness auto-cleans a worktree left
100
+ unchanged, so the worktree survives **iff** the agent was not in fact
101
+ read-only, which makes the isolation simultaneously the confinement and the
102
+ detector.
32
103
  - **One commit per unit, sized to finish within budget.** Each unit gets its own
33
104
  commit (+ a `[blocked-by: prior]` tag where ordered). A unit that investigates
34
105
  long before its first commit is the only thing an interrupt can destroy —
@@ -37,7 +108,7 @@ reach-through, not a change to this protocol; every rule below still applies.
37
108
  - **Gate-driven worklist where one exists.** Drive the sweep from the gate's
38
109
  output, so an interrupt loses only the in-flight uncommitted unit and a fresh
39
110
  session re-runs the gate to resume.
40
- - **Resume journal — agent writes, supervisor deletes.** The agent `Write`s a
111
+ - **Resume journal — agent writes, scratch reset sweeps.** The agent `Write`s a
41
112
  running progress journal (findings triaged, edits applied, what remains) to a
42
113
  repo-local gitignored scratch dir in the main checkout — `.tmp/` here — never a
43
114
  temporary worktree (deleted with the worktree) nor a system temp dir (a restart
@@ -48,25 +119,97 @@ reach-through, not a change to this protocol; every rule below still applies.
48
119
  `DONE` marker. Each finding is
49
120
  written into the journal *inline as it is confirmed* — never "see final
50
121
  output": the agent's return message dies with the session, so a pointer-only
51
- journal makes `DONE` lie about recoverability. **Agents have no `rm`, so the
52
- supervisor deletes the journal at the post-commit validation checkpoint.** A
53
- journal *without* a `DONE` marker signals interruption only in a **cold read**
122
+ journal makes `DONE` lie about recoverability. **Nobody deletes a journal
123
+ while the work it covers is live** — not the agent (no `rm`) and not the
124
+ supervisor, whose deletion would take the file out from under a resumed agent
125
+ and destroy its own pull channel mid-unit. Cleanup is the consumer's scratch
126
+ reset at its next work-unit boundary, not a chore in this protocol. `DONE` is
127
+ the completion marker and counts **only as the file's last line**: a session
128
+ resumed past its own marker appends after it. A journal *without* a `DONE`
129
+ marker signals interruption only in a **cold read**
54
130
  — the supervisor found a journal but never consumed the agent's return (its
55
131
  session died before returning); there, no `DONE` = interrupted, resume from
56
132
  it. On the ordinary path the supervisor consumed the return and ran its
57
133
  post-commit verification, which *is* the completion attest, so the missing
58
- marker is redundant, not a signal of interruption. **Caveat — a background agent's sandbox may block
134
+ marker is redundant, not a signal of interruption. Since every journal now
135
+ outlives its session, presence alone signals nothing — tell a live journal
136
+ from a spent one by its per-session name, the work cursor, and `git log`
137
+ (delegation-kit/SPEC.md §Resume journal — agent writes, scratch reset
138
+ sweeps). **Caveat — a background agent's sandbox may block
59
139
  the journal write.** `run_in_background` agents have been observed unable to
60
140
  `Write` to the granted path and silently falling back to returning findings in
61
141
  their final message — which makes the journal mechanic non-functional exactly
62
142
  when it matters (a long, interruptible run). So: for a **read-only fan-out**
63
143
  (audit, survey), the return value *is* the contract — don't rely on a journal.
64
- Reserve the journal / worktree isolation for agents that **mutate files**, and
65
- for those grant the journal path explicitly before dispatch rather than
66
- assuming the write succeeds.
67
- - **Validate after every agent commit** — a sub-agent's "passed" claim is not
144
+ Reserve the **journal** for agents that **mutate files**, and for those grant
145
+ the journal path explicitly before dispatch rather than assuming the write
146
+ succeeds. **Worktree isolation is not reserved with it** — the two answer
147
+ different questions, and bundling them read as *a read-only fan-out needs no
148
+ isolation*, which is the reading that licensed an unreviewed commit on the
149
+ shared branch. A read-only fan-out takes isolation precisely *because* it is
150
+ claimed read-only (the **A read-only claim is made by isolation, not by
151
+ sentence** rule above). A contract has two ends, though: the child owes
152
+ no journal, and the **parent** owes the durable landing of what it received
153
+ before acting on it (next bullet). The caveat is about a backgrounded child's
154
+ write failing silently, so it never licensed the parent — which has already
155
+ demonstrated it can write, being the session that granted the path.
156
+ - **A child's only upward route is a durable artifact.** Probed, not assumed: a
157
+ child's sends to an invented dispatcher name and to its own agent type both
158
+ failed, only a send addressed to the **top-level session** arrived, and
159
+ neither level knows its own identity or its parent's. There is therefore no
160
+ address a child can use to reach the agent that dispatched it, and four
161
+ dispositions follow. **(1) A durable artifact, for anything mid-run** — the
162
+ dispatcher mints a path, names it **absolute into the main checkout** in the
163
+ prompt, and the child writes as it goes. That is already the journal rule
164
+ above; it is now also the *only* upward route there is, and it is stronger
165
+ than a message would be, because a file survives a child that dies before
166
+ returning. A **stop signal takes the same shape** — a sentinel the child
167
+ checks — so it is cooperative by construction and a wedged child stays out of
168
+ reach. **(2) Return-value only, otherwise** — a fan-out needing no mid-run
169
+ channel needs no artifact, which is the read-only carve-out above. **(3) The
170
+ downward half is a dispatch-shape rule** — a dispatcher that wants control
171
+ over its fan-out dispatches in the background and keeps the handle; what
172
+ actually failed was a dispatcher blocked on a foreground dispatch, holding
173
+ neither the handle nor a turn. **(4) Naming the address a child should use is
174
+ refused** — there is none, and the refusal is stated rather than omitted
175
+ because it is the first thing both original filings reached for. Two
176
+ corollaries defeat the workarounds a reader would otherwise invent: a message
177
+ that does reach the top-level session is attributed to the sender's **type**,
178
+ so a fan-out wider than one is ambiguous at the receiving end; and a child
179
+ resumed by a message from its dispatcher still cannot reply, so being
180
+ addressed creates no return path. One live hazard rides with them: the
181
+ message and stop tools may be **deferred** for a dispatched agent — callable
182
+ only after a discovery call it has to know to make — so a child that needs to
183
+ escalate may not hold the channel at all. Hence the obligation, which is the
184
+ part that binds you: **a dispatcher handing out work that will need a mid-run
185
+ channel grants a durable path with it**, and reads that path itself.
186
+
187
+ - **Findings you will act on are durable before you act on them.** A child's
188
+ return value lives only in your context, and your context dies with your
189
+ session. Before you *act* on a dispatched agent's findings — edit against
190
+ them, rule from them, plan the next wave on them — land them somewhere that
191
+ survives you: a commit, or your own journal. The write is the parent's,
192
+ discharged on receipt, not a chore delegated back to the child. This binds
193
+ whoever holds findings they will act on, at any depth. It costs one write per
194
+ returned child, not a running narration. The obligation is **durability**, and
195
+ committing and journalling are two ways to discharge it — a session uses
196
+ whichever is available to it. A dispatched session journals, to the path it was
197
+ granted, because it cannot commit. A top-level session commits, because it can.
198
+ A top-level session that *cannot* commit right now — another session is holding
199
+ the shared index, the normal condition while an iteration is running — journals
200
+ for as long as that holds, and discharges by committing when the index frees.
201
+ Neither the supervising role nor a session running outside any dispatch is
202
+ exempt: the axis is what the session can do at this moment, never what it is.
203
+ - **Verify after every agent commit** — a sub-agent's "passed" claim is not
68
204
  trustworthy. Re-run the relevant gates (the sweep's own gate) and the consumer
69
- validate battery below. **Diff every gate change in an agent commit before
205
+ validate battery below — the act is `verify`, the artifact is the battery.
206
+ **Never verify a unit by re-running the producer of what it delivered**: where
207
+ the unit's deliverable *is* an evidence artifact, the verify is a **read** of
208
+ the committed artifact, because re-running its sole writer overwrites or
209
+ duplicates the record instead of checking it. Having already run the wrong
210
+ check, read delegation-kit/SPEC.md §Verify after every agent commit for which
211
+ of the two re-runs you are holding — only one of them leaves evidence to
212
+ restore. **Diff every gate change in an agent commit before
70
213
  accepting** — a gate modification inside a feature commit is a supervisor-owned
71
214
  ruling; an agent blocked by a gate will weaken it (a false exemption) to make
72
215
  its commit pass instead of fixing the code. "The gate is in my way" almost
@@ -75,7 +218,7 @@ reach-through, not a change to this protocol; every rule below still applies.
75
218
  two attested shapes (a gate edit co-staged with product code; a new path/glob
76
219
  exemption co-staged with the file it excuses) — but it does **not** catch
77
220
  semantic weakening inside a legitimate scripts-only commit, so the by-eye diff
78
- review remains your duty (delegation-kit/SPEC.md §Validate after every agent
221
+ review remains your duty (delegation-kit/SPEC.md §Verify after every agent
79
222
  commit — the honest limit).
80
223
  - **Budget-check before *each* dispatch in a fan-out**, not once at the start.
81
224
  `bash delegation-kit/bin/usage-verdict.sh` (verdict exit 0/1/2 from `usage.txt` —
@@ -90,6 +233,13 @@ reach-through, not a change to this protocol; every rule below still applies.
90
233
  window-expensive than its
91
234
  subagent-token total suggests, so size waves to leave the next one headroom, or
92
235
  accept one wave per window.
236
+ **The projection reaches downward as well as forward.** The guard re-arms at
237
+ every depth — a dispatched session's own dispatches fire it too — but each
238
+ verdict prices **one call**, never the subtree that call opens. Nothing
239
+ between a dispatch and its children's children ever sees the whole. So budget
240
+ a dispatch you expect to fan out for its **subtree**, not its own turn, and
241
+ read a child's fan-out as your spend even though its verdicts land in a
242
+ context you never see.
93
243
  **Do not read live budget off the statusline while parked on a dispatch.**
94
244
  Observed: the harness statusline does not refresh while the main session waits
95
245
  on a background agent's completion notification, so its displayed budget
@@ -113,8 +263,14 @@ reach-through, not a change to this protocol; every rule below still applies.
113
263
  whose description commits to review work, never one that disclaims it (an
114
264
  excerpt-locator serves pure search, not audit). Selection sits with the
115
265
  dispatching session — its context holds what selection
116
- needs — and a standing choice lands in a tracked agent-type definition, never
117
- per-dispatch habit.
266
+ needs — and it is **affirmative**: an unselected dispatch does not fall back
267
+ to a cheap default, it **inherits the dispatcher's tier**, so declining to
268
+ choose silently buys the most expensive tier in reach — and buys it precisely
269
+ for the read-only fan-outs that are the cheapest work you dispatch. That is
270
+ why a standing choice lands in a tracked agent-type definition rather than
271
+ per-dispatch habit, and why an omitted `model:` field there is not a neutral
272
+ default but the inherit default: the field is stated even when the answer is
273
+ to inherit.
118
274
  - **Never revert substantial completed work on your own design judgment** —
119
275
  especially an expensive delegated sweep. Surface the tension and wait for the
120
276
  explicit go-ahead before discarding it: a self-judged revert forfeits the
@@ -1,2 +1,6 @@
1
1
  # shellcheck shell=bash
2
2
  # spec: delegation-kit/SPEC.md §Layout and configuration — the knob table (every knob, its default, when to set it) and how to install this config; set only what you override
3
+
4
+ # spec: delegation-kit/SPEC.md §Layout and configuration — D2's roster: the consumer's own read-only-dispatched agent-type names; default empty (D2 inert) — never a kit-shipped vocabulary (CLAUDE.md §The provenance seam)
5
+ # shellcheck disable=SC2034 # consumed by templates/agent-dispatch-guard.sh after sourcing
6
+ # DELEGATION_KIT_READONLY_TYPES=()
@@ -1,7 +1,7 @@
1
1
  DISPATCH CHECKLISTS — a reach-through from [agent-execution.md](agent-execution.md),
2
2
  loaded only when a dispatch is a deletion, a rename, or a heavy cross-spec audit.
3
3
  It adds no new protocol: the safety, budget, resume-journal, and
4
- validate-after-commit rules stay in `agent-execution.md` and still apply in full.
4
+ verify-after-commit rules stay in `agent-execution.md` and still apply in full.
5
5
  This file is the mechanical pre-flight for those dispatch shapes — the steps an
6
6
  agent skips by reflex and the supervisor pays for later. Owned by
7
7
  delegation-kit/SPEC.md §One template, a resident pointer.
@@ -0,0 +1,30 @@
1
+ # Agent dispatch-guard decision table — <decision><TAB><subagent_type><TAB><isolation><TAB><nested><TAB><desc>.
2
+ # decision is block (exit 2) / advise (exit 0, additionalContext) / fallthrough
3
+ # (exit 0, no output). Tab-separated; # and blank lines ignored. '-' marks an
4
+ # absent isolation/nested value — never a truly empty field between tabs, since
5
+ # a whitespace IFS collapses runs of empty fields (the exact bug the guard's own
6
+ # jq-to-read split works around; see agent-dispatch-guard.sh).
7
+ #
8
+ # The runner fixes one roster for the whole table: DELEGATION_KIT_READONLY_TYPES=(ro-type).
9
+ # A subagent_type prefixed 'noroster:' runs with no roster config at all (an
10
+ # empty declare), proving D2 stays inert on the roster's absence rather than on
11
+ # this type's absence from a populated one; the prefix is stripped before it
12
+ # reaches the guard's payload. subagent_type UNPARSEABLE sends invalid JSON on
13
+ # stdin instead of a built payload.
14
+
15
+ # D1 — the fork ban is unconditional
16
+ block fork - - a fork dispatch blocks regardless of isolation or roster
17
+ fallthrough noroster:other-type - - a typed, non-fork dispatch is not blocked (no roster configured)
18
+
19
+ # D2 — a declared read-only type without isolation: worktree
20
+ block ro-type - - a rostered type dispatched without isolation: worktree blocks
21
+ fallthrough ro-type worktree - the same rostered type with isolation: worktree does not block
22
+ fallthrough other-type - - a typed dispatch outside a populated roster does not block
23
+ fallthrough noroster:ro-type - - D2 stays inert against an empty roster, even naming the type that would otherwise match
24
+
25
+ # D3 — nested-dispatch advisory (never blocks)
26
+ advise other-type - yes a payload carrying agent_id advises: this dispatch creates a grandchild
27
+ fallthrough other-type - - a payload with no agent_id falls through D3 untouched
28
+
29
+ # Degradation — fail-open, but loud
30
+ advise UNPARSEABLE - - an unparseable payload advises rather than blocks, naming what could not be enforced