AEGISdocs
Guides

AgoraIV -- AEGIS Integration Contract

Version: 1.1.0 | Updated: 2026-02-26 | Status: Active

Version: 1.1.0 | Updated: 2026-02-26 | Status: Active GAP Reference: GAP-7 (AgoraIV Integration Contract) AEGIS Version: v1.1.0 (aegis-governance package) AgoraIV Component: aegis_bridge/ module


1. Overview

AgoraIV orchestrates multi-model LLM dialogue across GPT-5.2, Claude Opus 4.6, and Gemini 3 via the PCW V3 (PowerCommunalWisdom Version 3) consensus protocol. AEGIS provides quantitative governance gates that evaluate research outputs before they are routed to decision logic.

The integration boundary lives in aegis_bridge/ within the AgoraIV codebase. This bridge module adapts AgoraIV research outputs into AEGIS gate inputs and converts AEGIS gate results back into AgoraIV's internal decision-routing types.

AgoraIV (multi-model orchestration)
    |
    +-- aegis_bridge/          <-- Integration boundary (AgoraIV-owned)
    |       |
    |       +-- ResearchToAegisMapper    Converts research outputs -> AEGIS params
    |       +-- AegisGateResult          Internal gate result type
    |       +-- GateType (AgoraIV)       Maps to AEGIS GateType enum
    |       +-- evaluate()               Calls GateEvaluator.evaluate_all()
    |       +-- fallback_evaluate()      Degraded mode when AEGIS unavailable
    |
    +-- decision_engine/       <-- Consumes gate results for routing

Relationship: AEGIS is a governance dependency of AgoraIV. AEGIS does not depend on AgoraIV. This contract is unidirectional: AgoraIV calls AEGIS, never the reverse.


2. AEGIS Version Requirements

RequirementValueNotes
Minimum versionv1.1.0aegis-governance package
Python compatibility3.9+Matches AEGIS CI matrix (3.9, 3.10, 3.11, 3.12)
Required extras[engine]scipy for UtilityCalculator z-score computation
Authoritative parametersschema/interface-contract.yamlFrozen at guardrail-v1.1-freeze

Import Mechanism

Resolved (GAP-1): AgoraIV now imports AEGIS via pip install aegis-governance[engine] (or pip install -e path/to/aegis-governance[engine] for development). The aegis_governance package exposes a stable public API via src/aegis_governance/__init__.py. The previous sys.path hack has been removed from aegis_bridge/gate_adapter.py and replaced with standard pip imports. The dependency is declared in requirements_agora.txt.


3. Gate Evaluation

AEGIS evaluates all 6 quantitative gates for every AgoraIV research proposal. The bridge calls GateEvaluator.evaluate_all() and receives a GateEvaluationResult containing individual GateResult objects keyed by GateType.

3.1 Gates Evaluated

AEGIS GateTypeThresholdAgoraIV MappingStatus
RISKBayesian posteriorP(delta >= 2 | data) > 0.95Mapped to AgoraIV GateType.RISKActive
PROFITBayesian posteriorP(delta >= 2 | data) > 0.95Mapped to AgoraIV GateType.PROFIT (advisory)Active
NOVELTYLogistic functionG(N) >= 0.6 (N0=0.7, k=10)Mapped to AgoraIV GateType.NOVELTYActive
COMPLEXITYHard floorC_norm >= 0.5Mapped to AgoraIV GateType.COMPLEXITYActive
QUALITYMinimum + no-zeroQ >= 0.7, no zero subscoresMapped to AgoraIV GateType.QUALITYActive
UTILITYLower Confidence BoundLCB(U) > 0.0 (alpha=0.05)Mapped to AgoraIV GateType.UTILITYActive

GAP-3 (Resolved): The PROFIT gate result is now mapped to GateType.PROFIT and passed through to the AgoraIV decision engine as an advisory gate.

3.2 Mandatory vs Advisory Classification

The bridge classifies gate results into two enforcement tiers before passing them to the AgoraIV decision engine.

Mandatory Gates (failure halts or blocks the proposal)

GateConditionOverride?Rationale
COMPLEXITYcomplexity_score < 0.5No -- HALT is non-overridablePrevents execution of proposals exceeding complexity bounds. AEGIS enforces this as a hard floor per spec SS 4.1.4.
RISKP(delta >= risk_trigger_factor | data) > 0.95Two-key BIP-322 override onlyHigh-confidence evidence of unacceptable risk increase. Bayesian posterior provides calibrated confidence.
QUALITYquality_score < 0.7 OR any subscore is 0.0Two-key BIP-322 override onlyEnsures minimum quality bar. Zero-subscore rejection prevents single-dimension blind spots.

