You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 8ce40d9
Browse filesBrowse the repository at this point in the historyBrowse files
Demote hosted format-1 bun.lockb locks exactly on the vendor takeover
The bun backtest's binary job failed only for the format-1 writers (Bun
0.1.1 / 0.1.6, readers 0.5.9 and 1.4.2) after 65aa074: the hosted rewrite
promotes a format-1 lock to format 2 (format 1 has no URL column), and
the new native upstream restorer rebuilt the registry record inside that
promoted lock. The vendor ledger then recorded the promoted bytes as its
pre-vendor original, so `vendor --revert` returned a format-2 lock and
e2e_bun_lockb's "the revert restores the pre-hosted bytes exactly"
assertion failed. A promoted lock is byte-for-byte indistinguishable from
one Bun 0.1.7+ wrote (same pool order, same metadata hash), and hosted
mode keeps no ledger, so the restorer could not tell.
The codec now marks a lock whenever an edit had to normalize it: seven
magic bytes and a flag byte in the last eight bytes of the root package's
resolution (the root resolution's value union, which no Bun reader reads;
early writers leave uninitialized bytes there, and 1.4.2 / 0.5.9 read such
locks). For a promoted lock those bytes are new, so the mark overwrites
nothing. promote_legacy_format sets NORMALIZED_FORMAT_1;
normalize_workspace_behaviors sets NORMALIZED_WORKSPACE when it changes a
dependency behavior or workspace literal. The vendor ledger's
layout_original path normalizes the original the same way, so its exact
revert is unchanged.
The bun.lockb upstream restorer then:
- demotes a NORMALIZED_FORMAT_1 lock back to format 1 once every hosted
record is rebuilt (BunLockb::demote_legacy_format, which drops the URL
column and the URLs the promotion appended to the pool, and succeeds
only if promoting the result again reproduces the lock byte for byte).
Otherwise the pins are refused with the `git checkout -- bun.lockb`
remedy.
- refuses a NORMALIZED_WORKSPACE lock outright with that remedy, since
clearing the workspace behavior bit cannot be undone. It no longer
takes the lock over non-exactly.
Tests: the upstream restorer's byte-exact test now covers 0.1.1 / 0.1.6.
Workspace-normalized extension locks refuse, and so does a lock whose mark
carries an unknown flag. The codec rebuild test checks the exact
demotion. vendor_eject_bun_lockb adds the 0.1.1 / 0.1.6 takeover with an
exact revert and a workspace-lock refusal. Locally with real Bun, the
1.4.2 reader x 0.1.1 / 0.1.6 writer cells now pass the takeover and the
exact revert. They then stop at the 0.5.9 legacy reader, which segfaults
on any networked install in this sandbox. The 1.1.45 / 1.2.0 / 1.4.2
cells pass everything except the `extensions` shape, which needs
api.github.com (403 here).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018tncU7u7FK48tubFNA12UQ
***Scope.** The hosted pins are what lockfile discovery finds — `(purl, patch uuid, files wiring it)`, recognized only on `https://patch.socket.dev` or the `--patch-server-url` / `SOCKET_PATCH_SERVER_URL` origin. A scoped rollback (paths / identifiers / `--ecosystems`) restores exactly the pins in scope; each pin restores or refuses on its own (there is no whole-ledger replay, and a pre-v5 ledger's edits are never replayed). A pin discovery cannot see is out of reach: a lockless cargo `registry = "socket-patch-<uuid>"` pin, a nuget exact-id mapping with no `packages.lock.json`, a gem wired only in the `Gemfile` (pre-bundler-2.6 mixed state) — restore those files from version control.
959
959
***What a restore does.** Every file wiring the pin is rewritten back to the DEFAULT UPSTREAM registry entry for `name@version`, re-resolving whatever the entry pins (tarball URL, integrity, checksum, hashes) from the public registry; only the hosted entries change and every other byte stays the file's own. A pin is **all-or-nothing**: refused in one of its files, it is restored in none of them, so no pin is left half hosted. Nothing reaches disk until every pin has resolved, and `--dry-run` resolves exactly like a wet run — registry lookups included — and skips only the write. Per format:
960
-
* **npm family** — `package-lock.json` / `npm-shrinkwrap.json`, `yarn.lock` (classic and berry), `pnpm-lock.yaml` / `shrinkwrap.yaml`, `bun.lock`: resolution + integrity (+ shasum where recorded) from the npm registry's version document (`SOCKET_NPM_REGISTRY`). Side settings: a project `.npmrc` that is exactly `allow-remote=all\n` is deleted once no root npm lock entry is hosted, otherwise a remaining top-level `allow-remote=all` warns `npm_allow_remote_left`; a `pnpm-workspace.yaml` that is exactly the scaffold hosted mode creates is deleted once `pnpm-lock.yaml` is no longer hosted, otherwise a remaining `trustLockfile: true` warns `pnpm_trust_lockfile_left`. **`bun.lockb` (binary)**: `rollback` and `remove` refuse it (the checkout remedy) — a rebuilt record is not byte-exact for every lock: a binary format 1 lock stays promoted to format 2 and a workspace lock keeps its normalized dependency behaviors. The hosted → vendored takeover and the eject DO restore it, since the vendor ledger then records the rebuilt record as its pre-vendor original: the native codec turns each hosted remote-tarball record back into Bun's npm registry record for `name@version` (the registry's `dist.tarball` + `dist.integrity`, the package metadata hash re-derived, the hosted URL string dropped from the string pool). The hosted rewrite keeps the registry record's inactive bytes (padding, semver) in the tarball record, so a lock it wrote comes back byte for byte — early writers' uninitialized padding included; a record without them (an older socket-patch or a Bun re-save) is rebuilt the way Bun writes one, and refused for a prerelease/build version.
960
+
* **npm family** — `package-lock.json` / `npm-shrinkwrap.json`, `yarn.lock` (classic and berry), `pnpm-lock.yaml` / `shrinkwrap.yaml`, `bun.lock`: resolution + integrity (+ shasum where recorded) from the npm registry's version document (`SOCKET_NPM_REGISTRY`). Side settings: a project `.npmrc` that is exactly `allow-remote=all\n` is deleted once no root npm lock entry is hosted, otherwise a remaining top-level `allow-remote=all` warns `npm_allow_remote_left`; a `pnpm-workspace.yaml` that is exactly the scaffold hosted mode creates is deleted once `pnpm-lock.yaml` is no longer hosted, otherwise a remaining `trustLockfile: true` warns `pnpm_trust_lockfile_left`. **`bun.lockb` (binary)**: `rollback` and `remove` refuse it (the checkout remedy). The hosted → vendored takeover and the eject DO restore it, since the vendor ledger then records the rebuilt record as its pre-vendor original: the native codec turns each hosted remote-tarball record back into Bun's npm registry record for `name@version` (the registry's `dist.tarball` + `dist.integrity`, the package metadata hash re-derived, the hosted URL string dropped from the string pool). The hosted rewrite keeps the registry record's inactive bytes (padding, semver) in the tarball record, so a lock it wrote comes back byte for byte — early writers' uninitialized padding included; a record without them (an older socket-patch or a Bun re-save) is rebuilt the way Bun writes one, and refused for a prerelease/build version. A lock the hosted rewrite had to normalize is marked in the root package's resolution value bytes (which no Bun reader reads): a binary format 1 lock it promoted to format 2 is demoted back to its exact format-1 bytes (verified by promoting it again, otherwise refused), and a lock whose workspace dependency behaviors it normalized is refused with the `git checkout -- bun.lockb` remedy.
961
961
***vlt** — `vlt-lock.json`: slot [2] from the registry's `dist.integrity`, slot [3] per the lock's own convention (see the vlt hosted-mode contract); every hosted instance of the pin together.
962
962
***cargo** — `Cargo.lock` back on crates.io (source + the sparse index's checksum, `SOCKET_CRATES_INDEX`); every `Cargo.toml` declaration loses its `registry = "socket-patch-<uuid>"` pin (the shorthand the rewriter produced collapses back); the unreferenced `[registries.socket-patch-<uuid>]` block leaves the project cargo config. A declaration it cannot unpin refuses.
963
963
***golang** — the hosted `replace` and the socket module's go.sum lines go; the upstream module's two go.sum lines come back, hashed from the module proxy (`SOCKET_GOPROXY`, else `GOPROXY` / `GONOPROXY` / `GOPRIVATE` as go reads them) and cross-checked against the checksum database (`SOCKET_GOSUMDB_URL`, else `sum.golang.org` unless `GOSUMDB=off` / `GONOSUMDB` / `GOPRIVATE` say go would not ask it). A `replace` the user had before the hosted run is not recorded anywhere, so the restore lands on the plain upstream module.
0 commit comments