Skip to content

fix(license): rune-aware SPDX tokenizer + honest GPL/LGPL classifier mapping - #14

Merged
jonyoder merged 1 commit into
mainfrom
license-mapping-fixes
Jul 23, 2026
Merged

jonyoder merged 1 commit into
mainfrom
license-mapping-fixes

Conversation

@jonyoder

Copy link
Copy Markdown
Collaborator

Summary

Resolves three RoboRev findings (jobs 1103, 1104, 1105) on the license/ package, originally raised on the pypi-license-derivation branch (rstudio/package-manager#19135). These files are a faithful port of PPM's PyPI license derivation; the identical fixes are being applied to PPM in sync (rstudio/package-manager PR, linked below) so the cross-parity test there keeps passing.

The three fixes

  1. NBSP / Unicode-whitespace tokenizer (jobs 1103 & 1105). tokenizeSPDX iterated byte-by-byte (rune(expr[i])) while classifying whitespace with unicode.IsSpace, so a multi-byte UTF-8 whitespace separator (e.g. NBSP U+00A0 in MIT<NBSP>OR<NBSP>Apache-2.0) was misread and the expression was not split — producing a single malformed token. The tokenizer now decodes runes via utf8.DecodeRuneInString. ASCII behavior is unchanged; added NBSP and ideographic-space (U+3000) regression cases.

  2. LGPLv3 mapping (job 1104). The classifier GNU Lesser General Public License v3 (LGPLv3) denotes exactly v3 (there is a separate LGPLv3+ classifier for or-later), but mapped to LGPL-3.0-or-later. Corrected to LGPL-3.0-only. The analogous GPLv3 entry was already correct (GPL-3.0-only).

  3. Versionless GPL/LGPL (job 1104). GNU General Public License (GPL) and GNU Library or Lesser General Public License (LGPL) state no version, but mapped to GPL-3.0-only / LGPL-3.0-only, fabricating a version the metadata does not declare. Both are now "SPDXIdentifier": "" / "SPDXNotIncluded": true, so they derive to Unknown (honest, no fabricated version).

Behavior change — needs reviewer attention

Fixes 2 and 3 change license-derivation output for affected classifiers:

  • LGPLv3 -> LGPL-3.0-only (was LGPL-3.0-or-later)
  • versionless GPL / LGPL -> Unknown (was GPL-3.0-only / LGPL-3.0-only)

These feed PPM block/compliance decisions downstream, so they are not cosmetic.

Testing

gofmt / go vet / go test ./license/ all green. Added regression cases for NBSP + ideographic-space tokenization and for all three corrected classifier mappings.

Coordination

After merge: cut v0.1.1 so PPM can re-pin from the temporary pseudo-version to the tag.

🤖 Generated with Claude Code

…mapping

Addresses three RoboRev findings on the license/ package
(rstudio/package-manager#19135):

1. NBSP tokenizer (jobs 1103 & 1105): tokenizeSPDX iterated byte-by-byte
   (rune(expr[i])) while classifying with unicode.IsSpace, so multi-byte
   UTF-8 whitespace separators (e.g. NBSP U+00A0 in "MIT<NBSP>OR<NBSP>
   Apache-2.0") were misread and the expression was not split. The
   tokenizer now decodes runes via utf8.DecodeRuneInString. ASCII
   behavior is unchanged; added NBSP and ideographic-space regressions.

2. LGPLv3 mapping (job 1104): the classifier "GNU Lesser General Public
   License v3 (LGPLv3)" denotes exactly v3 (a separate LGPLv3+ classifier
   exists for or-later), but mapped to LGPL-3.0-or-later. Corrected to
   LGPL-3.0-only. (The analogous GPLv3 entry was already GPL-3.0-only.)

3. Versionless GPL/LGPL (job 1104): "GNU General Public License (GPL)"
   and "GNU Library or Lesser General Public License (LGPL)" stated no
   version but mapped to GPL-3.0-only / LGPL-3.0-only, fabricating a
   version the metadata does not declare. Both are now SPDXIdentifier ""
   / SPDXNotIncluded true, so they derive to "Unknown".

These change license-derivation output: LGPLv3 -> LGPL-3.0-only, and
versionless GPL/LGPL -> Unknown.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jonyoder
jonyoder merged commit e5a9dc4 into main Jul 23, 2026
2 checks passed
@jonyoder
jonyoder deleted the license-mapping-fixes branch August 27, 2026 14:38
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.

1 participant