Advisory Gates (failure triggers review, not halt)

GateConditionEffect on AgoraIVRationale
NOVELTYG(N) &lt; 0.6Decision engine flags for human reviewLow novelty suggests the proposal is insufficiently differentiated. Review required but execution is not blocked.
UTILITYLCB(U) ≤ 0.0Decision engine adds risk noteNegative lower confidence bound indicates high uncertainty in expected value. Advisory because the utility model may not be calibrated for all research domains.
PROFITP(delta >= trigger | data) > 0.95Advisory — flags for reviewPerformance regression detection. Advisory tier because research outputs have inherently uncertain profit estimates.

4. Data Flow

4.1 Normal Path (AEGIS Available)

AgoraIV PCW V3 Research Outputs
         |
         v
 ResearchToAegisMapper.map(research_output)
         |  Extracts: risk_baseline, risk_proposed, profit_baseline,
         |  profit_proposed, novelty_score, complexity_score,
         |  quality_score, quality_subscores, proposal_summary,
         |  estimated_impact
         v
 GateEvaluator.evaluate_all(
     risk_baseline=...,
     risk_proposed=...,
     profit_baseline=...,
     profit_proposed=...,
     novelty_score=...,
     complexity_score=...,
     quality_score=...,
     quality_subscores=[...],
 )
         |
         v
 GateEvaluationResult
     .gates[GateType.RISK]      -> GateResult(passed, value, threshold, ...)
     .gates[GateType.PROFIT]    -> GateResult(passed, value, threshold, ...)
     .gates[GateType.NOVELTY]   -> GateResult(passed, value, threshold, ...)
     .gates[GateType.COMPLEXITY]-> GateResult(passed, value, threshold, ...)
     .gates[GateType.QUALITY]   -> GateResult(passed, value, threshold, ...)
     .gates[GateType.UTILITY]   -> GateResult(passed, value, threshold, ...)
         |
         v
 Bridge converts to AegisGateResult objects
     (all 6 gates mapped including PROFIT)
         |
         v
 AgoraIV DecisionEngine.route(gate_results)
     Applies mandatory/advisory classification
     Routes to: execute | review | halt

4.2 Degraded Path (AEGIS Unavailable)

When the AEGIS package cannot be imported (AEGIS_AVAILABLE = False), the bridge degrades to simplified threshold comparisons. This ensures AgoraIV continues functioning but with reduced governance rigor.

# Simplified fallback logic (approximate representation)
def fallback_evaluate(research_output):
    results = {}
    if research_output.risk_score < 0.5:
        results["risk"] = PASS
    else:
        results["risk"] = FAIL

    if research_output.quality_score >= 0.7:
        results["quality"] = PASS
    else:
        results["quality"] = FAIL

    if research_output.complexity_score >= 0.5:
        results["complexity"] = PASS
    else:
        results["complexity"] = FAIL

    # Novelty and utility use simple thresholds
    # No Bayesian posterior, no logistic function, no LCB
    return results

Limitations of fallback mode:

CapabilityNormal (AEGIS)Fallback
Bayesian posterior for risk/profitYesNo -- simple threshold comparison
Logistic novelty functionYesNo -- linear threshold
LCB utility checkYesNo -- omitted entirely
Posterior probability confidenceYesNo -- binary pass/fail only
Quality subscore zero-checkYesNo -- aggregate score only
Drift detectionYesNo -- not available
Audit trailYes (when using AuditMiddleware)No
Parameter freezingYes (AegisConfig frozen dataclass)No -- hardcoded values

Expectation: Fallback mode is acceptable for development and testing. Production deployments MUST have AEGIS available. The bridge SHOULD log a warning at startup when operating in fallback mode.


5. Audit Requirements

5.1 Current State (GAP-2 Resolved)

The bridge now uses AuditMiddleware.decide() for audit trail emission after each gate evaluation. The GateAdapter creates an AuditMiddleware(source="agoraiv") instance at construction and calls _emit_audit_event() after every successful evaluation.

This provides:

  • Automatic input validation (NaN/Inf rejection, bool guarding, type coercion).
  • Audit event emission with SHA-256 integrity hashes.
  • Drift detection via DriftMonitor integration (GAP-4 resolved).
  • Rate limiting (when configured).
  • Consistent behavior with MCP, Lambda, and CLI entry points.

