Repository navigation
Refuse vendored patches the same way everywhere - #2015
Mikola Lysenko (mikolalysenko) wants to merge 1 commit into
Conversation
A vendored run decides before any download which patches the engine would refuse, so it never fetches a view, asks for a grant or strips a hosted pin for a package it cannot vendor. That decision was assembled in the CLI from five sources (the Bun and vlt preflights, the package-lock project refusal, the lock-text gates and the pnpm takeover), and each entry point merged its own subset by hand. They had drifted: the download phase never asked the package-lock project refusal or the pnpm takeover gates, `get <uuid>` raised only the Bun and vlt refusals before the engine, and the vendor loop judged only Bun and vlt before its takeover. All of it now lives in one core function, `socket_patch_core::vendor::refusals::vendor_refusals`, which runs the checks in the engine's order and scopes the lock-text gates (hosted pins, the ledger's idempotency skip, packages that never reach their backend). The scan preview and rollout plan, the download phase, both `get` paths and the vendor loop call it. The CLI's bun_preflight.rs and vlt_preflight.rs are gone, and their tests moved to core. What users see: a v1 package-lock project, or a hosted pnpm pin whose takeover the pnpm gates refuse, is now refused before its patch view is fetched; `get <uuid> --mode vendored` raises every such refusal with its pre-record error envelope and writes nothing; and `vendor` refuses them before restoring a hosted pin instead of restoring and rolling back. Codes and details are unchanged. Assisted-by: Claude Code:claude-opus-5-5
|
Labeled Ready for review by the burn-down agent.
Generated by Claude Code |
Final review briefWhat it does. This PR replaces Risk: medium. This is mostly a move, but more wet paths now apply refusals.
Look here
Verified
Changes I made. None. Open questions (non-blocking)
Merge path: this PR is stacked on #2013, so auto-merge is not armed. Once #2013 merges and this PR is retargeted to Generated by Claude Code |
LLM Description written by Claude Code:claude-opus-5-5
Stacked on #2013.
Summary
The vendored refusals a run can decide before it downloads or writes anything are now one core function,
socket_patch_core::vendor::refusals::vendor_refusals. It replaces five CLI-side sources that every call site merged by hand:commands/bun_preflight.rscommands/vlt_preflight.rsscan/vendor_flow.rs'snpm_lock_refusallock_text_refusalswrapper overagent_download::unclaimed_lock_text_refusalspnpm_takeover_lock_text_refusalsThose CLI modules re-implemented the engine's decision order from outside the engine, and covered gaps in core from the CLI (the unreadable-ledger refusal, the rule that vlt beats Bun). Entry points also drifted: each one asked a different subset of the checks.
It runs the checks in the engine's order, and the first refusal wins:
vendor_state_unreadable;Each check stays in its backend's module;
refusals.rsonly dispatches and scopes them.Callers: the scan preview and rollout plan, the scan download phase, both
get --mode vendoredpaths, and thevendorloop (CandidateGates, which also feeds the download plan).Behavior changes
Codes and detail strings are unchanged. These fix coverage gaps where an entry point skipped checks another one ran:
download_patch_records_v1_package_lock_refuses_before_any_view.get <uuid> --mode vendored: every refusal now exits with the error envelope before anything is written; previously only Bun and vlt did. Test:get_uuid_vendored_over_unhosted_v1_lock_refuses_before_any_write.vendor: it judges all of these before the takeover and the download plan, so a pnpm takeover is refused without first restoring and then rolling back the hosted pin. The now-unreachable package-lock fallback in the takeover is removed. Test:the_plan_leaves_out_a_package_a_v1_package_lock_refuses.Still in the CLI
These are candidates for a follow-up.
Validation
cargo fmt --checkandcargo clippy --workspace --all-features -- -D warnings: clean.--lib: 7146 passed, including 12 newvendor::refusalstests moved from the CLI.get,scan,vendor,repair,rollback,remove,in_process_vendor, the bun/npm-v1/pnpm takeover suites,mode_migration_bun/_vlt,scan_vendor_e2e, and thee2e_vendor_*_buildsuites.scripts/tests: 384 passed.Re-verified after rebasing onto #2013: clippy is clean, and the CLI lib (859) plus
get,vendor,scan,in_process_vendor,in_process_vendor_bun_takeover,hosted_memory_engine,in_process_redirect,mode_migration_vlt,cli_parse_scanandcli_parse_getall pass.In core
--lib,crawlers::nuget_crawler::tests::solution_roots_and_unrestored_projects_keep_the_walkfails on any machine whose real~/.nuget/packagesholds a package. The test crawls the host's global packages folder, and it passes with an emptyHOME. This is unrelated to this stack and also fails on #2013 alone.Bun and vlt aren't installed locally, so their toolchain-gated cases skipped themselves; the
#[ignore]d production tests weren't run.🤖 Generated with Claude Code
Note
Medium Risk
Changes shared vendored download, dry-run preview, and vendor-loop gating across scan/get/vendor; intentional behavior tightening but high touch area for lockfile and takeover edge cases.
Overview
Vendored-mode checks that block a patch before any view fetch or disk write now go through a single core API,
socket_patch_core::vendor::refusals::vendor_refusals, instead of the CLI merging Bun preflight, vlt preflight, npm lock preflight, lock-text helpers, and pnpm takeover logic separately.The CLI drops
bun_preflight.rsandvlt_preflight.rs;agent_download,get,scan/vendor_flow(preview + download), andvendorcallvendored_download_refusals/vendor_refusalswith oneVendorRefusalsmap in the fetch loop.CLI_CONTRACT.mddocuments that npm v1 package-lock and hosted-pnpm takeover refusals share that same decision path, including onget <uuid> --mode vendored.Coverage fixes (same error codes as before): scan’s download phase and
get <uuid>now refuse v1package-lockprojects before/patches/view/;vendorapplies the full refusal set before hosted→vendored takeover (so pnpm takeover failures don’t briefly un-host). Tests move intorefusals.rsin core plus new download/uuid e2e cases; the vlt workflow path filter no longer lists the deleted preflight module.Reviewed by Cursor Bugbot for commit 42843ef. Configure here.
Generated by Claude Code