checkwright 0.35.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 (113) hide show
  1. package/README.md +3 -0
  2. package/package.json +2 -2
  3. package/payload/artifact/aarch64-apple-darwin/checkwright-gates +0 -0
  4. package/payload/artifact/aarch64-apple-darwin/checkwright-gates.sha256 +1 -1
  5. package/payload/artifact/aarch64-pc-windows-msvc/checkwright-gates.exe +0 -0
  6. package/payload/artifact/aarch64-pc-windows-msvc/checkwright-gates.exe.sha256 +1 -1
  7. package/payload/artifact/aarch64-unknown-linux-gnu/checkwright-gates +0 -0
  8. package/payload/artifact/aarch64-unknown-linux-gnu/checkwright-gates.sha256 +1 -1
  9. package/payload/artifact/aarch64-unknown-linux-musl/checkwright-gates +0 -0
  10. package/payload/artifact/aarch64-unknown-linux-musl/checkwright-gates.sha256 +1 -1
  11. package/payload/artifact/x86_64-apple-darwin/checkwright-gates +0 -0
  12. package/payload/artifact/x86_64-apple-darwin/checkwright-gates.sha256 +1 -1
  13. package/payload/artifact/x86_64-pc-windows-msvc/checkwright-gates.exe +0 -0
  14. package/payload/artifact/x86_64-pc-windows-msvc/checkwright-gates.exe.sha256 +1 -1
  15. package/payload/artifact/x86_64-unknown-linux-gnu/checkwright-gates +0 -0
  16. package/payload/artifact/x86_64-unknown-linux-gnu/checkwright-gates.sha256 +1 -1
  17. package/payload/artifact/x86_64-unknown-linux-musl/checkwright-gates +0 -0
  18. package/payload/artifact/x86_64-unknown-linux-musl/checkwright-gates.sha256 +1 -1
  19. package/payload/canon-kit/README.md +1 -0
  20. package/payload/canon-kit/checks/check-comment-tier.gate +1 -1
  21. package/payload/canon-kit/checks/check-rule-id-coverage.gate +4 -0
  22. package/payload/canon-kit/gate-tests/check-amendment-queue.test.sh +39 -0
  23. package/payload/canon-kit/gate-tests/check-comment-tier/bad/expect.txt +1 -0
  24. package/payload/canon-kit/gate-tests/check-comment-tier/bad/lib/rules.rs +5 -0
  25. package/payload/canon-kit/gate-tests/check-comment-tier/bad/scripts/canon-config.knobs +5 -0
  26. package/payload/canon-kit/gate-tests/check-comment-tier/good/expect.txt +1 -1
  27. package/payload/canon-kit/gate-tests/check-comment-tier/good/good.rs +1 -0
  28. package/payload/canon-kit/gate-tests/check-comment-tier/good/scripts/canon-config.knobs +5 -0
  29. package/payload/canon-kit/gate-tests/check-comment-tier/good/src/rules.rs +5 -0
  30. package/payload/canon-kit/gate-tests/check-rule-id-coverage/bad/expect.txt +3 -0
  31. package/payload/canon-kit/gate-tests/check-rule-id-coverage/bad/scripts/canon-config.knobs +5 -0
  32. package/payload/canon-kit/gate-tests/check-rule-id-coverage/bad/specs/access.md +7 -0
  33. package/payload/canon-kit/gate-tests/check-rule-id-coverage/bad/specs/export.md +3 -0
  34. package/payload/canon-kit/gate-tests/check-rule-id-coverage/bad/src/rules.rs +5 -0
  35. package/payload/canon-kit/gate-tests/check-rule-id-coverage/good/expect.txt +1 -0
  36. package/payload/canon-kit/gate-tests/check-rule-id-coverage/good/scripts/canon-config.knobs +7 -0
  37. package/payload/canon-kit/gate-tests/check-rule-id-coverage/good/specs/access.md +9 -0
  38. package/payload/canon-kit/gate-tests/check-rule-id-coverage/good/specs/export.md +3 -0
  39. package/payload/canon-kit/gate-tests/check-rule-id-coverage/good/src/rules.rs +7 -0
  40. package/payload/canon-kit/gate-tests/check-unmarked-claim.test.sh +2 -2
  41. package/payload/context-kit/gate-tests/check-settings-paths/bad/expect.txt +5 -0
  42. package/payload/context-kit/gate-tests/check-settings-paths/bad/settings.json +35 -0
  43. package/payload/context-kit/gate-tests/check-settings-paths/good/expect.txt +2 -2
  44. package/payload/context-kit/gate-tests/check-settings-paths/good/settings.json +26 -0
  45. package/payload/delegation-kit/README.md +1 -1
  46. package/payload/delegation-kit/usage-tests/cases.tsv +13 -0
  47. package/payload/doctrine-kit/DOCTRINE.md +1 -1
  48. package/payload/evidence-kit/README.md +8 -5
  49. package/payload/evidence-kit/checks/check-test-control.gate +4 -0
  50. package/payload/evidence-kit/gate-tests/check-evidence-manifest/bad/validate-evidence.txt +2 -2
  51. package/payload/evidence-kit/gate-tests/check-evidence-manifest/good/validate-evidence.txt +2 -2
  52. package/payload/evidence-kit/gate-tests/check-evidence-manifest.test.sh +56 -7
  53. package/payload/evidence-kit/gate-tests/check-test-control/bad/TASK-QUEUE.md +1 -0
  54. package/payload/evidence-kit/gate-tests/check-test-control/bad/WORKFLOW-STATE.txt +4 -0
  55. package/payload/evidence-kit/gate-tests/check-test-control/bad/args +5 -0
  56. package/payload/evidence-kit/gate-tests/check-test-control/bad/expect.txt +2 -0
  57. package/payload/evidence-kit/gate-tests/check-test-control/bad/scripts/evidence-config.knobs +4 -0
  58. package/payload/evidence-kit/gate-tests/check-test-control/bad/since-baseline.txt +2 -0
  59. package/payload/evidence-kit/gate-tests/check-test-control/bad/validate-baseline.txt +4 -0
  60. package/payload/evidence-kit/gate-tests/check-test-control/bad/validate-evidence.txt +3 -0
  61. package/payload/evidence-kit/gate-tests/check-test-control/good/TASK-QUEUE.md +1 -0
  62. package/payload/evidence-kit/gate-tests/check-test-control/good/WORKFLOW-STATE.txt +4 -0
  63. package/payload/evidence-kit/gate-tests/check-test-control/good/args +5 -0
  64. package/payload/evidence-kit/gate-tests/check-test-control/good/expect.txt +1 -0
  65. package/payload/evidence-kit/gate-tests/check-test-control/good/scripts/evidence-config.knobs +4 -0
  66. package/payload/evidence-kit/gate-tests/check-test-control/good/since-baseline.txt +2 -0
  67. package/payload/evidence-kit/gate-tests/check-test-control/good/validate-baseline.txt +3 -0
  68. package/payload/evidence-kit/gate-tests/check-test-control/good/validate-evidence.txt +3 -0
  69. package/payload/evidence-kit/gate-tests/check-test-control.test.sh +121 -0
  70. package/payload/evidence-kit/gate-tests/pre-hook.test.sh +18 -2
  71. package/payload/evidence-kit/gate-tests/producer-lock.test.sh +1 -1
  72. package/payload/evidence-kit/gate-tests/run-member-door.test.sh +1 -1
  73. package/payload/evidence-kit/gate-tests/statement-store.test.sh +64 -0
  74. package/payload/evidence-kit/gate-tests/test-control-run.test.sh +91 -0
  75. package/payload/evidence-kit/gate-tests/verify-gate-run-strict.test.sh +121 -0
  76. package/payload/evidence-kit/templates/evidence-config.knobs +7 -0
  77. package/payload/gate-sdk/README.md +1 -0
  78. package/payload/gate-sdk/checks/check-hook-knobs-fresh.gate +5 -0
  79. package/payload/gate-sdk/gate-tests/binary-only-recipe.test.sh +125 -0
  80. package/payload/gate-sdk/gate-tests/check-enforcement-fresh/good/docs/enforcement.md +1 -0
  81. package/payload/gate-sdk/gate-tests/check-hook-knobs-fresh/bad/args +2 -0
  82. package/payload/gate-sdk/gate-tests/check-hook-knobs-fresh/bad/expect.txt +5 -0
  83. package/payload/gate-sdk/gate-tests/check-hook-knobs-fresh/bad/hooks/not-a-hook.md +4 -0
  84. package/payload/gate-sdk/gate-tests/check-hook-knobs-fresh/bad/hooks/shell-guard.md +3 -0
  85. package/payload/gate-sdk/gate-tests/check-hook-knobs-fresh/bad/hooks/subagent-stop-liveness.md +12 -0
  86. package/payload/gate-sdk/gate-tests/check-hook-knobs-fresh/good/args +2 -0
  87. package/payload/gate-sdk/gate-tests/check-hook-knobs-fresh/good/expect.txt +1 -0
  88. package/payload/gate-sdk/gate-tests/check-hook-knobs-fresh/good/hooks/subagent-stop-liveness.md +16 -0
  89. package/payload/gate-sdk/gate-tests/lib-test-hermetic.test.sh +19 -1
  90. package/payload/gate-sdk/gate-tests/run-for-path.test.sh +16 -1
  91. package/payload/gate-sdk/lib/test-hermetic.sh +6 -1
  92. package/payload/guard-kit/gate-tests/git-mutation-under-producer.test.sh +11 -1
  93. package/payload/lifecycle-kit/README.md +4 -0
  94. package/payload/lifecycle-kit/gate-tests/check-survey-record.test.sh +1 -1
  95. package/payload/lifecycle-kit/gate-tests/peer-channel.test.sh +150 -0
  96. package/payload/lifecycle-kit/templates/stages/close.md +2 -2
  97. package/payload/lifecycle-kit/templates/stages/scope.md +2 -0
  98. package/payload/lifecycle-kit/templates/stages/validate.md +1 -1
  99. package/payload/queue-kit/gate-tests/roadmap.test.sh +1 -1
  100. package/payload/site-kit/README.md +3 -0
  101. package/payload/site-kit/checks/check-docs-since.gate +4 -0
  102. package/payload/site-kit/gate-tests/check-docs-since/bad/expect.txt +6 -0
  103. package/payload/site-kit/gate-tests/check-docs-since/bad/notes/2026-01-01-v99-1-0.md +7 -0
  104. package/payload/site-kit/gate-tests/check-docs-since/bad/scripts/site-config.knobs +3 -0
  105. package/payload/site-kit/gate-tests/check-docs-since/bad/site/bare.md +7 -0
  106. package/payload/site-kit/gate-tests/check-docs-since/bad/site/odd.md +8 -0
  107. package/payload/site-kit/gate-tests/check-docs-since/bad/site/open.md +8 -0
  108. package/payload/site-kit/gate-tests/check-docs-since/bad/site/twice.md +9 -0
  109. package/payload/site-kit/gate-tests/check-docs-since/good/expect.txt +1 -0
  110. package/payload/site-kit/gate-tests/check-docs-since/good/notes/announce.md +3 -0
  111. package/payload/site-kit/gate-tests/check-docs-since/good/scripts/site-config.knobs +3 -0
  112. package/payload/site-kit/gate-tests/check-docs-since/good/site/done.md +8 -0
  113. package/payload/site-kit/gate-tests/check-docs-since/good/site/open.md +8 -0
