Skip to content

Commit e42b006

Browse files
committed
refactor: #2336 filed; the path arguments ran
The path matcher of agent-mode scan and rollback selects nothing for an absolute pattern under the default --cwd, or for a lone dot. Five neighbouring areas ran clean. Assisted-by: Claude Code:claude-fable-5-2
1 parent baa5405 commit e42b006

2 files changed

Lines changed: 112 additions & 13 deletions

File tree

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
[agent] 2026-11-28: architecture refactor
2+
3+
**`main`:** cfc870f. The run started at 10: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 none has changed since 2026-11-26 (each `updated_at` is the same): none merged or closed, none has a review from a person, and no maintainer has commented on the discussion. The only issue opened by anyone else since the last run is #2335, a `bughunt` issue for Bun. The PR shepherd commented on #2270 at 10:09Z: it still blocks `ci-ok`.
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 run under this charter had executed: the path arguments of agent-mode `scan` and of `rollback`. I chose it by counting which flags and modules the 34 earlier entries name; the path matcher (CLI `src/path_scope.rs`) was in none. Two spellings of a directory select nothing: filed as #2336. The other things I ran beside it are clean.
9+
10+
### PR
11+
None opened. #2261, #2265 and #2267 still await review. `main` has not moved from cfc870f.
12+
13+
### Leads and issues
14+
15+
**New: L68, filed as #2336.** An agent-mode `scan [PATHS]` and a `rollback <path>` share one matcher. Over a real npm workspace (`kleur`, `left-pad` twice and `ms`, installed by npm 10.9, each with a patch from a stand-in API), from the project directory:
16+
17+
```
18+
$ socket-patch scan --mode agent --yes "$PWD/packages/b"; echo "exit $?"
19+
No installed packages found under the given path: /work/ws/packages/b.
20+
exit 0 # files patched: 0 of 4
21+
$ socket-patch scan --mode agent --yes .; echo "exit $?"
22+
No installed packages found under the given path: ..
23+
exit 0
24+
$ socket-patch scan --mode agent --yes packages/b | head -2 # control
25+
Found 1 package (1 npm)
26+
Applied 1 patch.
27+
$ socket-patch rollback --yes "$PWD/packages/b"; echo "exit $?"
28+
Error: Path pattern matched no patched packages: /work/ws/packages/b (…)
29+
exit 1
30+
$ socket-patch rollback --yes .; echo "exit $?"
31+
Error: No patch found matching identifier: . (to target a directory instead, use ./. or ./**)
32+
exit 1
33+
$ socket-patch rollback --yes ./.; echo "exit $?"
34+
Error: Path pattern matched no patched packages: ./. (…)
35+
exit 1
36+
```
37+
38+
With `--cwd "$PWD"` the absolute path selects the package in both commands. So there are two causes in one function:
39+
40+
- **An absolute pattern is compared with the copy's path as the crawler gave it**, and under the default `--cwd .` that path is `./packages/b/node_modules/left-pad` (`BoundScope::matches`, lines 141 to 165; the comment at line 145 says "crawler paths are already absolute", the struct's comment at line 130 says they are not). The relative-pattern branch has stripped the cwd as given since #231. The contract (line 451) says absolute patterns match the absolute path.
41+
- **`.` normalizes to itself and is never tried**: the ancestor walk goes from the copy's relative path down to its first component and stops. `*` and `**` select everything, `.` nothing. `rollback` builds its hint as `./{id}`, which for `.` cannot match.
42+
43+
Hosted and vendored mode read the same argument as a project directory and take `.`, `./`, `"$PWD"` and `"$PWD/packages/b"` under every `--cwd` spelling (33 runs). The same holds in agent mode for a pnpm workspace member (a link into the root store) and a Python virtualenv. Two unit tests beside the matcher's own fail on `main`, with their controls passing; the issue has them, a table of eight spellings against two modes, and the plan. It is not a decision issue: the contract's absolute-path and ancestor rules settle both. `./` stays the usage error the contract names; the issue leaves that to a maintainer.
44+
45+
It joins the queue after #2315: a scan that reports nothing found, exits 0 and patches nothing, in a spelling scripts use (`"$GITHUB_WORKSPACE/apps/web"`).
46+
47+
**Seen and not filed:**
48+
- **`packages//b` and `packages/../packages/b`** select nothing in agent mode and work in hosted mode. The contract calls the agent match "purely textual". Named in #2336.
49+
- **A shell inside a symlinked directory** has a `$PWD` the kernel's working directory does not spell, so `"$PWD/packages/b"` will still miss there after the planned fix unless the matcher also compares with the cwd as given. Named in #2336.
50+
- **A purl with an uppercase npm name** (`pkg:npm/Left-Pad@1.2.0`) selects the package for `scan --package` and is `patch_not_found` for `rollback` and `remove`, where the bare name `Left-Pad` selects it in all three. No tool writes an npm purl in uppercase.
51+
- **`apply --check --vex <path>`** exits 0 and writes no document, without a word. The contract says so (line 738: "it stays read-only and offline-safe, leaving the output path untouched").
52+
53+
**L08, L13, L14, #1970:** still to verify. They need Windows, scala-cli or Docker.
54+
55+
### Areas examined
56+
All with the binary built from `main`, over the npm workspace above unless said.
57+
58+
- **The path arguments of agent-mode `scan` and of `rollback`** (CLI `src/path_scope.rs`): 25 spellings of a pattern under the default `--cwd`, 24 combinations of pattern and `--cwd` (relative, absolute, with a trailing slash or `/.`, through a symlink, from the parent directory, from inside the symlink), 20 `rollback` targets, the same patterns in a pnpm 10.28.0 workspace and a uv virtualenv, and 33 runs of hosted and vendored mode over the same spellings. #2336; relative patterns, globs, backslashes and trailing slashes select what they name.
59+
- **`--cwd` spelled three ways** (default, absolute, relative from the parent), 19 commands each: `scan` dry, wet and `--sync`, `list`, `apply`, `apply --check`, `vex`, `repair`, `rollback` dry, wet and by purl, and `remove`, human and `--json`, outputs compared after normalizing the project path. Clean: they differ only in how an event's `path` is spelled and in the order of `rollback`'s events (#1836).
60+
- **`--verbose`** with `--json` on 14 commands and with `vex -O -` (stdout is one document; stderr is empty but for `vex`'s `Emitted 4 VEX statements`), and with `--silent` on 5 (both streams empty). Clean.
61+
- **Where a relative VEX path lands**: `vex -O`, `apply --vex`, `scan --vex` and `SOCKET_CWD`, each run from the parent with `--cwd`. All write under the process's directory, as `--help` says.
62+
- **What `--prune` removes under each filter**: with four patches applied, `scan --sync` with `--package` (a match and no match), `--min-severity critical`, `--ecosystems pypi`, a PATH, `--max-new-patches 0`, and a `socket.yml` with `ignorePackages`, `enabled: false` and `minSeverity: critical` (12 runs). Clean: no filter makes the prune drop a patch of an installed package.
63+
- **One target in 17 spellings** against `rollback`, `remove` and `scan --package` (51 runs): a name in three cases, a purl with and without a version, with a qualifier, percent-encoded, a short version, a full, short and padded uuid. Nothing new: they differ where the contract says they do (a qualified purl is exact for the undo commands and ignored by `--package`), and in the uppercase purl above.
64+
65+
### Lessons
66+
- **Count what the entries never name.** A loop over the flags of every `--help` and over the CLI's modules, each grepped in `entries/refactor/`, listed 27 flags and nine modules no entry mentions. The matcher was one of them, and the first batch of commands over it showed the defect. Most of the others turned out to be exercised under another name, so the list is a place to look, not a finding.
67+
- **Give a path argument every spelling a script would.** Relative, `.`, `./`, `"$PWD"` and `"$PWD/sub"`, with no `--cwd`. The suites pin an absolute `--cwd` for hermeticity (the register's note on `--cwd` already says why), and the matcher's unit tests bind `/proj`, so neither can meet a relative candidate with an absolute pattern.
68+
- **Two comments in one file that contradict each other mark the spot.** Line 130 says crawler paths are not absolute and line 145 says they are.
69+
- **When one argument is read by two implementations, run both.** `[PATHS]` is a project directory in hosted and vendored mode and a glob over installed copies in agent mode. The first accepts every spelling, which is what makes the second's answer a defect and not a design.
70+
- **A catalog from the installed bytes.** `mkcat.py <out> <purl>=<package dir>:<file>` reads each installed file as the patch's `before` and appends a comment for `after`; the stand-in API of the 22:56Z entry of 11-26 serves it unchanged. With a real `npm install` that is an agent-mode project and patch service in under a minute:
71+
72+
```python
73+
#!/usr/bin/env python3
74+
"""mkcat.py <out catalog.json> <purl>=<installed package dir>:<file>[,...] ..."""
75+
import sys, json, base64, hashlib, os
76+
def gh(b): return hashlib.sha256(b"blob %d\0" % len(b) + b).hexdigest()
77+
cat = {}
78+
for n, spec in enumerate(sys.argv[2:], 1):
79+
purl, rest = spec.split("=", 1)
80+
d, files = rest.split(":", 1)
81+
fs = {}
82+
for f in files.split(","):
83+
before = open(os.path.join(d, f), "rb").read()
84+
after = before + b"\n/* socket patched %d */\n" % n
85+
fs["package/" + f] = {"before": base64.b64encode(before).decode(), "after": base64.b64encode(after).decode(), "beforeHash": gh(before), "afterHash": gh(after)}
86+
cat[purl] = [{"uuid": "%08x-1111-4111-8111-%012x" % (n, n), "purl": purl, "tier": "free", "severity": "high", "ghsa": "GHSA-aaaa-bbbb-%04d" % n, "cve": "CVE-2026-%04d" % n, "publishedAt": "2026-01-01T00:00:00Z", "files": fs}]
87+
json.dump(cat, open(sys.argv[1], "w"), indent=1)
88+
```
89+
90+
- The hunt took about 20 minutes of wall time: the build 3 (in the background, while reading the matcher and the contract), the fixture and the path spellings 6, the two probe tests 4 (two builds of the CLI's unit tests), the other areas 7.
91+
- The register was at 11,993 characters and is at 11,991. L68 joined the collapsed `filed` row and the three areas the third Areas row. To make room, five phrases of that row, one lead, one recipe and three notes are shorter. `wc -m` counts bytes in this sandbox's locale (12,015 before): count with Python's `len`.
92+
- The owner was notified of #2336.
93+
94+
### Needs a person
95+
- **#2336: an agent-mode scan scoped to an absolute path, or to `.`, exits 0 and patches nothing**, and `rollback` fails on the same paths. It asks nothing; the fix is in one function.
96+
- **Review #2261, #2265 and #2267.** This is the twenty-eighth run in a row that could only verify leads.
97+
- **#2270** still blocks `ci-ok` on every PR; #2280 is open for it.
98+
- **#2309, #2277 and #2297 need an answer.** **#2299** and **#2315** each ask which of two fixes a maintainer prefers.
99+
- Thirty-seven confirmed problems wait for a slot. #2301, #2303, #2305, #2308, #2310, #2312 with #2314, #2317, #2287, #2330, #2332, #2290, #2299, #2327 with #2334, #2318, #2321, #2286, #2289, #2315 and #2336 go first, then #2259, #2294, #2296, #2271, L22 (after #2261), #647, #1917, #1926, #1860 beside #2271, #1836, #2306, #2322, #2324, #2328, #2319 and #2333.

0 commit comments

Comments
 (0)