Skip to content

Publish license categories based only on literal data - #177

Open
elrayle wants to merge 4 commits into
elr/license-categories-source-provenancefrom
elr/license-categories-data-only
Open

elrayle wants to merge 4 commits into
elr/license-categories-source-provenancefrom
elr/license-categories-data-only

Conversation

@elrayle

@elrayle elrayle commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator

Stack position

Layer 3 of the fresh four-PR stack, based on #176 (elr/license-categories-release-policy at 6c84574c70c4eb9a85f760633bc3eed9ebf2874d). This PR targets that parent branch. The existing #174 and its branches remain intact. Fetch/npm-generation integration and scheduled updates belong to layer 4 and are not included here.

Changes

  • Make generator verification ignore all three fixed leading provenance values, while requiring exact generator ownership, header labels/order, nonempty values, and byte-for-byte equality everywhere else.
  • Compare only literal categoryDescriptions and licensesById from the packed dist/generated.js against the most recently published npm artifact. Ignore the entire header, all comments, literal formatting/key order, and other package files for automatic publication decisions.
  • Parse with the existing TypeScript dependency without importing or evaluating downloaded JavaScript. Reject missing, malformed, duplicate, nonliteral, unsupported, or TypeScript-only data syntax explicitly.
  • Allow verified Actions workflow_dispatch to publish unchanged data for non-data fixes. Preserve consistent, unused, semantically newer version requirements, archive/integrity and registry checks, first-publication handling, exact refs, the enablement gate, and the GitHub prerelease guard. No automatic version bumps or older-track bypass.
  • Preserve local/release/dispatch provenance production and existing SPDX identifier behavior; full-SHA expansion is deferred. Update the operations guide and add real-built local/release/dispatch stamp cross-product coverage.

Validation

  • go test -race ./cmd/license-categories/... passed.
  • golangci-lint run ./cmd/license-categories/... passed with zero issues.
  • make verify-license-categories passed before and after the commit; existing missing-ScanCode metadata warnings were unchanged.
  • npm test --prefix packages/license-categories passed all 26 checks, including independent tarball import, offline registry fixtures, forced-dispatch version reuse rejection, malformed-data failures, and stamped built-data equivalence.
  • Workflow YAML parsed with Ruby; workflow safeguard assertions passed. actionlint was not installed. Local checks used Node.js 26.4.0; the unchanged workflows use Node.js 24.
  • git diff --check passed.

No npm publication, workflow dispatch, remote-setting changes, or merges were performed.

Copilot AI adaptive review requested due to automatic review settings November 11, 2026 17:38
@elrayle
elrayle added this pull request to stack #179 November 11, 2026 17:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unresolved critical issues let executable code in provenance headers evade source verification and cause validation and publication to fail on shallow CI checkouts.

4 open issues
What changed in this PR

Makes automatic license-category publication depend on literal generated data rather than provenance or unrelated package files, while allowing manual publication of non-data fixes.

Changes:

  • Ignore all three leading provenance values during source verification while preserving other comparisons.
  • Parse and compare packaged license data without executing downloaded JavaScript.
  • Allow verified manual dispatch to publish unchanged data, preserving version safeguards and expanding tests and documentation.
File Description
packages/​license-categories/​test/​stamp-provenance.test.mjs Tests built-data equivalence across provenance stamps.
packages/​license-categories/​test/​prepare-publication.test.mjs Covers data-only comparison, forced dispatch, and malformed data.
packages/​license-categories/​script/​prepare-publication.mjs Adds literal-data parsing, comparison, and dispatch override.
packages/​license-categories/​docs/​operations.md Documents comparison rules and manual publication policy.
cmd/​license-categories/​main.go Normalizes all three provenance values during verification.
cmd/​license-categories/​main_test.go Updates provenance acceptance and rejection coverage.

Review effort: Max (auto)

len(bytes.TrimSpace(lines[i+1][len(prefix):])) == 0 {
return nil, fmt.Errorf("generated data must have a nonempty %q provenance header on line %d", prefix, i+2)
}
lines[i+1] = []byte(prefix + "<provenance>")
Comment on lines +56 to +58
const script = new URL('../script/prepare-publication.mjs', import.meta.url).pathname
const run = (event, ref) => {
assert.throws(() => execFileSync(process.execPath, [script, join(directory, 'candidate.tgz')], {
Comment on lines +76 to +77
if (!ts.isPropertyAssignment(property) || property.questionToken || property.exclamationToken
|| !(ts.isStringLiteral(property.name) || ts.isIdentifier(property.name))) unsupported()
} else if (name === 'licensesById') {
data.set(name, objectValue(declaration.initializer, node => {
const record = objectValue(node, stringValue)
if (Object.keys(record).sort().join(',') !== 'category,name') unsupported()
@elrayle
elrayle force-pushed the elr/license-categories-data-only branch from d3b0f4d to 2238d31 Compare November 11, 2026 18:43
@elrayle
elrayle removed this pull request from stack #179 November 11, 2026 18:44
@elrayle
elrayle changed the base branch from elr/license-categories-release-policy to elr/license-categories-source-provenance November 11, 2026 18:45
@elrayle
elrayle added this pull request to stack #184 November 11, 2026 18:45
@elrayle
elrayle force-pushed the elr/license-categories-source-provenance branch from 5977708 to 51fc71f Compare November 11, 2026 21:00
@elrayle
elrayle force-pushed the elr/license-categories-data-only branch from 2238d31 to a991934 Compare November 11, 2026 21:03
@elrayle
elrayle force-pushed the elr/license-categories-source-provenance branch from 168fc68 to fbd47e2 Compare November 11, 2026 22:25
elrayle and others added 4 commits November 11, 2026 17:26
Ignore all three leading provenance values during generated-source verification while retaining strict header and remaining-byte checks. Compare packed literal license data for automatic releases; allow validated dispatches to publish non-data fixes without weakening version or registry safeguards.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Build mismatching refs in a temporary Git repository and run the Actions entry point there, so depth-one checkouts exercise the intended commit-mismatch guard without relying on HEAD~1.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Keep the data-only provenance cross-product test aligned with the inherited released-event contract after synchronizing the stack.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Run the isolated publication fixture from its own packaged helper, supply event SHAs to provenance equivalence checks, and exercise comment terminator rejection for every normalized header.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@elrayle
elrayle force-pushed the elr/license-categories-data-only branch from a991934 to a0b1264 Compare November 11, 2026 22:28
@elrayle
elrayle removed this pull request from stack #184 November 12, 2026 11:28
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.

2 participants