# Orchestration as Cognition: Workflow Planning as Executive Function

**Series**: AGI Perspectives | **Document**: 6 of 10 | **Last Updated**: March 2026

## The Executive Function Thesis

Cognitive neuroscience distinguishes *primary processes* (perception, memory, motor control) from *executive function* — the meta-cognitive system that coordinates primaries, selects goals, sequences actions, and monitors progress. Baddeley (2003) models this as the "central executive" of working memory; Baars (1988) as the "global workspace" broadcasting information to specialized processors; Dehaene et al. (2014) as "conscious access" through a neuronal global workspace bottleneck.

The mapping to computation is precise. Codomyrmex's `orchestrator` module and its `WorkflowEngine` serve as the system's executive function. This essay traces how DAG-based orchestration maps to formal models of executive cognition and classical planning theory, and what this reveals about the requirements for AGI-level planning.

## Architecture of the Executive

```mermaid
graph TB
    subgraph EXECUTIVE["Executive: Orchestrator / Central Executive"]
        WE["WorkflowEngine<br/><i>DAG: π = (a₁→a₂→...→aₖ)</i>"]
        TS["TaskScheduler<br/><i>priority queue: O(log n)</i>"]
        DG["DependencyGraph<br/><i>topological sort: O(V+E)</i>"]
    end

    subgraph WORKSPACE["Global Workspace: Broadcasting"]
        EVENTS["events/EventBus<br/><i>fanout: |subscribers|</i>"]
        SKILLS["skills/<br/><i>capability index: O(|S|·d)</i>"]
        CEREB["cerebrum/<br/><i>CBR: sim(τ, C_k)</i>"]
    end

    subgraph PHONOLOGICAL["Phonological Loop: Sequential State"]
        AMEM["agentic_memory/<br/><i>session context window</i>"]
        CACHE["cache/<br/><i>hot intermediate results</i>"]
        LOG["logging_monitoring/<br/><i>execution trace</i>"]
    end

    subgraph EFFECTORS["Effectors: Motor Output"]
        AGENTS["agents/<br/><i>13 LLM providers</i>"]
        CODING["coding/<br/><i>code generation</i>"]
        TOOLS["tool_use/<br/><i>600 MCP tools</i>"]
    end

    EXECUTIVE -->|"broadcast"| WORKSPACE
    WORKSPACE -->|"load"| PHONOLOGICAL
    PHONOLOGICAL -->|"invoke"| EFFECTORS
    EFFECTORS -.->|"feedback"| EXECUTIVE
```

### The Global Workspace as Information Integration

Baars' Global Workspace Theory (GWT) proposes that flexible cognition arises from broadcasting information from a shared workspace to specialized processors. Tononi's (2004) **Integrated Information Theory** (IIT) extends this: consciousness (and by extension, flexible cognition) corresponds to *integrated information* — information generated by a system *above and beyond* its parts:

$$\Phi = I(\text{whole}) - \sum_i I(\text{parts}_i)$$

where Φ (phi) measures the integrated information. A system with high Φ processes information as a unified whole rather than as independent channels.

In codomyrmex, the `events/EventBus` implements GWT's broadcasting pattern:

1. An event is published to the bus — information enters the workspace
2. All subscribed handlers receive it — broadcast to specialists (fanout = |subscribers|)
3. The most relevant handler processes it — competition for cognitive access
4. The handler's output is published back — result re-enters the workspace

