policyaware 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. policyaware-0.2.0/.github/workflows/ci.yml +32 -0
  2. policyaware-0.2.0/.github/workflows/publish-testpypi.yml +50 -0
  3. policyaware-0.2.0/.github/workflows/publish.yml +49 -0
  4. policyaware-0.2.0/.gitignore +13 -0
  5. policyaware-0.2.0/CONTRIBUTING.md +29 -0
  6. policyaware-0.2.0/LICENSE +18 -0
  7. policyaware-0.2.0/PKG-INFO +170 -0
  8. policyaware-0.2.0/README.md +146 -0
  9. policyaware-0.2.0/SECURITY.md +16 -0
  10. policyaware-0.2.0/docs/.nojekyll +1 -0
  11. policyaware-0.2.0/docs/404.html +19 -0
  12. policyaware-0.2.0/docs/PolicyAware_AI_Gateway_User_Guide.docx +0 -0
  13. policyaware-0.2.0/docs/architecture.md +45 -0
  14. policyaware-0.2.0/docs/index.html +265 -0
  15. policyaware-0.2.0/docs/production-features.md +147 -0
  16. policyaware-0.2.0/docs/pypi-publishing.md +57 -0
  17. policyaware-0.2.0/docs/site.css +220 -0
  18. policyaware-0.2.0/docs/working-examples.md +562 -0
  19. policyaware-0.2.0/examples/evals/executable_governance_cases.yaml +52 -0
  20. policyaware-0.2.0/examples/evals/governance_cases.yaml +32 -0
  21. policyaware-0.2.0/examples/evals/support_rag.yaml +19 -0
  22. policyaware-0.2.0/examples/policies/basic.yaml +33 -0
  23. policyaware-0.2.0/examples/policies/invalid-policy.yaml +14 -0
  24. policyaware-0.2.0/examples/policies/regulated-rag.yaml +23 -0
  25. policyaware-0.2.0/examples/policies/tool-governance.yaml +43 -0
  26. policyaware-0.2.0/examples/providers/provider-routing.py +67 -0
  27. policyaware-0.2.0/pyproject.toml +50 -0
  28. policyaware-0.2.0/scripts/build_policyaware_user_guide.py +1233 -0
  29. policyaware-0.2.0/src/policyaware/__init__.py +46 -0
  30. policyaware-0.2.0/src/policyaware/approvals.py +68 -0
  31. policyaware-0.2.0/src/policyaware/audit.py +222 -0
  32. policyaware-0.2.0/src/policyaware/cli.py +306 -0
  33. policyaware-0.2.0/src/policyaware/data_protection.py +51 -0
  34. policyaware-0.2.0/src/policyaware/evals.py +171 -0
  35. policyaware-0.2.0/src/policyaware/gateway.py +79 -0
  36. policyaware-0.2.0/src/policyaware/integrations/__init__.py +2 -0
  37. policyaware-0.2.0/src/policyaware/integrations/fastapi.py +41 -0
  38. policyaware-0.2.0/src/policyaware/integrations/flask.py +29 -0
  39. policyaware-0.2.0/src/policyaware/integrations/langchain.py +29 -0
  40. policyaware-0.2.0/src/policyaware/integrations/llamaindex.py +26 -0
  41. policyaware-0.2.0/src/policyaware/models.py +196 -0
  42. policyaware-0.2.0/src/policyaware/observability.py +80 -0
  43. policyaware-0.2.0/src/policyaware/policy.py +237 -0
  44. policyaware-0.2.0/src/policyaware/policy_schema.py +136 -0
  45. policyaware-0.2.0/src/policyaware/providers.py +443 -0
  46. policyaware-0.2.0/src/policyaware/reason_codes.py +36 -0
  47. policyaware-0.2.0/src/policyaware/risk.py +94 -0
  48. policyaware-0.2.0/src/policyaware/routing.py +45 -0
  49. policyaware-0.2.0/src/policyaware/tools.py +121 -0
  50. policyaware-0.2.0/tests/test_deny_by_default.py +27 -0
  51. policyaware-0.2.0/tests/test_gateway.py +41 -0
  52. policyaware-0.2.0/tests/test_policy.py +49 -0
  53. policyaware-0.2.0/tests/test_policy_schema.py +92 -0
  54. policyaware-0.2.0/tests/test_production_features.py +67 -0
  55. policyaware-0.2.0/tests/test_providers.py +92 -0
  56. policyaware-0.2.0/tests/test_risk.py +21 -0
  57. policyaware-0.2.0/tests/test_tools.py +35 -0
