Repository navigation
Description
star lint copyright's checker is far looser than the pattern its fixer writes, and because the fixer only runs
on files the checker flags, the correct fix is unreachable for every defect the checker cannot see.
check_result = check_file(f, license, holder)
if check_result["skipped"] or check_result["ok"]:
continue
fix_result = fix_file(f, license, holder)check_file is the gate on fix_file. Anything it calls ok is never normalized, however far from the pattern
it sits.
The pattern
One function defines it, build_expected_header at
cmd/star/extensions/com.noblefactor.star.LintCopyright/commands/lint-copyright.star:118:
<comment> SPDX-License-Identifier: <license>
<comment> Copyright <holder>. All rights reserved.
Two lines, adjacent, in that order, comment prefix by extension. With license: auto resolving to Apache-2.0
and holder: Noble Factor from star/config.yaml, the canonical Go header is:
// SPDX-License-Identifier: Apache-2.0
// Copyright Noble Factor. All rights reserved.No year, no (c), no LLC.
What the checker lets through
| Header | Checker | Ever fixed? |
|---|---|---|
no blank line before package — the license becomes the package doc comment |
passes | no |
# Copyright 2025-2026 Noble Factor LLC — as in star/config.yaml itself |
passes | no |
# Copyright (c) 2026 Noble Factor. All rights reserved. — as in the PR scripts |
passes | no |
//SPDX-License-Identifier:Apache-2.0 with no spaces anywhere |
passes | no |
| missing, or a holder not containing "Noble Factor" | fails | yes, correctly |
Three variants of the copyright line are live in this organization's files and all three pass, because the only
assertion is holder not in found_holder — a substring test. \s* in both patterns makes the spacing after the
comment marker free.
The blank line is the one that carries meaning. check_file reads lines[start_line] and
lines[start_line + 1], matches two regexes and returns; nothing looks at what follows. In Go a comment block
immediately above package is the package doc comment, so go doc would print the license as the package's
documentation. The blank line is what makes it a plain file header.
Measured 2026-09-30: 0 tracked .go files are in that state. The blank line is present everywhere, by
convention and gofmt habit rather than because anything checks it. So this is a hole in the gate, not damage
in the tree — it stays a hole until a file slips through it.
Where the fixer over-reaches
fix_file writes shebang + header + "\n\n" + rest after stripping leading blanks, which is correct — exactly
one blank line. But shebang = lines[0] + "\n\n" always inserts a blank line between a shebang and the SPDX
line, and check_file accepts a shebang with or without one. Our .ps1 scripts carry SPDX on line 2 with no
blank, so the fixer would rewrite a conforming file. It can only trigger when something else in the header is
already wrong, so it is over-reach rather than damage.
fix_file's header-detection loop scans min(start_line + 5, len(lines)) lines. The bound has no stated
reason and silently mis-handles any file with a longer leading comment block.
Evidence of completion
-
check_fileasserts a blank line follows the header, and a fixture with the header directly above
packagefails. -
check_fileasserts the canonical copyright line rather than a substring, so the three live variants
converge on one. The files carrying the other two are updated in the same change,star/config.yaml
among them. -
check_fileandfix_fileagree about the shebang blank line; one of them changes, and a.ps1
fixture pins whichever way it goes. - The
+ 5scan window is given a reason or a bound that cannot mis-handle a long leading comment block. - A fixture that passes the checker but differs from
build_expected_headeris added, and the test
asserts there is no such file — check and fix describe the same pattern.
Related documents
| Document | What it is |
|---|---|
| lint-copyright.star | The checker, the fixer, and build_expected_header |
| devlore-cli#994 | go-style --fix merges the two header lines into one; this checker is what would catch it, and the regression test belongs here |
| devlore-cli#964 | CI lints neither Markdown, PowerShell, Go style nor copyright; copyright is the one of the four that passes today |
| star/config.yaml | lint.copyright settings, and itself one of the files carrying a non-canonical header |
Activity
doc(plan): our copyright pattern is ours to declare, not the builtin'…
perf(plan): copyright's 12.6 seconds are 39 tree walks, 34 of which f…
David-Noble-at-work commentedon Oct 1, 2026
Resolved by a simpler design than this issue proposed, 2026-10-01
The divergence is real and the fix is not a tighter checker. The header becomes a literal string in
configuration, so there is nothing left to pattern-match and
SPDX_PATTERNandCOPYRIGHT_PATTERNaredeleted rather than tightened.
checkcompares a file's leading lines to that string with the comment prefix applied;fixwrites the samestring. They cannot disagree, because there is one string. That is stronger than the property this issue asked
for, which was that they agree.
Ruled while designing it:
No template fields. An earlier design had a Go template with
{{.Year}},{{.Holder}}and{{.License}}.All three were struck: the year needs a clock no provider exposes,
Holdersubstitutes one configured stringinto another, and the license identifier is typed into the header where a reader can see it.
license: auto,detect_license,LICENSE_PATTERNS,resolve_licenseand theholderkey are deleted with them -- and withthem a fourth substring match of exactly this issue's kind,
if LICENSE_PATTERNS[spdx_id] in content.The four disagreements, and what closes each
checkrequires it. In Go a comment block immediately abovepackageIS the package doc comment, so this rule changes meaning, not appearanceskipper language, so the header follows the skipped line. This is the kernel's own rule: the identifier goes on "the first line that can contain a comment," line two in a scriptThe
+ 5scan window is replaced bydetect, a per-language pattern matching a line of a header alreadypresent, so
fixknows what to replace rather than assuming every leading comment line is part of it.What the fixer's reachability means, and it still matters
fix_fileruns only on filescheck_fileflags, so the checker is the gate on the fixer and every defect thechecker cannot see is permanently unfixable. A literal header closes that by construction, but the acceptance
is still written as a property rather than a list of cases, because the coupling is the reason the four
disagreements above were invisible rather than merely wrong.
Performance, measured, and the conclusion reversed
This issue also carried the 39 fruitless walks. Measured 2026-09-30/10-01: 4.3 s warm with 39 walks, 1.1 s
with four, over the same 1,001 files -- so the cost was discovery, not the checking, and deleting 35 dict
entries recovers it. An earlier draft concluded the sweep should move into a Go provider method. That is
withdrawn: there is no performance case for Go here, and the rule the codebase follows is narrower --
lint.starlarkis in Go because it resolves calls againstop.ReceiverRegistry(), which Starlark cannot see.Comparing two lines of text is not that.
The diagnostic changes as a consequence:
Wrong license: expected Apache-2.0, found MITbecomes a differenceagainst the configured header. Less specific, more actionable, and it cannot go stale as the header changes.
Tracked in #994's plan,
Requirements 3, 4 and 6, Phases 3 and 4.
doc: the header is configuration, the table describes file types, and…
David-Noble-at-work commentedon Oct 1, 2026
Addendum: identification is a lookup, and the work happens in one pass
Two refinements to the performance half of this issue, both from review after the earlier comment.
The table is inverted into lookups once, before the walk. Deleting the 34 fruitless walks fixes discovery,
but it leaves identification: asking "what language is this file" by scanning every language and every pattern,
with each glob compiled on every comparison. A thousand files over nine languages is tens of thousands of
string operations, and the broad default table a shipped builtin wants makes it hundreds of thousands. So
by_extensionandby_filenamebecome dictionaries and the globs are compiled once, leaving only the globand shebang paths linear -- and both are reached rarely.
The first draft of the fix did the linear version and read as compliant, because "walk once and decide per
entry" conceals what deciding costs.
The checking and repairing happen in the reducer, in that same pass. An earlier draft walked the tree to
build a list of
(path, language)pairs and then iterated it. Two defenses were offered for the second passand both were wrong:
--fixwriting into the tree it is walking is a hazard. It is not.--fixrewrites a file's contents andadds, removes or renames no directory entry, so the walk's view does not change under it. The
modify-while-walking hazard concerns entries changing, not bytes changing.
fs.WalkDir, which Godocuments as walking in lexical order, so the ordering was already stable and the sort was redundant.
The single pass costs the count up front -- the report moves to the end, since the number of files is unknown
until the walk finishes. That is the whole price.
Two costs accepted rather than removed, recorded so neither looks like an oversight later:
file.SkipDirexists in Go but is not exposed to Starlark -- so the walker descends into an excludeddirectory and the reducer rejects what it finds. 82 of devlore-cli's 1,542 in-scope files sit under
testdata, so the waste is small. True pruning needsSkipDirreachable from a Starlark reducer, which isa provider change and not this issue's.
filename, extension and glob lookups all miss -- about twenty files across the three repositories rather
than every font and image in the tree.
doc(plan): identification is a lookup, and the work happens in one pa…
feat(lint): the copyright header is configuration, and check compares…
David-Noble-at-work commentedon Nov 9, 2026
star github triage sweep added this issue to Triage: devlore, for the rule it breaks:
severity: a Bug whose Severity is blank; a bug is Critical, High, Medium or Low