Repository navigation
Read patch files committed to .socket/blob/ when .socket/blobs/ lacks them - #2514
Mikola Lysenko (mikolalysenko) wants to merge 5 commits into
Conversation
…acks them A project whose patch files were committed under `.socket/blob/` (an older commit layout, as written by an integration) has every byte of its patch in the repository, in a folder the CLI never read. Each `apply` downloaded the files again, `apply --offline` failed with "no local source", and once the patch service stopped serving a superseded patch the run failed with "Blob not found on server" and exit 1. The apply source stager now looks for a blob `.socket/blobs/` lacks in `.socket/blob/` before it counts it as missing. A file found there is read into memory and used only when it is a regular file reached through no link and its bytes hash (git-sha256) to its name; any other file is ignored and the blob is downloaded as before. The verified bytes are handed to the pipeline as in-memory sources, so `apply` still writes nothing under `.socket/`, needs no API client when the folder covers the run, and `get` / `scan`'s nested apply get the same behaviour. A run that read such files says so once (`Warning:` on stderr, muted by `--silent`; run warning `legacy_blob_dir` in `--json`) and points at `socket-patch repair`, which now copies the blobs the manifest references from `.socket/blob/` into `.socket/blobs/` before any download (with `--offline` too; `--dry-run` reports the copy). The legacy folder is never modified, and no sweep reads it. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ed cases The stager asked the server by hash for what `.socket/blobs/` lacked, which skips an entry the overlay holds in any form. It now asks, as before this branch, for what the overlay lacks by the cache's own rule, less the blobs read from `.socket/blob/`. Tests: a run with one patch's file in the legacy folder and another's nowhere downloads only the second and applies both; `get`'s nested apply reads the legacy folder, makes no blob request and carries the `legacy_blob_dir` warning in both output modes. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
- `repair` copies from the legacy folder by the whole manifest, not the one scoped to non-vendored records: `apply` stages for vendored records too, so its advisory named files `repair` never copied and never cleared. - `repair` tells a person what is left to do (commit `.socket/blobs/`), which only the `--json` warning said. A dry run, which copied nothing, no longer says to commit, nor that every blob is present. - The "no download" test counts requests on a listening server: against a dead endpoint it could not fail. - Say why the stager reads the legacy blobs up front. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A project in the older layout was set up long ago and often holds a patch that has since been replaced. Now that its `apply` runs offline, this notice is the only one it gets, and `repair` only copies the old files as they are. `scan` moves the manifest to the current patches and stores their files in `.socket/blobs/`, so the notice names it first and `repair` second, and says to commit `.socket/`. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
PR SummaryMedium Risk Overview Legacy files are accepted only as regular, non-symlink entries whose bytes match their git-sha256 filename; verified content is passed through
Reviewed by Cursor Bugbot for commit c359dbb. Configure here. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit c359dbb. Configure here.
|
[agent] PR shepherd: review brief What it does. Projects that committed their patch files under the older Risk: low. It only acts when a Look here
Verified. Read the whole diff. Changes I made. No code changes. I answered Bugbot's "legacy hit skips bad cache entries" thread and resolved it: the no-overlay path it describes is the one Open questions. None. The description's "Declined" list covers the remaining trade-offs: no fallback when a Generated by Claude Code |

Problem
A project whose patch files were committed under
.socket/blob/(an older commit layout, as written by an integration) has every byte of its patch in the repository, in a folder the CLI never read. So:applydownloaded the patch files again;apply --offlinefailed with "no local source";applyfailed with "Blob not found on server" and exit 1, although the files were in the checkout.Change
One fallback, in the apply source stager (
commands/fetch_stage.rs, the place that decides "missing, so download"). A blob.socket/blobs/lacks is looked for in.socket/blob/before it counts as missing.apply, the nested apply ofgetandscan, and--offlineall go through it.A legacy file is used only when it is a regular file reached through no link (same rules as
.socket/blobs/) and its bytes hash (git-sha256) to its name. Any other file is ignored and the blob is downloaded as before.The verified bytes are handed to the pipeline as in-memory sources.
applystill writes nothing under.socket/, and builds no API client when the folder covers the run.The run says so once, on stderr (muted by
--silent), and as run warninglegacy_blob_dirin--json:scanis named first on purpose. A project in this layout was set up long ago and often holds a patch that has since been replaced. Now that itsapplyruns offline, this notice is the only one it gets.scanmoves the manifest to the current patches and stores their files in.socket/blobs/;repaironly copies the old files as they are.repaircopies them. Before any download,repaircopies the blobs the manifest references that.socket/blobs/lacks (or holds corrupt) from.socket/blob/, through the existing verified blob writer. It works with--offline;--dry-runreports the copy and makes none. It goes by the whole manifest (vendored records included, asapplystages them), so theapplynotice clears after onerepair. It printsand reports the same
legacy_blob_dirwarning in--json. The legacy folder is never modified or removed: it is the user's committed data.Readers left alone
rollback: needs before-hash blobs, which the older layout never held; it fetches them on demand as before.remove,vendor,vex,get/ agent download: they read or fill.socket/blobs/and work afterrepairhas copied the files. Giving each its own fallback would spread the legacy name over every reader.repair,remove,rollback,scan --prune) only read.socket/blobs/,diffs/andpackages/. Checked on a real project: ascan --pruneand arepairleave.socket/blob/and every file in it untouched. This PR does not widen them.Tests
tests/apply/legacy_blob_dir.rs): offline apply from the legacy folder alone, with.socket/unchanged; online apply against an endpoint that refuses every request; a partly covered run downloads only the uncovered blob; the--jsonwarning and--silent; a corrupt legacy file is ignored; linked entries are not followed;repair --offlinecopies and the next apply is quiet.get's nested apply (tests/get/get_nested_apply_api_flags_e2e.rs): reads the legacy folder, makes no blob request, andgetcarries the warning in both output modes.Review (
/code-review high)Fixed:
.socket/blobs/lacked instead of what the overlay lacked, so an entry the overlay does not mirror (a link, a directory) was no longer downloaded. It is the old rule again, less the legacy blobs.repaircopied by the manifest scoped to non-vendored records whileapplystages vendored records too, so the notice could name filesrepairnever copied.repairnow copies by the whole manifest. Not covered by a test of its own (a vendored fixture needs a full vendor run).repairin human mode did not say to commit.socket/blobs/; a dry run said to commit and that every blob was present. Both fixed.Declined:
applydoes not use an intact legacy copy when.socket/blobs/holds a corrupt entry of the same name. Finding that out means hashing the whole cache on everyapply, whichapplyhas never done;repairrestores such an entry from the legacy folder. The contract row says so.applyreads every legacy blob the cache lacks on every run, a no-op run included. The offline gate and the download plan need to know up front which hashes have a usable source, only a read can tell, and holding the verified bytes is what makes the bytes checked the bytes written. It replaces a download of the same blobs on every run, and onerepairends it. Said in a comment..socket/blob/and no longer in the manifest is not recognised as Socket content. It was not recognised before this change either; the fallback covers the blobs the manifest references.Windows
A Windows test run was dispatched by hand (PR runs have no Windows job) on the commit before the last two, which change a contract sentence and the notice text. All tests this PR adds passed there. One test failed,
quoted_url_credentials::a_hosted_warning_quotes_a_lock_entry_without_its_tokenin the scan suite; it fails onmainon Windows too and is in code this PR does not touch.Generated by Claude Code