§ 4 — Modules

Three autonomous agents. One negotiated decision.

The CORTEX Framework is decomposed into three autonomous agents, each governed by an explicit type contract, each independently evaluable through the unit-evaluation harness described in §6, and each able to contest the outputs of its peers. The decomposition is intentionally symmetric — every agent exposes an interface boundary, a computational kernel, a provenance fabric and an emission boundary — which permits the same orchestration, observability and ablation infrastructure to be reused without modification. Coordination is not scripted: agents exchange CLAIM, CHALLENGE, CONGESTION and DISCOVERY messages, renegotiating contested fields and rerouting around saturated peers until the protocol converges. Together they form the canonical configuration of the framework; in isolation each constitutes a falsifiable scientific contribution in its own right.

Module · M1

OPTIC — Generative Optical Perception

OPTIC is the generative optical perception agent of CORTEX. It admits heterogeneous source documents — scanned PDFs, photographed forms, semi-structured layouts, machine-readable XML and structurally noisy email bodies — through a single typed acquisition interface and reads them with a vision–language decoder rather than a classical character recogniser, emitting schema-bound structured records directly from pixels. Perception is decomposed into three composable subsystems: a layout analyser that recovers the physical and logical structure of the page, a generative typed-entity decoder that projects that layout onto a domain-specific schema, and a confidence calibrator that attaches a per-field reliability score derived from agreement across redundant decoding passes at different temperatures. Because generative decoding can produce fluent but unsupported values, OPTIC never asserts a field unilaterally: every extraction is emitted as a CLAIM carrying calibrated confidence and a pixel-level evidence span, leaving adjudication to NEXUS.

Typed acquisition across PDF, image, XML and email payloads
Layout analysis with topological reconstruction of reading order
Schema-bound entity and field extraction under explicit type contracts
Per-field confidence calibration through redundant-decoder agreement
Composable processing pipeline with deterministic replay against snapshots
Scientific Contribution

Formalises document intelligence as a typed, side-effect-free transformation from unstructured corpora to schema-bound representations admitting compositional reasoning, ablation and audit-grade replay.

python
# OPTIC — Document Intelligence Kernel
from typing import Mapping
from cortex.types import (
    SourceRef, DocumentEnvelope, ExtractedRecord,
    LayoutTree, Typed, ProvenanceTree,
)

def acquire(source: SourceRef) -> DocumentEnvelope:
    """Typed, source-agnostic acquisition boundary."""
    raw  = source.fetch()
    meta = extract_metadata(raw)
    return DocumentEnvelope(
        payload     = raw,
        mime        = meta.mime,
        provenance  = meta.provenance,
    )

# Composable, pure transformations
pipeline = compose(
    parse_pdf,
    segment_layout,        # → LayoutTree
    project_to_schema,     # → Mapping[str, Typed]
    calibrate_confidence,  # redundant-decoder agreement
)

record: ExtractedRecord = pipeline(envelope)
# record.fields      :: Mapping[str, Typed]
# record.confidence  :: Mapping[str, float ∈ [0,1]]
# record.layout      :: LayoutTree
# record.provenance  :: ProvenanceTree
Interface signature — OPTIC (illustrative).
Module · M2

NEXUS — Consensus Arbitration

NEXUS introduces validation as a first-class pipeline stage rather than a post-hoc quality check. Given an extracted record R and an indexed family of independent evidence sources E = {S₁, …, Sₙ}, it computes an agreement functional a(R, E) weighted by an empirically calibrated reliability prior over the sources and returns a confidence-weighted verdict together with a closed provenance subgraph. The module is designed for fan-in/fan-out topologies in which redundant sources attenuate the variance of any individual extractor; disagreement is resolved through a principled arbitration procedure rather than through ad-hoc heuristics, eliminating the silent failure modes characteristic of first-source-wins strategies.

Cross-source validation under heterogeneous reliability profiles
Government and registry data verification through typed adapters
Consistency analysis with closed-form replay against evidence snapshots
Principled disagreement resolution and arbitration auditing
Full provenance tracking materialised as an immutable DAG
Scientific Contribution

Provides formal consistency guarantees across heterogeneous evidence sources and converts validation from an implicit assumption of the pipeline into an explicit, evaluable kernel.

python
# NEXUS — Cross-Source Validation Kernel
from nexus.types import (
    ExtractedRecord, Source, Verdict, Evidence,
)
from nexus.priors import RELIABILITY_PRIOR

THRESHOLD: float = 0.78  # empirically calibrated

def validate(
    record: ExtractedRecord,
    sources: list[Source],
) -> Verdict:
    """Agreement functional a(R, E) under heterogeneous reliability."""
    evidence: list[Evidence] = [
        s.lookup(record.key) for s in sources
    ]

    # Weighted agreement under reliability prior
    weights = [RELIABILITY_PRIOR[s.id] for s in sources]
    score   = weighted_agreement(record, evidence, weights)

    return Verdict(
        consistent  = score >= THRESHOLD,
        confidence  = score,
        evidence    = evidence,
        arbitration = arbitrate_disagreement(record, evidence),
        provenance  = build_dag(record, evidence, weights),
    )

verdict = validate(record, sources=[s1, s2, s3])
# verdict.consistent  :: bool
# verdict.confidence  :: float ∈ [0,1]
# verdict.provenance  :: DAG[Source, Transform]
Interface signature — NEXUS (illustrative).
Module · M3

AEGIS — Symbolic Guardrail

AEGIS encodes operational restrictions as a declarative constraint set C and evaluates it symbolically against the validated record R. The output is an auditable decision-support emission carrying the decision status, the set of violated constraints, and a machine-readable rationale paired with a natural-language justification suitable for downstream human review. The constraint system is constructively monotone in C — adding a restriction never converts a reject into an approve — which guarantees that constraint catalogues can be extended without invalidating prior decisions, a property required for stable longitudinal audit and regulatory compliance.

Declarative business rules expressed in a constrained logical fragment
Symbolic restriction evaluation with monotonicity guarantees
Operational validation against compliance and regulatory catalogues
Audit-ready justifications in machine- and human-readable form
Decision-support emission with explicit rationale and violation set
Scientific Contribution

Enables transparent, restriction-aware decision support with full traceability and longitudinal stability under constraint catalogue evolution.

python
# AEGIS — Symbolic Restriction Evaluator
from aegis.types import (
    ExtractedRecord, Verdict, Constraint,
    Decision, Justification, Status,
)
from aegis.catalogue import RESTRICTION_SET

def evaluate(
    record:   ExtractedRecord,
    verdict:  Verdict,
    rules:    frozenset[Constraint] = RESTRICTION_SET,
) -> Decision:
    """Monotone symbolic evaluation of C against (R, verdict)."""
    violations: set[Constraint] = {
        c for c in rules if not c.holds(record, verdict)
    }

    status: Status = (
        Status.APPROVE if not violations and verdict.consistent
        else Status.REVIEW if verdict.confidence >= 0.6
        else Status.REJECT
    )

    return Decision(
        status      = status,
        violations  = frozenset(violations),
        rationale   = Justification.from_violations(violations),
        provenance  = verdict.provenance.extend(rules),
    )

decision = evaluate(record, verdict, RESTRICTION_SET)
# decision.status     :: {approve, review, reject}
# decision.violations :: Set[Constraint]
# decision.rationale  :: Justification
Interface signature — AEGIS (illustrative).