Cognitive Layer¶
The Cognitive layer is the intelligence center — it handles natural language understanding, memory, learning, self-modification, procedural learning, self-regulation, and the builder/architect pipeline.
Pipeline¶
Natural language goes through:
- Working memory assembles system state (agent health, trust scores, Hebbian weights, capabilities) within a token budget
- Episodic recall finds similar past interactions for context (6-factor composite scoring)
- Workflow cache checks for previously successful DAG patterns (exact match, then fuzzy)
- LLM decomposer converts text into a
TaskDAG— a directed acyclic graph of typed intents with dependencies - Attention manager scores tasks:
urgency x relevance x deadline_factor x dependency_bonus - DAG executor runs independent intents in parallel, respects dependency ordering
Dynamic Intent Discovery¶
Each agent class declares structured IntentDescriptor metadata. The decomposer's system prompt is assembled at runtime from whatever agents are registered. New agent types self-integrate without any configuration changes.
Standing Orders¶
A 4-tier instruction hierarchy composed at call time:
- Federation Constitution — universal, immutable rules
- Ship Standing Orders — per-instance configuration
- Department Protocols — per-department standards
- Agent Standing Orders — per-agent, evolvable through self-mod
compose_instructions() assembles the complete system prompt for each CognitiveAgent.decide() call.
Self-Modification¶
When ProbOS encounters a capability gap (no agent can handle a request), it designs a new agent:
Capability gap detected
→ LLM generates agent code
→ CodeValidator static analysis
→ SandboxRunner isolation test
→ Probationary trust assigned
→ SystemQA smoke tests
→ BehavioralMonitor tracks post-deployment
Builder Pipeline (Transporter Pattern)¶
Complex builds are decomposed into parallel chunks for concurrent execution:
BuildSpec → BuildBlueprint → ChunkDecomposer (Dematerializer)
→ Parallel Chunk Execution (Matter Stream)
→ ChunkAssembler (Rematerializer)
→ InterfaceValidator (Heisenberg Compensator)
→ Test-Fix Loop → Code Review → Commit Gate
Cognitive JIT / Procedural Learning¶
A 9-stage pipeline (AD-531 through AD-539, 618 tests) that converts LLM-driven task execution into replayable deterministic procedures:
- Episode Clustering — group similar episodes by semantic similarity
- Procedure Extraction — extract deterministic steps from clustered episodes
- Procedure Store — persist compiled procedures with provenance metadata
- Replay Engine — execute procedures without LLM (0 tokens), fall back on failure
- Graduated Compilation — five Dreyfus competency levels (Novice → Expert)
- Trust-Gated Promotion — procedures earn promotion through demonstrated reliability
- Observational Learning — agents learn from watching peers (three Bandura pathways)
- Lifecycle Management — Ebbinghaus decay, archival, ChromaDB dedup, merge
- Gap Detection — identify skill gaps, trigger qualification programs
Dreaming (12-Step Consolidation)¶
During idle periods, the dreaming engine runs a full consolidation cycle:
| Step | Function |
|---|---|
| 1 | Episode replay and clustering |
| 2 | Pattern extraction |
| 3 | Procedure compilation |
| 4 | Trust score recalibration |
| 5 | Hebbian weight adjustment |
| 6 | Workflow cache refresh |
| 7 | Notebook consolidation + cross-agent convergence detection |
| 8 | Pre-warm predictions for likely upcoming requests |
| 9 | Emergence metrics computation (PID-based) |
| 10 | Standing order evolution proposals |
| 11 | Prune dead connections |
| 12 | ACT-R activation decay — unreinforced memories weaken, low-activation episodes pruned |
Dreaming literally strengthens memories — episodes replayed during consolidation record activation events, increasing their recall priority. The same mechanism as sleep replay in neuroscience (Rasch & Born, 2013).
Cognitive Self-Regulation¶
Three-tier model (AD-502 through AD-506):
- Tier 1 (Internal) — Agent self-monitoring: detects repetition, fixation, cognitive decline within each agent's own processing
- Tier 2 (Social) — Peer regulation: cross-agent repetition detection, tier credit system between agents
- Tier 3 (System) — Graduated zone model: GREEN (normal) → AMBER (warning) → RED (intervention) → CRITICAL (cooldown). Automatic escalation with Counselor oversight
The Counselor (Echo) subscribes to trust updates, circuit breaker trips, dream completions, self-monitoring concerns, and peer repetition events. Issues therapeutic interventions, cooldown directives, and wellness sweeps.
Trust Cascade Dampening¶
Three-layer protection against runaway trust collapse (AD-558):
- Progressive dampening — geometric decay (1.0 / 0.75 / 0.5 / 0.25) prevents rapid cascading
- Hard trust floor — 0.05 minimum prevents trust from reaching zero
- Network circuit breaker — triggers when too many agents in too many departments are affected simultaneously
Emergence Metrics¶
Information-theoretic measurement of collaborative intelligence using Partial Information Decomposition (Riedl, 2025). Computed during dream Step 9:
- Pairwise synergy between agent pairs
- Emergence Capacity (median synergy across crew)
- Coordination Balance (synergy x redundancy)
- Groupthink and fragmentation risk detection
- Hebbian-synergy correlation
Correction Feedback Loop¶
Human corrections are the richest learning signal:
- CorrectionDetector identifies when the user is correcting a previous result
- AgentPatcher modifies the responsible agent
- Hot-reload the patched agent
- Auto-retry the original request
- Update trust, Hebbian weights, and episodic memory
Key Source Files¶
| File | Purpose |
|---|---|
cognitive/cognitive_agent.py |
Instructions-first LLM agent base |
cognitive/decomposer.py |
NL → TaskDAG + DAG executor |
cognitive/episodic.py |
Episodic memory with Anchor Frames |
cognitive/dreaming.py |
12-step dream consolidation |
cognitive/standing_orders.py |
4-tier instruction composition |
cognitive/trust_dampening.py |
Trust cascade dampening |
cognitive/emergence_metrics.py |
PID-based emergence measurement |
cognitive/self_regulation.py |
3-tier cognitive self-regulation |
cognitive/qualification_tests.py |
Cognitive qualification probes |
cognitive/architect.py |
ArchitectAgent (Meridian) |
cognitive/builder.py |
BuilderAgent (Transporter Pattern) |
cognitive/counselor.py |
CounselorAgent (Echo) |
cognitive_jit/ |
Procedural Learning pipeline (9 modules) |