Skip to content

Commit 4acbe5f

Browse files
committed
refactor: #2345 to #2347 filed; hostile paths ran
A stop signal sent to the npm launcher does not reach the binary, so a killed apply goes on to patch the project (#2345). A glob PATH of a hosted or vendored scan reads --cwd as pattern text (#2346). A vendored Maven project cannot be built from a checkout path with a bare percent sign (#2347, a decision issue). Hosted mode on twenty package managers and agent and vendored mode on nine real ones behave the same at seventeen hostile directory names. Assisted-by: Claude Code
1 parent bdf37bf commit 4acbe5f

2 files changed

Lines changed: 119 additions & 8 deletions

File tree

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
[agent] 2026-11-28: architecture refactor
2+
3+
**`main`:** cfc870f. The run started at 20:55Z.
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. Nobody else opened an issue or a PR since 18:56Z.
7+
8+
The leads still marked `to verify` (L08, L13, L14, #1970) need Windows, scala-cli or a Docker daemon. So this run took two things no entry under this charter names:
9+
10+
- **a project or a home directory whose path holds a space, a `#`, a `%`, a quote, a bracket or one of twelve other characters**, in all three modes;
11+
- **the npm launcher** in front of the binary, which the charter puts in scope when the defect is there.
12+
13+
The paths came back almost clean: 20 package managers in hosted mode and nine real ones in agent and vendored mode behave the same at 17 hostile directory names as at a plain one. Two path problems are real, one found by reading and one by a real Maven build. The launcher gave the run's main defect. Three issues: #2345, #2346 and #2347 (a decision issue).
14+
15+
### PR
16+
None opened. #2261, #2265 and #2267 still await review. `main` has not moved from cfc870f.
17+
18+
### Leads and issues
19+
20+
**New: L77, filed as #2345.** The npm launcher (`npm/socket-patch/bin/socket-patch`) runs the binary with `spawnSync` and registers no signal listener. A `SIGTERM`, `SIGINT` or `SIGHUP` sent to the launcher's process ends the launcher and leaves the binary running. With the launcher copied beside the binary built from `main`, and a stand-in patch API that answers a blob after 8 seconds:
21+
22+
```
23+
$ socket-patch apply & pid=$!; sleep 3; kill $pid; wait $pid; echo $?
24+
143
25+
$ sleep 9; cat node_modules/left-pad/index.js
26+
module.exports=1
27+
28+
$ node bin/socket-patch apply & pid=$!; sleep 3; kill $pid; wait $pid; echo $?
29+
143
30+
$ sleep 9; cat node_modules/left-pad/index.js
31+
module.exports=2 // patched
32+
```
33+
34+
The same for `SIGINT` and `SIGHUP` (six runs, each process in a session of its own). Against an API that never answers, the binary ran 58 seconds past the launcher's exit. As the main process of a PID namespace (`unshare --pid --fork --mount-proc`, the stand-in for a container), the binary exits 143 at once on `SIGTERM`; the launcher does not react, and the run completes with the file patched.
35+
36+
The contract's "Stop signals" paragraph (line 3186) says a command stopped by one of the three signals ends by it, and exits `128 +` the number as PID 1. The binary does (#808, #1030), and the launcher reports a binary's signal death as `128 +` its number (#1022), but nothing passes a signal on. Who is hit: a supervisor that signals one process, such as a script's `kill $pid`, Node's `subprocess.kill()` and the `timeout` option of `child_process`, `timeout --foreground`, or a container whose main process is the launcher. A terminal's Ctrl-C and plain GNU `timeout` signal the process group and stop both (ran). The fix is in the launcher alone: `spawn`, pass the three signals on, keep the exit status.
37+
38+
**New: L78, filed as #2346. Low harm.** In hosted and vendored mode `scan PATH…` takes a glob "relative to `--cwd`" (the contract, line 450). `project_dirs` (CLI `commands/scan/mod.rs`, lines 1705 to 1745) joins `--cwd` and the PATH and gives the whole string to `glob::glob`, so a `[` in `--cwd` is pattern syntax:
39+
40+
```
41+
$ socket-patch scan --mode hosted --offline --cwd "/work/repo/sites/[brand]" "packages/*"
42+
== /work/repo/sites/b/packages/other ==
43+
== /work/repo/sites/b/packages/other2 ==
44+
$ (cd "/work/repo/sites/[brand]" && socket-patch scan --mode hosted --offline "packages/*")
45+
== packages/a ==
46+
== packages/b2 ==
47+
$ socket-patch scan --mode hosted --offline --cwd "/work/app [v2]" "packages/*"
48+
Error: `packages/*` matches no directory # exit 2
49+
```
50+
51+
A wet scan would rewire the two projects under `sites/b`. A match outside the repository is refused (`path_outside_repo`), a literal PATH works, and so does the default `--cwd .`. Agent mode's reader (`path_scope.rs`) compiles the PATH alone and strips `--cwd` as a prefix: the same pattern selects the same package under `/work/pplain` and `/work/proj[ab]`. The fix is `glob::Pattern::escape` over the `--cwd` part.
52+
53+
**New: L81, filed as #2347 (a decision issue). Low harm.** Vendored Maven writes a fallback repository, `file://${maven.multiModuleProjectDirectory}/.socket/vendor/maven2`. Maven interpolates a raw path and then percent-decodes the URL. Real Maven 3.9.11, each run with a local repository that has not cached the vendored jar:
54+
55+
| Checkout directory | Pristine | Vendored | Vendored, no `.mvn/maven.config` |
56+
|---|---|---|---|
57+
| `plain` | exit 0 | exit 0, vendored jar | exit 0, vendored jar |
58+
| `my%20repo`, `feature%2Fx` | exit 0 | exit 0, vendored jar (the tail) | exit 1, `Could not find artifact` |
59+
| `100% x`, `a%zz` | exit 0 | exit 1, `Invalid artifact repository: For input string: " x" under radix 16` | exit 1, the same |
60+
61+
With a `%` that two hex digits do not follow, Maven cannot read the vendored POM at all, on the Maven the documentation names for vendored mode; the project builds there before vendoring. `vendor --check` says "committed artifact and wiring verified". The `%XX` rows are what #350's closing comment already said (it builds through the 3.9.2 tail, and fails loudly without it); that issue closed with an invitation to open a new one. The fix changes what `vendor` writes into `pom.xml`, so the issue asks: document it, write no fallback where the project pins Maven 3.9.2 or later, or respell the URL. The routine recommends documenting it unless a format change is wanted. The repository's own test shows the first row: `maven_vendor_fresh_checkout_install_and_manifestless_vex` with its fresh checkout renamed fails for `100% x` and passes for nine other names.
62+
63+
**L79, rejected; the copies agree on every manifest the CLI writes.** The npm package exports a zod schema of `.socket/manifest.json` beside the Rust reader. They differ on one field: `zod` 4.6.6's `.uuid()` wants RFC version and variant bits, and Rust takes any string. `12345678-1234-1234-1234-123456789abc` (the uuid of Rust's own unit fixture), `00000000-0000-0000-0000-000000000001` and an unhyphenated one pass `list` and `apply --dry-run` and fail the schema. The CLI mints no patch uuid, and all ten uuids recorded in the docs and the production suites are version 4, so no real project produces the input.
64+
65+
**L80, out of charter; it fails closed.** A stage file is named `.socket-stage-<name>-<uuid>`, 51 bytes longer than the file. A patched file whose own name is over 204 bytes cannot be written:
66+
67+
```
68+
name of 204 bytes: Summary: 1 of 1 targeted patch applied # exit 0
69+
name of 205 bytes: Error: Failed to patch pkg:npm/left-pad@1.3.0: Cannot apply patch: package/aaa….js - File name too long (os error 36) # exit 1, file untouched
70+
```
71+
72+
No package with such a name is known, and a failed apply that exits 1 is the rule. On a filesystem with a shorter limit (eCryptfs, 143 bytes) the threshold is lower; not run.
73+
74+
**Seen and not filed:**
75+
- **A backslash in a directory name** (`proj\x`, Linux): after a vendored rewire pnpm 10.28.0 says `No projects found` and installs nothing with exit 0, and Bun 1.4.4's frozen install exits 1. `vex` warns that the installed tree does not match. No real project has such a path.
76+
- **The tools' own refusals:** a Python virtualenv, Bundler and Poetry refuse a path with `:`, Composer one with `\`, and this sandbox's JVM cannot open a non-ASCII path (its locale), so Maven's `é` cell is no evidence.
77+
- **Bun after `vendor --revert`** keeps the vendored copy through a plain install; the revert says so and names `bun install --force` (#764).
78+
- **L08, L13, L14, #1970:** still to verify. They need Windows, scala-cli or Docker.
79+
80+
### Areas examined
81+
All with the binary built from `main`. The 17 directory names: `my proj`, `proj#1`, `proj%41%2fx`, `proj@2.0.0`, `projé日本`, `proj'q`, `proj"q`, `proj$HOME${x}`, `proj&a;b|c`, `proj[ab]*?`, `proj:x`, `proj\x`, `proj+x=y,z`, `proj<a>&amp;`, `proj{a,b}`, `~proj`, `-proj` (the real-tool runs use shorter forms of the same characters, and `proj (1)`).
82+
83+
- **Hosted mode, the bench's 20 projects**, each copied to the plain name and to the 17, ten commands each (`scan --json` twice, `list --json`, `vex`, `scan`, `list`, `repair --json`, `rollback --dry-run`, `rollback --json`, `scan --dry-run`): exit codes, both streams and every file compared after the path is replaced by a placeholder. Twelve differences, all one thing: Bundler's remedy command quotes the path where the shell needs it, correctly (`'…proj'\''q/…'`). No file holds the absolute path. Then the same with the home directory renamed (Cargo's registry, Go's module cache, `~/.m2`, Gradle's caches and NuGet's packages are read from it): no difference.
84+
- **Agent mode, nine real tools** (npm 10.9.9, pnpm 10.28.0, Yarn 1.22.22, Bun 1.4.4, pip 24.0 in a virtualenv, uv 0.11.32, Poetry 2.4.3 with its out-of-tree virtualenv, Composer 2.8.12, Bundler 4.0.18): a real install at each of 18 names, a hand-built manifest and blobs, then `apply --offline`, the installed bytes, what the tool loads, `apply --check`, `list`, `vex`, `rollback` and the bytes again. The same with the home renamed. Every cell matches the plain one; five cells are the tools' own refusals. Poetry's virtualenv name is a hash of the project's path, and the crawler's copy of that rule found the environment at every name.
85+
- **Vendored mode, the same nine tools** over the repository's fixture service: `vendor`, the files it wrote, the real install (`npm ci`, frozen installs, `pip install --force-reinstall`, `uv sync --reinstall`), what the tool loads, `vendor --check`, `vex`, `list`, `vendor --revert`, the files against the start, the install again. Every cell matches but the backslash ones above. Every reference `vendor` writes is relative.
86+
- **Vendored Maven** by the repository's ignored real-Maven test with its fresh checkout renamed to eleven names, then by hand: L81.
87+
- **The npm launcher:** signals (L77), and the schema (L79). Its candidate order, musl detection and exit status have tests that test them.
88+
- **Read:** the eleven sites that build a regex from a package name, a version, a key or a URL each escape it (`regex::escape`; Gradle's repository filter rules are regexes by design); the parsers of `npm root -g`, `pnpm root -g`, `yarn global dir` and `bun pm ls -g` keep a path with spaces whole; `origin::vendor_ref` refuses `%`, `#` and `::` in a vendored leaf by design.
89+
- Not run: Windows, a hostile path under Cargo, Go, Gradle and NuGet with their real tools, vendored mode with the home renamed, and Docker.
90+
91+
### Lessons
92+
- **The launcher is the product for most users, and no run had started it.** Every earlier signal test signalled the binary. Copy `npm/socket-patch/bin/socket-patch` into a directory beside the built binary named `socket-patch-linux-x64`, and `node <dir>/socket-patch` is the installed command. Ask of each mechanism the contract states (signals, exit status, streams) whether the thing in front of the binary keeps it.
93+
- **A signal test must say which processes it signals.** GNU `timeout` signals the whole process group, so `timeout 3 node bin/socket-patch apply` looked fine. `kill $pid` from a script, or a child started in a session of its own, signals one. My first measurement of the orphan also timed my own next command; watch the installed file, not the clock.
94+
- **Search the issues before the second command, again.** The Maven case took ten minutes before `search/issues` with `"radix 16" maven` showed #350, closed, with the `%XX` half already analysed. The search would have sent me straight to the half that was new.
95+
- **A shared local repository hides a Maven miss.** The first by-hand runs shared one `-Dmaven.repo.local`, the vendored jar was cached by the plain run, and every `%XX` cell passed. Give each cell a copy of the warm repository with the vendored version removed.
96+
- **Shell functions share their variables.** A `run()` that set `name` overwrote the loop's `name`, and two rounds of rows were labelled with the wrong directory. Use `local`, and print the directory the command ran in beside its result.
97+
- **Reading found what 7,000 runs did not.** The differential cannot reach a glob PATH under a hostile `--cwd` unless a command line uses one. After a clean matrix, grep for the engine a path can be fed to (`glob::glob`, `Regex::new(&format!`, `file://`) and read each site.
98+
- **Three runners, about 120 lines of Python each.** `drv.py <pm> proj|home` parses the line the bench prints, keeps a pristine copy of `work/project` and `work/home`, copies it to each name, runs the ten commands, and stores each exit code, both streams and a hash of every file with the path replaced. `agent.py <tool>` makes a real install per name, builds the manifest and two blobs from the installed file plus a marker line, runs the commands, and asks the tool what it loads. `vend.py` runs the same projects against the fixture service, whose source project is a copy no run touches.
99+
- **Two harness traps.** A path with `}` broke my cut of the VEX document out of the combined streams (a warning quoted the path after it): parse stdout alone. And replace the path's JSON-escaped spelling as well as the raw one before comparing.
100+
- The hunt took about 45 minutes of wall time: the builds 9 (the CLI, the bench, the fixture service and one real-Maven test, in the background), the hosted differential 6, the launcher 8, agent and vendored mode 10, Maven 9, the rest reading and the three write-ups.
101+
- The register was at 11,982 characters and is at 11,938. L77, L78 and L81 joined the `filed` row, L79 the rejected row, L80 the out-of-charter row, and the two areas the Areas row. To make room, the out-of-charter row points at the entries for seven leads.
102+
- The owner was notified at 21:29Z of #2345 and #2346, and of #2347 at the end of the run.
103+
104+
### Needs a person
105+
- **#2345:** a stop signal sent to the npm launcher does not reach the binary. It asks nothing; the fix is in the launcher alone.
106+
- **#2347 needs a decision:** document that a vendored Maven project does not build from a checkout path with a `%`, or change what `vendor` writes.
107+
- **Review #2261, #2265 and #2267.** This is the thirty-third run in a row that could only verify leads.
108+
- **#2270** still blocks `ci-ok` on every PR; #2280 is open for it.
109+
- **#2340, #2309, #2277 and #2297 need an answer.** **#2299** and **#2315** each ask which of two fixes a maintainer prefers.
110+
- Forty-three confirmed problems wait for a slot, in the order the register's "Next PR" line gives.

0 commit comments

Comments
 (0)