5.2 Implementation Pattern

from aegis_governance import AuditMiddleware, DriftMonitor, build_pcw_context

audit = AuditMiddleware(source="agoraiv")
drift_monitor = DriftMonitor()

# After gate evaluation, emit audit event with drift context
ctx = build_pcw_context({
    "agent_id": "agoraiv-bridge",
    "phase": "work",
    "risk_baseline": mapped.risk_baseline,
    "risk_proposed": mapped.risk_proposed,
    "profit_baseline": mapped.profit_baseline,
    "profit_proposed": mapped.profit_proposed,
    "novelty_score": mapped.novelty_score,
    "complexity_score": mapped.complexity_score,
    "quality_score": mapped.quality_score,
    "quality_subscores": mapped.quality_subscores,
    "metadata": {"source": "agoraiv-gate-adapter", "drift_baseline_data": drift_history},
})

decision = audit.decide(ctx, drift_monitor=drift_monitor)

5.3 Audit Event Schema

Each AuditMiddleware.decide() call emits an AuditEvent containing:

FieldTypeDescription
event_idUUIDUnique identifier for this evaluation
timestampISO 8601 (UTC)When the evaluation occurred
sourcestring"agoraiv-bridge"
agent_idstringAgent identifier from context
proposal_summarystringProposal description
gate_resultsdictPer-gate pass/fail with values
decision_statusstringPROCEED / PAUSE / HALT / ESCALATE
integrity_hashstringSHA-256 of the event payload

6. Parameter Mapping Reference

The ResearchToAegisMapper MUST produce values conforming to AEGIS parameter constraints. See Parameter Reference for full derivation guidance.

AEGIS ParameterTypeRangeRequiredNotes
risk_baselinefloat0.0--1.0YesCurrent risk before proposed research action
risk_proposedfloat0.0--1.0YesPredicted risk after research action
profit_baselinefloatanyYesCurrent performance metric
profit_proposedfloatanyYesExpected performance after action
novelty_scorefloat0.0--1.0YesResearch novelty (higher = more novel)
complexity_scorefloat0.0--1.0YesSimplicity margin (higher = simpler)
quality_scorefloat0.0--1.0YesOverall research quality
quality_subscoresfloat[]0.0--1.0 eachNoPer-dimension quality breakdown
proposal_summarystringnon-emptyYesHuman-readable description
estimated_impactstringlow/medium/high/criticalYesBlast radius classification
utility_resultUtilityResult--NoAuto-synthesized from profit/risk inputs if absent (PERT ±20% spread, epsilon clamp 0.001)

Input validation: All float parameters MUST be finite (not NaN, not Inf). Boolean values MUST NOT be passed where floats are expected. The AuditMiddleware and build_pcw_context() enforce these constraints; direct GateEvaluator calls do not.


7. Shared Testing Responsibility

7.1 AEGIS Owns

ResponsibilityVerificationLocation
Gate evaluation correctness4100+ tests, ~92.0% coveragetests/ in aegis-governance
Bayesian posterior mathematicsUnit tests for BayesianPosteriortests/test_bayesian.py
GateEvaluator API stabilityPublic API teststests/test_gates.py
AuditMiddleware behaviorMiddleware unit teststests/test_middleware.py
SDK public surface (aegis_governance package)Import teststests/test_init.py
Parameter validation (NaN, Inf, bool, type)Transport parity teststests/test_cli.py, tests/test_lambda.py, tests/test_mcp.py
Frozen parameter consistencySchema teststests/test_schema_consistency.py

7.2 AgoraIV Owns

ResponsibilityVerificationLocation
ResearchToAegisMapper correctnessUnit tests in AgoraIVaegis_bridge/tests/
GateType enum mappingUnit tests in AgoraIVaegis_bridge/tests/
Decision engine behaviorIntegration testsAgoraIV test suite
Fallback logic correctnessUnit tests with AEGIS mocked unavailableaegis_bridge/tests/
PROFIT gate advisory routing (GAP-3 resolved)Test that PROFIT is routed as advisoryaegis_bridge/tests/

7.3 Shared (Cross-Project)

ResponsibilityStatusLocation
AEGIS API contract tests (GAP-5)Activetests/integration/test_agoraiv_contract.py (67 tests)
Parameter contract testsPlannedValidate ResearchToAegisMapper output against interface-contract.yaml
Regression suite for bridge upgradesPlannedShared fixtures with pinned AEGIS version

