ci: reject private run paths and raw model output (#1000)

Merge note (batch b2r; pull_request_target spec-trace workflow has a startup_failure, so its checks run locally):
- One Test run (47177109517) succeeded (go test (linux), process-level tests (real binaries)) on the integration tree f57965f8 = main f2bc730b + #1004 #1000 #995 #1001  in this order; these squash merges reproduce that tree, verified after the last one.
- spec-trace-check.sh and public-text-check.sh, run with main's scripts against this head and body: both exit 0.
- Code review ACCEPT on f0cbee2a: the public-text check now refuses home-directory paths, run-metadata lines and recorded model-run artifacts in added text and added or modified paths; the path enumeration's exit status is checked before its output is used, so a failed listing never reads as clean.
This commit is contained in:
pingqiu-cpu authored and GitHub committed 2026-12-03 11:08:18 -08:00
1 parent 16ba3217bc
commit b92dc1fd68
2 files changed
+60 -3

No files matched your search

+45
View File
@@ -16,6 +16,34 @@ expect() { # expect RC NAME
}
echo "plain line" >> a.txt; git commit -q -am "add a plain line"
expect 0 "clean change" "$mb" HEAD title body
# Synthetic equivalents exercise private-path and run-metadata signatures.
for leaked in \
'Parsing file /home/example/run-1/Example.tla' \
'Synthetic model run with 1 worker on 2 cores with 123MB heap [pid: 12345]' \
'[pid: 12345]' \
'pid=12345' \
'2 cores with 123MB heap'; do
echo "$leaked" >> a.txt; git commit -q -am "model output"
expect 1 "raw run metadata in added text" "$mb" HEAD title body
git reset -q --hard HEAD~1
done
echo '/home/example/run-1' > body
expect 1 "home path in description" "$mb" HEAD title body; : > body
echo 'docs/spec/example/recorded-example/RESULT.txt' > body
expect 1 "artifact reference in description" "$mb" HEAD title body; : > body
echo '[pid: 12345]' > title
expect 1 "run metadata in title" "$mb" HEAD title body; : > title
for artifact in docs/spec/example/recorded-example/RESULT.txt docs/spec/recorded-example.txt; do
mkdir -p "$(dirname "$artifact")"; echo 'all checks passed' > "$artifact"
git add "$artifact"; git commit -q -m "add model artifact"
expect 1 "artifact path even with clean contents" "$mb" HEAD title body
artifact_base=$(git rev-parse HEAD)
git rm -q "$artifact"; git commit -q -m "remove model artifact"
expect 0 "artifact removal is allowed" "$artifact_base" HEAD title body
git reset -q --hard HEAD~2
done
echo 'Model workers execute in parallel; heap limits and PID namespaces are documented.' > body
expect 0 "ordinary explanatory prose" "$mb" HEAD title body; : > body
seat="clau""de06"; path="V:/sha""re/x"; nas="share/rd""ma/y"
echo "// asked by $seat" >> a.txt; git commit -q -am "comment"
expect 1 "seat name in an added line" "$mb" HEAD title body
@@ -41,6 +69,23 @@ expect 1 "backslash form of the share path in the title" "$mb2" HEAD title body;
expect 2 "a missing title file is an error, not clean" "$mb2" HEAD no-such-title body
expect 2 "a missing description file is an error, not clean" "$mb2" HEAD title no-such-body
expect 2 "an unknown commit is an error, not clean" 0000000000000000000000000000000000000000 HEAD title body
# Only the NUL-separated artifact enumeration fails, after partial output;
# every other git call delegates to the real executable.
real_git=$(command -v git)
mkdir -p fakegit
cat > fakegit/git <<'EOF'
#!/usr/bin/env bash
if [[ $1 == diff && ${2:-} == --name-only && ${3:-} == -z ]]; then
printf 'docs/spec/clean.txt\0'
exit 7
fi
exec "$PUBLIC_TEXT_REAL_GIT" "$@"
EOF
chmod +x fakegit/git
rc=0
PUBLIC_TEXT_REAL_GIT="$real_git" PATH="$PWD/fakegit:$PATH" bash "$here/public-text-check.sh" "$mb2" HEAD title body >out 2>&1 || rc=$?
[ "$rc" = 2 ] || { echo "public-text-check-test: failed artifact enumeration: exit $rc, want 2"; cat out; exit 1; }
if grep -q 'public-text: clean' out; then echo 'public-text-check-test: failed artifact enumeration printed clean'; cat out; exit 1; fi
# A grep that fails (exit 2) is an error: the check must refuse and never print "clean".
mkdir -p fakebin; printf '#!/bin/sh
exit 2
+15 -3
View File
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
# Refuses internal names in what a pull request makes public: the lines it
# adds, its commit messages, its title and its description. This repository is
# public; internal seat names and internal file-share paths do not belong in it.
# public; internal names, machine paths and raw run artifacts do not belong in it.
#
# Usage: public-text-check.sh MERGE_BASE HEAD TITLE_FILE BODY_FILE
# Exit 0: clean. Exit 1: at least one hit (each printed). Exit 2: usage.
@@ -18,8 +18,9 @@ git rev-parse -q --verify "$mb^{commit}" >/dev/null && git rev-parse -q --verify
{ echo "public-text: unknown commit $mb or $head" >&2; exit 2; }
# match: a grep error fails the check instead of reading as "no hit".
match() { local rc=0; grep -E -i -- "$pat" "$@" || rc=$?; [ "$rc" -le 1 ] || { echo "public-text: grep failed ($rc)" >&2; exit 2; }; }
pat='(claude|codex)0[0-9]|share[/\]rdma|V:[/\]share|diskstation'
out=$(mktemp); trap 'rm -f "$out"' EXIT
pat='(claude|codex)0[0-9]|share[/\]rdma|V:[/\]share|diskstation|/home/[^/[:space:]]+/|(^|[^[:alnum:]_])pid[[:space:]]*[:=][[:space:]]*[0-9]+|[0-9]+[[:space:]]+cores[[:space:]]+with[[:space:]]+[0-9]+([.][0-9]+)?[[:space:]]*(KB|MB|GB|KiB|MiB|GiB)?[[:space:]]+heap|docs/spec/([^/[:space:]]+/)*recorded-[^/[:space:]]+'
out=$(mktemp); paths=; trap 'rm -f "$out" "$paths"' EXIT
paths=$(mktemp)
report() { # report WHERE < matching lines
local where=$1 line
while IFS= read -r line; do
@@ -27,6 +28,17 @@ report() { # report WHERE < matching lines
' "$where" "${line:0:160}" >>"$out"
done
}
# Raw run artifacts are not public specs, even with scrubbed contents.
# Allow deletions so existing artifacts can be removed.
if ! git diff --name-only -z --no-renames --diff-filter=ACMT "$mb" "$head" -- docs/spec/ >"$paths"; then
echo 'public-text: cannot enumerate artifact paths' >&2
exit 2
fi
while IFS= read -r -d '' path; do
if [[ $path =~ ^docs/spec/(.*/)?recorded-[^/]+(/|$) ]]; then
printf '%s\n' "$path" | report "artifact path"
fi
done <"$paths"
# Added lines of the diff, with file and line number.
git diff --no-color --no-renames -U0 "$mb" "$head" -- . \
':(exclude).github/scripts/public-text-check.sh' ':(exclude).github/scripts/public-text-check-test.sh' |