@@ -3,7 +3,9 @@
3
3
  # assertions the one good/bad pair (grammar) cannot hold: (C) a validate stamp
4
4
  # demands ≥1 evidence line, disarmed while the cursor is still at validate and
5
5
  # re-armed past it; (A) a close-entry cursor demands the full green block over
6
- # every configured suite; and both no-cursor disarms.
6
+ # every configured suite, imported lines included; both no-cursor disarms; and
7
+ # (B) per major: each v2 field and line kind, a line under the other major's
8
+ # header, a green v1 file and an unknown major.
7
9
  #
8
10
  # The cursor is the state file's last data line, so every case
9
11
  # below drives the stage axis from <state-body> and the header carries the name
@@ -21,11 +23,17 @@ fails=0
21
23
  tmp="$(mktemp -d)"
22
24
  trap 'rm -rf "$tmp"' EXIT
23
25
 
26
+ # The v2 suite line's four appended fields, for a line otherwise spelled at v1's eight.
27
+ COMMIT=0123456789abcdef0123456789abcdef01234567
28
+ TAIL=" commit=$COMMIT tree=clean cmd=$HASH origin=local"
29
+ MAJOR=v2
30
+
24
31
  # case_run <name> <manifest-body> <header> <state-body> <suites> <want> <expect>
