SDS-028: MECE Quadrant Integration Service

Status: Draft
Version: 1.0
Date: 2025-12-30
Satisfies: PRD-005, ADR-025
Bounded-Context: shared


0. Isomorphism Declaration

Spec Section SEA-DSL Target Cardinality Verification
2.1 Dependency Graph Flow definition 1:1 Stage names match
3.1 Execute Pipeline Aggregate root 1:1 Method signatures match
4.1 Event Bus Event definitions 1:1 Event names + payload match
4.2 Circuit Breakers Policy nodes 1:1 Threshold expressions match
5. API Contract Flow @command/@query 1:1 Input/output schema identical
6. Configuration Entity schema 1:1 Field names + types match

0.1 Domain Glossary

Term Definition Type Canonical?
IntegrationService Orchestrator coordinating all four MECE quadrant components Service
ExecutionResult Outcome of intention processing (SUCCESS, FAILED, DEFERRED, REJECTED) Entity
Autopoietic Cycle Self-maintaining loop that continuously improves the system Algorithm
Quality Gate Pipeline stage that must pass before proceeding Concept
Circuit Breaker Fault tolerance mechanism preventing cascade failures Pattern
Human Approval Sovereign signature required for EXISTENTIAL tier actions Process
Component Health Per-quadrant status (GREEN, YELLOW, RED, BLACK) Value Object

1. System Overview

The MECE Quadrant Integration Service orchestrates the four core components of the Cognitive Architecture:

