package dobotaiops import ( "context" "errors" "testing" "time" ) func TestSourceRechecksEffectivePrivilegesBeforeEveryQuery(t *testing.T) { pool := fixturePool(t) roDSN := buildFixture(t, pool) client := buildReadOnlyClient(t, roDSN) execFixture(t, pool, `CREATE TABLE acl_other_surface(id text)`, `GRANT INSERT ON acl_other_surface TO kg_ro_fixture`) t.Cleanup(func() { execFixture(t, pool, `DROP TABLE IF EXISTS acl_other_surface`) }) window := Window{TenantKey: "default", Start: time.Date(2026, 10, 14, 0, 0, 0, 0, time.UTC), End: time.Date(2026, 10, 15, 0, 0, 0, 0, time.UTC)} if _, err := client.QueryCounts(context.Background(), window, Filter{}); !errors.Is(err, ErrNotReadOnly) { t.Fatalf("unexpected privilege escalation outside legacy tables was not blocked: %v", err) } }