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
@@ -0,0 +1,302 @@
1
+ #!/usr/bin/env bash
2
+ # graph: couples=scripts/gates.list,kit:checks/*,gate-sdk/SPEC.md,native/*,.github/workflows/publish.yml dir=one valve=none tier=precommit
3
+ # spec: gate-sdk/SPEC.md §check-gate-substrate-parity — one declaration per member, descriptor/subcommand parity both ways, a recorded disposition for every substrate-sensitive member, no implementation source inside the vendoring set, and one owner for the target roster the artifact path derives from
4
+ #
5
+ # usage: check-gate-substrate-parity.sh [gates-dir] [conservation-doc]
6
+ # two args: steer onto hermetic fixture copies of each surface.
7
+ set -uo pipefail
8
+
9
+ SDK="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
10
+ # shellcheck source=../lib/gate.sh
11
+ source "$SDK/lib/gate.sh"
12
+
13
+ GATES_DIR="${1:-$(gate_sdk_gates_dir)}"
14
+ DOC="${2:-$SDK/SPEC.md}"
15
+ LIST="$GATES_DIR/gates.list"
16
+ SECTION="## Meta-gate conservation for the binary substrate"
17
+
18
+ [[ -f "$LIST" ]] || { echo "check-gate-substrate-parity: no registry at $LIST" >&2; exit 2; }
19
+ [[ -f "$DOC" ]] || { echo "check-gate-substrate-parity: conservation doc not found: $DOC" >&2; exit 2; }
20
+
21
+ mapfile -t MEMBERS < <(gates_list_members "$LIST")
22
+ [[ ${#MEMBERS[@]} -gt 0 ]] || { echo "check-gate-substrate-parity: $LIST names no gates" >&2; exit 2; }
23
+
24
+ RESOLVE_DIRS=("$GATES_DIR")
25
+ while IFS= read -r k; do RESOLVE_DIRS+=("$k/checks"); done < <(gate_kit_roots_rel)
26
+
27
+ # spec: gate-sdk/SPEC.md §Meta-gate conservation for the binary substrate — the one
28
+ # disposition surface, read by assertion B's reference-only allowance and assertion C
29
+ section="$(awk -v s="$SECTION" '
30
+ $0 == s { inb = 1; next }
31
+ inb && /^## / { inb = 0 }
32
+ inb { print }
33
+ ' "$DOC")"; st=$?
34
+ fail_closed "$st" check-gate-substrate-parity awk
35
+ [[ -n "$section" ]] || { echo "check-gate-substrate-parity: no '$SECTION' section in $DOC" >&2; exit 2; }
36
+
37
+ findings=()
38
+
39
+ # spec: gate-sdk/SPEC.md §check-gate-substrate-parity — assertion F's publishing-tree test: the
40
+ # crate's *tracked source* is here, step 1 of §check-gate-binary-fresh's source stamp reused rather
41
+ # than spelled twice — source, so build output under the crate root cannot read as a publisher
42
+ crate_source_here() {
43
+ [[ -d "$1" ]] || return 1
44
+ [[ -n "$(git -C "$1" ls-files 2>/dev/null)" ]]
45
+ }
46
+
47
+ # assertion A: each member resolves to exactly one declaration — a dir carrying
48
+ # both <name>.sh and <name>.gate is ambiguous dispatch, never resolved by order
49
+ declared=0
50
+ # spec: gate-sdk/SPEC.md §check-gate-substrate-parity — a descriptor on disk is a declaration;
51
+ # a registered member resolving to one is a dispatch, and only a dispatch makes the binary
52
+ # load-bearing. Derived here because assertion A already resolves every member.
53
+ dispatching=0
54
+ for m in "${MEMBERS[@]}"; do
55
+ for d in "${RESOLVE_DIRS[@]}"; do
56
+ if [[ -f "$d/$m.sh" && -f "$d/$m.gate" ]]; then
57
+ findings+=("ambiguous dispatch: $d carries both $m.sh and $m.gate")
58
+ fi
59
+ done
60
+ if ! src="$(gate_resolve "$m" "${RESOLVE_DIRS[@]}")"; then
61
+ findings+=("unresolvable member: $m declares in none of: ${RESOLVE_DIRS[*]}")
62
+ continue
63
+ fi
64
+ [[ "$src" == *.gate ]] && dispatching=$((dispatching + 1))
65
+ declared=$((declared + 1))
66
+ done
67
+
68
+ # assertion B: the .gate descriptors on disk and the binary's reported subcommand
69
+ # roster are the same set, with 'reference-only' the one dispositioned exception
70
+ # spec: gate-sdk/SPEC.md §check-gate-substrate-parity
71
+ mapfile -t DESCRIPTORS < <(
72
+ for d in "${RESOLVE_DIRS[@]}"; do
73
+ [[ -d "$d" ]] || continue
74
+ for f in "$d"/*.gate; do
75
+ [[ -f "$f" ]] || continue
76
+ b="${f##*/}"; printf '%s\n' "${b%.gate}"
77
+ done
78
+ done | sort -u
79
+ )
80
+ BIN="$(gate_native_bin)"
81
+ subcommands=()
82
+ refonly=0
83
+ roster_read=0
84
+ # spec: gate-sdk/SPEC.md §check-gate-substrate-parity — the fail-closed arm is on the corrected
85
+ # predicate: descriptors nothing registered dispatches to leave the binary not load-bearing
86
+ if [[ "$dispatching" -gt 0 && ! -x "$BIN" ]]; then
87
+ echo "check-gate-substrate-parity: $BIN is absent or not executable, but $dispatching registered member(s) dispatch to it — the check could not run; treating as failure (not clean)" >&2
88
+ echo " help: build it — cargo build --release --manifest-path native/Cargo.toml" >&2
89
+ exit 2
90
+ fi
91
+ # spec: gate-sdk/SPEC.md §check-gate-substrate-parity — the roster half is gated on a
92
+ # readable binary, never on descriptor count
93
+ if [[ -x "$BIN" ]]; then
94
+ roster_read=1
95
+ listing="$("$BIN" --list)"; st=$?
96
+ fail_closed "$st" check-gate-substrate-parity "$BIN --list"
97
+ mapfile -t subcommands < <(printf '%s\n' "$listing" | grep -v '^$' | sort -u)
98
+ for g in "${DESCRIPTORS[@]+"${DESCRIPTORS[@]}"}"; do
99
+ printf '%s\n' "${subcommands[@]}" | grep -qx -- "$g" \
100
+ || findings+=("descriptor names no subcommand: $g.gate declares a gate the binary does not carry")
101
+ done
102
+ for s in "${subcommands[@]}"; do
103
+ printf '%s\n' "${DESCRIPTORS[@]+"${DESCRIPTORS[@]}"}" | grep -qx -- "$s" && continue
104
+ if grep -F -- "\`$s\`" <<<"$section" | grep -qi -- 'reference-only'; then
105
+ refonly=$((refonly + 1))
106
+ continue
107
+ fi
108
+ findings+=("subcommand nothing declares: the binary carries '$s' with no $s.gate descriptor and no reference-only disposition in $SECTION")
109
+ done
110
+ fi
111
+
112
+ # assertion C: every derived substrate-sensitive member carries a disposition in
113
+ # the conservation section — the anti-vacuity assertion, so a new meta-gate over
114
+ # gate source reds until its disposition is recorded
115
+ mapfile -t DECLPATHS < <(
116
+ for m in "${MEMBERS[@]}"; do gate_resolve "$m" "${RESOLVE_DIRS[@]}" || true; done
117
+ )
118
+ sensitive=0
119
+ for m in "${MEMBERS[@]}"; do
120
+ src="$(gate_resolve "$m" "${RESOLVE_DIRS[@]}")" || continue
121
+ couples="$(gate_manifest_field "$src" couples)"
122
+ [[ -n "$couples" ]] || continue
123
+ gate_expand_couples_var couples "$couples"
124
+ IFS=',' read -ra globs <<<"$couples"
125
+ hit=0
126
+ for g in "${globs[@]}"; do
127
+ for p in "${DECLPATHS[@]}"; do
128
+ # shellcheck disable=SC2053
129
+ if [[ "$p" == $g ]]; then hit=1; break 2; fi
130
+ done
131
+ done
132
+ (( hit )) || continue
133
+ sensitive=$((sensitive + 1))
134
+ grep -qF -- "\`$m\`" <<<"$section" \
135
+ || findings+=("no recorded disposition: $m is substrate-sensitive (its couples= covers a gate declaration path) but $SECTION does not name it")
136
+ done
137
+
138
+ # assertion D: manifest-class annotations live in the declaration only — a second
139
+ # writable copy in the implementation is an SSOT violation that drifts silently,
140
+ # and the manifest must stay readable with no build and no execution
141
+ IMPL_DIR="${GATE_SDK_NATIVE_SRC:-native/src}"
142
+ impl_scanned=0
143
+ if [[ -d "$IMPL_DIR" ]]; then
144
+ while IFS= read -r f; do
145
+ [[ -n "$f" ]] || continue
146
+ impl_scanned=$((impl_scanned + 1))
147
+ while IFS= read -r hit; do
148
+ [[ -n "$hit" ]] || continue
149
+ findings+=("manifest-class annotation in implementation source: $f:${hit%%:*} — the '# graph:' manifest belongs to the declaration path alone")
150
+ done < <(grep -nE '^[[:space:]]*(#|//|/\*)[[:space:]]*graph:[[:space:]]' "$f" || true)
151
+ done < <(gate_find "$IMPL_DIR" -type f)
152
+ fi
153
+
154
+ # assertion E: opacity is held by structure — a ported gate's implementation source
155
+ # may not reach the vendoring set, whose members are exactly the kit roots
156
+ # spec: gate-sdk/SPEC.md §Consumer payload
157
+ CRATE="$(gate_native_crate)"
158
+ declare -A DESCRIPTOR_SET=()
159
+ for g in "${DESCRIPTORS[@]+"${DESCRIPTORS[@]}"}"; do DESCRIPTOR_SET["$g"]=1; done
160
+ kit_scanned=0
161
+ while IFS= read -r root; do
162
+ root="${root%/}"
163
+ if [[ "$CRATE" == "$root" || "$CRATE" == "$root"/* ]]; then
164
+ findings+=("crate root inside the vendoring set: $CRATE sits under kit root $root — a kit root vendors whole, so the implementation source would ship with it")
165
+ fi
166
+ [[ ${#DESCRIPTOR_SET[@]} -gt 0 && -d "$root" ]] || continue
167
+ kit_scanned=$((kit_scanned + 1))
168
+ while IFS= read -r f; do
169
+ [[ -n "$f" ]] || continue
170
+ base="${f##*/}"
171
+ stem="${base%.*}"
172
+ # spec: gate-sdk/SPEC.md §check-gate-substrate-parity — an extensionless name is out of reach by contract, and .gate/.sh are owned by the descriptor itself and by assertion A
173
+ [[ "$stem" == "$base" ]] && continue
174
+ ext="${base##*.}"
175
+ [[ "$ext" == gate || "$ext" == sh ]] && continue
176
+ if [[ -n "${DESCRIPTOR_SET[$stem]:-}" ]]; then
177
+ findings+=("implementation sibling in the vendoring set: $f shares its name with the $stem.gate descriptor — a ported gate's implementation may not sit under a kit root")
178
+ fi
179
+ done < <(gate_find "$root" -type f)
180
+ done < <(gate_kit_roots_rel)
181
+
182
+ # assertion F: the target roster has one owner and the publish path derives from it
183
+ # — the roster is what asserts platform support, so a second spelling of it (a
184
+ # platform literal in the build matrix) or a second producer of a published digest
185
+ # is the failure this assertion exists to make impossible
186
+ # spec: gate-sdk/SPEC.md §Consumer payload
187
+ ROSTER="$(gate_native_targets_file)"
188
+ roster_targets=0
189
+ roster_state="absent"
190
+ if [[ -f "$ROSTER" ]]; then
191
+ roster_state="read"
192
+ mapfile -t TARGETS < <(gates_list_members "$ROSTER")
193
+ if [[ ${#TARGETS[@]} -eq 0 ]]; then
194
+ findings+=("empty target roster: $ROSTER declares no target — a roster asserting no platform support cannot be the surface that asserts it")
195
+ fi
196
+ for t in "${TARGETS[@]}"; do
197
+ roster_targets=$((roster_targets + 1))
198
+ [[ "$t" =~ ^[A-Za-z0-9_]+(-[A-Za-z0-9_.]+){2,3}$ ]] \
199
+ || findings+=("malformed target triple: '$t' in $ROSTER is not <arch>-<vendor>-<os>[-<env>]")
200
+ done
201
+ elif [[ "$dispatching" -gt 0 ]] && crate_source_here "$CRATE"; then
202
+ # spec: gate-sdk/SPEC.md §check-gate-substrate-parity — assertion F rides the corrected
203
+ # predicate *and* the publishing-tree test: declaring platform support is the act of the tree
204
+ # that builds and publishes the artifact, and a consumer receives kit roots but never the crate
205
+ findings+=("no target roster: $ROSTER is absent, but $dispatching registered member(s) dispatch to the binary and $CRATE carries tracked source here — a tree that builds the artifact declares the platforms it carries one for")
206
+ fi
207
+
208
+ WORKFLOW="${GATE_SDK_NATIVE_PUBLISH_WORKFLOW:-.github/workflows/publish.yml}"
209
+ wf_state="absent"
210
+ wf_matrix=0
211
+ wf_jobs=0
212
+ if [[ -f "$WORKFLOW" ]]; then
213
+ wf_state="read"
214
+ # spec: gate-sdk/SPEC.md §check-gate-substrate-parity — assertion F, roster-derived matrix: every value in a matrix declaration is a GitHub expression, never a literal
215
+ matrix_lits="$(awk '
216
+ function ind(s, n) { n = match(s, /[^ ]/); return (n == 0) ? -1 : n - 1 }
217
+ inb {
218
+ if ($0 ~ /^[[:space:]]*$/) next
219
+ if (ind($0) > keycol) {
220
+ if ($0 !~ /^[[:space:]]*#/ && index($0, "${{") == 0)
221
+ printf "%d\t%s\n", FNR, $0
222
+ next
223
+ }
224
+ inb = 0
225
+ }
226
+ /^[[:space:]]*matrix:[[:space:]]*$/ { inb = 1; keycol = ind($0); n++; next }
227
+ /^[[:space:]]*matrix:[[:space:]]*[^[:space:]]/ {
228
+ n++
229
+ if (index($0, "${{") == 0) printf "%d\t%s\n", FNR, $0
230
+ }
231
+ END { printf "#\t%d\n", n }
232
+ ' "$WORKFLOW")"; st=$?
233
+ fail_closed "$st" check-gate-substrate-parity "awk matrix($WORKFLOW)"
234
+ while IFS=$'\t' read -r ln text; do
235
+ [[ -n "$ln" ]] || continue
236
+ if [[ "$ln" == "#" ]]; then wf_matrix="$text"; continue; fi
237
+ text="${text#"${text%%[![:space:]]*}"}"
238
+ findings+=("matrix declaration not roster-derived: $WORKFLOW:$ln '$text' is a literal where an expression over $ROSTER belongs — a hand-written platform in a build matrix is a second spelling of the support commitment")
239
+ done <<<"$matrix_lits"
240
+
241
+ # spec: gate-sdk/SPEC.md §check-gate-substrate-parity — assertion F, one producer per digest: a job computes at most one, and a job that downloads a run artifact and uploads none computes none
242
+ digests="$(awk '
243
+ function emit() { if (job != "") printf "%s\t%d\t%d\t%d\n", job, d, dl, ul }
244
+ /^jobs:[[:space:]]*$/ { injobs = 1; next }
245
+ injobs && /^[^[:space:]#]/ { emit(); job = ""; injobs = 0 }
246
+ injobs && /^ [A-Za-z0-9_-]+:[[:space:]]*$/ {
247
+ emit()
248
+ job = $0; sub(/^ +/, "", job); sub(/:.*$/, "", job)
249
+ d = 0; dl = 0; ul = 0
250
+ next
251
+ }
252
+ job != "" {
253
+ if ($0 !~ /^[[:space:]]*#/ && $0 ~ /sha256sum/ && $0 !~ /sha256sum[[:space:]]+-c/) d++
254
+ if ($0 ~ /uses:[[:space:]]*[^[:space:]]*download-artifact/) dl = 1
255
+ if ($0 ~ /uses:[[:space:]]*[^[:space:]]*upload-artifact/) ul = 1
256
+ }
257
+ END { emit() }
258
+ ' "$WORKFLOW")"; st=$?
259
+ fail_closed "$st" check-gate-substrate-parity "awk digests($WORKFLOW)"
260
+ while IFS=$'\t' read -r job d dl ul; do
261
+ [[ -n "$job" ]] || continue
262
+ wf_jobs=$((wf_jobs + 1))
263
+ if [[ "$d" -gt 1 ]]; then
264
+ findings+=("digest recomputed: job '$job' in $WORKFLOW computes $d digests — each is emitted once, where its bytes are produced, and moved thereafter")
265
+ elif [[ "$d" -gt 0 && "$dl" == 1 && "$ul" == 0 ]]; then
266
+ findings+=("digest computed by a consumer: job '$job' in $WORKFLOW downloads a run artifact, produces none, and still computes a digest — it must move the sidecar it received, never re-derive it")
267
+ fi
268
+ done <<<"$digests"
269
+ fi
270
+
271
+ if [[ ${#findings[@]} -gt 0 ]]; then
272
+ echo "check-gate-substrate-parity: the gate substrate seam is not conserved:"
273
+ printf ' %s\n' "${findings[@]}"
274
+ echo " help: one declaration per member — delete the stale .sh or .gate where a dir"
275
+ echo " carries both. Keep the descriptor set and the binary's --list roster equal:"
276
+ echo " add the missing .gate, or drop the subcommand nothing declares — or,"
277
+ echo " for an implementation deliberately kept ahead of any live port, give it"
278
+ echo " a 'reference-only' disposition naming it in $SECTION."
279
+ echo " A substrate-sensitive member with no disposition is recorded in"
280
+ echo " $DOC $SECTION — say ported, retained, or retired with cause;"
281
+ echo " an unrecorded one silently stops asserting when a gate ports."
282
+ echo " help: delete a manifest-class annotation from implementation source — the"
283
+ echo " '# graph:' manifest has exactly one writable home, the declaration"
284
+ echo " path, so that every reader of it works with no build and no execution."
285
+ echo " help: move a ported gate's implementation out of every kit root, and keep the"
286
+ echo " crate root outside them too — a kit root vendors whole, so anything"
287
+ echo " under one ships, and the payload withholds the predicate by structure."
288
+ echo " help: the target roster is the one surface asserting platform support — keep"
289
+ echo " every live line a well-formed target triple, derive the publish"
290
+ echo " workflow's matrix from it rather than spelling a platform there, and"
291
+ echo " emit each artifact's digest in exactly one step, where its bytes are"
292
+ echo " produced. A runner mapping may name a platform; a matrix may not."
293
+ exit 1
294
+ fi
295
+
296
+ if [[ "$roster_read" == 1 ]]; then
297
+ roster="${#DESCRIPTORS[@]} descriptor(s) in parity with the ${#subcommands[@]}-subcommand roster, $refonly reference-only"
298
+ else
299
+ roster="${#DESCRIPTORS[@]} descriptor(s), no binary at $BIN so no subcommand roster to compare"
300
+ fi
301
+ echo "GATE-SUBSTRATE-PARITY: clean ($declared member(s) with one declaration each, $dispatching of them dispatching to the binary; $roster; $sensitive substrate-sensitive member(s) all dispositioned; $impl_scanned implementation source(s) free of manifest-class annotation; $kit_scanned kit root(s) scanned for an implementation sibling, crate root $CRATE outside every kit root; target roster $roster_state at $ROSTER with $roster_targets well-formed target(s); publish workflow $wf_state at $WORKFLOW, $wf_matrix matrix declaration(s) roster-derived across $wf_jobs job(s) with one producer per digest)"
302
+ exit 0
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env bash
2
- # graph: couples=scripts/gates.list,scripts/*.sh,kit:*.sh,scripts/git-hooks/pre-commit,.workflow/CHECK-GRAPH.html,docs/check-graph.html,SPEC-*.md,*/SPEC-*.md dir=one valve=none tier=precommit
2
+ # graph: couples=scripts/gates.list,scripts/*.sh,kit:*.sh,scripts/git-hooks/pre-commit,scripts/CHECK-GRAPH.html,docs/check-graph.html,SPEC-*.md,*/SPEC-*.md dir=one valve=none tier=precommit
3
3
  # spec: gate-sdk/SPEC.md §check-graph — manifest well-formedness, trigger parity, cycle valves, artifact drift, and amendment-body manifest validation (assertion G)
4
4
  set -uo pipefail
5
5
 
@@ -9,7 +9,6 @@ source "$SDK/lib/gate.sh"
9
9
 
10
10
  GATES_DIR="$(gate_sdk_gates_dir)"
11
11
  LIST="$GATES_DIR/gates.list"
12
- WORKFLOW_DIR="${GATE_SDK_WORKFLOW_DIR:-.workflow}"
13
12
  HOOK="${GATE_SDK_HOOKS_DIR:-$GATES_DIR/git-hooks}/pre-commit"
14
13
  GEN="$SDK/bin/gen-pre-commit.sh"
15
14
 
@@ -95,7 +94,7 @@ resolve_member() {
95
94
 
96
95
  emit_graph() {
97
96
  local checks
98
- local resolved_artifact="${GATE_SDK_GRAPH_ARTIFACT:-$WORKFLOW_DIR/CHECK-GRAPH.html}"
97
+ local resolved_artifact="${GATE_SDK_GRAPH_ARTIFACT:-$GATES_DIR/CHECK-GRAPH.html}"
99
98
  mapfile -t checks < <(gates_list_members "$LIST" | sort -u)
100
99
  declare -A C_COUPLES C_DIR C_VALVE NODE_SEEN
101
100
  local c src man kv couples dir valve s
@@ -586,9 +585,9 @@ if [[ "$has_msg_gate" -eq 1 ]]; then
586
585
  fi
587
586
 
588
587
  # assertion E: the coupling-graph artifact matches --emit; its path is the
589
- # GATE_SDK_GRAPH_ARTIFACT knob (workflow-dir default), so a consumer that
588
+ # GATE_SDK_GRAPH_ARTIFACT knob (gates-dir default), so a consumer that
590
589
  # republishes the artifact elsewhere gets its own path in every remedy line
591
- ARTIFACT="${GATE_SDK_GRAPH_ARTIFACT:-$WORKFLOW_DIR/CHECK-GRAPH.html}"
590
+ ARTIFACT="${GATE_SDK_GRAPH_ARTIFACT:-$GATES_DIR/CHECK-GRAPH.html}"
592
591
  ARTIFACT_DIR="$(dirname "$ARTIFACT")"
593
592
  emitted="$(emit_graph)"
594
593
  if [[ ! -f "$ARTIFACT" ]]; then
@@ -37,12 +37,17 @@ for r in "${KIT_ROOTS[@]}"; do
37
37
  [[ -d "$abs/checks" ]] || { skipped=$((skipped + 1)); continue; }
38
38
  swept=$((swept + 1))
39
39
 
40
+ # spec: gate-sdk/SPEC.md §check-readme-roster — both declaration spellings
40
41
  shipped=""
41
42
  shopt -s nullglob
42
43
  for f in "$abs/checks/"*.sh; do
43
44
  bn="${f##*/}"
44
45
  shipped+="${bn%.sh}"$'\n'
45
46
  done
47
+ for f in "$abs/checks/"*.gate; do
48
+ bn="${f##*/}"
49
+ shipped+="${bn%.gate}"$'\n'
50
+ done
46
51
  shopt -u nullglob
47
52
 
48
53
  readme="$abs/README.md"
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env bash
2
- # graph: couples=kit:checks/*.sh,scripts/*.sh,scripts/gates.list dir=one valve=none tier=precommit trigger=*
2
+ # graph: couples=kit:checks/*.sh,scripts/*.sh,scripts/gates.list,native/src/*.rs,native/src/gates/*.rs dir=one valve=none tier=precommit trigger=*
3
3
  # spec: gate-sdk/SPEC.md §check-reads-couples — every statically resolvable recursive walk in a registered gate has its tracked read set covered by the gate's expanded couples; the undecidable remainder is skipped-and-counted
4
4
  set -uo pipefail
5
5
 
@@ -83,6 +83,34 @@ path_matches_glob() {
83
83
  return 0
84
84
  }
85
85
 
86
+ # spec: gate-sdk/SPEC.md §check-reads-couples — the per-root coverage assertion, shared by
87
+ # both substrates: a root the shell parse resolved and a root the binary reported land here
88
+ # identically, so porting a gate changes where the root came from and nothing else.
89
+ cover_root() {
90
+ local root="$1" prune="$2" namepat="$3" gname="$4" where="$5"
91
+ local listing gst f covered g
92
+ if [[ "$root" == "." ]]; then
93
+ listing="$(git ls-files)"; gst=$?
94
+ else
95
+ listing="$(git ls-files -- "$root")"; gst=$?
96
+ fi
97
+ [[ "$gst" -eq 0 ]] || { echo "check-reads-couples: git ls-files failed for root '$root'" >&2; exit 2; }
98
+ while IFS= read -r f; do
99
+ [[ -n "$f" ]] || continue
100
+ [[ "$prune" == 1 ]] && gate_path_pruned "$f" && continue
101
+ if [[ -n "$namepat" ]]; then
102
+ # shellcheck disable=SC2053 # namepat is the glob, deliberately unquoted
103
+ [[ "${f##*/}" == $namepat ]] || continue
104
+ fi
105
+ covered=0
106
+ for g in "${COUPLE_GLOBS[@]}"; do
107
+ path_matches_glob "$f" "$g" && { covered=1; break; }
108
+ done
109
+ [[ "$covered" == 1 ]] || \
110
+ findings+=("$gname: $where reads tracked '$f' — no couple covers it (couples: $couples)")
111
+ done <<<"$listing"
112
+ }
113
+
86
114
  sources=()
87
115
  if [[ $# -gt 0 ]]; then
88
116
  sources=("$@")
@@ -102,10 +130,49 @@ findings=()
102
130
 
103
131
  for src in "${sources[@]+"${sources[@]}"}"; do
104
132
  [[ -f "$src" ]] || continue
133
+ gname="$(basename "$src")"; gname="${gname%.sh}"; gname="${gname%.gate}"
105
134
  couples=""
106
135
  couples_field="$(gate_manifest_field "$src" couples)"
107
136
  gate_expand_couples_var couples "$couples_field"
108
137
  IFS=',' read -ra COUPLE_GLOBS <<<"$couples"
138
+
139
+ # spec: gate-sdk/SPEC.md §check-reads-couples — a .gate member's walks are unreadable to
140
+ # this shell parser, so the substrate reports them instead: `--reads` answers what the
141
+ # binary walks and the coverage assertion below is unchanged.
142
+ if [[ "$src" == *.gate ]]; then
143
+ bin="${GATE_SDK_NATIVE_BIN:-native/target/release/checkwright-gates}"
144
+ if [[ ! -x "$bin" ]]; then
145
+ echo "check-reads-couples: $src dispatches to the native binary, but $bin is absent" >&2
146
+ echo "or not executable — the declared read set cannot be read, so the coverage" >&2
147
+ echo "assertion could not run; treating as failure (not clean)." >&2
148
+ echo " help: build it (cargo build --release --manifest-path native/Cargo.toml), or" >&2
149
+ echo " install the prebuilt artifact, then re-run." >&2
150
+ exit 2
151
+ fi
152
+ reads="$("$bin" --reads "$gname" 2>&1)"; rst=$?
153
+ if [[ "$rst" -ne 0 ]]; then
154
+ echo "check-reads-couples: '$bin --reads $gname' exited $rst — the gate's own read set" >&2
155
+ echo "is unavailable, so this check could not run; treating as failure (not clean)." >&2
156
+ printf ' %s\n' "$reads" >&2
157
+ echo " help: the binary must answer --reads for every subcommand a descriptor" >&2
158
+ echo " declares. There is deliberately no descriptor-level exemption: a port" >&2
159
+ echo " that could opt out of this in a sentence would end the assertion it" >&2
160
+ echo " must replace." >&2
161
+ exit 2
162
+ fi
163
+ while IFS= read -r root; do
164
+ [[ -n "$root" ]] || continue
165
+ # spec: gate-sdk/SPEC.md §check-reads-couples — '?' is the substrate's own honesty
166
+ # marker, counted by the same skip counter the shell arm's unresolvable roots use.
167
+ if [[ "$root" == '?' ]]; then
168
+ skipped=$((skipped + 1)); continue
169
+ fi
170
+ analyzed=$((analyzed + 1))
171
+ cover_root "$root" 1 "" "$gname" "declared read root '$root' (--reads)"
172
+ done <<<"$reads"
173
+ continue
174
+ fi
175
+
109
176
  walks="$(extract_walks "$src")"; st=$?
110
177
  fail_closed "$st" READS-COUPLES "awk walk-scan($src)"
111
178
  [[ -n "$walks" ]] || continue
@@ -117,26 +184,8 @@ for src in "${sources[@]+"${sources[@]}"}"; do
117
184
  fi
118
185
  analyzed=$((analyzed + 1))
119
186
  namepat="$(name_pattern "$rawline")"
120
- if [[ "$root" == "." ]]; then
121
- listing="$(git ls-files)"; gst=$?
122
- else
123
- listing="$(git ls-files -- "$root")"; gst=$?
124
- fi
125
- [[ "$gst" -eq 0 ]] || { echo "check-reads-couples: git ls-files failed for root '$root'" >&2; exit 2; }
126
- while IFS= read -r f; do
127
- [[ -n "$f" ]] || continue
128
- [[ "$cmd" == gate_find ]] && gate_path_pruned "$f" && continue
129
- if [[ -n "$namepat" ]]; then
130
- # shellcheck disable=SC2053 # namepat is the glob, deliberately unquoted
131
- [[ "${f##*/}" == $namepat ]] || continue
132
- fi
133
- covered=0
134
- for g in "${COUPLE_GLOBS[@]}"; do
135
- path_matches_glob "$f" "$g" && { covered=1; break; }
136
- done
137
- [[ "$covered" == 1 ]] || \
138
- findings+=("$(basename "$src" .sh): recursive walk over '$root' (line $lno) reads tracked '$f' — no couple covers it (couples: $couples)")
139
- done <<<"$listing"
187
+ prune=0; [[ "$cmd" == gate_find ]] && prune=1
188
+ cover_root "$root" "$prune" "$namepat" "$gname" "recursive walk over '$root' (line $lno)"
140
189
  done <<<"$walks"
141
190
  done
142
191
 
@@ -0,0 +1,81 @@
1
+ #!/usr/bin/env bash
2
+ # graph: couples=kit:templates/*.list,kit:*/*.sh dir=bi valve=none tier=precommit
3
+ # spec: gate-sdk/SPEC.md §check-template-registry-parity — a kit's shipped `.list` registry template names exactly the artifacts of its sibling directory, both directions
4
+ #
5
+ # usage: check-template-registry-parity.sh [root]
6
+ # bare: sweep gate_kit_roots against the git toplevel; root: resolve relative
7
+ # kit roots against a fixture tree (the case dir's gate-sdk-config.sh names them).
8
+ set -uo pipefail
9
+
10
+ SDK="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
11
+ # shellcheck source=../lib/gate.sh
12
+ source "$SDK/lib/gate.sh"
13
+
14
+ ROOT="${1:-}"
15
+ if [[ -z "$ROOT" ]]; then
16
+ ROOT="$(git rev-parse --show-toplevel 2>/dev/null)" \
17
+ || { echo "check-template-registry-parity: not a git repository and no root argument" >&2; exit 2; }
18
+ fi
19
+ [[ -d "$ROOT" ]] || { echo "check-template-registry-parity: root not found: $ROOT" >&2; exit 2; }
20
+
21
+ mapfile -t KIT_ROOTS < <(gate_kit_roots)
22
+ [[ ${#KIT_ROOTS[@]} -gt 0 ]] || { echo "check-template-registry-parity: no kit roots enumerated" >&2; exit 2; }
23
+
24
+ findings=()
25
+ registries=0
26
+ skipped=0
27
+
28
+ for r in "${KIT_ROOTS[@]}"; do
29
+ r="${r%/}"
30
+ abs="$r"
31
+ [[ "$abs" == /* ]] || abs="$ROOT/$r"
32
+ kit="${r##*/}"
33
+
34
+ shopt -s nullglob
35
+ templates=("$abs"/templates/*.list)
36
+ shopt -u nullglob
37
+
38
+ for tpl in "${templates[@]}"; do
39
+ base="${tpl##*/}"
40
+ dir="$abs/${base%.list}"
41
+ # spec: gate-sdk/SPEC.md §check-template-registry-parity — the population predicate: a `.list` template enters only beside a sibling directory of kit-shipped artifacts, so a template of consumer rule content is skipped-and-counted by construction rather than by an exception naming it
42
+ [[ -d "$dir" ]] || { skipped=$((skipped + 1)); continue; }
43
+ [[ -r "$tpl" ]] || { echo "check-template-registry-parity: template not readable: $tpl" >&2; exit 2; }
44
+ [[ -r "$dir" && -x "$dir" ]] || { echo "check-template-registry-parity: sibling directory not readable: $dir" >&2; exit 2; }
45
+ registries=$((registries + 1))
46
+ rel_tpl="${tpl#"$ROOT"/}"
47
+
48
+ listing="$(git -C "$dir" ls-files -- '*.sh')"; st=$?
49
+ [[ "$st" -eq 0 ]] || { echo "check-template-registry-parity: git ls-files failed under $dir" >&2; exit 2; }
50
+ shipped="$(
51
+ while IFS= read -r f; do
52
+ [[ -n "$f" && "$f" != */* ]] || continue
53
+ printf '%s\n' "${f%.sh}"
54
+ done <<<"$listing" | sort -u
55
+ )"
56
+ registered="$(gates_list_members "$tpl" | sort -u)"
57
+
58
+ # assertion A: every shipped artifact is registered
59
+ while IFS= read -r m; do
60
+ [[ -n "$m" ]] && findings+=("$kit: $rel_tpl does not register shipped artifact: $m")
61
+ done < <(comm -23 <(printf '%s\n' "$shipped") <(printf '%s\n' "$registered"))
62
+
63
+ # assertion B: every registry line resolves to a shipped artifact
64
+ while IFS= read -r m; do
65
+ [[ -n "$m" ]] && findings+=("$kit: $rel_tpl registers a name no shipped artifact answers: $m")
66
+ done < <(comm -13 <(printf '%s\n' "$shipped") <(printf '%s\n' "$registered"))
67
+ done
68
+ done
69
+
70
+ if [[ ${#findings[@]} -gt 0 ]]; then
71
+ echo "check-template-registry-parity: a kit's shipped registry template is out of parity with the directory it registers:"
72
+ printf ' %s\n' "${findings[@]}"
73
+ echo " help: a shipped registry template names the kit's whole bundled set — add the"
74
+ echo " missing line (the consumer prunes its own copy, the kit ships all of it),"
75
+ echo " or drop the line whose artifact the kit no longer ships. An untracked file"
76
+ echo " is not shipped and forces nothing: commit it first."
77
+ exit 1
78
+ fi
79
+
80
+ echo "TEMPLATE-REGISTRY-PARITY: clean ($registries shipped registry template(s) in name-set parity with the sibling directory each registers; $skipped .list template(s) with no such sibling skipped)"
81
+ exit 0
@@ -53,6 +53,21 @@ check_case indicator ' - run: |2
53
53
  # C — a YAML alias as the run: value. No anchor resolution is attempted.
54
54
  check_case alias ' - run: *setup' 2 "a YAML alias as the run: value (run: *setup)"
55
55
 
56
+ # C2 — the anchor half of the same rule. This fell through every refusal arm and
57
+ # landed on the plain-scalar counter, so an anchored body was reported skipped and
58
+ # never linted: a silent fail-open in the gate whose whole job is linting this
59
+ # shell. The body below is ShellCheck-dirty, so a regression here reads as clean.
60
+ check_case anchor ' - run: &setup |
61
+ echo "$undefined_var"
62
+ unused=1' 2 "a YAML anchor on the run: value (run: &setup |)"
63
+
64
+ # C3 — an anchor on a plain scalar refuses too: the anchor is what we cannot
65
+ # resolve, independent of the scalar style it decorates.
66
+ check_case anchor_plain ' - run: &setup echo hi' 2 "a YAML anchor on the run: value (run: &setup echo hi)"
67
+
68
+ # C4 — a quoted value merely beginning with & is an ordinary string, not an anchor.
69
+ check_case anchor_quoted ' - run: "echo && echo"' 0 "0 run: block(s) linted"
70
+
56
71
  # D — an unbalanced GitHub expression on a body line: substituting it would mangle
57
72
  # the fragment, so the line is refused rather than linted wrong.
58
73
  check_case unbalanced ' - run: |
@@ -84,5 +99,5 @@ if [[ "$fails" -gt 0 ]]; then
84
99
  echo "check-action-run-shell.test: $fails assertion(s) failed"
85
100
  exit 1
86
101
  fi
87
- echo "check-action-run-shell.test: ok (folded scalars, an explicit indentation indicator, a YAML alias and an unbalanced GitHub expression each refuse at exit 2 naming the construct; |- and |+ extract normally; a refusable construct outside the Actions-shape subject is skipped and counted rather than refused)"
102
+ echo "check-action-run-shell.test: ok (folded scalars, an explicit indentation indicator, a YAML alias, a YAML anchor on either scalar style and an unbalanced GitHub expression each refuse at exit 2 naming the construct; |- and |+ extract normally; a quoted value merely starting with & is not an anchor; a refusable construct outside the Actions-shape subject is skipped and counted rather than refused)"
88
103
  exit 0
@@ -0,0 +1,64 @@
1
+ #!/usr/bin/env bash
2
+ # spec: gate-sdk/SPEC.md §check-core-files — a kit: manifest line derives one path per kit root, so a root missing that path reds without any manifest edit; a kit: token carrying a wildcard is refused fail-closed because this reader requires each expanded path to exist, which is a different invariant from the glob match a couples= field performs. This lives in the bespoke unit lane rather than the good/+bad/ pair because the fixture runner reads exit 2 as a harness error and runs each case with the fixture dir as cwd, so neither the refusal nor the expansion is expressible there.
3
+ set -uo pipefail
4
+ source "$(dirname "${BASH_SOURCE[0]}")/../lib/test-hermetic.sh"
5
+
6
+ ROOT="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
7
+ GATE="$ROOT/gate-sdk/checks/check-core-files.sh"
8
+ [[ -x "$GATE" ]] || { echo "check-core-files.test: gate not found: $GATE"; exit 2; }
9
+
10
+ sb="$(mktemp -d)"
11
+ trap 'rm -rf "$sb"' EXIT
12
+
13
+ git -C "$sb" init -q
14
+ git -C "$sb" config user.email t@example.invalid
15
+ git -C "$sb" config user.name t
16
+ mkdir -p "$sb/alpha-kit" "$sb/beta-kit"
17
+ printf 'a\n' > "$sb/alpha-kit/SPEC.md"
18
+ printf 'b\n' > "$sb/beta-kit/SPEC.md"
19
+ printf 'r\n' > "$sb/plain.txt"
20
+ git -C "$sb" add -A
21
+ git -C "$sb" commit -qm seed
22
+
23
+ fails=0
24
+ run() { ( cd "$sb" && GATE_SDK_KIT_DIRS="alpha-kit beta-kit" bash "$GATE" "$1" 2>&1 ); }
25
+
26
+ # A kit: line expands to one path per root; every expansion exists, so the gate is clean
27
+ # and its count proves the derivation ran (2 derived + 1 hand line).
28
+ printf 'kit:SPEC.md\nplain.txt\n' > "$sb/good.list"
29
+ out="$(run good.list)"; rc=$?
30
+ [[ "$rc" -eq 0 ]] || { echo "FAIL [expand-clean]: expected exit 0, got $rc: $out"; fails=$((fails + 1)); }
31
+ grep -qF '3 manifest path(s)' <<<"$out" || { echo "FAIL [expand-count]: expected 3 expanded paths: $out"; fails=$((fails + 1)); }
32
+
33
+ # A new root with no SPEC.md reds without any manifest edit — the property Delta 2 exists for.
34
+ mkdir -p "$sb/gamma-kit"
35
+ printf 'g\n' > "$sb/gamma-kit/other.md"
36
+ git -C "$sb" add -A
37
+ git -C "$sb" commit -qm gamma
38
+ out="$( cd "$sb" && GATE_SDK_KIT_DIRS="alpha-kit beta-kit gamma-kit" bash "$GATE" good.list 2>&1 )"; rc=$?
39
+ [[ "$rc" -eq 1 ]] || { echo "FAIL [new-root-reds]: expected exit 1, got $rc: $out"; fails=$((fails + 1)); }
40
+ grep -qF 'missing: gamma-kit/SPEC.md' <<<"$out" || { echo "FAIL [new-root-names]: $out"; fails=$((fails + 1)); }
41
+
42
+ # An untracked expansion reds on the tracked half of the invariant, not just existence.
43
+ printf 'u\n' > "$sb/gamma-kit/SPEC.md"
44
+ out="$( cd "$sb" && GATE_SDK_KIT_DIRS="alpha-kit beta-kit gamma-kit" bash "$GATE" good.list 2>&1 )"; rc=$?
45
+ [[ "$rc" -eq 1 ]] || { echo "FAIL [untracked-reds]: expected exit 1, got $rc: $out"; fails=$((fails + 1)); }
46
+ grep -qF 'untracked: gamma-kit/SPEC.md' <<<"$out" || { echo "FAIL [untracked-names]: $out"; fails=$((fails + 1)); }
47
+
48
+ # A wildcard is refused fail-closed: this reader cannot express "some file matches".
49
+ for tok in 'kit:checks/*.sh' 'kit:SPEC?.md' 'kit:[ab].md'; do
50
+ printf '%s\n' "$tok" > "$sb/wild.list"
51
+ out="$(run wild.list)"; rc=$?
52
+ [[ "$rc" -eq 2 ]] || { echo "FAIL [wildcard-refused $tok]: expected exit 2, got $rc: $out"; fails=$((fails + 1)); }
53
+ grep -qF 'carries a wildcard' <<<"$out" || { echo "FAIL [wildcard-message $tok]: $out"; fails=$((fails + 1)); }
54
+ done
55
+
56
+ # Backward compatibility: a manifest with no kit: line behaves exactly as before.
57
+ printf 'plain.txt\n' > "$sb/plainonly.list"
58
+ out="$(run plainonly.list)"; rc=$?
59
+ [[ "$rc" -eq 0 ]] || { echo "FAIL [no-token-unchanged]: expected exit 0, got $rc: $out"; fails=$((fails + 1)); }
60
+ grep -qF '1 manifest path(s)' <<<"$out" || { echo "FAIL [no-token-count]: $out"; fails=$((fails + 1)); }
61
+
62
+ [[ "$fails" -eq 0 ]] || { echo "check-core-files.test: $fails assertion(s) failed"; exit 1; }
63
+ echo "check-core-files.test: clean (kit: expands per root and reds on a root missing the path or leaving it untracked; a wildcard token is refused fail-closed; a token-free manifest is unchanged)"
64
+ exit 0