Component Service Interface
Soul Axiological Constitution /axiological/*
Mind Isomorphic Compiler /compiler/*
Will Evolutionary Kernel /kernel/*
Body Thermodynamic Substrate /substrate/*

This service ensures Autopoiesis—the continuous self-reproduction and self-maintenance of the system through component interaction.


2. Integration Architecture

2.1 Component Dependency Graph

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
                    ┌─────────────────────┐
                    │   INTENTION (I)     │
                    └──────────┬──────────┘
                               │
                               ▼
          ┌────────────────────────────────────────┐
          │         INTEGRATION SERVICE            │
          │                                        │
          │  ┌──────────────────────────────────┐  │
          │  │     1. FEASIBILITY CHECK         │  │
          │  │     (Thermodynamic Substrate)    │  │
          │  └──────────────┬───────────────────┘  │
          │                 │ Can Afford?          │
          │                 ▼                      │
          │  ┌──────────────────────────────────┐  │
          │  │     2. VALUE EVALUATION          │  │
          │  │     (Axiological Constitution)   │  │
          │  └──────────────┬───────────────────┘  │
          │                 │ Worth Doing?         │
          │                 ▼                      │
          │  ┌──────────────────────────────────┐  │
          │  │     3. COMPILATION               │  │
          │  │     (Isomorphic Compiler)        │  │
          │  └──────────────┬───────────────────┘  │
          │                 │ Success/Failure      │
          │                 ▼                      │
          │  ┌──────────────────────────────────┐  │
          │  │     4. LEARNING                  │  │
          │  │     (Evolutionary Kernel)        │  │
          │  └──────────────────────────────────┘  │
          └────────────────────────────────────────┘
                               │
                               ▼
                    ┌─────────────────────┐
                    │    ARTIFACT (A)     │
                    └─────────────────────┘

2.2 Data Flow

sequenceDiagram
    participant Client
    participant Integration as Integration Service
    participant Substrate as Thermodynamic Substrate
    participant Nexus as Axiological Constitution
    participant Compiler as Isomorphic Compiler
    participant Kernel as Evolutionary Kernel

    Client->>Integration: Submit Intention

    Integration->>Substrate: Check Feasibility
    alt Not Feasible
        Substrate-->>Integration: REJECTED (capacity)
        Integration-->>Client: Error: Insufficient Resources
    else Feasible
        Substrate-->>Integration: OK (estimated cost)
    end

    Integration->>Nexus: Evaluate Value
    alt Low Value (Tier 3 Noise)
        Nexus-->>Integration: REJECTED (noise)
        Integration-->>Client: Error: Below Threshold
    else Worth Doing
        Nexus-->>Integration: APPROVED (tier, budget)
    end

    Integration->>Compiler: Compile Intention
    alt Compilation Success
        Compiler-->>Integration: Artifact
        Integration->>Substrate: Consume Resources
        Integration-->>Client: Success: Artifact
    else Compilation Failure
        Compiler-->>Integration: Error
        Integration->>Kernel: Report Trauma
        Kernel-->>Integration: Mutation Proposal
        Integration-->>Client: Error + Evolution Proposal
    end

3. Core Operations

3.1 Execute Intention (Full Pipeline)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
class IntegrationService:
    def __init__(
        self,
        substrate: ThermodynamicSubstrate,
        nexus: AxiologicalConstitution,
        compiler: IsomorphicCompiler,
        kernel: EvolutionaryKernel
    ):
        self.substrate = substrate
        self.nexus = nexus
        self.compiler = compiler
        self.kernel = kernel

    async def execute(self, intention: Intention) -> ExecutionResult:
        """
        Full MECE Quadrant execution pipeline.
        """
        # 1. BODY: Check thermodynamic feasibility
        estimated_cost = self.compiler.estimate_cost(intention)
        feasibility = await self.substrate.check_feasibility(estimated_cost)

        if not feasibility.is_feasible:
            return ExecutionResult.REJECTED(
                reason="THERMODYNAMIC_CONSTRAINT",
                deficit=feasibility.deficit
            )

        # 2. SOUL: Evaluate axiological value
        evaluation = await self.nexus.evaluate(intention, estimated_cost)

        if evaluation.tier == Tier.NOISE:
            return ExecutionResult.REJECTED(
                reason="BELOW_VALUE_THRESHOLD",
                value_score=evaluation.value_score
            )

        if evaluation.tier == Tier.EXISTENTIAL and not intention.has_human_signature:
            return ExecutionResult.DEFERRED(
                reason="REQUIRES_HUMAN_APPROVAL",
                tier=evaluation.tier
            )

        # 3. MIND: Compile intention to artifact
        try:
            artifact = await self.compiler.compile(
                intention,
                attention_budget=evaluation.attention_budget
            )

            # Consume resources on success
            actual_cost = artifact.provenance.cost
            await self.substrate.consume(actual_cost)

            return ExecutionResult.SUCCESS(artifact=artifact)

        except CompilationError as e:
            # 4. WILL: Report trauma and trigger evolution
            trauma = TraumaSignal(
                source_intention=intention,
                error=str(e),
                magnitude=self._calculate_trauma_magnitude(e)
            )

            mutation_proposal = await self.kernel.process_trauma(trauma)

            return ExecutionResult.FAILED(
                error=str(e),
                mutation_proposal=mutation_proposal
            )

3.2 Autopoietic Loop

The system continuously improves itself through the feedback loop:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
async def autopoietic_cycle(self):
    """
    The self-maintaining loop that keeps the system evolving.
    """
    while True:
        # Gather telemetry
        substrate_status = await self.substrate.get_status()
        trauma_backlog = await self.kernel.get_pending_traumas()
        stale_specs = await self.compiler.detect_stale_specs()

        # Process pending traumas
        for trauma in trauma_backlog:
            mutation = await self.kernel.generate_mutation(trauma)

            # Evaluate mutation against values
            mutation_value = await self.nexus.evaluate_mutation(mutation)

            if mutation_value.approved:
                if mutation.is_minor:
                    # Auto-apply minor mutations
                    await self.compiler.apply_mutation(mutation)
                else:
                    # Queue major mutations for human review
                    await self.queue_for_review(mutation)

        # Check substrate health
        if substrate_status.health == Health.CRITICAL:
            await self.kernel.trigger_lean_mutations()

        # Sleep before next cycle
        await asyncio.sleep(AUTOPOIETIC_INTERVAL)

4. Inter-Service Communication

4.1 Event Bus

All components communicate via a shared event bus:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
events:
  # Axiological Events
  - name: 'ValueEvaluated'
    payload:
      intention_id: string
      value_score: float
      tier: enum[EXISTENTIAL, OPERATIONAL, NOISE]

  # Compiler Events
  - name: 'ArtifactReified'
    payload:
      artifact_id: string
      intention_id: string
      cost: ResourceCost

  - name: 'CompilationFailed'
    payload:
      intention_id: string
      error: string

  # Evolutionary Events
  - name: 'TraumaDetected'
    payload:
      trauma_id: string
      magnitude: float
      source: string

  - name: 'MutationProposed'
    payload:
      mutation_id: string
      predicted_value: float
      requires_approval: bool

  # Thermodynamic Events
  - name: 'ResourcesConsumed'
    payload:
      artifact_id: string
      cost: ResourceCost

  - name: 'CapacityAlert'
    payload:
      level: enum[YELLOW, RED, BLACK]
      component: string

4.2 Circuit Breakers

Each integration point has circuit breakers to prevent cascade failures:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
CIRCUIT_BREAKER_CONFIG = {
    "substrate": {
        "failure_threshold": 3,
        "recovery_timeout": 30,
        "fallback": lambda: FeasibilityResult(is_feasible=False, reason="SUBSTRATE_UNAVAILABLE")
    },
    "nexus": {
        "failure_threshold": 5,
        "recovery_timeout": 60,
        "fallback": lambda: ValueEvaluation(tier=Tier.OPERATIONAL)  # Conservative default
    },
    "compiler": {
        "failure_threshold": 3,
        "recovery_timeout": 120,
        "fallback": None  # No fallback; must succeed or fail explicitly
    },
    "kernel": {
        "failure_threshold": 10,
        "recovery_timeout": 300,
        "fallback": lambda: MutationProposal(status="DEFERRED")
    }
}

5. API Contract

5.1 Execute Intention

1
POST /integration/execute

Request:

1
2
3
4
5
6
{
  "intention": "Create a user authentication system with JWT",
  "target_runtime": "ENGINEERING",
  "priority": "HIGH",
  "human_signature": "base64-encoded-signature"
}

Response (Success):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
{
  "status": "SUCCESS",
  "artifact": {
    "id": "art-uuid",
    "type": "CODE",
    "content": { ... }
  },
  "metrics": {
    "value_score": 45.2,
    "tier": "EXISTENTIAL",
    "cost_consumed": {
      "compute": 1500,
      "capital": 2.50,
      "attention": 0.5
    }
  }
}

Response (Deferred):

1
2
3
4
5
6
{
  "status": "DEFERRED",
  "reason": "REQUIRES_HUMAN_APPROVAL",
  "tier": "EXISTENTIAL",
  "approval_url": "/integration/approve/{request_id}"
}

Response (Failed):

1
2
3
4
5
6
7
8
9
{
  "status": "FAILED",
  "error": "Schema validation failed: missing required field 'userId'",
  "mutation_proposal": {
    "id": "mut-uuid",
    "vector": "CONCRETIZATION",
    "proposed_change": "Add requirement for userId field in all user-related schemas"
  }
}

5.2 Get System Status

1
GET /integration/status

Response:

1
2
3
4
5
6
7
8
9
10
11
12
{
  "components": {
    "substrate": { "health": "GREEN", "capacity": { ... } },
    "nexus": { "health": "GREEN", "active_tier": "OPERATIONAL" },
    "compiler": { "health": "GREEN", "queue_depth": 3 },
    "kernel": { "health": "YELLOW", "pending_traumas": 5 }
  },
  "autopoietic_cycle": {
    "last_run": "2025-12-22T10:00:00Z",
    "next_run": "2025-12-22T10:05:00Z"
  }
}

5.3 Approve Deferred Request

1
POST /integration/approve/{request_id}

6. Configuration

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
integration:
  autopoietic_interval_seconds: 300

  quality_gates:
    - name: 'thermodynamic_check'
      enabled: true
      required: true
    - name: 'axiological_evaluation'
      enabled: true
      required: true
    - name: 'compilation'
      enabled: true
      required: true
    - name: 'evolution_reporting'
      enabled: true
      required: false # Failures don't block success path

  circuit_breakers:
    enabled: true
    global_timeout_ms: 30000

  human_approval:
    required_for_tiers: ['EXISTENTIAL']
    timeout_hours: 24
    escalation_policy: 'notify_sovereign'

7. Observability

7.1 Metrics

Metric Type Description
integration_requests_total Counter Total requests by status
integration_latency_seconds Histogram End-to-end latency
component_health Gauge Per-component health (0/1)
autopoietic_cycles_total Counter Self-maintenance cycles
pending_approvals Gauge Requests awaiting human approval

7.2 Tracing

All requests are traced across components:

1
2
Intention → [substrate:check] → [nexus:evaluate] → [compiler:compile] → [substrate:consume]
                                                 ↘ [kernel:trauma] → [kernel:mutate]

ADRs

PRDs

Other SDS (MECE Quadrant Components)

References