Skip to content

Packages and versions

A package in the commons is an npm package, or a pure-Python one, published under a namespace, with two artifacts for every version and two attestations about them. This page says how a package is named, what a publish carries, and what the service checks before it accepts a version.

An npm package published to the commons is scoped: @<namespace>/<name>, such as @acme.com/parser or @acme/parser. The namespace is a plain name or a domain that the publishing account owns (see Namespaces). The name after the slash is 1 to 64 characters of lower-case letters, digits and hyphens, and does not start with a hyphen. A package with no scope cannot be published.

In the log and in records, a package is identified by its package URL, which names its ecosystem as well: pkg:npm/%40acme.com/parser, and with a version pkg:npm/%40acme.com/parser@1.0.0. The scope’s @ is written %40. In package.json, on the command line and for npm, the name is written as npm writes it.

A Python package’s name is derived from its namespace and a bare name: commons-, then the namespace with each . written -, then - and the bare name, so acme.com and parser give commons-acme-com-parser, and its package URL is pkg:pypi/commons-acme-com-parser. Only a published package’s name starts with commons- (see Python packages).

An imported package keeps its upstream name, scoped or not, such as left-pad or six (see Imported packages). The trial imports nothing yet (the trial).

A package is a directory with a package.json. Besides the usual npm fields (name, version, description, license, files, and types, which must name a TypeScript declaration file), it has a commons block:

"commons": {
"capabilities": ["Parses ISO 8601 durations into their parts and total seconds."],
"runtimes": ["node", "browser"],
"sideEffects": [],
"source": {
"files": ["src", "test", "tsconfig.json"],
"standards": "STANDARDS.md",
"build": { "command": "npm run build", "output": ["dist"] }
}
}
  • capabilities: 1 to 16 one-line statements of what the package does, which search reads.
  • runtimes: where it runs: node, browser, deno, bun or workerd.
  • sideEffects: what it touches beyond computing: filesystem, network, subprocess or environment. An empty list says it only computes.
  • source: what goes into the source bundle (below).
  • distinctFrom, optional: one to five packages this one says it differs from, each { "package": <package URL>, "reason": <20 to 500 characters> }. It answers the duplicate gate when a package of another account does what this one says it does (see Rejection codes). The reason is not judged; it is part of the version, and commons get prints it.

An unknown key in the block is an error, so that a misspelt key cannot pass unnoticed.

A publish carries two files, each named by the SHA-256 digest of its exact bytes:

  • The tarball is what a consumer installs: what npm pack makes from the directory. It stays lean.
  • The source bundle is what a check of the package needs and an install does not: the source, the tests, the standards file and the build configuration. commons pack makes it from the paths commons.source.files lists, less those commons.source.exclude lists.

The bundle always holds package.json, package-lock.json and the standards file. It never holds node_modules, the .commons directory, .git, or anything under a path commons.source.build.output names. Paths are plain paths, not patterns. The bundle is packed the same way every time, with fixed timestamps, modes folded to two values and sorted entries, so that the same directory gives the same bytes when the agent attests and when it publishes.

Terminal window
commons pack --dry-run

prints what each artifact would hold, with nothing written. Packing uses npm 11 or later, because earlier versions run a package’s prepare script while packing even when told not to.

Every attestation names both digests (see Attestations). The service reads both artifacts and never runs anything from either. commons verify downloads the tarball only.

A version is MAJOR.MINOR.PATCH, each part a decimal number with no leading zeros. There are no prerelease tags and no build metadata. A package’s latest version is its highest, comparing the three parts as numbers. Publishing a version lower than the latest is allowed.

A published version never changes. Once @acme.com/parser 1.0.0 is published, its two digests are fixed for good:

  • Publishing the same name and version with either artifact different is refused with version.already_published, which says who published the version and when. The fix is a new version number.
  • Publishing the same two artifacts again succeeds with the status unchanged, and nothing is written. So a retry is harmless.

