Skip to content

chore(build): include benches/ in insert_apache_header.py target roots - #1728

Merged
inureyes merged 3 commits into
lablup:mainfrom
saitejagirada:chore/fix-apache-header-benches
Sep 11, 2026
Merged

chore(build): include benches/ in insert_apache_header.py target roots#1728
inureyes merged 3 commits into
lablup:mainfrom
saitejagirada:chore/fix-apache-header-benches

Conversation

@saitejagirada

Copy link
Copy Markdown
Contributor

Summary

Add "benches" to TARGET_ROOTS in scripts/insert_apache_header.py so the Apache-header insertion script covers the benches/ directory. Insert the standard header into benches/audio_fft.rs, the only Rust source file under a top-level source root that was missing it. Extend the Python test by one assertion to pin the new root.

Closes #1707

Changes

File Change
scripts/insert_apache_header.py Add "benches" to TARGET_ROOTS
benches/audio_fft.rs Insert the standard Apache 2.0 license header
tests/test_insert_apache_header.py Add should_process_path("benches/audio_fft.rs") assertion

Verification

python3 -m pytest tests/test_insert_apache_header.py -v
# 5 passed

Running the script itself confirms benches/audio_fft.rs is now recognized and skipped (header already present):

⏭️  Skipped existing header: .../benches/audio_fft.rs