The EventBus is not a metaphor for GWT — it is a literal implementation of the same computational pattern. The critical difference is *bottleneck*: biological global workspaces have a capacity limit (Dehaene's "conscious bottleneck" of ~7±2 items), while the EventBus broadcasts without bandwidth limitation. This means the `events/` module implements a *superhuman* global workspace — one without Cowan's (2001) capacity limits.

### DAGs as STRIPS Plans

The `WorkflowEngine` executes Directed Acyclic Graphs where nodes are tasks and edges are dependencies. This is equivalent to **STRIPS** (Fikes & Nilsson, 1971) planning: each node specifies preconditions (dependencies must be complete), add-effects (outputs produced), and delete-effects (resources consumed).

Formally, a workflow DAG is a tuple (S, A, s₀, G) where:

- S is the state space (possible system states)
- A is the action set (tool invocations)
- s₀ is the initial state
- G ⊆ S is the goal set

The orchestrator's topological sort computes a *valid plan*: a totally ordered sequence of actions consistent with the partial order defined by dependencies.

**Computational complexity**: DAG execution is O(V + E). But *plan synthesis* (constructing the DAG from a goal description) is PSPACE-complete in general (Bylander, 1994). This is the critical gap: codomyrmex executes pre-defined DAGs efficiently but does not synthesize novel DAGs from goal specifications.

### Skill Selection as Attentional Gating

The `skills` module implements *capability matching* functionally equivalent to attentional gating:

$$\text{attention}(\tau) = \text{softmax}\left(\frac{Q(\tau) \cdot K(\text{skills})^T}{\sqrt{d_k}}\right) \cdot V(\text{skills})$$

where Q is the query (task embedding), K is the key (skill description embeddings), and V is the value (skill implementations). This is literally the attention mechanism from the transformer architecture (Vaswani et al., 2017) applied to capability selection — the system attends to its own skill inventory.

The `cerebrum` module adds *reasoned selection*: case-based reasoning retrieves past episodes where similar tasks were solved, and the stored solutions bias skill selection. This implements what Anderson (1993) calls **production compilation**: frequently co-occurring skill combinations are compiled into single productions (cached DAGs) for faster retrieval.

## The Planning Hierarchy

```mermaid
graph TD
    subgraph RATIONAL["Rational Band (~days)"]
        MISSION["Mission definition<br/><i>utility maximization: argmax U(s)</i>"]
    end

    subgraph COGNITIVE["Cognitive Band (~minutes)"]
        WORKFLOW["Workflow assembly<br/><i>DAG synthesis: STRIPS planning</i>"]
    end

    subgraph NEURAL["Neural Band (~seconds)"]
        SELECTION["Tool selection<br/><i>attention + CBR</i>"]
    end

    subgraph BIOLOGICAL["Biological Band (~ms)"]
        EXECUTION["Tool execution<br/><i>atomic invocation</i>"]
    end

    RATIONAL --> COGNITIVE --> NEURAL --> BIOLOGICAL
    BIOLOGICAL -.->|"reward signal"| NEURAL
    NEURAL -.->|"replanning trigger"| COGNITIVE
    COGNITIVE -.->|"mission revision"| RATIONAL
```

This four-level hierarchy maps to Newell's (1990) **cognitive band hierarchy**:

| Band | Time Scale | Codomyrmex | Cognitive Equivalent |
|:-----|:----------|:-----------|:--------------------|
| **Rational** | seconds–days | Mission decomposition | Deliberative reasoning |
| **Cognitive** | 100ms–seconds | Workflow assembly | Problem solving |
| **Neural** | 10ms–100ms | Tool selection | Pattern recognition |
| **Biological** | µs–10ms | Tool execution | Reflex action |

The feedback loops between bands enable **dynamic replanning**: if a tool call fails (biological → neural), the orchestrator adjusts the DAG (neural → cognitive); if a sub-goal proves infeasible, the strategic planner revises (cognitive → rational).

### Metacognition: Monitoring the Monitor

Norman and Shallice's (1986) Supervisory Attentional System (SAS) model proposes two levels of executive control:

1. **Contention scheduling** — Routine, automatic selection (the DAG executor)
2. **Supervisory attention** — Novel situations requiring deliberate control (replanning)

Codomyrmex's metacognitive monitoring is limited to workflow status tracking — the system knows *whether* a plan is executing correctly but not *why* it might be failing. Missing: a metacognitive layer that evaluates *plan quality* independent of plan execution:

$$\text{metacognition}(\pi) = P(\text{goal achieved} \mid \text{plan } \pi, \text{history}) \cdot U(\text{goal})$$

This would enable the system to *abandon* a plan mid-execution when the probability of success drops below threshold — the computational equivalent of "knowing when to quit."

## Gap Analysis

| Executive Function | Status | Formal Gap |
|:------------------|:-------|:-----------|
| Sequential planning (DAG execution) | ✅ | O(V+E), efficient |
| Goal decomposition | ⚠️ Manual | No automated STRIPS planning |
| Dynamic DAG synthesis | ❌ | PSPACE-complete in general |
| Attentional selection | ✅ | Transformer-style attention |
| Metacognitive monitoring | ⚠️ | No plan-quality estimation |
| Production compilation | ⚠️ | Cached DAGs but no automatic compilation |

## Comparison with Cognitive Architectures

| Feature | **Codomyrmex** | **Soar** (Laird) | **ACT-R** (Anderson) |
|:--------|:--------------|:-----------------|:--------------------|
| Executive structure | WorkflowEngine (DAGs) | Decision cycle | Production system |
| Working memory capacity | Unbounded | Bounded | 7±2 chunks |
| Planning | Static DAGs | Lookahead search | Analogical transfer |
| Metacognition | Status tracking | Meta-level reasoning | Conflict resolution |
| Learning mechanism | CBR + evolutionary | Chunking + RL | Bayesian knowledge tracing |
| Attention mechanism | Transformer-style matching | Operator selection | Activation spreading |
| Broadcasting | EventBus (GWT-like) | No explicit GWT | No explicit GWT |
| **Integrated information (Φ)** | **Medium** (EventBus links all) | **High** (tight coupling) | **Low** (modular) |

The key architectural distinction: Soar and ACT-R are *monolithic* cognitive architectures with tight internal coupling. Codomyrmex is a *distributed* cognitive architecture with loose coupling via the EventBus. The Integrated Information Φ is lower in codomyrmex but scales better — adding a new module doesn't require modifying the architecture, only subscribing to relevant events.

## The Anytime Property

An **anytime algorithm** produces progressively better results as more computation time is available, but can return a valid (partial) result at any interruption point. Well-designed DAG workflows have this property when early nodes produce useful intermediate results.

The practical implication: an agent interrupted mid-workflow still has the outputs of completed nodes. The `orchestrator` should preserve completed node outputs in `agentic_memory` so that resumed execution can continue from the interruption point rather than restarting.

This maps to Zilberstein's (1996) **contract algorithm** framework: an algorithm that guarantees a minimum quality level for any execution time above a threshold. The threshold is the time to complete the first DAG node; the quality improves monotonically with additional nodes completed.

## Cross-References

- **Biological**: [eusociality.md](../bio/eusociality.md) — Division of labor as decentralized executive
- **Cognitive**: [active_inference.md](../cognitive/active_inference.md) — Action selection via EFE minimization
- **Previous**: [alignment_and_safety.md](./alignment_and_safety.md) — Constraints on executive decisions
- **Next**: [memory_and_continuity.md](./memory_and_continuity.md) — Working memory foundations

## References

- Anderson, J. R. (1993). *Rules of the Mind*. Lawrence Erlbaum.
- Baars, B. J. (1988). *A Cognitive Theory of Consciousness*. Cambridge University Press.
- Baddeley, A. (2003). "Working Memory." *Nature Reviews Neuroscience*, 4(10), 829–839.
- Bylander, T. (1994). "The Computational Complexity of STRIPS Planning." *Artificial Intelligence*, 69(1-2), 165–204.
- Cowan, N. (2001). "The Magical Number 4 in Short-Term Memory." *BBS*, 24(1), 87–114.
- Dehaene, S., et al. (2014). "Toward a Computational Theory of Conscious Processing." *Current Opinion in Neurobiology*, 25, 76–84.
- Fikes, R. E., & Nilsson, N. J. (1971). "STRIPS: A New Approach to the Application of Theorem Proving to Problem Solving." *Artificial Intelligence*, 2(3-4), 189–208.
- Newell, A. (1990). *Unified Theories of Cognition*. Harvard University Press.
- Norman, D. A., & Shallice, T. (1986). "Attention to Action." In *Consciousness and Self-Regulation*, Vol. 4. Plenum.
- Tononi, G. (2004). "An Information Integration Theory of Consciousness." *BMC Neuroscience*, 5, 42.
- Vaswani, A., et al. (2017). "Attention Is All You Need." *NeurIPS 2017*.

---

*[← Alignment & Safety](./alignment_and_safety.md) | [Next: Memory & Continuity →](./memory_and_continuity.md)*
