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-governancepackage) 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 routingRelationship: 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
| Requirement | Value | Notes |
|---|---|---|
| Minimum version | v1.1.0 | aegis-governance package |
| Python compatibility | 3.9+ | Matches AEGIS CI matrix (3.9, 3.10, 3.11, 3.12) |
| Required extras | [engine] | scipy for UtilityCalculator z-score computation |
| Authoritative parameters | schema/interface-contract.yaml | Frozen 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 Gate | Type | Threshold | AgoraIV Mapping | Status |
|---|---|---|---|---|
| RISK | Bayesian posterior | P(delta >= 2 | data) > 0.95 | Mapped to AgoraIV GateType.RISK | Active |
| PROFIT | Bayesian posterior | P(delta >= 2 | data) > 0.95 | Mapped to AgoraIV GateType.PROFIT (advisory) | Active |
| NOVELTY | Logistic function | G(N) >= 0.6 (N0=0.7, k=10) | Mapped to AgoraIV GateType.NOVELTY | Active |
| COMPLEXITY | Hard floor | C_norm >= 0.5 | Mapped to AgoraIV GateType.COMPLEXITY | Active |
| QUALITY | Minimum + no-zero | Q >= 0.7, no zero subscores | Mapped to AgoraIV GateType.QUALITY | Active |
| UTILITY | Lower Confidence Bound | LCB(U) > 0.0 (alpha=0.05) | Mapped to AgoraIV GateType.UTILITY | Active |
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)
| Gate | Condition | Override? | Rationale |
|---|---|---|---|
| COMPLEXITY | complexity_score < 0.5 | No -- HALT is non-overridable | Prevents execution of proposals exceeding complexity bounds. AEGIS enforces this as a hard floor per spec SS 4.1.4. |
| RISK | P(delta >= risk_trigger_factor | data) > 0.95 | Two-key BIP-322 override only | High-confidence evidence of unacceptable risk increase. Bayesian posterior provides calibrated confidence. |
| QUALITY | quality_score < 0.7 OR any subscore is 0.0 | Two-key BIP-322 override only | Ensures minimum quality bar. Zero-subscore rejection prevents single-dimension blind spots. |
Advisory Gates (failure triggers review, not halt)
| Gate | Condition | Effect on AgoraIV | Rationale |
|---|---|---|---|
| NOVELTY | G(N) < 0.6 | Decision engine flags for human review | Low novelty suggests the proposal is insufficiently differentiated. Review required but execution is not blocked. |
| UTILITY | LCB(U) ≤ 0.0 | Decision engine adds risk note | Negative lower confidence bound indicates high uncertainty in expected value. Advisory because the utility model may not be calibrated for all research domains. |
| PROFIT | P(delta >= trigger | data) > 0.95 | Advisory — flags for review | Performance 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 | halt4.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 resultsLimitations of fallback mode:
| Capability | Normal (AEGIS) | Fallback |
|---|---|---|
| Bayesian posterior for risk/profit | Yes | No -- simple threshold comparison |
| Logistic novelty function | Yes | No -- linear threshold |
| LCB utility check | Yes | No -- omitted entirely |
| Posterior probability confidence | Yes | No -- binary pass/fail only |
| Quality subscore zero-check | Yes | No -- aggregate score only |
| Drift detection | Yes | No -- not available |
| Audit trail | Yes (when using AuditMiddleware) | No |
| Parameter freezing | Yes (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
DriftMonitorintegration (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:
| Field | Type | Description |
|---|---|---|
event_id | UUID | Unique identifier for this evaluation |
timestamp | ISO 8601 (UTC) | When the evaluation occurred |
source | string | "agoraiv-bridge" |
agent_id | string | Agent identifier from context |
proposal_summary | string | Proposal description |
gate_results | dict | Per-gate pass/fail with values |
decision_status | string | PROCEED / PAUSE / HALT / ESCALATE |
integrity_hash | string | SHA-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 Parameter | Type | Range | Required | Notes |
|---|---|---|---|---|
risk_baseline | float | 0.0--1.0 | Yes | Current risk before proposed research action |
risk_proposed | float | 0.0--1.0 | Yes | Predicted risk after research action |
profit_baseline | float | any | Yes | Current performance metric |
profit_proposed | float | any | Yes | Expected performance after action |
novelty_score | float | 0.0--1.0 | Yes | Research novelty (higher = more novel) |
complexity_score | float | 0.0--1.0 | Yes | Simplicity margin (higher = simpler) |
quality_score | float | 0.0--1.0 | Yes | Overall research quality |
quality_subscores | float[] | 0.0--1.0 each | No | Per-dimension quality breakdown |
proposal_summary | string | non-empty | Yes | Human-readable description |
estimated_impact | string | low/medium/high/critical | Yes | Blast radius classification |
utility_result | UtilityResult | -- | No | Auto-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
| Responsibility | Verification | Location |
|---|---|---|
| Gate evaluation correctness | 4100+ tests, ~92.0% coverage | tests/ in aegis-governance |
| Bayesian posterior mathematics | Unit tests for BayesianPosterior | tests/test_bayesian.py |
| GateEvaluator API stability | Public API tests | tests/test_gates.py |
| AuditMiddleware behavior | Middleware unit tests | tests/test_middleware.py |
SDK public surface (aegis_governance package) | Import tests | tests/test_init.py |
| Parameter validation (NaN, Inf, bool, type) | Transport parity tests | tests/test_cli.py, tests/test_lambda.py, tests/test_mcp.py |
| Frozen parameter consistency | Schema tests | tests/test_schema_consistency.py |
7.2 AgoraIV Owns
| Responsibility | Verification | Location |
|---|---|---|
ResearchToAegisMapper correctness | Unit tests in AgoraIV | aegis_bridge/tests/ |
| GateType enum mapping | Unit tests in AgoraIV | aegis_bridge/tests/ |
| Decision engine behavior | Integration tests | AgoraIV test suite |
| Fallback logic correctness | Unit tests with AEGIS mocked unavailable | aegis_bridge/tests/ |
| PROFIT gate advisory routing (GAP-3 resolved) | Test that PROFIT is routed as advisory | aegis_bridge/tests/ |
7.3 Shared (Cross-Project)
| Responsibility | Status | Location |
|---|---|---|
| AEGIS API contract tests (GAP-5) | Active | tests/integration/test_agoraiv_contract.py (67 tests) |
| Parameter contract tests | Planned | Validate ResearchToAegisMapper output against interface-contract.yaml |
| Regression suite for bridge upgrades | Planned | Shared 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
| GAP | Title | Severity | Status | Owner | Description |
|---|---|---|---|---|---|
| GAP-1 | sys.path Import Hack | HIGH | Resolved | AEGIS | Replaced with pip install aegis-governance[engine]. Dependency declared in requirements_agora.txt. |
| GAP-2 | No Audit Trail via Bridge | HIGH | Resolved | AgoraIV | Bridge now uses AuditMiddleware.decide() for audit event emission after every gate evaluation. |
| GAP-3 | PROFIT Gate Silently Dropped | MEDIUM | Resolved | AgoraIV | PROFIT gate now mapped to GateType.PROFIT and routed to decision engine as advisory gate. |
| GAP-4 | No Drift Detection in Bridge | MEDIUM | Resolved | AgoraIV | Bridge passes drift_baseline_data via DriftMonitor integration. Bounded deque (maxlen=100) stores evaluation history. |
| GAP-5 | No Cross-Project Integration Tests | MEDIUM | Resolved | Shared | 67 contract tests in tests/integration/test_agoraiv_contract.py verify AEGIS API surface matches AgoraIV expectations. |
| GAP-6 | Fallback Thresholds Hardcoded | LOW | Open | AgoraIV | Fallback mode uses hardcoded thresholds that may drift from interface-contract.yaml frozen values. |
| GAP-7 | Integration Contract Missing | HIGH | Resolved | AEGIS | This document. |
| GAP-8 | No Shadow Mode in Bridge | LOW | Open | AgoraIV | Bridge 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 bridge9. 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:
| Parameter | Frozen Value |
|---|---|
complexity_floor | 0.5 |
quality_min_score | 0.7 |
trigger_confidence_prob | 0.95 |
risk_trigger_factor | 2.0 |
novelty_threshold | 0.6 |
utility_threshold (theta) | 0.0 |
10. Contact and Ownership
| Domain | Owner | Scope |
|---|---|---|
AEGIS SDK interface (aegis_governance package) | AEGIS team | GateEvaluator, AuditMiddleware, pcw_decide, AegisConfig |
| AEGIS frozen parameters | AEGIS Risk Lead | schema/interface-contract.yaml |
AgoraIV bridge (aegis_bridge/) | AgoraIV team | ResearchToAegisMapper, fallback logic, GateType mapping |
| AgoraIV decision engine | AgoraIV team | Gate result routing, mandatory/advisory classification |
| Integration contract (this document) | AEGIS team | Kept 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
- AEGIS Parameter Reference -- Full parameter semantics and derivation guidance
- AEGIS Domain Templates -- Worked integration examples
- Interface Contract -- Frozen parameter values (authoritative)
- AEGIS Middleware -- AuditMiddleware, validation helpers
- Gap Analysis -- Full AEGIS component gap inventory
- Production Guide -- AEGIS deployment and observability
- Unified AEGIS Specification -- Complete system architecture
Changelog
| Version | Date | Author | Changes |
|---|---|---|---|
| 1.1.0 | 2026-02-26 | Claude Code | GAPs 1-5 resolved: pip dependency, AuditMiddleware, PROFIT gate, drift detection, 67 contract tests |
| 1.0.0 | 2026-02-19 | Claude Code | Initial integration contract (GAP-7 resolution) |