Expand description
AI model governance (DW-084): per-team model allowlists and the shadow-audit switch.
A team is a POLICY name (the same vocabulary the token budgets use
for scope: policy): every consumer attaching a policy that
carries an allowlist entry is restricted to that allowlist’s
client-facing model aliases. The check runs BEFORE routing, against
the alias the client put in the request body, so a disallowed (or
typo’d) alias is blocked at the edge with a 403
model_denied_by_policy rather than surfacing as a provider 404.
§Resolution (deny-wins intersection)
The binding allowlists for one request are EVERY policy in the
frozen precedence chain (consumer > route > service > listener >
global) that has a team_allowlists entry. The model must be in
ALL of them — the intersection, deny-anywhere-wins (the same
principle as authz). A consumer with no binding allowlist policy
is unrestricted (fail-open, the DW-017 default posture).
§Audit
When ai.governance.audit is true, BOTH allowed and denied
attempts are recorded into the ai_governance_events analytics
table for shadow review (the admin /analytics/governance-audit
endpoint reads it). When false, only the denial metric fires — no
per-event audit rows. Denied requests are ALWAYS audited when the
governance block is present (the done-when requirement: a blocked
attempt appears in the audit log); the audit flag extends
recording to ALLOWED calls for spend-by-team shadow review.
§Dependency direction
ai depends on config only (see scripts/check_deps.py); this
module reads config::ai::AiConfig and nothing else. The audit
RECORD DTO lives in analytics (a plain struct, not importing
ai) — the dataplane converts at the call site, keeping the
dependency direction downward.
Structs§
- Governance
Engine - The per-generation compiled governance rules (DW-084): the team_allowlists map plus the audit switch. Built at dataplane refresh from the published config; immutable once built. Stored on the dataplane behind an ArcSwap and swapped on reload, so a governance change applies to the next request with no restart.
Enums§
- Governance
Verdict - The governance check verdict for one request.