Gateway and Policy
AifGateway is the application-facing execution boundary for inference, streaming, embeddings, moderation, retrieval, and tools. RuntimeMode::Development supports local evaluation. RuntimeMode::Governed fails closed unless trusted caller context, policy enforcement, and audit persistence are configured.
Gateway Responsibilities
- validate runtime dependencies and request input
- resolve a capable provider and immutable approved prompt
- evaluate operation-aware policy
- enforce obligations such as redaction or human review
- execute the provider, retrieval, or permission-aware tool operation
- run pre- and post-execution evaluators
- attempt one correlated terminal audit record
- emit vendor-neutral operational metrics
Policy Decisions
Policy should be able to return clear decisions:
| Decision | Meaning |
|---|---|
| allow | Continue through the governed lifecycle. |
| deny | Stop before provider or tool side effects. |
| review | Persist a pending review and stop before execution. |
Policy obligations may transform a request, such as redacting classified fields. AIF rejects an unsupported or unenforceable obligation rather than ignoring it.
Example Policy Questions
- Is this user allowed to run this AI capability?
- Is this provider allowed for this workspace?
- Does the prompt contain sensitive data?
- Does the task require human review?
- Is the output permitted to enter a workflow automatically?
Keep these questions in policy contracts, not scattered through UI pages. Use OperationAwarePolicyEngineInterface when the decision must distinguish inference, embedding, moderation, retrieval, streaming, or tool execution.
See Review Workflows for approval and replay-protection behavior.