Skip to content

feat(ai): MEAI Phase 2 — policy, sanitize, audit middleware - #232

Draft
IanFrelinger wants to merge 3 commits into
masterfrom
cursor/meai-phase2-governance-5a04
Draft

feat(ai): MEAI Phase 2 — policy, sanitize, audit middleware#232
IanFrelinger wants to merge 3 commits into
masterfrom
cursor/meai-phase2-governance-5a04

Conversation

@IanFrelinger

Copy link
Copy Markdown
Owner

Summary

Phase 2 of the MEAI migration: every keyed IChatClient registered via AddNexoMeaiPipeline is wrapped with the fixed governance stack PolicyGate → Sanitizing → Auditing → provider through UseNexoGovernance().

This branch stacks on Phase 0 + Phase 1 work. Prefer merging #230#231 → this PR, or take this PR alone (includes prior phases).

Changes

  • New governance types under src/Nexo.AI.Pipeline/Governance/:
    • PolicyGateChatClient, SanitizingChatClient, AuditingChatClient
    • PolicyViolationException, sanitize dispositions, ports + defaults
    • UseNexoGovernance(targetKey) — enforced composition order
  • AddNexoMeaiPipeline always applies governance (raw providers never DI-public)
  • Defaults: local:* allowed + sanitize Pass; cloud:* denied unless allow-listed; cloud sanitize = block-on-secret / redact-on-PII
  • Tests for deny short-circuit, PII redaction before spy, audit on success/fault/cancel, composition order, architecture checks
  • Migration notes updated

Testing

dotnet test src/Nexo.Tests.AI.Pipeline/Nexo.Tests.AI.Pipeline.csproj
# Passed: 15 on net8.0, 15 on net9.0

Testing strategy (blast radius)

Change type Minimum proof
AI pipeline middleware Unit tests in Nexo.Tests.AI.Pipeline
  • Focused unit tests (policy / sanitize / audit / architecture)

Checklist

  • Feature flag still defaults off (legacy path untouched)
  • Impossible to resolve ungoverned clients through AddNexoMeaiPipeline
  • Docs updated

Next

Phase 3: RoutingChatClient with local-first policy × availability matrix.

Open in Web Open in Cursor 

cursoragent and others added 3 commits July 14, 2026 17:59
Map current model invocation, sanitization, audit, policy packs, RAG,
and host DI seams to proposed Microsoft.Extensions.AI concepts for the
governed pipeline migration.

Co-authored-by: IanFrelinger <IanFrelinger@users.noreply.github.com>
Add Nexo.AI.Pipeline with keyed local:ollama and local:onnx chat clients,
wire optional registration through hosting Phase 13b when
Nexo:UseMeaiPipeline is enabled (default off), and cover registration
with FakeChatClient tests. Legacy IProviderFactory path remains default.

Co-authored-by: IanFrelinger <IanFrelinger@users.noreply.github.com>
Introduce UseNexoGovernance with fixed PolicyGate → Sanitizing → Auditing
order on every keyed IChatClient, plus unit tests for deny short-circuit,
PII redaction, audit outcomes, and composition/architecture guarantees.

Co-authored-by: IanFrelinger <IanFrelinger@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants