βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β
β PERSISTENT SELF-IMPROVING MEMORY FOR MULTI-AGENT LLM SYSTEMS β
β β
β 3-lobe cognitive architecture Β· semantic decay & promotion β
β boot injection Β· closed learning loop Β· fleet signal bus β
β β
β The reasoning core. Every agent runs on top of this. β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Theorex gives AI agents persistent, self-improving memory that survives across sessions β not a chat log, but a live concept graph that decays, promotes, and injects itself into every new session.
WITHOUT β Each session starts blank. Same mistakes. No growth.
WITH β Agent boots with its 50 most relevant concepts pre-injected.
Wins reinforce. Losses write trace_fix concepts.
3am cron runs evolve-review. Session N+1 is smarter than N.
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β CLAUDE CODE SESSION β
β β
β [Hook Dispatcher] ββββββββββββββββββββββββββββββββββββββββββΊ β
β PostToolUse Β· Stop inject at start βββ [SHARED_CONTEXT] β
ββββββββββββββββββββββββ€ββββββββββββββββββββββββββββββββ€βββββββββββββββ
β emitSpan() β boot-inject
βΌ β
ββββββββββββββββββββββββββββββββββββ β
β FLASH LOBE β β
β per-session ring buffer β β
β flush on Stop β Significance β β
ββββββββββββββββββββββββ€ββββββββββββ β
β scored concept events β
βΌ β
ββββββββββββββββββββββββββββββββββββ β
β SIGNIFICANCE ENGINE β β
β β β
β ConceptExtractor β β
β β β β
β ImportanceGate (binary) β β
β β β β
β FrequencyAmplifier (log-norm) β β
β β β β
β CompositeSignal (0.0 β 1.0) β β
ββββββββββββββββββββββββ€ββββββββββββ β
β β
βΌ β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ§βββββββββββββββ
β CONCEPT WEB (Axon) Β· PostgreSQL β
β β
β CrossPollinator Β· activation spreads through edge weights β
β DecayRunner Β· exponential decay on idle nodes β
β TierClassifier Β· ACTIVE (β₯0.6) Β· MILD (β₯0.3) Β· LESS β
β β
β concepts Β· agent_spans Β· flash_events Β· outcomes β
ββββββββββββββββββββββββ€βββββββββββββββββββ€βββββββββββββββββββ€βββββββββ
β β β
ββββββββββΌβββββββ ββββββββββΌβββββββ βββββββββΌβββββββ
β SHORT-TERM β β LONG-TERM β β MCP SERVER β
β BM25 + vector β β axon.json β β :18800 β
β 14-day window β β moment nodes β β JSON-RPC2.0 β
βββββββββββββββββ βββββββββββββββββ ββββββββββββββββ
Claude Code session (tool call)
β
β SpanStore.emitSpan() Β· TokenJuice (~60β80% compression)
βΌ
agent_spans ββ PostgreSQL ββ FTS5-indexed ββ searchable by session
β
β [3am OC cron] theorex evolve-review --agent all
βΌ
concepts ββ enrich_bodies ββ scan ββ promote
β
β theorex boot-inject
β Postgres β semantic grouping β palace structure
βΌ
~/.openclaw/workspace/theorex/SHARED_CONTEXT.md
β
ββββΊ injected at every new session start
Palace structure at inject time:
| Wing | Tier | Score |
|---|---|---|
| π’ Wins | ACTIVE | β₯ 0.6 |
| π΄ Losses | ACTIVE | β₯ 0.6 |
| π‘ Identity | MILD | β₯ 0.3 |
β‘ Flash Lobe β per-session ring buffer
Purpose β presence, not retrieval. "What happened this session?"
Writes β ~/.theorex/flash/{session-id}.jsonl
Trigger β PostToolUse + Stop hooks via Claude Code
Flush β on session Stop β Significance Engine
π Short-Term Lobe β 14-day rolling window
Search β BM25 + vector hybrid (RRF fusion)
Window β 14-day rolling JSONL log
Promotion β qualifying concepts graduate β Long-Term Lobe
BM25 β Postgres FTS5 tsvector (auto-populated generated column)
Vector β nomic-embed-text-v1.5 via LM Studio
𧬠Long-Term Lobe β permanent crystallised knowledge
Storage β axon.json (concept graph with edge weights)
Nodes β Moment nodes β permanent episodic anchors
Decay β exponential, halflife 14 days (configurable)
Promotion β composite score β₯ 0.5
Tiers β ACTIVE β₯ 0.6 | MILD β₯ 0.3 | LESS < 0.3
theorex dispatch(task, {outcome_id})
β
βββ LM_INFERENCE_START (trace_id = preGeneratedUUID)
β
βββ qwen-abliterated :8000 β success / failure
β
βββ LM_INFERENCE_END β EventBus β TraceRecord written
β
βββ patchOutcomeTraceId(outcome_id, trace_id)
β
β [3am OC cron] theorex evolve-review --agent all
βββ reviewOutcomes() + refineFromReport()
βββ reviewAllFailures() β trace_fix concepts written
β
β [OC cron] theorex promote + boot-inject
βββ trace_fix in SHARED_CONTEXT.md Β· half-life = 7 days
Router priority chain:
1 Role registry model_preference wins if query type matches
2 EnergyDispatch pmset battery check Β· largeβmedium below 20%
3 ConfidenceMatrix 0.6 Γ success_rate + 0.4 Γ (1 β latency)
4 HeuristicRouter code Β· math Β· retrieval Β· synthesis Β· creative Β· safety Β· general
Gene registry + GEP directives
bun run src/ge/signal-scanner.ts --source watchdog
bun run src/ge/signal-scanner.ts --source pm2
bun run src/ge/signal-scanner.ts --source theorexββββββββββββββββββββββββββββββββββββββββββββββββββββββββ¬βββββββββββ
β Gene β Priority β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββΌβββββββββββ€
β gene_divergence_win_rate_anomaly β HIGH β
β gene_horizon_outcome_tracking β HIGH β
β gene_singularity_position_cap β CRITICAL β
β gene_hades_turboquant_health_monitor β MEDIUM β
β gene_hades_watchdog_cooldown_race β HIGH β β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ΄βββββββββββ
Every GEP directive written to evolution_events with full audit trail.
JSON-RPC 2.0 on :18800 β full axon read/write/search for any agent or external tool.
theorex mcp-start --port 18800 --agent main| Method | Description |
|---|---|
status |
agent name Β· concept count Β· top ACTIVE |
search |
FTS5 + vector hybrid search |
write |
extract concepts + write to axon |
search_spans |
FTS5 span search across sessions |
boot-inject |
regenerate SHARED_CONTEXT.md |
retrieve_outcomes |
read trade outcomes |
write_trade_outcome |
shadow a trade outcome |
write_learning |
write structured lesson |
get_learnings |
query lessons by agent + context |
ββββββββββββββ¬βββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββ
β OC ID β Schedule β Job β
ββββββββββββββΌβββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββ€
β c6bd399a β 0 */4 * * * β fleet-ge-signal-scan β
β 10fd0f7d β 0 3 * * * β theorex evolve-review (all agents) β
β 4f7a8761 β */5 * * * * β theorex-health-check β
β 66ddb18c β 0 6 * * * β monitor-partitions (daily) β
β 5b65a0c7 β 0 2 * * 0 β security-sweep (weekly) β
ββββββββββββββ΄βββββββββββββββββββ΄βββββββββββββββββββββββββββββββββββββββ
git clone https://github.com/LORD-ZYTHOZ/Theorex
cd Theorex && bun install
theorex write --agent main "TTL invalidation prevents cache stampedes"
theorex search "cache invalidation" --agent main
theorex learn --agent nova --event decision \
--context "direct LAN vs relay" \
--pattern "direct LAN more reliable" \
--outcome positive
theorex evolve-review --agent all
theorex boot-inject --top 50 --depth summary
theorex mcp-start --port 18800 --agent mainRuntime Bun 1.3+
Storage PostgreSQL ββ concepts Β· agent_spans Β· flash_events Β· outcomes
Semantic nomic-embed-text-v1.5 via LM Studio :1234
Full-text Postgres FTS5 + ts_rank
Compression TokenJuice ββ ~60β80% token reduction on stored spans
Vector quant TurboQuant (ICLR 2026) ββ 4320 compressed embeddings
Large LLM Qwen API ββ Qwen Max / Qwen3.5-122B-A10B
Background qwen-abliterated :8000 ββ fire-and-forget inference
Protocol JSON-RPC 2.0 MCP :18800
Scheduling OpenClaw cron (source of truth) Β· PM2 (theorex-scan only)
β οΈ TURBOQUANT_SEED = 42is baked into all 4320 stored TurboCode vectors. Changing it invalidates ALL stored codes and requires a full backfill.
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Memory that earns its keep. Built in Sydney. β
β Self-improving since day one. β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
MIT License Β· Bun Β· TypeScript Β· PostgreSQL
