1
//! The reader is reachable from a report query parameter and from the SSH eval
2
//! channel, and `parse_expr`/`parse_list` are mutually recursive. Without a
3
//! ceiling, a few kilobytes of `(((…` aborts the process — not an error, a
4
//! SIGABRT that takes every tenant on the pod with it. CLAUDE.md requires every
5
//! recursive parse path to carry a depth guard.
6

            
7
#[test]
8
1
fn deeply_nested_input_is_refused_not_fatal() {
9
2
    for depth in [1_000usize, 100_000] {
10
2
        let src = format!("{}x{}", "(not ".repeat(depth), ")".repeat(depth));
11
2
        assert!(
12
2
            nomiscript::Reader::parse(&src).is_err(),
13
            "{depth} levels must be refused, not abort the process"
14
        );
15
    }
16
1
}
17

            
18
/// The ceiling must stay far above anything a person writes.
19
#[test]
20
1
fn ordinary_nesting_still_parses() {
21
1
    let src = format!("{}x{}", "(not ".repeat(32), ")".repeat(32));
22
1
    assert!(
23
1
        nomiscript::Reader::parse(&src).is_ok(),
24
        "32 levels is normal"
25
    );
26
1
}