Skip to content

fix(tools): accept licence notices in the conventions check - #16580

Merged
oneandonlydean merged 2 commits into
boykopovar:mainfrom
Lykein4:fix/conventions-license-notices
Nov 9, 2026
Merged

oneandonlydean merged 2 commits into
boykopovar:mainfrom
Lykein4:fix/conventions-license-notices

Conversation

@Lykein4

@Lykein4 Lykein4 commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

What

The conventions checker could not tell a required upstream licence notice
from an undocumented comment, so Math.cpp and SignalList.cpp needed an
unrelated debt-file touch to add one. It now recognizes a notice by its own
text (SPDX-License-Identifier, Copyright with (c)/©/a year,
Permission is hereby granted, Permission to use, copy, modify, or
Redistribution and use in source and binary forms) and exempts its
unbroken run of comment lines, stopping at the first blank line or line of
code on either side; a comment on the same line as code is never exempt.

Known limitation: a comment glued directly to an existing notice, with no
blank line between them, is exempted too — the rule checks the whole run
for a marker, not each line. The same goes for a comment that contains a
marker itself alongside unrelated text (// Copyright 2025 TODO: hack
passes): the rule trusts marker text, it doesn't parse intent. A plain
// TODO still needs a blank-line or code separator from the nearest
notice to be caught.

Removes the closed entry in docs/dev/debt/libc.md. I left
docs/dev/CONVENTIONS.md unchanged so the wording of the exception is
yours; happy to add a line if you'd like. The blanket "any debt file
touched anywhere in the diff waives every comment" behaviour is unchanged
and still used by other comments (e.g.
libSceConvertKeycode/ImeKeyboardType.hpp:9).

Tooling only; no title involved.

Tested

Linux (Arch, kernel 7.0.11-arch1-1), Python 3.14.5. Tools-only change; no
build or ctest applies.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw; silent stubs listed — n/a
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source — n/a
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes (Claude Code)

The checker could not tell a required upstream licence notice from an
undocumented comment, so adding one needed an unrelated debt-file
touch as a workaround. Recognize the notice by its own text instead.
@github-actions github-actions Bot added the docs label Nov 7, 2026
@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 16862 docs/dev/debt/libc.md L153-154

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 5021 docs/dev/debt/libc.md
PR 7386 docs/dev/debt/libc.md
PR 7447 docs/dev/debt/libc.md
PR 7544 docs/dev/debt/libc.md
PR 7715 docs/dev/debt/libc.md
PR 8150 docs/dev/debt/libc.md
PR 8965 docs/dev/debt/libc.md
PR 9087 docs/dev/debt/libc.md
PR 9340 docs/dev/debt/libc.md
PR 9371 docs/dev/debt/libc.md
PR 9447 docs/dev/debt/libc.md
PR 9466 docs/dev/debt/libc.md
PR 9526 docs/dev/debt/libc.md
PR 9677 docs/dev/debt/libc.md
PR 10274 docs/dev/debt/libc.md
PR 10780 docs/dev/debt/libc.md
PR 11109 docs/dev/debt/libc.md
PR 11172 docs/dev/debt/libc.md
PR 11332 docs/dev/debt/libc.md
PR 11661 docs/dev/debt/libc.md
PR 11689 docs/dev/debt/libc.md
PR 11698 docs/dev/debt/libc.md
PR 11726 docs/dev/debt/libc.md
PR 12518 docs/dev/debt/libc.md
PR 12592 docs/dev/debt/libc.md
PR 12622 docs/dev/debt/libc.md
PR 12627 docs/dev/debt/libc.md
PR 12682 docs/dev/debt/libc.md
PR 12688 docs/dev/debt/libc.md
PR 12700 docs/dev/debt/libc.md
PR 12704 docs/dev/debt/libc.md
PR 12849 docs/dev/debt/libc.md
PR 12965 docs/dev/debt/libc.md
PR 13449 docs/dev/debt/libc.md
PR 13794 docs/dev/debt/libc.md
PR 13804 docs/dev/debt/libc.md
PR 14212 docs/dev/debt/libc.md
tools/check_conventions.py
PR 14298 docs/dev/debt/libc.md
PR 15095 docs/dev/debt/libc.md
PR 15807 docs/dev/debt/libc.md
PR 17261 docs/dev/debt/libc.md
PR 17555 docs/dev/debt/libc.md
PR 17557 docs/dev/debt/libc.md
PR 17558 docs/dev/debt/libc.md
PR 17691 docs/dev/debt/libc.md
tools/check_conventions.py
tools/tests/test_check_conventions_comments.py