Contract tests (GAP-5) verify the AEGIS public API surface against AgoraIV's requirements. These run in AEGIS CI automatically.


8. Known Gaps

GAPTitleSeverityStatusOwnerDescription
GAP-1sys.path Import HackHIGHResolvedAEGISReplaced with pip install aegis-governance[engine]. Dependency declared in requirements_agora.txt.
GAP-2No Audit Trail via BridgeHIGHResolvedAgoraIVBridge now uses AuditMiddleware.decide() for audit event emission after every gate evaluation.
GAP-3PROFIT Gate Silently DroppedMEDIUMResolvedAgoraIVPROFIT gate now mapped to GateType.PROFIT and routed to decision engine as advisory gate.
GAP-4No Drift Detection in BridgeMEDIUMResolvedAgoraIVBridge passes drift_baseline_data via DriftMonitor integration. Bounded deque (maxlen=100) stores evaluation history.
GAP-5No Cross-Project Integration TestsMEDIUMResolvedShared67 contract tests in tests/integration/test_agoraiv_contract.py verify AEGIS API surface matches AgoraIV expectations.
GAP-6Fallback Thresholds HardcodedLOWOpenAgoraIVFallback mode uses hardcoded thresholds that may drift from interface-contract.yaml frozen values.
GAP-7Integration Contract MissingHIGHResolvedAEGISThis document.
GAP-8No Shadow Mode in BridgeLOWOpenAgoraIVBridge does not support AEGIS shadow mode for calibration periods.

Resolution Priority

Phase 1 (Immediate) — RESOLVED 2026-02-26:
  GAP-1: ✅ aegis-governance pip-installable, sys.path hack removed
  GAP-2: ✅ Bridge uses AuditMiddleware.decide() for audit trail

Phase 2 (Short-term) — RESOLVED 2026-02-26:
  GAP-3: ✅ PROFIT gate mapped as advisory tier
  GAP-4: ✅ drift_baseline_data passed via DriftMonitor integration
  GAP-5: ✅ 67 contract tests in tests/integration/test_agoraiv_contract.py

Phase 3 (Backlog):
  GAP-6: Load fallback thresholds from interface-contract.yaml
  GAP-8: Add shadow_mode passthrough to bridge

9. Compatibility and Versioning

AEGIS SDK Stability Guarantees

The aegis_governance public API (everything in __all__ of src/aegis_governance/__init__.py) follows semantic versioning:

  • PATCH (1.0.x): Bug fixes, no API changes. AgoraIV bridge SHOULD upgrade without changes.
  • MINOR (1.x.0): New features, backward-compatible. AgoraIV bridge MAY need updates to use new capabilities.
  • MAJOR (x.0.0): Breaking changes. AgoraIV bridge MUST be updated.

Frozen Parameters

Gate threshold values in schema/interface-contract.yaml are frozen at guardrail-v1.1-freeze. These values MUST NOT change without formal recalibration approval. AgoraIV MAY rely on these values being stable across AEGIS patch and minor versions.

If AgoraIV's fallback mode hardcodes threshold values, those values MUST match the frozen parameters:

ParameterFrozen Value
complexity_floor0.5
quality_min_score0.7
trigger_confidence_prob0.95
risk_trigger_factor2.0
novelty_threshold0.6
utility_threshold (theta)0.0

10. Contact and Ownership

DomainOwnerScope
AEGIS SDK interface (aegis_governance package)AEGIS teamGateEvaluator, AuditMiddleware, pcw_decide, AegisConfig
AEGIS frozen parametersAEGIS Risk Leadschema/interface-contract.yaml
AgoraIV bridge (aegis_bridge/)AgoraIV teamResearchToAegisMapper, fallback logic, GateType mapping
AgoraIV decision engineAgoraIV teamGate result routing, mandatory/advisory classification
Integration contract (this document)AEGIS teamKept in sync with AEGIS SDK changes

Escalation path: Changes to the AEGIS SDK public surface that affect AgoraIV MUST be communicated to the AgoraIV team before release. Changes to schema/interface-contract.yaml frozen values require Risk Lead approval per AEGIS governance policy (CLAUDE.md SS 2).


References


Changelog

VersionDateAuthorChanges
1.1.02026-02-26Claude CodeGAPs 1-5 resolved: pip dependency, AuditMiddleware, PROFIT gate, drift detection, 67 contract tests
1.0.02026-02-19Claude CodeInitial integration contract (GAP-7 resolution)

On this page