Skip to content

rfc(pnpr): publish-time manifest verification - #47

Merged
zkochan merged 5 commits into
mainfrom
rfc/pnpr-publish-manifest-verification
Oct 31, 2026
Merged

zkochan merged 5 commits into
mainfrom
rfc/pnpr-publish-manifest-verification

Conversation

@zkochan

@zkochan zkochan commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Summary

Split from #44. When a package is published to a pnpr-hosted registry, derive its install-critical metadata from the archive's package.json, compare it with the submitted manifest, and reject the publish if they disagree. After acceptance, serve only the archive-derived metadata.

This closes manifest confusion for hosted packages without any client or protocol change, and doesn't depend on the other drafts split from #44.

Related drafts

🤖 Generated with Claude Code

Split from #44.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 49 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8aae8675-97e9-4806-a173-1f0f7f49ac69
Commits

Reviewing files that changed from the base of the PR and between ea127a2 and 7f7277e.

Files selected for processing: 1
  • pnpr/text/0000-publish-manifest-verification.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

zkochan added a commit that referenced this pull request Oct 27, 2026
#44 was split into #47, #48, and #49.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
zkochan added a commit that referenced this pull request Oct 27, 2026
#44 was split into #47, #48, and #49.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
npm publish uploads the output of @npmcli/package-json prepare(), not the
raw package.json, so a strict comparison would reject ordinary uploads
(bin refs, the gypfile install-script injection, bundleDependencies true,
version cleaning). Define these as profile normalizations, accept the one
benign direction (submitted claims a build the archive cannot run), add
name and version to the compared fields, and add evidence from the npm
trackers plus a 1,674-package survey of registry metadata vs archives.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@zkochan

zkochan commented Oct 28, 2026

Copy link
Copy Markdown
Member Author

