From c3952917376493f57d19fd2abdb76e6baaa591c3 Mon Sep 17 00:00:00 2001 From: bong-water-water-bong Date: Sun, 8 Nov 2026 17:53:55 -0400 Subject: [PATCH] licensing: one notice per file, and a gate that says so (Fixes #1547) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 20 files carried the Apache notice twice: the header block, then Copyright+SPDX repeated around line 15-17. `tools/copyright.py` never checked for that — `has_notice()` asks only whether the notice is *present* in the first 20 lines — which is how #1535 and #1544 shipped one. 17 files: the second pair deleted (comment-only, 34 lines; `git diff --stat` is 2 deletions per file) 3 files: the second occurrence is DATA and stays, each now saying why in a comment scripts/mk-kernel-packages.sh the notice it EMITS into the package's README tests/copyright_check_untracked_test.py the NOTICE string the cases assert against tools/npu_leaderboard.py the NOTICE template written into a generated leaderboard The issue's count was from 5481b5d and has moved: `tools/npu_leaderboard.py` is new (a fourth exemption), and `tools/npu-arena/make_task.sh` had a *third* occurrence inside a heredoc — both kinds in one file, so the duplicate pair went and the emitted one stayed. The gate: `duplicated_notice()` fails when Copyright+SPDX appear more than once inside the same 20-line window `has_notice()` already looks at. Deliberately windowed rather than tree-wide: the three legitimate second occurrences all sit past line 20 because they are data, so this needs no exemption list and cannot rot into one. Proven in both directions on real trees, not on fixtures: against main's 17 unfixed files -> names all 17, rc=1 against this tree -> rc=0 `tests/copyright_check_untracked_test.py` gets two new cases against the real tool in a scratch repo: a doubled header fails and names the file; a second occurrence past the window (an emitted notice) stays green. CONTRIBUTING rule 5 now says "once" and explains the window. Fixes #1547. --- CONTRIBUTING.md | 8 +++-- onnx/build_ort.sh | 2 -- onnx/tests/ort_run_generic.sh | 2 -- os/v3/puppy/catalogue-manifest.py | 2 -- .../embed/etc/sysctl.d/60-1bit-console.conf | 2 -- os/v3/puppy/shell-login.sh | 2 -- scripts/check_repack_config.py | 2 -- scripts/mk-kernel-packages.sh | 3 ++ tests/copyright_check_untracked_test.py | 25 ++++++++++++++++ tests/fconst19_measure_test.py | 2 -- tools/amd-rai-sweep/README.md | 2 -- tools/copyright.py | 29 +++++++++++++++++-- tools/fconst19_measure.py | 2 -- tools/flm_head_pb16i.py | 2 -- tools/npu-arena/TOOLCHAIN.lock.example | 2 -- tools/npu-arena/ceiling.sh | 2 -- tools/npu-arena/lib/env.sh | 2 -- tools/npu-arena/make_probe.sh | 2 -- tools/npu-arena/make_task.sh | 2 -- tools/npu-arena/oracle.sh | 2 -- tools/npu-arena/runner/build.sh | 2 -- tools/npu_leaderboard.py | 2 ++ 22 files changed, 62 insertions(+), 39 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 94253b886..dbd2de9db 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -32,10 +32,14 @@ This repository exists to be reviewable. Five rules keep it that way. xclbins and the repository vendors none. A private add-on (docs/npu.md, "Private routes") builds its kernels from source in its own repository. -5. **Every file carries the copyright and Apache-2.0 notice.** Run +5. **Every file carries the copyright and Apache-2.0 notice, once.** Run `python3 tools/copyright.py --fix` before committing; CI runs `--check`. Files that cannot hold a comment (binaries, JSON, test data) are exempt, - listed in the tool. + listed in the tool. `--check` also fails a notice **duplicated inside the + first 20 lines** — the accidental shape that shipped 20 times before + engine#1547. A second occurrence further down is data (a heredoc or a + template that emits the notice into a generated file) and is left alone; + the three such files say so in a comment. ## RFCs: design before code diff --git a/onnx/build_ort.sh b/onnx/build_ort.sh index 7d6c58263..24c8e7d16 100755 --- a/onnx/build_ort.sh +++ b/onnx/build_ort.sh @@ -13,8 +13,6 @@ # 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. -# Copyright 2026 bong-water-water-bong -# SPDX-License-Identifier: Apache-2.0 # # Build ONNX Runtime from source and install it to a prefix we own, so onnx/ links against our # libonnxruntime instead of the distro's. ORT is MIT: patching it and shipping the result closed diff --git a/onnx/tests/ort_run_generic.sh b/onnx/tests/ort_run_generic.sh index 0c58619e7..c41ed188f 100755 --- a/onnx/tests/ort_run_generic.sh +++ b/onnx/tests/ort_run_generic.sh @@ -13,8 +13,6 @@ # 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. -# Copyright 2026 bong-water-water-bong -# SPDX-License-Identifier: Apache-2.0 # # ort_run_generic.sh BINARY PYTHON — `ort-run --input/--output/--dump-all` on a graph it has never # seen (docs/onnx.md, "Any graph"). The model is a two-node MatMul+Relu written here with python diff --git a/os/v3/puppy/catalogue-manifest.py b/os/v3/puppy/catalogue-manifest.py index 19341993d..c46c0588b 100644 --- a/os/v3/puppy/catalogue-manifest.py +++ b/os/v3/puppy/catalogue-manifest.py @@ -13,8 +13,6 @@ # 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. -# Copyright 2026 bong-water-water-bong -# SPDX-License-Identifier: Apache-2.0 # # catalogue-manifest.py # diff --git a/os/v3/puppy/embed/etc/sysctl.d/60-1bit-console.conf b/os/v3/puppy/embed/etc/sysctl.d/60-1bit-console.conf index 9c8f740ca..00d67c233 100644 --- a/os/v3/puppy/embed/etc/sysctl.d/60-1bit-console.conf +++ b/os/v3/puppy/embed/etc/sysctl.d/60-1bit-console.conf @@ -12,8 +12,6 @@ # 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. -# Copyright 2026 bong-water-water-bong -# SPDX-License-Identifier: Apache-2.0 # # Cycle 26, item 1: the console belongs to the console. Nothing may print onto tty1 while the console TUI is on it. # diff --git a/os/v3/puppy/shell-login.sh b/os/v3/puppy/shell-login.sh index fa76a9d6c..29c0267a6 100644 --- a/os/v3/puppy/shell-login.sh +++ b/os/v3/puppy/shell-login.sh @@ -13,8 +13,6 @@ # 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. -# Copyright 2026 bong-water-water-bong -# SPDX-License-Identifier: Apache-2.0 # # shell-login.sh # diff --git a/scripts/check_repack_config.py b/scripts/check_repack_config.py index f1d15a5cb..559ad285a 100755 --- a/scripts/check_repack_config.py +++ b/scripts/check_repack_config.py @@ -13,8 +13,6 @@ # 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. -# Copyright 2026 bong-water-water-bong -# SPDX-License-Identifier: Apache-2.0 # # check_repack_config.py -- oracle-free repack validation. # diff --git a/scripts/mk-kernel-packages.sh b/scripts/mk-kernel-packages.sh index 9890a6c38..0c27ce24d 100755 --- a/scripts/mk-kernel-packages.sh +++ b/scripts/mk-kernel-packages.sh @@ -141,6 +141,9 @@ chmod 0644 "$cfg"/etc/security/limits.d/*.conf "$cfg"/etc/udev/rules.d/*.rules \ "$cfg"/etc/modules-load.d/*.conf install -m 0644 "$work/MOK-Kernel.der" "$cfg/usr/share/1bit/mok/MOK-Kernel.der" cp "$repo/LICENSE" "$cfg/usr/share/licenses/1bit-npu-config/LICENSE" +# The block below is EMITTED into the package's README, not this script's own header (which is +# at the top). Deleting it as a duplicate ships a package whose documentation carries no licence +# (engine#1547, one of the three exemptions there). cat > "$cfg/usr/share/doc/1bit-npu-config/README.md" <<'EOF' # AMD Ryzen AI ONNX packs — image + Whisper sweep diff --git a/tools/copyright.py b/tools/copyright.py index bbe742caf..346cca2fb 100644 --- a/tools/copyright.py +++ b/tools/copyright.py @@ -121,11 +121,29 @@ def exempt(path): return _match(path, EXEMPT) or _match(path.rsplit("/", 1)[-1], EXEMPT) +NOTICE_WINDOW = 20 # the lines has_notice() looks at; duplicated_notice() uses the same window + + def has_notice(text): - head = "\n".join(text.splitlines()[:20]) + head = "\n".join(text.splitlines()[:NOTICE_WINDOW]) return NOTICE[0] in head and NOTICE[1] in head and "Licensed under the Apache License, Version 2.0" in head +def duplicated_notice(text): + """True when the Copyright + SPDX pair appears twice inside the header window. + + Present-in-the-head was all this gate ever asked, so a file whose header block was pasted twice passed — + which is how #1535 and #1544 shipped one, and why #1547 lists 20 files. The window is deliberate: the + three legitimate second occurrences in the tree (a heredoc emitting a licence header in + scripts/mk-kernel-packages.sh, the NOTICE string a test asserts on in + tests/copyright_check_untracked_test.py, and the NOTICE template in tools/npu_leaderboard.py) all sit + past line 20, because they are *data*, not the file's own header. A duplicate inside the window is the + accidental shape; anything further down is somebody's deliberate string. + """ + head = "\n".join(text.splitlines()[:NOTICE_WINDOW]) + return head.count(NOTICE[0]) > 1 and head.count(NOTICE[1]) > 1 + + def add_notice(text, block): lines = text.splitlines(keepends=True) insert_at = 1 if lines and lines[0].startswith("#!") else 0 @@ -148,7 +166,7 @@ def listing(*args): return subprocess.run(["git", "ls-files", *args], capture_output=True, text=True, check=True).stdout.split("\n") files = sorted(set(filter(None, listing())) | set(filter(None, listing("--others", "--exclude-standard")))) - missing, unknown = [], [] + missing, unknown, duplicated = [], [], [] for path in filter(None, files): if exempt(path): continue @@ -158,6 +176,9 @@ def listing(*args): continue with open(path, encoding="utf-8") as f: text = f.read() + if duplicated_notice(text): + duplicated.append(path) + continue if has_notice(text): continue if args.fix: @@ -167,11 +188,13 @@ def listing(*args): else: missing.append(path) + for path in duplicated: + print("copyright notice duplicated inside the header window (delete the second copy):", path) for path in unknown: print("no comment style known (add one to LINE_STYLES/BLOCK_STYLES or EXEMPT):", path) for path in missing: print("missing copyright notice:", path) - if missing or unknown: + if missing or unknown or duplicated: print("run: python3 tools/copyright.py --fix", file=sys.stderr) return 1 return 0 diff --git a/tools/fconst19_measure.py b/tools/fconst19_measure.py index 10e574858..a458696cf 100755 --- a/tools/fconst19_measure.py +++ b/tools/fconst19_measure.py @@ -13,8 +13,6 @@ # 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. -# Copyright 2026 bong-water-water-bong -# SPDX-License-Identifier: Apache-2.0 """Measure a Ryzen AI 1.9 Token .fconst against its 1.8 twin, and print the table line to add. An importer cannot derive a 1.9 pack's layout from the pack: the q/k/v bundle's tile shape is not a diff --git a/tools/flm_head_pb16i.py b/tools/flm_head_pb16i.py index 9b95902ea..31f473556 100644 --- a/tools/flm_head_pb16i.py +++ b/tools/flm_head_pb16i.py @@ -13,8 +13,6 @@ # 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. -# Copyright 2026 bong-water-water-bong -# SPDX-License-Identifier: Apache-2.0 # # The MTP head in our "pb16i" form: codes x per-(32 K, column) magnitudes, no per-group bias. # diff --git a/tools/npu-arena/TOOLCHAIN.lock.example b/tools/npu-arena/TOOLCHAIN.lock.example index 022e959a2..656c831c0 100644 --- a/tools/npu-arena/TOOLCHAIN.lock.example +++ b/tools/npu-arena/TOOLCHAIN.lock.example @@ -12,8 +12,6 @@ # 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. -# Copyright 2026 bong-water-water-bong -# SPDX-License-Identifier: Apache-2.0 # # TOOLCHAIN.lock.example -- copy to TOOLCHAIN.lock (git-ignored) and fill in for # your box. The arena resolves every path from the environment first, then from diff --git a/tools/npu-arena/ceiling.sh b/tools/npu-arena/ceiling.sh index 7b8d7a9e2..b252a2bdf 100755 --- a/tools/npu-arena/ceiling.sh +++ b/tools/npu-arena/ceiling.sh @@ -13,8 +13,6 @@ # 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. -# Copyright 2026 bong-water-water-bong -# SPDX-License-Identifier: Apache-2.0 # # ceiling.sh -- phase 1 of the 2026-10-30 14:58 addendum: measure the attainable # weight-stream bandwidth for EACH phase's tap/tile geometry with the matrix unit diff --git a/tools/npu-arena/lib/env.sh b/tools/npu-arena/lib/env.sh index 53bcfe02a..fdb7cb36c 100755 --- a/tools/npu-arena/lib/env.sh +++ b/tools/npu-arena/lib/env.sh @@ -12,8 +12,6 @@ # 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. -# Copyright 2026 bong-water-water-bong -# SPDX-License-Identifier: Apache-2.0 # # lib/env.sh -- sourced by every arena build/run. Resolves the toolchain from the # environment (or from a local TOOLCHAIN.lock, which is deliberately NOT in the diff --git a/tools/npu-arena/make_probe.sh b/tools/npu-arena/make_probe.sh index 92bc628c3..a1207b6a6 100755 --- a/tools/npu-arena/make_probe.sh +++ b/tools/npu-arena/make_probe.sh @@ -13,8 +13,6 @@ # 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. -# Copyright 2026 bong-water-water-bong -# SPDX-License-Identifier: Apache-2.0 # # make_probe.sh [ ...] -- build the DMA-ceiling probe submissions for # a phase: the phase's own tap/tile geometry with the matrix unit replaced by diff --git a/tools/npu-arena/make_task.sh b/tools/npu-arena/make_task.sh index 5215576d9..aafad6027 100755 --- a/tools/npu-arena/make_task.sh +++ b/tools/npu-arena/make_task.sh @@ -13,8 +13,6 @@ # 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. -# Copyright 2026 bong-water-water-bong -# SPDX-License-Identifier: Apache-2.0 # # make_task.sh -- create or refresh a task bundle for one phase. # make_task.sh GU|D|QKV|O|Z diff --git a/tools/npu-arena/oracle.sh b/tools/npu-arena/oracle.sh index 02c42268d..739782952 100755 --- a/tools/npu-arena/oracle.sh +++ b/tools/npu-arena/oracle.sh @@ -13,8 +13,6 @@ # 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. -# Copyright 2026 bong-water-water-bong -# SPDX-License-Identifier: Apache-2.0 # # oracle.sh -- score ONE submission for ONE phase. # diff --git a/tools/npu-arena/runner/build.sh b/tools/npu-arena/runner/build.sh index 7a6594edf..1a4411f01 100755 --- a/tools/npu-arena/runner/build.sh +++ b/tools/npu-arena/runner/build.sh @@ -13,8 +13,6 @@ # 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. -# Copyright 2026 bong-water-water-bong -# SPDX-License-Identifier: Apache-2.0 # # runner/build.sh -- build the arena's host-side on-device scorer. # Links the engine's own NPU runtime (pinned in TOOLCHAIN.lock); no XRT. diff --git a/tools/npu_leaderboard.py b/tools/npu_leaderboard.py index d8ccbb92b..2f82c3372 100644 --- a/tools/npu_leaderboard.py +++ b/tools/npu_leaderboard.py @@ -30,6 +30,8 @@ import sys from pathlib import Path +# Data, not this file's header: NOTICE is the HTML block written into a generated leaderboard, which is +# why the second Copyright+SPDX pair here is legitimate (engine#1547). NOTICE = """