flowchart TD
U([User]) --> DASH
U([User]) --> TGW
subgraph EDGE["Client edge — where the user is · channels are thin doors (HR12)"]
direction TB
DASH["Dashboard · web client (Next.js)<br/>chat UI · approval queues · SSE render"]
TGW["Telegram dispatcher<br/>webhook · thin transport"]
FUTCH["Future channels · WhatsApp · Slack · …<br/>thin transports (HR12)"]
AUTH["Auth / session · next-auth<br/>owner identity · per-owner scope (RLS)"]
DASH --> AUTH
TGW --> AUTH
FUTCH --> AUTH
end
AUTH -->|POST /v1/chat/send| BRAIN["One brain<br/>process_account_turn<br/><i>channels are thin transports — no brain</i>"]
subgraph ROUTERP["Router / planner · LLM tool-router — SELECTS over the registry (not pattern-matching)"]
direction TB
RPSHORT["shortlist candidates · BM25 over usage_examples → small candidate menu"]
RPLLM["Router LLM · DeepSeek Flash → strict JSON {tool, action, args} or none"]
RPARGS["structured args · ADR 0142 CaMeL · write-target id from server opaque ids, not the model"]
RPTIER["tier · TIER_BY_TOOL_ACTION → ALLOWLIST auto / CONFIRMATION propose / ADR-0153 instant"]
RPSHORT --> RPLLM --> RPARGS --> RPTIER
end
REG2[("Tool registry · 15 ToolSpecs · CAPABILITY GROUND TRUTH · [A]=allowlist · [C]=confirmation · web_search: search [A] · browser_agent: run [A] · self_code_read: read/list/search/worktrees [A] · weather: get_current_today [A] · contact: dossier [A] · todo: list/add/start/done/drop/update [C] · node_control: list/show/local [C] · google_gmail: list/read/send/trash/untrash/archive/mark_read/mark_unread/star/unstar/label_add/label_remove [C] · google_calendar: list/get/create/update/cancel_event [C] · google_tasks: list/insert/update/delete/sync [C] · google_drive: list/read/get/trash/move/rename/copy/create_folder [C] · pdf: render/from_content/from_url [C] · reminder: create/list/cancel/snooze [C] · browser_task: create/list/cancel [C] · worker_exec: exec [C]")]
CAP2["⚠ capability self-description · capabilities.py + capability_truth<br/>SEPARATE source · drifts from registry → false denials ('no reminder tool')"]
BRAIN --> RPSHORT
REG2 -->|candidate menu = the registry| RPSHORT
REG2 -.ground truth ≠ self-description.-> CAP2
CAP2 -.when it drifts.-> RBUG["false denial · 'no reminder tool' / 'I only have a todo list'"]
style RBUG fill:#fdecec,stroke:#e5484d,stroke-width:1px,color:#9b1c1c
RPTIER --> RDEC{"ToolPlan"}
RDEC -->|needs a tool| GOV
RDEC -->|answer / clarify| ASM["Recall +<br/>assemble context"]
subgraph GOV["Governance gate · authz/govern() — runs before any tool · fail-closed · server-built capability (confused-deputy guard) · observe by default, enforce-capable"]
direction LR
GCAP["required_capability_for(tool, action)<br/>server-built · never from the LLM"]
GTIER["Tool risk-tier · planner.risk_tiers<br/>ALLOWLIST ·or· CONFIRMATION · safe-delete → trash"]
GCAPS["capabilities_for(owner)<br/>granted capability set"]
GRSEC["Risk: secret-pattern scan<br/>15 patterns"]
GRPII["Risk: PII scan<br/>6 patterns · heavy at high/critical"]
GRSIDE["Risk: side-effect level<br/>read · write · irreversible"]
GREG["Risk: egress required?"]
GRBAND["Risk band<br/>low · medium · high · critical"]
GPOL["Policy decision point · fail-closed precedence<br/>unmapped → missing-cap → secrets/critical →<br/>high/irreversible → allow(low/med + cap) → unknown ⇒ escalate"]
GDLP["DLP scan + fail-safe tighten<br/>outbound secrets / PII · only tightens allow→escalate"]
GEGR["Egress / SSRF guard<br/>scheme · host · IP · allowlist"]
GCHN["Chain limiter<br/>calls · bytes · cross-owner"]
GSIGN["RS256 sign event hash"]
GAUD[("Hash-chained audit<br/>genesis → append → verify_chain")]
GLOG[("governance_decisions log<br/>shadow + enforce")]
GMODE{"Enforcement mode<br/>shadow ·or· enforce · read-gate"}
GCAP --> GTIER --> GCAPS --> GRSEC --> GRPII --> GRSIDE --> GREG --> GRBAND --> GPOL --> GDLP --> GEGR --> GCHN --> GSIGN --> GAUD --> GLOG --> GMODE
end
subgraph APPROVAL["Operator approval — action held until cleared"]
direction TB
AWTOK["Write-action chip / token · LIVE<br/>gates Gmail · Drive · Calendar writes"]
ATG["Telegram operator approval"]
AQ["govern() escalate → queue · planned"]
end
GOV -->|gate verdict · shadow = observe · enforce = apply| GDEC{"allow · deny · escalate"}
GDEC -->|allow| TDISP
GDEC -->|deny| BLK["Blocked<br/>policy / DLP / egress message"]
GDEC -->|escalate| APPROVAL
APPROVAL -->|approved| TDISP
APPROVAL -->|denied| BLK
BLK -.blocked reply.-> ASM
subgraph TOOLS["Tools — invoked once governance allows · 15 tools"]
direction TB
TDISP["Tool dispatch"]
subgraph TG1["Google Workspace"]
direction TB
TGM["Gmail<br/>list · read · send · trash · untrash<br/>archive · mark · star · label"]
TGC["Calendar<br/>list · get · create · update · cancel"]
TGT["Tasks<br/>list · insert · update · delete · sync"]
TGD["Drive<br/>list · read · trash · move<br/>rename · copy · create_folder"]
end
subgraph TG2["Web & browser"]
direction TB
TWS["Web search"]
TBA["Browser agent · run"]
TBT["Browser task<br/>create · list · cancel"]
end
subgraph TG3["Scheduling & notes"]
direction TB
TTD["Todo<br/>list · add · start · done · drop · update"]
TRM["Reminder<br/>create · list · cancel · snooze"]
end
subgraph TG4["Docs & info"]
direction TB
TPDF["PDF<br/>render · from_content · from_url"]
TWX["Weather · current today"]
TCON["Contact · dossier"]
end
subgraph TG5["System / self"]
direction TB
TSCR["Self-code read<br/>read · list · search · worktrees"]
TND["Node control<br/>list · show · local"]
TWE["Worker exec · exec"]
end
TDISP --> TGM
TGM ~~~ TGC ~~~ TGT ~~~ TGD ~~~ TWS ~~~ TBA ~~~ TBT ~~~ TTD ~~~ TRM ~~~ TPDF ~~~ TWX ~~~ TCON ~~~ TSCR ~~~ TND ~~~ TWE
end
TDISP -->|result| ASM
ASM --> LLM["Main chat LLM<br/>DeepSeek"]
LLM -->|model call · via| LLMPROXY[("LLM observability proxy<br/>logs tokens · cost · latency · OpenAI-compatible<br/>main · planner · embeddings · Morpheus all route here")]
LLMPROXY -->|provider API| PDSPRO["DeepSeek Pro<br/>main chat reply"]
LLMPROXY -->|provider API| PDSFLA["DeepSeek Flash<br/>planner / tool router"]
LLMPROXY -->|provider API| POAI["OpenAI<br/>embeddings"]
LLM --> PIPE["Reply pipeline<br/>format · persist"]
PIPE -->|publish stream events| REDIS[("Redis · stream fanout (pub/sub)<br/>per-conversation streams · SSE endpoints subscribe<br/>token + event bus across processes")]
REDIS -->|subscribe / fan out| SSE[/"Stream back (SSE)"/]
SSE --> OUT([Reply rendered in Dashboard / channel])
subgraph MEMLINK["Memlink — durable memory store · inside"]
direction TB
subgraph WRITE["Ingest path · write"]
direction TB
WIN["POST /ingest"]
WRAW["Store raw event<br/>append-only"]
WFAST["Fast-lane derive · sync<br/>fact · entity · relation candidates · dedupe"]
WPERS["Persist + provenance"]
WJOB["Enqueue async jobs<br/>derive · embed"]
WDERV["Derivation worker<br/>polls jobs · LLM extraction"]
WEMB["Embed worker<br/>OpenAI text-embedding-3 → vectors"]
WIN --> WRAW --> WFAST --> WPERS --> WJOB --> WDERV --> WEMB
end
subgraph READ["Retrieve path · read"]
direction TB
RIN["POST /retrieve"]
RROUTE["Retrieval router<br/>classify query → route"]
RSEARCH["Hybrid search<br/>lexical FTS + semantic vector + PPR graph walk"]
RFUSE["RRF fusion"]
RRANK["Ranker · 7-signal blend<br/>lexical · semantic · recency · importance<br/>provenance · kind · subkind"]
RRERANK["Reranker<br/>embedding cosine ·or· null"]
RTRUST["Trust-grade render<br/>structured beats raw"]
RHYD["Hydrate + assemble<br/>+ provenance chains"]
ROUT["Support bundle<br/>objects · provenance"]
RIN --> RROUTE --> RSEARCH --> RFUSE --> RRANK --> RRERANK --> RTRUST --> RHYD --> ROUT
end
subgraph STORE["Postgres + pgvector · ONE database · multiple schemas"]
direction TB
subgraph SWO["world.* — memory graph · 27 tables"]
direction TB
TEV[("events_raw")]
TFACT[("facts")]
TENT[("entities")]
TREL[("relations · bitemporal")]
TEPI[("episodes")]
TCON[("consolidations")]
TEMB[("object_embeddings · HNSW")]
TPROV[("object_provenance")]
TJOB[("asc_jobs queue")]
TEV ~~~ TFACT ~~~ TENT ~~~ TREL ~~~ TEPI ~~~ TCON ~~~ TEMB ~~~ TPROV ~~~ TJOB
end
subgraph SST["steelmoth.* — AGENT / runtime · 57 tables"]
direction TB
A1[("chat_turns · stream_events · reasoning · hints · affordances · memlink_links")]
A2[("agent_self_events")]
A3[("living_documents + revisions")]
A4[("morpheus_memories · morpheus_run_audit")]
A5[("governance_decisions · settings_audit · write_action_audit · write_approval_tokens · runtime_context_audit")]
A6[("mail_* · messages · threads · folders · flags · labels · send_intents · approval_grants · audit")]
A7[("clients · access_requests · provisioning_jobs · teardown_jobs · pool_slots · agreements")]
A8[("provider_accounts · provider_grants · mail_accounts")]
A9[("channel_bindings · telegram_* routes / idempotency / nonces")]
A10[("llm_usage_event · notification_outbox · skills · attachments · sidecar_runs · user_settings_profile")]
A1 ~~~ A2 ~~~ A3 ~~~ A4 ~~~ A5 ~~~ A6 ~~~ A7 ~~~ A8 ~~~ A9 ~~~ A10
end
subgraph SCO["core.* — identity / infra · 11 tables"]
direction TB
C1[("owner_identity")]
C2[("lane_policy")]
C3[("browser_client + context + blob")]
C4[("telegram_dashboard_connection · operator_link")]
C5[("vault_lookup_audit")]
C6[("terminal_runs · terminal_bridge_state")]
C7[("eval_goldens")]
C1 ~~~ C2 ~~~ C3 ~~~ C4 ~~~ C5 ~~~ C6 ~~~ C7
end
subgraph SOA["operator_authority.* — agent authority · 7 tables"]
direction TB
O1[("scope_manifests")]
O2[("approval_requests · task_plans")]
O3[("sessions · settings · projector_health")]
O4[("violations")]
O1 ~~~ O2 ~~~ O3 ~~~ O4
end
subgraph SMO["moth.* — legacy"]
direction TB
MO1[("legacy · reminders · google identity")]
end
end
WRAW --> TEV
WPERS -->|facts · entities · relations · provenance| TFACT
WJOB --> TJOB
WEMB --> TEMB
RSEARCH -.reads.-> TEMB
RHYD -.hydrate.-> TFACT
end
BRAIN -->|ingest message| WIN
PIPE -.persist reply.-> WIN
ASM -->|query| RIN
ROUT -->|context| ASM
subgraph MORPH["Autonomous subsystem · background · off the live chat path · TWO independent pipelines (separate triggers)"]
direction TB
subgraph MDREAM["① Luna · self-memory consolidation — runs inside Memlink"]
direction TB
MDTRIG["Trigger · LUNA_AUTO · on-start · every N turns · interval · or POST /v1/morpheus/consolidate · luna_run_in_flight lock"]
MDQ["Quota gate · count today's runs · budget exhausted ⇒ skip"]
MD1["Read self-events + prior living-doc revision"]
MD2["LLM consolidate · Anthropic · INV-022 preamble · cap 8000"]
MDF["deterministic fallback · _build_luna_document · if LLM absent/fails"]
MD3["Write living document + revision"]
MD4["Audit row · morpheus_run_audit · = what the quota gate counts"]
MDA1["arm · SAGE reinforce → relations · gated off"]
MDA2["arm · self-heal · reconcile facts · gated off"]
MDA3["arm · anomaly scan · read-only · default on"]
MDTRIG --> MDQ --> MD1 --> MD2 --> MD3 --> MD4
MD2 -.fails.-> MDF --> MD3
MD4 --> MDA1
MD4 --> MDA2
MD4 --> MDA3
end
subgraph MDRAIN["② Morpheus · coding drain · todo drain — autonomous PRs · state machine"]
direction TB
MCTRIG["Trigger · endless-dreaming daemon · run_cycle ~5s · in API"]
MC1["pending → read #morpheus todos"]
MCP["planning · build_planning_prompt"]
MC2["coding · Codex (gpt-5.5 · xhigh) · branch morpheus/T#-slug · gated writes"]
MCC["critic · opt · iterate"]
MC3["smoke (≤3 retries) + browser screenshot"]
MC4["pre-PR gate · HR11 · runs repo CI scripts"]
MC5["pr-open → Open PR → operator review / merge"]
MCB["blocked ↔ operator reply (Telegram)"]
MCTRIG --> MC1 --> MCP --> MC2 --> MCC --> MC3 --> MC4 --> MC5
MC2 -.blocker.-> MCB
MCB -.reply.-> MC2
end
end
A2 -.self-events.-> MD1
MD3 -.living document.-> A3
MD4 -.audit row.-> A4
MDA1 -.reinforce relations.-> TREL
RESOLVER["Secret resolver · credentials.py<br/>this VPS · per-process cache ≤ 60s<br/>DeepSeek · Google OAuth · OpenAI · GH · Telegram"]
subgraph PRONTERA["Prontera — separate host (Agent Vault) · not on this VPS"]
direction TB
PNGINX["nginx · TLS<br/>prontera.sole-augmented.ts.net/secrets"]
PAUTH["Validate bearer token<br/>+ client-vault binding"]
PBROKER["Agent Vault secret broker<br/>resolve alias → secret · GET-only"]
subgraph PVAULT["Agent Vault — per-vault slots"]
direction TB
VST[("staging vault<br/>shared system secrets<br/>LLM keys · gh tokens · memlink-scope")]
VMK[("client-mark vault<br/>operator Google OAuth refresh")]
VC1[("client vault · slot 1<br/>(empty)")]
VC2[("client vault · slot 2<br/>(empty)")]
VC3[("client vault · slot 3<br/>(empty)")]
VST ~~~ VMK ~~~ VC1 ~~~ VC2 ~~~ VC3
end
PNGINX --> PAUTH --> PBROKER
PBROKER -->|vault per client-vault binding| VST
end
AVTOK{{"Agent Vault session token<br/>mounted /etc/agent-vault"}}
AVTOK -->|bearer token| RESOLVER
LLM -. model key .-> RESOLVER
TDISP -. Google OAuth .-> RESOLVER
MC2 -. GH token .-> RESOLVER
RESOLVER -. "GET alias · Bearer token (tailnet)" .-> PNGINX
PBROKER -. "secret value" .-> RESOLVER
subgraph AGENTAUTH["Agent Authority · Operator-Authority gate (HR11) — governs coding agents' writes, not the chat path"]
direction TB
AAAG["Coding agents<br/>Claude Code · Codex · Morpheus drain"]
AASHIM["Shim / PreToolUse hook<br/>intercepts every write · edit · shell"]
AAGATE{"Operator-Authority gate · gate.py<br/>allow (0) · deny (2) · approval-required"}
AAPOL[("AGENT_POLICY.yaml<br/>canonical policy · protected paths")]
AAMAN[("Scope manifest<br/>per-worktree · allowed_paths · scope tokens")]
AALAND["Landlock<br/>kernel sandbox enforces"]
AAQUEUE["Dashboard approval queue<br/>Phase 8 · operator approves / denies"]
AAVIOL[("Violations log · violations.jsonl<br/>+ post-hoc sweep")]
AAAG --> AASHIM --> AAGATE
AAPOL --> AAGATE
AAMAN --> AAGATE
AAGATE -->|allow| AALAND
AAGATE -->|approval-required| AAQUEUE
AAQUEUE -->|approved| AALAND
AAGATE -->|deny / violation| AAVIOL
end
MC2 -. gated writes .-> AASHIM
MC2 -. state .-> MDS["drain state · run/morpheus-drain-state/T#.json · token ledger · patches"]
MWS["workspace sync · stm-morpheus-workspace-sync · git fetch loop · morpheus_workspace vol"]
MWS -. repo clone .-> MC2
MC5 --> MGH["GitHub · git push + gh pr create → operator review / merge"]
subgraph BROWSER["Browser automation — backend for the browser tools"]
direction TB
BORCH["Browser-pool orchestrator<br/>allocates a session"]
BPOOL["Chromium via docker proxy<br/>Playwright drives · CDP"]
BVNC["noVNC live view"]
BRES["Result · text + screenshot"]
BORCH --> BPOOL --> BVNC
BPOOL --> BRES
end
TBA -. drives .-> BORCH
TBT -. schedules .-> BORCH
subgraph WORKERS["Background workers — act outside a chat turn"]
direction TB
WREM["Reminders daemon<br/>polls due reminders · fires"]
WNOT["Notifications worker<br/>web push · channel delivery"]
WREM --> WNOT
end
STORE -. reads scheduled reminders .-> WREM
WNOT -. deliver .-> OUT
subgraph CONTROL["Control plane · provisioning — multi-tenant"]
direction TB
CPLANE["Control plane<br/>tenant admin · access requests · approvals"]
PROV["Provisioner<br/>new client: workspace + vault slot + dashboard access"]
CPLANE --> PROV
end
PROV -. provisions client vault .-> VC1
style MEMLINK fill:#f4f1ff,stroke:#7c5cff,stroke-width:2px,color:#4a3fb0
style WRITE fill:#eef9f2,stroke:#1f9d63,stroke-width:1.5px,color:#1f9d63
style READ fill:#eef3ff,stroke:#2f6df6,stroke-width:1.5px,color:#2f6df6
style STORE fill:#f4f1ff,stroke:#7c5cff,stroke-width:1.5px,color:#4a3fb0
style SWO fill:#f4f1ff,stroke:#7c5cff,stroke-width:1px,color:#4a3fb0
style SST fill:#f4f1ff,stroke:#7c5cff,stroke-width:1px,color:#4a3fb0
style SCO fill:#f4f1ff,stroke:#7c5cff,stroke-width:1px,color:#4a3fb0
style SOA fill:#f4f1ff,stroke:#7c5cff,stroke-width:1px,color:#4a3fb0
style SMO fill:#f4f1ff,stroke:#7c5cff,stroke-width:1px,color:#4a3fb0
style ROUTERP fill:#eef3ff,stroke:#2f6df6,stroke-width:2px,color:#2f6df6
style GOV fill:#fff7ed,stroke:#c2570c,stroke-width:2px,color:#9a4708
style APPROVAL fill:#fff7ed,stroke:#c2570c,stroke-width:1px,color:#9a4708
style TOOLS fill:#ecfeff,stroke:#0c8ea4,stroke-width:2px,color:#0a6e7e
style TG1 fill:#f4fdff,stroke:#0c8ea4,stroke-width:1px,color:#0a6e7e
style TG2 fill:#f4fdff,stroke:#0c8ea4,stroke-width:1px,color:#0a6e7e
style TG3 fill:#f4fdff,stroke:#0c8ea4,stroke-width:1px,color:#0a6e7e
style TG4 fill:#f4fdff,stroke:#0c8ea4,stroke-width:1px,color:#0a6e7e
style TG5 fill:#f4fdff,stroke:#0c8ea4,stroke-width:1px,color:#0a6e7e
style MORPH fill:#fdf2f8,stroke:#be185d,stroke-width:2px,color:#9d174d
style MDREAM fill:#fdf6fa,stroke:#be185d,stroke-width:1px,color:#9d174d
style MDRAIN fill:#fdf6fa,stroke:#be185d,stroke-width:1px,color:#9d174d
style PRONTERA fill:#f1f5f9,stroke:#475569,stroke-width:2px,color:#334155
style PVAULT fill:#f6f9fc,stroke:#475569,stroke-width:1px,color:#334155
style AGENTAUTH fill:#eef0ff,stroke:#4338ca,stroke-width:2px,color:#3730a3
style EDGE fill:#eff8ff,stroke:#0369a1,stroke-width:2px,color:#075985
style BROWSER fill:#f5f4f2,stroke:#78716c,stroke-width:1.5px,color:#57534e
style WORKERS fill:#f5f4f2,stroke:#78716c,stroke-width:1.5px,color:#57534e
style CONTROL fill:#f5f4f2,stroke:#78716c,stroke-width:1.5px,color:#57534e
classDef mem fill:#ffffff,stroke:#7c5cff,color:#27272a,stroke-width:1px
classDef gov fill:#ffffff,stroke:#c2570c,color:#27272a,stroke-width:1px
classDef blk fill:#fdecec,stroke:#e5484d,color:#9b1c1c,stroke-width:1px
classDef tool fill:#ffffff,stroke:#0c8ea4,color:#27272a,stroke-width:1px
classDef morph fill:#ffffff,stroke:#be185d,color:#27272a,stroke-width:1px
classDef pron fill:#f6f9fc,stroke:#475569,color:#27272a,stroke-width:1px
classDef redis fill:#ffffff,stroke:#b45309,color:#27272a,stroke-width:1px
classDef vacant fill:#f6f9fc,stroke:#475569,color:#9a9aa4,stroke-width:1px,stroke-dasharray:4 4
classDef aa fill:#ffffff,stroke:#4338ca,color:#27272a,stroke-width:1px
classDef cli fill:#ffffff,stroke:#0369a1,color:#27272a,stroke-width:1px
classDef sup fill:#ffffff,stroke:#78716c,color:#27272a,stroke-width:1px
classDef plan fill:#ffffff,stroke:#2f6df6,color:#27272a,stroke-width:1px
class RPSHORT,RPLLM,RPARGS,RPTIER,RDEC plan
class REG2 tool
class CAP2 blk
class WIN,WRAW,WFAST,WPERS,WJOB,WDERV,WEMB,RIN,RROUTE,RSEARCH,RFUSE,RRANK,RRERANK,RTRUST,RHYD,ROUT,TEV,TFACT,TENT,TREL,TEPI,TCON,TEMB,TPROV,TJOB,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,C1,C2,C3,C4,C5,C6,C7,O1,O2,O3,O4,MO1 mem
class GCAP,GTIER,GCAPS,GRSEC,GRPII,GRSIDE,GREG,GRBAND,GPOL,GDLP,GEGR,GCHN,GSIGN,GAUD,GLOG,GMODE,GDEC,AWTOK,ATG,AQ gov
class BLK blk
class TDISP,TGM,TGC,TGT,TGD,TWS,TBA,TBT,TTD,TRM,TPDF,TWX,TCON,TSCR,TND,TWE tool
class MDTRIG,MDQ,MD1,MD2,MDF,MD3,MD4,MDA1,MDA2,MDA3,MCTRIG,MC1,MCP,MC2,MCC,MC3,MC4,MC5,MCB morph
class RESOLVER,AVTOK,PNGINX,PAUTH,PBROKER,VST,VMK pron
class VC1,VC2,VC3 vacant
class REDIS redis
class AAAG,AASHIM,AAGATE,AAPOL,AAMAN,AALAND,AAQUEUE,AAVIOL aa
class DASH,TGW,FUTCH,AUTH cli
class LLMPROXY,PDSPRO,PDSFLA,POAI,BORCH,BPOOL,BVNC,BRES,WREM,WNOT,CPLANE,PROV,MDS,MWS,MGH sup