Updated in 5eca093.

  • npm publish uploads the output of @npmcli/package-json's prepare(), not the raw package.json. A strict comparison would reject ordinary uploads. Examples: bin refs, the gypfile step that sets node-gyp rebuild when a *.gyp file is in the source directory, bundleDependencies: true, and version cleaning. These are now profile normalizations applied to both sides.
  • One direction stays benign after normalization: the submitted manifest claims a build the archive cannot run ([email protected]). It is accepted and served from the archive. The reverse direction is always rejected.
  • Added name and version to the compared fields (Registry should reject packages with mismatched name/version npm/feedback#797), and always-derived hasInstallScript and _hasShrinkwrap.
  • Added evidence from the npm trackers and a survey of the 1,674 registry packages in pnpm/pnpm's lockfile. 46 differ before normalization, and all 46 are explained by the normalizations above.

Written by an agent (Claude Code, claude-opus-5-5).

Add the latest version of the 5,000 most-downloaded packages and a random
older version of each of the top 2,000. 273 of 8,620 versions differ
before normalization; all are explained by publisher-side normalization,
which adds empty-vs-absent maps, directories.bin expansion, stripped build
metadata, and git shorthand expansion to the profile.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@zkochan

zkochan commented Oct 29, 2026

Copy link
Copy Markdown
Member Author

Updated in d49aaf6: the survey now also covers the latest version of the 5,000 most-downloaded packages and a random older version of each of the top 2,000: 8,620 versions in total. 273 (about 3%) differ before normalization, and every one is explained by publisher-side normalization. The new rules: empty map versus absent field, directories.bin expanded into bin, semver build metadata stripped from version (lerna canary builds), and a git shorthand expanded to github:. The only version whose metadata claims a build its archive can't run is still [email protected]. The profile section lists the added rules.


Written by an agent (Claude Code, claude-opus-5-5).

@zkochan
zkochan marked this pull request as ready for review October 31, 2026 17:52
@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

RFC: Verify hosted package manifests at publish time

📝 Documentation 🕐 40+ Minutes

Grey Divider

AI Description

• Proposes rejecting hosted publications whose submitted install metadata disagrees with the package
 archive.
• Defines publisher-side normalizations so ordinary npm uploads pass without hiding unsafe
 mismatches.
• Proposes serving immutable, archive-derived manifests under versioned interpretation profiles.
Diagram

graph TD
  Publish["Hosted publication"] --> Validate["Validate archive"] --> Derive["Derive manifest"] --> Normalize["Normalize manifests"] --> Compare{"Fields agree?"} --> Store["Store accepted profile"] --> Serve["Serve derived metadata"]
  Compare -->|unsafe mismatch| Reject["Reject publication"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Verify at install time
  • ➕ Protects clients using registries pnpr does not host.
  • ➖ Detects disagreement only after publication and resolution; requires client changes.
2. Replace submitted metadata without rejection
  • ➕ Avoids rejecting incompatible publisher uploads.
  • ➖ Conceals unexpected publisher behavior and may serve metadata the publisher did not expect.
3. Warn without rejecting
  • ➕ Minimizes publication friction.
  • ➖ Leaves conflicting metadata available to consumers.

Recommendation: Prefer the proposed publish-time check for hosted packages: it prevents unsafe mismatches before they reach consumers while normalizing documented publisher behavior. Install-time verification is complementary for other registries, not a substitute.

Files changed (1) +243 / -0

Documentation (1) +243 / -0
0000-publish-manifest-verification.mdSpecify publish-time verification of hosted package manifests +243/-0

Specify publish-time verification of hosted package manifests

• Adds a draft RFC for comparing submitted install-critical metadata with the archive's package.json, rejecting unsafe disagreements, and serving immutable archive-derived metadata. It documents publisher-side normalization, survey evidence across 8,620 package versions, versioned interpretation profiles, implementation steps, and unresolved policy decisions. No implementation or tests are added.

pnpr/text/0000-publish-manifest-verification.md

@zkochan
zkochan merged commit 7fe8add into main Oct 31, 2026
1 check passed
zkochan added a commit that referenced this pull request Nov 1, 2026
zkochan added a commit that referenced this pull request Nov 1, 2026
* docs(pnpr): propose atomic workspace publication

* docs(pnpr): define publication through SQL transactions

* rfc(pnpr): build on the split SQL metadata storage draft

#44 was split into #47, #48, and #49.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* rfc(pnpr): add evidence, keyless retries, uploads by integrity, and workload batches

Add npm tracker evidence for half-published releases and ghost-version
conflicts. Name the pnpr gaps the transaction must close: a byte-identical
retry returns VersionAlreadyPublished, one 100 MiB body carries every
archive, and OIDC workloads can only PUT a single package. Upload archives
by integrity before commit, treat content as the idempotency key for
keyless clients, let workloads submit transactions, and let staging hold a
whole transaction.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* rfc(pnpr): record committed publications for clients to read

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* rfc(pnpr): advance the current reference on commit, backfill publications, keep the policy epoch across replacement

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* rfc(pnpr): commit publications with releases, match whole keyless requests, recover outcomes after revocation, drain before export

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* rfc(pnpr): settle transaction scope, ecosystems, keyless batches, and retention

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
zkochan added a commit that referenced this pull request Nov 1, 2026
zkochan added a commit that referenced this pull request Nov 1, 2026
* rfc(pnpr): platform variants, one version with many artifacts

Let a version carry a primary archive plus platform-tagged variant
archives, published together and described in dist.pnpr.variants. pnpm
locks every variant in the existing variations resolution and links the
matching one as the package, replacing the per-platform optionalDependencies
pattern behind npm/cli#4828 and install-script binary downloads.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* rfc(pnpr): fit platform variants to packages and tools that would migrate

Check the RFC against 32 npm packages that use per-platform optional
dependencies and against tools shipped only as GitHub release archives,
and adjust it where they would not fit:

- a variant lists several platforms (static Linux builds, macOS
  universal binaries) and is named by a tag carried in the lockfile;
- the primary is optional, for tools with no portable implementation;
- bundled dependencies are excluded from the dependency-equality check,
  so wasm32 variants and fallbacks can carry their runtime;
- virtual store keys, Node ABI targets, per-archive provenance;
- a Migration section with the packages, the tools, and what does not fit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* rfc(pnpr): fold platform variants prototype results into the RFC

A prototype on real packages (esbuild, biome, rolldown, lightningcss,
tailwind oxide, typst) found that:

- global virtual store slots must be keyed by the selected archive;
- the installer must record the linked variant to relink on a change;
- older pnpm rewrites the lockfile without variants unless frozen;
- npm gets a primary that fails, so the compatibility view ships first;
- pnpm fetch must fetch every variant supportedArchitectures matches;
- archives must be uploaded one per request.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs: rewrap a paragraph

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* rfc(pnpr): let platform variants declare their own dependencies

Variants may now declare different dependencies and optionalDependencies,
as platform packages do today. Peer dependencies must still be equal, and
a dependency name that more than one archive declares must use the same
specifier in each. The lockfile resolves every archive's dependencies and
records which archives use each one, so it stays the same on every
platform.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* rfc(pnpr): declare variant platforms as explicit combinations

The os, cpu and libc arrays of package.json match every combination of
their values. A variant now lists its platforms one by one, and those
arrays never select a variant. The compatibility view gets one reserved
name per platform when a variant's platforms are not a full cross
product, so npm never installs a variant on a platform it does not serve.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* rfc(pnpr): declare a variant's platforms in its own package.json

A variant's package.json now declares its tag and platforms in a
platformVariant field. pnpr derives dist.pnpr.variants from the verified
archive, so the archive's provenance covers where the build claims to
run. Variants may no longer declare os, cpu, or libc, so there is one
statement of where a variant runs, and the publish command needs no
--platform flag.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* rfc(pnpr): keep variant integrities out of large packuments

Variant integrities do not compress, so inline they make a packument
several times larger. Large documents are split under a media type that
clients opt into: each version's dist moves to its immutable version
document and is marked dist.pnpr.details external, except for the
versions a resolution almost always picks. The prototype measured cold
resolution 29 to 40 percent faster. A release record covers every
archive of a version.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* rfc(pnpr): keep split metadata in a cache of its own

An older client that shares the metadata cache must never read a split
document, whose versions lack their integrity. The prototype hit this
with an older pnpm on PATH.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* rfc(pnpr): refer to the split packuments RFC

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* rfc(pnpr): move whole versions of split packuments, with corrected numbers

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* rfc(pnpr): external versions and release records for split packuments

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* rfc(pnpr): other versions with recent publish times in split packuments

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* rfc(pnpr): split packuments in a format of pnpr's own

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* rfc(pnpr): link the merged split packuments RFC

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* rfc(pnpr): describe variants only in pnpr's package document

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* rfc(pnpr): variants as a field of a version's entry

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* rfc(pnpr): variants reach pnpm only from declared pnpr registries

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* rfc(pnpr): name the variant declaration field variant

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* rfc(pnpr): derive a variant's tag from its platforms

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* rfc(pnpr): clarify primary-less variants, revision in VariationsResolution, and link #47

* rfc(pnpr): use manifest on variant entries, specify route encoding, and drop post-publish variant mutation question

* docs(pnpr): use flat variant snapshot keys instead of archiveDependencies

* docs(pnpr): derive lockfile variant tag from targets instead of adding tag field

* docs(pnpr): use batch publish with integrity-addressed blob uploads instead of stages

* rfc(pnpr): deterministic variant tags, per-variant specifiers, manifest overrides, generated primary trust

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs: rewrap paragraphs

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* rfc(pnpr): one provenance statement from the release job names every archive

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* rfc(pnpr): show variant manifests in the metadata example

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* rfc(pnpr): link the merged atomic workspace publication RFC

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* rfc(pnpr): libc in the generated primary, one generated primary per revision, optional dependencies in variant snapshots

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* rfc(pnpr): serve the selected revision's generated primary to npm clients

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* rfc(pnpr): compare variants' external dependencies, without bundled ones

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* rfc(pnpr): compare variants' resolved dependencies with the version's snapshot

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* rfc(pnpr): compare and record a variant's complete resolved snapshot

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* rfc(pnpr): align the lockfile change list with the snapshot rule

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* rfc(pnpr): unknown tag fields without a primary fail like an unmatched host

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
zkochan added a commit that referenced this pull request Nov 1, 2026
#44 was split into #47, #48, and #49.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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