Skip to content

M003 — Cognitive Foundation (Consolidated)

Project: XYBEROS AI Platform
Milestone: M003
Status: ✅ Completed
Version: v0.3.0
Date: July 23, 2026


Executive Summary

M003 transforms XYBEROS from a robust execution platform into a true Cognitive AI Platform. This consolidated milestone covers everything built after the Runtime Foundation (M002): the full cognitive pipeline, multi-tier memory, pluggable knowledge, storage and database subsystems, learning, workflow orchestration, and the entry-point ecosystem.

Where M001 delivered the microkernel and M002 delivered the runtime, M003 delivers the brain.


Scope

Phase What was built Status
M003a — Brain/Cognitive Pipeline Perception, Attention, Reasoning (7 strategies), Planning, Decision, Action, Reflection, Language subsystem ✅ Complete
M003b — Memory System 6-tier memory with fallback chain, promotion, TTL, retrieval strategies ✅ Complete
M003c — Knowledge System Knowledge providers, retrieval, fusion, grounding, caching, ranking ✅ Complete
M003d — Storage Subsystem Pluggable storage with in-memory + local filesystem providers, fallback chain ✅ Complete
M003e — Database Subsystem Pluggable database with in-memory + SQLite providers, transactions, migrations ✅ Complete
M003f — Learning System Evaluator, reward function, policy, reinforcement learning, consolidation ✅ Complete
M003g — Workflow Engine DAG execution with topological sort, parallel dispatch, retries ✅ Complete
M003h — Plugin Ecosystem 12 entry-point groups, 54 auto-discovered plugins ✅ Complete
M003i — XYBEROS Facade Unified xyberos singleton with chat, reason, plan, remember ✅ Complete
M003j — E2E Testing 83 end-to-end tests covering kernel→runtime→brain→storage→database→memory ✅ Complete

System at a Glance

Metric Value
Python LOC ~30,388
Python files 580
Package init files 90
Test files 45
Tests passing 1,641
Entry point groups 12
Registered plugins 54
Kernel services 14
Brain subsystems 14
Memory tiers 6
LLM backends 5
Reasoning strategies 7
Perception processors 10
Specialized agents 4

Architecture Layers

                    XYBEROS Platform (v0.3.0)

  ┌─────────────────────────────────────────────────────┐
  │                    XYBEROS Facade                       │
  │          chat()  .  reason()  .  plan()  .  remember │
  └────────────────────────┬────────────────────────────┘
  ┌────────────────────────▼────────────────────────────┐
  │                   Cognitive Brain                    │
  │                                                      │
  │  Perceive → Attend → Reason → Plan → Decide → Act   │
  │               → Reflect → Remember                   │
  │                                                      │
  │  ┌──────┐ ┌──────┐ ┌─────────┐ ┌──────┐ ┌──────┐   │
  │  │Attention│Language│Reasoning│Planning│Decision│   │
  │  └──────┘ └──────┘ └─────────┘ └──────┘ └──────┘   │
  │  ┌──────┐ ┌────────┐ ┌────────┐                     │
  │  │Action│Reflection│Perceiver│                     │
  │  └──────┘ └────────┘ └────────┘                     │
  └────────────────────────┬────────────────────────────┘
  ┌────────────────────────▼────────────────────────────┐
  │       Pluggable Modules (xyberos/ level)                │
  │                                                      │
  │  Processors · Providers · Strategies · Models        │
  │  Knowledge · Embeddings · Tools · Agents · Skills    │
  └────────────────────────┬────────────────────────────┘
  ┌────────────────────────▼────────────────────────────┐
  │             Memory (6-tier fallback chain)           │
  │                                                      │
  │  Working → Episodic → Semantic → Procedural          │
  │              → Vector → Knowledge Graph              │
  └────────────────────────┬────────────────────────────┘
  ┌────────────────────────▼────────────────────────────┐
  │         Storage & Database (pluggable backends)      │
  │                                                      │
  │  Storage:  [In-Memory] ↔ [Local Filesystem]          │
  │  Database: [In-Memory] ↔ [SQLite]                    │
  └────────────────────────┬────────────────────────────┘
  ┌────────────────────────▼────────────────────────────┐
  │             Learning System                          │
  │  Evaluator → Reward → Policy → RL → Consolidation   │
  └────────────────────────┬────────────────────────────┘
  ┌────────────────────────▼────────────────────────────┐
  │               Workflow Engine                        │
  │    DAG Execution with Topological Sort               │
  └────────────────────────┬────────────────────────────┘
  ┌────────────────────────▼────────────────────────────┐
  │         Runtime (Plugins · Modules · Sandbox)        │
  └────────────────────────┬────────────────────────────┘
  ┌────────────────────────▼────────────────────────────┐
  │         Kernel (Services · Container · Lifecycle)    │
  └─────────────────────────────────────────────────────┘

