Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions crates/socket-patch-cli/CLI_CONTRACT.md
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,8 @@ The route is taken only when **all** of these hold; otherwise the run takes the

**pnpm per-branch locks (#556)**: with `gitBranchLockfile` on (a top-level `gitBranchLockfile: true` in the root `pnpm-workspace.yaml`; when the YAML leaves the key unset, `git-branch-lockfile=true` in the root `.npmrc`, as pnpm 10 and older read it; on disk also `pnpm_config_git_branch_lockfile` (pnpm 11 and newer) or `npm_config_git_branch_lockfile` (pnpm 10 and older; either when the major is unknown, read as for the `lockfile` setting above) set to `true`; a workspace member with no `pnpm-workspace.yaml` of its own reads the governing ancestor's file and the `.npmrc` beside it), pnpm installs a git branch from its own `pnpm-lock.<branch>.yaml` whenever that lock exists, in every directory it installs a lock from: the root, and under `sharedWorkspaceLockfile: false` each member's (#492). When the setting is on AND at least one such `pnpm-lock.<branch>.yaml` exists (at the root, or in a member that installs from its own lock), hosted mode leaves every root pnpm lock (`pnpm-lock.yaml`, `shrinkwrap.yaml`) and `pnpm-workspace.yaml` untouched (every member lock too), confirms no npm pin from them and warns `redirect_pnpm_git_branch_lockfile` (in place of `redirect_pnpm_no_lockfile` when the branch lock is the only one); the detail names the setting and the branch lock(s), and the remedy is to turn `gitBranchLockfile` off and fold the branch locks into `pnpm-lock.yaml` with `pnpm install --merge-git-branch-lockfiles`, then re-run. A vendored→hosted takeover of a pnpm-vendored purl is refused with the same code (the vendored wiring and ledger stay byte-for-byte). Vendored mode refuses the same projects with `vendor_pnpm_git_branch_lockfile`, before any write and in the pre-flight. The setting with no branch lock (main, or a branch whose dependencies never changed) installs from `pnpm-lock.yaml`, which both modes wire as usual; a stray branch lock with the setting off is ignored. The in-memory engine fetches root `pnpm-lock.*.yaml` names presence-only and refuses the same way. `vex` omits every pin of those pnpm locks (`vex_pnpm_git_branch_lockfile`) whenever such a branch lock exists, whatever the setting says (fail-closed; read from the project's files only, not the environment); see **Unattested references**.

**pnpm: a hosted package over a local dependency (#2263)**: pnpm 12.23 and newer refuse a lock in which a package that is not local depends on a local file unless they can tie the workspace override to that package, and they cannot for a package a hosted patch pins (the tarball of its pin, or of the named registry of the registry route): every install then fails with `ERR_PNPM_LOCAL_SUBDEP_NOT_ALLOWED`, frozen or not. A vendored patch is a `file:` tarball its dependents are pointed at, so for 9.0 locks neither mode creates the pair, whatever pnpm the project pins. Hosted mode refuses a pin that would make a hosted package of one whose `snapshots:` entry (any peer context) has a `file:` dependency: `redirect_pnpm_local_dependency`, one warning per lock that has the dependency, nothing rewritten in any lock and the patch not confirmed. A package an earlier hosted patch already pins is re-pinned as before, and a `link:` dependency (a peer a workspace project satisfies) refuses nothing. Vendored mode refuses to vendor a package (`vendor_lock_entry_unsupported`, before anything is staged and in the pre-flight; Rush locks included) when a registry-keyed dependent of it resolves to a hosted patch's tarball. A dependent that is local itself (a vendored one among them), on the default registry, or on any other tarball URL (`lockfileIncludeTarballUrl`) is not in the way. A hosted → vendored takeover in `scan` / `get --mode vendored` judges each pin against the lock as the run found it, so a hosted dependency of a hosted package stays hosted in the run that vendors the package and is vendored by the next run (the first run exits 1); two hosted packages that depend on each other are refused on every such run. A plain `vendor` eject restores every pin first and vendors them in one run. The remedy for either refusal is one mode for the package and its dependency.

`redirect_pnpm_no_lockfile` names pnpm when installer markers exist without a lock; `redirect_pnpm_entry_vendored` identifies a vendored entry instead of reporting it missing. Supported `shrinkwrap.yaml` files are writable lockfiles, not read-only markers, when no `pnpm-lock.yaml` sits beside them. pnpm >= 3 never reads a `shrinkwrap.yaml` it has a `pnpm-lock.yaml` for, so that one is shadowed (unless the project pins pnpm 1 or 2 in `node_modules/.modules.yaml` or package.json's `packageManager`: those read only `shrinkwrap.yaml`, so there the stray `pnpm-lock.yaml` is the shadowed one): hosted mode never rewrites it and leaves it out of the all-or-nothing gate, so an entry it cannot repoint (or pnpm 1's early shrinkwrap head) refuses nothing, and `vex` only sweeps it for stale Socket identities. Vendored mode never writes it either, and refuses a project that pins pnpm 1 or 2 beside a `shrinkwrap.yaml` (`vendor_lockfile_version_unsupported`: it does not write the shrinkwrap grammar, and the stray `pnpm-lock.yaml` would patch nothing pnpm installs).

**vlt hosted-mode contract**: `scan` / `get --mode hosted` rewrite, in `vlt-lock.json`, every default-registry node of a granted `name@version` (the `''` / `npm` segment or a URL segment equal to the lock's scalar `registry`, both DepID grammars, every peer and modifier variant): slot [2] becomes the granted sha512 and slot [3] the hosted URL (appended to a 3-tuple); the DepID, flags and trailing slots, the line ending and every other byte stay. `options` is never edited and `vlt.json` is only read. A lock with another `lockfileVersion` (decided on the raw JSON token), a BOM, a non-object body or a `nodes` section outside vlt's one-node-per-line layout refuses the whole lock (`redirect_vlt_lock_unsupported`). **Confirmation**: vlt drives when its install state (`node_modules/.vlt-lock.json` or `node_modules/.vlt/`) is present or no other npm-family lock is; then only `vlt-lock.json` confirms a uuid. Otherwise every lock is rewritten, `redirect_vlt_sibling_lockfiles` warns, and the other locks' rules confirm, including a dep `vlt-lock.json` merely does not wire (`redirect_vlt_entry_not_found`, `redirect_vlt_entry_vendored`, or `redirect_vlt_custom_registry_skipped` alone). Whichever lock drives, a dep the vlt rewriter refuses (`redirect_vlt_missing_sha512`, `redirect_vlt_unsupported_lock_key`) is never confirmed by any lock, although a sibling lock may already carry its rewritten URL. **Artifacts**: the scan never downloads the hosted artifacts; the patch server sends them unencoded (`Cache-Control: no-transform`), and vlt verifies slot [2] against the bytes it receives at install time. **Heal**: an installed copy is stale when vlt's hidden lock (`node_modules/.vlt-lock.json`) does not record its DepID at the integrity the lock pins, and cannot be checked without a readable hidden lock; stale installed copies of Socket-owned nodes are removed so the next `vlt install` extracts the patched bytes, and `rollback` / `remove` do the same for the registry bytes (`--no-vlt-install-cleanup` keeps them; optional dependencies' copies are always kept); `redirect_vlt_reinstall_required` says what happened and what to run. The same-run `--vex` never attests a vlt package whose installed copy is stale or unchecked, whose lock a vlt release may ignore (`redirect_vlt_lockfile_version_missing`, `redirect_vlt_old_lockfile_ignored`, `redirect_vlt_scalar_registry_ignored`), or which also resolves from a non-default registry (`redirect_vlt_custom_registry_skipped`). `vlt.json` or vlt install state without `vlt-lock.json` warns `redirect_vlt_no_lockfile` instead of `redirect_npm_no_lockfile`. `rollback` / `remove` restore each hosted node's slots [2] and [3] from the version document of the registry the node resolves against (slot [3] is its `dist.tarball`, as vlt writes it; `upstream_registry_fallback` when that registry can't be read), following the lock's own slot-[3] convention (see "Hosted unwind coverage"). Tested releases: `docs/testing/vlt-compatibility.md`.
Expand Down Expand Up @@ -2474,6 +2476,7 @@ command's integration tests check its output.
| `hosted_restore_refused` / `hosted_write_failed` | `failed` (`details.mode: "hosted"`) | rollback (v5.0): a hosted pin's upstream restore was refused (detail names the `git checkout` remedy), or writing the restored lockfiles failed (artifact-level, no `purl`; on `--dry-run`: would fail). That write is all or nothing, so no pin of the run is `rolledBack` / `verified` beside it; the detail ends `nothing was written` / `nothing was changed`, or names each file that could not be put back (see "Hosted unwind coverage"). Exit 1. |
| `gc_skipped` | rollback `warnings[]` | rollback (v5.0): the artifact GC could not run (a before-blob gate abort, an unreadable vendor ledger); `gc` is absent. Not raised under `--preserve-state`, which never asks for one. |
| `registry_entry_unused` | `removed` (`verified` on dry-run; artifact-level, no `purl`) | repair, scan (and `get --mode hosted`, which runs the same rewrite): an entry of hosted mode's pnpm registry route that no lockfile uses any more was taken out of pnpm-workspace.yaml or a pnpm lock (`details: {mode: "hosted", file, entry, key, value?}`; `entry` is `registry`, `override`, `lockOverride` or `lockKey`). A registry's address is never in the event. Bumps no `summary` counter; counted in `gc.removedRegistryEntries` where the run reports a `gc`. See "pnpm registry route", *Cleanup*. |
| `redirect_pnpm_local_dependency` | `warnings[]` (warning, one per lock) | scan/get `--mode hosted` (pnpm, 9.0 locks): the pin would make a hosted package of one whose `snapshots:` entry depends on a local `file:` package (a vendored one among them). pnpm 12.23 and newer refuse that lock on every install (`ERR_PNPM_LOCAL_SUBDEP_NOT_ALLOWED`), so nothing is rewritten in any lock and the patch is `skipped` / `redirect_unconfirmed`. The detail names the lock and the dependency; patch both in one mode (`scan --mode hosted` takes a vendored dependency over). See "pnpm: a hosted package over a local dependency". |
| `redirect_pnpm_registry_held` | `warnings[]` (warning) | scan/get `--mode hosted` (pnpm): a release the project routes through its patch's registry has a newer patch, and this run does not update pnpm-workspace.yaml (`--no-trust-lockfile-config`, an unreadable file, a lock that could not be converted back). The newer patch's tarball under the old patch's registry would not install, so the lock entry is left on the patch it is routed to and the newer patch is `skipped` / `redirect_unconfirmed`. The detail names the releases and, under the opt-out, says to re-run without the flag. See "pnpm registry route", *Cleanup*. |
| `registry_cleanup_unknown_host` | repair + scan run-level `warnings[]` | repair, `scan --prune`, a hosted scan that crawled no package: pnpm-workspace.yaml declares registries in the shape of a patch's registry (`socket-<hex>` at a patch's directory with matching digits) on a host this run was not given as a patch server. They were left alone, as a registry of the project's own is, so nothing of them was tidied. One warning per host; the detail gives the count, the host's origin (never the address) and `--patch-server-url <origin>` / `SOCKET_PATCH_SERVER_URL` as what lets the command tidy them. The run continues and exits 0. See "pnpm registry route", *Cleanup* (Limits). |
| `registry_cleanup_skipped` / `registry_cleanup_failed` | repair + scan run-level `warnings[]` | repair, `scan --prune`, a hosted scan that crawled no package: the cleanup of unused pnpm registry entries could not read the pnpm locks or pnpm-workspace.yaml to tell what still uses the route (`…_skipped`; nothing was removed), or could not write the cleaned files (`…_failed`; they are as they were, or the detail names each one that is not). `…_failed` is also what a hosted scan reports when it could not delete a pnpm-workspace.yaml a run created and it has emptied (the file is left holding its `packages:` list; the detail says to delete it). The run continues and exits 0. |
Expand Down
Loading
Loading