From 3fd88624268a6feaf47a2f3f205ff7d4d5efa142 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Sat, 5 Dec 2026 04:08:59 -0800 Subject: [PATCH] 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// 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 --- .github/block/scripts/block-ci-port-test.py | 18 ++++++++++++++++++ .github/block/scripts/public-text-check.sh | 21 +++++++++++++++++---- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/.github/block/scripts/block-ci-port-test.py b/.github/block/scripts/block-ci-port-test.py index 4f4633634d..b68427fd15 100644 --- a/.github/block/scripts/block-ci-port-test.py +++ b/.github/block/scripts/block-ci-port-test.py @@ -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): diff --git a/.github/block/scripts/public-text-check.sh b/.github/block/scripts/public-text-check.sh index a9bc036158..b485202dda 100644 --- a/.github/block/scripts/public-text-check.sh +++ b/.github/block/scripts/public-text-check.sh @@ -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