base red: cmux-tui panic ratchet and clippy from #28950 and #32065 (checked slices, JsonSet, one CloudAccess)

Merged
LA
4d ago
+42-35

Fixes feat-cmux-next tip reds in cmux-tui. They block the clippy and panic steps of every cmux-tui PR (for example #31937, #31921).

1. Rust panic ratchet (from #28950, 7ea60b1b546b)

Tip watcher job eebb0e75406ab4c13e2ee200: cmux-tui: clippy::indexing_slicing 835 > baseline 831 and clippy::string_slice 84 > baseline 82.
The 4 + 2 new hits from #28950's production code, now checked forms with the same results:

  • link/cloud_broker.rs mint_token: services[0] == services[1] -> matches!(services, [first, second] if first == second).
  • link/native_broker.rs read_identity: bootstrap.team[5..] -> strip_prefix("team_").is_some_and(|hex| hex.len() == 20 && ...).
  • link/native_broker.rs native_id: value[prefix.len()..] -> strip_prefix(prefix).is_some_and(|id| id.len() == 26 && ...).
  • link/mod.rs: ready_line["native"] = ... and ready_line["wg_public_key"] = ... (serde_json IndexMut) -> cmux_json::JsonSet::set, the repo's form for string-key JSON writes.

Bad input still fails closed (Forbidden, refused()).

2. cmux-tui clippy (seen on #31921, hq run 41428596319)

  • clippy::too_many_arguments (8/7) on link::serve, from #28950, which added the native broker as an eighth argument.
    The broker and the credential relay socket are the two ways a serve resolves cloud hosts, and run_serve already
    refuses both at once (cloud.native.scope_conflict). They become one CloudAccess enum
    (Broker(Box<Bound>) | Relay(Option<PathBuf>); boxed for large_enum_variant). The branches are unchanged.
  • unused_qualifications at cli/app/tests.rs:352, from #32065: std::path::Path::new -> Path::new (in scope through super::*).

The force-unwrap red from #28950 is fixed separately in #32129.

Changelog

none

Observed / Not run

Observed:

  • Panic step (cmux-ci run --script scripts/ci/cmux-tui-rust-check.sh --arg panic --os linux):
    at f8a56d7f299 still red (indexing_slicing 833 > 831: the 2 serde_json writes);
    at 89343994531 pass; at a120c6b850d pass (step f11999b503f788836f662bfd).
  • Clippy step (--arg clippy --os linux): at 9cae85cf223 red only on the new enum's large_enum_variant; at a120c6b850d pass (step f29404fd9222043a4ae6c39a).
  • rustfmt +1.95.0 --edition 2024 --check on the changed files and python3 scripts/cmux-next/prepush-gate.py: clean.

Not run:

  • The cmux-tui unit tests (native_broker, cloud_broker_tests, link tests); CI runs them.