Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions crates/socket-patch-cli/src/commands/scan/hosted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,25 @@ pub(super) async fn run_redirect(
}
}

// Cross-mode takeover: a committed vendored ledger (`.socket/vendor/state.json`)
// may still claim package(s) this project also has a hosted redirect ledger
// for — their tarballs would then be orphaned and that ledger stale. But the
// overlap alone does NOT prove hosted won: only warn for the package(s) the
// LIVE lockfile actually routes to `patch.socket.dev` (see
// `classify_overlap_takeover`), so a dry-run / no-op over a lock that still
// points at the vendored files stays silent instead of pointing cleanup at
// the live vendored ledger. Warn (JSON `warnings[]` and stderr) WITHOUT
// deleting the other mode's ledger; reconciliation is deferred (see PR Scope).
// Read after the ledger write above so a non-dry-run reflects this run.
let mut takeover_warnings: Vec<serde_json::Value> = Vec::new();
let superseded = super::classify_overlap_takeover(&args.common.cwd).await.redirect;
if !superseded.is_empty() {
takeover_warnings.push(serde_json::json!({
"code": super::REDIRECT_SUPERSEDES_VENDORED,
"detail": super::mode_takeover_detail(&superseded, /*current_is_hosted=*/ true),
}));
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong takeover warning direction

High Severity

Overlap detection only proves both ledgers claim the same PURLs, but each flow still assumes the active command displaced the other and that the lockfile matches that mode. After a real takeover leaves both ledgers on disk, a later hosted dry-run or no-op scan (or a vendored run that does not rewire the overlapping packages) emits the opposite *_supersedes_* warning and remediation, which can point cleanup at the live ledger.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 44df961. Configure here.


// Emit an OpenVEX attestation when `--vex` was requested. The redirected
// bytes are fetched from the hosted patch server at install time, so the
// PURLs CONFIRMED REDIRECTED BY THIS RUN are attested from the ledger
Expand Down Expand Up @@ -534,6 +553,7 @@ pub(super) async fn run_redirect(
warnings.extend(migration_warnings.iter().cloned());
warnings.extend(rush_warnings.iter().cloned());
warnings.extend(pnpm_warnings.iter().cloned());
warnings.extend(takeover_warnings.iter().cloned());
let mut result = serde_json::json!({
"status": "success",
"redirect": {
Expand Down Expand Up @@ -599,6 +619,9 @@ pub(super) async fn run_redirect(
for w in &pnpm_warnings {
eprintln!(" warning: {}", w["detail"].as_str().unwrap_or_default());
}
for w in &takeover_warnings {
eprintln!(" warning: {}", w["detail"].as_str().unwrap_or_default());
}
if let Some(statements) = vex_statements {
eprintln!(
"Wrote OpenVEX document with {} statement(s) to {} (redirected patches are \
Expand Down
Loading
Loading