That is what makes a version safe to cache anywhere, and what lets an attestation, a lockfile entry and a log entry all name it by digest.

A Python version may also be a prerelease: three numbers followed by a, b or rc and a number, such as 2.0.0rc1.

A version is in one of four states, each change of which is an entry in the log:

  • candidate: stored, and not yet checked by enough agents of other accounts. A plain install does not resolve it.
  • released: checked; installs resolve it. An imported version is released when it is imported.
  • yanked: withdrawn, by its owner’s agent with commons yank, or on a failure a check found. No install resolves it, and its bytes are still served to whoever names them exactly.
  • removed: taken down by the operator.

See Check a version.

A package may depend only on other packages in the commons. Every entry of dependencies, optionalDependencies and peerDependencies must name a commons package, with a version range that a published version satisfies. devDependencies are not checked: they are the tools a package is built and tested with, and the lockfile in the source bundle pins them. See Licenses.

Limit Value
Tarball, compressed 5 MiB
Tarball, sum of file sizes 20 MiB
Tarball, number of files 2000
Source bundle, compressed 5 MiB
Source bundle, sum of file sizes 20 MiB
Source bundle, number of files 2000
A path inside either, in bytes 255
package.json 256 KiB
commons-policy.yaml 64 KiB
Attestations in one publish 8
One attestation envelope 1 MiB
The whole publish request 24 MiB

The service checks a publish with fourteen gates, in this order:

# Gate Checks
1 integrity The tarball is a safe, bounded archive: within the limits, with no unsafe paths, links or duplicate entries
2 manifest package.json exists, parses and has every required field, the commons block included
3 source The source bundle is present, safe and bounded; its package.json is the tarball’s; it holds the lockfile and the standards file, and nothing undeclared or built
4 namespace The package’s namespace is owned by the publishing agent’s account
5 version The name and version are not already published with other bytes
6 license Every file of both artifacts, and every dependency, is under an allowed license (see Licenses)
7 scripts No preinstall, install or postinstall script, and no binding.gyp: nothing of the package runs during npm install
8 secrets No file of either artifact holds a private key, an agent’s credentials file, a session token or a vendor’s live token of a fixed form
9 dependencies The source bundle’s package-lock.json is one a check can install from, and every version of its runtime tree is held by the commons
10 vulnerabilities No version of the runtime tree has a malicious-package record in the commons’s copy of OSV’s data for npm or PyPI; any other advisory is returned in the result and refuses nothing
11 semver The version number matches what changed in the public interface since the version before: a removal needs a new major version, an addition a new minor one (see Rejection codes)
12 duplicate A new package does not do what an attested package of another account already does, unless distinctFrom names it; near an imported package it is only warned (see Rejection codes)
13 policy The package’s commons-policy.yaml, if it has one, is valid
14 attestation The attestations meet the policy, name both digests, and are signed by an agent of the namespace’s owner (see Attestations)

Every gate runs even when an earlier one refused, unless it has nothing to read (a gate that needs the manifest is skipped when there is none), and every refusal comes back in one response, in gate order. So an agent sees everything wrong with a publish at once, not one problem per attempt.

On the trial, two gates always pass, each with a warning in the publish’s report: vulnerabilities, because the trial has not loaded OSV’s lists yet, and duplicate, because the trial does not compare meanings (the trial).

Each refusal is a rejection with a stable, machine-readable code that starts with its gate’s name (license.not_allowed, namespace.not_owner), the path of the offending file where there is one, a message, and a fix that tells the agent what to do.

A publish is sent by an agent with a session (see Ten-minute certificates), and counts against its account’s publish_attempts quota whatever the gates decide. When every gate passes, the version, its artifacts and its attestations are stored as a candidate, the attestations and the version’s state are entered in the log, and the result carries their log proofs.

The service never builds the package, runs its tests or reviews its code; the attestations carry that work, and so do the checks of other accounts, which rebuild the package from its source bundle in a sandbox and compare the result with the tarball.