GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Agent mode writes the patch into PDM's shared install cache when PDM 2.0–2.12 installs packages as directory symlinks (install.cache + symlink) · Issue #332 · SocketDev/socket-patch Closed Labels agent:triagedbugSomething isn't workingSomething isn't workingbughuntFound by a scheduled package-manager bug-hunt agentFound by a scheduled package-manager bug-hunt agentpm:pdmPDMPDMpriority:p1 Description[agent] Found by the scheduled PDM bug-hunt routine (ledger #312). SummaryOn PDM 2.0 – 2.12 with The rename-over write in Impact
PDM 2.15+ (and 2.x Repro (Linux, real PDM, mock patch API serving
|
| PDM | cache_method | Linux | macOS | Windows |
|---|---|---|---|---|
| 2.0.3 | symlink (dir) | writes through (local) | — | — |
| 2.8.2 | symlink (dir) | writes through (local + CI) | writes through | writes through |
| 2.10.4 | symlink (dir) | writes through (local) | — | — |
| 2.11.2 | symlink (dir) | writes through (local) | — | — |
| 2.12.4 | symlink (dir) | writes through (local + CI) | writes through | writes through |
| 2.15.4 / 2.20.1 / 2.26.9 / 2.29.2 | symlink (per-file) | OK | OK (2.15.4, 2.29.2) | OK |
| 2.12.4 – 2.29.2 | hardlink | OK | OK | OK |
| 2.10.4 | pth | fails closed (File not found), OK |
— | — |
PDM 1.x (feature.install_cache) was not tested.
crates/socket-patch-core/src/patch/apply.rs:496-513: the stage-and-rename is done in filepath.parent(), which resolves through the symlinked site-packages/<pkg> directory.crates/socket-patch-core/src/utils/fs.rs:457 (atomic_write_bytes)Neither checks whether any ancestor between the package root (site-packages) and the file is a symlink.
Probe run: https://github.com/SocketDev/socket-patch/actions/runs/36735829162 (tested on main f6b7fb9, latest release v4.0.0).
[agent] Triaged: priority:p1 (PDM). Not a duplicate, and no existing fix PR. The cause is that agent apply's copy-on-write rename in patch/apply.rs guards only a symlinked or hardlinked file. A symlinked ancestor directory between site-packages and the file isn't checked, so the write goes through into PDM's shared cache.
Generated by Claude Code
[agent] Re-triage on v5: this still reproduces on main 2463257 (#277, the v5 consolidation).
I re-ran the probe.py from the issue (real PDM, local mock API, install.cache=true, cache_method=symlink) against a release build of 2463257, twice on Linux:
| PDM | site-packages/urllib3 |
scan exit / applied | PDM cache patched | never-scanned project b patched |
verdict |
|---|---|---|---|---|---|
| 2.12.4 | dir symlink → pdmcache/packages/urllib3-1.26.18-py2.py3-none-any/lib/urllib3 |
0 / 1 | yes | yes (no .socket/) |
BUG (2/2 runs) |
| 2.29.2 (control) | real dir, per-file symlinks | 0 / 1 | no | no | OK |
v5 doesn't change the agent-mode write path, so the suspect code is the same as before (the stage-and-rename in filepath.parent() in crates/socket-patch-core/src/patch/apply.rs). macOS and Windows weren't re-probed this run.
Generated by Claude Code
[agent] New information from the PDM bug-hunt routine (ledger #312): global mode hits this too. On main 6e7ef74, PDM 2.12.4 with install.cache = true / install.cache_method = symlink installs the pdm add -g package into the global interpreter as a directory symlink (/usr/local/lib/python3.11/dist-packages/urllib3 -> ~/.cache/pdm/packages/urllib3-1.26.18-py2.py3-none-any/lib/urllib3). socket-patch scan -g --mode agent --yes then writes the patch into PDM's shared cache:
scan -g --mode agent -> status success, applied 1
cache response.py -> marker present (patched)
unrelated project (venv.in_project, never scanned, no .socket/) -> pdm lock && pdm sync -> marker present
rollback -g -> cache restored byte-for-byte, and the unrelated project is un-patched too
This reproduced 2 out of 2 times. It's the same root cause (apply.rs stages and renames through the symlinked package directory). The maintainer's global-mode checklist asks specifically that -g never patch PDM's install cache, so scan -g, apply -g and rollback -g need the fix as well. The control passes: on PDM 2.29.2 the global-project venv links per file, the rename breaks the link, and the cache stays pristine.
Generated by Claude Code
[agent] Re-triaged after the global-mode comment: still priority:p1. Same root cause (agent apply stages and renames through a symlinked package directory in patch/apply.rs), so scan -g / apply -g / rollback -g are in scope for this issue.
Generated by Claude Code
[agent] Claiming this issue (with #361; shared root cause: agent apply/rollback write through a symlinked package directory into a cross-project shared store, PDM's package cache or pnpm's global virtual store links/, because the copy-on-write rename only isolates the file entry, not its directory). Branch: agent/fix-agent-apply-shared-store-dir. Claim-ID: 2026-10-01T17:20:57Z-c763be
Generated by Claude Code