M003a — Brain / Cognitive Pipeline

The cognitive pipeline is the heart of XYBEROS — an 8-stage processing loop that transforms raw input into reasoned, planned, executed, and remembered action.

Perception

10 pluggable processors in xyberos/processors/ running in a deterministic pipeline:

Processor Purpose
Language Detect input language (Lingua, Regex fallback)
Tokenizer Tokenize input into tokens
Entities Extract named entities (Regex)
Keywords Extract keywords (TF-IDF)
Metadata Attach metadata (length, source, timestamp)
Safety Evaluate safety (blocked patterns)
Intent Detect user intent (classifier)
Syntax Parse syntax structure
Semantics Extract semantic meaning
Context Attach contextual information

Attention (xyberos/brain/attention/)

Scoring and selection mechanism that determines which observations deserve focus:

  • AttentionScorer — scores items by relevance
  • AttentionSelector — selects top-K items
  • CognitiveAttention — orchestrates scoring + selection
  • DefaultAttentionScorer, TopKAttentionSelector — built-in implementations

Reasoning

Multi-strategy reasoning engine (xyberos/brain/reasoning/) with 7 pluggable strategies (in xyberos/strategies/):

Strategy Approach
Deductive Forward-chaining rule application
Inductive Frequency-based pattern generalization
Abductive Hypothesis generation
Analogical Analogy-based inference
Probabilistic Probabilistic inference
Fusion Weighted merge of parallel traces
Verification Contradiction detection + confidence check

Deep reasoning pipeline: parallel strategies → fusion → verification → feedback loop.

LLM provider with 5 backends (in xyberos/providers/): OpenAI, Anthropic, Ollama, OpenAI-compatible, Simulated — with automatic fallback.

