block-ci: keep the public-text adapter in step with the module checker

The root adapter carried the v1.1.0 signatures: it passed /home/<user>/
paths and run metadata, and an empty docs/spec/**/recorded-* artifact,
which the module checker refuses. Take the module's pattern and artifact
path check, keep module-relative paths, skip the root adapter's own
pattern when run from the root, and run the module self-test against the
adapter so the two cannot drift.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Chris LuandClaude Opus 5.5 committed 2026-12-05 04:08:59 -08:00
1 parent bb8c969709
commit 3fd8862426
2 files changed
+35 -4

No files matched your search

@@ -123,6 +123,24 @@ class PortTests(unittest.TestCase):
title, body = root / "title.txt", root / "body.txt"
title.write_text("CI scope"); body.write_text("Checker patterns")
self.assertEqual(run("public-text-check.sh", control_head, pattern_head, str(title), str(body)), b"public-text: clean\n")
from_root = subprocess.check_output(["bash", str(HERE / "public-text-check.sh"), control_head, pattern_head, str(title), str(body)], cwd=root, timeout=20)
self.assertEqual(from_root, b"public-text: clean\n")
artifact = module / "docs/spec/recorded-example.txt"
artifact.parent.mkdir(parents=True); artifact.write_text("")
git("add", "."); git("commit", "-m", "artifact")
artifact_head = git("rev-parse", "HEAD").decode().strip()
leak = subprocess.run(["bash", str(HERE / "public-text-check.sh"), pattern_head, artifact_head, str(title), str(body)], cwd=module, capture_output=True, timeout=20)
self.assertEqual(leak.returncode, 1)
self.assertIn(b"artifact path: docs/spec/recorded-example.txt", leak.stdout)
def test_public_text_adapter_passes_the_module_self_test(self):
module = ROOT / "seaweed-block/.github/scripts"
pattern = lambda path: [l for l in path.read_text().splitlines() if l.startswith("pat=")]
self.assertEqual(pattern(HERE / "public-text-check.sh"), pattern(module / "public-text-check.sh"))
with tempfile.TemporaryDirectory() as tmp:
for source in (module / "public-text-check-test.sh", HERE / "public-text-check.sh"):
(Path(tmp) / source.name).write_bytes(source.read_bytes())
subprocess.run(["bash", str(Path(tmp) / "public-text-check-test.sh")], check=True, capture_output=True, timeout=60)
def test_safe_merge_refuses_wrong_head_base_and_incomplete_jobs(self):
+17 -4
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,10 +28,22 @@ 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 --relative --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 --relative --no-color --no-renames -U0 "$mb" "$head" -- . \
':(exclude).github/scripts/public-text-check.sh' ':(exclude).github/scripts/public-text-check-test.sh'
':(exclude).github/scripts/public-text-check.sh' ':(exclude).github/scripts/public-text-check-test.sh' \
':(exclude,top).github/block/scripts/public-text-check.sh'
if [ -n "$(git rev-parse --show-prefix)" ]; then
git -C "$(git rev-parse --show-toplevel)" diff --no-color --no-renames -U0 "$mb" "$head" -- '.github/workflows/block-*.yml' '.github/dockerfiles/block-*.Dockerfile' '.github/block/**' ':(exclude).github/block/scripts/public-text-check.sh'
fi