Fix the merge gate for AI-written unsafe Rust
Your task
Your team mostly writes Python, and an AI agent rewrote a hot data path component in Rust for speed. It uses unsafe blocks, which switch off the compiler's memory safety checks, and nobody on the team can audit them. Before anything merges, a gate decides what the change needs next.
An assistant wrote assess_unsafe_merge(unsafe_blocks, qualified_reviewers, sanitizers_run, fuzz_hours), the gate. It is in the editor. It has a bug. Find it and fix it.
Input and output:
unsafe_blocks: how manyunsafeblocks the change has.qualified_reviewers: how many people can review this Rust code, unsafe blocks included.sanitizers_run: the sanitizers CI ran, by name. Sanitizers are tools such as Miri, ASan and TSan that catch memory and threading errors while the code runs.fuzz_hours: hours of fuzzing (testing with random inputs) behind the change.- Return one verdict string.
Rules the tests check. Return the first that applies:
unsafe_blocks,qualified_reviewersorfuzz_hoursis negative:invalid_input.- No unsafe blocks and at least 1 reviewer:
merge. - No unsafe blocks and no reviewer:
needs_review. - Unsafe blocks and no reviewer:
rewrite_in_safe_rust. sanitizers_runis missing any ofmiri,asanandtsan:run_sanitizers. An entry matches when it equals the name, ignoring the case of ASCII letters. Other entries and repeats do not matter.- Fewer than 8 fuzz hours:
extend_fuzzing. - Otherwise:
merge_after_audit.
Examples
assess_unsafe_merge(unsafe_blocks: int, qualified_reviewers: int, sanitizers_run: list[str], fuzz_hours: int) -> strExample 1
Input
assess_unsafe_merge(3, 0, ["asan", "miri", "tsan"], 24)Output
"rewrite_in_safe_rust"Example 2
Input
assess_unsafe_merge(3, 1, ["asan", "miri"], 24)Output
"run_sanitizers"