From d64c787248cc8b9abbab4156ba53deff3fc03e58 Mon Sep 17 00:00:00 2001 From: bong-water-water-bong Date: Sun, 8 Nov 2026 19:02:59 -0400 Subject: [PATCH 1/2] gitignore: stop the HRX probe run logs being added, and pin what the copyright gate reads engine#1564 reports `tools/copyright.py --check` red in a developer clone on `.hrx123/logs/*.jsonl` while a clean checkout of main is green. Measured here before changing anything, and the premise needs one correction that matters for the fix: those files are in the gate's view because the gate lists `git ls-files` **plus** `--others --exclude-standard`, and nothing ignored `.hrx123/`. One clone also has 468 of them *tracked* (a local commit made by a `git add -A`), which `.gitignore` cannot fix for that clone -- `git rm -r --cached .hrx123` does. So, from main: - `.gitignore` gains `.hrx123/` with the reason: the probe tools write run logs there, they are output and not source, and until now nothing stopped a sweep from adding them. - `tests/copyright_gate_test.sh` (CTest `copyright_gate`) pins the three states the gate can be asked about, because this is the second time tonight its enumeration surprised someone: a **staged** file without a notice is red, an **untracked and unignored** file is red (that is the state a new file is in before `git add`, and why running the check in a clone is useful), and an **ignored** file is not seen at all. The test builds a throwaway repo in a temp dir, so it needs no build and no device, and its last arm reproduces #1564 exactly: the same output file is reported once nothing ignores it. Two things the work turned up, both recorded in the test's comments: the checks had to capture the gate's output rather than pipe it (`gate | grep -q` closes the pipe early and, under `pipefail`, reports the gate's SIGPIPE as a failure -- my first version did exactly that), and this file's own notice sits three lines inside the 20-line window, so any docstring growth in `tools/copyright.py` reds the gate on the file that defines it. Fixes #1564 --- CMakeLists.txt | 3 ++ tests/copyright_gate_test.sh | 84 ++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100755 tests/copyright_gate_test.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 0d8a5f29f..b7bcef470 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -246,6 +246,9 @@ add_test(NAME release_check_row COMMAND ${CMAKE_SOURCE_DIR}/os/mini/release-chec # the handoff driver must not orphan its server on SIGKILL (PR_SET_PDEATHSIG); no GPU, no model add_test(NAME kvshare_orphan COMMAND ${CMAKE_SOURCE_DIR}/tests/kvshare_orphan_test.sh) add_test(NAME seal_manifest COMMAND ${CMAKE_SOURCE_DIR}/tests/seal_manifest_test.sh) +# engine#1564: which files the copyright gate looks at -- a staged file is seen, an untracked one is seen (that is why +# running it before `git add` is useful), an ignored one is not. A throwaway repo in a temp dir: no build, no device. +add_test(NAME copyright_gate COMMAND ${CMAKE_SOURCE_DIR}/tests/copyright_gate_test.sh) # engine #1279: the version a package is built with (scripts/pack-version.sh) -- a release tag as # it stands, a candidate mapped into the ISO week of its own date with a suffix that sorts below that # release, and the ordering a candidate needs: previous release < candidate < its release. The diff --git a/tests/copyright_gate_test.sh b/tests/copyright_gate_test.sh new file mode 100755 index 000000000..74676a5ce --- /dev/null +++ b/tests/copyright_gate_test.sh @@ -0,0 +1,84 @@ +#!/usr/bin/env bash +# Copyright 2026 bong-water-water-bong +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Which files `tools/copyright.py` looks at, pinned (engine#1564). +# +# The gate reads `git ls-files` plus the files git would add (`--others --exclude-standard`), so its verdict depends on +# three states a developer actually meets, and only two of them are about the repository: +# - a staged file without a notice -> RED (it is about to be committed), +# - an untracked, non-ignored file -> RED (this is the state a new file is in before `git add`; it is why the +# check is useful in a working clone at all), +# - an ignored file -> not seen at all, +# which is the case #1564 hit from the other direction: run logs under a directory nothing ignored were untracked and +# therefore RED in a developer clone, while a clean checkout of main was green. The fix was to ignore the output +# directory; this test keeps the three states apart so a future `--check` complaint can be attributed in one look. +# +# usage: tests/copyright_gate_test.sh (no build, no device: a throwaway git repo in a temp dir) +set -uo pipefail + +root=$(cd "$(dirname "$0")/.." && pwd) +tmp=$(mktemp -d) +trap 'rm -rf "$tmp"' EXIT +fail=0 +check() { if eval "$2"; then echo "ok $1"; else echo "FAIL $1"; [ -n "${3:-}" ] && echo " $3"; fail=1; fi; } + +git -C "$tmp" init -q +git -C "$tmp" config user.email t@example.com +git -C "$tmp" config user.name t +cp "$root/tools/copyright.py" "$tmp/copyright.py" +# a committed file with the notice, and an ignore rule for the output directory +python3 - "$tmp" <<'PY' +import sys +d = sys.argv[1] +notice = open(d + "/copyright.py", encoding="utf-8").read().split('NOTICE = """')[1].split('""".split')[0] +open(d + "/noticed.py", "w", encoding="utf-8").write("# " + notice.replace("\n", "\n# ") + "\n") +# .gitignore is checked too (it is in LINE_STYLES), so the fixture's own ignore file carries the notice +open(d + "/.gitignore", "w", encoding="utf-8").write("# " + notice.replace("\n", "\n# ") + "\nrun-output/\n") +PY +git -C "$tmp" add noticed.py .gitignore copyright.py +git -C "$tmp" commit -qm base + +# captured into a variable, never piped: `gate | grep -q` would make grep close the pipe early and, with pipefail, +# report the gate's SIGPIPE instead of its verdict +gate() { ( cd "$tmp" && python3 copyright.py --check 2>&1 ); } +gate_has() { case "$(gate)" in *"$1"*) return 0;; *) return 1;; esac; } + +# 1. a committed tree with the notice is green +check "a tree whose files carry the notice passes" "[ $(gate >/dev/null; echo $?) -eq 0 ]" "$(gate)" + +# 2. a staged file without the notice is RED -- the case that makes the gate worth running in a clone +printf 'x = 1\n' > "$tmp/staged.py" +git -C "$tmp" add staged.py +check "a STAGED file without the notice is reported" "gate_has 'missing copyright notice: staged.py'" "$(gate)" +git -C "$tmp" reset -q staged.py && rm -f "$tmp/staged.py" + +# 3. an untracked, non-ignored file is RED too -- a new file before `git add`, which `git ls-files` alone cannot see +printf 'y = 2\n' > "$tmp/fresh.py" +check "an UNTRACKED, non-ignored file without the notice is reported" "gate_has 'missing copyright notice: fresh.py'" "$(gate)" +rm -f "$tmp/fresh.py" + +# 4. an untracked file inside an ignored directory is NOT seen -- engine#1564: run output is not source +mkdir -p "$tmp/run-output" +printf '{"log": 1}\n' > "$tmp/run-output/probe.jsonl" +check "an ignored output directory is not reported" "! gate_has 'run-output'" "$(gate)" +check "and it does not make the gate red" "[ $(gate >/dev/null; echo $?) -eq 0 ]" "$(gate)" + +# 5. the same file, NOT ignored, is reported -- which is what #1564 measured in a developer clone +rm -f "$tmp/.gitignore" && git -C "$tmp" rm -q --cached .gitignore 2>/dev/null; git -C "$tmp" commit -qm noignore --allow-empty +check "the same output file IS reported once nothing ignores it" "gate_has 'run-output/probe.jsonl'" "$(gate)" + +echo "$([ $fail -eq 0 ] && echo PASS || echo FAIL)" +exit $((fail)) From 6bd1e1de769c4dc688a85270f2df66e166366428 Mon Sep 17 00:00:00 2001 From: bong-water-water-bong Date: Sun, 8 Nov 2026 19:22:02 -0400 Subject: [PATCH 2/2] copyright_gate_test: pin what the gate reads, now that #1580 and the ignore rule have landed Rebased onto main after #1580 (untracked unknown-style files are a skip) and after the `.hrx123/logs/` ignore rule arrived in main from the other PR, so this is now only the part that was not duplicated: the test. Six arms, PASS on this head and verified the same way against #1580's own copyright.py before it merged: an ignored output directory is unseen; a staged file without the notice is red; an untracked file with a *known* style is red (the arm that keeps 'run the gate before git add' useful); a tracked file of unknown style is red -- the case that holds whatever #1580 decides about untracked ones, which is why arm 5 asserts that one and leaves the other verdict to it. Refs #1564 --- tests/copyright_gate_test.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/copyright_gate_test.sh b/tests/copyright_gate_test.sh index 74676a5ce..5c1829475 100755 --- a/tests/copyright_gate_test.sh +++ b/tests/copyright_gate_test.sh @@ -76,9 +76,13 @@ printf '{"log": 1}\n' > "$tmp/run-output/probe.jsonl" check "an ignored output directory is not reported" "! gate_has 'run-output'" "$(gate)" check "and it does not make the gate red" "[ $(gate >/dev/null; echo $?) -eq 0 ]" "$(gate)" -# 5. the same file, NOT ignored, is reported -- which is what #1564 measured in a developer clone +# 5. once such an output file is TRACKED it is reported, whatever the ignore rule says -- and this is the arm that +# survives #1580, which makes an *untracked* file of unknown comment style a skip (a file nobody has committed +# should not fail the gate) while a tracked one stays an error. The untracked case is therefore deliberately NOT +# asserted here: #1580 owns that verdict, and asserting it would make whichever PR lands second turn CI red. rm -f "$tmp/.gitignore" && git -C "$tmp" rm -q --cached .gitignore 2>/dev/null; git -C "$tmp" commit -qm noignore --allow-empty -check "the same output file IS reported once nothing ignores it" "gate_has 'run-output/probe.jsonl'" "$(gate)" +git -C "$tmp" add -f run-output/probe.jsonl +check "a TRACKED output file is reported even though nothing ignores it" "gate_has 'run-output/probe.jsonl'" "$(gate)" echo "$([ $fail -eq 0 ] && echo PASS || echo FAIL)" exit $((fail))