Skip to content

Commit bdf37bf

Browse files
committed
refactor: projects v4 wrote, run with main
One issue filed (#2344) and the evidence for #594. The v4 hooks, agent state, vendored state on seven ecosystems and hosted state on twenty package managers ran; the rest is clean or already known. Assisted-by: Claude Code:claude-fable-5-2
1 parent 569665f commit bdf37bf

2 files changed

Lines changed: 121 additions & 13 deletions

File tree

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
[agent] 2026-11-28: architecture refactor
2+
3+
**`main`:** cfc870f. The run started at 18:56Z.
4+
5+
### Chosen
6+
No PR this run. Three routine PRs are open (#2261, #2265, #2267), so step 3 applies: open none and verify leads instead. All three are `ready` and unchanged since 2026-11-26: none merged or closed, none has a review from a person, and no maintainer has commented on the discussion. One issue was opened by another routine since 16:55Z (#2343, `bughunt`); it does not carry `arch-audit`.
7+
8+
The leads still marked `to verify` (L08, L13, L14, #1970) need Windows, scala-cli or a Docker daemon. So this run took an area no entry names: **a project that v4.0.0 last wrote, run with the binary built from `main`.** The reason it matters now: v4's `setup` wrote an unpinned hook into `package.json`,
9+
10+
```
11+
"postinstall": "npx @socketsecurity/socket-patch apply --silent --ecosystems npm"
12+
```
13+
14+
and the npm registry's `latest` for that package is 5.1.0 (`npm view @socketsecurity/socket-patch dist-tags`). Every v4 project with that hook has been running v5's `apply` on fresh runners since the release, whether or not anyone upgraded.
15+
16+
I built the `v4.0.0` tag, let it patch real projects in each of its three modes, committed them, and ran `main` over clones with the real package managers. Most of it is clean. Two problems are confirmed: one is a new issue (#2344), the other is the evidence an open issue was missing (#594).
17+
18+
### PR
19+
None opened. #2261, #2265 and #2267 still await review. `main` has not moved from cfc870f.
20+
21+
### Leads and issues
22+
23+
**New: L74, filed as #2344.** `apply` checks that every manifest record has its blobs before it reads which records are vendored. A project v4 vendored has the record and no blob (v4's vendored scan wrote the record to `.socket/manifest.json` and kept the content in memory). On `main`, with `left-pad@1.3.0` vendored by v4 and installed patched:
24+
25+
```
26+
$ socket-patch vendor --check
27+
pkg:npm/left-pad@1.3.0: committed artifact and wiring verified # exit 0
28+
$ socket-patch apply --check --offline
29+
No patches to check. # exit 0
30+
$ socket-patch apply --offline
31+
Error: 1 patch has no local source and --offline is set:
32+
- pkg:npm/left-pad@1.3.0
33+
Run `socket-patch repair` to download missing artifacts. # exit 1
34+
$ socket-patch repair
35+
All blobs are present locally. # exit 0, nothing downloaded
36+
$ socket-patch apply --offline # exit 1 again
37+
```
38+
39+
Online, `apply` downloads the blob and then skips the patch as `vendored`; with no patch API it exits 1. `repair` leaves vendored records out on purpose (`repair.rs`, lines 688 to 722, since #115), and `apply` states the same rule for `--ecosystems` a few lines above the call that breaks it (`apply.rs`, lines 3280 to 3299; the ledger is read at line 3371). The same results come from all seven vendored projects of this run. v4.0.0 exits 1 in the same place, so nothing regressed; one `socket-patch scan` moves the record and ends it.
40+
41+
**L75, confirmed; the evidence is a comment on #594.** That issue's remaining half is the hosted restore's own regex over `nuget.config`. An earlier run left it out of charter for want of an input on which the copies disagree. v4 supplies one: it writes the Socket source as the first child of `<packageSources>`, before the project's `<clear />`. On `main`:
42+
43+
```
44+
$ socket-patch rollback # list and remove say the same
45+
Error: […] <packageSourceMapping> routes packages to socket-patch-67016c7e-…, which no <packageSources>
46+
entry defines […] (re-run `socket-patch scan --mode hosted`) or restore them from version control # exit 1
47+
$ socket-patch scan
48+
Switched 1 package to hosted patches; rewrote 1 file. # exit 0
49+
$ socket-patch rollback
50+
Error: […] the config does not define the Socket source socket-patch-67016c7e-… exactly once […] # exit 1
51+
```
52+
53+
The scan adds a second source after the `<clear />` and a second mapping element beside the first. The reader (`formats::nuget::parse_config`) honors `<clear />` and counts identical definitions once; `remove_source` counts every `<add>` in the raw text. No command of `main` undoes that project. The harm is low: NuGet ignores a source before `<clear />`, so the restore was already failing under v4, and I found the input nowhere else. This sandbox has no `dotnet`, so a restore over the doubled mapping did not run.
54+
55+
**L76, out of charter; the migration guide states it.** A single-module Maven project vendored by v4 keeps the same-version `<repository>` wiring, which v5 refuses to extend and still attests. With `commons-io` 2.11.0 in `~/.m2` from an earlier build (Maven 3.9.11):
56+
57+
```
58+
$ mvn dependency:build-classpath # the jar Maven builds with
59+
/root/.m2/repository/commons-io/commons-io/2.11.0/commons-io-2.11.0.jar # 0 patched lines
60+
$ socket-patch vex --product pkg:generic/app@1.0.0 -O vex.json
61+
Warning: […] the installed tree does not match its vendored artifact; […] re-run your package manager's install to resync it.
62+
Wrote OpenVEX document with 1 statement to vex.json # not_affected
63+
```
64+
65+
Maven keeps the cached jar through any install, so the warning's remedy does nothing. `docs/migrating-to-v5.md` says "The pre-v5 `<repository>` wiring was also attested from `pom.xml` alone", #973 decided to retire that wiring, and `scan` and `vendor` refuse the project with the two commands that migrate it. v4 warned at vendoring time (`vendor_maven_local_cache_shadow`); v5 dropped the code because its own pins cannot be shadowed. What a maintainer could still want: `vex` to stop attesting the pre-v5 wiring, or to name the purge.
66+
67+
**#377 (closed, `bughunt`), confirmed again; nothing filed.** v4's `setup` wrote `socket-patch[hook]` into Python requirements. PyPI has `socket-patch` 4.0.0, whose `hook` extra requires `socket-patch-hook`, and no project of that name (`https://pypi.org/pypi/socket-patch-hook/json` is a 404). With pip 24.0 and with uv 0.11.32:
68+
69+
```
70+
$ pip install -r requirements.txt
71+
WARNING: socket-patch 3.3.0 does not provide the extra 'hook'
72+
Successfully installed iniconfig-2.0.0 socket-patch-3.3.0 # exit 0
73+
```
74+
75+
No `.pth` is installed, the package stays unpatched in every new environment, and an activated virtualenv now finds CLI 3.3.0 first on `PATH`. I had the transcript before I searched; #377 said all of it on 2026-09-30 and was closed the next day because `setup` was removed. What is left on `main` is two sentences: `CLI_CONTRACT.md` says of every v4 hook "they keep working until you delete them", and the migration guide tells Python users to uninstall `socket-patch-hook`, which was never installable. `main` reports the Bundler leftover (`gem_bundler_plugin_stale`) and says nothing of this one.
76+
77+
**Seen and not filed:**
78+
- **v4 left `.socket/apply.lock` in the project with no ignore rule.** A project that committed it shows ` D .socket/apply.lock` after every run of `main`, a hook's `apply` included. The contract says the lock never outlives its command.
79+
- **uv, hosted by v4:** `list` exits 1 (`hosted_wiring_contested`) and `vex` omits the patch (`redirect_unwired`), because v4 swapped the wheel URLs under a registry source and `main` writes a URL source. The remedy the message names, a rescan, works: the project ends byte for byte where a scan by `main` alone ends.
80+
- **Bundler, hosted by v4:** v4 replaced `gem "x", "~> 8.10.6"` with a `source … do gem "x", "8.10.6" end` block. `main` keeps the block. The original requirement is only in the retired ledger, whose `edits` the contract says are never replayed.
81+
- **The hook's command in ten states of the project** (see Areas): `main` exits 0 where v4 exited 1 for a package that is not installed or has another version, and exits 1 where v4 exited 0 over a locally edited file, which v4 overwrote.
82+
- **L08, L13, L14, #1970:** still to verify. They need Windows, scala-cli or Docker.
83+
84+
### Areas examined
85+
The v4 binary is the `v4.0.0` tag built in a worktree. Each project holds a real package from its registry and a one-file patch served by a stand-in patch API; v4 patched it, the result was committed, and every run below is a fresh clone with the binary built from `main`.
86+
87+
- **v4's hooks, run by their tools.** npm 10.9.9 (`npm ci`, the hook resolving to `main`'s binary), Bundler 2.5.22 with the plugin v4 committed under `.socket/bundler-plugin/`, Composer 2.8.12 (`post-install-cmd`), and the Python hook's exact command run from another directory with no virtualenv activated. Each leaves the installed file patched and the install at exit 0, as with the v4 binary.
88+
- **The npm hook's command in ten states**, v4 against `main`: plain, already patched, package not installed, no `node_modules`, no `.socket/`, an empty manifest, no blobs, a locally edited file, another version installed, a broken manifest. No state where `main` fails an install that v4 passed, except the edited file.
89+
- **v4 agent state:** `apply --offline`, `scan` (stays in agent mode), a dry scan and `list`. Clean.
90+
- **v4 vendored state** for npm, pip, Composer, Bundler, Cargo, Go and Maven: `vendor --check`, a bare `scan`, `vex`, `rollback`, `vendor --revert` and `repair`, with the real install or build before and after (`npm ci`, `pip install -r`, `composer install`, `bundle install`, `cargo metadata --locked`, `go list -m`, `mvn dependency:build-classpath`). The scan moves the manifest record into the ledger; for Cargo it and `repair` move the `[patch]` entry to `Cargo.toml` and tag the version, as the guide says; for Maven the refusal, the byte-exact `vendor --revert` and the undo commands are as the guide says. Found: L74 in all seven, L76 in Maven.
91+
- **v4 hosted state** on the bench's 20 projects: a scan by `main` alone against v4's hosted scan followed by `main`'s, compared file by file. v4 wires 12 of the 20. Ten end identical but for the retired ledger file; Bundler keeps v4's block; NuGet is L75. `list`, a dry scan, `vex`, `repair`, `rollback` and `remove` over v4's npm state behave as the contract's paragraph on the retired ledger says.
92+
- Not run: v4's state on Windows, a v4 monorepo, yarn, pnpm and Bun vendored locks, and the v4 Python hook itself (it cannot be installed).
93+
94+
### Lessons
95+
- **Ask the registry what a committed command resolves to.** `npm view <pkg> dist-tags` and PyPI's JSON page turned "users upgrade when they choose" into "v4 hooks already run v5". A hook, a lock or a requirement line that names no version is a migration that has already happened.
96+
- **Build the old release to make its state.** `git fetch --depth=1 origin tag v4.0.0`, a worktree and `cargo build -p socket-patch-cli` took 2.5 minutes beside the build of `main`. v4 builds vendored artifacts itself when the service has none, so the plain stand-in API of the 22:56Z entry was enough; the bench serves its hosted scan as it serves `main`'s. Hand-written old state would have missed L74: I would not have known v4 wrote a manifest record for a vendored patch.
97+
- **Search the issues by the artifact's name before building the case.** `search/issues` with `socket-patch-hook` found #377 in one request, after I had the transcript. The same lesson as #2302 two hours earlier; the search belongs before the second command.
98+
- **Three fixture traps.** A `vendor/` rule in `.gitignore` also ignores `.socket/vendor/`, so my first Composer clone had no artifact (`main` refuses that rule as `vendor_artifact_gitignored`; v4 did not). Composer installs from source here, and v4 copied the package with its `.git`, which the outer repository records as a gitlink: move the `.git` out first. Java reads the home directory from the password database, not `HOME`, so `mvn` used the real `~/.m2` while the tool read the one I set.
99+
- **The sandbox refuses `rm -rf` of a path built from a variable.** A runner that makes each state in a new `mktemp -d` directory needs no removal.
100+
- The hunt took about 35 minutes of wall time: the two builds 4 (in the background), the hooks and the differential 8, the vendored states 12, the hosted comparison 6, the two write-ups 5.
101+
- The register was at 11,993 characters and is at 11,982. L74 joined the `filed` row, L76 the out-of-charter row, #594 the confirmed row, and the v4 area the Areas row. To make room, one note about `agent/*` PRs and four recipe pointers went, and two notes are shorter.
102+
- The owner was notified once, of #2344, #594 and the two v4 leftovers that are a maintainer's call.
103+
104+
### Needs a person
105+
- **Review #2261, #2265 and #2267.** This is the thirty-second run in a row that could only verify leads.
106+
- **#2270** still blocks `ci-ok` on every PR; #2280 is open for it.
107+
- **#2340, #2309, #2277 and #2297 need an answer.** **#2299** and **#2315** each ask which of two fixes a maintainer prefers.
108+
- **Two v4 leftovers are a maintainer's call, not defects by the contract.** L76: whether `vex` should keep attesting the pre-v5 Maven wiring, which a cached jar shadows. #377: whether `main` should report a `socket-patch[hook]` requirement as it reports the Bundler plugin, and the contract's sentence that v4 hooks keep working, which is false for Python.
109+
- Forty-one confirmed problems wait for a slot, in the order the register's "Next PR" line gives.

0 commit comments

Comments
 (0)