Acceptance Criteria (from #1707)

  • benches/audio_fft.rs carries the standard header
  • The script and its test cover benches/

Add "benches" to TARGET_ROOTS so the Apache-header insertion script
covers the benches/ directory. Insert the standard header into
benches/audio_fft.rs, the only Rust source file under a top-level
source root that was missing it. Extend the Python test by one
assertion to pin the new root.

Closes lablup#1707
@cla-assistant

cla-assistant Bot commented Sep 9, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@inureyes inureyes added status:review Under review type:chore Maintenance tasks (build, CI, etc.) priority:medium Medium priority labels Sep 11, 2026
Issue lablup#1707 found `benches/audio_fft.rs` shipping unlicensed and attributed it to `benches` missing from `insert_apache_header.py`'s `TARGET_ROOTS`, calling it "the only Rust file under a top-level source root missing it". Running the script proves that premise wrong: 95 further files under `src`, `examples` and `tests` were unlicensed too, and those three roots were already listed. The roots list was never the binding constraint; nothing ever ran the script.

Every file here is a pure 14-line prepend, +14/-0 with no source line touched. The two files under `src/lib/mlx-cpp/patches/` that receive a header are the ones marked "Added by mlxcel. Not an upstream MLX file." The rest of that directory keeps Apple's copyright and is skipped by `has_existing_header`, which must stay true: this must never stamp a Lablup header onto upstream-derived code.

`build.rs` is included because it is the crate's own build script (`build = "build.rs"` in Cargo.toml) and ships in the published package. `spike/` stays out: those are scratch crates outside the workspace `members` list.

Refs lablup#1707, lablup#1728
PR lablup#1728 adds `benches` to `TARGET_ROOTS`, which is correct but cannot hold on its own: nothing in CI, the Makefile, or any script ever invoked `insert_apache_header.py`, and `tests/test_insert_apache_header.py` was run by nothing at all. It sits outside `python/`, and python.yml's pytest step is scoped to `python/tests` behind a `python/**` path filter, so the assertion this PR adds there never executed. That is why 95 files under roots the script already covered shipped unlicensed.

`--check` reports the files the default insert mode would write to and exits 1, writing nothing. It reuses `has_existing_header`, the same predicate `insert_header_in_file` branches on, so the gate can never demand an edit that running the script does not produce; a test asserts the two agree on the same tree.

`TARGET_FILES` reaches top-level shipped files the root walk cannot: `Path("build.rs").parts[0]` is the file itself and matches no root, so `build.rs` needed an explicit entry rather than a new root.

The new `license-headers` job runs both the check and the unit suite, following the `kernel-dtype-keys` pattern: ubuntu-latest, no toolchain, outside the `changes` filter. Verified by reverting: stripping the header off one backfilled file fails the check, and dropping `build.rs` from `TARGET_FILES` fails three tests.

`from __future__ import annotations` keeps the PEP 604 unions in the new signatures parseable on Python 3.9, which python.yml still tests.

Refs lablup#1707, lablup#1728
@inureyes

Copy link
Copy Markdown
Member

Hardening pass on this PR

Reviewed this PR against #1707. The benches addition is correct and stays as authored. Two findings pushed on top.

The issue's premise was wrong, and understated the gap

#1707 called benches/audio_fft.rs "the only Rust file under a top-level source root missing it". Actually running the script found 96: 95 under src, examples and tests, roots the script already listed, plus build.rs. Fixing TARGET_ROOTS would not have caught one of them. Backfilled in f689b31d, every file a pure +14/-0 prepend with no source line touched. The two files under src/lib/mlx-cpp/patches/ that got a header are the ones marked "Added by mlxcel. Not an upstream MLX file."; the rest keep Apple's copyright, skipped by has_existing_header.

Nothing enforced any of this

insert_apache_header.py was invoked by no CI job, no Makefile target, and no script, and tests/test_insert_apache_header.py was run by nothing at all: it sits outside python/, and python.yml's pytest step is scoped to python/tests behind a python/** path filter. So the assertion this PR adds there never executed. That is why the 95 accumulated.

3e3461dd adds a --check mode (reports, exits 1, writes nothing) and a license-headers CI job running both the check and the unit suite. --check reuses has_existing_header, the same predicate the writer branches on, so the gate cannot demand an edit the script does not make; a test pins that agreement. build.rs needed TARGET_FILES rather than a new root, since Path("build.rs").parts[0] matches no root. spike/ stays out (scratch crates outside the workspace members).

Validation

11/11 unit tests pass; --check clean; cargo fmt --all -- --check clean across the 96 files. Reverting proves the tests bite: stripping a header off one backfilled file fails the check, dropping build.rs from TARGET_FILES fails three tests. The new license headers job passed on this PR's CI run.

Security and performance: no runtime code paths touched. The one risk considered was stamping Lablup copyright onto upstream-derived files, which has_existing_header prevents and the CI job comment records as a standing constraint.

Refs #1707

@inureyes
inureyes merged commit f11de86 into lablup:main Sep 11, 2026
16 checks passed
inureyes added a commit that referenced this pull request Sep 11, 2026
## Summary

- Normalize project-owned source headers and the header generator around Lablup Inc.
- Replace individual NOTICE attribution with collective `Lablup Inc. and contributors.` wording.
- Retain authorship provenance in the core crate's package metadata.
- Follow up on PR #1728's repository-wide header coverage.

## Test plan

- `python3 tests/test_insert_apache_header.py -v` (11 tests passed)
- `python3 scripts/insert_apache_header.py --check`
- `cargo metadata --no-deps --format-version 1`
- `git diff --check`
@inureyes

Copy link
Copy Markdown
Member

Thanks for this one, @saitejagirada. Your diagnosis was right and your commit went in unchanged.

Apologies for how much the PR grew under your branch. The hardening comment above has the detail, but the short version is that your fix was correct and the problem was simply bigger than #1707 described: the roots list was never what was holding it back, since nothing had ever run the script. That was not visible from the issue, and finding it took someone actually pulling on the thread.

The --check mode and the CI job that came out of it now run your test file on every PR, so this cannot drift again.

@saitejagirada

Copy link
Copy Markdown
Contributor Author

good to see that my contribution helped you , and thanks for the merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority:medium Medium priority status:review Under review type:chore Maintenance tasks (build, CI, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore(build): insert_apache_header.py skips benches/, leaving audio_fft.rs unlicensed

2 participants