GeezerVison is showing github.com — fix(setup,scan): fail closed on corrupt manifests, JSON envelopes on every hosted failure; fetch_stage unit tests by mikolalysenko · Pull Request #152 · SocketDev/socket-patch
Conversation
Summary
Stacked on #150 (retarget to main once it lands). Three coverage gaps from the 2026-08-10 structure review, each fixed with the RED-first test that pins it:
-
setup --exclude clobbered a corrupt manifest — persist_setup_excludes flattened a read/parse error to "no manifest yet" and rewrote the file as a bare setup block, destroying every patch record a merely-corrupt (possibly hand-recoverable) manifest still held. Now fails closed: persistence is skipped with a loud stderr warning and the manifest bytes are untouched. Exit semantics deliberately unchanged (the broader setup exit-code question stays a separate product decision). RED-verified: exclude_persistence_fails_closed_on_corrupt_manifest.
-
scan --redirect --json emitted empty stdout on every failure exit — discovery-detail failure, reference-resolve failure, and both write failures returned exit 1 with nothing to parse. All four bail-outs now emit the machine-readable error envelope (status/error/redirect.mode, mirroring the success envelope's error fold). RED-verified: redirect_json_mode_failures_emit_error_envelope (both legs).
-
fetch_stage.rs had zero direct tests (443-LOC offline-guard-critical download planner). New in-src unit tests pin: the read-only-.socket/ contract on the Unavailable path, in-place staging when fully cached, the documented disk-vs-vendor staging asymmetry (diff archive sufficient for apply, insufficient for vendor), writable_blobs overlay promotion (late downloads can't pollute the cache), overlay_dir semantics, and the bad --download-mode hard failure.
Verification
- Both regression tests RED-verified against the unfixed code, then green with the fixes.
- All 7 fetch_stage unit tests green; neighboring vendor/scan/redirect suites green.
cargo clippy --workspace --all-targets -- -D warnings and cargo fmt --check clean.
🤖 Generated with Claude Code
Note Medium Risk
Touches manifest persistence and hosted redirect CLI output on failure paths; changes are fail-closed and test-backed but affect data-loss and automation parsing behavior.
Overview
Closes three contract gaps with regression tests and targeted behavior fixes.
setup --exclude no longer treats a unreadable or corrupt .socket/manifest.json as “no manifest”: it skips persisting excludes, warns on stderr, and leaves the file byte-identical so patch records are not wiped for an exclude list.
scan --redirect --json (hosted) early failures (discovery, reference resolve, lockfile write, redirect ledger write) now print a parseable JSON envelope on stdout (status: error, error, redirect.mode: hosted) instead of exit 1 with empty stdout; stderr behavior is unchanged.
fetch_stage gains in-module unit tests for offline staging, read-only .socket/, disk vs vendor diff-archive policy, writable_blobs overlay promotion, overlay_dir, and invalid --download-mode.
Reviewed by Cursor Bugbot for commit 078fa1f. Configure here.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…every hosted failure; fetch_stage unit tests
Three coverage gaps from the 2026-08-10 structure review, each with the
test that pins it:
* setup --exclude persistence clobbered a corrupt manifest:
persist_setup_excludes flattened a read/parse error to "no manifest
yet" and rewrote the file as a bare setup block, destroying every
patch record a merely-corrupt manifest still held. Now fails closed
(skip persistence, warn on stderr, manifest bytes untouched). RED
test: exclude_persistence_fails_closed_on_corrupt_manifest.
* scan --redirect --json emitted empty stdout on every failure exit
(discovery-detail failure, reference-resolve failure, file/ledger
write failure) — exit 1 with nothing to parse. All four bail-outs now
emit the machine-readable error envelope (status/error mirror the
success envelope's error fold). RED test:
redirect_json_mode_failures_emit_error_envelope.
* fetch_stage.rs (the offline-guard-critical download planner) had zero
direct tests. In-src unit tests now pin: the read-only-.socket
contract, in-place staging when fully cached, the diff-archive
disk-vs-vendor staging asymmetry both module docs describe, overlay
promotion for late downloads, overlay_dir semantics, and the
bad --download-mode hard failure.
Co-Authored-By: Claude Fable 5 <[email protected]>
|
Folded into #150 — the stack was consolidated into a single PR at the author's request; this PR's commit is included there verbatim (cherry-picked, all tests green on the consolidated head).
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|