32
+ # (the manifest header's major is $MAJOR)
25
33
  case_run() {
26
34
  local name="$1" man="$2" hdr="$3" state="$4" suites="$5" want="$6" expect="$7"
27
35
  local d="$tmp/$name" out rc; mkdir -p "$d/scripts"
28
- printf '# contract: evidence-manifest v1\n%b' "$man" >"$d/man.txt"
36
+ printf '# contract: evidence-manifest %s\n%b' "$MAJOR" "$man" >"$d/man.txt"
29
37
  printf '%s\n' "$hdr" >"$d/queue.md"
30
38
  printf '%b' "$state" >"$d/state.txt"
31
39
  # shellcheck disable=SC2086 # one element line per space-separated suite
@@ -58,7 +66,7 @@ case_run "C-disarmed-at-validate" \
58
66
  # C — close entry with one of two configured suites missing its clean line:
59
67
  # assertion A fires for the missing suite.
60
68
  case_run "A-missing-suite" \
61
- "it unit sha256=$HASH pass=1 fail=0 ignore=0 verdict=clean 2026-07-06\n" \
69
+ "it unit sha256=$HASH pass=1 fail=0 ignore=0 verdict=clean 2026-07-06$TAIL\n" \
62
70
  '## Iteration: it' \
63
71
  'h\n---\nit validate s2 2026-07-05\nit close s3 2026-07-06\n' 'unit extra' \
64
72
  1 "no clean evidence line"
@@ -66,18 +74,59 @@ case_run "A-missing-suite" \
66
74
  # D — close entry with both suites clean and dated after the validate stamp is
67
75
  # CLEAN (the full green block).
68
76
  case_run "A-green-block" \
69
- "it unit sha256=$HASH pass=1 fail=0 ignore=0 verdict=clean 2026-07-06\nit extra sha256=$HASH pass=2 fail=0 ignore=0 verdict=clean 2026-07-06\n" \
77
+ "it unit sha256=$HASH pass=1 fail=0 ignore=0 verdict=clean 2026-07-06$TAIL\nit extra sha256=$HASH pass=2 fail=0 ignore=0 verdict=clean 2026-07-06$TAIL\n" \
70
78
  '## Iteration: it' \
71
79
  'h\n---\nit validate s2 2026-07-05\nit close s3 2026-07-06\n' 'unit extra' \
72
80
  0 "clean"
73
81
 
74
82
  # E — a clean line dated BEFORE the earliest validate stamp is stale evidence.
75
83
  case_run "A-stale-date" \
76
- "it unit sha256=$HASH pass=1 fail=0 ignore=0 verdict=clean 2026-07-01\n" \
84
+ "it unit sha256=$HASH pass=1 fail=0 ignore=0 verdict=clean 2026-07-01$TAIL\n" \
77
85
  '## Iteration: it' \
78
86
  'h\n---\nit validate s2 2026-07-05\nit close s3 2026-07-06\n' 'unit' \
79
87
  1 "before the earliest validate stamp"
80
88
 
89
+ # E2 — an imported clean line satisfies the close-entry block like a local one.
90
+ case_run "A-imported-line" \
91
+ "it unit sha256=$HASH pass=1 fail=0 ignore=0 verdict=clean 2026-07-06${TAIL/origin=local/origin=imported}\n" \
92
+ '## Iteration: it' \
93
+ 'h\n---\nit validate s2 2026-07-05\nit close s3 2026-07-06\n' 'unit' \
94
+ 0 "clean"
95
+
96
+ # B — the grammar of each major. A v2 header reds an unknown third field and each
97
+ # malformed appended field; the stage cursor is disarmed so only (B) speaks.
98
+ V1LINE="it unit sha256=$HASH pass=1 fail=0 ignore=0 verdict=clean 2026-07-06"
99
+ case_run "B-unknown-kind" "it unit mutant=x pass=1 fail=0 ignore=0 verdict=clean 2026-07-06$TAIL\n" \
100
+ '## Iteration: it' 'h\n---\n' '' 1 "unknown line kind"
101
+ case_run "B-v1-line-under-v2" "$V1LINE\n" '## Iteration: it' 'h\n---\n' '' 1 "malformed line"
102
+ case_run "B-bad-commit" "$V1LINE${TAIL/commit=$COMMIT/commit=ABC}\n" \
103
+ '## Iteration: it' 'h\n---\n' '' 1 "bad commit field"
104
+ case_run "B-bad-tree" "$V1LINE${TAIL/tree=clean/tree=-}\n" \
105
+ '## Iteration: it' 'h\n---\n' '' 1 "bad tree field"
106
+ case_run "B-bad-cmd" "$V1LINE${TAIL/cmd=$HASH/cmd=xyz}\n" \
107
+ '## Iteration: it' 'h\n---\n' '' 1 "bad cmd field"
108
+ case_run "B-bad-origin" "$V1LINE${TAIL/origin=local/origin=ci}\n" \
109
+ '## Iteration: it' 'h\n---\n' '' 1 "bad origin field"
110
+ case_run "B-unborn" "$V1LINE commit=- tree=- cmd=$HASH origin=local\n" \
111
+ '## Iteration: it' 'h\n---\n' '' 0 "clean"
112
+ # A control line is v2's second kind: green under its suite line, red with none above it, red
113
+ # on a witness outside red|green|absent, and red at eight fields, its assign= dropped.
114
+ CTLLINE="it unit control=c scenario=t witnessed=red 2026-07-06 commit=$COMMIT cmd=$HASH assign=$HASH"
115
+ case_run "B-control-under-suite" "$V1LINE$TAIL\n$CTLLINE\n" '## Iteration: it' 'h\n---\n' '' 0 "clean"
116
+ case_run "B-control-no-suite" "$CTLLINE\n$V1LINE$TAIL\n" \
117
+ '## Iteration: it' 'h\n---\n' '' 1 "control line with no 'it unit' suite line above it"
118
+ case_run "B-control-bad-witness" "$V1LINE$TAIL\n${CTLLINE/witnessed=red/witnessed=pink}\n" \
119
+ '## Iteration: it' 'h\n---\n' '' 1 "bad witnessed field"
120
+ case_run "B-control-eight-fields" "$V1LINE$TAIL\n${CTLLINE% assign=*}\n" \
121
+ '## Iteration: it' 'h\n---\n' '' 1 "malformed control line"
122
+ # A v1 file whose lines are v1 stays green; a v2 line under a v1 header is red.
123
+ MAJOR=v1
124
+ case_run "B-v1-file" "$V1LINE\n" '## Iteration: it' 'h\n---\n' '' 0 "clean"
125
+ case_run "B-v2-line-under-v1" "$V1LINE$TAIL\n" '## Iteration: it' 'h\n---\n' '' 1 "malformed line"
126
+ MAJOR=v3
127
+ case_run "B-unknown-major" "" '## Iteration: it' 'h\n---\n' '' 1 "not a versioned wire-format header"
128
+ MAJOR=v2
129
+
81
130
  # F — the no-cursor window /scope leaves at the iteration boundary: the state
82
131
  # file exists but is truncated to its preamble + '---', so there is no data
83
132
  # line to read a stage from. A and C must disarm at the gate's DECLARED
@@ -94,7 +143,7 @@ case_run "no-cursor-window" \
94
143
  # G — no lifecycle state file at all: the second no-cursor shape, same early-out.
95
144
  _no_state() {
96
145
  local d="$tmp/nostate"; mkdir -p "$d"
97
- printf '# contract: evidence-manifest v1\n' >"$d/man.txt"
146
+ printf '# contract: evidence-manifest v2\n' >"$d/man.txt"
98
147
  printf '## Iteration: it\n' >"$d/queue.md"
99
148
  gate_run check-evidence-manifest "$CHECKS" "$d/man.txt" "$d/queue.md" "$d/absent-state.txt" 2>&1
100
149
  }
@@ -106,5 +155,5 @@ if [[ "$fails" -gt 0 ]]; then
106
155
  echo "check-evidence-manifest.test: $fails assertion(s) failed"
107
156
  exit 1
108
157
  fi
109
- echo "check-evidence-manifest.test: ok (C recorded-nothing + A missing-suite + A stale-date rejected; C disarmed-at-validate + A green-block + both no-cursor shapes accepted)"
158
+ echo "check-evidence-manifest.test: ok (C recorded-nothing + A missing-suite + A stale-date + each v2 field and kind + a cross-major line + an unknown major rejected; C disarmed-at-validate + A green-block + A imported + a v1 file + an unborn line + both no-cursor shapes accepted)"
110
159
  exit 0
@@ -0,0 +1 @@
1
+ ## Iteration: demo-iter
@@ -0,0 +1,4 @@
1
+ fixture state header
2
+ ---
3
+ demo-iter validate s1 2026-07-02 none
4
+ demo-iter close s1 2026-07-03 none
@@ -0,0 +1,5 @@
1
+ validate-baseline.txt
2
+ since-baseline.txt
3
+ validate-evidence.txt
4
+ TASK-QUEUE.md
5
+ WORKFLOW-STATE.txt
@@ -0,0 +1,2 @@
1
+ new test 'unit t_new'
2
+ control 'nullguard' witnessed=green
@@ -0,0 +1,4 @@
1
+ # spec: evidence-kit/SPEC.md §check-test-control — one suite and one declared control, so all three assertions are armed
2
+ EVIDENCE_KIT_SUITES[] = unit
3
+ EVIDENCE_KIT_CONTROLS[] = nullguard
4
+ EVIDENCE_KIT_CONTROL_nullguard = unit t_null BREAK_NULL=1
@@ -0,0 +1,2 @@
1
+ # fixture baseline at the since commit
2
+ unit t_old pass
@@ -0,0 +1,4 @@
1
+ # fixture baseline
2
+ unit t_old pass
3
+ unit t_null pass
4
+ unit t_new pass
@@ -0,0 +1,3 @@
1
+ # contract: evidence-manifest v2
2
+ demo-iter unit sha256=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa pass=2 fail=0 ignore=0 verdict=clean 2026-07-02 commit=- tree=- cmd=bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb origin=local
3
+ demo-iter unit control=nullguard scenario=t_null witnessed=green 2026-07-02 commit=- cmd=bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb assign=ffc2bf120f95ff83431fa8cb7d89902ed9cdf9a3c62dd02a78a7fc2c0d3d2ff3
@@ -0,0 +1 @@
1
+ ## Iteration: demo-iter
@@ -0,0 +1,4 @@
1
+ fixture state header
2
+ ---
3
+ demo-iter validate s1 2026-07-02 none
4
+ demo-iter close s1 2026-07-03 none
@@ -0,0 +1,5 @@
1
+ validate-baseline.txt
2
+ since-baseline.txt
3
+ validate-evidence.txt
4
+ TASK-QUEUE.md
5
+ WORKFLOW-STATE.txt
@@ -0,0 +1,4 @@
1
+ # spec: evidence-kit/SPEC.md §check-test-control — one suite and one declared control, so all three assertions are armed
2
+ EVIDENCE_KIT_SUITES[] = unit
3
+ EVIDENCE_KIT_CONTROLS[] = nullguard
4
+ EVIDENCE_KIT_CONTROL_nullguard = unit t_null BREAK_NULL=1
@@ -0,0 +1,2 @@
1
+ # fixture baseline at the since commit
2
+ unit t_old pass
@@ -0,0 +1,3 @@
1
+ # fixture baseline
2
+ unit t_old pass
3
+ unit t_null pass
@@ -0,0 +1,3 @@
1
+ # contract: evidence-manifest v2
2
+ demo-iter unit sha256=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa pass=2 fail=0 ignore=0 verdict=clean 2026-07-02 commit=- tree=- cmd=bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb origin=local
3
+ demo-iter unit control=nullguard scenario=t_null witnessed=red 2026-07-02 commit=- cmd=bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb assign=ffc2bf120f95ff83431fa8cb7d89902ed9cdf9a3c62dd02a78a7fc2c0d3d2ff3
@@ -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