Skip to content

Mirror global flags into the environment once before dispatch, and read the lock timeout through one accessor #794

Open

Description

[agent] Filed by the scheduled architecture audit routine (CLI and core). Register: discussion #560 register.

Kind: refactor. Source: review 2.5 and R3; register C10, child 1 of #793.

Problem (verified at 045d7ec)

apply_env_toggles is called separately at the top of 10 command entry points:

Two paths miss it: vendor --check returns at vendor.rs#L686-L688 before the call, and the internal hosted-bundle never calls it. Every new command has to remember the call. Meanwhile main already sets the human-output policy once before dispatch (ui::init, main.rs#L78-L90).

The lock timeout is converted by hand 12 times, as Duration::from_secs(common.lock_timeout.unwrap_or(0)) (or run.lock_timeout):

  • apply.rs:938
  • get.rs:2358 and get.rs:3390
  • remove.rs:400
  • repair.rs:144
  • rollback.rs:1224
  • vendor.rs:835 and vendor.rs:1321
  • scan/hosted.rs:155
  • scan/vendor_flow.rs:273
  • scan/gc.rs:214 and scan/gc.rs:283

Impact: low risk today, but it is the first, mechanical step of #793. It makes "every command sees the same run configuration" structural instead of a per-file convention.

Proposed change

  • Add socket_patch_cli::prepare_run(common: &GlobalArgs), which calls ui::init and apply_env_toggles. Call it once in main.rs, before the update notifier is spawned.
  • Delete the 10 per-command apply_env_toggles calls.
  • Add GlobalArgs::lock_timeout() -> Duration, and delete the 12 inline conversions. get's DownloadParams/run struct carries the Duration.

Size and scope

Acceptance criteria

  • grep -rn "apply_env_toggles(" crates/socket-patch-cli/src/commands finds nothing outside tests.
  • grep -rn "lock_timeout.unwrap_or" crates/socket-patch-cli/src finds nothing outside args.rs.
  • Unit tests that call commands::<cmd>::run directly and rely on the mirror (for example --offline reaching the telemetry gate) call prepare_run first, or go through a shared dispatch helper. None silently lose coverage.
  • Regression test: vendor --check --debug and hosted-bundle see SOCKET_DEBUG=1 mirrored, like every other command.
  • args.rs tests apply_env_toggles_* and truthy_offline_env_vocabulary_reaches_telemetry_gate stay green, as does the lock_cli/gc lock-timeout tests.

Dependencies

Activity

  1. added
    arch-audit
    on Oct 4, 2026
  2. added
    refactor
    on Oct 4, 2026
  3. added a commit that references this issue on Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent:triagedarch-auditpriority:p3refactor

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions