a3bb78e06b
Security Quality Gate / npm audit, Bandit, pip-audit, detect-secrets (pull_request) Failing after 16m35s
4.1 KiB
4.1 KiB
V2 Phase 3 AI Platform Tenant And Trace Governance
Date: 2026-07-02
Status
This slice adds the first AI Platform governance baseline for knowledge assets, AI Trace, and quality actions.
Completed:
- Added migration
20260624_0019_add_tenant_trace_governance.py. - Added
tenant_idto:knowledge_documentsknowledge_import_batchesknowledge_chunksknowledge_reindex_executionsknowledge_ingestion_jobsai_run_auditsai_quality_improvement_actions
- Added AI Trace governance fields to
ai_run_audits:redaction_statusredaction_policyretention_untilarchive_statusarchived_at
- Added tenant/governance indexes for high-frequency knowledge, trace, ingestion, and quality-action paths.
- Updated SQLAlchemy models and DTO mappers.
- Updated SQLAlchemy persistence to write and read the default tenant boundary.
- Updated AI Platform runtime schema-check with:
tenant_columnstrace_governance_columns
- Added/updated tests for schema-check, Trace response compatibility, and SQLAlchemy roundtrip persistence.
Compatibility
The original tenant/governance migration slice did not require frontends or callers to pass tenant IDs yet.
Current behavior:
- New rows default to
tenant_id = "default". - Existing rows are backfilled by migration defaults.
- AI Trace list/detail responses include governance fields with safe defaults.
- The API surface remains backward compatible for existing callers.
Follow-up completed on 2026-07-02:
- Request-level
X-Tenant-Idcontext. - Tenant-aware API filtering for knowledge documents, AI Trace, and quality actions.
- Cross-tenant AI Trace detail isolation with
404. - Backward-compatible
defaulttenant behavior whenX-Tenant-Idis omitted.
Deferred to later slices:
- Tenant-aware auth/permission enforcement.
- Row-level security.
- Actual redaction job implementation.
- Retention/archive worker.
- Sensitive field encryption.
Validation
Local validation passed:
python -m py_compile `
yuqei-ai-platform/services/ai-platform-api/src/yuqei_ai_platform_api/models.py `
yuqei-ai-platform/services/ai-platform-api/src/yuqei_ai_platform_api/schema_check.py `
yuqei-ai-platform/services/ai-platform-api/src/yuqei_ai_platform_api/persistence/audit.py `
yuqei-ai-platform/services/ai-platform-api/src/yuqei_ai_platform_api/persistence/knowledge.py `
yuqei-ai-platform/services/ai-platform-api/src/yuqei_ai_platform_api/persistence/quality.py `
yuqei-ai-platform/services/ai-platform-api/src/yuqei_ai_platform_api/repository.py `
yuqei-ai-platform/services/ai-platform-api/migrations/versions/20260624_0019_add_tenant_trace_governance.py
python -m pytest yuqei-ai-platform/services/ai-platform-api/tests/test_health.py -q
python -m pytest `
yuqei-ai-platform/services/ai-platform-api/tests/test_provider_flow.py::test_legal_qa_uses_provider_answer_when_enabled `
yuqei-ai-platform/services/ai-platform-api/tests/test_platform_data.py::test_sqlalchemy_repository_persists_platform_data -q
python -m pytest yuqei-ai-platform/services/ai-platform-api/tests -q
Result:
- AI Platform API tests: passed.
Remaining Items From Closure List
Done in this slice:
- AI Platform tenant fields for knowledge assets, AI Trace, and quality actions.
- AI Trace redaction/retention/archive metadata.
- Runtime schema-check coverage for these fields.
Still pending:
- Implement actual Trace redaction worker.
- Implement retention/archive worker.
- Delivery quality gates rerun.
Recommended Next Step
Continue with Trace redaction/retention/archive workers and delivery quality gates.
Smoke verification for this slice is recorded in:
project-docs/V2-phase3-ai-platform-tenant-trace-governance-smoke-verification-2026-07-02.md
Request-level tenant context implementation and smoke verification are recorded in:
project-docs/V2-phase3-ai-platform-request-tenant-context-2026-07-02.md
Provider/OCR secret ref compatibility and pgvector schema-check hardening are recorded in:
project-docs/V2-phase3-provider-ocr-secret-ref-pgvector-schema-2026-07-02.md