Internal messages visible to customers
Problem
Section titled “Problem”Agents leave private triage notes on tickets (is_internal = true) — “this customer is angry, route to senior support.” The customer reads them through the public ticket-detail API.
The code
Section titled “The code”Why review misses it
Section titled “Why review misses it”The mental model is “messages inherit visibility from the parent ticket.” That’s true for agents — and almost true for customers. The exception (is_internal) is invisible in the policy.
The example test that passes
Section titled “The example test that passes”Seeds one customer message; doesn’t seed an internal note; passes.
The SqlProof property
Section titled “The SqlProof property”Notice the columns={"messages.is_internal": st.booleans()} override — is_internal has a DEFAULT false, so the dataset generator omits it; we have to opt in for the test to read it. And assume(internal) discards runs where Hypothesis happens to generate zero internal messages, since the bug can’t leak what doesn’t exist.
The counterexample
Section titled “The counterexample”Illustrative — Hypothesis would print the actual draw and assertion:
The fix
Section titled “The fix”Add the missing gate to the customer branch of the USING clause: