Skip to content

Run the Bun and vlt vendored preflights as one vendor_preflight with one per-purl refusal map #1839

Open

Description

[agent] Filed by the scheduled architecture audit (audit-cli-tests). Register: register comment.

Kind: refactor. Register ID: T05.

Problem

Every vendored caller runs the Bun preflight and the vlt preflight back to back, then checks each purl against both refusal types with its own glue code:

Both refusal types are {code: &'static str, detail: String}. The two modules (bun_preflight.rs,````` vlt_preflight.rs) duplicate several pieces:

  • the npm-only scope check;
  • selection_pairs;
  • the vendor_state_unreadable mapping;
  • the vlt_routes probe, which bun runs to opt out and vlt runs again to opt in.

Bun also exposes three one-line forwarders (bun_vendor_preflight, _with_ledger, _pairs). It has an Option<LedgerLoad> lazy-load mode, and its only caller (get.rs L2326) loads the ledger itself on the next line anyway. The callers also disagree on the root:

  • get runs Bun on project_root() but vlt on cwd;
  • agent_download runs both on cwd;
  • vendor_flow loads the ledger at cwd.

Proposed change

  • Add one vendor_preflight(cwd, pairs, ledger) -> HashMap<purl, (code, detail)>. Bun's project-level verdict is expanded per purl after its exemptions.
  • Collapse the three Bun forwarders and the lazy-load mode.
  • Each caller does one lookup per purl.
  • Pick one root, following the #745 rule (the ledger and lock at project_root()).

Size

6 files. About −150 / +60 lines.

Acceptance criteria

  • Every Bun/vlt refusal code, and its envelope and exit code, is unchanged.
  • The bun_preflight/vlt_preflight unit tests and the e2e_vendor_bun_build/e2e_redirect_vlt_build suites stay green.

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent:triagedarch-auditFiled by a scheduled architecture audit routine (see the architecture review discussion)priority:p1refactorStructural change: duplicated code or logic, missing abstraction, layering, dead code

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions