1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//! The rank check is the mechanism every other lock-discipline claim leans on.
//!
//! `docs/internals.md` states the global lock order as an executable check
//! rather than prose ("what used to be prose is now an executable check"), and
//! `the_ttl_clock_is_reachable_under_the_config_guard` is written on the premise
//! that a misorder panics there. But the whole enforcement is one
//! `debug_assert!` inside `RankGuard::enter`, and nothing asserted that it
//! actually fires: a refactor that dropped the check, or loosened `>` to `>=`,
//! would compile, keep every lock test green, and silently downgrade the order
//! to prose again — the exact failure the module was built to end.
//!
//! These pin the mechanism itself, both directions. `debug_assertions`-gated
//! because the check compiles out in release, where the guard is a no-op by
//! design (a `--release` test run must not fail for the absence of a panic).
use *;
/// The inversion that deadlocks: `Rotation` (100) is held across the OAuth HTTP
/// round trip and is outermost by design, while `Config` (400) is held across
/// the TUI's account-swap actions. Taking rotation *under* config is the order
/// inversion — it must panic in dev/test rather than deadlock in production.
/// The comparison is strictly `>`, not `>=`. Re-entering the same rank means
/// taking the same non-reentrant mutex twice, which self-deadlocks — so the
/// equal case must panic too. Loosening the assert to `>=` would still pass
/// every ascending-order test in the tree; only this one catches it.
/// The documented nesting (`config` → state flock → `activity`, with rotation
/// outermost) is legal, and dropping the guards pops them: a sequential
/// acquire-then-drop constrains nothing, so the lowest rank is acquirable again
/// afterwards. Without this the two `should_panic` tests above would also pass
/// against a guard that panicked unconditionally.