@@ -0,0 +1,32 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ python-version: ["3.10", "3.11", "3.12"]
16
+
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+
20
+ - uses: actions/setup-python@v5
21
+ with:
22
+ python-version: ${{ matrix.python-version }}
23
+
24
+ - name: Install package
25
+ run: python -m pip install -e ".[dev]"
26
+
27
+ - name: Run tests
28
+ run: pytest
29
+
30
+ - name: Compile source
31
+ run: python -m compileall src tests examples
32
+
@@ -0,0 +1,50 @@
1
+ name: Publish Python Package To TestPyPI
2
+
3
+ on:
4
+ workflow_dispatch:
5
+
6
+ jobs:
7
+ build:
8
+ runs-on: ubuntu-latest
9
+
10
+ steps:
11
+ - uses: actions/checkout@v4
12
+
13
+ - uses: actions/setup-python@v5
14
+ with:
15
+ python-version: "3.12"
16
+
17
+ - name: Install build tools
18
+ run: python -m pip install --upgrade build twine
19
+
20
+ - name: Build package
21
+ run: python -m build
22
+
23
+ - name: Check package
24
+ run: twine check dist/*
25
+
26
+ - uses: actions/upload-artifact@v4
27
+ with:
28
+ name: dist
29
+ path: dist/
30
+
31
+ publish-testpypi:
32
+ needs: build
33
+ runs-on: ubuntu-latest
34
+ environment: testpypi
35
+
36
+ permissions:
37
+ contents: read
38
+ id-token: write
39
+
40
+ steps:
41
+ - uses: actions/download-artifact@v4
42
+ with:
43
+ name: dist
44
+ path: dist/
45
+
46
+ - name: Publish to TestPyPI
47
+ uses: pypa/gh-action-pypi-publish@release/v1
48
+ with:
49
+ repository-url: https://test.pypi.org/legacy/
50
+
@@ -0,0 +1,49 @@
1
+ name: Publish Python Package
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ build:
9
+ runs-on: ubuntu-latest
10
+
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+
14
+ - uses: actions/setup-python@v5
15
+ with:
16
+ python-version: "3.12"
17
+
18
+ - name: Install build tools
19
+ run: python -m pip install --upgrade build twine
20
+
21
+ - name: Build package
22
+ run: python -m build
23
+
24
+ - name: Check package
25
+ run: twine check dist/*
26
+
27
+ - uses: actions/upload-artifact@v4
28
+ with:
29
+ name: dist
30
+ path: dist/
31
+
32
+ publish:
33
+ needs: build
34
+ runs-on: ubuntu-latest
35
+ environment: pypi
36
+
37
+ permissions:
38
+ contents: read
39
+ id-token: write
40
+
41
+ steps:
42
+ - uses: actions/download-artifact@v4
43
+ with:
44
+ name: dist
45
+ path: dist/
46
+
47
+ - name: Publish to PyPI
48
+ uses: pypa/gh-action-pypi-publish@release/v1
49
+
@@ -0,0 +1,13 @@
1
+ .venv/
2
+ __pycache__/
3
+ *.pyc
4
+ .pytest_cache/
5
+ .ruff_cache/
6
+ .policyaware/
7
+ .docx_tmp/
8
+ render_tmp/
9
+ .tools/
10
+ docs/rendered_user_guide/
11
+ dist/
12
+ build/
13
+ *.egg-info/
@@ -0,0 +1,29 @@
1
+ # Contributing
2
+
3
+ Thanks for helping build PolicyAware AI Gateway.
4
+
5
+ ## Local Setup
6
+
7
+ ```bash
8
+ pip install -e ".[dev]"
9
+ pytest
10
+ policyaware dev simulate
11
+ ```
12
+
13
+ ## Design Principles
14
+
15
+ - Deny by default.
16
+ - Keep policy decisions explainable.
17
+ - Treat tools as privileged operations.
18
+ - Keep provider integrations behind stable interfaces.
19
+ - Prefer structured traces over plain logs.
20
+ - Make local development possible without external model credentials.
21
+
22
+ ## Good First Areas
23
+
24
+ - Provider adapters.
25
+ - Additional sensitive-data detectors.
26
+ - OpenTelemetry exporter.
27
+ - FastAPI request-body inspection.
28
+ - Golden dataset execution.
29
+ - Dashboard prototype.
@@ -0,0 +1,18 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ Copyright 2026 PolicyAware AI Gateway Contributors
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+
@@ -0,0 +1,170 @@
1
+ Metadata-Version: 2.4
2
+ Name: policyaware
3
+ Version: 0.2.0
4
+ Summary: Policy-aware control plane for enterprise LLM, RAG, and AI agent applications.
5
+ Project-URL: Homepage, https://ktirupati.github.io/policyaware/
6
+ Project-URL: Documentation, https://ktirupati.github.io/policyaware/
7
+ Project-URL: Repository, https://github.com/ktirupati/policyaware
8
+ Project-URL: Issues, https://github.com/ktirupati/policyaware/issues
9
+ Author: PolicyAware AI Gateway Contributors
10
+ License-Expression: Apache-2.0
11
+ License-File: LICENSE
12
+ Keywords: agents,ai-gateway,audit,governance,llm,policy,rag
13
+ Requires-Python: >=3.10
14
+ Requires-Dist: pydantic>=2.6
15
+ Requires-Dist: pyyaml>=6.0
16
+ Requires-Dist: rich>=13.7
17
+ Requires-Dist: typer>=0.12
18
+ Provides-Extra: dev
19
+ Requires-Dist: pytest>=8.0; extra == 'dev'
20
+ Requires-Dist: ruff>=0.4; extra == 'dev'
21
+ Provides-Extra: providers
22
+ Requires-Dist: boto3>=1.34; extra == 'providers'
23
+ Description-Content-Type: text/markdown
24
+
25
+ # PolicyAware AI Gateway
26
+
27
+ PolicyAware AI Gateway is an open-source control plane for governed AI execution across enterprise LLM, RAG, AI agent, and MCP-style tool workflows. It enforces organizational, legal, security, cost, and routing policy before requests reach models or tools, then evaluates outputs for safety, quality, compliance, and auditability.
28
+
29
+ The default posture is deny-by-default: every request must match an allow or conditional policy before execution.
30
+
31
+ Documentation site: https://ktirupati.github.io/policyaware/
32
+
33
+ ## What It Provides
34
+
35
+ - Policy enforcement for RBAC, context, tenant, region, compliance, budgets, tokens, latency, and model constraints.
36
+ - PII, PHI, secrets, and sensitive-data detection with redaction actions.
37
+ - Multi-provider model routing with fallbacks by policy, task type, risk, cost, availability, and quality.
38
+ - Runtime evaluation for safety, policy compliance, grounding, citations, and leakage.
39
+ - Risk-tier classification with explainable reason codes.
40
+ - MCP/tool governance for connector-level and action-level permissions.
41
+ - Full request/response trace, explainable decisions, replay-ready audit logs, and exportable JSONL records.
42
+ - Python SDK, CLI, YAML policies, local development mode, and integration shims.
43
+
44
+ ## Quick Start
45
+
46
+ ```bash
47
+ pip install policyaware
48
+ ```
49
+
50
+ For local development from this repository:
51
+
52
+ ```bash
53
+ pip install -e ".[dev]"
54
+ policyaware policy test examples/policies/basic.yaml
55
+ policyaware policy validate examples/policies/basic.yaml
56
+ policyaware policy explain examples/policies/basic.yaml --prompt "Email jane@example.com"
57
+ policyaware risk classify "Summarize this patient diagnosis" --domain healthcare
58
+ policyaware tools check examples/policies/tool-governance.yaml --agent code_assistant --connector github --action create_pr
59
+ policyaware eval run examples/evals/support_rag.yaml
60
+ ```
61
+
62
+ For copy-pasteable end-to-end examples, see [Working Examples](docs/working-examples.md).
63
+
64
+ ```python
65
+ from policyaware import Gateway, GatewayRequest
66
+
67
+ gateway = Gateway.from_policy_file("examples/policies/basic.yaml")
68
+
69
+ response = gateway.chat(
70
+ GatewayRequest(
71
+ tenant="acme",
72
+ app="claims-assistant",
73
+ user={"id": "u_123", "role": "claims_adjuster"},
74
+ context={"region": "us", "task_type": "summarization", "risk": "low"},
75
+ messages=[{"role": "user", "content": "Summarize claim ACME-42."}],
76
+ )
77
+ )
78
+
79
+ print(response.content)
80
+ print(response.policy.decision)
81
+ print(response.policy.reason_codes)
82
+ print(response.trace_id)
83
+ ```
84
+
85
+ ## Architecture
86
+
87
+ ```text
88
+ Application / Agent / RAG App
89
+ |
90
+ v
91
+ PolicyAware SDK / Middleware
92
+ |
93
+ v
94
+ Identity + Context Resolver
95
+ |
96
+ v
97
+ Policy Decision Engine -> Data Protection Engine -> Model Router -> Provider/Tool
98
+ |
99
+ v
100
+ Runtime Evaluation -> Audit Trace -> Response
101
+ ```
102
+
103
+ ## Repository Layout
104
+
105
+ ```text
106
+ src/policyaware/
107
+ audit.py Request traces and audit export records
108
+ cli.py policyaware CLI
109
+ data_protection.py PII/PHI/secret detection and redaction
110
+ evals.py Offline and runtime evaluation primitives
111
+ gateway.py Main SDK facade
112
+ models.py Core typed contracts
113
+ policy.py Deny-by-default policy engine
114
+ providers.py Provider abstraction and local simulated provider
115
+ routing.py Policy-aware model routing
116
+ integrations/ FastAPI, Flask, LangChain, LlamaIndex shims
117
+ examples/
118
+ policies/
119
+ evals/
120
+ tests/
121
+ ```
122
+
123
+ ## Policy Example
124
+
125
+ ```yaml
126
+ id: basic_enterprise_policy
127
+ default: deny
128
+
129
+ rules:
130
+ - name: allow_low_risk_support
131
+ effect: allow
132
+ when:
133
+ user.role_in: ["support_agent", "claims_adjuster"]
134
+ request.risk_in: ["low", "medium"]
135
+ data.contains_secrets: false
136
+
137
+ - name: redact_pii_for_non_privileged_users
138
+ effect: transform
139
+ action: redact
140
+ when:
141
+ data.contains_pii: true
142
+ user.role_not_in: ["privacy_admin", "compliance_officer"]
143
+
144
+ - name: require_approval_for_high_risk
145
+ effect: require_approval
146
+ when:
147
+ request.risk: "high"
148
+ ```
149
+
150
+ ## Development Status
151
+
152
+ This is a production-grade starter framework: the core extension points and executable behavior are present, while provider integrations, enterprise identity adapters, dashboard UI, and long-term storage can be expanded by contributors.
153
+
154
+ ## v0.2 MVP Capabilities
155
+
156
+ - Deterministic risk classification: low, medium, high, critical.
157
+ - Explainable policy decisions with reason codes and remediation.
158
+ - Replayable audit trace snapshots.
159
+ - Audit bundle generation.
160
+ - Tool governance policies for MCP-style connectors and actions.
161
+ - Governance-aware eval report schema.
162
+ - Provider adapters for OpenAI-compatible APIs, Azure OpenAI, Anthropic, Bedrock, Vertex AI, Ollama, and vLLM.
163
+ - SQLite audit storage and static trace viewer.
164
+ - Prometheus text and OpenTelemetry-shaped JSON exporters.
165
+ - File and webhook approval hooks.
166
+ - Executable golden dataset policy checks.
167
+
168
+ ## License
169
+
170
+ Apache-2.0
@@ -0,0 +1,146 @@
1
+ # PolicyAware AI Gateway
2
+
3
+ PolicyAware AI Gateway is an open-source control plane for governed AI execution across enterprise LLM, RAG, AI agent, and MCP-style tool workflows. It enforces organizational, legal, security, cost, and routing policy before requests reach models or tools, then evaluates outputs for safety, quality, compliance, and auditability.
4
+
5
+ The default posture is deny-by-default: every request must match an allow or conditional policy before execution.
6
+
7
+ Documentation site: https://ktirupati.github.io/policyaware/
8
+
9
+ ## What It Provides
10
+
11
+ - Policy enforcement for RBAC, context, tenant, region, compliance, budgets, tokens, latency, and model constraints.
12
+ - PII, PHI, secrets, and sensitive-data detection with redaction actions.
13
+ - Multi-provider model routing with fallbacks by policy, task type, risk, cost, availability, and quality.
14
+ - Runtime evaluation for safety, policy compliance, grounding, citations, and leakage.
15
+ - Risk-tier classification with explainable reason codes.
16
+ - MCP/tool governance for connector-level and action-level permissions.
17
+ - Full request/response trace, explainable decisions, replay-ready audit logs, and exportable JSONL records.
18
+ - Python SDK, CLI, YAML policies, local development mode, and integration shims.
19
+
20
+ ## Quick Start
21
+
22
+ ```bash
23
+ pip install policyaware
24
+ ```
25
+
26
+ For local development from this repository:
27
+
28
+ ```bash
29
+ pip install -e ".[dev]"
30
+ policyaware policy test examples/policies/basic.yaml
31
+ policyaware policy validate examples/policies/basic.yaml
32
+ policyaware policy explain examples/policies/basic.yaml --prompt "Email jane@example.com"
33
+ policyaware risk classify "Summarize this patient diagnosis" --domain healthcare
34
+ policyaware tools check examples/policies/tool-governance.yaml --agent code_assistant --connector github --action create_pr
35
+ policyaware eval run examples/evals/support_rag.yaml
36
+ ```
37
+
38
+ For copy-pasteable end-to-end examples, see [Working Examples](docs/working-examples.md).
39
+
40
+ ```python
41
+ from policyaware import Gateway, GatewayRequest
42
+
43
+ gateway = Gateway.from_policy_file("examples/policies/basic.yaml")
44
+
45
+ response = gateway.chat(
46
+ GatewayRequest(
47
+ tenant="acme",
48
+ app="claims-assistant",
49
+ user={"id": "u_123", "role": "claims_adjuster"},
50
+ context={"region": "us", "task_type": "summarization", "risk": "low"},
51
+ messages=[{"role": "user", "content": "Summarize claim ACME-42."}],
52
+ )
53
+ )
54
+
55
+ print(response.content)
56
+ print(response.policy.decision)
57
+ print(response.policy.reason_codes)
58
+ print(response.trace_id)
59
+ ```
60
+
61
+ ## Architecture
62
+
63
+ ```text
64
+ Application / Agent / RAG App
65
+ |
66
+ v
67
+ PolicyAware SDK / Middleware
68
+ |
69
+ v
70
+ Identity + Context Resolver
71
+ |
72
+ v
73
+ Policy Decision Engine -> Data Protection Engine -> Model Router -> Provider/Tool
74
+ |
75
+ v
76
+ Runtime Evaluation -> Audit Trace -> Response
77
+ ```
78
+
79
+ ## Repository Layout
80
+
81
+ ```text
82
+ src/policyaware/
83
+ audit.py Request traces and audit export records
84
+ cli.py policyaware CLI
85
+ data_protection.py PII/PHI/secret detection and redaction
86
+ evals.py Offline and runtime evaluation primitives
87
+ gateway.py Main SDK facade
88
+ models.py Core typed contracts
89
+ policy.py Deny-by-default policy engine
90
+ providers.py Provider abstraction and local simulated provider
91
+ routing.py Policy-aware model routing
92
+ integrations/ FastAPI, Flask, LangChain, LlamaIndex shims
93
+ examples/
94
+ policies/
95
+ evals/
96
+ tests/
97
+ ```
98
+
99
+ ## Policy Example
100
+
101
+ ```yaml
102
+ id: basic_enterprise_policy
103
+ default: deny
104
+
105
+ rules:
106
+ - name: allow_low_risk_support
107
+ effect: allow
108
+ when:
109
+ user.role_in: ["support_agent", "claims_adjuster"]
110
+ request.risk_in: ["low", "medium"]
111
+ data.contains_secrets: false
112
+
113
+ - name: redact_pii_for_non_privileged_users
114
+ effect: transform
115
+ action: redact
116
+ when:
117
+ data.contains_pii: true
118
+ user.role_not_in: ["privacy_admin", "compliance_officer"]
119
+
120
+ - name: require_approval_for_high_risk
121
+ effect: require_approval
122
+ when:
123
+ request.risk: "high"
124
+ ```
125
+
126
+ ## Development Status
127
+
128
+ This is a production-grade starter framework: the core extension points and executable behavior are present, while provider integrations, enterprise identity adapters, dashboard UI, and long-term storage can be expanded by contributors.
129
+
130
+ ## v0.2 MVP Capabilities
131
+
132
+ - Deterministic risk classification: low, medium, high, critical.
133
+ - Explainable policy decisions with reason codes and remediation.
134
+ - Replayable audit trace snapshots.
135
+ - Audit bundle generation.
136
+ - Tool governance policies for MCP-style connectors and actions.
137
+ - Governance-aware eval report schema.
138
+ - Provider adapters for OpenAI-compatible APIs, Azure OpenAI, Anthropic, Bedrock, Vertex AI, Ollama, and vLLM.
139
+ - SQLite audit storage and static trace viewer.
140
+ - Prometheus text and OpenTelemetry-shaped JSON exporters.
141
+ - File and webhook approval hooks.
142
+ - Executable golden dataset policy checks.
143
+
144
+ ## License
145
+
146
+ Apache-2.0
@@ -0,0 +1,16 @@
1
+ # Security Policy
2
+
3
+ PolicyAware AI Gateway is security-sensitive infrastructure. Please do not open public issues for suspected vulnerabilities.
4
+
5
+ ## Reporting
6
+
7
+ Email the maintainers or use your organization's private disclosure process until this project has a dedicated security contact.
8
+
9
+ ## Security Model
10
+
11
+ - Requests are denied unless policy allows them.
12
+ - Transform rules do not grant access.
13
+ - Tool calls should be treated as privileged operations.
14
+ - Audit traces should be protected as sensitive records.
15
+ - Redaction reduces risk but is not a substitute for access control.
16
+
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,19 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title>PolicyAware Documentation</title>
7
+ <link rel="stylesheet" href="site.css">
8
+ </head>
9
+ <body>
10
+ <main class="section">
11
+ <div class="shell">
12
+ <h1>PolicyAware Documentation</h1>
13
+ <p>The page you requested was not found.</p>
14
+ <p><a class="button" href="./">Return to documentation home</a></p>
15
+ </div>
16
+ </main>
17
+ </body>
18
+ </html>
19
+
@@ -0,0 +1,45 @@
1
+ # Architecture
2
+
3
+ PolicyAware AI Gateway is organized around explicit, replaceable engines.
4
+
5
+ ## Request Lifecycle
6
+
7
+ 1. The SDK or middleware constructs a `GatewayRequest`.
8
+ 2. `DataProtectionEngine` detects PII, PHI, secrets, and sensitive categories.
9
+ 3. `RiskClassifier` assigns low, medium, high, or critical risk.
10
+ 4. `PolicyEngine` evaluates deny, approval, allow, and transform rules with explainable reason codes.
11
+ 5. Denied and approval-gated requests stop before model execution.
12
+ 6. Allowed requests are transformed if required, then sent to `ModelRouter`.
13
+ 7. `ModelProvider` executes the request against a local or external model.
14
+ 8. `RuntimeEvaluator` scores the output for leakage, citations, policy consistency, and safety hooks.
15
+ 9. `AuditLogger` writes a replay-ready trace.
16
+
17
+ ## Extension Points
18
+
19
+ - `PolicyEngine`: replace YAML policies with OPA, Cedar, SQL-backed policies, or custom PDPs.
20
+ - `DataProtectionEngine`: add Microsoft Presidio, Cloud DLP, custom classifiers, or domain detectors.
21
+ - `ModelRouter`: add health checks, quality feedback, provider quotas, and SLO-aware routing.
22
+ - `ModelProvider`: implement OpenAI, Azure OpenAI, Bedrock, Vertex, Anthropic, vLLM, Ollama, or TGI adapters.
23
+ - `RuntimeEvaluator`: plug in LLM-as-judge, RAGAS-style scoring, citation validation, toxicity classifiers, and golden datasets.
24
+ - `AuditLogger`: write to OpenTelemetry, Kafka, SIEM, S3, BigQuery, Snowflake, or Postgres.
25
+ - `ToolPolicyEngine`: govern MCP-style connectors and action permissions.
26
+
27
+ ## Policy Semantics
28
+
29
+ PolicyAware is deny-by-default.
30
+
31
+ Evaluation order:
32
+
33
+ 1. `deny`
34
+ 2. `require_approval`
35
+ 3. `allow` plus any matching `transform`
36
+ 4. default decision
37
+
38
+ Transform rules never grant access by themselves. They only modify requests that were otherwise allowed, or requests permitted by a default-allow policy.
39
+
40
+ ## v0.2 Governance Additions
41
+
42
+ - Risk classification is deterministic and based on data sensitivity, domain, tool use, autonomy, business impact, and action type.
43
+ - Policy decisions include reason codes, matched policy IDs, violated policy IDs, and remediation guidance.
44
+ - Audit traces include request/response snapshots for replay and evidence bundles.
45
+ - Tool governance is separate from chat/model policy so agent actions can be authorized at connector and action level.