base red: panic ratchet: remove the merge wave's cmux-tui-core and automation index/slice hits; reasons on chats-mirror's allows
What
A base red, priority zero. cmux-tui spec / clippy (changed cmux-tui packages), step "Rust panic ratchet on changed cmux-tui packages", is red on every feat-cmux-next push since 591cc787b25 (00:34Z). The last green push was dfaa79eb0f4 / 2b79f24ed65 only because those pushes did not check cmux-tui-core:
cmux-tui-core: clippy::indexing_slicing 856 > baseline 853
cmux-tui-core: clippy::string_slice 57 > baseline 52
cmux-tui/crates/cmux-chats-mirror/src/{feed,index,chat}.rs: allow(cast_possible_truncation) needs reason = "..."
Each PR in the 00:0x-00:35Z merge wave passed alone; together they went over the baseline. I compared the CI clippy JSON artifacts of the push runs 41150144171 (853/52), 41150892225 (855/52) and 41151676131 (856/57) to find the new hits:
| Hits | Culprit | Fix |
|---|---|---|
1 indexing, launch_snapshot.rs projection[key] | #28071 (ac1c524325a) | projection.get(key).and_then(Value::as_str) |
1 indexing, personal_store.rs bytes[0] | #28056 (8f3e9c2b1f3) | bytes.first().is_some_and(u8::is_ascii_lowercase) |
1 indexing + 5 string_slice, terminal_adoption.rs digest[..16], &hex[a..b] | #27895 (15f07aa9ad1) | a pure derive_template_workspace_key: a zip copy and a writer that puts a dash before bytes 4, 6, 8 and 10 |
| 4 allows without a reason, cmux-chats-mirror | aaa31184e32 | the tip deleted the crate (f7e5bb613b6), so the merge ddd1753d663 takes the deletion; the cherry-pick of #28739 is no longer in the diff |
| cmux-automations, a new crate (must be 0): 9 indexing + 3 string_slice; cmux-tui 832 > 831 (cli/automation.rs &args[i]) | the cmux automation series ee371795740, d2c6a0dfc1f, c91791229a6 (direct pushes, 01:52Z-02:24Z, after this branch's first base) | 9e0d6b0416b: ALPHABET.get, a 5-field slice pattern in cron, id_head(id, prefix), split at NUL for the hostname, strip_prefix in is_automation_id, an iterator in Args::parse |
These hits are in the same job, so their fix is in this PR too (each fix stays red on the other's red).
The baseline is not raised. Behavior does not change:
the_template_workspace_key_is_the_same_uuidv8_as_the_first_derivationpins the key for one input. I computed the expected value with the original algorithm (Pythonhashlib), so a restart still finds a claim that was cut short.a_session_capability_list_holds_only_unique_capability_tokensadds a token that starts with a digit (1profiles). That is the case thatbytes[0]checked.- The
projection[key]change returns the same values (getgivesNonewhere indexing gaveNull, and both become""). - Automation:
run_ids_are_deterministic_per_due_timepinsrun_d2wwsnkgaqvsacwxjsaj, computed in Python from the original base32, because run ids are stored and compared across machines. Cron refuses 6 fields.id_headhas a unit test for the valid forms and for an id of another form (no panic).
Red on the base: push run 41158092570 at a112726195c (and every push run from 41150892225 on).
At 9eaed30c5b9 this PR's own ratchet run said that cmux-tui-core went down (853/52) and that no allow is without a reason. The remaining reds were only the automation hits above. Pass on the head 9e0d6b0416b: this PR's own clippy (changed cmux-tui packages) run (the same command, on the merge ref); the result goes in a comment.
Changelog
none
Observed / Not run
- Observed: the hit diff of the three CI clippy JSON artifacts above. The original key algorithm, run in Python, for the pinned value.
python3 scripts/cmux-next/prepush-gate.py: no new violations. The ratchet's reason scan (allow_without_reason) on the head: empty. - Fleet (cmux-ci, macOS):
cmux-tui-rust-check.sh clippyandtestwith the three filters on 9e0d6b0416b;an_oversized_snapshot_dropspassed on 9eaed30c5b9 (1 passed). I will add the other results in a comment. - Not run on this VM: no Rust compile (the rules do not allow it). The ratchet count itself comes from this PR's CI job, which is the only runner of
rust_panic_ratchet.py.
![View with [code]smith](https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-dark-v3-3x.png)
![Autofix with [code]smith](https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark-3x.png)
Need help on this PR? Tag @codesmith-bot with what you need.
Summary by cubic
Fixes the feat-cmux-next panic ratchet, which went red when three individually-green PRs merged and pushed cmux-tui-core indexing and string-slice counts over baseline, and again when the cmux-automations series landed after this branch's base. The ratchet now fails with 856 indexing (baseline 853) and 57 string slices (baseline 52) in cmux-tui-core, 9 indexing and 3 string slices in the new cmux-automations crate, and 832 vs 831 indexing in cmux-tui, plus reason-less cast allows in cmux-chats-mirror.
Changes
launch_snapshot.rs: replaceprojection[key]withprojection.get(key).and_then(Value::as_str).personal_store.rs: replacebytes[0]withbytes.first().is_some_and(u8::is_ascii_lowercase).terminal_adoption.rs: rewrite the template key derivation as a pure function using a zip copy and a dash-inserting writer.cmux-automations: useALPHABET.get, a 5-field slice pattern in cron,id_headin exec, split at NUL for the hostname,strip_prefixinis_automation_id, and an iterator inArgs::parse.cmux-chats-mirror: add thereasonparameter to the four cast allows.
Behavior
- The template key output is pinned by a test to the original algorithm's value, so restarts still find claims cut short.
projection.get()returnsNonewhere indexing returnedNull; both become empty strings, so no change in behavior.- Run ids are pinned for one input, cron refuses 6 fields, and
id_headhandles ids of another form without panicking. - The capability test now includes a digit-first token, the case the old code guarded.