base red: machine vault host check has no expect (crash ratchet cmux-tui expect 76 -> 77)

Merged
LA
2d ago
+116-10

Summary

The crash ratchet is red on feat-cmux-next: rust cmux-tui: expect 76 -> 77.

Cause: #34390 (commit 9a277f3aa8f8) added this line in
cmux-tui/crates/cmux-tui/src/cli/machine_join/vault/policy.rs:

regex::Regex::new(r"^(\*\.)?(...)+[a-z][a-z0-9-]{0,62}(:[1-9][0-9]{0,4})?$")
    .expect("the host pattern compiles")

The ratchet counts each .expect( in product code. Thus the cmux-tui count went up by one.

Fix: The host pattern is simple, so this change replaces the regex with a small check by
hand, host_pattern_ok. No pattern build occurs at run time, so no panic can occur. The check
accepts the same hosts as the platform pattern:

  • An optional *. prefix.
  • One or more labels before the last dot. Each label has 1 to 63 of a-z, 0-9 and -, and does not start or end with -.
  • A last label with 1 to 63 of a-z, 0-9 and -. It starts with a-z. (The pattern lets it end with -; the check keeps that.)
  • An optional :port with 1 to 5 digits and no leading zero.

host_ok keeps its length limit (260) and its port range check (65535). The regex
dependency stays, because cli/agents/wait.rs and cli/mcp.rs use it.

A new test, the_host_check_accepts_what_the_platform_pattern_accepts, compares
host_pattern_ok with the original regex. It uses edge cases (label lengths 63 and 64,
hyphens, leading-zero and 6-digit ports, uppercase, non-ASCII, newlines, double colons, empty
labels) and every string up to six characters from the alphabet a 0 1 - . * : Z. The test
code keeps the regex, so the test is the reference for the platform pattern.

Takes back #34390: its .expect( on the host regex added one crash-ratchet hit; this
change removes the regex and keeps the same host check.

Red at the base, green at the head

Command: bash scripts/cmux-next/check-crash-safety.sh <checkout>/Packages/macOS/CmuxNext

  • Base b7c9441d175202ac92f0548d4e5f9fdf8e259702 (feat-cmux-next tip): red.
    check-crash-safety: ok
    crash-ratchet: rust cmux-tui: expect 76 -> 77
    crash-ratchet: 1 module(s) or crate(s) gained a crash-class hit ...
    
  • Head d1e96363b3e93fc7ee1fe0b8806a5bd7607433b3: green.
    check-crash-safety: ok
    crash-ratchet: ok; 2 count(s) went down: run scripts/cmux-next/crash_ratchet.py --update-baseline
    

Changelog

none

Observed / Not run

Observed:

  • check-crash-safety.sh: red at base b7c9441d, also red at the earlier tip 448f2245695; green at head d1e96363.
  • python3 scripts/cmux-next/prepush-gate.py: no new violations.
  • rustfmt --edition 2024 --check on the two changed files: clean.
  • A Python copy of the new check gives the same result as the same regex (with \Z for Rust's end-of-text $) on 2,396,745 strings (every string up to 7 characters from a 0 - . * : Z 1), plus long-label and non-ASCII cases. This only checks the logic, not the Rust code.
  • Fleet clippy (cmux-tui-rust-check.sh clippy) at head (run https://github.com/manaflow-ai/cmuxterm-hq/actions/runs/41753847086, Rust 1.95.0): red, with base findings only. It reports unnecessary qualification at cmux-wg-tun/src/utun.rs:32, manual implementation of .is_multiple_of() at cmux-tui/src/cli/automation/teleport.rs:130 and very complex type at cmux-tui/src/cli/automation.rs:98. This PR does not change these files. The cmux-tui lib and lib-test targets (they include policy.rs and tests.rs) report only these 2 errors, so the changed files have no clippy finding.
  • Fleet test (cmux-tui-rust-check.sh test machine_join::vault::tests) at head (run https://github.com/manaflow-ai/cmuxterm-hq/actions/runs/41754078592): 17 tests run, 17 passed, including the new the_host_check_accepts_what_the_platform_pattern_accepts and the old policy_flags_parse_and_refuse_what_does_not_fit.

Not run:

  • The full cmux-tui test suite. Only the vault tests ran.
  • A live cmux machine vault set --host against the platform. The check gives the same answer as before, so the requests do not change.