Skip to content

Email ontology · PROPOSED (RFC 0098)

flowchart TD
  NOTE["PROPOSED · design-gate only · RFC 0098 / ADR 0154<br/>no runtime · schema · compose · deploy change shipped"]
  GMAIL["Gmail · source of truth (INV-022)"]
  EXTRACT["Email ingest · email_object_extraction.py<br/>POST /v2/ingest/events (sibling of RFC0097 Phase 5)"]

  subgraph ONT["Email ontology · 4 planes (Palantir-style) — built ON the memlink world-graph"]
    direction TB
    subgraph OBJ["① Objects · typed"]
      direction TB
      OEMAIL["Email / Message"]
      OTHREAD["Thread"]
      OCONTACT["Contact / Person"]
      OSENDER["Sender / Newsletter"]
      OBIZ["Order · Invoice · Booking · Receipt"]
      OEMAIL ~~~ OTHREAD ~~~ OCONTACT ~~~ OSENDER ~~~ OBIZ
    end
    subgraph LNK["② Links · typed relations"]
      direction TB
      LFROM["message —from→ contact"]
      LTHREAD["message —in_thread→ thread"]
      LWORK["contact —works_for→ org"]
      LSUB["contact —subscribed_to→ sender"]
      LFROM ~~~ LTHREAD ~~~ LWORK ~~~ LSUB
    end
    subgraph ACT["③ Actions · governed write-back · ontology_actions.py"]
      direction TB
      AREPLY["reply"]
      ALABEL["label"]
      AARCH["archive"]
      AUNSUB["unsubscribe · composition"]
      AREPLY ~~~ ALABEL ~~~ AARCH ~~~ AUNSUB
    end
    subgraph FUN["④ Functions · computed · ontology_functions/"]
      direction TB
      FSENT["contact_sentiment"]
      FFOLLOW["thread_needs_followup"]
      FDEAD["subscription_is_dead"]
      FSENT ~~~ FFOLLOW ~~~ FDEAD
    end
  end

  subgraph IDR["Identity resolver · confidence ledger (separate · accretive)"]
    direction TB
    LEDGER["confidence-ledger identity<br/>per-evidence · accretive"]
  end

  subgraph FUNNEL["Search funnel · LLM-formed / graph-resolved"]
    direction TB
    QLLM["LLM forms structured query"]
    QPARSE["deterministic parser · guardrail"]
    QGRAPH["graph resolve · ≤2-hop CTE + RRF"]
    QLLM --> QPARSE --> QGRAPH
  end

  subgraph SUB["memlink world-graph substrate · REUSED (no new tables)"]
    direction TB
    SENT[("world.entities · object instances")]
    SREL[("world.relations · links · bitemporal")]
    SFACT[("world.facts · attributes + slot enum")]
    SPROV[("world.object_provenance · evidence")]
    SEMB[("world.object_embeddings")]
    SRAW[("world.events_raw · append-only ingest")]
    SENT ~~~ SREL ~~~ SFACT ~~~ SPROV ~~~ SEMB ~~~ SRAW
  end

  subgraph GATE["EXISTING gated tool plane · REUSE (no new routing)"]
    direction TB
    TIER["risk_tiers.TIER_BY_TOOL_ACTION"]
    DEC["decider_engine.route_via_engine<br/>read / instant-write / proposal gates"]
    TOK["approval chip / single-use token"]
    TIER --> DEC --> TOK
  end

  GMAIL --> EXTRACT --> OEMAIL
  EXTRACT -. local index .-> MAILDB[("DB · steelmoth.mail_* · mail_messages · mail_threads · mail_folders · mail_labels · mail_send_intents · mail_audit_events (Gmail-derived index)")]
  style MAILDB fill:#ffffff,stroke:#7c5cff,stroke-width:1px,color:#27272a
  EXTRACT -.append.-> SRAW
  OEMAIL -.maps to.-> SENT
  LFROM -.maps to.-> SREL
  OEMAIL -.attributes.-> SFACT
  OEMAIL -.evidence.-> SPROV
  LEDGER -.resolves.-> OCONTACT
  LEDGER -.reads evidence.-> SPROV
  QGRAPH -.reads.-> SREL
  QGRAPH -.reads.-> SEMB
  AREPLY -->|tool, action| TIER
  AUNSUB -.composition.-> TIER

  style ONT fill:#f5f1fe,stroke:#7c3aed,stroke-width:2px,color:#7c3aed,stroke-dasharray:6 4
  style OBJ fill:#f5f1fe,stroke:#7c3aed,stroke-width:1px,color:#7c3aed,stroke-dasharray:5 4
  style LNK fill:#f5f1fe,stroke:#7c3aed,stroke-width:1px,color:#7c3aed,stroke-dasharray:5 4
  style ACT fill:#f5f1fe,stroke:#7c3aed,stroke-width:1px,color:#7c3aed,stroke-dasharray:5 4
  style FUN fill:#f5f1fe,stroke:#7c3aed,stroke-width:1px,color:#7c3aed,stroke-dasharray:5 4
  style IDR fill:#f5f1fe,stroke:#7c3aed,stroke-width:1px,color:#7c3aed,stroke-dasharray:5 4
  style FUNNEL fill:#f5f1fe,stroke:#7c3aed,stroke-width:1px,color:#7c3aed,stroke-dasharray:5 4
  style SUB fill:#f4f1ff,stroke:#7c5cff,stroke-width:2px,color:#7c5cff
  style GATE fill:#fff7ed,stroke:#c2570c,stroke-width:2px,color:#c2570c
  classDef ontN fill:#ffffff,stroke:#7c3aed,color:#27272a,stroke-width:1px,stroke-dasharray:5 4
  classDef subN fill:#ffffff,stroke:#7c5cff,color:#27272a,stroke-width:1px
  classDef gtN fill:#ffffff,stroke:#c2570c,color:#27272a,stroke-width:1px
  classDef exN fill:#ffffff,stroke:#475569,color:#27272a,stroke-width:1px
  classDef noteN fill:#f5f1fe,stroke:#7c3aed,color:#7c3aed,stroke-width:2px,stroke-dasharray:6 4
  class OEMAIL,OTHREAD,OCONTACT,OSENDER,OBIZ,LFROM,LTHREAD,LWORK,LSUB,AREPLY,ALABEL,AARCH,AUNSUB,FSENT,FFOLLOW,FDEAD,LEDGER,QLLM,QPARSE,QGRAPH,EXTRACT ontN
  class SENT,SREL,SFACT,SPROV,SEMB,SRAW subN
  class TIER,DEC,TOK gtN
  class GMAIL exN
  class NOTE noteN