Add cases for a marker on the same line as code (still reported), a
marker sharing its line with unrelated text (still exempt, documenting
the limitation), and rename the leading-header case to say what it
actually covers. Revert the CONVENTIONS.md wording change; the debt
entry removal stays.
@JJenkx

JJenkx commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Windows check of head 15bc943a3d, merged onto main 877a983b2e (9c728f2a60, clean merge).

Setup: Windows 11 Enterprise 22621, Python 3.15.1, python -I -m unittest discover -s tools/tests -p test_check_conventions_comments.py.

  • All 91 tests pass in 3 of 3 runs.

AI-assisted: yes.

@blawesom

blawesom commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Linux verification (CachyOS x86-64, Python 3.13): the conventions test suite passes 219 of 219 including the new licence cases, and I probed the rule end-to-end through the real script on this head, holding docs/dev/debt/libc.md at main's state so the any-debt-change-suppresses-comment-findings mechanism stays out of the picture:

  • Positive control: prepending a Regents/BSD licence block to Math.cpp produces no [comment] error — the recognition genuinely replaces the debt entry this PR removes.
  • Negative control: a plain // a regular comment that must still be flagged in Threads.cpp, same conditions, is still flagged.

One observation from the same probes: license_run accepts the whole contiguous run of comment-only lines when any line in it matches a marker, so a comment placed adjacent to a licence block joins the run and is not flagged — I prepended // a sneaky regular comment beside a licence above GetSubOpt.cpp's FreeBSD header and it passes. Files whose headers carry the notices (Math.cpp, SignalList.cpp) are exactly where stray comments would land, so requiring the marker within each individual comment block — or bounding the run — would close that. Minor, not blocking; the mechanism itself works and the negative control shows nothing else was loosened.

AI-assisted: yes

@Lykein4

Lykein4 commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

Linux verification (CachyOS x86-64, Python 3.13): the conventions test suite passes 219 of 219 including the new licence cases, and I probed the rule end-to-end through the real script on this head, holding docs/dev/debt/libc.md at main's state so the any-debt-change-suppresses-comment-findings mechanism stays out of the picture:

* Positive control: prepending a Regents/BSD licence block to `Math.cpp` produces no `[comment]` error — the recognition genuinely replaces the debt entry this PR removes.

* Negative control: a plain `// a regular comment that must still be flagged` in `Threads.cpp`, same conditions, is still flagged.

One observation from the same probes: license_run accepts the whole contiguous run of comment-only lines when any line in it matches a marker, so a comment placed adjacent to a licence block joins the run and is not flagged — I prepended // a sneaky regular comment beside a licence above GetSubOpt.cpp's FreeBSD header and it passes. Files whose headers carry the notices (Math.cpp, SignalList.cpp) are exactly where stray comments would land, so requiring the marker within each individual comment block — or bounding the run — would close that. Minor, not blocking; the mechanism itself works and the negative control shows nothing else was loosened.

AI-assisted: yes

Thanks! The adjacent-comment case is the known limitation in the description. Requiring a marker per block would flag 13 of 22 header blocks in Math.cpp (the “Derived from…” lines), so I kept the run-level rule.

AI-assisted: yes

@oneandonlydean oneandonlydean self-assigned this Nov 9, 2026
@oneandonlydean
oneandonlydean merged commit ca761ca into boykopovar:main Nov 9, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants