-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-verification.sh
More file actions
181 lines (151 loc) · 4.42 KB
/
Copy pathrun-verification.sh
File metadata and controls
181 lines (151 loc) · 4.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#!/bin/bash
set -euo pipefail
echo "=== Riverbraid Evaluation Kit ==="
REGISTRY_FILE="/evaluator/verified-repo-registry.json"
EXPECTED_FILE="/evaluator/expected-results.json"
RESULTS_FILE="/tmp/riverbraid-actual-results.json"
WORK_ROOT="/tmp/riverbraid-evaluation-workspace"
rm -rf "$WORK_ROOT"
mkdir -p "$WORK_ROOT"
registry_count="$(jq 'length' "$REGISTRY_FILE")"
if [ "$registry_count" -ne 30 ]; then
echo "FAIL: registry must contain exactly 30 entries. Found: $registry_count"
exit 1
fi
unpinned_count="$(jq '[.[] | select(.commit == "UNPINNED" or .commit == "" or .commit == null)] | length' "$REGISTRY_FILE")"
if [ "$unpinned_count" -ne 0 ]; then
echo "FAIL_CLOSED: registry contains unpinned commits."
jq -r '.[] | select(.commit == "UNPINNED" or .commit == "" or .commit == null) | .name' "$REGISTRY_FILE"
exit 1
fi
resolve_verify_command() {
local configured="$1"
if [ "$configured" != "npm test" ]; then
printf '%s\n' "$configured"
return 0
fi
if [ -f package.json ] && jq -e '.scripts.test? // empty' package.json >/dev/null 2>&1; then
printf '%s\n' "npm test"
return 0
fi
if [ -f package.json ] && jq -e '.scripts.verify? // empty' package.json >/dev/null 2>&1; then
printf '%s\n' "npm run verify"
return 0
fi
if [ -f verify.mjs ]; then
printf '%s\n' "node verify.mjs"
return 0
fi
if [ -f run-vectors.cjs ]; then
printf '%s\n' "node run-vectors.cjs verify"
return 0
fi
return 1
}
run_resolved_verify_command() {
local command="$1"
case "$command" in
"npm test")
npm test
;;
"npm run verify")
npm run verify
;;
"npm run test:riverbraid")
npm run test:riverbraid
;;
"npm run verify:feature-flow")
npm run verify:feature-flow
;;
"node verify.mjs")
node verify.mjs
;;
"node run-vectors.cjs verify")
node run-vectors.cjs verify
;;
"test -f README.md")
test -f README.md
;;
*)
echo "FAIL_CLOSED: verifier command is not in the Evaluation Kit allowlist"
echo "resolved_verify_command=$command"
return 1
;;
esac
}
TOTAL=0
PASS=0
FAIL=0
while IFS= read -r entry; do
name="$(echo "$entry" | jq -r '.name')"
url="$(echo "$entry" | jq -r '.url')"
commit="$(echo "$entry" | jq -r '.commit')"
verify_command="$(echo "$entry" | jq -r '.verify_command')"
echo "--- Processing $name ---"
repo_dir="$WORK_ROOT/$name"
if ! git clone --quiet "$url" "$repo_dir"; then
echo "FAIL: clone failed for $name"
FAIL=$((FAIL + 1))
TOTAL=$((TOTAL + 1))
continue
fi
cd "$repo_dir"
if ! git checkout --quiet "$commit"; then
echo "FAIL: checkout failed for $name at $commit"
FAIL=$((FAIL + 1))
TOTAL=$((TOTAL + 1))
continue
fi
actual_commit="$(git rev-parse HEAD)"
if [ "$actual_commit" != "$commit" ]; then
echo "FAIL: commit mismatch for $name"
echo "expected=$commit"
echo "actual=$actual_commit"
FAIL=$((FAIL + 1))
TOTAL=$((TOTAL + 1))
continue
fi
if ! resolved_verify_command="$(resolve_verify_command "$verify_command")"; then
echo "FAIL_CLOSED: no executable verifier command resolved for $name"
echo "configured_verify_command=$verify_command"
FAIL=$((FAIL + 1))
TOTAL=$((TOTAL + 1))
continue
fi
echo "resolved_verify_command=$resolved_verify_command"
if [ -f package-lock.json ]; then
npm ci --silent
elif [ -f package.json ] && [[ "$resolved_verify_command" == npm* ]]; then
npm install --package-lock-only --ignore-scripts --silent
npm ci --silent
fi
if run_resolved_verify_command "$resolved_verify_command"; then
PASS=$((PASS + 1))
else
echo "FAIL: verifier failed for $name"
FAIL=$((FAIL + 1))
fi
TOTAL=$((TOTAL + 1))
done < <(jq -c '.[]' "$REGISTRY_FILE")
jq -n \
--argjson checked "$TOTAL" \
--argjson passing "$PASS" \
--argjson failing "$FAIL" \
'{
riverbraid_reproduction: (if $failing == 0 then "PASS" else "FAIL" end),
registry_checked: $checked,
registry_passing: $passing,
registry_failing: $failing,
external_reproduction: ($failing == 0),
non_claims_preserved: true
}' > "$RESULTS_FILE"
echo "=== Actual Result ==="
jq -S . "$RESULTS_FILE"
echo "=== Expected Result ==="
jq -S . "$EXPECTED_FILE"
if diff -u <(jq -S . "$EXPECTED_FILE") <(jq -S . "$RESULTS_FILE"); then
echo "REPRODUCTION_MATCH"
else
echo "FAIL_CLOSED: reproduction output differs from expected result."
exit 1
fi