Skip to content

[Proposal] Cognitive Firewall Control Plane - FastAPI Service, /validate Contract & Audit Layer #6

@Saisharathchandranandnetha

Description

⚠️ Updated Revised to align with Phase-1 Architecture

Changes from original:


Overview

Hi @tharindupr and the ACF-SDK team 👋

Following the design work in Issues #1, #2, and #3, I am proposing
a Cognitive Firewall Control Plane a stable input/output
contract layer that gives the pipeline a consistent, inspectable
interface, built on the UDS transport and OTel audit plane already
established in Phase 1.

To be clear upfront: I am not proposing to re-architect the sidecar
kernel or the transport layer. The goal is a thin schema contract
layer with OTel-native observability, built incrementally with
maintainer sign-off at each step.


Why This Layer?

The sidecar kernel currently has no stable input/output contract
that all pipeline layers conform to. This means:

  • Each layer (heuristics, semantic, provenance) may emit signals
    in different shapes
  • There is no single observable control point for policy decisions
  • External agents have no agreed interface for submitting inputs
    for validation

This proposal defines that contract not as an HTTP service, but
as a UDS-native schema that all layers write to and read from.


The /validate Contract (UDS-aligned)

The most important step before any code is agreeing on the
data schema. Here is my proposed starting point — fully open
to refinement by maintainers.

Request (sent over UDS as binary-framed payload):

@dataclass
class ValidateRequest:
    input: str
    agent_id: str
    trace_id: str              # UUID for OTel span correlation
    policy_version: str        # semver
    timestamp_utc: str         # ISO-8601
    memory_snapshot: list[str]
    tool_results: list[dict]   # {tool_name, output, source_signature}
    conversation_history: list[str]

Response (returned over UDS):

@dataclass
class ValidateResponse:
    decision: str              # "PASS" | "SANITIZE" | "BLOCK"
    risk_score: float          # 0.0–1.0
    reasons: list[str]
    sanitized_input: str | None
    trace_id: str              # echoed for OTel correlation
    layer_signals: dict        # per-layer outputs → OTel span attributes
    # layer_signals shape:
    # {
    #   "normalisation": {"obfuscation_severity": 0.0, "fast_fail": false},
    #   "lexical":       {"matched_patterns": []},
    #   "semantic":      {"cosine_score": 0.0},
    #   "provenance":    {"signature_valid": true}
    # }

This schema is intentionally compatible with the v1.1 Telemetry
Contract referenced in PR #4 it is a structured projection
of the same data model.


Phased Delivery (Maintainer-Gated)

Each phase is a standalone Draft PR. Nothing merges without
review and explicit sign-off.

Phase Deliverable Stack
1 UDS listener skeleton + Pydantic schemas Python, UDS, zero HTTP
2 Route to pipeline modules as they land Wires normalisation, lexical, semantic outputs
3 OTel span emission per decision opentelemetry-sdk, trace_id correlation
4 Operations Dashboard (OTel-native, optional) Next.js or Streamlit → Jaeger
5 Docker + docker-compose One-command deployment
6 MCP adapter Agent-agnostic interface per GSoC spec

Phase 4 note: The observability dashboard is scoped as
optional and experimental. It will only be pursued if Phases 1–3
are stable and maintainers confirm it as a priority.


Relationship to Existing Work

SDK Interceptor (PR #4)
    │
    ├── [UDS binary] ──► Sidecar Kernel (Issues #1, #3)
    │                         │
    │                    [OTel spans] ──► Jaeger / Prometheus
    │                                          │
    │                                   Operations Dashboard
    │                                   (Phase 4 optional)
    │
    └── ValidateRequest / ValidateResponse schema
        (this proposal sits across all layers as the contract)

This adds a schema contract, not a new transport path.
Contributors on individual pipeline layers can conform to this
schema without changing their module interfaces.


Why I Can Build This

At the India AI Impact Buildathon 2026 (top 850 / 38,000+
participants), I built Scam Shield an offensive AI honeypot
that processes adversarial scammer messages across 8 Indian
languages using a 6-layer detection pipeline with confidence
scoring, a multi-LLM cascade, and a FastAPI backend deployed
on Render.

The schema design problem here defining a stable contract
that multiple detection layers write to is identical to the
problem I solved in Scam Shield. I have direct production
experience with exactly this architecture pattern.

Live system: https://scam-shield-5hnk.onrender.com


Questions for Maintainers

  1. Does the ValidateRequest / ValidateResponse schema align
    with the v1.1 Telemetry Contract in PR feat(core): Phase 1 Integration Scaffold & v1.1 Telemetry Contract #4, or should I adjust
    the field names or shape?
  2. Should the UDS listener use length-prefixed framing or a
    different binary protocol?
  3. Is Phase 4 (dashboard) in scope for GSoC 2026, or is it
    purely post-GSoC?
  4. Is there an existing contract I should conform to that I
    may have missed?

Ready to open a Draft PR with just the Pydantic dataclasses
and a UDS skeleton zero logic immediately for early review
and correction.


cc: @tharindupr @charithccmc @eddymontana

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions