checkwright 0.36.0 → 0.37.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 (82) hide show
  1. package/package.json +2 -2
  2. package/payload/artifact/aarch64-apple-darwin/checkwright-gates +0 -0
  3. package/payload/artifact/aarch64-apple-darwin/checkwright-gates.sha256 +1 -1
  4. package/payload/artifact/aarch64-pc-windows-msvc/checkwright-gates.exe +0 -0
  5. package/payload/artifact/aarch64-pc-windows-msvc/checkwright-gates.exe.sha256 +1 -1
  6. package/payload/artifact/aarch64-unknown-linux-gnu/checkwright-gates +0 -0
  7. package/payload/artifact/aarch64-unknown-linux-gnu/checkwright-gates.sha256 +1 -1
  8. package/payload/artifact/aarch64-unknown-linux-musl/checkwright-gates +0 -0
  9. package/payload/artifact/aarch64-unknown-linux-musl/checkwright-gates.sha256 +1 -1
  10. package/payload/artifact/x86_64-apple-darwin/checkwright-gates +0 -0
  11. package/payload/artifact/x86_64-apple-darwin/checkwright-gates.sha256 +1 -1
  12. package/payload/artifact/x86_64-pc-windows-msvc/checkwright-gates.exe +0 -0
  13. package/payload/artifact/x86_64-pc-windows-msvc/checkwright-gates.exe.sha256 +1 -1
  14. package/payload/artifact/x86_64-unknown-linux-gnu/checkwright-gates +0 -0
  15. package/payload/artifact/x86_64-unknown-linux-gnu/checkwright-gates.sha256 +1 -1
  16. package/payload/artifact/x86_64-unknown-linux-musl/checkwright-gates +0 -0
  17. package/payload/artifact/x86_64-unknown-linux-musl/checkwright-gates.sha256 +1 -1
  18. package/payload/canon-kit/README.md +1 -0
  19. package/payload/canon-kit/checks/check-comment-tier.gate +1 -1
  20. package/payload/canon-kit/checks/check-rule-id-coverage.gate +4 -0
  21. package/payload/canon-kit/gate-tests/check-amendment-queue.test.sh +39 -0
  22. package/payload/canon-kit/gate-tests/check-comment-tier/bad/expect.txt +1 -0
  23. package/payload/canon-kit/gate-tests/check-comment-tier/bad/lib/rules.rs +5 -0
  24. package/payload/canon-kit/gate-tests/check-comment-tier/bad/scripts/canon-config.knobs +5 -0
  25. package/payload/canon-kit/gate-tests/check-comment-tier/good/expect.txt +1 -1
  26. package/payload/canon-kit/gate-tests/check-comment-tier/good/good.rs +1 -0
  27. package/payload/canon-kit/gate-tests/check-comment-tier/good/scripts/canon-config.knobs +5 -0
  28. package/payload/canon-kit/gate-tests/check-comment-tier/good/src/rules.rs +5 -0
  29. package/payload/canon-kit/gate-tests/check-rule-id-coverage/bad/expect.txt +3 -0
  30. package/payload/canon-kit/gate-tests/check-rule-id-coverage/bad/scripts/canon-config.knobs +5 -0
  31. package/payload/canon-kit/gate-tests/check-rule-id-coverage/bad/specs/access.md +7 -0
  32. package/payload/canon-kit/gate-tests/check-rule-id-coverage/bad/specs/export.md +3 -0
  33. package/payload/canon-kit/gate-tests/check-rule-id-coverage/bad/src/rules.rs +5 -0
  34. package/payload/canon-kit/gate-tests/check-rule-id-coverage/good/expect.txt +1 -0
  35. package/payload/canon-kit/gate-tests/check-rule-id-coverage/good/scripts/canon-config.knobs +7 -0
  36. package/payload/canon-kit/gate-tests/check-rule-id-coverage/good/specs/access.md +9 -0
  37. package/payload/canon-kit/gate-tests/check-rule-id-coverage/good/specs/export.md +3 -0
  38. package/payload/canon-kit/gate-tests/check-rule-id-coverage/good/src/rules.rs +7 -0
  39. package/payload/canon-kit/gate-tests/check-unmarked-claim.test.sh +2 -2
  40. package/payload/doctrine-kit/DOCTRINE.md +1 -1
  41. package/payload/evidence-kit/README.md +8 -5
  42. package/payload/evidence-kit/checks/check-test-control.gate +4 -0
  43. package/payload/evidence-kit/gate-tests/check-evidence-manifest/bad/validate-evidence.txt +2 -2
  44. package/payload/evidence-kit/gate-tests/check-evidence-manifest/good/validate-evidence.txt +2 -2
  45. package/payload/evidence-kit/gate-tests/check-evidence-manifest.test.sh +56 -7
  46. package/payload/evidence-kit/gate-tests/check-test-control/bad/TASK-QUEUE.md +1 -0
  47. package/payload/evidence-kit/gate-tests/check-test-control/bad/WORKFLOW-STATE.txt +4 -0
  48. package/payload/evidence-kit/gate-tests/check-test-control/bad/args +5 -0
  49. package/payload/evidence-kit/gate-tests/check-test-control/bad/expect.txt +2 -0
  50. package/payload/evidence-kit/gate-tests/check-test-control/bad/scripts/evidence-config.knobs +4 -0
  51. package/payload/evidence-kit/gate-tests/check-test-control/bad/since-baseline.txt +2 -0
  52. package/payload/evidence-kit/gate-tests/check-test-control/bad/validate-baseline.txt +4 -0
  53. package/payload/evidence-kit/gate-tests/check-test-control/bad/validate-evidence.txt +3 -0
  54. package/payload/evidence-kit/gate-tests/check-test-control/good/TASK-QUEUE.md +1 -0
  55. package/payload/evidence-kit/gate-tests/check-test-control/good/WORKFLOW-STATE.txt +4 -0
  56. package/payload/evidence-kit/gate-tests/check-test-control/good/args +5 -0
  57. package/payload/evidence-kit/gate-tests/check-test-control/good/expect.txt +1 -0
  58. package/payload/evidence-kit/gate-tests/check-test-control/good/scripts/evidence-config.knobs +4 -0
  59. package/payload/evidence-kit/gate-tests/check-test-control/good/since-baseline.txt +2 -0
  60. package/payload/evidence-kit/gate-tests/check-test-control/good/validate-baseline.txt +3 -0
  61. package/payload/evidence-kit/gate-tests/check-test-control/good/validate-evidence.txt +3 -0
  62. package/payload/evidence-kit/gate-tests/check-test-control.test.sh +121 -0
  63. package/payload/evidence-kit/gate-tests/pre-hook.test.sh +18 -2
  64. package/payload/evidence-kit/gate-tests/producer-lock.test.sh +1 -1
  65. package/payload/evidence-kit/gate-tests/run-member-door.test.sh +1 -1
  66. package/payload/evidence-kit/gate-tests/statement-store.test.sh +64 -0
  67. package/payload/evidence-kit/gate-tests/test-control-run.test.sh +91 -0
  68. package/payload/evidence-kit/gate-tests/verify-gate-run-strict.test.sh +121 -0
  69. package/payload/evidence-kit/templates/evidence-config.knobs +7 -0
  70. package/payload/gate-sdk/gate-tests/binary-only-recipe.test.sh +125 -0
  71. package/payload/gate-sdk/gate-tests/lib-test-hermetic.test.sh +19 -1
  72. package/payload/gate-sdk/gate-tests/run-for-path.test.sh +16 -1
  73. package/payload/gate-sdk/lib/test-hermetic.sh +6 -1
  74. package/payload/lifecycle-kit/README.md +4 -0
  75. package/payload/lifecycle-kit/gate-tests/check-survey-record.test.sh +1 -1
  76. package/payload/lifecycle-kit/gate-tests/peer-channel.test.sh +150 -0
  77. package/payload/lifecycle-kit/templates/stages/close.md +2 -2
  78. package/payload/lifecycle-kit/templates/stages/scope.md +2 -0
  79. package/payload/lifecycle-kit/templates/stages/validate.md +1 -1
  80. package/payload/queue-kit/gate-tests/roadmap.test.sh +1 -1
  81. package/payload/site-kit/gate-tests/check-docs-since/bad/expect.txt +1 -0
  82. package/payload/site-kit/gate-tests/check-docs-since/bad/site/twice.md +9 -0
@@ -0,0 +1,121 @@
1
+ #!/usr/bin/env bash
2
+ # Behavioral test of check-test-control — the branches the one good/bad pair cannot hold: the
3
+ # empty-controls not-applicable line, a malformed declaration suppressing (B) and (C), the git read
4
+ # of the baseline at the iteration start, the EVIDENCE_KIT_CONTROL_SINCE fall-through and its
5
+ # unresolvable-revision exit 2, (B)'s disarmed early-out, and (C) against a scratch manifest.
6
+ #
7
+ # Run by the --run-gate-tests arm (any <tests-dir>/*.test.sh; must exit 0).
8
+ set -uo pipefail
9
+ source "$(dirname "${BASH_SOURCE[0]}")/../../gate-sdk/lib/test-hermetic.sh"
10
+
11
+ DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" # evidence-kit/
12
+
13
+ fails=0
14
+ tmp="$(mktemp -d)"
15
+ trap 'rm -rf "$tmp"' EXIT
16
+
17
+ H64="$(printf 'b%.0s' {1..64})"
18
+
19
+ # A scratch repository whose iteration started at $start with one baselined test.
20
+ repo="$tmp/repo"; mkdir -p "$repo/scripts"
21
+ _git() { git -C "$repo" -c user.name=t -c user.email=t@t -c core.hooksPath=/dev/null "$@"; }
22
+ _git init -q .
23
+ printf '# fixture\nunit t_old pass\n' >"$repo/base.txt"
24
+ _git add base.txt && _git commit -qm start
25
+ start="$(_git rev-parse HEAD)"
26
+ printf '# state\n---\nit scope sid 2026-01-01 %s\n' "$start" >"$repo/state.txt"
27
+ printf '## Iteration: it\n' >"$repo/queue.md"
28
+ printf '# contract: evidence-manifest v2\n' >"$repo/manifest.txt"
29
+
30
+ # knobs <controls-lines…> — the scratch repo's knob file: suite `unit` plus the given lines
31
+ knobs() {
32
+ { printf 'EVIDENCE_KIT_SUITES[] = unit\n'; printf '%s\n' "$@"; } >"$repo/scripts/evidence-config.knobs"
33
+ }
34
+
35
+ # case_run <name> <want-exit> <expect-substring> <positional…>
36
+ case_run() {
37
+ local name="$1" want="$2" expect="$3" out rc; shift 3
38
+ out="$( cd "$repo" && unset EVIDENCE_KIT_KNOB_FILE && gate_env GATE_SDK_GATES_DIR=scripts \
39
+ && gate_run check-test-control "$DIR/checks" "$@" 2>&1 )"; rc=$?
40
+ if [[ "$rc" -ne "$want" ]]; then
41
+ echo " FAIL: $name expected exit $want, got $rc: $out"; fails=$((fails + 1)); return
42
+ fi
43
+ if ! grep -qF -- "$expect" <<<"$out"; then
44
+ echo " FAIL: $name exit OK but output lacks '$expect': $out"; fails=$((fails + 1))
45
+ fi
46
+ }
47
+
48
+ CTL=('EVIDENCE_KIT_CONTROLS[] = nullguard' 'EVIDENCE_KIT_CONTROL_nullguard = unit t_null BREAK_NULL=1')
49
+
50
+ # 1 — no control declared: nothing asserted, the not-applicable line, however red the tree.
51
+ knobs
52
+ printf '# fixture\nunit t_old pass\nunit t_new pass\n' >"$repo/base.txt"
53
+ case_run "empty-controls" 0 "clean (not applicable: EVIDENCE_KIT_CONTROLS is empty)" base.txt "" manifest.txt queue.md state.txt
54
+
55
+ # 2 — (A): a malformed declaration, a control named SINCE and a duplicate each red, and (B) is
56
+ # suppressed: the uncontrolled new test above goes unreported.
57
+ knobs 'EVIDENCE_KIT_CONTROLS[] = a' 'EVIDENCE_KIT_CONTROLS[] = b' 'EVIDENCE_KIT_CONTROLS[] = c' 'EVIDENCE_KIT_CONTROLS[] = SINCE' \
58
+ 'EVIDENCE_KIT_CONTROL_a = unit t_null BREAK=1' 'EVIDENCE_KIT_CONTROL_b = unit t_null BREAK=2' 'EVIDENCE_KIT_CONTROL_c = ghost t X=1'
59
+ out="$( cd "$repo" && unset EVIDENCE_KIT_KNOB_FILE && gate_env GATE_SDK_GATES_DIR=scripts \
60
+ && gate_run check-test-control "$DIR/checks" base.txt "" manifest.txt queue.md state.txt 2>&1 )"; rc=$?
61
+ for want in "both name unit t_null" "names suite 'ghost'" "collides with EVIDENCE_KIT_CONTROL_SINCE"; do
62
+ grep -qF -- "$want" <<<"$out" || { echo " FAIL: (A) lacks '$want': $out"; fails=$((fails + 1)); }
63
+ done
64
+ if [[ "$rc" -ne 1 ]] || grep -qF "t_new" <<<"$out"; then
65
+ echo " FAIL: (A) exited $rc or did not suppress (B): $out"; fails=$((fails + 1))
66
+ fi
67
+
68
+ # 3 — (B) through git: t_new was baselined after the iteration start and no control names it.
69
+ knobs "${CTL[@]}"
70
+ printf '# fixture\nunit t_old pass\nunit t_null pass\nunit t_new pass\n' >"$repo/base.txt"
71
+ case_run "new-test-at-iteration-start" 1 "new test 'unit t_new' (baselined pass since the iteration start $start)" \
72
+ base.txt "" manifest.txt queue.md state.txt
73
+
74
+ # 4 — a baseline absent at the since commit makes every pass row new.
75
+ printf '# fixture\nunit t_null pass\n' >"$repo/later.txt"
76
+ case_run "absent-at-since" 0 "1 new test(s) judged against the iteration start $start" \
77
+ later.txt "" manifest.txt queue.md state.txt
78
+
79
+ # 5 — with no iteration start, EVIDENCE_KIT_CONTROL_SINCE names the since commit.
80
+ knobs "${CTL[@]}" "EVIDENCE_KIT_CONTROL_SINCE = $start"
81
+ case_run "since-fall-through" 1 "baselined pass since EVIDENCE_KIT_CONTROL_SINCE $start" \
82
+ base.txt "" manifest.txt queue.md no-state.txt
83
+
84
+ # 6 — an unresolvable EVIDENCE_KIT_CONTROL_SINCE is exit 2 naming it, never clean or disarmed.
85
+ knobs "${CTL[@]}" "EVIDENCE_KIT_CONTROL_SINCE = no-such-rev"
86
+ case_run "since-unresolvable" 2 "EVIDENCE_KIT_CONTROL_SINCE 'no-such-rev' resolves to no commit" \
87
+ base.txt "" manifest.txt queue.md no-state.txt
88
+
89
+ # 7 — neither an iteration start nor a since revision disarms (B) at its declared early-out.
90
+ knobs "${CTL[@]}"
91
+ case_run "since-disarmed" 0 "new-test check off: no iteration-start commit and EVIDENCE_KIT_CONTROL_SINCE is empty" \
92
+ base.txt "" manifest.txt queue.md no-state.txt
93
+
94
+ # 8 — (C) on a close cursor: judged per control against the suite line it follows.
95
+ printf '# fixture\nunit t_old pass\nunit t_null pass\n' >"$repo/base.txt"
96
+ printf '# state\n---\nit validate sid 2026-01-02 %s\nit close sid 2026-01-03 %s\n' "$start" "$start" >"$repo/close.txt"
97
+ suite="it unit sha256=$H64 pass=2 fail=0 ignore=0 verdict=clean 2026-01-02 commit=$start tree=clean cmd=$H64 origin=local"
98
+ # The witness's assign= is the SHA-256 of nullguard's one assignment, 'BREAK_NULL=1' and a newline.
99
+ witness="it unit control=nullguard scenario=t_null witnessed=red 2026-01-02 commit=$start cmd=$H64 assign=ffc2bf120f95ff83431fa8cb7d89902ed9cdf9a3c62dd02a78a7fc2c0d3d2ff3"
100
+ # close_case <name> <want-exit> <expect> <manifest-lines…>
101
+ close_case() {
102
+ local name="$1" want="$2" expect="$3"; shift 3
103
+ { printf '# contract: evidence-manifest v2\n'; printf '%s\n' "$@"; } >"$repo/manifest.txt"
104
+ case_run "$name" "$want" "$expect" base.txt "" manifest.txt queue.md close.txt
105
+ }
106
+ close_case "close-witnessed" 0 "every control witnessed red for 'it' at stage 'close'" "$suite" "$witness"
107
+ close_case "close-unwitnessed" 1 "control 'nullguard' has no witness" "$suite"
108
+ close_case "close-green" 1 "control 'nullguard' witnessed=green" "$suite" "${witness/witnessed=red/witnessed=green}"
109
+ close_case "close-other-scenario" 1 "not its declared scenario t_null" "$suite" "${witness/scenario=t_null/scenario=t_old}"
110
+ close_case "close-other-command" 1 "not the commit and command of the suite line it follows" "$suite" "${witness/cmd=$H64/cmd=${H64//b/c}}"
111
+ close_case "close-stale" 1 "before the earliest validate stamp 2026-01-02" "$suite" "${witness/2026-01-02/2026-01-01}"
112
+ close_case "close-imported-after" 1 "control 'nullguard' has no witness" "$suite" "$witness" "${suite/origin=local/origin=imported}"
113
+ knobs 'EVIDENCE_KIT_CONTROLS[] = nullguard' 'EVIDENCE_KIT_CONTROL_nullguard = unit t_null BREAK_NULL=2'
114
+ close_case "close-other-assignments" 1 "control 'nullguard' was witnessed under other assignments than its declaration's" "$suite" "$witness"
115
+
116
+ if [[ "$fails" -gt 0 ]]; then
117
+ echo "check-test-control.test: $fails assertion(s) failed"
118
+ exit 1
119
+ fi
120
+ echo "check-test-control.test: ok (empty controls not applicable; (A) reds and suppresses (B); (B) through git at the iteration start, an absent prior baseline, the since fall-through, its unresolvable exit 2 and the disarmed early-out; (C) witnessed, unwitnessed, green, other scenario, other command, stale, import-superseded and other assignments)"
121
+ exit 0
@@ -17,7 +17,7 @@ mk_tree() {
17
17
  rm -rf "$1"; mkdir -p "$1/.workflow" "$1/scripts" "$1/.tmp"
18
18
  ( cd "$1" && git init -q . ) >/dev/null 2>&1
19
19
  printf '# baseline\nalpha alpha pass\nbeta beta pass\n' >"$1/.workflow/validate-baseline.txt"
20
- printf '# contract: evidence-manifest v1\n' >"$1/.workflow/validate-evidence.txt"
20
+ printf '# contract: evidence-manifest v2\n' >"$1/.workflow/validate-evidence.txt"
21
21
  printf '#!/usr/bin/env bash\nprintf "%%s\\n" "$1" >> .tmp/hook.log\n' >"$1/scripts/hook.sh"
22
22
  # The suite exits non-zero unless the hook already ran for it, so ordering is observable as a verdict.
23
23
  printf '#!/usr/bin/env bash\nprintf "%%s\\n" "$1" >> .tmp/suite.log\ngrep -qx "$1" .tmp/hook.log\n' >"$1/scripts/suite.sh"
@@ -58,9 +58,25 @@ if grep -q '^hook-test ' "$tmp/b/.workflow/validate-evidence.txt"; then
58
58
  echo " FAIL: a run its hook refused still recorded evidence"; fails=$((fails + 1))
59
59
  fi
60
60
 
61
+ # C — with a Statement configured, a hook that moves HEAD refuses at exit 2 before
62
+ # its suite runs, naming the suite, and neither the manifest nor the Statement is written.
63
+ mk_tree "$tmp/c" "bash scripts/commit.sh"
64
+ printf '#!/usr/bin/env bash\ngit -c user.name=t -c user.email=t@t commit -q --allow-empty -m "hook $1"\n' >"$tmp/c/scripts/commit.sh"
65
+ printf 'EVIDENCE_KIT_STATEMENT_FILE = .tmp/statement.json\n' >>"$tmp/c/scripts/evidence-config.knobs"
66
+ ( cd "$tmp/c" && git -c user.name=t -c user.email=t@t commit -q --allow-empty -m base ) >/dev/null 2>&1
67
+ before="$(cat "$tmp/c/.workflow/validate-evidence.txt")"
68
+ out="$(_rv "$tmp/c")"; rc=$?
69
+ if [[ "$rc" -ne 2 ]] || [[ "$out" != *"'alpha'"* ]]; then
70
+ echo " FAIL: a hook that commits must refuse at exit 2 naming its suite (rc=$rc): $out"; fails=$((fails + 1))
71
+ fi
72
+ if [[ -e "$tmp/c/.tmp/suite.log" ]] || [[ -e "$tmp/c/.tmp/statement.json" ]] \
73
+ || [[ "$(cat "$tmp/c/.workflow/validate-evidence.txt")" != "$before" ]]; then
74
+ echo " FAIL: a run refused for a moved HEAD still ran a suite or wrote a file"; fails=$((fails + 1))
75
+ fi
76
+
61
77
  if [[ "$fails" -gt 0 ]]; then
62
78
  echo "pre-hook.test: $fails assertion(s) failed"
63
79
  exit 1
64
80
  fi
65
- echo "pre-hook.test: ok (per-suite hook in roster order with its operand ahead of the suite, failing hook exit 2 with no suite run and no evidence)"
81
+ echo "pre-hook.test: ok (per-suite hook in roster order with its operand ahead of the suite, failing hook exit 2 with no suite run and no evidence, a HEAD-moving hook under a Statement exit 2 with nothing written)"
66
82
  exit 0
@@ -37,7 +37,7 @@ mk_tree() {
37
37
  rm -rf "$1"; mkdir -p "$1/.workflow" "$1/scripts" "$1/.tmp"
38
38
  ( cd "$1" && git init -q . ) >/dev/null 2>&1
39
39
  printf '# baseline\ngreen green pass\n' >"$1/.workflow/validate-baseline.txt"
40
- printf '# contract: evidence-manifest v1\n' >"$1/.workflow/validate-evidence.txt"
40
+ printf '# contract: evidence-manifest v2\n' >"$1/.workflow/validate-evidence.txt"
41
41
  printf "EVIDENCE_KIT_SUITES[] = green\nEVIDENCE_KIT_RUN_ID = lock-test\nEVIDENCE_KIT_RUN_green = %s\n" \
42
42
  "${2:-true}" >"$1/scripts/evidence-config.knobs"
43
43
  }
@@ -22,7 +22,7 @@ printf '#!/usr/bin/env bash\ntouch "%s/ran"\n' "$tmp" >"$p/probe-kit/gate-tests/
22
22
  printf 'GATE_SDK_KIT_DIRS = probe-kit\nGATE_SDK_NATIVE_BIN = bin/cw\n' >"$p/scripts/gate-sdk-config.knobs"
23
23
  printf 'EVIDENCE_KIT_SUITES[] <- EVIDENCE_KIT_FIXTURE_SUITES\nEVIDENCE_KIT_RUN_ID = door-test\n' >"$p/scripts/evidence-config.knobs"
24
24
  printf '# baseline\n' >"$p/.workflow/validate-baseline.txt"
25
- printf '# contract: evidence-manifest v1\n' >"$p/.workflow/validate-evidence.txt"
25
+ printf '# contract: evidence-manifest v2\n' >"$p/.workflow/validate-evidence.txt"
26
26
 
27
27
  prefix="$(git -C "$p" rev-parse --show-prefix 2>&1)"
28
28
  if [[ "$prefix" != "proj/" ]]; then
@@ -0,0 +1,64 @@
1
+ #!/usr/bin/env bash
2
+ # spec: evidence-kit/SPEC.md §bin/run-validate.sh — the git-notes pair: a run stores its Statement as a note on the subject with no file configured, the read knob verifies it with no operand, the store leaves the worktree untouched, a second run's note replaces the first, and a failing store exits 2 naming the published manifest.
3
+ #
4
+ # Run by the --run-gate-tests arm (any <tests-dir>/*.test.sh; must exit 0).
5
+ set -uo pipefail
6
+ source "$(dirname "${BASH_SOURCE[0]}")/../../gate-sdk/lib/test-hermetic.sh"
7
+
8
+ DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" # evidence-kit/
9
+ FE="$(cd "$DIR/../gate-sdk/bin" && pwd)/run-gates.sh"
10
+
11
+ fails=0
12
+ tmp="$(mktemp -d)"
13
+ trap 'rm -rf "$tmp"' EXIT
14
+ fail() { echo " FAIL: $*"; fails=$((fails + 1)); }
15
+
16
+ t="$tmp/tree"
17
+ mkdir -p "$t/.workflow" "$t/scripts"
18
+ ( cd "$t" && git init -q . && git config user.name t && git config user.email t@t ) >/dev/null 2>&1
19
+ printf '# baseline\nok ok pass\n' >"$t/.workflow/validate-baseline.txt"
20
+ printf '# contract: evidence-manifest v2\n' >"$t/.workflow/validate-evidence.txt"
21
+ printf '.tmp/\n' >"$t/.gitignore"
22
+ printf '%s\n' "EVIDENCE_KIT_SUITES[] = ok" "EVIDENCE_KIT_RUN_ID = store" "EVIDENCE_KIT_RUN_ok = true" >"$t/scripts/base.knobs"
23
+ {
24
+ cat "$t/scripts/base.knobs"
25
+ printf 'EVIDENCE_KIT_STATEMENT_WRITE_CMD[] = %s\n' git notes --ref=gate-run add -f -F -
26
+ printf 'EVIDENCE_KIT_STATEMENT_CMD[] = %s\n' git notes --ref=gate-run show HEAD
27
+ } >"$t/scripts/notes.knobs"
28
+ {
29
+ cat "$t/scripts/base.knobs"
30
+ printf 'EVIDENCE_KIT_STATEMENT_WRITE_CMD[] = %s\n' git no-such-subcommand
31
+ } >"$t/scripts/broken.knobs"
32
+ ( cd "$t" && git add -A && git commit -q -m base ) >/dev/null 2>&1
33
+ _fe() { local knobs="$1"; shift; ( cd "$t" && EVIDENCE_KIT_KNOB_FILE="scripts/$knobs" bash "$FE" "$@" 2>&1 ); }
34
+
35
+ # A — the store: a note on the subject, no file written, and nothing in the worktree but the fold.
36
+ out="$(_fe notes.knobs --run-validate)"; rc=$?
37
+ [[ "$rc" -eq 0 && "$out" == *"Statement stored by EVIDENCE_KIT_STATEMENT_WRITE_CMD"* ]] || fail "the run must store its Statement (rc=$rc): $out"
38
+ git -C "$t" notes --ref=gate-run show HEAD 2>/dev/null | grep -q '"predicateType":"https://checkwright.dev/gate-run/v1"' \
39
+ || fail "no gate-run Statement stored as the subject's note"
40
+ status="$(git -C "$t" status --porcelain --untracked-files=all)"
41
+ [[ "$status" == " M .workflow/validate-evidence.txt" ]] || fail "the store must leave the worktree untouched but for the fold: $status"
42
+
43
+ # B — the read half: the verify arm judges the note with no operand.
44
+ out="$(_fe notes.knobs --verify-gate-run)"; rc=$?
45
+ [[ "$rc" -eq 0 && "$out" == *"clean"*"ahead=0"* ]] || fail "the verify arm must read the note clean through EVIDENCE_KIT_STATEMENT_CMD (rc=$rc): $out"
46
+
47
+ # C — a second run at the same subject replaces the note: still one note, and one more notes commit.
48
+ out="$(_fe notes.knobs --run-validate)"; rc=$?
49
+ [[ "$rc" -eq 0 ]] || fail "a second run must replace the note (rc=$rc): $out"
50
+ notes="$(git -C "$t" notes --ref=gate-run list | wc -l | tr -d ' ')"
51
+ commits="$(git -C "$t" rev-list --count refs/notes/gate-run)"
52
+ [[ "$notes" == 1 && "$commits" == 2 ]] || fail "a second run must replace the first note (notes=$notes, notes commits=$commits)"
53
+
54
+ # D — a failing store: exit 2, naming the manifest as published.
55
+ out="$(_fe broken.knobs --run-validate)"; rc=$?
56
+ [[ "$rc" -eq 2 && "$out" == *"EVIDENCE_KIT_STATEMENT_WRITE_CMD exited"*"the manifest"*"published, the store is not"* ]] \
57
+ || fail "a failing store must exit 2 naming the published manifest (rc=$rc): $out"
58
+
59
+ if [[ "$fails" -gt 0 ]]; then
60
+ echo "statement-store.test: $fails assertion(s) failed"
61
+ exit 1
62
+ fi
63
+ echo "statement-store.test: ok (the run stores a note on its subject with no file written and the worktree untouched but for the fold, the verify arm reads it clean with no operand, a second run replaces the note, a failing store exits 2 naming the published manifest)"
64
+ exit 0
@@ -0,0 +1,91 @@
1
+ #!/usr/bin/env bash
2
+ # spec: evidence-kit/SPEC.md §Test controls — a control re-runs its suite under its assignments and records the witness after the suite's line; a control that witnesses no red exits 1 and still publishes the Statement, a malformed declaration exits 2 before the claim, and a re-run supersedes the suite's control lines.
3
+ #
4
+ # Run by the --run-gate-tests arm (any <tests-dir>/*.test.sh; must exit 0).
5
+ set -uo pipefail
6
+ source "$(dirname "${BASH_SOURCE[0]}")/../../gate-sdk/lib/test-hermetic.sh"
7
+
8
+ DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" # evidence-kit/
9
+ FE="$(cd "$DIR/../gate-sdk/bin" && pwd)/run-gates.sh"
10
+
11
+ fails=0
12
+ tmp="$(mktemp -d)"
13
+ trap 'rm -rf "$tmp"' EXIT
14
+
15
+ # mk_tree <dir> <suite-script-body> <control-value> — one suite, alpha, under the exit-code parser,
16
+ # so its one scenario is the suite's name; the tree carries one commit for a Statement's subject
17
+ mk_tree() {
18
+ rm -rf "$1"; mkdir -p "$1/.workflow" "$1/scripts" "$1/.tmp"
19
+ printf '# baseline\nalpha alpha pass\n' >"$1/.workflow/validate-baseline.txt"
20
+ printf '# contract: evidence-manifest v2\n' >"$1/.workflow/validate-evidence.txt"
21
+ printf '#!/usr/bin/env bash\nprintf "run\\n" >> .tmp/suite.log\n%s\n' "$2" >"$1/scripts/suite.sh"
22
+ printf '%s\n' \
23
+ "EVIDENCE_KIT_SUITES[] = alpha" \
24
+ "EVIDENCE_KIT_RUN_ID = ctl-test" \
25
+ "EVIDENCE_KIT_RUN_alpha = bash scripts/suite.sh" \
26
+ "EVIDENCE_KIT_CONTROLS[] = guard" \
27
+ "EVIDENCE_KIT_CONTROL_guard = $3" >"$1/scripts/evidence-config.knobs"
28
+ ( cd "$1" && git init -q . && git -c user.name=t -c user.email=t@t commit -q --allow-empty -m base ) >/dev/null 2>&1
29
+ }
30
+ _rv() { ( cd "$1" && EVIDENCE_KIT_KNOB_FILE=scripts/evidence-config.knobs bash "$FE" --run-validate 2>&1 ); }
31
+ manifest_lines() { grep -v '^#' "$1/.workflow/validate-evidence.txt"; }
32
+
33
+ # A — a suite that fails when BREAK is set: the control witnesses red, its line follows the suite's,
34
+ # its log and parse sit beside the suite's, and the run exits 0. A re-run leaves one control line.
35
+ # The line's assign= is the SHA-256 of the declaration's one assignment, 'BREAK=1' and a newline.
36
+ BREAK_DIGEST=ed00581708d857f9a1d8afd4572cdf1ef80eb19cdd5721a5405edfb5f617fa56
37
+ mk_tree "$tmp/a" '[[ -z "${BREAK:-}" ]]' "alpha alpha BREAK=1"
38
+ out="$(_rv "$tmp/a")"; rc=$?
39
+ lines="$(manifest_lines "$tmp/a")"
40
+ if [[ "$rc" -ne 0 ]]; then
41
+ echo " FAIL: a control witnessed red must exit 0 (rc=$rc): $out"; fails=$((fails + 1))
42
+ fi
43
+ if ! grep -q '^ctl-test alpha sha256=' <<<"$(sed -n 1p <<<"$lines")" \
44
+ || ! grep -q '^ctl-test alpha control=guard scenario=alpha witnessed=red ' <<<"$(sed -n 2p <<<"$lines")"; then
45
+ echo " FAIL: the control line does not follow its suite line witnessed red: $lines"; fails=$((fails + 1))
46
+ fi
47
+ if ! grep -q " assign=$BREAK_DIGEST\$" <<<"$(sed -n 2p <<<"$lines")"; then
48
+ echo " FAIL: the control line does not record its declaration's assignments digest: $lines"; fails=$((fails + 1))
49
+ fi
50
+ if [[ ! -e "$tmp/a/.tmp/validate-alpha.control-guard.log" ]] \
51
+ || ! grep -q '^alpha fail' "$tmp/a/.tmp/validate-alpha.control-guard.parsed" 2>/dev/null; then
52
+ echo " FAIL: the control's log and parse are not beside the suite's"; fails=$((fails + 1))
53
+ fi
54
+ _rv "$tmp/a" >/dev/null; rc=$?
55
+ if [[ "$rc" -ne 0 ]] || [[ "$(manifest_lines "$tmp/a" | grep -c 'control=guard')" -ne 1 ]]; then
56
+ echo " FAIL: a re-run did not supersede the suite's control line (rc=$rc): $(manifest_lines "$tmp/a")"; fails=$((fails + 1))
57
+ fi
58
+
59
+ # B — a suite that ignores BREAK: the control witnesses green, the run exits 1 naming the control,
60
+ # the line is still written, and the Statement still publishes.
61
+ mk_tree "$tmp/b" 'true' "alpha alpha BREAK=1"
62
+ printf 'EVIDENCE_KIT_STATEMENT_FILE = .tmp/statement.json\n' >>"$tmp/b/scripts/evidence-config.knobs"
63
+ out="$(_rv "$tmp/b")"; rc=$?
64
+ if [[ "$rc" -ne 1 ]] || [[ "$out" != *"control 'guard' witnessed green"* ]]; then
65
+ echo " FAIL: a control witnessing no red must exit 1 naming it (rc=$rc): $out"; fails=$((fails + 1))
66
+ fi
67
+ if ! manifest_lines "$tmp/b" | grep -q 'control=guard scenario=alpha witnessed=green' \
68
+ || ! manifest_lines "$tmp/b" | grep -q 'verdict=clean'; then
69
+ echo " FAIL: the green witness was not recorded beside a clean suite line: $(manifest_lines "$tmp/b")"; fails=$((fails + 1))
70
+ fi
71
+ if [[ ! -s "$tmp/b/.tmp/statement.json" ]]; then
72
+ echo " FAIL: a run whose control witnessed no red did not publish its Statement"; fails=$((fails + 1))
73
+ fi
74
+
75
+ # C — a declaration with no assignment refuses at exit 2 before the claim: no suite runs, nothing is written.
76
+ mk_tree "$tmp/c" 'true' "alpha alpha"
77
+ before="$(cat "$tmp/c/.workflow/validate-evidence.txt")"
78
+ out="$(_rv "$tmp/c")"; rc=$?
79
+ if [[ "$rc" -ne 2 ]] || [[ "$out" != *"control 'guard' carries no <VAR>=<value> assignment"* ]]; then
80
+ echo " FAIL: a malformed declaration must refuse at exit 2 naming it (rc=$rc): $out"; fails=$((fails + 1))
81
+ fi
82
+ if [[ -e "$tmp/c/.tmp/suite.log" ]] || [[ "$(cat "$tmp/c/.workflow/validate-evidence.txt")" != "$before" ]]; then
83
+ echo " FAIL: a refused declaration still ran a suite or wrote the manifest"; fails=$((fails + 1))
84
+ fi
85
+
86
+ if [[ "$fails" -gt 0 ]]; then
87
+ echo "test-control-run.test: $fails assertion(s) failed"
88
+ exit 1
89
+ fi
90
+ echo "test-control-run.test: ok (red witness after its suite line at exit 0, carrying its assignments digest, and superseded on re-run; green witness exit 1 with the line and Statement written; malformed declaration exit 2 with nothing run)"
91
+ exit 0
@@ -0,0 +1,121 @@
1
+ #!/usr/bin/env bash
2
+ # spec: evidence-kit/SPEC.md §verify-gate-run — each EVIDENCE_KIT_VERIFY_REQUIRE word reds its own case and holds on a run of HEAD with every suite clean; EVIDENCE_KIT_TREE_UNTRACKED=count reads an untracked path as modified unless it is ignored or the run's own write, a link judged where it sits; --json prints the result as one document on exit 0 and 1 and none on a refusal, and the import arm refuses the option.
3
+ #
4
+ # Run by the --run-gate-tests arm (any <tests-dir>/*.test.sh; must exit 0).
5
+ set -uo pipefail
6
+ source "$(dirname "${BASH_SOURCE[0]}")/../../gate-sdk/lib/test-hermetic.sh"
7
+
8
+ DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" # evidence-kit/
9
+ FE="$(cd "$DIR/../gate-sdk/bin" && pwd)/run-gates.sh"
10
+
11
+ fails=0
12
+ tmp="$(mktemp -d)"
13
+ trap 'rm -rf "$tmp"' EXIT
14
+ fail() { echo " FAIL: $*"; fails=$((fails + 1)); }
15
+
16
+ # spec: evidence-kit/SPEC.md §bin/run-validate.sh — each scratch tree is its own git toplevel, crossing the absolute binary the preamble exports; the tmp dir is left unignored so only the run-write exclusion keeps it out of a count.
17
+ mk_tree() {
18
+ rm -rf "$1"; mkdir -p "$1/.workflow" "$1/scripts" "$1/out"
19
+ ( cd "$1" && git init -q . && git config user.name t && git config user.email t@t ) >/dev/null 2>&1
20
+ printf '# baseline\nok ok pass\nbad bad pass\n' >"$1/.workflow/validate-baseline.txt"
21
+ printf '# contract: evidence-manifest v2\n' >"$1/.workflow/validate-evidence.txt"
22
+ printf 'ignored.txt\n' >"$1/.gitignore"
23
+ printf '%s\n' "EVIDENCE_KIT_SUITES[] = $2" \
24
+ "EVIDENCE_KIT_RUN_ID = strict" \
25
+ "EVIDENCE_KIT_RUN_ok = true" \
26
+ "EVIDENCE_KIT_RUN_bad = false" \
27
+ "EVIDENCE_KIT_STATEMENT_FILE = out/statement.json" >"$1/scripts/evidence-config.knobs"
28
+ ( cd "$1" && git add -A && git commit -q -m base ) >/dev/null 2>&1
29
+ }
30
+ _fe() { local d="$1"; shift; ( cd "$d" && EVIDENCE_KIT_KNOB_FILE=scripts/evidence-config.knobs bash "$FE" "$@" 2>&1 ); }
31
+ _commit() { ( cd "$1" && git add -A && git commit -q --allow-empty -m "${2:-next}" ) >/dev/null 2>&1; }
32
+
33
+ # A — head: clean on a Statement of HEAD, red one commit later, and the default selection reds neither.
34
+ mk_tree "$tmp/a" ok
35
+ _fe "$tmp/a" --run-validate >/dev/null
36
+ out="$(EVIDENCE_KIT_VERIFY_REQUIRE="head" _fe "$tmp/a" --verify-gate-run out/statement.json)"; rc=$?
37
+ [[ "$rc" -eq 0 && "$out" == *"clean"*"ahead=0"* ]] || fail "head must hold on a Statement of HEAD (rc=$rc): $out"
38
+ cp "$tmp/a/out/statement.json" "$tmp/a-statement.json"
39
+ _commit "$tmp/a"
40
+ out="$(EVIDENCE_KIT_VERIFY_REQUIRE="head" _fe "$tmp/a" --verify-gate-run "$tmp/a-statement.json")"; rc=$?
41
+ [[ "$rc" -eq 1 && "$out" == *"is 1 commit(s) behind HEAD (EVIDENCE_KIT_VERIFY_REQUIRE: head)"* && "$out" == *"ahead=1"* ]] \
42
+ || fail "head must red a Statement one commit behind HEAD, naming the requirement (rc=$rc): $out"
43
+ out="$(_fe "$tmp/a" --verify-gate-run "$tmp/a-statement.json")"; rc=$?
44
+ [[ "$rc" -eq 0 ]] || fail "the empty default must not red a Statement behind HEAD (rc=$rc): $out"
45
+
46
+ # A' — --json: the document's top-level verdict and ahead on a clean and on a contradicted Statement,
47
+ # no document on a refusal, and the import arm keeps refusing the option.
48
+ out="$(_fe "$tmp/a" --verify-gate-run --json "$tmp/a-statement.json")"; rc=$?
49
+ [[ "$rc" -eq 0 && "$out" == '{"ahead":1,'* && "$out" == *'],"verdict":"clean"}' ]] \
50
+ || fail "--json must print a clean document at ahead 1 (rc=$rc): $out"
51
+ out="$(EVIDENCE_KIT_VERIFY_REQUIRE="head" _fe "$tmp/a" --verify-gate-run "$tmp/a-statement.json" --json)"; rc=$?
52
+ [[ "$rc" -eq 1 && "$out" == '{"ahead":1,'* && "$out" == *'],"verdict":"contradiction"}' ]] \
53
+ || fail "--json must print a contradiction document, the option after the operand (rc=$rc): $out"
54
+ out="$( cd "$tmp/a" && EVIDENCE_KIT_KNOB_FILE=scripts/evidence-config.knobs bash "$FE" --verify-gate-run --json "$tmp/absent.json" 2>/dev/null )"; rc=$?
55
+ [[ "$rc" -eq 2 && -z "$out" ]] || fail "--json must print no document on a refusal (rc=$rc): $out"
56
+ out="$(EVIDENCE_KIT_IMPORTED_RUNS=accept _fe "$tmp/a" --import-gate-run --json "$tmp/a-statement.json")"; rc=$?
57
+ [[ "$rc" -eq 2 && "$out" == *"at most one operand (got: --json "* ]] || fail "--import-gate-run must keep refusing --json (rc=$rc): $out"
58
+
59
+ # B — verdict: clean on a passing suite, red on a failing one, and the default selection reds neither.
60
+ out="$(EVIDENCE_KIT_VERIFY_REQUIRE=verdict _fe "$tmp/a" --verify-gate-run "$tmp/a-statement.json")"; rc=$?
61
+ [[ "$rc" -eq 0 ]] || fail "verdict must hold on a passing suite (rc=$rc): $out"
62
+ mk_tree "$tmp/b" bad
63
+ _fe "$tmp/b" --run-validate >/dev/null; rc=$?
64
+ [[ "$rc" -eq 1 && -s "$tmp/b/out/statement.json" ]] || fail "a failing suite must exit 1 and still write its Statement (rc=$rc)"
65
+ out="$(EVIDENCE_KIT_VERIFY_REQUIRE=verdict _fe "$tmp/b" --verify-gate-run out/statement.json)"; rc=$?
66
+ [[ "$rc" -eq 1 && "$out" == *"suite 'bad' verdict: new-failures (EVIDENCE_KIT_VERIFY_REQUIRE: verdict)"* ]] \
67
+ || fail "verdict must red a failing suite, naming the requirement (rc=$rc): $out"
68
+ out="$(_fe "$tmp/b" --verify-gate-run out/statement.json)"; rc=$?
69
+ [[ "$rc" -eq 0 ]] || fail "the empty default must not red a failing suite's Statement (rc=$rc): $out"
70
+ out="$(EVIDENCE_KIT_VERIFY_REQUIRE=ahead _fe "$tmp/b" --verify-gate-run out/statement.json)"; rc=$?
71
+ [[ "$rc" -eq 2 && "$out" == *"EVIDENCE_KIT_VERIFY_REQUIRE word 'ahead'"* ]] || fail "an unknown requirement word must refuse at exit 2 (rc=$rc): $out"
72
+
73
+ # C — count: clean with only an ignored file and the run's own writes untracked, modified with another
74
+ # untracked file; the default ignore reads that same tree clean.
75
+ mk_tree "$tmp/c" ok
76
+ : >"$tmp/c/ignored.txt"
77
+ EVIDENCE_KIT_TREE_UNTRACKED=count _fe "$tmp/c" --run-validate >/dev/null
78
+ grep -q '^strict ok .* tree=clean ' "$tmp/c/.workflow/validate-evidence.txt" \
79
+ || fail "count must read clean with only an ignored file and the tmp dir untracked: $(cat "$tmp/c/.workflow/validate-evidence.txt")"
80
+ _commit "$tmp/c"
81
+ git -C "$tmp/c" rm -q --cached out/statement.json >/dev/null 2>&1; _commit "$tmp/c"
82
+ [[ -f "$tmp/c/out/statement.json" ]] || fail "the Statement under test is missing"
83
+ EVIDENCE_KIT_TREE_UNTRACKED=count _fe "$tmp/c" --run-validate >/dev/null
84
+ grep -q '^strict ok .* tree=clean ' "$tmp/c/.workflow/validate-evidence.txt" \
85
+ || fail "count must not read the untracked Statement it wrote: $(cat "$tmp/c/.workflow/validate-evidence.txt")"
86
+ _commit "$tmp/c"
87
+ git -C "$tmp/c" rm -q --cached out/statement.json >/dev/null 2>&1; _commit "$tmp/c"
88
+ : >"$tmp/c/stray.txt"
89
+ EVIDENCE_KIT_TREE_UNTRACKED=count _fe "$tmp/c" --run-validate >/dev/null
90
+ grep -q '^strict ok .* tree=modified ' "$tmp/c/.workflow/validate-evidence.txt" \
91
+ || fail "count must read modified with another untracked file: $(cat "$tmp/c/.workflow/validate-evidence.txt")"
92
+ out="$(_fe "$tmp/c" --verify-gate-run out/statement.json)"; rc=$?
93
+ [[ "$rc" -eq 1 && "$out" == *"suite 'ok' tree: modified"* ]] || fail "verify must red the Statement count produced (rc=$rc): $out"
94
+ _commit "$tmp/c"
95
+ git -C "$tmp/c" rm -q --cached out/statement.json >/dev/null 2>&1; _commit "$tmp/c"
96
+ : >"$tmp/c/stray2.txt"
97
+ _fe "$tmp/c" --run-validate >/dev/null
98
+ grep -q '^strict ok .* tree=clean ' "$tmp/c/.workflow/validate-evidence.txt" \
99
+ || fail "the default ignore must read an untracked file clean: $(cat "$tmp/c/.workflow/validate-evidence.txt")"
100
+ out="$(EVIDENCE_KIT_TREE_UNTRACKED=all _fe "$tmp/c" --run-validate)"; rc=$?
101
+ [[ "$rc" -eq 2 && "$out" == *"EVIDENCE_KIT_TREE_UNTRACKED is 'all'"* ]] || fail "an unknown untracked selection must refuse at exit 2 (rc=$rc): $out"
102
+
103
+ # D — count judges a link where it sits: an untracked symlink outside the tmp dir whose target lies
104
+ # inside it is no write of the run's. Git Bash copies on a plain `ln -s`, so a copy is a skip.
105
+ mk_tree "$tmp/d" ok
106
+ mkdir -p "$tmp/d/.tmp/inside"
107
+ MSYS=winsymlinks:nativestrict ln -s .tmp/inside "$tmp/d/escape" 2>/dev/null
108
+ if [[ -L "$tmp/d/escape" ]]; then
109
+ EVIDENCE_KIT_TREE_UNTRACKED=count _fe "$tmp/d" --run-validate >/dev/null
110
+ grep -q '^strict ok .* tree=modified ' "$tmp/d/.workflow/validate-evidence.txt" \
111
+ || fail "count must read an untracked link into the tmp dir as modified: $(cat "$tmp/d/.workflow/validate-evidence.txt")"
112
+ else
113
+ echo "verify-gate-run-strict.test: skip [D]: this host made no symlink"
114
+ fi
115
+
116
+ if [[ "$fails" -gt 0 ]]; then
117
+ echo "verify-gate-run-strict.test: $fails assertion(s) failed"
118
+ exit 1
119
+ fi
120
+ echo "verify-gate-run-strict.test: ok (head clean at the subject and red one commit later, verdict clean on a passing suite and red on a failing one, count clean with only ignored and run-written untracked files and modified with another or with a link into the tmp dir, unknown words refused at exit 2, --json a document on exit 0 and 1 and none on a refusal)"
121
+ exit 0
@@ -1 +1,8 @@
1
1
  # spec: evidence-kit/SPEC.md §Layout and configuration — the knob roster (every knob, its default) and the line grammar; the gate binary at `GATE_SDK_NATIVE_BIN` prints the defaults with `--emit knob-roster`; set only what you override
2
+
3
+ # spec: evidence-kit/SPEC.md §Test controls — the ordered control names and one declaration each, its assignments re-introducing the defect its scenario catches; default empty (no control run, check-test-control asserting nothing)
4
+ # EVIDENCE_KIT_CONTROLS[] = <name>
5
+ # EVIDENCE_KIT_CONTROL_<name> = <suite> <scenario> <VAR>=<value>
6
+
7
+ # spec: evidence-kit/SPEC.md §check-test-control — the since commit where the state file carries no iteration start; default empty (the new-test assertion disarmed)
8
+ # EVIDENCE_KIT_CONTROL_SINCE = <revision>
@@ -0,0 +1,125 @@
1
+ #!/usr/bin/env bash
2
+ # spec: gate-sdk/SPEC.md §run-gates — the binary-only recipe's oracle (docs/binary-only.md): on a scratch
3
+ # checkout holding no kit, the direct form's exit codes on a read-only tree, the root positional's
4
+ # narrowing, exit 2 for a missing <KIT>_KNOB_FILE and outside a worktree, GATE_SDK_KIT_DIRS keeping a
5
+ # top-level checks/ directory in the scan, and --run over a registry
6
+ # outside the checkout writing its SARIF log there and leaving the checkout's status empty.
7
+ # Run by the --run-gate-tests arm.
8
+ set -uo pipefail
9
+ source "$(dirname "${BASH_SOURCE[0]}")/../../gate-sdk/lib/test-hermetic.sh"
10
+
11
+ SRC="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
12
+ BIN="$GATE_SDK_NATIVE_BIN"
13
+ [[ -x "$BIN" ]] || { echo "binary-only-recipe.test: gate binary not found: $BIN"; exit 2; }
14
+
15
+ scratch="$(cd -P "$(mktemp -d)" && pwd -P)"
16
+ trap 'chmod -R u+w "$scratch" 2>/dev/null; rm -rf "$scratch"' EXIT
17
+
18
+ fails=0
19
+ assert_rc() { [[ "$2" -eq "$3" ]] || { echo "FAIL [$1]: expected exit $3, got $2"; [[ -n "${4:-}" ]] && printf '%s\n' "$4"; fails=$((fails + 1)); }; }
20
+ assert_clean() {
21
+ local st
22
+ st="$(git -C "$repo" status --porcelain --untracked-files=all --ignored)"
23
+ [[ -z "$st" ]] || { echo "FAIL [$1]: the checkout's status is not empty:"; printf '%s\n' "$st"; fails=$((fails + 1)); }
24
+ }
25
+
26
+ # The container: the binary, git, PATH and HOME, and nothing a vendored kit or a knob file would set.
27
+ mkdir -p "$scratch/home"
28
+ container() {
29
+ env -i PATH="$PATH" HOME="$scratch/home" TMPDIR="$scratch" \
30
+ GIT_CONFIG_GLOBAL="$GIT_CONFIG_GLOBAL" GIT_CONFIG_NOSYSTEM=1 \
31
+ GIT_CEILING_DIRECTORIES="$scratch" "$@"
32
+ }
33
+
34
+ repo="$scratch/repo"
35
+ mkdir -p "$repo/crates/a" "$repo/owned" "$repo/.github/workflows"
36
+ printf '# A spec\n\nbody\n\n## Definition of Done\n\n- x\n' > "$repo/crates/a/SPEC.md"
37
+ printf '# a\n\n## What changes\n\n### (1) x\n\ny\n\n## Retired spellings\n\n- None — nothing\n' > "$repo/crates/a/SPEC-x.md"
38
+ sha=0123456789abcdef0123456789abcdef01234567
39
+ printf 'on: push\njobs:\n a:\n runs-on: ubuntu-latest\n steps:\n - uses: actions/checkout@%s\n' "$sha" > "$repo/owned/ci.yml"
40
+ printf 'on: push\njobs:\n a:\n runs-on: ubuntu-latest\n steps:\n - uses: actions/checkout@v4\n' > "$repo/.github/workflows/upstream.yml"
41
+ git -C "$repo" init -q
42
+ git -C "$repo" add -A
43
+ git -C "$repo" -c user.name=t -c user.email=t@e.invalid commit -qm base
44
+
45
+ # ---- the direct form, on a read-only checkout ------------------------------------
46
+ chmod -R a-w "$repo"
47
+ for g in check-spec-dod-singleton check-amendment-update-target check-amendment-retired-spelling check-spec-fence-balance; do
48
+ out="$(cd "$repo" && container "$BIN" "$g" 2>&1)"; rc=$?
49
+ assert_rc "direct $g" "$rc" 0 "$out"
50
+ done
51
+ # spec: gate-sdk/SPEC.md §The install disposition — the scan root is the adopter's scope: the
52
+ # upstream workflow reds a whole-tree scan, and the owned directory alone passes
53
+ out="$(cd "$repo" && container "$BIN" check-action-pinning 2>&1)"; rc=$?
54
+ assert_rc "root positional, whole tree" "$rc" 1 "$out"
55
+ out="$(cd "$repo" && container "$BIN" check-action-pinning owned 2>&1)"; rc=$?
56
+ assert_rc "root positional, owned" "$rc" 0 "$out"
57
+ out="$(cd "$repo" && container CANON_KIT_KNOB_FILE="$scratch/absent.knobs" "$BIN" check-spec-dod-singleton 2>&1)"; rc=$?
58
+ assert_rc "missing knob file" "$rc" 2 "$out"
59
+ chmod -R u+w "$repo"
60
+ assert_clean direct
61
+
62
+ # a finding is exit 1, and a knob file outside the checkout configures the gate away from it
63
+ printf '# A spec\n\nbody\n' > "$repo/crates/a/SPEC.md"
64
+ out="$(cd "$repo" && container "$BIN" check-spec-dod-singleton 2>&1)"; rc=$?
65
+ assert_rc "finding" "$rc" 1 "$out"
66
+ printf 'CANON_KIT_DOD_MODE = at-most-one\n' > "$scratch/canon.knobs"
67
+ out="$(cd "$repo" && container CANON_KIT_KNOB_FILE="$scratch/canon.knobs" "$BIN" check-spec-dod-singleton 2>&1)"; rc=$?
68
+ assert_rc "knob file outside the checkout" "$rc" 0 "$out"
69
+ git -C "$repo" checkout -q -- crates/a/SPEC.md
70
+
71
+ # a top-level directory holding checks/ reads as a kit root and leaves the scan; the override keeps it in
72
+ mkdir -p "$repo/tools/checks"
73
+ printf '# A tool spec\n\nbody\n' > "$repo/tools/SPEC.md"
74
+ out="$(cd "$repo" && container "$BIN" check-spec-dod-singleton 2>&1)"; rc=$?
75
+ assert_rc "derived kit roots" "$rc" 0 "$out"
76
+ out="$(cd "$repo" && container GATE_SDK_KIT_DIRS=gate-sdk "$BIN" check-spec-dod-singleton 2>&1)"; rc=$?
77
+ assert_rc "kit-dirs override" "$rc" 1 "$out"
78
+ rm -rf "$repo/tools"
79
+
80
+ # a gate that reads history needs a worktree: a retired spelling declared on a tree without git is exit 2
81
+ mkdir -p "$scratch/nogit"
82
+ cp -R "$repo/crates" "$scratch/nogit/"
83
+ printf '# a\n\n## What changes\n\n### (1) x\n\ny\n\n## Retired spellings\n\n- `oldname` — gone (delta 1)\n' > "$scratch/nogit/crates/a/SPEC-x.md"
84
+ out="$(cd "$scratch/nogit" && container "$BIN" check-amendment-retired-spelling 2>&1)"; rc=$?
85
+ assert_rc "no worktree" "$rc" 2 "$out"
86
+
87
+ # ---- a set with a SARIF verdict, through a registry outside the checkout ---------
88
+ gates="$scratch/gates"
89
+ mkdir -p "$gates"
90
+ printf 'check-spec-dod-singleton\ncheck-spec-fence-balance\n' > "$gates/gates.list"
91
+ cp "$SRC/canon-kit/checks/check-spec-dod-singleton.gate" "$SRC/canon-kit/checks/check-spec-fence-balance.gate" "$gates/"
92
+ sarif="$scratch/gates.sarif"
93
+ out="$(cd "$repo" && container GATE_SDK_SARIF_FILE="$sarif" GATE_SDK_TMP_DIR="$scratch/run" "$BIN" --run --gates-dir "$gates" 2>&1)"; rc=$?
94
+ assert_rc "run" "$rc" 0 "$out"
95
+ [[ -s "$sarif" ]] || { echo "FAIL [run]: no SARIF log at $sarif"; fails=$((fails + 1)); }
96
+ assert_clean run
97
+
98
+ # spec: gate-sdk/SPEC.md §The install disposition — a registered member scans from the tree's root, so
99
+ # an action gate is scoped inside the battery by a member of the adopter's own calling the direct form
100
+ printf 'check-action-pinning\n' > "$gates/gates.list"
101
+ cp "$SRC/gate-sdk/checks/check-action-pinning.gate" "$gates/"
102
+ out="$(cd "$repo" && container GATE_SDK_TMP_DIR="$scratch/run" "$BIN" --run --gates-dir "$gates" 2>&1)"; rc=$?
103
+ assert_rc "run, registered action gate" "$rc" 1 "$out"
104
+ { printf '#!/usr/bin/env bash\n'
105
+ printf '# graph: couples=owned dir=one valve=none tier=precommit trigger=owned/*\n'
106
+ printf 'exec %q check-action-pinning owned\n' "$BIN"
107
+ } > "$gates/owned-action-pinning.sh"
108
+ chmod +x "$gates/owned-action-pinning.sh"
109
+ printf 'owned-action-pinning\n' > "$gates/gates.list"
110
+ out="$(cd "$repo" && container GATE_SDK_TMP_DIR="$scratch/run" "$BIN" --run --gates-dir "$gates" 2>&1)"; rc=$?
111
+ assert_rc "run, scoped member" "$rc" 0 "$out"
112
+ assert_clean "run, scoped member"
113
+ printf 'check-spec-dod-singleton\ncheck-spec-fence-balance\n' > "$gates/gates.list"
114
+ rm -f "$gates/owned-action-pinning.sh" "$gates/check-action-pinning.gate"
115
+
116
+ # the descriptor is the registry's: a list naming compiled-in gates with no descriptor beside it resolves nothing
117
+ rm -f "$gates"/*.gate
118
+ out="$(cd "$repo" && container GATE_SDK_TMP_DIR="$scratch/run" "$BIN" --run --gates-dir "$gates" 2>&1)"; rc=$?
119
+ assert_rc "run, no descriptor" "$rc" 1 "$out"
120
+ grep -qF '(unresolved)' <<<"$out" || { echo "FAIL [run, no descriptor]: no member reported unresolved"; printf '%s\n' "$out"; fails=$((fails + 1)); }
121
+ assert_clean "run, no descriptor"
122
+
123
+ [[ "$fails" -eq 0 ]] || { echo "binary-only-recipe.test: $fails assertion(s) failed"; exit 1; }
124
+ echo "binary-only-recipe.test: clean (the direct form's four kit-free gates green on a read-only checkout, a finding at exit 1, a missing knob file and a worktree-less tree at exit 2, the root positional narrowing an action gate's scan to the owned directory, a knob file outside the checkout read, a top-level checks/ directory scanned once GATE_SDK_KIT_DIRS names the kit set, and --run over an out-of-tree registry writing its SARIF log outside a checkout left clean, an action gate scoped there by a member of the adopter's own, its members unresolved once its descriptors are gone)"
125
+ exit 0
@@ -21,4 +21,22 @@ out="$(bash -c '
21
21
  exit 1
22
22
  }
23
23
  [[ "$out" == survived ]] || exit 1
24
- echo 'LIB-TEST-HERMETIC: clean (inherited kit variables cleared, binary kept, library and later pins applied)'
24
+
25
+ hostile="$(mktemp -d)"
26
+ trap 'rm -rf "$hostile"' EXIT
27
+ mkdir -p "$hostile/home/.config/git" "$hostile/plain"
28
+ printf '[core]\n\thooksPath = %s\n' /hostile-system >"$hostile/system.config"
29
+ printf '[core]\n\thooksPath = %s\n' /hostile-global >"$hostile/global.config"
30
+ printf '[core]\n\thooksPath = %s\n' /hostile-home >"$hostile/home/.gitconfig"
31
+ printf '[core]\n\thooksPath = %s\n' /hostile-xdg >"$hostile/home/.config/git/config"
32
+ system=GIT_CONFIG_SYSTEM
33
+ case "${OSTYPE:-}" in msys* | cygwin* | win32*) system=GIT_CONFIG_HOSTILE_UNREAD ;; esac
34
+ leaked="$(env -u GIT_CONFIG_NOSYSTEM "$system=$hostile/system.config" GIT_CONFIG_GLOBAL="$hostile/global.config" \
35
+ HOME="$hostile/home" XDG_CONFIG_HOME="$hostile/home/.config" \
36
+ bash -c 'source "$1"; git -C "$2" config --get-all core.hooksPath' \
37
+ bash "$GATE_SDK_TEST_LIB_DIR/test-hermetic.sh" "$hostile/plain")"
38
+ [[ -z "$leaked" ]] || {
39
+ printf 'FAIL: a sourcing suite read host git config: %s\n' "$leaked"
40
+ exit 1
41
+ }
42
+ echo 'LIB-TEST-HERMETIC: clean (inherited kit variables cleared, binary kept, library and later pins applied, host git config unread)'