package ai import "testing" // TestBidWinRateIntentRegisteredAndSafe proves the M7 advisory base rate intent is wired safely into the // closed Registry: it is registered under its name, the whole Registry still validates (every intent passes // GuardReadOnlyQuery against the ReadAllowlist), and the new intent's own SQL passes the read only guard. // This is the unit guarantee that the bid_win_rate_by_segment read can only ever run as a single read only // SELECT over allowlisted tables, never a write and never an eeo read. func TestBidWinRateIntentRegisteredAndSafe(t *testing.T) { intent, ok := IntentByName(IntentBidWinRateBySegment) if !ok { t.Fatalf("intent %q is not registered", IntentBidWinRateBySegment) } if len(intent.Params) != 0 { t.Fatalf("bid win rate intent takes no SQL parameter, got %d params", len(intent.Params)) } // The whole Registry must still validate with the new intent and the new allowlist entry. if err := ValidateRegistry(); err != nil { t.Fatalf("ValidateRegistry failed with the bid win rate intent: %v", err) } // The new intent's SQL must pass the read only guard directly (defense in depth, the same check // ExecuteIntent re runs at execution time). if err := GuardReadOnlyQuery(intent.SQL, ReadAllowlist); err != nil { t.Fatalf("GuardReadOnlyQuery rejected the bid win rate SQL: %v", err) } // bid_outcomes must be in the read allowlist (the reviewed decision that allowlists the tenant ledger). if !ReadAllowlist["bid_outcomes"] { t.Fatal("bid_outcomes must be in the AI ReadAllowlist for the advisory base rate read") } } // TestBidWinRateIsTAGNotGraphOrBench pins the routing classification: the advisory base rate is a plain TAG // aggregate intent, so it is NEITHER a graph intent NOR a person touching bench intent. A misclassification // would route it to the graph evidence path or, worse, treat it as suppressed bench data, so this guards the // boundary the task fixed. func TestBidWinRateIsTAGNotGraphOrBench(t *testing.T) { if IsGraphIntent(IntentBidWinRateBySegment) { t.Fatal("the bid win rate base rate is a TAG aggregate intent, it must NOT be a graph intent") } if IsBenchIntent(IntentBidWinRateBySegment) { t.Fatal("the bid win rate base rate reads no person table, it must NOT be a bench intent") } }