test(enclave): assert Coyote Mode auto-ban trigger deterministically (LC-341) #357
Loading…
Reference in a new issue
No description provided.
Delete branch "test/lc-341-coyote-trigger"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Decision
Yes, the trigger needs an assertion. The Coyote Mode trigger glue in
post_message- mode-on AND not-site-admin AND not-enclave-manager ANDcount_distinct_rooms_posted_recently >= 3- is security-relevant: a regression silently disables bot protection or, worse, over-bans real users. The DB layer (count/ban/purge) and HTTP enforcement were already tested, but the trigger itself was not, only because it runs in a fire-and-forget spawn.Change
Extract the fully-gated decision+action from
post_messageintopub routes::maybe_coyote_ban(state, enclave_id, room_id, user) -> Result<bool>(returns whether it fired).post_messagenow spawns that for enclave rooms - behaviour is unchanged (same fire-and-forget, same gating), and the coyote-on lookup moves off the request path as a bonus. Re-exported asroutes::maybe_coyote_ban(without making the wholeroommodule public) so the integration test canawaitit directly instead of racing the spawn.Deterministic tests in
routes_coyote_mode.rs:Ok(true), user banned + last-24h enclave messages soft-deleted.Ok(false), not banned (threshold boundary).Ok(false).Ok(false)(exempt).The detection/purge SQL stays unit-tested in
db_coyote_mode.rs.Test
just check(clippy std+saas+desktop, fmt),just test,just test-saasall pass. No production behaviour change; no migration.Closes LC-341.