Planning (xyberos/brain/planning/)

  • CognitivePlanner — strategy-based plan generation
  • PlanExecutor — bridges planning to runtime execution (topological sort via Kahn's algorithm)
  • Strategies: sequential, parallel, conditional (in xyberos/strategies/)

Decision (xyberos/brain/decision/)

  • DecisionEngine — policy-based candidate selection
  • Policies (in xyberos/strategies/): HighestScorePolicy, GreedyPolicy, HybridPolicy, LLMPolicy, RiskAwarePolicy, RuleBasedPolicy, SymbolicPolicy, UtilityPolicy, ConfidencePolicy
  • DecisionCandidate — value + confidence + metadata

Action

  • ActionExecutor (xyberos/brain/action/) — orchestrates action dispatch
  • Pluggable providers (in xyberos/providers/): ShellProvider, PythonProvider, HttpProvider, FilesystemProvider, CompositeActionProvider

Reflection (xyberos/brain/reflection/)

  • Reflector — Critic → Evaluator → Improver pipeline
  • ConsistencyCritic, DefaultCritic — contradiction detection
  • Quality scoring (0.0–1.0), actionable improvement suggestions

Language (xyberos/brain/language/)

  • PromptBuilder, TemplateEngine — structured prompt construction
  • TemplateRegistry, FormatterRegistry, ParserRegistry — pluggable registries
  • Built-in templates: REASONING_TEMPLATE, REFLECTION_TEMPLATE, DECISION_TEMPLATE, PLANNING_TEMPLATE, SUMMARY_TEMPLATE

Cognitive Loop (xyberos/brain/loop/)

DefaultCognitiveLoop.execute() — the complete 8-stage cycle:

  1. Perceive — run perception pipeline (processors in xyberos/processors/)
  2. Attend — score and select relevant memory context
  3. Reason — multi-strategy reasoning with LLM + knowledge injection (strategies in xyberos/strategies/)
  4. Plan — generate structured plan
  5. Decide — select best course from candidates (policies in xyberos/strategies/)
  6. Act — dispatch via ActionExecutor (providers in xyberos/providers/)
  7. Reflect — critique, evaluate, suggest improvements
  8. Remember — persist episodic + semantic, record metrics

Brain (xyberos/brain/brain.py)

Public entry point: Brain.process(observation) runs the full cognitive cycle and returns CognitiveContext with all stage outputs.


M003b — Memory System

6-tier memory with auto-discovery and fallback chain:

Query → Working (fastest)
         ↓ miss
     → Episodic + Semantic (parallel)
         ↓ miss
     → Procedural
         ↓ miss
     → Vector Store
         ↓ miss
     → Knowledge Graph (slowest)
         ↓ hit
     → Promote to Working (for fast future access)
Tier Backend Capacity Purpose
Working WorkingMemoryProvider 1,000 Fast, short-term context
Episodic EpisodicMemoryProvider 10,000 Cycle-level experience storage
Semantic SemanticMemoryProvider 10,000 Extracted facts and knowledge
Procedural ProceduralMemoryProvider Configurable Executable procedures
Vector VectorMemoryProvider Configurable Embedding-based similarity
Knowledge Graph KnowledgeGraphProvider Configurable Node-relationship storage

Retrieval Strategies (xyberos/memory/retrieval/)

Strategy Approach
HybridStrategy Weighted combination of all signals
RecencyStrategy Timestamp-based
FrequencyStrategy Most-accessed
TextSimilarityStrategy Text overlap scoring

Memory Manager

  • MemoryManager — orchestrates all tiers with fallback chain
  • Auto-discovery via entry points (xyberos.memory)
  • Result promotion to working memory
  • Filtering by metadata, TTL expiry, key-based retrieval

M003c — Knowledge System (xyberos/knowledge/)

Pluggable knowledge providers for grounding and retrieval:

Provider Source
MemoryRetrievalKnowledgeProvider Internal memory
MemoryKnowledgeProvider Memory search
WebProvider Web search
FilesystemKnowledgeProvider Filesystem search

Knowledge Pipeline

  • KnowledgeManager — orchestrates all providers
  • GroundingEngine — grounds responses in retrieved knowledge
  • KnowledgeFusion — merges results from multiple sources
  • KnowledgeCache — caches frequent queries
  • KnowledgeRanker, KnowledgeReranker — result scoring
  • Chunker, EmbeddingModel — document processing
  • CitationGenerator — source attribution

M003d — Storage Subsystem

Pluggable storage with fallback chain:

Save  → All providers (redundancy)
Load  → Memory (fastest) → Local Filesystem (fallback)
         → Promote to Memory
Provider Backend
InMemoryStorageProvider Dict-backed, LRU eviction (max 10,000)
LocalFileStorageProvider JSON files on local filesystem

Auto-discovery via xyberos.storage entry points + hardcoded fallback.


M003e — Database Subsystem

Pluggable database with a unified IDatabaseProvider interface:

Provider Type Use case
InMemoryDatabaseProvider Dict-backed Testing, development
SQLiteProvider SQLite file Lightweight persistence

Database Manager

  • Connection lifecycle (connect/disconnect/dispose)
  • Query execution with timing, monitoring, event-bus integration
  • Transaction context manager
  • Schema migration orchestration
  • Connection pooling
  • Event-bus publishing (connect, disconnect, query, transaction, migration events)

Models

  • ConnectionConfig — with factory methods (for_sqlite, for_postgres)
  • Query, QueryResult — typed query/result objects
  • DatabaseStats — runtime statistics
  • Migration — versioned schema changes
  • DatabaseType, IsolationLevel — enumerations

M003f — Learning System

xyberos/brain/learning/ — concrete implementations replacing previous stubs:

Component Purpose
Evaluator Scores action outcomes (0.0–1.0)
RewardFunction Maps outcomes to reward signals
Policy Maps states to action selections
ReinforcementLearner Q-learning and TD updates
Consolidation Aggregates experiences for long-term improvement

M003g — Workflow Engine

xyberos/brain/workflow/ — directed-acyclic graph (DAG) execution:

  • Topological sort via Kahn's algorithm
  • Parallel dispatch of independent tasks
  • Configurable retry policies
  • WorkflowResult with per-task status

M003h — Plugin Ecosystem

12 entry-point groups with 54 auto-discovered plugins:

 xyberos.processors   → 10 perception processors
 xyberos.providers    →  6 perception + action + reasoning providers
 xyberos.memory       →  6 memory tiers
 xyberos.knowledge    →  4 knowledge providers
 xyberos.embeddings   →  1 embedding model
 xyberos.llm_backends →  5 LLM backends
 xyberos.agents       →  4 specialized agents
 xyberos.skills       →  3 built-in skills
 xyberos.strategies   →  7 reasoning + decision strategies
 xyberos.storage      →  2 storage providers
 xyberos.database     →  2 database providers
 xyberos.tools        →  4 pluggable tools

All defined in pyproject.toml [project.entry-points] and discoverable at runtime via importlib.metadata.entry_points().


M003i — XYBEROS Facade

xyberos/assistant.py — unified high-level API (exposes the xyberos singleton):

from xyberos import xyberos

# Full cognitive cycle
ctx = xyberos.chat("What is the weather?")
print(ctx.action.metadata)

# Direct reasoning
conclusion = xyberos.reason("If A > B and B > C, what follows?")

# Direct planning
steps = xyberos.plan("Write a summary of this document")

# Memory query
memories = xyberos.remember("past conversations about weather")

Lazy-initialises all subsystems on first use. Async variants available (achat).


M003j — E2E Testing

83 end-to-end tests in tests/test_e2e_full_workflow.py covering:

Section Tests Coverage
Kernel 8 Service registration, context wiring, lifecycle
Runtime 7 Invocation execution, pipeline, error handling
Brain 12 Full cognitive cycle, guardrails, multi-cycle
Storage 13 Save/load/delete/clear/fallback/TTL
Database 13 Connect/query/transactions/introspection
Memory 10 6-tier fallback, retrieval, filters, expiry
Cross-subsystem 10 Kernel→Runtime→Brain→Storage→Database→Memory
Observability 5 Events, metrics, no-op safety

Total test suite: 1,641 tests — all passing.


Resolved Issues

Two Goal Classes ✅

xyberos.brain.models.goal.Goal now has confidence and trace fields. The cognitive loop (xyberos/brain/loop/cognitive_loop.py) imports and uses the model's Goal directly — no local definition exists.

WorkflowExecutor Return Type ✅

The base interface (xyberos/brain/workflow/interfaces.py) now declares execute() -> WorkflowResult, matching the implementation. WorkflowResult moved to xyberos/brain/workflow/models.py.

Trivial Cleanup

~6 unused imports across the codebase. Low priority.


Looking Ahead — M004 (Developer Platform)

With the cognitive foundation complete, the next milestone shifts from engine capabilities to developer experience:

  • REST API/chat, /reason, /plan, /memory, /storage, /database
  • Python SDK — typed client for local and remote instances
  • Stable public imports — clean from xyberos import ... surface
  • Authentication & middleware
  • Documentation — "Getting Started", "Build Your First AI Assistant"
  • Plugin distribution — packaging and marketplace

Milestone Achievements

Milestone Version Status Tests
M001 — Kernel Foundation v0.1.0 ✅ Completed
M002 — Runtime Foundation v0.2.0 ✅ Completed 653
M003 — Cognitive Foundation v0.3.0 ✅ Completed 1,641
M004 — Developer Platform v0.4.0 🚧 Planned