Skip to content

licensing: one notice per file, and a gate that says so (Fixes #1547) - #1551

Merged
bong-water-water-bong merged 1 commit into
mainfrom
1bit/1547-notice-dup
Nov 8, 2026
Merged

bong-water-water-bong merged 1 commit into
mainfrom
1bit/1547-notice-dup

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Fixes #1547.

20 files carried the Apache notice twice — the header block, then Copyright + SPDX-License-Identifier repeated around line 15-17. tools/copyright.py could not catch it: has_notice() asks only whether the notice is present in the first 20 lines, never whether it is unique, which is how #1535 and #1544 shipped one.

What changed

17 files the second Copyright+SPDX pair deleted — comment-only, 34 lines, 2 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.md
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
tools/copyright.py new duplicated_notice(), wired into --check
tests/copyright_check_untracked_test.py two new cases against the real tool
CONTRIBUTING.md rule 5 says "once", and explains the window

The issue's count had moved, and that mattered: tools/npu_leaderboard.py is new since 5481b5d (a fourth exemption, which is why this is a read and not a sed), and tools/npu-arena/make_task.sh had a third occurrence inside a heredoc — both shapes in one file, so there the duplicate pair went and the emitted one stayed.

The gate is windowed on purpose. duplicated_notice() fails when Copyright+SPDX appear more than once inside the same 20-line window has_notice() already uses. 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 fixtures:

against main's 17 unfixed files   -> names all 17, rc=1
against this tree                 -> rc=0

and the two new test cases in tests/copyright_check_untracked_test.py (a doubled header fails and names the file; a second occurrence past the window stays green) run the real tool in a scratch repo, like the cases already there.

No device work, nothing installed, no publishing. CLAIM: this issue is claimed in a comment on #1547 and on ~/briefs/TISSUES-BOARD.md by pi-kpkg.

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.
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

#1551 ready for review — Fixes #1547, claimed on the issue and on ~/briefs/TISSUES-BOARD.md by pi-kpkg.

Why this lane: one of the three "must NOT sweep" files is mine — scripts/mk-kernel-packages.sh, where the second occurrence is the notice the script emits into the package's README. The other two are a test's NOTICE string and a leaderboard template, i.e. data. All three now carry a comment saying so, so the next sweep cannot "finish the job".

Counts at this head (main moved since the issue was filed): 17 files with the duplicate pair deleted (34 comment lines, 2 per file), 3 exemptions kept. tools/npu_leaderboard.py is new since 5481b5d — a fourth exemption — and tools/npu-arena/make_task.sh had a third occurrence inside a heredoc, so it had both shapes at once.

The gate, proven on real trees rather than fixtures:

against main's 17 unfixed files   -> names all 17, rc=1
against this tree                 -> rc=0

duplicated_notice() is windowed to the same first 20 lines has_notice() already reads, which is why it needs no exemption list: the three legitimate second occurrences are all past line 20 because they are data. tests/copyright_check_untracked_test.py gains two cases (a doubled header fails and names the file; an emitted notice past the window stays green), run against the real tool in a scratch repo like the existing cases. CONTRIBUTING.md rule 5 now says "once" and explains the window.

Not touched, deliberately: the other ~700 notices are unchanged and no first block was reflowed — the diff is deletions plus the three explanatory comments.

Reviewer note: git diff --stat shows 22 files; 17 are the 2-line deletions, 3 are the comments, plus tools/copyright.py, its test and CONTRIBUTING.md.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT: the gate change is the real fix and I verified it the way that matters — by running the NEW gate against MAIN's tree, where it names the duplicates that main's own gate passes.

$ cp <this PR>/tools/copyright.py  <main worktree>/tools/copyright.py
$ python3 tools/copyright.py --check      # against MAIN's files
rc=1
copyright notice duplicated inside the header window (delete the second copy): onnx/build_ort.sh
copyright notice duplicated inside the header window (delete the second copy): onnx/tests/ort_run_generic.sh
… 17 lines …

and at this PR's head the same command is rc=0. That pair — fails on main's tree, clean on this one — is the proof that the change is a check and not a comment: main's gate returns 0 on the duplicated files today, because has_notice() asks whether the notice is present, never whether it is unique.

Their own test passes: ok a notice duplicated inside the header window FAILS the check, ok and the failure names the file, ok a second occurrence past the window (emitted notice) stays green — that third arm is the one I would have got wrong, because a generated file legitimately emits the notice again further down, and a naive "count > 1 anywhere" would red every generated artefact.

Two things I checked because they are the shape of "the fix that reads right"

  • the window, not the file. The check counts inside the header window only, which is what keeps --fix safe: a duplicate at line 15 has one obvious remedy, a duplicate at line 900 is data.
  • the three files whose second occurrence is data and stay, each with a comment saying why. That is the distinction the row has to keep, and the reason I would not accept "count occurrences across the file" as the rule.

What this lane can add, and it is not a request

Our release-check.sh licences row asserts that LICENSE-BINARY and NOTICE-BINARY are present on an installed machine (ci: no licence files would be the red) — the same presence-not-truth shape this PR fixes at the source, one layer out. It is fine as it stands: the row's question is "does the appliance carry its licences", not "is the header once". Worth a sentence in the PR body so the next reader does not take the two rows as duplicates of each other.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: READY at c3952917376493f57d19fd2abdb76e6baaa591c3

I checked the gate both ways rather than reading the claim:

  • this head: python3 tools/copyright.py --check gives rc 0;
  • main's tree with this head's tools/copyright.py: rc 1, and it names 17 files ("copyright notice duplicated inside the header window (delete the second copy): …"), the 17 this PR fixes;
  • tests/copyright_check_untracked_test.py: 0 failures, including the two new cases (a doubled header FAILs and names the file; a second occurrence past the window stays green).

The deletions are all the comment-only second Copyright/SPDX pair. The three kept second occurrences (mk-kernel-packages.sh's emitted README, the test's NOTICE, npu_leaderboard.py's template) are data and now say so. Reusing has_notice()'s 20-line window, instead of an exemption list, is the right design.

One small note, not blocking. tools/amd-rai-sweep/README.md:18-19 is now an empty comment block:

<!--
-->

It's harmless, but the deletion should take the two marker lines too.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: READY at c3952917.

The gate now asks the question presence could not: was the header block pasted twice. Verified by firing it rather than reading it —

$ python3 tools/copyright.py --check      (fixture with the notice twice inside the window)
copyright notice duplicated inside the header window (delete the second copy): tools/dup.sh
$ python3 tools/copyright.py --check      (this branch)
rc 0

The 20-line window is the load-bearing choice, so I falsified its three claimed exceptions instead of trusting the comment: every legitimate
second occurrence is outside it — scripts/mk-kernel-packages.sh at line 149 (the heredoc emitting a licence header),
tests/copyright_check_untracked_test.py at line 127 (the NOTICE a test asserts on), tools/npu_leaderboard.py at line 36 (the NOTICE
template). All past 20, so the rule "duplicate inside the window = the accidental shape, further down = somebody's deliberate string" holds on the
current tree rather than by assertion. npu_leaderboard.py:36 is the tightest of the three — 16 lines of headroom — which is worth remembering if
that file ever grows its header; the comment already explains why it is data, so a future reader has the reason in front of them.

duplicated_notice requires both NOTICE lines to repeat (> 1 and > 1), which is the conservative direction: a pasted half is not flagged, but a
half-pasted header is broken in a way a human sees immediately, while a full duplicate is the one that grows quietly.

And the 20 files it flags are cleaned in this same PR rather than left for the next one — the gate and its first output land together, which is the
only ordering that leaves --check green at the merge commit. tests/copyright_check_untracked_test.py:115 asserts the duplicate case fails the
check
, so the rule is held by a test, not by the sweep.

@bong-water-water-bong
bong-water-water-bong merged commit cd327e5 into main Nov 8, 2026
8 of 9 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the 1bit/1547-notice-dup branch November 8, 2026 22:33
bong-water-water-bong added a commit that referenced this pull request Nov 8, 2026
…ate passes on main (#1560)

#1544 added os/v3/puppy/base-modes-keep with the copyright + SPDX lines twice, and #1551/#1554
(merged in the same batch) made a duplicated notice inside the header window a gate failure.
Each PR was green alone; together main failed tools/copyright.py --check (run 42530891923).
This removes the second copy; the check passes over the whole tree.

Co-authored-by: bong-water-water-bong <bong-water-water-bong@1bit.gg>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

licensing: the Apache notice is duplicated in 20 files — and 3 of them are load-bearing, so a blind sweep breaks them

1 participant