<mxfile host="app.diagrams.net" agent="eli-architecture-docgen" version="24.7.7" pages="25">
<diagram id="p1PlatSimple" name="Platform — System (Simplified)">
  <mxGraphModel dx="800" dy="600" grid="0" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1600" pageHeight="1200" math="0" shadow="0">
    <root>
      <mxCell id="0" />
      <mxCell id="1" parent="0" />
      <mxCell id="p1_title" value="eli — 10-second mental model: two principals, three surfaces, one storage seam, two backends, one AI gateway" style="text;html=1;fontSize=16;fontStyle=1;align=left;verticalAlign=middle;" vertex="1" parent="1">
        <mxGeometry x="40" y="20" width="1100" height="40" as="geometry" />
      </mxCell>
      <mxCell id="p1_usr" value="User&#10;(browser / PWA)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=13;" vertex="1" parent="1">
        <mxGeometry x="40" y="140" width="200" height="70" as="geometry" />
      </mxCell>
      <mxCell id="p1_agt" value="AI agent&#10;(Claude Code, Cursor, Codex, Gemini, OpenClaw)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=13;" vertex="1" parent="1">
        <mxGeometry x="40" y="400" width="200" height="80" as="geometry" />
      </mxCell>
      <mxCell id="p1_ui" value="Next.js UI&#10;app/(local) + app/(saas)&#10;same RSC tree in both modes" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=13;" vertex="1" parent="1">
        <mxGeometry x="360" y="80" width="220" height="80" as="geometry" />
      </mxCell>
      <mxCell id="p1_mcp" value="MCP server&#10;16 tools, stdio + streamable HTTP&#10;lib/mcp/server.ts, bin/eli-mcp.mjs" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=13;" vertex="1" parent="1">
        <mxGeometry x="360" y="300" width="220" height="80" as="geometry" />
      </mxCell>
      <mxCell id="p1_api" value="HTTP APIs&#10;/v1 (OpenAI-compatible), /api/ai/*,&#10;/api/clip, /api/search/hybrid" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=13;" vertex="1" parent="1">
        <mxGeometry x="360" y="520" width="220" height="80" as="geometry" />
      </mxCell>
      <mxCell id="p1_stor" value="StorageAdapter&#10;getStorage() — lib/storage/index.ts&#10;every surface goes through here" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=13;fontStyle=1;" vertex="1" parent="1">
        <mxGeometry x="720" y="290" width="240" height="90" as="geometry" />
      </mxCell>
      <mxCell id="p1_loc" value="Local backend&#10;.md files on disk (source of truth)&#10;+ rebuildable SQLite index&#10;~/.eli/index/&lt;hash&gt;.db" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=13;" vertex="1" parent="1">
        <mxGeometry x="1100" y="180" width="240" height="100" as="geometry" />
      </mxCell>
      <mxCell id="p1_saas" value="SaaS backend&#10;Supabase Postgres + RLS&#10;(tsvector, pgvector, Storage buckets)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=13;" vertex="1" parent="1">
        <mxGeometry x="1100" y="400" width="240" height="90" as="geometry" />
      </mxCell>
      <mxCell id="p1_gw" value="Vercel AI Gateway&#10;tiers: fast / smart / cheap / embed&#10;BYOK key resolver, usage metering" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=13;" vertex="1" parent="1">
        <mxGeometry x="720" y="520" width="240" height="90" as="geometry" />
      </mxCell>
      <mxCell id="p1_e1" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p1_usr" target="p1_ui">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p1_e2" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p1_agt" target="p1_mcp">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p1_e3" value="OpenAI-SDK clients" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p1_agt" target="p1_api">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p1_e4" value="server actions" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p1_ui" target="p1_stor">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p1_e5" value="all 16 tools" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p1_mcp" target="p1_stor">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p1_e6" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p1_api" target="p1_stor">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p1_e7" value="ELI_MODE=local" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p1_stor" target="p1_loc">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p1_e8" value="ELI_MODE=saas" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p1_stor" target="p1_saas">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p1_e9" value="inline AI, chat, digest" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p1_ui" target="p1_gw">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p1_e10" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p1_api" target="p1_gw">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
    </root>
  </mxGraphModel>
</diagram>
<diagram id="p2PlatDetailed" name="Platform — System (Detailed)">
  <mxGraphModel dx="800" dy="600" grid="0" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1600" pageHeight="1200" math="0" shadow="0">
    <root>
      <mxCell id="0" />
      <mxCell id="1" parent="0" />
      <mxCell id="p2_usr" value="User (browser / PWA)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=12;" vertex="1" parent="1">
        <mxGeometry x="150" y="30" width="200" height="50" as="geometry" />
      </mxCell>
      <mxCell id="p2_agt" value="AI agent (Claude Code, Cursor, ...)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=12;" vertex="1" parent="1">
        <mxGeometry x="670" y="30" width="220" height="50" as="geometry" />
      </mxCell>
      <mxCell id="p2_oai" value="Any OpenAI-SDK client (/v1)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=12;" vertex="1" parent="1">
        <mxGeometry x="1170" y="30" width="200" height="50" as="geometry" />
      </mxCell>

      <mxCell id="p2_c2" value="C2 — Authoring and Navigation UX" style="swimlane;startSize=28;rounded=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=13;fontStyle=1;" vertex="1" parent="1">
        <mxGeometry x="40" y="120" width="460" height="300" as="geometry" />
      </mxCell>
      <mxCell id="p2_c2_shell" value="Shell: sidebar, palette, inspector&#10;components/sidebar, command-palette.tsx" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="p2_c2">
        <mxGeometry x="15" y="45" width="210" height="70" as="geometry" />
      </mxCell>
      <mxCell id="p2_c2_editor" value="BlockNote / raw editor&#10;components/editor" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="p2_c2">
        <mxGeometry x="240" y="45" width="205" height="70" as="geometry" />
      </mxCell>
      <mxCell id="p2_c2_act" value="Server actions&#10;app/_actions/*" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="p2_c2">
        <mxGeometry x="15" y="135" width="210" height="70" as="geometry" />
      </mxCell>

      <mxCell id="p2_c5" value="C5 — Agent Surface (MCP)" style="swimlane;startSize=28;rounded=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=13;fontStyle=1;" vertex="1" parent="1">
        <mxGeometry x="540" y="120" width="460" height="300" as="geometry" />
      </mxCell>
      <mxCell id="p2_c5_stdio" value="stdio binary&#10;bin/eli-mcp.mjs (local only)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d6b656;fontSize=11;" vertex="1" parent="p2_c5">
        <mxGeometry x="15" y="45" width="210" height="70" as="geometry" />
      </mxCell>
      <mxCell id="p2_c5_http" value="HTTP transport + PAT auth&#10;app/api/mcp/[transport]/route.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d6b656;fontSize=11;" vertex="1" parent="p2_c5">
        <mxGeometry x="240" y="45" width="205" height="70" as="geometry" />
      </mxCell>
      <mxCell id="p2_c5_tools" value="16-tool registry&#10;lib/mcp/server.ts + lib/mcp/tools/*" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d6b656;fontSize=11;" vertex="1" parent="p2_c5">
        <mxGeometry x="15" y="135" width="210" height="70" as="geometry" />
      </mxCell>

      <mxCell id="p2_c7" value="C8 — Capture and Templating" style="swimlane;startSize=28;rounded=1;fillColor=#b0e3e2;strokeColor=#0e8088;fontSize=13;fontStyle=1;" vertex="1" parent="1">
        <mxGeometry x="1040" y="120" width="460" height="300" as="geometry" />
      </mxCell>
      <mxCell id="p2_c7_clip" value="Clip handler + bookmarklet&#10;lib/clipper, app/api/clip" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#0e8088;fontSize=11;" vertex="1" parent="p2_c7">
        <mxGeometry x="15" y="45" width="210" height="70" as="geometry" />
      </mxCell>
      <mxCell id="p2_c7_tpl" value="Template engine&#10;lib/templates" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#0e8088;fontSize=11;" vertex="1" parent="p2_c7">
        <mxGeometry x="240" y="45" width="205" height="70" as="geometry" />
      </mxCell>
      <mxCell id="p2_c7_pwa" value="PWA shell + share-target&#10;app/manifest.ts, app/share" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#0e8088;fontSize=11;" vertex="1" parent="p2_c7">
        <mxGeometry x="15" y="135" width="210" height="70" as="geometry" />
      </mxCell>

      <mxCell id="p2_c4" value="C4 — AI Platform" style="swimlane;startSize=28;rounded=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=13;fontStyle=1;" vertex="1" parent="1">
        <mxGeometry x="40" y="470" width="460" height="300" as="geometry" />
      </mxCell>
      <mxCell id="p2_c4_gw" value="Model registry + key resolver&#10;lib/ai/models.ts, lib/ai/resolver.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="p2_c4">
        <mxGeometry x="15" y="45" width="210" height="70" as="geometry" />
      </mxCell>
      <mxCell id="p2_c4_routes" value="/api/ai/* and /v1/* routes" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="p2_c4">
        <mxGeometry x="240" y="45" width="205" height="70" as="geometry" />
      </mxCell>
      <mxCell id="p2_c4_chat" value="Vault chat + function tools&#10;lib/ai/tools.ts (max 6 steps)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="p2_c4">
        <mxGeometry x="15" y="135" width="210" height="70" as="geometry" />
      </mxCell>
      <mxCell id="p2_c4_digest" value="Digest builder&#10;lib/ai/digest.ts, digest-runner.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="p2_c4">
        <mxGeometry x="240" y="135" width="205" height="70" as="geometry" />
      </mxCell>

      <mxCell id="p2_c1" value="C1 — Core Data and Storage" style="swimlane;startSize=28;rounded=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=13;fontStyle=1;" vertex="1" parent="1">
        <mxGeometry x="540" y="470" width="460" height="300" as="geometry" />
      </mxCell>
      <mxCell id="p2_c1_gs" value="getStorage() resolver&#10;lib/storage/index.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;fontStyle=1;" vertex="1" parent="p2_c1">
        <mxGeometry x="15" y="45" width="210" height="70" as="geometry" />
      </mxCell>
      <mxCell id="p2_c1_loc" value="LocalAdapter&#10;.md files + SQLite FTS5 index" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="p2_c1">
        <mxGeometry x="240" y="45" width="205" height="70" as="geometry" />
      </mxCell>
      <mxCell id="p2_c1_sup" value="SupabaseAdapter&#10;Postgres + RLS, notes_save() RPC" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="p2_c1">
        <mxGeometry x="240" y="135" width="205" height="70" as="geometry" />
      </mxCell>
      <mxCell id="p2_c1_watch" value="chokidar watcher + events bus&#10;lib/watch (750ms echo suppression)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="p2_c1">
        <mxGeometry x="15" y="135" width="210" height="70" as="geometry" />
      </mxCell>

      <mxCell id="p2_c6" value="C7 — SaaS Collaboration" style="swimlane;startSize=28;rounded=1;fillColor=#f8cecc;strokeColor=#b85450;fontSize=13;fontStyle=1;" vertex="1" parent="1">
        <mxGeometry x="1040" y="470" width="460" height="300" as="geometry" />
      </mxCell>
      <mxCell id="p2_c6_auth" value="Supabase auth + middleware&#10;magic link, OAuth, session refresh" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#b85450;fontSize=11;" vertex="1" parent="p2_c6">
        <mxGeometry x="15" y="45" width="210" height="70" as="geometry" />
      </mxCell>
      <mxCell id="p2_c6_ws" value="Workspaces + memberships&#10;RLS: 33 policies / 9 tables" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#b85450;fontSize=11;" vertex="1" parent="p2_c6">
        <mxGeometry x="240" y="45" width="205" height="70" as="geometry" />
      </mxCell>
      <mxCell id="p2_c6_collab" value="Comments, share links /s/[token],&#10;Supabase Realtime toasts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#b85450;fontSize=11;" vertex="1" parent="p2_c6">
        <mxGeometry x="15" y="135" width="210" height="70" as="geometry" />
      </mxCell>

      <mxCell id="p2_c3" value="C3 — Search and Embeddings" style="swimlane;startSize=28;rounded=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=13;fontStyle=1;" vertex="1" parent="1">
        <mxGeometry x="40" y="820" width="460" height="300" as="geometry" />
      </mxCell>
      <mxCell id="p2_c3_queue" value="Auto-embed queue, 30s debounce&#10;lib/ai/auto-embed-queue.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="p2_c3">
        <mxGeometry x="15" y="45" width="210" height="70" as="geometry" />
      </mxCell>
      <mxCell id="p2_c3_hybrid" value="Hybrid orchestrator, RRF k=60&#10;lib/search/hybrid.ts, rrf.ts (0.7 / 0.3)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="p2_c3">
        <mxGeometry x="240" y="45" width="205" height="70" as="geometry" />
      </mxCell>
      <mxCell id="p2_c3_store" value="Vector stores: SQLite BLOB / pgvector&#10;1536-dim text-embedding-3-large" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="p2_c3">
        <mxGeometry x="15" y="135" width="210" height="70" as="geometry" />
      </mxCell>

      <mxCell id="p2_c8" value="C6 — Versioning and Diff" style="swimlane;startSize=28;rounded=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=13;fontStyle=1;" vertex="1" parent="1">
        <mxGeometry x="540" y="820" width="460" height="300" as="geometry" />
      </mxCell>
      <mxCell id="p2_c8_loop" value="Commit loop, 30s debounce&#10;lib/git/commit-loop.ts (local only)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#666666;fontSize=11;" vertex="1" parent="p2_c8">
        <mxGeometry x="15" y="45" width="210" height="70" as="geometry" />
      </mxCell>
      <mxCell id="p2_c8_git" value="GitAdapter: simple-git or&#10;isomorphic-git (500ms auto-detect)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#666666;fontSize=11;" vertex="1" parent="p2_c8">
        <mxGeometry x="240" y="45" width="205" height="70" as="geometry" />
      </mxCell>
      <mxCell id="p2_c8_diff" value="Diff pages + section restore&#10;components/diff (reads versions table)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#666666;fontSize=11;" vertex="1" parent="p2_c8">
        <mxGeometry x="15" y="135" width="210" height="70" as="geometry" />
      </mxCell>

      <mxCell id="p2_c9" value="C9 — Platform Ops" style="swimlane;startSize=28;rounded=1;fillColor=#e6d0de;strokeColor=#996185;fontSize=13;fontStyle=1;" vertex="1" parent="1">
        <mxGeometry x="1040" y="820" width="460" height="300" as="geometry" />
      </mxCell>
      <mxCell id="p2_c9_sse" value="SSE live channel&#10;app/api/events/route.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#996185;fontSize=11;" vertex="1" parent="p2_c9">
        <mxGeometry x="15" y="45" width="210" height="70" as="geometry" />
      </mxCell>
      <mxCell id="p2_c9_cron" value="Cron: digest 13:00, trash-prune 04:00&#10;app/api/cron, vercel.json" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#996185;fontSize=11;" vertex="1" parent="p2_c9">
        <mxGeometry x="240" y="45" width="205" height="70" as="geometry" />
      </mxCell>
      <mxCell id="p2_c9_test" value="Test pyramid + CI gates&#10;tests/, .github/workflows/" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#996185;fontSize=11;" vertex="1" parent="p2_c9">
        <mxGeometry x="15" y="135" width="210" height="70" as="geometry" />
      </mxCell>

      <mxCell id="p2_e1" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p2_usr" target="p2_c2_shell">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p2_e2" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p2_agt" target="p2_c5_stdio">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p2_e3" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p2_agt" target="p2_c5_http">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p2_e4" value="/v1 Bearer PAT" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p2_oai" target="p2_c4_routes">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p2_e5" value="save / read" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p2_c2_act" target="p2_c1_gs">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p2_e6" value="every tool" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p2_c5_tools" target="p2_c1_gs">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p2_e7" value="search kind semantic/hybrid" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p2_c5_tools" target="p2_c3_hybrid">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p2_e8" value="apply_template" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p2_c5_tools" target="p2_c7_tpl">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p2_e9" value="clip writes" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p2_c7_clip" target="p2_c1_gs">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p2_e10" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p2_c7_pwa" target="p2_c7_clip">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p2_e11" value="scheduleEmbed on save" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p2_c1_loc" target="p2_c3_queue">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p2_e12" value="enqueue relPath" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p2_c1_loc" target="p2_c8_loop">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p2_e13" value="events bus" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p2_c1_watch" target="p2_c9_sse">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p2_e14" value="SSE debounced refresh" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p2_c9_sse" target="p2_c2_shell">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p2_e15" value="embed tier" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p2_c3_queue" target="p2_c4_gw">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p2_e16" value="RAG context" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p2_c4_chat" target="p2_c3_hybrid">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p2_e17" value="vault tools read/write" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p2_c4_chat" target="p2_c1_gs">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p2_e18" value="RLS session context" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p2_c6_auth" target="p2_c1_sup">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p2_e19" value="realtime toast" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p2_c6_collab" target="p2_c2_shell">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p2_e20" value="versions read" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p2_c8_diff" target="p2_c1_gs">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p2_e21" value="digest cron" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p2_c9_cron" target="p2_c4_digest">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p2_e22" value="trash prune" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p2_c9_cron" target="p2_c1_gs">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p2_e23" value="inline AI + chat UI" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p2_c2_editor" target="p2_c4_routes">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p2_e24" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p2_c8_loop" target="p2_c8_git">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
    </root>
  </mxGraphModel>
</diagram>
<diagram id="p3PlatIntegration" name="Platform — Integration Map">
  <mxGraphModel dx="800" dy="600" grid="0" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1600" pageHeight="1200" math="0" shadow="0">
    <root>
      <mxCell id="0" />
      <mxCell id="1" parent="0" />
      <mxCell id="p3_title" value="How the 9 clusters compose — every material runtime dependency, labeled. C1 is the hub: every surface reaches storage only through getStorage()." style="text;html=1;fontSize=15;fontStyle=1;align=left;verticalAlign=middle;" vertex="1" parent="1">
        <mxGeometry x="60" y="20" width="1300" height="40" as="geometry" />
      </mxCell>
      <mxCell id="p3_c2" value="C2 — Authoring UX&#10;editor, shell, palette, inspector&#10;components/, app/_actions/" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=13;fontStyle=1;verticalAlign=middle;" vertex="1" parent="1">
        <mxGeometry x="60" y="100" width="340" height="160" as="geometry" />
      </mxCell>
      <mxCell id="p3_c5" value="C5 — Agent Surface (MCP)&#10;16 tools, stdio + HTTP, PATs&#10;lib/mcp/, bin/eli-mcp.mjs" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=13;fontStyle=1;verticalAlign=middle;" vertex="1" parent="1">
        <mxGeometry x="620" y="100" width="340" height="160" as="geometry" />
      </mxCell>
      <mxCell id="p3_c7" value="C8 — Capture and Templating&#10;clip, share-target, import/export, templates&#10;lib/clipper/, lib/templates/" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#b0e3e2;strokeColor=#0e8088;fontSize=13;fontStyle=1;verticalAlign=middle;" vertex="1" parent="1">
        <mxGeometry x="1180" y="100" width="340" height="160" as="geometry" />
      </mxCell>
      <mxCell id="p3_c4" value="C4 — AI Platform&#10;gateway tiers, BYOK resolver, chat, digest, /v1&#10;lib/ai/, app/api/ai/, app/v1/" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=13;fontStyle=1;verticalAlign=middle;" vertex="1" parent="1">
        <mxGeometry x="60" y="460" width="340" height="160" as="geometry" />
      </mxCell>
      <mxCell id="p3_c1" value="C1 — Core Data and Storage&#10;StorageAdapter x4, schemas, watcher, config&#10;lib/storage/, lib/db/, lib/watch/" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=13;fontStyle=1;verticalAlign=middle;" vertex="1" parent="1">
        <mxGeometry x="620" y="460" width="340" height="160" as="geometry" />
      </mxCell>
      <mxCell id="p3_c6" value="C7 — SaaS Collaboration&#10;auth, workspaces, RLS, comments, shares&#10;app/(saas)/, components/comments/" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f8cecc;strokeColor=#b85450;fontSize=13;fontStyle=1;verticalAlign=middle;" vertex="1" parent="1">
        <mxGeometry x="1180" y="460" width="340" height="160" as="geometry" />
      </mxCell>
      <mxCell id="p3_c3" value="C3 — Search and Embeddings&#10;auto-embed queue, RRF hybrid search&#10;lib/search/, lib/ai/embeddings.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=13;fontStyle=1;verticalAlign=middle;" vertex="1" parent="1">
        <mxGeometry x="60" y="820" width="340" height="160" as="geometry" />
      </mxCell>
      <mxCell id="p3_c8" value="C6 — Versioning and Diff&#10;commit loop, GitAdapter, diff UI&#10;lib/git/, components/diff/" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=13;fontStyle=1;verticalAlign=middle;" vertex="1" parent="1">
        <mxGeometry x="620" y="820" width="340" height="160" as="geometry" />
      </mxCell>
      <mxCell id="p3_c9" value="C9 — Platform Ops&#10;cron, SSE, dev endpoints, tests, CI&#10;app/api/cron/, app/api/events/, tests/" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e6d0de;strokeColor=#996185;fontSize=13;fontStyle=1;verticalAlign=middle;" vertex="1" parent="1">
        <mxGeometry x="1180" y="820" width="340" height="160" as="geometry" />
      </mxCell>

      <mxCell id="p3_e1" value="save/read via server actions" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p3_c2" target="p3_c1">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p3_e2" value="all 16 tools via getStorage()" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p3_c5" target="p3_c1">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p3_e3" value="clip / import / export writes" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p3_c7" target="p3_c1">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p3_e4" value="session + RLS context for SupabaseAdapter" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p3_c6" target="p3_c1">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p3_e5" value="scheduleEmbed on save (30s)" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p3_c1" target="p3_c3">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p3_e6" value="enqueue path, debounced commit" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p3_c1" target="p3_c8">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p3_e7" value="events bus publish" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p3_c1" target="p3_c9">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p3_e8" value="SSE live refresh" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;exitX=0.25;exitY=0;entryX=1;entryY=0.75;" edge="1" parent="1" source="p3_c9" target="p3_c2">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p3_e9" value="cron digest trigger" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;exitX=0;exitY=0.5;entryX=1;entryY=0.5;" edge="1" parent="1" source="p3_c9" target="p3_c4">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p3_e10" value="cron trash prune" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;exitX=0.5;exitY=0;entryX=1;entryY=0.25;" edge="1" parent="1" source="p3_c9" target="p3_c1">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p3_e11" value="RAG context via hybrid search" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;exitX=0.25;exitY=1;entryX=0.25;entryY=0;" edge="1" parent="1" source="p3_c4" target="p3_c3">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p3_e12" value="embed tier + key resolver" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;exitX=0.75;exitY=0;entryX=0.75;entryY=1;" edge="1" parent="1" source="p3_c3" target="p3_c4">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p3_e13" value="chat vault tools read/write" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;exitX=1;exitY=0.25;entryX=0;entryY=0.25;" edge="1" parent="1" source="p3_c4" target="p3_c1">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p3_e14" value="search tool semantic/hybrid" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;exitX=0;exitY=0.75;entryX=0.5;entryY=0;" edge="1" parent="1" source="p3_c5" target="p3_c3">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p3_e15" value="apply_template" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;exitX=1;exitY=0.5;entryX=0;entryY=0.5;" edge="1" parent="1" source="p3_c5" target="p3_c7">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p3_e16" value="inline AI + vault chat UI" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;exitX=0.25;exitY=1;entryX=0.25;entryY=0;" edge="1" parent="1" source="p3_c2" target="p3_c4">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p3_e17" value="versions table read for diff" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;exitX=0.75;exitY=0;entryX=0.75;entryY=1;" edge="1" parent="1" source="p3_c8" target="p3_c1">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p3_e18" value="realtime note:updated toast" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;exitX=0.5;exitY=0;entryX=1;entryY=0.25;" edge="1" parent="1" source="p3_c6" target="p3_c2">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
    </root>
  </mxGraphModel>
</diagram>
<diagram id="p4PlatSpine" name="Platform — Data-Flow Spine">
  <mxGraphModel dx="800" dy="600" grid="0" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1600" pageHeight="1200" math="0" shadow="0">
    <root>
      <mxCell id="0" />
      <mxCell id="1" parent="0" />
      <mxCell id="p4_title" value="The life of one note: capture → store → index → embed → search → AI/agents → collaborate → version/recover → trash/prune. Mode branches shown in the two lanes." style="text;html=1;fontSize=15;fontStyle=1;align=left;verticalAlign=middle;" vertex="1" parent="1">
        <mxGeometry x="40" y="16" width="1400" height="40" as="geometry" />
      </mxCell>
      <mxCell id="p4_s1" value="Capture / author&#10;editor, clip, share-target,&#10;import, MCP agent" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="1">
        <mxGeometry x="40" y="80" width="210" height="80" as="geometry" />
      </mxCell>
      <mxCell id="p4_s2" value="Server action / API route /&#10;MCP tool&#10;(authorKind attribution)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="1">
        <mxGeometry x="320" y="80" width="210" height="80" as="geometry" />
      </mxCell>
      <mxCell id="p4_s3" value="StorageAdapter write&#10;+ append-only versions row&#10;lib/storage/*" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;fontStyle=1;" vertex="1" parent="1">
        <mxGeometry x="600" y="80" width="220" height="80" as="geometry" />
      </mxCell>

      <mxCell id="p4_lane_local" value="LOCAL MODE branch (ELI_MODE=local)" style="swimlane;startSize=28;rounded=1;fillColor=#f5f5f5;strokeColor=#6c8ebf;fontSize=13;fontStyle=1;horizontal=1;" vertex="1" parent="1">
        <mxGeometry x="40" y="220" width="1500" height="160" as="geometry" />
      </mxCell>
      <mxCell id="p4_l1" value="Atomic tmp+rename .md write&#10;markEcho 750ms&#10;lib/storage/local/writes.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="p4_lane_local">
        <mxGeometry x="20" y="45" width="230" height="90" as="geometry" />
      </mxCell>
      <mxCell id="p4_l2" value="Incremental SQLite FTS5 index&#10;~/.eli/index/&lt;hash&gt;.db" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="p4_lane_local">
        <mxGeometry x="330" y="45" width="230" height="90" as="geometry" />
      </mxCell>
      <mxCell id="p4_l3" value="Git commit queue&#10;one commit per 30s window&#10;lib/git/commit-loop.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=11;" vertex="1" parent="p4_lane_local">
        <mxGeometry x="640" y="45" width="230" height="90" as="geometry" />
      </mxCell>
      <mxCell id="p4_l4" value="Events bus → SSE /api/events&#10;debounced router.refresh&#10;in every open tab" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e6d0de;strokeColor=#996185;fontSize=11;" vertex="1" parent="p4_lane_local">
        <mxGeometry x="950" y="45" width="230" height="90" as="geometry" />
      </mxCell>
      <mxCell id="p4_l5" value="chokidar watcher catches&#10;external agent/vim edits too&#10;(same version + index path)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=11;dashed=1;" vertex="1" parent="p4_lane_local">
        <mxGeometry x="1260" y="45" width="220" height="90" as="geometry" />
      </mxCell>

      <mxCell id="p4_lane_saas" value="SAAS MODE branch (ELI_MODE=saas)" style="swimlane;startSize=28;rounded=1;fillColor=#f5f5f5;strokeColor=#b85450;fontSize=13;fontStyle=1;horizontal=1;" vertex="1" parent="1">
        <mxGeometry x="40" y="420" width="1500" height="160" as="geometry" />
      </mxCell>
      <mxCell id="p4_sa1" value="notes_save() RPC&#10;OCC on content_hash&#10;(RLS-scoped transaction)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f8cecc;strokeColor=#b85450;fontSize=11;" vertex="1" parent="p4_lane_saas">
        <mxGeometry x="20" y="45" width="230" height="90" as="geometry" />
      </mxCell>
      <mxCell id="p4_sa2" value="Version mismatch →&#10;conflict-snapshot version row&#10;(no data loss, banner in UI)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f8cecc;strokeColor=#b85450;fontSize=11;" vertex="1" parent="p4_lane_saas">
        <mxGeometry x="330" y="45" width="230" height="90" as="geometry" />
      </mxCell>
      <mxCell id="p4_sa3" value="Postgres tsvector kept in-row&#10;(no separate index step)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f8cecc;strokeColor=#b85450;fontSize=11;" vertex="1" parent="p4_lane_saas">
        <mxGeometry x="640" y="45" width="230" height="90" as="geometry" />
      </mxCell>
      <mxCell id="p4_sa4" value="Supabase Realtime&#10;note:updated toast in other&#10;members&#39; tabs" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f8cecc;strokeColor=#b85450;fontSize=11;" vertex="1" parent="p4_lane_saas">
        <mxGeometry x="950" y="45" width="230" height="90" as="geometry" />
      </mxCell>

      <mxCell id="p4_s4" value="Auto-embed queue&#10;30s debounce per note&#10;lib/ai/auto-embed-queue.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=12;" vertex="1" parent="1">
        <mxGeometry x="40" y="640" width="210" height="80" as="geometry" />
      </mxCell>
      <mxCell id="p4_s5" value="1536-dim vector stored&#10;SQLite BLOB / pgvector&#10;(text-embedding-3-large)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=12;" vertex="1" parent="1">
        <mxGeometry x="320" y="640" width="210" height="80" as="geometry" />
      </mxCell>
      <mxCell id="p4_s6" value="Hybrid search&#10;FTS + KNN fused with RRF&#10;k=60, fts 0.7 / vector 0.3" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=12;" vertex="1" parent="1">
        <mxGeometry x="600" y="640" width="210" height="80" as="geometry" />
      </mxCell>
      <mxCell id="p4_s7" value="AI chat + MCP agents&#10;RAG context, vault tools&#10;(max 6 steps, usage metered)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=12;" vertex="1" parent="1">
        <mxGeometry x="880" y="640" width="210" height="80" as="geometry" />
      </mxCell>
      <mxCell id="p4_s8" value="Collaborate (SaaS)&#10;section comments, share links&#10;/s/[token], audit log" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f8cecc;strokeColor=#b85450;fontSize=12;" vertex="1" parent="1">
        <mxGeometry x="1160" y="640" width="210" height="80" as="geometry" />
      </mxCell>
      <mxCell id="p4_s9" value="Diff / restore&#10;section-level, any version pair&#10;restore = new version row" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=12;" vertex="1" parent="1">
        <mxGeometry x="1160" y="800" width="210" height="80" as="geometry" />
      </mxCell>
      <mxCell id="p4_dig" value="Daily digest cron 13:00 UTC&#10;digest note mentions&#10;the day&#39;s changes" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e6d0de;strokeColor=#996185;fontSize=12;" vertex="1" parent="1">
        <mxGeometry x="320" y="800" width="210" height="80" as="geometry" />
      </mxCell>
      <mxCell id="p4_tr" value="Trash (soft delete)&#10;.eli/trash (local) or&#10;trashed_at stamp (SaaS)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="1">
        <mxGeometry x="880" y="800" width="210" height="80" as="geometry" />
      </mxCell>
      <mxCell id="p4_pr" value="Trash-prune cron 04:00 UTC&#10;purges entries older&#10;than 30 days" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e6d0de;strokeColor=#996185;fontSize=12;" vertex="1" parent="1">
        <mxGeometry x="600" y="800" width="210" height="80" as="geometry" />
      </mxCell>

      <mxCell id="p4_e1" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p4_s1" target="p4_s2">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p4_e2" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p4_s2" target="p4_s3">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p4_e3" value="local" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p4_s3" target="p4_l1">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p4_e4" value="saas" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p4_s3" target="p4_sa1">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p4_e5" value="index" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p4_l1" target="p4_l2">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p4_e6" value="enqueue" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p4_l2" target="p4_l3">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p4_e7" value="publish" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p4_l3" target="p4_l4">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p4_e8" value="on conflict" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p4_sa1" target="p4_sa2">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p4_e9" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p4_sa2" target="p4_sa3">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p4_e10" value="notify" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p4_sa3" target="p4_sa4">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p4_e11" value="scheduleEmbed (both modes)" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;exitX=0;exitY=1;entryX=0.5;entryY=0;" edge="1" parent="1" source="p4_s3" target="p4_s4">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p4_e12" value="gateway embed tier" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p4_s4" target="p4_s5">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p4_e13" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p4_s5" target="p4_s6">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p4_e14" value="RAG context" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p4_s6" target="p4_s7">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p4_e15" value="humans in the loop" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p4_s7" target="p4_s8">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p4_e16" value="every change restorable" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p4_s8" target="p4_s9">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p4_e17" value="recent activity feeds digest" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;exitX=0.25;exitY=1;entryX=0.5;entryY=0;" edge="1" parent="1" source="p4_s4" target="p4_dig">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p4_e18" value="delete = soft trash" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;exitX=0.5;exitY=1;entryX=0.5;entryY=0;" edge="1" parent="1" source="p4_s7" target="p4_tr">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="p4_e19" value="after 30 days" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="p4_tr" target="p4_pr">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
    </root>
  </mxGraphModel>
</diagram>
<diagram id="c1-system" name="C1 Core Data &amp; Storage — System">
  <mxGraphModel dx="800" dy="600" grid="0" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1600" pageHeight="1200" math="0" shadow="0">
    <root>
      <mxCell id="0" />
      <mxCell id="1" parent="0" />

      <!-- ================= SIMPLIFIED band ================= -->
      <mxCell id="c1s_simp" value="SIMPLIFIED — one interface, two backends, one mode switch" style="swimlane;startSize=28;rounded=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=14;fontStyle=1;" vertex="1" parent="1">
        <mxGeometry x="20" y="20" width="1560" height="330" as="geometry" />
      </mxCell>
      <mxCell id="c1s_callers" value="Server Actions, RSC pages,&#10;API routes, MCP tools" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=12;" vertex="1" parent="c1s_simp">
        <mxGeometry x="30" y="120" width="200" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c1s_gs" value="getStorage()&#10;lib/storage/index.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=12;" vertex="1" parent="c1s_simp">
        <mxGeometry x="290" y="120" width="190" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c1s_la" value="LocalAdapter&#10;files + SQLite index" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="c1s_simp">
        <mxGeometry x="540" y="60" width="200" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c1s_sa" value="SupabaseAdapter&#10;Postgres + RLS" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=12;" vertex="1" parent="c1s_simp">
        <mxGeometry x="540" y="210" width="200" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c1s_vault" value="Vault .md files&#10;(source of truth)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="c1s_simp">
        <mxGeometry x="800" y="45" width="190" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c1s_idx" value="SQLite index&#10;~/.eli/index/&lt;hash&gt;.db" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="c1s_simp">
        <mxGeometry x="800" y="125" width="190" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c1s_pg" value="Supabase Postgres&#10;notes / versions / RLS policies" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=12;" vertex="1" parent="c1s_simp">
        <mxGeometry x="800" y="215" width="190" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c1s_watch" value="chokidar watcher&#10;(echo-suppressed)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="c1s_simp">
        <mxGeometry x="1070" y="125" width="190" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c1s_sse" value="/api/events SSE&#10;browser tabs" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="c1s_simp">
        <mxGeometry x="1330" y="125" width="190" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c1s_e1" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c1s_simp" source="c1s_callers" target="c1s_gs">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c1s_e2" value="ELI_MODE=local" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c1s_simp" source="c1s_gs" target="c1s_la">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c1s_e3" value="ELI_MODE=saas" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c1s_simp" source="c1s_gs" target="c1s_sa">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c1s_e4" value="atomic writes" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c1s_simp" source="c1s_la" target="c1s_vault">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c1s_e5" value="derived index" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c1s_simp" source="c1s_la" target="c1s_idx">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c1s_e6" value="RLS-gated supabase-js" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c1s_simp" source="c1s_sa" target="c1s_pg">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c1s_e7" value="external edits reindexed" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c1s_simp" source="c1s_watch" target="c1s_idx">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c1s_e8" value="ChangeEvent" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c1s_simp" source="c1s_watch" target="c1s_sse">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>

      <!-- ================= DETAILED band ================= -->
      <mxCell id="c1s_det" value="DETAILED — full component graph by sub-area" style="swimlane;startSize=28;rounded=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=14;fontStyle=1;" vertex="1" parent="1">
        <mxGeometry x="20" y="380" width="1560" height="800" as="geometry" />
      </mxCell>

      <!-- Contract sub-area -->
      <mxCell id="c1s_ctr" value="Contract &amp; mode selection" style="swimlane;startSize=28;rounded=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=12;fontStyle=1;" vertex="1" parent="c1s_det">
        <mxGeometry x="20" y="50" width="240" height="290" as="geometry" />
      </mxCell>
      <mxCell id="c1s_ctr_adapter" value="StorageAdapter contract&#10;lib/storage/adapter.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c1s_ctr">
        <mxGeometry x="20" y="40" width="200" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c1s_ctr_gs" value="getStorage()&#10;lib/storage/index.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c1s_ctr">
        <mxGeometry x="20" y="120" width="200" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c1s_ctr_dom" value="Domain ids + types&#10;lib/domain/ids.ts, types.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c1s_ctr">
        <mxGeometry x="20" y="200" width="200" height="60" as="geometry" />
      </mxCell>

      <!-- Local backend sub-area -->
      <mxCell id="c1s_loc" value="Local backend (files + SQLite)" style="swimlane;startSize=28;rounded=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;fontStyle=1;" vertex="1" parent="c1s_det">
        <mxGeometry x="290" y="50" width="430" height="290" as="geometry" />
      </mxCell>
      <mxCell id="c1s_loc_f" value="LocalAdapter facade&#10;lib/storage/local.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c1s_loc">
        <mxGeometry x="15" y="40" width="190" height="50" as="geometry" />
      </mxCell>
      <mxCell id="c1s_loc_reads" value="reads.ts&#10;lenses, listNotes, backlinks" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c1s_loc">
        <mxGeometry x="15" y="100" width="190" height="50" as="geometry" />
      </mxCell>
      <mxCell id="c1s_loc_writes" value="writes.ts&#10;atomic save, trash, rename" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c1s_loc">
        <mxGeometry x="15" y="160" width="190" height="50" as="geometry" />
      </mxCell>
      <mxCell id="c1s_loc_search" value="search.ts&#10;FTS5 bm25 + snippets" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c1s_loc">
        <mxGeometry x="15" y="220" width="190" height="50" as="geometry" />
      </mxCell>
      <mxCell id="c1s_loc_vc" value="versions.ts + comments.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c1s_loc">
        <mxGeometry x="220" y="40" width="190" height="50" as="geometry" />
      </mxCell>
      <mxCell id="c1s_loc_fav" value="favorites.ts&#10;(config.json-backed)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c1s_loc">
        <mxGeometry x="220" y="100" width="190" height="50" as="geometry" />
      </mxCell>
      <mxCell id="c1s_loc_emb" value="embeddings.ts&#10;Float32 BLOB + cosine KNN" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c1s_loc">
        <mxGeometry x="220" y="160" width="190" height="50" as="geometry" />
      </mxCell>
      <mxCell id="c1s_loc_row" value="row.ts mappers" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c1s_loc">
        <mxGeometry x="220" y="220" width="190" height="50" as="geometry" />
      </mxCell>

      <!-- SaaS backend sub-area -->
      <mxCell id="c1s_saas" value="SaaS backend (Postgres + RLS)" style="swimlane;startSize=28;rounded=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=12;fontStyle=1;" vertex="1" parent="c1s_det">
        <mxGeometry x="750" y="50" width="430" height="290" as="geometry" />
      </mxCell>
      <mxCell id="c1s_saas_f" value="SupabaseAdapter facade&#10;lib/storage/supabase.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c1s_saas">
        <mxGeometry x="15" y="40" width="190" height="50" as="geometry" />
      </mxCell>
      <mxCell id="c1s_saas_q" value="queries.ts&#10;RLS-gated reads" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c1s_saas">
        <mxGeometry x="15" y="100" width="190" height="50" as="geometry" />
      </mxCell>
      <mxCell id="c1s_saas_w" value="writes.ts&#10;notes_save / notes_rename RPCs" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c1s_saas">
        <mxGeometry x="15" y="160" width="190" height="50" as="geometry" />
      </mxCell>
      <mxCell id="c1s_saas_sh" value="shares.ts + attachments.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c1s_saas">
        <mxGeometry x="15" y="220" width="190" height="50" as="geometry" />
      </mxCell>
      <mxCell id="c1s_saas_soc" value="comments, favorites,&#10;profiles, audit" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c1s_saas">
        <mxGeometry x="220" y="40" width="190" height="50" as="geometry" />
      </mxCell>
      <mxCell id="c1s_saas_keys" value="ai-keys.ts&#10;pgcrypto BYOK vault" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c1s_saas">
        <mxGeometry x="220" y="100" width="190" height="50" as="geometry" />
      </mxCell>
      <mxCell id="c1s_saas_knn" value="knn.ts + embeddings.ts&#10;pgvector HNSW" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c1s_saas">
        <mxGeometry x="220" y="160" width="190" height="50" as="geometry" />
      </mxCell>
      <mxCell id="c1s_saas_row" value="row.ts mappers" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c1s_saas">
        <mxGeometry x="220" y="220" width="190" height="50" as="geometry" />
      </mxCell>

      <!-- Freshness sub-area -->
      <mxCell id="c1s_fresh" value="Index freshness (shared with C9)" style="swimlane;startSize=28;rounded=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;fontStyle=1;" vertex="1" parent="c1s_det">
        <mxGeometry x="1210" y="50" width="330" height="490" as="geometry" />
      </mxCell>
      <mxCell id="c1s_fr_inst" value="instrumentation.ts&#10;boot-time watcher start" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c1s_fresh">
        <mxGeometry x="20" y="40" width="290" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c1s_fr_chok" value="chokidar.ts watcher&#10;markEcho 750ms suppression" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c1s_fresh">
        <mxGeometry x="20" y="115" width="290" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c1s_fr_incr" value="incremental.ts updatePath&#10;(delete row or rescan)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c1s_fresh">
        <mxGeometry x="20" y="190" width="290" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c1s_fr_scan" value="scanner.ts + walk.ts&#10;sha256 hash-skip full scan" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c1s_fresh">
        <mxGeometry x="20" y="265" width="290" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c1s_fr_bus" value="events-bus.ts&#10;globalThis singleton, 256 ring" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c1s_fresh">
        <mxGeometry x="20" y="340" width="290" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c1s_fr_sse" value="/api/events SSE route&#10;25s heartbeat, no replay" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c1s_fresh">
        <mxGeometry x="20" y="415" width="290" height="55" as="geometry" />
      </mxCell>

      <!-- SQLite layer -->
      <mxCell id="c1s_sql" value="SQLite index layer" style="swimlane;startSize=28;rounded=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;fontStyle=1;" vertex="1" parent="c1s_det">
        <mxGeometry x="20" y="370" width="240" height="220" as="geometry" />
      </mxCell>
      <mxCell id="c1s_sql_c" value="client.sqlite.ts + schema&#10;WAL, globalThis cache,&#10;inode staleness check" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c1s_sql">
        <mxGeometry x="20" y="40" width="200" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c1s_sql_m" value="migrations 0000-0004&#10;FTS5 + triggers, embeddings,&#10;chat, ai_usage" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c1s_sql">
        <mxGeometry x="20" y="130" width="200" height="70" as="geometry" />
      </mxCell>

      <!-- Shared helpers -->
      <mxCell id="c1s_help" value="Shared markdown helpers (pure functions)" style="swimlane;startSize=28;rounded=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=12;fontStyle=1;" vertex="1" parent="c1s_det">
        <mxGeometry x="290" y="370" width="430" height="170" as="geometry" />
      </mxCell>
      <mxCell id="c1s_h1" value="frontmatter / hash / title" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#666666;fontSize=11;" vertex="1" parent="c1s_help">
        <mxGeometry x="15" y="40" width="190" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c1s_h2" value="tags + wikilinks&#10;(fence-aware rewrite)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#666666;fontSize=11;" vertex="1" parent="c1s_help">
        <mxGeometry x="220" y="40" width="190" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c1s_h3" value="status / anchors / orphans" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#666666;fontSize=11;" vertex="1" parent="c1s_help">
        <mxGeometry x="15" y="105" width="190" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c1s_h4" value="section-diff / section-replace" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#666666;fontSize=11;" vertex="1" parent="c1s_help">
        <mxGeometry x="220" y="105" width="190" height="55" as="geometry" />
      </mxCell>

      <!-- Postgres layer -->
      <mxCell id="c1s_pgl" value="Postgres schema layer" style="swimlane;startSize=28;rounded=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=12;fontStyle=1;" vertex="1" parent="c1s_det">
        <mxGeometry x="750" y="370" width="430" height="170" as="geometry" />
      </mxCell>
      <mxCell id="c1s_pgl_s" value="schema.pg.ts + client.pg.ts&#10;+ seed.pg.ts fixture" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c1s_pgl">
        <mxGeometry x="15" y="40" width="190" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c1s_pgl_m" value="migrations pg 0000-0015&#10;RLS (427 lines), notes_save,&#10;buckets, PATs, ai_keys, knn" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c1s_pgl">
        <mxGeometry x="220" y="40" width="190" height="70" as="geometry" />
      </mxCell>

      <!-- Config & bootstrap -->
      <mxCell id="c1s_cfg" value="Config &amp; bootstrap" style="swimlane;startSize=28;rounded=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=12;fontStyle=1;" vertex="1" parent="c1s_det">
        <mxGeometry x="20" y="620" width="430" height="150" as="geometry" />
      </mxCell>
      <mxCell id="c1s_cfg_c" value="Config store lib/config&#10;~/.eli/config.json (0600)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#666666;fontSize=11;" vertex="1" parent="c1s_cfg">
        <mxGeometry x="15" y="45" width="190" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c1s_cfg_b" value="env.ts + middleware.ts&#10;+ next.config.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#666666;fontSize=11;" vertex="1" parent="c1s_cfg">
        <mxGeometry x="220" y="45" width="190" height="60" as="geometry" />
      </mxCell>

      <!-- Test adapters -->
      <mxCell id="c1s_test" value="Test / reference adapters" style="swimlane;startSize=28;rounded=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=12;fontStyle=1;" vertex="1" parent="c1s_det">
        <mxGeometry x="480" y="620" width="240" height="150" as="geometry" />
      </mxCell>
      <mxCell id="c1s_test_m" value="MemoryAdapter memory.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d6b656;fontSize=11;" vertex="1" parent="c1s_test">
        <mxGeometry x="20" y="40" width="200" height="45" as="geometry" />
      </mxCell>
      <mxCell id="c1s_test_j" value="JsonFileAdapter json-file.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d6b656;fontSize=11;" vertex="1" parent="c1s_test">
        <mxGeometry x="20" y="95" width="200" height="45" as="geometry" />
      </mxCell>

      <!-- Detailed-band edges -->
      <mxCell id="c1s_de1" value="local" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c1s_ctr_gs" target="c1s_loc_f">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c1s_de2" value="saas" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c1s_ctr_gs" target="c1s_saas_f">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c1s_de3" value="implements" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;dashed=1;" edge="1" parent="1" source="c1s_ctr_adapter" target="c1s_loc_f">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c1s_de4" value="implements" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;dashed=1;" edge="1" parent="1" source="c1s_ctr_adapter" target="c1s_test_m">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c1s_de5" value="openVaultIndex" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c1s_loc_f" target="c1s_sql_c">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c1s_de6" value="parse / serialize" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c1s_loc_writes" target="c1s_h1">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c1s_de7" value="markEcho + emit" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c1s_loc_writes" target="c1s_fr_chok">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c1s_de8" value="RPC calls" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c1s_saas_w" target="c1s_pgl_m">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c1s_de9" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c1s_fr_inst" target="c1s_fr_chok">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c1s_de10" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c1s_fr_chok" target="c1s_fr_incr">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c1s_de11" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c1s_fr_incr" target="c1s_fr_scan">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c1s_de12" value="upserts" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c1s_fr_scan" target="c1s_sql_c">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c1s_de13" value="ChangeEvent" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c1s_fr_chok" target="c1s_fr_bus">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c1s_de14" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c1s_fr_bus" target="c1s_fr_sse">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c1s_de15" value="activeVault" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c1s_cfg_c" target="c1s_ctr_gs">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c1s_de16" value="ELI_MODE" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c1s_cfg_b" target="c1s_ctr_gs">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
    </root>
  </mxGraphModel>
</diagram>
<diagram id="c1-flows" name="C1 Core Data &amp; Storage — Flows">
  <mxGraphModel dx="800" dy="600" grid="0" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1600" pageHeight="1240" math="0" shadow="0">
    <root>
      <mxCell id="0" />
      <mxCell id="1" parent="0" />

      <!-- ================= SIMPLIFIED band ================= -->
      <mxCell id="c1f_simp" value="SIMPLIFIED — local note save happy path (file-first, then index, then fan-out)" style="swimlane;startSize=28;rounded=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=14;fontStyle=1;" vertex="1" parent="1">
        <mxGeometry x="20" y="20" width="1560" height="290" as="geometry" />
      </mxCell>
      <mxCell id="c1f_s1" value="Editor autosave&#10;(debounced)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="c1f_simp">
        <mxGeometry x="25" y="60" width="175" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c1f_s2" value="Server Action&#10;app/_actions/notes.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="c1f_simp">
        <mxGeometry x="225" y="60" width="175" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c1f_s3" value="LocalAdapter.updateNote" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="c1f_simp">
        <mxGeometry x="425" y="60" width="175" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c1f_s4" value="markEcho + atomic write&#10;(tmp then rename)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="c1f_simp">
        <mxGeometry x="625" y="60" width="175" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c1f_s5" value="Vault .md file&#10;(source of truth)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="c1f_simp">
        <mxGeometry x="855" y="60" width="175" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c1f_s6" value="SQLite tx: notes + tags&#10;+ links + versions" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="c1f_simp">
        <mxGeometry x="625" y="180" width="175" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c1f_s7" value="emit note:updated&#10;on events bus" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="c1f_simp">
        <mxGeometry x="855" y="180" width="175" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c1f_s8" value="/api/events SSE" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="c1f_simp">
        <mxGeometry x="1085" y="180" width="175" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c1f_s9" value="Other tabs&#10;router.refresh" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="c1f_simp">
        <mxGeometry x="1315" y="180" width="175" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c1f_s10" value="git auto-commit&#10;(best effort)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=12;" vertex="1" parent="c1f_simp">
        <mxGeometry x="425" y="180" width="175" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c1f_se1" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c1f_simp" source="c1f_s1" target="c1f_s2">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c1f_se2" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c1f_simp" source="c1f_s2" target="c1f_s3">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c1f_se3" value="1. write file first" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c1f_simp" source="c1f_s3" target="c1f_s4">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c1f_se4" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c1f_simp" source="c1f_s4" target="c1f_s5">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c1f_se5" value="2. then index" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c1f_simp" source="c1f_s4" target="c1f_s6">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c1f_se6" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c1f_simp" source="c1f_s6" target="c1f_s7">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c1f_se7" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c1f_simp" source="c1f_s7" target="c1f_s8">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c1f_se8" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c1f_simp" source="c1f_s8" target="c1f_s9">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c1f_se9" value="side effect" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;dashed=1;" edge="1" parent="c1f_simp" source="c1f_s3" target="c1f_s10">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>

      <!-- ================= DETAILED band ================= -->
      <mxCell id="c1f_det" value="DETAILED — swimlane per actor: Local save (L1-L9, blue) | External edit (X1-X5, green) | SaaS save with OCC (S1-S7, orange)" style="swimlane;startSize=28;rounded=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=14;fontStyle=1;" vertex="1" parent="1">
        <mxGeometry x="20" y="340" width="1560" height="880" as="geometry" />
      </mxCell>

      <!-- Lanes -->
      <mxCell id="c1f_lane_br" value="Browser / UI" style="swimlane;horizontal=0;startSize=28;rounded=1;fillColor=#ffffff;strokeColor=#666666;fontSize=12;fontStyle=1;" vertex="1" parent="c1f_det">
        <mxGeometry x="20" y="40" width="1520" height="110" as="geometry" />
      </mxCell>
      <mxCell id="c1f_lane_srv" value="Next server (middleware + Server Action)" style="swimlane;horizontal=0;startSize=28;rounded=1;fillColor=#ffffff;strokeColor=#666666;fontSize=12;fontStyle=1;" vertex="1" parent="c1f_det">
        <mxGeometry x="20" y="150" width="1520" height="110" as="geometry" />
      </mxCell>
      <mxCell id="c1f_lane_ad" value="Storage adapter (Local | Supabase)" style="swimlane;horizontal=0;startSize=28;rounded=1;fillColor=#ffffff;strokeColor=#666666;fontSize=12;fontStyle=1;" vertex="1" parent="c1f_det">
        <mxGeometry x="20" y="260" width="1520" height="160" as="geometry" />
      </mxCell>
      <mxCell id="c1f_lane_ds" value="Data store (Vault FS + SQLite | Postgres)" style="swimlane;horizontal=0;startSize=28;rounded=1;fillColor=#ffffff;strokeColor=#666666;fontSize=12;fontStyle=1;" vertex="1" parent="c1f_det">
        <mxGeometry x="20" y="420" width="1520" height="160" as="geometry" />
      </mxCell>
      <mxCell id="c1f_lane_fw" value="Watcher / events bus / SSE" style="swimlane;horizontal=0;startSize=28;rounded=1;fillColor=#ffffff;strokeColor=#666666;fontSize=12;fontStyle=1;" vertex="1" parent="c1f_det">
        <mxGeometry x="20" y="580" width="1520" height="130" as="geometry" />
      </mxCell>
      <mxCell id="c1f_lane_ext" value="External editor + side effects" style="swimlane;horizontal=0;startSize=28;rounded=1;fillColor=#ffffff;strokeColor=#666666;fontSize=12;fontStyle=1;" vertex="1" parent="c1f_det">
        <mxGeometry x="20" y="710" width="1520" height="110" as="geometry" />
      </mxCell>

      <!-- Browser lane steps -->
      <mxCell id="c1f_L1" value="L1. debounced autosave&#10;POST server action" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c1f_lane_br">
        <mxGeometry x="60" y="25" width="160" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c1f_L9" value="L9. SSE frame, 500ms&#10;debounce, router.refresh" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c1f_lane_br">
        <mxGeometry x="600" y="25" width="160" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c1f_X5" value="X5. router.refresh renders&#10;fresh index data" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c1f_lane_br">
        <mxGeometry x="920" y="25" width="160" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c1f_S1" value="S1. save request&#10;(saas workspace route)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c1f_lane_br">
        <mxGeometry x="1120" y="25" width="160" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c1f_S7" value="S7. conflict banner if&#10;snapshot id returned via&#10;onConflictSnapshot" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c1f_lane_br">
        <mxGeometry x="1330" y="25" width="165" height="60" as="geometry" />
      </mxCell>

      <!-- Server lane steps -->
      <mxCell id="c1f_L2" value="L2. action calls&#10;storage.updateNote&#10;(id, patch, SaveOpts)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c1f_lane_srv">
        <mxGeometry x="60" y="25" width="160" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c1f_S2" value="S2. middleware refreshes&#10;session cookies, action&#10;resolves eli_ws workspace" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c1f_lane_srv">
        <mxGeometry x="1120" y="25" width="160" height="60" as="geometry" />
      </mxCell>

      <!-- Adapter lane steps -->
      <mxCell id="c1f_L3" value="L3. read row by id; stale&#10;expectedVersionId writes&#10;auto-conflict-snapshot" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c1f_lane_ad">
        <mxGeometry x="60" y="25" width="160" height="65" as="geometry" />
      </mxCell>
      <mxCell id="c1f_L4" value="L4. materialise: title,&#10;sha256 hash, tags, links,&#10;new monotonic ULID" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c1f_lane_ad">
        <mxGeometry x="245" y="25" width="165" height="65" as="geometry" />
      </mxCell>
      <mxCell id="c1f_L5" value="L5. markEcho (750ms TTL)&#10;+ tmp write + rename&#10;+ markEcho again" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c1f_lane_ad">
        <mxGeometry x="435" y="25" width="160" height="65" as="geometry" />
      </mxCell>
      <mxCell id="c1f_S3" value="S3. read row via RLS;&#10;stale expectedVersionId&#10;writes snapshot" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c1f_lane_ad">
        <mxGeometry x="1120" y="25" width="160" height="65" as="geometry" />
      </mxCell>
      <mxCell id="c1f_S4" value="S4. rpc notes_save with&#10;p_expected_version_id =&#10;just-read version" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c1f_lane_ad">
        <mxGeometry x="1320" y="25" width="175" height="65" as="geometry" />
      </mxCell>
      <mxCell id="c1f_S6" value="S6. on 40001 race: re-read,&#10;snapshot fresh loser, retry&#10;with null (force-accept)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c1f_lane_ad">
        <mxGeometry x="1320" y="95" width="175" height="60" as="geometry" />
      </mxCell>

      <!-- Data store lane steps -->
      <mxCell id="c1f_L5a" value="L5a. vault .md file&#10;replaced atomically" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c1f_lane_ds">
        <mxGeometry x="435" y="90" width="160" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c1f_L6" value="L6. SQLite tx: UPDATE notes,&#10;replace tags/links, INSERT&#10;versions; FTS5 triggers fire" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c1f_lane_ds">
        <mxGeometry x="620" y="20" width="175" height="65" as="geometry" />
      </mxCell>
      <mxCell id="c1f_X3" value="X3. updatePath: unlink&#10;deletes row, else scanVault&#10;prune:false (hash-skip)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c1f_lane_ds">
        <mxGeometry x="830" y="20" width="175" height="65" as="geometry" />
      </mxCell>
      <mxCell id="c1f_S5" value="S5. OCC ok: UPDATE notes +&#10;INSERT versions atomically,&#10;author from JWT sub" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c1f_lane_ds">
        <mxGeometry x="1120" y="20" width="175" height="65" as="geometry" />
      </mxCell>

      <!-- Watcher lane steps -->
      <mxCell id="c1f_Lecho" value="L5b. own-write fs event&#10;consumed by isEcho&#10;(no reindex)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=11;" vertex="1" parent="c1f_lane_fw">
        <mxGeometry x="435" y="30" width="160" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c1f_L7" value="L7. emit note:updated&#10;on events bus" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c1f_lane_fw">
        <mxGeometry x="620" y="15" width="150" height="50" as="geometry" />
      </mxCell>
      <mxCell id="c1f_L8" value="L8. /api/events streams,&#10;25s heartbeat, no replay" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c1f_lane_fw">
        <mxGeometry x="620" y="72" width="150" height="50" as="geometry" />
      </mxCell>
      <mxCell id="c1f_X2" value="X2. chokidar add/change/&#10;unlink (.md only); isEcho?&#10;no, proceed" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c1f_lane_fw">
        <mxGeometry x="830" y="15" width="175" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c1f_X4" value="X4. emit ChangeEvent,&#10;SSE fan-out to tabs" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c1f_lane_fw">
        <mxGeometry x="830" y="75" width="175" height="45" as="geometry" />
      </mxCell>

      <!-- External lane steps -->
      <mxCell id="c1f_git" value="SE. enqueueCommit: git&#10;auto-commit, debounced,&#10;failures swallowed" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=11;" vertex="1" parent="c1f_lane_ext">
        <mxGeometry x="435" y="25" width="175" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c1f_X1" value="X1. external editor writes&#10;note.md (Obsidian, agent,&#10;script)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c1f_lane_ext">
        <mxGeometry x="830" y="25" width="175" height="60" as="geometry" />
      </mxCell>

      <!-- Detailed edges (local save) -->
      <mxCell id="c1f_de1" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c1f_L1" target="c1f_L2">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c1f_de2" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c1f_L2" target="c1f_L3">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c1f_de3" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c1f_L3" target="c1f_L4">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c1f_de4" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c1f_L4" target="c1f_L5">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c1f_de5" value="rename lands" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c1f_L5" target="c1f_L5a">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c1f_de6" value="then persistRow" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c1f_L5" target="c1f_L6">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c1f_de7" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c1f_L6" target="c1f_L7">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c1f_de8" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c1f_L7" target="c1f_L8">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c1f_de9" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c1f_L8" target="c1f_L9">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c1f_de10" value="fs event" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;dashed=1;" edge="1" parent="1" source="c1f_L5a" target="c1f_Lecho">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c1f_de11" value="after save" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;dashed=1;" edge="1" parent="1" source="c1f_L6" target="c1f_git">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>

      <!-- Detailed edges (external edit) -->
      <mxCell id="c1f_de12" value="fs add/change/unlink" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c1f_X1" target="c1f_X2">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c1f_de13" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c1f_X2" target="c1f_X3">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c1f_de14" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c1f_X3" target="c1f_X4">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c1f_de15" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c1f_X4" target="c1f_X5">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>

      <!-- Detailed edges (SaaS save) -->
      <mxCell id="c1f_de16" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c1f_S1" target="c1f_S2">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c1f_de17" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c1f_S2" target="c1f_S3">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c1f_de18" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c1f_S3" target="c1f_S4">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c1f_de19" value="no race" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c1f_S4" target="c1f_S5">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c1f_de20" value="SQLSTATE 40001" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;dashed=1;" edge="1" parent="1" source="c1f_S4" target="c1f_S6">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c1f_de21" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c1f_S5" target="c1f_S7">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c1f_de22" value="retry lands" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;dashed=1;" edge="1" parent="1" source="c1f_S6" target="c1f_S7">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>

      <!-- Legend -->
      <mxCell id="c1f_leg1" value="Local save L1-L9" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c1f_det">
        <mxGeometry x="20" y="830" width="170" height="30" as="geometry" />
      </mxCell>
      <mxCell id="c1f_leg2" value="External edit X1-X5" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c1f_det">
        <mxGeometry x="210" y="830" width="170" height="30" as="geometry" />
      </mxCell>
      <mxCell id="c1f_leg3" value="SaaS save S1-S7 (OCC)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c1f_det">
        <mxGeometry x="400" y="830" width="170" height="30" as="geometry" />
      </mxCell>
      <mxCell id="c1f_leg4" value="Side effects / echo suppression" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=11;" vertex="1" parent="c1f_det">
        <mxGeometry x="590" y="830" width="200" height="30" as="geometry" />
      </mxCell>
    </root>
  </mxGraphModel>
</diagram>
<diagram id="c2-system" name="C2 Authoring &amp; Knowledge UX — System">
  <mxGraphModel dx="800" dy="600" grid="0" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1600" pageHeight="1200" math="0" shadow="0">
    <root>
      <mxCell id="0" />
      <mxCell id="1" parent="0" />

      <!-- ============ SIMPLIFIED BAND ============ -->
      <mxCell id="c2s_simband" value="SIMPLIFIED — Authoring UX at a glance" style="swimlane;startSize=28;rounded=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=14;fontStyle=1;" vertex="1" parent="1">
        <mxGeometry x="40" y="30" width="1520" height="260" as="geometry" />
      </mxCell>
      <mxCell id="c2s_s1" value="User" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=13;" vertex="1" parent="c2s_simband">
        <mxGeometry x="30" y="95" width="140" height="50" as="geometry" />
      </mxCell>
      <mxCell id="c2s_s2" value="Navigation shell&#10;sidebar + note list + palette" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=13;" vertex="1" parent="c2s_simband">
        <mxGeometry x="210" y="90" width="195" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c2s_s3" value="Editor stack&#10;BlockNote or raw textarea" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=13;" vertex="1" parent="c2s_simband">
        <mxGeometry x="445" y="90" width="195" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c2s_s4" value="Inspector&#10;properties, backlinks, history" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="c2s_simband">
        <mxGeometry x="445" y="175" width="195" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c2s_s5" value="Server actions&#10;app/_actions" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=13;" vertex="1" parent="c2s_simband">
        <mxGeometry x="690" y="90" width="185" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c2s_s6" value="Storage abstraction (C1)&#10;Local SQLite vault or Supabase" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=13;" vertex="1" parent="c2s_simband">
        <mxGeometry x="925" y="90" width="210" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c2s_s7" value="AI routes /api/ai/* (C4)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=12;" vertex="1" parent="c2s_simband">
        <mxGeometry x="690" y="175" width="185" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c2s_s8" value="Auto-embed queue (C3)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=12;" vertex="1" parent="c2s_simband">
        <mxGeometry x="925" y="175" width="210" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c2s_se1" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c2s_simband" source="c2s_s1" target="c2s_s2"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c2s_se2" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c2s_simband" source="c2s_s2" target="c2s_s3"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c2s_se3" value="debounced 1500ms save" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c2s_simband" source="c2s_s3" target="c2s_s5"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c2s_se4" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c2s_simband" source="c2s_s3" target="c2s_s4"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c2s_se5" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c2s_simband" source="c2s_s4" target="c2s_s5"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c2s_se6" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c2s_simband" source="c2s_s5" target="c2s_s6"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c2s_se7" value="slash menu / toolbar AI" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c2s_simband" source="c2s_s3" target="c2s_s7"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c2s_se8" value="scheduleEmbed" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c2s_simband" source="c2s_s5" target="c2s_s8"><mxGeometry relative="1" as="geometry" /></mxCell>

      <!-- ============ DETAILED BAND ============ -->
      <mxCell id="c2s_detband" value="DETAILED — full component graph (grouped by sub-area)" style="swimlane;startSize=28;rounded=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=14;fontStyle=1;" vertex="1" parent="1">
        <mxGeometry x="40" y="320" width="1520" height="740" as="geometry" />
      </mxCell>

      <!-- Editor stack -->
      <mxCell id="c2s_dEd" value="Editor stack — components/editor/" style="swimlane;startSize=24;rounded=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;fontStyle=1;" vertex="1" parent="c2s_detband">
        <mxGeometry x="20" y="45" width="380" height="300" as="geometry" />
      </mxCell>
      <mxCell id="c2s_dEd1" value="note-editor-root.tsx&#10;server variant switch" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c2s_dEd">
        <mxGeometry x="15" y="35" width="170" height="46" as="geometry" />
      </mxCell>
      <mxCell id="c2s_dEd2" value="blocknote-editor-dynamic.tsx&#10;ssr:false + skeleton" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c2s_dEd">
        <mxGeometry x="195" y="35" width="170" height="46" as="geometry" />
      </mxCell>
      <mxCell id="c2s_dEd3" value="blocknote-editor.tsx — BlockNote + slash AI + [[ wikilink autocomplete" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c2s_dEd">
        <mxGeometry x="15" y="95" width="350" height="46" as="geometry" />
      </mxCell>
      <mxCell id="c2s_dEd4" value="note-editor.tsx&#10;raw textarea" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c2s_dEd">
        <mxGeometry x="15" y="155" width="170" height="46" as="geometry" />
      </mxCell>
      <mxCell id="c2s_dEd5" value="mobile-editor-switch.tsx&#10;matchMedia max-width 767px" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c2s_dEd">
        <mxGeometry x="195" y="155" width="170" height="46" as="geometry" />
      </mxCell>
      <mxCell id="c2s_dEd6" value="conflict-banner.tsx" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c2s_dEd">
        <mxGeometry x="15" y="215" width="170" height="46" as="geometry" />
      </mxCell>
      <mxCell id="c2s_dEd7" value="ai-transform-menu.tsx" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c2s_dEd">
        <mxGeometry x="195" y="215" width="170" height="46" as="geometry" />
      </mxCell>

      <!-- Navigation shell -->
      <mxCell id="c2s_dNav" value="Navigation shell (local)" style="swimlane;startSize=24;rounded=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;fontStyle=1;" vertex="1" parent="c2s_detband">
        <mxGeometry x="420" y="45" width="380" height="300" as="geometry" />
      </mxCell>
      <mxCell id="c2s_dNav1" value="sidebar/app-sidebar.tsx&#10;buckets, types, folders, tags" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c2s_dNav">
        <mxGeometry x="15" y="35" width="170" height="46" as="geometry" />
      </mxCell>
      <mxCell id="c2s_dNav2" value="sidebar/vault-header.tsx&#10;breadcrumbs + re-scan" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c2s_dNav">
        <mxGeometry x="195" y="35" width="170" height="46" as="geometry" />
      </mxCell>
      <mxCell id="c2s_dNav3" value="two-pane-shell.tsx&#10;URL filter parsing" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c2s_dNav">
        <mxGeometry x="15" y="95" width="170" height="46" as="geometry" />
      </mxCell>
      <mxCell id="c2s_dNav4" value="note-list/*&#10;list + 250ms search debounce" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c2s_dNav">
        <mxGeometry x="195" y="95" width="170" height="46" as="geometry" />
      </mxCell>
      <mxCell id="c2s_dNav5" value="vault-events-bridge.tsx — SSE /api/events, 500ms refresh debounce" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c2s_dNav">
        <mxGeometry x="15" y="155" width="350" height="46" as="geometry" />
      </mxCell>
      <mxCell id="c2s_dNav6" value="(local)/v/layout.tsx — force-dynamic sidebar data per request" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c2s_dNav">
        <mxGeometry x="15" y="215" width="350" height="46" as="geometry" />
      </mxCell>

      <!-- Palette & capture -->
      <mxCell id="c2s_dPal" value="Palette &amp; quick capture" style="swimlane;startSize=24;rounded=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=12;fontStyle=1;" vertex="1" parent="c2s_detband">
        <mxGeometry x="820" y="45" width="340" height="125" as="geometry" />
      </mxCell>
      <mxCell id="c2s_dPal1" value="command-palette.tsx&#10;cmdk, Cmd+K" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c2s_dPal">
        <mxGeometry x="15" y="40" width="150" height="50" as="geometry" />
      </mxCell>
      <mxCell id="c2s_dPal2" value="new-note-dialog.tsx&#10;NFKD slug capture" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c2s_dPal">
        <mxGeometry x="175" y="40" width="150" height="50" as="geometry" />
      </mxCell>

      <!-- Inspector -->
      <mxCell id="c2s_dInsp" value="Inspector" style="swimlane;startSize=24;rounded=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=12;fontStyle=1;" vertex="1" parent="c2s_detband">
        <mxGeometry x="820" y="190" width="340" height="125" as="geometry" />
      </mxCell>
      <mxCell id="c2s_dInsp1" value="properties-panel.tsx&#10;actions, props, history" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c2s_dInsp">
        <mxGeometry x="15" y="40" width="150" height="50" as="geometry" />
      </mxCell>
      <mxCell id="c2s_dInsp2" value="backlinks-panel.tsx" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c2s_dInsp">
        <mxGeometry x="175" y="40" width="150" height="50" as="geometry" />
      </mxCell>

      <!-- Keybindings -->
      <mxCell id="c2s_dKey" value="Keybindings" style="swimlane;startSize=24;rounded=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=12;fontStyle=1;" vertex="1" parent="c2s_detband">
        <mxGeometry x="1180" y="45" width="320" height="200" as="geometry" />
      </mxCell>
      <mxCell id="c2s_dKey1" value="lib/keybindings/registry.ts + overrides.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d6b656;fontSize=11;" vertex="1" parent="c2s_dKey">
        <mxGeometry x="15" y="35" width="290" height="44" as="geometry" />
      </mxCell>
      <mxCell id="c2s_dKey2" value="keybinding-provider.tsx + help dialog (handler stacks)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d6b656;fontSize=11;" vertex="1" parent="c2s_dKey">
        <mxGeometry x="15" y="89" width="290" height="44" as="geometry" />
      </mxCell>
      <mxCell id="c2s_dKey3" value="keybinding-recorder.tsx + /keybindings page (local)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d6b656;fontSize=11;" vertex="1" parent="c2s_dKey">
        <mxGeometry x="15" y="143" width="290" height="44" as="geometry" />
      </mxCell>

      <!-- Theming -->
      <mxCell id="c2s_dTheme" value="Theming" style="swimlane;startSize=24;rounded=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=12;fontStyle=1;" vertex="1" parent="c2s_detband">
        <mxGeometry x="1180" y="265" width="320" height="115" as="geometry" />
      </mxCell>
      <mxCell id="c2s_dTheme1" value="theme-script.tsx&#10;pre-paint stamp" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d6b656;fontSize=11;" vertex="1" parent="c2s_dTheme">
        <mxGeometry x="15" y="35" width="140" height="50" as="geometry" />
      </mxCell>
      <mxCell id="c2s_dTheme2" value="theme-provider.tsx&#10;+ theme-toggle" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d6b656;fontSize=11;" vertex="1" parent="c2s_dTheme">
        <mxGeometry x="165" y="35" width="140" height="50" as="geometry" />
      </mxCell>

      <!-- Row B: Projects / Actions / Mobile / Realtime -->
      <mxCell id="c2s_dProj" value="Projects board" style="swimlane;startSize=24;rounded=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;fontStyle=1;" vertex="1" parent="c2s_detband">
        <mxGeometry x="20" y="410" width="250" height="110" as="geometry" />
      </mxCell>
      <mxCell id="c2s_dProj1" value="projects/project-board.tsx&#10;HTML5 DnD kanban, optimistic" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c2s_dProj">
        <mxGeometry x="15" y="35" width="220" height="55" as="geometry" />
      </mxCell>

      <mxCell id="c2s_dAct" value="Server actions — app/_actions/" style="swimlane;startSize=24;rounded=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;fontStyle=1;" vertex="1" parent="c2s_detband">
        <mxGeometry x="290" y="410" width="560" height="110" as="geometry" />
      </mxCell>
      <mxCell id="c2s_dAct1" value="notes.ts / favorites.ts&#10;save OCC, trash, pin" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c2s_dAct">
        <mxGeometry x="15" y="35" width="125" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c2s_dAct2" value="projects.ts&#10;status merge" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c2s_dAct">
        <mxGeometry x="150" y="35" width="125" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c2s_dAct3" value="vault.ts&#10;register, scan, sample" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c2s_dAct">
        <mxGeometry x="285" y="35" width="125" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c2s_dAct4" value="keybindings.ts&#10;override persistence" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c2s_dAct">
        <mxGeometry x="420" y="35" width="125" height="55" as="geometry" />
      </mxCell>

      <mxCell id="c2s_dMob" value="Mobile &amp; a11y" style="swimlane;startSize=24;rounded=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=12;fontStyle=1;" vertex="1" parent="c2s_detband">
        <mxGeometry x="870" y="410" width="290" height="110" as="geometry" />
      </mxCell>
      <mxCell id="c2s_dMob1" value="saas/mobile-nav.tsx&#10;44px sheet nav" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#666666;fontSize=11;" vertex="1" parent="c2s_dMob">
        <mxGeometry x="15" y="35" width="125" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c2s_dMob2" value="resizable-shell.tsx&#10;+ skip-link (app/layout)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#666666;fontSize=11;" vertex="1" parent="c2s_dMob">
        <mxGeometry x="150" y="35" width="125" height="55" as="geometry" />
      </mxCell>

      <mxCell id="c2s_dRT" value="SaaS realtime" style="swimlane;startSize=24;rounded=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=12;fontStyle=1;" vertex="1" parent="c2s_detband">
        <mxGeometry x="1180" y="410" width="320" height="110" as="geometry" />
      </mxCell>
      <mxCell id="c2s_dRT1" value="realtime/note-watcher.tsx&#10;postgres_changes toast, own saves suppressed" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c2s_dRT">
        <mxGeometry x="15" y="35" width="290" height="55" as="geometry" />
      </mxCell>

      <!-- Row C: External subsystems -->
      <mxCell id="c2s_dExt" value="External subsystems" style="swimlane;startSize=24;rounded=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=12;fontStyle=1;" vertex="1" parent="c2s_detband">
        <mxGeometry x="20" y="560" width="1480" height="130" as="geometry" />
      </mxCell>
      <mxCell id="c2s_dExt1" value="getStorage() adapters (C1)&#10;Local SQLite / Supabase" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c2s_dExt">
        <mxGeometry x="15" y="40" width="225" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c2s_dExt2" value="/api/ai/draft, summarize, transform (C4)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c2s_dExt">
        <mxGeometry x="260" y="40" width="225" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c2s_dExt3" value="lib/ai/auto-embed-queue (C3)&#10;debounced re-embed" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c2s_dExt">
        <mxGeometry x="505" y="40" width="225" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c2s_dExt4" value="/api/events SSE&#10;FS watcher events bus" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c2s_dExt">
        <mxGeometry x="750" y="40" width="225" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c2s_dExt5" value="Supabase Realtime (C7)&#10;postgres_changes UPDATE" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c2s_dExt">
        <mxGeometry x="995" y="40" width="225" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c2s_dExt6" value="~/.eli/config.json&#10;vault registry + keybindings" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c2s_dExt">
        <mxGeometry x="1240" y="40" width="225" height="55" as="geometry" />
      </mxCell>

      <!-- Detailed band edges (parent = band so coordinates resolve) -->
      <mxCell id="c2s_de1" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="c2s_detband" source="c2s_dEd1" target="c2s_dEd3"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c2s_de2" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="c2s_detband" source="c2s_dEd1" target="c2s_dEd4"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c2s_de3" value="1500ms debounce save" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="c2s_detband" source="c2s_dEd3" target="c2s_dAct1"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c2s_de4" value="slash AI / transform" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;dashed=1;" edge="1" parent="c2s_detband" source="c2s_dEd7" target="c2s_dExt2"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c2s_de5" value="listNotes limit 200" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="c2s_detband" source="c2s_dNav3" target="c2s_dExt1"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c2s_de6" value="EventSource" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;dashed=1;" edge="1" parent="c2s_detband" source="c2s_dNav5" target="c2s_dExt4"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c2s_de7" value="searchNotesAction" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="c2s_detband" source="c2s_dPal1" target="c2s_dAct1"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c2s_de8" value="createNoteAction" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="c2s_detband" source="c2s_dPal2" target="c2s_dAct1"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c2s_de9" value="frontmatter / pin / trash" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="c2s_detband" source="c2s_dInsp1" target="c2s_dAct1"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c2s_de10" value="setProjectStatusAction" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="c2s_detband" source="c2s_dProj1" target="c2s_dAct2"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c2s_de11" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="c2s_detband" source="c2s_dAct1" target="c2s_dExt1"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c2s_de12" value="scheduleEmbed" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;dashed=1;" edge="1" parent="c2s_detband" source="c2s_dAct1" target="c2s_dExt3"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c2s_de13" value="setKeybindingAction" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="c2s_detband" source="c2s_dKey3" target="c2s_dAct4"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c2s_de14" value="writes overrides" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="c2s_detband" source="c2s_dAct4" target="c2s_dExt6"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c2s_de15" value="subscribe id=eq.noteId" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;dashed=1;" edge="1" parent="c2s_detband" source="c2s_dRT1" target="c2s_dExt5"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c2s_de16" value="filter URLs" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="c2s_detband" source="c2s_dNav1" target="c2s_dNav3"><mxGeometry relative="1" as="geometry" /></mxCell>
    </root>
  </mxGraphModel>
</diagram>
<diagram id="c2-flows" name="C2 Authoring &amp; Knowledge UX — Flows">
  <mxGraphModel dx="800" dy="600" grid="0" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1600" pageHeight="1240" math="0" shadow="0">
    <root>
      <mxCell id="0" />
      <mxCell id="1" parent="0" />

      <!-- ============ SIMPLIFIED BAND ============ -->
      <mxCell id="c2f_simband" value="SIMPLIFIED — autosave happy path" style="swimlane;startSize=28;rounded=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=14;fontStyle=1;" vertex="1" parent="1">
        <mxGeometry x="40" y="30" width="1520" height="220" as="geometry" />
      </mxCell>
      <mxCell id="c2f_f1" value="Open /v/n/(path)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=12;" vertex="1" parent="c2f_simband">
        <mxGeometry x="25" y="80" width="170" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c2f_f2" value="Markdown to blocks&#10;tryParseMarkdownToBlocks" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="c2f_simband">
        <mxGeometry x="235" y="80" width="180" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c2f_f3" value="User types — every change&#10;blocksToMarkdownLossy" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="c2f_simband">
        <mxGeometry x="455" y="80" width="180" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c2f_f4" value="1500ms idle debounce&#10;(SAVE_DEBOUNCE_MS)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="c2f_simband">
        <mxGeometry x="675" y="80" width="180" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c2f_f5" value="saveNoteAction&#10;FormData + expectedVersionId" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="c2f_simband">
        <mxGeometry x="895" y="80" width="180" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c2f_f6" value="storage.updateNote — OCC,&#10;snapshot loser body on race" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=12;" vertex="1" parent="c2f_simband">
        <mxGeometry x="1115" y="80" width="180" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c2f_f7" value="revalidatePath + scheduleEmbed,&#10;editor advances versionId" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="c2f_simband">
        <mxGeometry x="1325" y="80" width="180" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c2f_fe1" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c2f_simband" source="c2f_f1" target="c2f_f2"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c2f_fe2" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c2f_simband" source="c2f_f2" target="c2f_f3"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c2f_fe3" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c2f_simband" source="c2f_f3" target="c2f_f4"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c2f_fe4" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c2f_simband" source="c2f_f4" target="c2f_f5"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c2f_fe5" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c2f_simband" source="c2f_f5" target="c2f_f6"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c2f_fe6" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c2f_simband" source="c2f_f6" target="c2f_f7"><mxGeometry relative="1" as="geometry" /></mxCell>

      <!-- ============ DETAILED BAND ============ -->
      <mxCell id="c2f_detband" value="DETAILED — open-and-edit autosave loop (numbered) + quick capture" style="swimlane;startSize=28;rounded=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=14;fontStyle=1;" vertex="1" parent="1">
        <mxGeometry x="40" y="280" width="1520" height="930" as="geometry" />
      </mxCell>

      <!-- Actor lanes (horizontal pools, title at left) -->
      <mxCell id="c2f_laneU" value="User" style="swimlane;horizontal=0;startSize=28;rounded=0;fillColor=#f5f5f5;strokeColor=#666666;fontSize=12;fontStyle=1;" vertex="1" parent="c2f_detband">
        <mxGeometry x="10" y="40" width="1500" height="120" as="geometry" />
      </mxCell>
      <mxCell id="c2f_u1" value="1. Open /v/n/(path)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#666666;fontSize=11;" vertex="1" parent="c2f_laneU">
        <mxGeometry x="45" y="30" width="150" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c2f_u2" value="5. Type in the editor" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#666666;fontSize=11;" vertex="1" parent="c2f_laneU">
        <mxGeometry x="470" y="30" width="150" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c2f_u3" value="12. (opt) Conflict banner shown — click Review snapshot, History row highlighted via hash" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c2f_laneU">
        <mxGeometry x="1240" y="25" width="235" height="70" as="geometry" />
      </mxCell>

      <mxCell id="c2f_laneE" value="Editor (client)" style="swimlane;horizontal=0;startSize=28;rounded=0;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;fontStyle=1;" vertex="1" parent="c2f_detband">
        <mxGeometry x="10" y="160" width="1500" height="140" as="geometry" />
      </mxCell>
      <mxCell id="c2f_e1" value="2. NoteEditorRoot picks variant from ELI_LEGACY_EDITOR / ELI_MOBILE_EDITOR (server-side)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c2f_laneE">
        <mxGeometry x="45" y="35" width="200" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c2f_e2" value="4. tryParseMarkdownToBlocks — fallback: single paragraph with raw markdown" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c2f_laneE">
        <mxGeometry x="265" y="35" width="185" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c2f_e3" value="6. onChange — blocksToMarkdownLossy, restart 1500ms debounce" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c2f_laneE">
        <mxGeometry x="470" y="35" width="185" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c2f_e4" value="7. Debounce fires — POST FormData (id, bodyMd, expectedVersionId, workspaceId in SaaS)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c2f_laneE">
        <mxGeometry x="675" y="35" width="200" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c2f_e5" value="11. SaveState — advance versionId, clear dirty; SaaS: markVersionAsLocal so realtime toast is suppressed" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c2f_laneE">
        <mxGeometry x="1000" y="35" width="220" height="70" as="geometry" />
      </mxCell>

      <mxCell id="c2f_laneA" value="saveNoteAction (server)" style="swimlane;horizontal=0;startSize=28;rounded=0;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;fontStyle=1;" vertex="1" parent="c2f_detband">
        <mxGeometry x="10" y="300" width="1500" height="130" as="geometry" />
      </mxCell>
      <mxCell id="c2f_a1" value="8. zod parse — storage.updateNote(authorKind user, expectedVersionId, onConflictSnapshot)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c2f_laneA">
        <mxGeometry x="675" y="30" width="200" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c2f_a2" value="10. revalidatePath note + /v layout; scheduleEmbed fire-and-forget (never blocks)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c2f_laneA">
        <mxGeometry x="1000" y="30" width="220" height="70" as="geometry" />
      </mxCell>

      <mxCell id="c2f_laneS" value="Storage adapter (C1)" style="swimlane;horizontal=0;startSize=28;rounded=0;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=12;fontStyle=1;" vertex="1" parent="c2f_detband">
        <mxGeometry x="10" y="430" width="1500" height="130" as="geometry" />
      </mxCell>
      <mxCell id="c2f_s1" value="3. getNote(relPath) + parallel backlinks, versions, favorite, comments" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c2f_laneS">
        <mxGeometry x="265" y="30" width="185" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c2f_s2" value="9. OCC check then write. On race: park previous body as auto-conflict-snapshot version, return its id (write still accepted)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c2f_laneS">
        <mxGeometry x="675" y="30" width="200" height="70" as="geometry" />
      </mxCell>

      <mxCell id="c2f_laneX" value="Side effects" style="swimlane;horizontal=0;startSize=28;rounded=0;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=12;fontStyle=1;" vertex="1" parent="c2f_detband">
        <mxGeometry x="10" y="560" width="1500" height="130" as="geometry" />
      </mxCell>
      <mxCell id="c2f_x1" value="SaaS: postgres_changes UPDATE reaches other clients — toast with Refresh (never auto-replaces buffer)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c2f_laneX">
        <mxGeometry x="470" y="30" width="185" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c2f_x2" value="Embed queue (C3) — debounced re-embed for semantic search" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c2f_laneX">
        <mxGeometry x="1000" y="30" width="170" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c2f_x3" value="Local: /api/events SSE — VaultEventsBridge router.refresh, 500ms debounce" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c2f_laneX">
        <mxGeometry x="1240" y="30" width="200" height="70" as="geometry" />
      </mxCell>

      <!-- Numbered flow edges across lanes -->
      <mxCell id="c2f_de1" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="c2f_detband" source="c2f_u1" target="c2f_e1"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c2f_de2" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="c2f_detband" source="c2f_e1" target="c2f_s1"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c2f_de3" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="c2f_detband" source="c2f_s1" target="c2f_e2"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c2f_de4" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="c2f_detband" source="c2f_e2" target="c2f_u2"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c2f_de5" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="c2f_detband" source="c2f_u2" target="c2f_e3"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c2f_de6" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="c2f_detband" source="c2f_e3" target="c2f_e4"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c2f_de7" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="c2f_detband" source="c2f_e4" target="c2f_a1"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c2f_de8" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="c2f_detband" source="c2f_a1" target="c2f_s2"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c2f_de9" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="c2f_detband" source="c2f_s2" target="c2f_a2"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c2f_de10" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="c2f_detband" source="c2f_a2" target="c2f_e5"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c2f_de11" value="if snapshotVersionId" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;dashed=1;" edge="1" parent="c2f_detband" source="c2f_e5" target="c2f_u3"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c2f_de12" value="fire-and-forget" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;dashed=1;" edge="1" parent="c2f_detband" source="c2f_a2" target="c2f_x2"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c2f_de13" value="local mode" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;dashed=1;" edge="1" parent="c2f_detband" source="c2f_a2" target="c2f_x3"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c2f_de14" value="saas mode" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;dashed=1;" edge="1" parent="c2f_detband" source="c2f_s2" target="c2f_x1"><mxGeometry relative="1" as="geometry" /></mxCell>

      <!-- Quick capture sub-flow -->
      <mxCell id="c2f_qct" value="Quick capture — Cmd+Shift+N to hard navigation" style="text;html=1;align=left;verticalAlign=middle;fontSize=13;fontStyle=1;" vertex="1" parent="c2f_detband">
        <mxGeometry x="20" y="710" width="500" height="30" as="geometry" />
      </mxCell>
      <mxCell id="c2f_qc1" value="1. Cmd+Shift+N keydown — KeybindingProvider matchAction, top handler wins, preventDefault" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=11;" vertex="1" parent="c2f_detband">
        <mxGeometry x="20" y="750" width="250" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c2f_qc2" value="2. NewNoteDialog — title only, NFKD slugify to inbox/(slug).md" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=11;" vertex="1" parent="c2f_detband">
        <mxGeometry x="310" y="750" width="250" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c2f_qc3" value="3. createNoteAction — storage.createNote via getStorage()" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c2f_detband">
        <mxGeometry x="600" y="750" width="250" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c2f_qc4" value="4. revalidatePath('/v', 'layout')" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c2f_detband">
        <mxGeometry x="890" y="750" width="220" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c2f_qc5" value="5. window.location.assign('/v/n/(path)') — hard navigation on purpose: soft push races the layout revalidation" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c2f_detband">
        <mxGeometry x="1150" y="750" width="290" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c2f_qe1" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="c2f_detband" source="c2f_qc1" target="c2f_qc2"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c2f_qe2" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="c2f_detband" source="c2f_qc2" target="c2f_qc3"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c2f_qe3" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="c2f_detband" source="c2f_qc3" target="c2f_qc4"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c2f_qe4" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="c2f_detband" source="c2f_qc4" target="c2f_qc5"><mxGeometry relative="1" as="geometry" /></mxCell>
    </root>
  </mxGraphModel>
</diagram>
<diagram id="c3-system" name="C3 Semantic Layer &amp; Search — System">
  <mxGraphModel dx="800" dy="600" grid="0" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1600" pageHeight="1200" math="0" shadow="0">
    <root>
      <mxCell id="0" />
      <mxCell id="1" parent="0" />
      <mxCell id="c3s_simband" value="SIMPLIFIED — semantic layer at a glance (index path top, query path bottom)" style="swimlane;startSize=30;rounded=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=14;fontStyle=1;" vertex="1" parent="1">
        <mxGeometry x="20" y="20" width="1560" height="310" as="geometry" />
      </mxCell>
      <mxCell id="c3s_s1" value="Note save&#10;(C2 editor)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=13;" vertex="1" parent="c3s_simband">
        <mxGeometry x="30" y="60" width="180" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c3s_s2" value="Auto-embed queue&#10;30s debounce per note" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=13;" vertex="1" parent="c3s_simband">
        <mxGeometry x="250" y="60" width="180" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c3s_s3" value="AI Gateway&#10;text-embedding-3-large @ 1536" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=13;" vertex="1" parent="c3s_simband">
        <mxGeometry x="470" y="60" width="180" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c3s_s4" value="Vector store&#10;SQLite BLOB / pgvector" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=13;" vertex="1" parent="c3s_simband">
        <mxGeometry x="690" y="60" width="180" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c3s_s5" value="FTS index&#10;FTS5 bm25 / tsvector" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=13;" vertex="1" parent="c3s_simband">
        <mxGeometry x="910" y="60" width="180" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c3s_s6" value="Search UI + any client" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=13;" vertex="1" parent="c3s_simband">
        <mxGeometry x="30" y="200" width="180" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c3s_s7" value="POST /api/search/hybrid&#10;hybridSearch orchestrator" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=13;" vertex="1" parent="c3s_simband">
        <mxGeometry x="250" y="200" width="200" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c3s_s8" value="RRF fuse&#10;k=60, fts 0.7 / vector 0.3" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=13;" vertex="1" parent="c3s_simband">
        <mxGeometry x="690" y="200" width="180" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c3s_s9" value="Ranked hits&#10;fusedScore + contributions" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=13;" vertex="1" parent="c3s_simband">
        <mxGeometry x="910" y="200" width="180" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c3s_se1" value="on save" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c3s_simband" source="c3s_s1" target="c3s_s2"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3s_se2" value="embedMany" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c3s_simband" source="c3s_s2" target="c3s_s3"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3s_se3" value="one vector per note" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c3s_simband" source="c3s_s3" target="c3s_s4"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3s_se4" value="POST q, kind" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c3s_simband" source="c3s_s6" target="c3s_s7"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3s_se5" value="KNN pass" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c3s_simband" source="c3s_s7" target="c3s_s4"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3s_se6" value="FTS pass" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c3s_simband" source="c3s_s7" target="c3s_s5"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3s_se7" value="fuse ranks" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c3s_simband" source="c3s_s7" target="c3s_s8"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3s_se8" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c3s_simband" source="c3s_s8" target="c3s_s9"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3s_detband" value="DETAILED — every component, grouped by sub-area" style="swimlane;startSize=30;rounded=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=14;fontStyle=1;" vertex="1" parent="1">
        <mxGeometry x="20" y="360" width="1560" height="830" as="geometry" />
      </mxCell>
      <mxCell id="c3s_g1" value="Embedding producers" style="swimlane;startSize=28;rounded=1;fillColor=#fff7ed;strokeColor=#d79b00;fontSize=12;fontStyle=1;" vertex="1" parent="c3s_detband">
        <mxGeometry x="20" y="45" width="360" height="410" as="geometry" />
      </mxCell>
      <mxCell id="c3s_d1" value="saveNoteAction / deleteNoteAction&#10;app/_actions/notes.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="c3s_g1">
        <mxGeometry x="20" y="40" width="320" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c3s_d2" value="Auto-embed queue (30s debounce, globalThis Map)&#10;lib/ai/auto-embed-queue.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=12;" vertex="1" parent="c3s_g1">
        <mxGeometry x="20" y="110" width="320" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c3s_d3" value="EmbedIndexerCard (AI settings)&#10;components/ai/embed-indexer-card.tsx" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="c3s_g1">
        <mxGeometry x="20" y="180" width="320" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c3s_d4" value="POST + GET /api/ai/embed (batch, progress)&#10;app/api/ai/embed/route.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=12;" vertex="1" parent="c3s_g1">
        <mxGeometry x="20" y="250" width="320" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c3s_d5" value="pnpm embed:backfill CLI (bypasses HTTP + rate limits)&#10;scripts/embed-backfill.mjs + embed-backfill-args.mjs" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=12;" vertex="1" parent="c3s_g1">
        <mxGeometry x="20" y="320" width="320" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c3s_g2" value="Embedding generation" style="swimlane;startSize=28;rounded=1;fillColor=#f8f4fb;strokeColor=#9673a6;fontSize=12;fontStyle=1;" vertex="1" parent="c3s_detband">
        <mxGeometry x="410" y="45" width="360" height="340" as="geometry" />
      </mxCell>
      <mxCell id="c3s_d6" value="embedTexts (embedMany, dims forced 1536)&#10;lib/ai/embeddings.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=12;" vertex="1" parent="c3s_g2">
        <mxGeometry x="20" y="40" width="320" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c3s_d7" value="resolveAiKey (saas-byok → local-byok → env)&#10;lib/ai/resolver.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=12;" vertex="1" parent="c3s_g2">
        <mxGeometry x="20" y="110" width="320" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c3s_d8" value="embed tier pin: openai/text-embedding-3-large&#10;lib/ai/models.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=12;" vertex="1" parent="c3s_g2">
        <mxGeometry x="20" y="180" width="320" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c3s_d9" value="chunkText 3500/250 — NOT used for embeddings&#10;lib/ai/chunking.ts (consumed by C4 chat/research)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=12;dashed=1;" vertex="1" parent="c3s_g2">
        <mxGeometry x="20" y="250" width="320" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c3s_g3" value="Local stores (SQLite)" style="swimlane;startSize=28;rounded=1;fillColor=#f2f9f1;strokeColor=#82b366;fontSize=12;fontStyle=1;" vertex="1" parent="c3s_detband">
        <mxGeometry x="800" y="45" width="360" height="270" as="geometry" />
      </mxCell>
      <mxCell id="c3s_d10" value="note_embeddings BLOB store + brute-force cosine KNN&#10;lib/storage/local/embeddings.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="c3s_g3">
        <mxGeometry x="20" y="40" width="320" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c3s_d11" value="notes_fts FTS5 + triggers, bm25 sign-flip, snippets&#10;lib/storage/local/search.ts + lib/db/fts.test.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="c3s_g3">
        <mxGeometry x="20" y="110" width="320" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c3s_d22" value="pnpm bench-search (FTS p95 budget gate)&#10;scripts/bench-search.mjs" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=12;" vertex="1" parent="c3s_g3">
        <mxGeometry x="20" y="180" width="320" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c3s_g4" value="SaaS stores (Supabase)" style="swimlane;startSize=28;rounded=1;fillColor=#f2f9f1;strokeColor=#82b366;fontSize=12;fontStyle=1;" vertex="1" parent="c3s_detband">
        <mxGeometry x="1190" y="45" width="350" height="270" as="geometry" />
      </mxCell>
      <mxCell id="c3s_d12" value="writeNoteEmbeddings (service role UPDATE)&#10;lib/storage/supabase/embeddings.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="c3s_g4">
        <mxGeometry x="15" y="40" width="320" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c3s_d13" value="notes_knn pgvector RPC (HNSW, SECURITY INVOKER)&#10;lib/storage/supabase/knn.ts + pg/0013_notes_knn.sql" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="c3s_g4">
        <mxGeometry x="15" y="110" width="320" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c3s_d14" value="notes_search tsvector RPC (RLS)&#10;SupabaseAdapter.search" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="c3s_g4">
        <mxGeometry x="15" y="180" width="320" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c3s_g5" value="Query path" style="swimlane;startSize=28;rounded=1;fillColor=#fffbeb;strokeColor=#d6b656;fontSize=12;fontStyle=1;" vertex="1" parent="c3s_detband">
        <mxGeometry x="410" y="470" width="460" height="340" as="geometry" />
      </mxCell>
      <mxCell id="c3s_d15" value="POST /api/search/hybrid (zod, auth split, force-dynamic)&#10;app/api/search/hybrid/route.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=12;" vertex="1" parent="c3s_g5">
        <mxGeometry x="20" y="40" width="420" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c3s_d16" value="hybridSearch orchestrator (FTS limit×2, 2-phase KNN, fallback)&#10;lib/search/hybrid.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=12;" vertex="1" parent="c3s_g5">
        <mxGeometry x="20" y="110" width="420" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c3s_d17" value="RRF fusion: k=60, weights fts 0.7 / vector 0.3&#10;lib/search/rrf.ts + rrf.test.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=12;" vertex="1" parent="c3s_g5">
        <mxGeometry x="20" y="180" width="420" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c3s_d18" value="checkRateLimit 60/min + 10k/day (shared with C5 MCP)&#10;lib/mcp/ratelimit.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=12;" vertex="1" parent="c3s_g5">
        <mxGeometry x="20" y="250" width="420" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c3s_g6" value="Debug UIs" style="swimlane;startSize=28;rounded=1;fillColor=#eff6ff;strokeColor=#6c8ebf;fontSize=12;fontStyle=1;" vertex="1" parent="c3s_detband">
        <mxGeometry x="20" y="500" width="360" height="270" as="geometry" />
      </mxCell>
      <mxCell id="c3s_d19" value="/search (local only, notFound gate)&#10;app/(local)/search/page.tsx" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="c3s_g6">
        <mxGeometry x="20" y="40" width="320" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c3s_d20" value="/w/[workspace]/search (slug → id via RLS)&#10;app/(saas)/(app)/w/[workspace]/search/page.tsx" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="c3s_g6">
        <mxGeometry x="20" y="110" width="320" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c3s_d21" value="HybridSearchExplorer (tabs, rank table, tinting)&#10;components/search/hybrid-explorer.tsx" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="c3s_g6">
        <mxGeometry x="20" y="180" width="320" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c3s_d23" value="Vercel AI Gateway (external)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=12;" vertex="1" parent="c3s_detband">
        <mxGeometry x="920" y="380" width="220" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c3s_e1" value="scheduleEmbed / cancelEmbed" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c3s_d1" target="c3s_d2"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3s_e2" value="POST all:true" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c3s_d3" target="c3s_d4"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3s_e3" value="1 text on fire" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c3s_d2" target="c3s_d6"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3s_e4" value="batches of 50" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c3s_d4" target="c3s_d6"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3s_e5" value="batches of 32" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c3s_d5" target="c3s_d6"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3s_e6" value="Bearer key" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c3s_d6" target="c3s_d7"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3s_e7" value="model pin" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;dashed=1;" edge="1" parent="1" source="c3s_d6" target="c3s_d8"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3s_e8" value="embedMany HTTPS" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c3s_d6" target="c3s_d23"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3s_e9" value="local upsert" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c3s_d2" target="c3s_d10"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3s_e10" value="saas UPDATE" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c3s_d2" target="c3s_d12"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3s_e11" value="local" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c3s_d4" target="c3s_d10"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3s_e12" value="saas" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c3s_d4" target="c3s_d12"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3s_e13" value="local" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c3s_d5" target="c3s_d10"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3s_e14" value="saas" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c3s_d5" target="c3s_d12"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3s_e15" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c3s_d19" target="c3s_d21"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3s_e16" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c3s_d20" target="c3s_d21"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3s_e17" value="POST q, kind, limit 20" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c3s_d21" target="c3s_d15"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3s_e18" value="rate check" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c3s_d15" target="c3s_d18"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3s_e19" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c3s_d15" target="c3s_d16"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3s_e20" value="FTS local" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c3s_d16" target="c3s_d11"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3s_e21" value="FTS saas" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c3s_d16" target="c3s_d14"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3s_e22" value="embed query" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c3s_d16" target="c3s_d6"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3s_e23" value="KNN local" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c3s_d16" target="c3s_d10"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3s_e24" value="KNN saas" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c3s_d16" target="c3s_d13"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3s_e25" value="fuse" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c3s_d16" target="c3s_d17"><mxGeometry relative="1" as="geometry" /></mxCell>
    </root>
  </mxGraphModel>
</diagram>
<diagram id="c3-flows" name="C3 Semantic Layer &amp; Search — Flows">
  <mxGraphModel dx="800" dy="600" grid="0" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1600" pageHeight="1400" math="0" shadow="0">
    <root>
      <mxCell id="0" />
      <mxCell id="1" parent="0" />
      <mxCell id="c3f_simband" value="SIMPLIFIED — hybrid query happy path" style="swimlane;startSize=30;rounded=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=14;fontStyle=1;" vertex="1" parent="1">
        <mxGeometry x="20" y="20" width="1560" height="240" as="geometry" />
      </mxCell>
      <mxCell id="c3f_h1" value="Client POSTs q&#10;/api/search/hybrid" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="c3f_simband">
        <mxGeometry x="30" y="80" width="170" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c3f_h2" value="Validate + rate limit&#10;60/min + 10k/day" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=12;" vertex="1" parent="c3f_simband">
        <mxGeometry x="220" y="80" width="170" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c3f_h3" value="FTS pass&#10;limit ×2 candidates" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="c3f_simband">
        <mxGeometry x="410" y="80" width="170" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c3f_h4" value="Embed query&#10;1536-dim via gateway" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=12;" vertex="1" parent="c3f_simband">
        <mxGeometry x="600" y="80" width="170" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c3f_h5" value="KNN: candidates first,&#10;then global top-up" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="c3f_simband">
        <mxGeometry x="790" y="80" width="170" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c3f_h6" value="RRF fuse k=60&#10;fts 0.7 / vector 0.3" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=12;" vertex="1" parent="c3f_simband">
        <mxGeometry x="980" y="80" width="170" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c3f_h7" value="Hydrate vector-only&#10;hits via getNote" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=12;" vertex="1" parent="c3f_simband">
        <mxGeometry x="1170" y="80" width="170" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c3f_h8" value="JSON hits: fusedScore,&#10;ranks, contributions" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="c3f_simband">
        <mxGeometry x="1360" y="80" width="170" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c3f_he1" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c3f_simband" source="c3f_h1" target="c3f_h2"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3f_he2" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c3f_simband" source="c3f_h2" target="c3f_h3"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3f_he3" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c3f_simband" source="c3f_h3" target="c3f_h4"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3f_he4" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c3f_simband" source="c3f_h4" target="c3f_h5"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3f_he5" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c3f_simband" source="c3f_h5" target="c3f_h6"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3f_he6" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c3f_simband" source="c3f_h6" target="c3f_h7"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3f_he7" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c3f_simband" source="c3f_h7" target="c3f_h8"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3f_detband" value="DETAILED — flow A (save → auto-embed → vector stored, steps A1-A7) and flow B (hybrid query → ranked hits, steps B1-B10)" style="swimlane;startSize=30;rounded=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=14;fontStyle=1;" vertex="1" parent="1">
        <mxGeometry x="20" y="290" width="1560" height="1020" as="geometry" />
      </mxCell>
      <mxCell id="c3f_L1" value="User / UI" style="swimlane;startSize=30;rounded=1;fillColor=#eff6ff;strokeColor=#6c8ebf;fontSize=12;fontStyle=1;" vertex="1" parent="c3f_detband">
        <mxGeometry x="10" y="45" width="250" height="960" as="geometry" />
      </mxCell>
      <mxCell id="c3f_a1" value="A1. Save note (1.5s editor debounce or Cmd+S)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c3f_L1">
        <mxGeometry x="15" y="50" width="220" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c3f_b1" value="B1. Explorer POSTs q, limit 20, kind (Hybrid / FTS / Semantic tab)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c3f_L1">
        <mxGeometry x="15" y="470" width="220" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c3f_b10" value="B10. Rank table: ftsRank / vectorRank / fused 5dp — blue = FTS-only, amber = vector-only" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c3f_L1">
        <mxGeometry x="15" y="860" width="220" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c3f_L2" value="Server action / API route" style="swimlane;startSize=30;rounded=1;fillColor=#fff7ed;strokeColor=#d79b00;fontSize=12;fontStyle=1;" vertex="1" parent="c3f_detband">
        <mxGeometry x="265" y="45" width="250" height="960" as="geometry" />
      </mxCell>
      <mxCell id="c3f_a2" value="A2. saveNoteAction persists via storage.updateNote (new version row)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c3f_L2">
        <mxGeometry x="15" y="50" width="220" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c3f_a3" value="A3. scheduleEmbed fire-and-forget in try/catch — can never fail the save" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c3f_L2">
        <mxGeometry x="15" y="140" width="220" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c3f_b2" value="B2. zod validate (q ≤1000, limit ≤100); local: no auth / saas: 401 without session" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c3f_L2">
        <mxGeometry x="15" y="470" width="220" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c3f_b3" value="B3. checkRateLimit 60/min + 10k/day → 429 with retry-after when exhausted" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c3f_L2">
        <mxGeometry x="15" y="560" width="220" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c3f_b9" value="B9. JSON hits: fusedScore, contributions, ftsRank, vectorRank, snippet" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c3f_L2">
        <mxGeometry x="15" y="860" width="220" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c3f_L3" value="Embed queue / hybridSearch" style="swimlane;startSize=30;rounded=1;fillColor=#fffbeb;strokeColor=#d6b656;fontSize=12;fontStyle=1;" vertex="1" parent="c3f_detband">
        <mxGeometry x="520" y="45" width="250" height="960" as="geometry" />
      </mxCell>
      <mxCell id="c3f_a4" value="A4. 30s debounce per noteId — re-save resets timer, delete cancels it" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=11;" vertex="1" parent="c3f_L3">
        <mxGeometry x="15" y="140" width="220" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c3f_a5" value="A5. Fire: getStorage fresh + getNote; skip if under 50 chars; text = title + body cut at 30k" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=11;" vertex="1" parent="c3f_L3">
        <mxGeometry x="15" y="230" width="220" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c3f_an1" value="Side effect: failure = console.warn only — no retry, no queue persistence" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=11;dashed=1;" vertex="1" parent="c3f_L3">
        <mxGeometry x="15" y="330" width="220" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c3f_bn1" value="SaaS-only short-circuit: kind=hybrid + 0 FTS hits → return [] before vector side (hybrid.ts:79-81)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=11;dashed=1;" vertex="1" parent="c3f_L3">
        <mxGeometry x="15" y="470" width="220" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c3f_b4" value="B4. FTS pass adapter.search limit ×2 (skipped when kind=semantic)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=11;" vertex="1" parent="c3f_L3">
        <mxGeometry x="15" y="560" width="220" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c3f_b7" value="B7. KNN two-phase: FTS-candidate ids first, global top-up when under limit" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=11;" vertex="1" parent="c3f_L3">
        <mxGeometry x="15" y="660" width="220" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c3f_b8" value="B8. hybridFuse k=60 (fts 0.7 / vector 0.3), topK = limit; hydrate vector-only hits via getNote" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=11;" vertex="1" parent="c3f_L3">
        <mxGeometry x="15" y="760" width="220" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c3f_L4" value="AI Gateway" style="swimlane;startSize=30;rounded=1;fillColor=#f8f4fb;strokeColor=#9673a6;fontSize=12;fontStyle=1;" vertex="1" parent="c3f_detband">
        <mxGeometry x="775" y="45" width="250" height="960" as="geometry" />
      </mxCell>
      <mxCell id="c3f_a6" value="A6. embedMany text-embedding-3-large, dims=1536 forced, Bearer key via resolveAiKey (saas-byok → local-byok → env)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c3f_L4">
        <mxGeometry x="15" y="230" width="220" height="80" as="geometry" />
      </mxCell>
      <mxCell id="c3f_b6" value="B6. Embed query (skipped when kind=fts); any error → FTS-only fallback. workspaceId forwarded, provider omitted — never workspace BYOK" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c3f_L4">
        <mxGeometry x="15" y="655" width="220" height="80" as="geometry" />
      </mxCell>
      <mxCell id="c3f_L5" value="Local store (SQLite)" style="swimlane;startSize=30;rounded=1;fillColor=#f2f9f1;strokeColor=#82b366;fontSize=12;fontStyle=1;" vertex="1" parent="c3f_detband">
        <mxGeometry x="1030" y="45" width="250" height="960" as="geometry" />
      </mxCell>
      <mxCell id="c3f_a7a" value="A7a. Local: upsert note_embeddings — Float32 BLOB, ON CONFLICT(note_id) DO UPDATE, one tx" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c3f_L5">
        <mxGeometry x="15" y="330" width="220" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c3f_b5a" value="B5a. notes_fts MATCH — bm25 sign-flipped, mark-wrapped snippets, trashed excluded" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c3f_L5">
        <mxGeometry x="15" y="560" width="220" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c3f_b7a" value="B7a. Brute-force cosine over BLOBs (model + dim filtered, no sqlite-vec)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c3f_L5">
        <mxGeometry x="15" y="660" width="220" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c3f_L6" value="SaaS store (Supabase)" style="swimlane;startSize=30;rounded=1;fillColor=#f2f9f1;strokeColor=#82b366;fontSize=12;fontStyle=1;" vertex="1" parent="c3f_detband">
        <mxGeometry x="1285" y="45" width="250" height="960" as="geometry" />
      </mxCell>
      <mxCell id="c3f_a7b" value="A7b. SaaS: service-role UPDATE notes.embedding scoped by id + workspace_id (silent no-op without workspaceId)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c3f_L6">
        <mxGeometry x="15" y="330" width="220" height="80" as="geometry" />
      </mxCell>
      <mxCell id="c3f_b5b" value="B5b. notes_search tsvector RPC via user-scoped client (RLS)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c3f_L6">
        <mxGeometry x="15" y="560" width="220" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c3f_b7b" value="B7b. notes_knn pgvector HNSW RPC — SECURITY INVOKER, similarity = 1 − distance" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c3f_L6">
        <mxGeometry x="15" y="660" width="220" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c3f_fe1" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c3f_a1" target="c3f_a2"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3f_fe2" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c3f_a2" target="c3f_a3"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3f_fe3" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c3f_a3" target="c3f_a4"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3f_fe4" value="timer fires" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c3f_a4" target="c3f_a5"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3f_fe5" value="1 text" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c3f_a5" target="c3f_a6"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3f_fe6" value="local" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c3f_a6" target="c3f_a7a"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3f_fe7" value="saas" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c3f_a6" target="c3f_a7b"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3f_fe8" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c3f_b1" target="c3f_b2"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3f_fe9" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c3f_b2" target="c3f_b3"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3f_fe10" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c3f_b3" target="c3f_b4"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3f_fe11" value="local" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c3f_b4" target="c3f_b5a"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3f_fe12" value="saas" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c3f_b4" target="c3f_b5b"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3f_fe13" value="unless kind=fts" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c3f_b4" target="c3f_b6"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3f_fe14" value="query vector" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c3f_b6" target="c3f_b7"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3f_fe15" value="local" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c3f_b7" target="c3f_b7a"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3f_fe16" value="saas" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c3f_b7" target="c3f_b7b"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3f_fe17" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c3f_b7" target="c3f_b8"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3f_fe18" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c3f_b8" target="c3f_b9"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c3f_fe19" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c3f_b9" target="c3f_b10"><mxGeometry relative="1" as="geometry" /></mxCell>
    </root>
  </mxGraphModel>
</diagram>
<diagram id="c4-system-page" name="C4 AI Platform — System">
  <mxGraphModel dx="800" dy="600" grid="0" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1600" pageHeight="1200" math="0" shadow="0">
    <root>
      <mxCell id="0" />
      <mxCell id="1" parent="0" />

      <!-- ===================== SIMPLIFIED BAND ===================== -->
      <mxCell id="c4s_band1" value="SIMPLIFIED — AI platform at a glance" style="swimlane;startSize=28;rounded=1;fillColor=#ffffff;strokeColor=#666666;fontSize=15;fontStyle=1;" vertex="1" parent="1">
        <mxGeometry x="20" y="20" width="1560" height="330" as="geometry" />
      </mxCell>
      <mxCell id="c4s_s1" value="eli UI&#10;(editor, VaultChat, settings)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=13;" vertex="1" parent="c4s_band1">
        <mxGeometry x="40" y="60" width="210" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c4s_s2" value="External OpenAI clients&#10;(Bearer PAT / local token)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=13;" vertex="1" parent="c4s_band1">
        <mxGeometry x="40" y="190" width="210" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c4s_s3" value="Native AI routes&#10;/api/ai/* + chat + digest" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=13;" vertex="1" parent="c4s_band1">
        <mxGeometry x="310" y="60" width="200" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c4s_s4" value="/v1 OpenAI-compatible facade" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=13;" vertex="1" parent="c4s_band1">
        <mxGeometry x="310" y="190" width="200" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c4s_s5" value="Key resolver&#10;saas-byok → local-byok → gateway master" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=13;" vertex="1" parent="c4s_band1">
        <mxGeometry x="570" y="120" width="200" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c4s_s6" value="Tier registry + gateway opts&#10;fast / smart / cheap / embed&#10;HIPAA allowlist, no prompt training" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=13;" vertex="1" parent="c4s_band1">
        <mxGeometry x="830" y="110" width="220" height="90" as="geometry" />
      </mxCell>
      <mxCell id="c4s_s7" value="Vercel AI Gateway&#10;→ anthropic / openai / google ..." style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=13;" vertex="1" parent="c4s_band1">
        <mxGeometry x="1120" y="120" width="200" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c4s_s8" value="Usage metering + read-time pricing" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=13;" vertex="1" parent="c4s_band1">
        <mxGeometry x="830" y="240" width="220" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c4s_s9" value="Hybrid search + vault tools&#10;(RAG context over notes)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=13;" vertex="1" parent="c4s_band1">
        <mxGeometry x="570" y="240" width="200" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c4s_e1" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c4s_band1" source="c4s_s1" target="c4s_s3"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c4s_e2" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c4s_band1" source="c4s_s2" target="c4s_s4"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c4s_e3" value="resolveAiKey" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c4s_band1" source="c4s_s3" target="c4s_s5"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c4s_e4" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c4s_band1" source="c4s_s4" target="c4s_s5"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c4s_e5" value="Bearer key per call" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c4s_band1" source="c4s_s5" target="c4s_s6"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c4s_e6" value="order / sort / only" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c4s_band1" source="c4s_s6" target="c4s_s7"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c4s_e7" value="RAG context" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c4s_band1" source="c4s_s3" target="c4s_s9"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c4s_e8" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c4s_band1" source="c4s_s4" target="c4s_s9"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c4s_e9" value="recordUsage" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;dashed=1;" edge="1" parent="c4s_band1" source="c4s_s3" target="c4s_s8"><mxGeometry relative="1" as="geometry" /></mxCell>

      <!-- ===================== DETAILED BAND ===================== -->
      <mxCell id="c4s_band2" value="DETAILED — full component graph (grouped by sub-area)" style="swimlane;startSize=28;rounded=1;fillColor=#ffffff;strokeColor=#666666;fontSize=15;fontStyle=1;" vertex="1" parent="1">
        <mxGeometry x="20" y="380" width="1560" height="760" as="geometry" />
      </mxCell>

      <!-- Core libs group -->
      <mxCell id="c4s_gcore" value="Core AI libs (lib/ai)" style="swimlane;startSize=26;rounded=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;fontStyle=1;" vertex="1" parent="c4s_band2">
        <mxGeometry x="30" y="45" width="370" height="330" as="geometry" />
      </mxCell>
      <mxCell id="c4s_n_models" value="models.ts&#10;tier pins + EMBEDDING_DIMS 1536" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c4s_gcore">
        <mxGeometry x="12" y="36" width="168" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c4s_n_gwo" value="gateway-opts.ts&#10;order / sort / HIPAA lockdown" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c4s_gcore">
        <mxGeometry x="190" y="36" width="168" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c4s_n_gwc" value="gateway-config.ts&#10;persisted order+sort loader" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c4s_gcore">
        <mxGeometry x="12" y="106" width="168" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c4s_n_res" value="resolver.ts&#10;3-tier key resolution" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c4s_gcore">
        <mxGeometry x="190" y="106" width="168" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c4s_n_met" value="usage.ts + pricing.ts&#10;metering + read-time cost" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=11;" vertex="1" parent="c4s_gcore">
        <mxGeometry x="12" y="176" width="168" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c4s_n_tools" value="tools.ts + audit.ts&#10;vault ToolSet + ai.tool.* audit" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c4s_gcore">
        <mxGeometry x="190" y="176" width="168" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c4s_n_testkey" value="test-key.ts&#10;provider auth pings (Test button)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c4s_gcore">
        <mxGeometry x="12" y="246" width="168" height="60" as="geometry" />
      </mxCell>

      <!-- Feature routes group -->
      <mxCell id="c4s_groutes" value="Feature routes (app/api/ai)" style="swimlane;startSize=26;rounded=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;fontStyle=1;" vertex="1" parent="c4s_band2">
        <mxGeometry x="430" y="45" width="370" height="250" as="geometry" />
      </mxCell>
      <mxCell id="c4s_n_draft" value="draft — stream, fast tier" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c4s_groutes">
        <mxGeometry x="12" y="36" width="168" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c4s_n_summ" value="summarize — fast, frontmatter persist" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c4s_groutes">
        <mxGeometry x="190" y="36" width="168" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c4s_n_trans" value="transform — fast, 5 actions" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c4s_groutes">
        <mxGeometry x="12" y="101" width="168" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c4s_n_resr" value="research — map-reduce (API-only)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c4s_groutes">
        <mxGeometry x="190" y="101" width="168" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c4s_n_extr" value="extract-tasks — smart, task notes" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c4s_groutes">
        <mxGeometry x="12" y="166" width="168" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c4s_n_cont" value="continue — stream, smart (no UI)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c4s_groutes">
        <mxGeometry x="190" y="166" width="168" height="55" as="geometry" />
      </mxCell>

      <!-- Chat group -->
      <mxCell id="c4s_gchat" value="Chat system" style="swimlane;startSize=26;rounded=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;fontStyle=1;" vertex="1" parent="c4s_band2">
        <mxGeometry x="830" y="45" width="370" height="250" as="geometry" />
      </mxCell>
      <mxCell id="c4s_n_chat" value="chat/route.ts&#10;non-streaming RAG" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c4s_gchat">
        <mxGeometry x="12" y="36" width="168" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c4s_n_chats" value="chat/stream/route.ts&#10;UI-message stream" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c4s_gchat">
        <mxGeometry x="190" y="36" width="168" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c4s_n_chatm" value="chat/messages/route.ts&#10;history fetch, 404 non-owner" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c4s_gchat">
        <mxGeometry x="12" y="101" width="168" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c4s_n_chst" value="lib/chat/storage.ts&#10;threads + messages CRUD" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c4s_gchat">
        <mxGeometry x="190" y="101" width="168" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c4s_n_vch" value="vault-chat.tsx&#10;/chat + /w/[ws]/chat" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c4s_gchat">
        <mxGeometry x="12" y="166" width="168" height="55" as="geometry" />
      </mxCell>

      <!-- v1 group -->
      <mxCell id="c4s_gv1" value="v1 facade (app/v1)" style="swimlane;startSize=26;rounded=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=12;fontStyle=1;" vertex="1" parent="c4s_band2">
        <mxGeometry x="1230" y="45" width="300" height="250" as="geometry" />
      </mxCell>
      <mxCell id="c4s_n_v1c" value="chat/completions&#10;SSE re-encode, eli_ extensions" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c4s_gv1">
        <mxGeometry x="12" y="36" width="276" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c4s_n_v1e" value="embeddings&#10;embedTexts delegate, 1536-dim" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c4s_gv1">
        <mxGeometry x="12" y="101" width="276" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c4s_n_v1m" value="models + openapi.json&#10;discovery (no auth / cached 300s)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c4s_gv1">
        <mxGeometry x="12" y="166" width="276" height="55" as="geometry" />
      </mxCell>

      <!-- Key management group -->
      <mxCell id="c4s_gkeys" value="Key management" style="swimlane;startSize=26;rounded=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=12;fontStyle=1;" vertex="1" parent="c4s_band2">
        <mxGeometry x="30" y="415" width="370" height="230" as="geometry" />
      </mxCell>
      <mxCell id="c4s_n_ksa" value="_actions/ai-keys.ts&#10;SaaS BYOK CRUD + Test" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c4s_gkeys">
        <mxGeometry x="12" y="36" width="168" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c4s_n_krpc" value="storage/supabase/ai-keys.ts&#10;pgcrypto RPCs (ELI_KMS_KEY)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c4s_gkeys">
        <mxGeometry x="190" y="36" width="168" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c4s_n_kla" value="_actions/ai-key-local.ts&#10;~/.eli/config.json (0600)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c4s_gkeys">
        <mxGeometry x="12" y="116" width="168" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c4s_n_rot" value="scripts/rotate-ai-keys.mjs&#10;offline KMS rotation" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c4s_gkeys">
        <mxGeometry x="190" y="116" width="168" height="60" as="geometry" />
      </mxCell>

      <!-- Digest group -->
      <mxCell id="c4s_gdig" value="Digest system" style="swimlane;startSize=26;rounded=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=12;fontStyle=1;" vertex="1" parent="c4s_band2">
        <mxGeometry x="430" y="325" width="370" height="200" as="geometry" />
      </mxCell>
      <mxCell id="c4s_n_dgb" value="digest.ts&#10;pure markdown builder" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d6b656;fontSize=11;" vertex="1" parent="c4s_gdig">
        <mxGeometry x="12" y="36" width="168" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c4s_n_dgr" value="digest-runner.ts&#10;runDigest idempotent upsert" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d6b656;fontSize=11;" vertex="1" parent="c4s_gdig">
        <mxGeometry x="190" y="36" width="168" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c4s_n_dgc" value="api/cron/digest/route.ts&#10;CRON_SECRET, workspace fan-out" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d6b656;fontSize=11;" vertex="1" parent="c4s_gdig">
        <mxGeometry x="12" y="116" width="168" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c4s_n_dga" value="_actions/digest.ts&#10;+ DigestNowButton (session-scoped)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d6b656;fontSize=11;" vertex="1" parent="c4s_gdig">
        <mxGeometry x="190" y="116" width="168" height="60" as="geometry" />
      </mxCell>

      <!-- Settings UI group -->
      <mxCell id="c4s_gui" value="Settings + usage UI" style="swimlane;startSize=26;rounded=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;fontStyle=1;" vertex="1" parent="c4s_band2">
        <mxGeometry x="430" y="545" width="370" height="150" as="geometry" />
      </mxCell>
      <mxCell id="c4s_n_setp" value="/ai-key + /w/[ws]/settings/ai&#10;+ usage cards" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c4s_gui">
        <mxGeometry x="12" y="36" width="168" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c4s_n_gform" value="gateway-config-form.tsx&#10;+ _actions/ai-gateway.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c4s_gui">
        <mxGeometry x="190" y="36" width="168" height="60" as="geometry" />
      </mxCell>

      <!-- External group -->
      <mxCell id="c4s_gext" value="External + sibling clusters" style="swimlane;startSize=26;rounded=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=12;fontStyle=1;" vertex="1" parent="c4s_band2">
        <mxGeometry x="830" y="325" width="700" height="230" as="geometry" />
      </mxCell>
      <mxCell id="c4s_x_gw" value="Vercel AI Gateway" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#666666;fontSize=11;" vertex="1" parent="c4s_gext">
        <mxGeometry x="12" y="36" width="160" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c4s_x_hs" value="hybridSearch + chunkText + embedTexts (C3)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#666666;fontSize=11;" vertex="1" parent="c4s_gext">
        <mxGeometry x="182" y="36" width="170" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c4s_x_sto" value="getStorage() adapters (C1)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#666666;fontSize=11;" vertex="1" parent="c4s_gext">
        <mxGeometry x="362" y="36" width="160" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c4s_x_pat" value="PAT auth + rate limit (C5)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#666666;fontSize=11;" vertex="1" parent="c4s_gext">
        <mxGeometry x="532" y="36" width="156" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c4s_x_cron" value="Vercel Cron 13:00 UTC" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#666666;fontSize=11;" vertex="1" parent="c4s_gext">
        <mxGeometry x="12" y="116" width="160" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c4s_x_aud" value="audit_log + workspace settings (C7)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#666666;fontSize=11;" vertex="1" parent="c4s_gext">
        <mxGeometry x="182" y="116" width="170" height="60" as="geometry" />
      </mxCell>

      <!-- Detailed edges -->
      <mxCell id="c4s_d1" value="resolveAiKey" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c4s_band2" source="c4s_groutes" target="c4s_n_res"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c4s_d2" value="resolveAiKey" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c4s_band2" source="c4s_gchat" target="c4s_n_res"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c4s_d3" value="resolveAiKey (no provider param)" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c4s_band2" source="c4s_gv1" target="c4s_n_res"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c4s_d4" value="ai_keys_decrypt RPC" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c4s_band2" source="c4s_n_res" target="c4s_n_krpc"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c4s_d5" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c4s_band2" source="c4s_n_gwc" target="c4s_n_gwo"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c4s_d6" value="save order/sort" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c4s_band2" source="c4s_n_gform" target="c4s_n_gwc"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c4s_d7" value="gateway options on every call" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c4s_band2" source="c4s_n_gwo" target="c4s_x_gw"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c4s_d8" value="RAG discovery" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c4s_band2" source="c4s_gchat" target="c4s_x_hs"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c4s_d9" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c4s_band2" source="c4s_gv1" target="c4s_x_hs"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c4s_d10" value="useTools" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c4s_band2" source="c4s_gchat" target="c4s_n_tools"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c4s_d11" value="read/write notes (authorKind agent)" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c4s_band2" source="c4s_n_tools" target="c4s_x_sto"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c4s_d12" value="ai.tool.* rows" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;dashed=1;" edge="1" parent="c4s_band2" source="c4s_n_tools" target="c4s_x_aud"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c4s_d13" value="recordUsage" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;dashed=1;" edge="1" parent="c4s_band2" source="c4s_groutes" target="c4s_n_met"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c4s_d14" value="recordUsage (LLM hook)" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;dashed=1;" edge="1" parent="c4s_band2" source="c4s_n_dgr" target="c4s_n_met"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c4s_d15" value="Bearer CRON_SECRET" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c4s_band2" source="c4s_x_cron" target="c4s_n_dgc"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c4s_d16" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c4s_band2" source="c4s_n_dgc" target="c4s_n_dgr"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c4s_d17" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c4s_band2" source="c4s_n_dga" target="c4s_n_dgr"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c4s_d18" value="upsert digests/date.md" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c4s_band2" source="c4s_n_dgr" target="c4s_x_sto"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c4s_d19" value="PAT verify + 60/min" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c4s_band2" source="c4s_gv1" target="c4s_x_pat"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c4s_d20" value="ai_keys_upsert RPC" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c4s_band2" source="c4s_n_ksa" target="c4s_n_krpc"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c4s_d21" value="decrypt → re-encrypt → verify" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;dashed=1;" edge="1" parent="c4s_band2" source="c4s_n_rot" target="c4s_n_krpc"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c4s_d22" value="daily / by-route / by-model rollups" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c4s_band2" source="c4s_n_setp" target="c4s_n_met"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c4s_d23" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c4s_band2" source="c4s_n_vch" target="c4s_n_chat"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c4s_d24" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c4s_band2" source="c4s_n_chatm" target="c4s_n_chst"><mxGeometry relative="1" as="geometry" /></mxCell>
    </root>
  </mxGraphModel>
</diagram>
<diagram id="c4-flows-page" name="C4 AI Platform — Flows">
  <mxGraphModel dx="800" dy="600" grid="0" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="2340" pageHeight="1200" math="0" shadow="0">
    <root>
      <mxCell id="0" />
      <mxCell id="1" parent="0" />

      <!-- ===================== SIMPLIFIED BAND ===================== -->
      <mxCell id="c4f_band1" value="SIMPLIFIED — multi-turn RAG chat, happy path" style="swimlane;startSize=28;rounded=1;fillColor=#ffffff;strokeColor=#666666;fontSize=15;fontStyle=1;" vertex="1" parent="1">
        <mxGeometry x="20" y="20" width="2280" height="230" as="geometry" />
      </mxCell>
      <mxCell id="c4f_f1" value="User sends message in VaultChat (Cmd+Enter)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="c4f_band1">
        <mxGeometry x="40" y="75" width="240" height="80" as="geometry" />
      </mxCell>
      <mxCell id="c4f_f2" value="POST /api/ai/chat&#10;(new turn + threadId)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="c4f_band1">
        <mxGeometry x="310" y="75" width="240" height="80" as="geometry" />
      </mxCell>
      <mxCell id="c4f_f3" value="Session auth + rate limit&#10;60/min, 10k/day" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="c4f_band1">
        <mxGeometry x="580" y="75" width="240" height="80" as="geometry" />
      </mxCell>
      <mxCell id="c4f_f4" value="hybridSearch top-8 on last user turn&#10;chunk 3500/250, cap 24" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=12;" vertex="1" parent="c4f_band1">
        <mxGeometry x="850" y="75" width="240" height="80" as="geometry" />
      </mxCell>
      <mxCell id="c4f_f5" value="Map: fast tier&#10;100-word summary per chunk" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=12;" vertex="1" parent="c4f_band1">
        <mxGeometry x="1120" y="75" width="240" height="80" as="geometry" />
      </mxCell>
      <mxCell id="c4f_f6" value="Reduce: smart tier over conversation + corpus&#10;optional tools, cap 6 steps" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=12;" vertex="1" parent="c4f_band1">
        <mxGeometry x="1390" y="75" width="240" height="80" as="geometry" />
      </mxCell>
      <mxCell id="c4f_f7" value="Persist user turns + reply&#10;to owned thread only" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=12;" vertex="1" parent="c4f_band1">
        <mxGeometry x="1660" y="75" width="240" height="80" as="geometry" />
      </mxCell>
      <mxCell id="c4f_f8" value="Reply with cited sources&#10;+ modelIds + key source" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="c4f_band1">
        <mxGeometry x="1930" y="75" width="240" height="80" as="geometry" />
      </mxCell>
      <mxCell id="c4f_fe1" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c4f_band1" source="c4f_f1" target="c4f_f2"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c4f_fe2" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c4f_band1" source="c4f_f2" target="c4f_f3"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c4f_fe3" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c4f_band1" source="c4f_f3" target="c4f_f4"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c4f_fe4" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c4f_band1" source="c4f_f4" target="c4f_f5"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c4f_fe5" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c4f_band1" source="c4f_f5" target="c4f_f6"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c4f_fe6" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c4f_band1" source="c4f_f6" target="c4f_f7"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c4f_fe7" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c4f_band1" source="c4f_f7" target="c4f_f8"><mxGeometry relative="1" as="geometry" /></mxCell>

      <!-- ===================== DETAILED BAND ===================== -->
      <mxCell id="c4f_band2" value="DETAILED — multi-turn RAG chat with tool loop, swimlane per actor, numbered steps + side effects" style="swimlane;startSize=28;rounded=1;fillColor=#ffffff;strokeColor=#666666;fontSize=15;fontStyle=1;" vertex="1" parent="1">
        <mxGeometry x="20" y="290" width="2280" height="870" as="geometry" />
      </mxCell>

      <mxCell id="c4f_lane_u" value="User / VaultChat client" style="swimlane;horizontal=0;startSize=30;rounded=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=12;fontStyle=1;" vertex="1" parent="c4f_band2">
        <mxGeometry x="20" y="40" width="2240" height="140" as="geometry" />
      </mxCell>
      <mxCell id="c4f_lane_r" value="/api/ai/chat route" style="swimlane;horizontal=0;startSize=30;rounded=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=12;fontStyle=1;" vertex="1" parent="c4f_band2">
        <mxGeometry x="20" y="180" width="2240" height="180" as="geometry" />
      </mxCell>
      <mxCell id="c4f_lane_l" value="AI core libs (resolver, gateway-opts)" style="swimlane;horizontal=0;startSize=30;rounded=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=12;fontStyle=1;" vertex="1" parent="c4f_band2">
        <mxGeometry x="20" y="360" width="2240" height="160" as="geometry" />
      </mxCell>
      <mxCell id="c4f_lane_g" value="Vercel AI Gateway" style="swimlane;horizontal=0;startSize=30;rounded=1;fillColor=#ffffff;strokeColor=#666666;fontSize=12;fontStyle=1;" vertex="1" parent="c4f_band2">
        <mxGeometry x="20" y="520" width="2240" height="140" as="geometry" />
      </mxCell>
      <mxCell id="c4f_lane_s" value="Storage + search + chat tables" style="swimlane;horizontal=0;startSize=30;rounded=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=12;fontStyle=1;" vertex="1" parent="c4f_band2">
        <mxGeometry x="20" y="660" width="2240" height="190" as="geometry" />
      </mxCell>

      <!-- Steps -->
      <mxCell id="c4f_s1" value="1. Send message, mint thread if none (title = first 60 chars)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c4f_lane_u">
        <mxGeometry x="50" y="30" width="190" height="80" as="geometry" />
      </mxCell>
      <mxCell id="c4f_s2" value="2. Zod validate + SaaS session auth (401) + checkRateLimit 60/min (429)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c4f_lane_r">
        <mxGeometry x="260" y="30" width="190" height="80" as="geometry" />
      </mxCell>
      <mxCell id="c4f_s3" value="3. Load owned thread history (local mode skips owner check)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c4f_lane_r">
        <mxGeometry x="470" y="30" width="190" height="80" as="geometry" />
      </mxCell>
      <mxCell id="c4f_s4" value="4. hybridSearch top-8 on last user turn → getNote → chunk 3500/250 (cap 24)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c4f_lane_s">
        <mxGeometry x="680" y="30" width="190" height="80" as="geometry" />
      </mxCell>
      <mxCell id="c4f_s5" value="5. resolveAiKey (byok → gateway master) + gatewayOpts (order/sort, HIPAA)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c4f_lane_l">
        <mxGeometry x="890" y="30" width="190" height="80" as="geometry" />
      </mxCell>
      <mxCell id="c4f_s6" value="6. Map: fast tier, 100-word summary per chunk (parallel)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=11;" vertex="1" parent="c4f_lane_g">
        <mxGeometry x="1100" y="30" width="190" height="80" as="geometry" />
      </mxCell>
      <mxCell id="c4f_s7" value="7. Reduce: smart tier, conversation + corpus system msg, tool loop stepCountIs(6)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=11;" vertex="1" parent="c4f_lane_g">
        <mxGeometry x="1310" y="30" width="190" height="80" as="geometry" />
      </mxCell>
      <mxCell id="c4f_s8" value="8. Tool calls read_note / search_notes / create_note / update_note via getStorage()" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c4f_lane_s">
        <mxGeometry x="1520" y="30" width="190" height="80" as="geometry" />
      </mxCell>
      <mxCell id="c4f_s9" value="9. Append user turns + assistant reply (sources jsonb) to owned thread" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c4f_lane_s">
        <mxGeometry x="1730" y="30" width="190" height="80" as="geometry" />
      </mxCell>
      <mxCell id="c4f_s10" value="10. Render reply + cited note links + model / key-source footer, refresh thread list" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c4f_lane_u">
        <mxGeometry x="1940" y="30" width="190" height="80" as="geometry" />
      </mxCell>

      <!-- Side-effect annotations -->
      <mxCell id="c4f_a1" value="Side effect gap: recordUsage is NOT called on chat routes — smart-tier chat is invisible in usage cards" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=10;dashed=1;" vertex="1" parent="c4f_lane_r">
        <mxGeometry x="700" y="120" width="330" height="45" as="geometry" />
      </mxCell>
      <mxCell id="c4f_a2" value="Error paths: 503 when no key resolves (setup hint), 502 when map or reduce fails" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=10;dashed=1;" vertex="1" parent="c4f_lane_l">
        <mxGeometry x="1120" y="118" width="330" height="35" as="geometry" />
      </mxCell>
      <mxCell id="c4f_a3" value="Side effects on writes: authorKind 'agent' version rows (both modes) + SaaS audit_log ai.tool.* via service role. Writes require useTools AND allowWrites. Persist failure only warns — response never sinks. Intermediate tool turns are never persisted." style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=10;dashed=1;" vertex="1" parent="c4f_lane_s">
        <mxGeometry x="1520" y="118" width="520" height="62" as="geometry" />
      </mxCell>

      <!-- Sequence edges -->
      <mxCell id="c4f_de1" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c4f_band2" source="c4f_s1" target="c4f_s2"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c4f_de2" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c4f_band2" source="c4f_s2" target="c4f_s3"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c4f_de3" value="history prepended" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="c4f_band2" source="c4f_s3" target="c4f_s4"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c4f_de4" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c4f_band2" source="c4f_s4" target="c4f_s5"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c4f_de5" value="Bearer key header" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="c4f_band2" source="c4f_s5" target="c4f_s6"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c4f_de6" value="summaries corpus" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="c4f_band2" source="c4f_s6" target="c4f_s7"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c4f_de7" value="tool loop (up to 6 steps)" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;dashed=1;" edge="1" parent="c4f_band2" source="c4f_s7" target="c4f_s8"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c4f_de8" value="final assistant text" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="c4f_band2" source="c4f_s8" target="c4f_s9"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c4f_de9" value="JSON response" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="c4f_band2" source="c4f_s9" target="c4f_s10"><mxGeometry relative="1" as="geometry" /></mxCell>
    </root>
  </mxGraphModel>
</diagram>
<diagram id="C5_SYSTEM_AGENT_SURFACE" name="C5 Agent-Native Surface (MCP) — System">
  <mxGraphModel dx="800" dy="600" grid="0" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1600" pageHeight="1200" math="0" shadow="0">
    <root>
      <mxCell id="0" />
      <mxCell id="1" parent="0" />

      <!-- ============ SIMPLIFIED band ============ -->
      <mxCell id="c5s_simp" value="SIMPLIFIED — agent surface at a glance" style="swimlane;startSize=28;rounded=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=14;fontStyle=1;" vertex="1" parent="1">
        <mxGeometry x="20" y="20" width="1560" height="310" as="geometry" />
      </mxCell>
      <mxCell id="c5s_s_agent" value="External AI agent&#10;Claude Code / Cursor / Codex&#10;Gemini / OpenClaw" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=13;" vertex="1" parent="c5s_simp">
        <mxGeometry x="40" y="110" width="230" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c5s_s_stdio" value="stdio binary&#10;bin/eli-mcp.mjs (local only)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=13;" vertex="1" parent="c5s_simp">
        <mxGeometry x="350" y="50" width="210" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c5s_s_http" value="HTTP/SSE route&#10;/api/mcp (both modes)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=13;" vertex="1" parent="c5s_simp">
        <mxGeometry x="350" y="190" width="210" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c5s_s_patui" value="PAT lifecycle UI&#10;Settings → Developers (SaaS)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=13;" vertex="1" parent="c5s_simp">
        <mxGeometry x="640" y="60" width="230" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c5s_s_auth" value="Auth + rate limit&#10;PAT / JWT / MCP_LOCAL_TOKEN" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=13;" vertex="1" parent="c5s_simp">
        <mxGeometry x="640" y="190" width="230" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c5s_s_tools" value="16 MCP tools&#10;lib/mcp/tools/*" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=13;" vertex="1" parent="c5s_simp">
        <mxGeometry x="950" y="115" width="200" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c5s_s_storage" value="StorageAdapter (C1)&#10;SQLite + files / Supabase RLS" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=13;" vertex="1" parent="c5s_simp">
        <mxGeometry x="1250" y="115" width="250" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c5s_s_wizard" value="Setup wizard&#10;writes 5 agent config files" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=13;" vertex="1" parent="c5s_simp">
        <mxGeometry x="40" y="220" width="230" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c5s_se1" value="JSON-RPC stdin/stdout" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c5s_simp" source="c5s_s_agent" target="c5s_s_stdio">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c5s_se2" value="HTTP/SSE + Bearer" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c5s_simp" source="c5s_s_agent" target="c5s_s_http">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c5s_se3" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c5s_simp" source="c5s_s_http" target="c5s_s_auth">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c5s_se4" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c5s_simp" source="c5s_s_auth" target="c5s_s_tools">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c5s_se5" value="no per-call auth" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c5s_simp" source="c5s_s_stdio" target="c5s_s_tools">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c5s_se6" value="every tool call" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c5s_simp" source="c5s_s_tools" target="c5s_s_storage">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c5s_se7" value="registers eli entry" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;dashed=1;" edge="1" parent="c5s_simp" source="c5s_s_wizard" target="c5s_s_agent">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c5s_se8" value="mints eli_pat_*" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;dashed=1;" edge="1" parent="c5s_simp" source="c5s_s_patui" target="c5s_s_auth">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>

      <!-- ============ DETAILED band ============ -->
      <mxCell id="c5s_det" value="DETAILED — full component graph" style="swimlane;startSize=28;rounded=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=14;fontStyle=1;" vertex="1" parent="1">
        <mxGeometry x="20" y="350" width="1560" height="790" as="geometry" />
      </mxCell>

      <mxCell id="c5s_d_agent" value="External agents (Claude Code / Cursor / Codex / Gemini / OpenClaw) + browser extension" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="c5s_det">
        <mxGeometry x="20" y="40" width="320" height="55" as="geometry" />
      </mxCell>

      <mxCell id="c5s_g_trans" value="Transports" style="swimlane;startSize=28;rounded=1;fillColor=#fff8f0;strokeColor=#d79b00;fontSize=12;fontStyle=1;" vertex="1" parent="c5s_det">
        <mxGeometry x="20" y="115" width="320" height="360" as="geometry" />
      </mxCell>
      <mxCell id="c5s_d_bin" value="bin shim&#10;bin/eli-mcp.mjs" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=12;" vertex="1" parent="c5s_g_trans">
        <mxGeometry x="20" y="40" width="280" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c5s_d_stdio" value="runStdioServer&#10;lib/mcp/stdio.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=12;" vertex="1" parent="c5s_g_trans">
        <mxGeometry x="20" y="110" width="280" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c5s_d_esb" value="esbuild bundle (prepack)&#10;scripts/build-mcp-bin.mjs" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=12;" vertex="1" parent="c5s_g_trans">
        <mxGeometry x="20" y="180" width="280" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c5s_d_route" value="HTTP route (mcp-handler wrap)&#10;app/api/mcp/[transport]/route.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=12;" vertex="1" parent="c5s_g_trans">
        <mxGeometry x="20" y="260" width="280" height="60" as="geometry" />
      </mxCell>

      <mxCell id="c5s_g_core" value="Server core + 16 tools" style="swimlane;startSize=28;rounded=1;fillColor=#f2fbf0;strokeColor=#82b366;fontSize=12;fontStyle=1;" vertex="1" parent="c5s_det">
        <mxGeometry x="370" y="40" width="560" height="490" as="geometry" />
      </mxCell>
      <mxCell id="c5s_d_srv" value="createMcpServer + registerTools&#10;lib/mcp/server.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="c5s_g_core">
        <mxGeometry x="20" y="40" width="250" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c5s_d_ctx" value="McpContext providers&#10;lib/mcp/context.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="c5s_g_core">
        <mxGeometry x="20" y="115" width="250" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c5s_d_fmt" value="serializeNote / formatting&#10;lib/mcp/format.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="c5s_g_core">
        <mxGeometry x="20" y="190" width="250" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c5s_d_tread" value="read.ts — list_artifacts,&#10;read_artifact, list_versions" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="c5s_g_core">
        <mxGeometry x="290" y="40" width="250" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c5s_d_twrite" value="write.ts — create / edit /&#10;rename / delete_artifact" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="c5s_g_core">
        <mxGeometry x="290" y="105" width="250" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c5s_d_tappend" value="append.ts — append_to_artifact" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="c5s_g_core">
        <mxGeometry x="290" y="170" width="250" height="45" as="geometry" />
      </mxCell>
      <mxCell id="c5s_d_tsearch" value="search.ts — search&#10;(fts / semantic / hybrid)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="c5s_g_core">
        <mxGeometry x="290" y="225" width="250" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c5s_d_tdiff" value="diff.ts — get_diff, restore_version" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="c5s_g_core">
        <mxGeometry x="290" y="290" width="250" height="45" as="geometry" />
      </mxCell>
      <mxCell id="c5s_d_tmisc" value="comment.ts / daily.ts / template.ts&#10;add_comment, daily_note, apply_template" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="c5s_g_core">
        <mxGeometry x="290" y="345" width="250" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c5s_d_tmem" value="memory.ts — memory_search,&#10;memory_get (.openclaw/)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="c5s_g_core">
        <mxGeometry x="290" y="410" width="250" height="55" as="geometry" />
      </mxCell>

      <mxCell id="c5s_g_auth" value="Auth + credentials" style="swimlane;startSize=28;rounded=1;fillColor=#faf5fd;strokeColor=#9673a6;fontSize=12;fontStyle=1;" vertex="1" parent="c5s_det">
        <mxGeometry x="960" y="40" width="290" height="530" as="geometry" />
      </mxCell>
      <mxCell id="c5s_d_auth" value="authForMcp / authForLocal&#10;lib/mcp/auth.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=12;" vertex="1" parent="c5s_g_auth">
        <mxGeometry x="20" y="40" width="250" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c5s_d_rl" value="rate limiter 60/min + 10k/day&#10;lib/mcp/ratelimit.ts (in-memory)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=12;" vertex="1" parent="c5s_g_auth">
        <mxGeometry x="20" y="110" width="250" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c5s_d_patlib" value="PAT primitives (eli_pat_*)&#10;lib/auth/pat.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=12;" vertex="1" parent="c5s_g_auth">
        <mxGeometry x="20" y="180" width="250" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c5s_d_patact" value="PAT Server Actions&#10;app/_actions/pats.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=12;" vertex="1" parent="c5s_g_auth">
        <mxGeometry x="20" y="250" width="250" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c5s_d_patui" value="Developers page + dialogs&#10;components/pat/*" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=12;" vertex="1" parent="c5s_g_auth">
        <mxGeometry x="20" y="320" width="250" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c5s_d_pairlib" value="pairing tokens (eli_pair_*)&#10;lib/pair/extension.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=12;" vertex="1" parent="c5s_g_auth">
        <mxGeometry x="20" y="390" width="250" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c5s_d_pairui" value="/pair page + /api/pair&#10;components/pair-approval.tsx" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=12;" vertex="1" parent="c5s_g_auth">
        <mxGeometry x="20" y="460" width="250" height="55" as="geometry" />
      </mxCell>

      <mxCell id="c5s_g_setup" value="Setup + guidance" style="swimlane;startSize=28;rounded=1;fillColor=#fffbef;strokeColor=#d6b656;fontSize=12;fontStyle=1;" vertex="1" parent="c5s_det">
        <mxGeometry x="1280" y="40" width="260" height="400" as="geometry" />
      </mxCell>
      <mxCell id="c5s_d_dlg" value="setup dialog + palette entry&#10;components/setup/*" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=12;" vertex="1" parent="c5s_g_setup">
        <mxGeometry x="15" y="40" width="230" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c5s_d_act" value="setupExternalToolsAction&#10;app/_actions/setup.ts (local only)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=12;" vertex="1" parent="c5s_g_setup">
        <mxGeometry x="15" y="110" width="230" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c5s_d_wr" value="5 config writers&#10;lib/setup/* (JSON + Codex TOML)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=12;" vertex="1" parent="c5s_g_setup">
        <mxGeometry x="15" y="180" width="230" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c5s_d_agmd" value="AGENTS.md library (UNWIRED)&#10;lib/agents-md/*" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f8cecc;strokeColor=#b85450;fontSize=12;" vertex="1" parent="c5s_g_setup">
        <mxGeometry x="15" y="250" width="230" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c5s_d_oclaw" value="OpenClaw compat&#10;lib/openclaw/format.ts + scaffold.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=12;" vertex="1" parent="c5s_g_setup">
        <mxGeometry x="15" y="320" width="230" height="55" as="geometry" />
      </mxCell>

      <mxCell id="c5s_g_ext" value="Neighbouring clusters + stores" style="swimlane;startSize=28;rounded=1;fillColor=#fafafa;strokeColor=#666666;fontSize=12;fontStyle=1;" vertex="1" parent="c5s_det">
        <mxGeometry x="20" y="600" width="1520" height="170" as="geometry" />
      </mxCell>
      <mxCell id="c5s_d_storage" value="StorageAdapter (C1)&#10;Local / Supabase" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=12;" vertex="1" parent="c5s_g_ext">
        <mxGeometry x="20" y="45" width="225" height="80" as="geometry" />
      </mxCell>
      <mxCell id="c5s_d_hybrid" value="hybridSearch (C3)&#10;lib/search/hybrid.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=12;" vertex="1" parent="c5s_g_ext">
        <mxGeometry x="270" y="45" width="225" height="80" as="geometry" />
      </mxCell>
      <mxCell id="c5s_d_pats" value="personal_access_tokens&#10;table under RLS (C7)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=12;" vertex="1" parent="c5s_g_ext">
        <mxGeometry x="520" y="45" width="225" height="80" as="geometry" />
      </mxCell>
      <mxCell id="c5s_d_cfg" value="~/.eli/config.json&#10;pairings[] (hashed)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=12;" vertex="1" parent="c5s_g_ext">
        <mxGeometry x="770" y="45" width="225" height="80" as="geometry" />
      </mxCell>
      <mxCell id="c5s_d_acfg" value="agent config files&#10;~/.claude ~/.cursor ~/.codex&#10;~/.gemini ~/.openclaw" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=12;" vertex="1" parent="c5s_g_ext">
        <mxGeometry x="1020" y="45" width="225" height="80" as="geometry" />
      </mxCell>
      <mxCell id="c5s_d_clip" value="/api/clip (C8)&#10;consumes eli_pair_* + PATs" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=12;" vertex="1" parent="c5s_g_ext">
        <mxGeometry x="1270" y="45" width="225" height="80" as="geometry" />
      </mxCell>

      <!-- Detailed edges -->
      <mxCell id="c5s_de1" value="stdio spawn" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c5s_det" source="c5s_d_agent" target="c5s_d_bin">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c5s_de2" value="HTTP + Bearer" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c5s_det" source="c5s_d_agent" target="c5s_d_route">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c5s_de3" value="bundles" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;dashed=1;" edge="1" parent="c5s_det" source="c5s_d_esb" target="c5s_d_bin">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c5s_de4" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c5s_det" source="c5s_d_bin" target="c5s_d_stdio">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c5s_de5" value="staticContext, agentName pinned" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c5s_det" source="c5s_d_stdio" target="c5s_d_srv">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c5s_de6" value="withMcpAuth (mode-conditional)" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c5s_det" source="c5s_d_route" target="c5s_d_auth">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c5s_de7" value="after auth" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c5s_det" source="c5s_d_auth" target="c5s_d_rl">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c5s_de8" value="service-role prefix lookup" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c5s_det" source="c5s_d_auth" target="c5s_d_pats">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c5s_de9" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c5s_det" source="c5s_d_route" target="c5s_d_srv">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c5s_de10" value="registers 16 tools" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c5s_det" source="c5s_d_srv" target="c5s_d_tread">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c5s_de11" value="getContext per call" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c5s_det" source="c5s_d_ctx" target="c5s_d_storage">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c5s_de12" value="kind semantic / hybrid" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c5s_det" source="c5s_d_tsearch" target="c5s_d_hybrid">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c5s_de13" value="pathInScope helpers" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;dashed=1;" edge="1" parent="c5s_det" source="c5s_d_tmem" target="c5s_d_oclaw">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c5s_de14" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c5s_det" source="c5s_d_patui" target="c5s_d_patact">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c5s_de15" value="RLS insert / revoke / rotate" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c5s_det" source="c5s_d_patact" target="c5s_d_pats">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c5s_de16" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c5s_det" source="c5s_d_pairui" target="c5s_d_pairlib">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c5s_de17" value="sha256 hash persisted" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c5s_det" source="c5s_d_pairlib" target="c5s_d_cfg">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c5s_de18" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c5s_det" source="c5s_d_dlg" target="c5s_d_act">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c5s_de19" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c5s_det" source="c5s_d_act" target="c5s_d_wr">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c5s_de20" value="atomic tmp + rename" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c5s_det" source="c5s_d_wr" target="c5s_d_acfg">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c5s_de21" value="verifyPairingToken" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;dashed=1;" edge="1" parent="c5s_det" source="c5s_d_clip" target="c5s_d_pairlib">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c5s_de22" value="handshake mentions AGENTS.md" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;dashed=1;" edge="1" parent="c5s_det" source="c5s_d_srv" target="c5s_d_agmd">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c5s_de23" value="parseBearer / verifyHash" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;dashed=1;" edge="1" parent="c5s_det" source="c5s_d_auth" target="c5s_d_patlib">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
    </root>
  </mxGraphModel>
</diagram>
<diagram id="C5_FLOWS_AGENT_SURFACE" name="C5 Agent-Native Surface (MCP) — Flows">
  <mxGraphModel dx="800" dy="600" grid="0" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1600" pageHeight="1200" math="0" shadow="0">
    <root>
      <mxCell id="0" />
      <mxCell id="1" parent="0" />

      <!-- ============ SIMPLIFIED band ============ -->
      <mxCell id="c5f_simp" value="SIMPLIFIED — happy path: agent edits a note over stdio" style="swimlane;startSize=28;rounded=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=14;fontStyle=1;" vertex="1" parent="1">
        <mxGeometry x="20" y="20" width="1560" height="240" as="geometry" />
      </mxCell>
      <mxCell id="c5f_s1" value="Claude Code&#10;(MCP client)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="c5f_simp">
        <mxGeometry x="40" y="85" width="190" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c5f_s2" value="spawn eli-mcp (stdio)&#10;LocalAdapter pinned at boot" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=12;" vertex="1" parent="c5f_simp">
        <mxGeometry x="255" y="85" width="190" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c5f_s3" value="tools/call&#10;edit_artifact" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="c5f_simp">
        <mxGeometry x="470" y="85" width="190" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c5f_s4" value="storage.updateNote&#10;authorKind 'agent' + agentName" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="c5f_simp">
        <mxGeometry x="685" y="85" width="190" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c5f_s5" value="atomic .md write + SQLite TX&#10;+ agent-attributed version row" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=12;" vertex="1" parent="c5f_simp">
        <mxGeometry x="900" y="85" width="190" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c5f_s6" value="SSE note:updated to tabs&#10;+ debounced git auto-commit" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=12;" vertex="1" parent="c5f_simp">
        <mxGeometry x="1115" y="85" width="190" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c5f_s7" value="embed queue NOT fired&#10;(needs UI save or backfill)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f8cecc;strokeColor=#b85450;fontSize=12;" vertex="1" parent="c5f_simp">
        <mxGeometry x="1330" y="85" width="190" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c5f_se1" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c5f_simp" source="c5f_s1" target="c5f_s2">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c5f_se2" value="JSON-RPC" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c5f_simp" source="c5f_s2" target="c5f_s3">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c5f_se3" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c5f_simp" source="c5f_s3" target="c5f_s4">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c5f_se4" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c5f_simp" source="c5f_s4" target="c5f_s5">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c5f_se5" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c5f_simp" source="c5f_s5" target="c5f_s6">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c5f_se6" value="gap" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;dashed=1;" edge="1" parent="c5f_simp" source="c5f_s5" target="c5f_s7">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>

      <!-- ============ DETAILED band ============ -->
      <mxCell id="c5f_det" value="DETAILED — Flow A: stdio edit (left) / Flow B: SaaS HTTP tool call with PAT (right)" style="swimlane;startSize=28;rounded=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=14;fontStyle=1;" vertex="1" parent="1">
        <mxGeometry x="20" y="290" width="1560" height="880" as="geometry" />
      </mxCell>

      <mxCell id="c5f_l_agent" value="Agent (MCP client)" style="swimlane;horizontal=0;startSize=30;rounded=1;fillColor=#f0f6ff;strokeColor=#6c8ebf;fontSize=12;fontStyle=1;" vertex="1" parent="c5f_det">
        <mxGeometry x="10" y="40" width="1540" height="130" as="geometry" />
      </mxCell>
      <mxCell id="c5f_ta" value="FLOW A — stdio (local)" style="text;html=1;fillColor=none;strokeColor=none;fontSize=12;fontStyle=1;" vertex="1" parent="c5f_l_agent">
        <mxGeometry x="50" y="8" width="250" height="22" as="geometry" />
      </mxCell>
      <mxCell id="c5f_tb" value="FLOW B — HTTP (SaaS, PAT)" style="text;html=1;fillColor=none;strokeColor=none;fontSize=12;fontStyle=1;" vertex="1" parent="c5f_l_agent">
        <mxGeometry x="830" y="8" width="280" height="22" as="geometry" />
      </mxCell>
      <mxCell id="c5f_a1" value="A1. spawn node bin/eli-mcp.mjs&#10;env VAULT_PATH (+ MCP_LOCAL_TOKEN)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="c5f_l_agent">
        <mxGeometry x="50" y="45" width="260" height="65" as="geometry" />
      </mxCell>
      <mxCell id="c5f_a2" value="A2. tools/call edit_artifact&#10;{id, body_md, message}" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="c5f_l_agent">
        <mxGeometry x="360" y="45" width="230" height="65" as="geometry" />
      </mxCell>
      <mxCell id="c5f_b1" value="B1. POST /api/mcp/mcp&#10;Bearer eli_pat_&lt;prefix&gt;_&lt;secret&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="c5f_l_agent">
        <mxGeometry x="830" y="45" width="260" height="65" as="geometry" />
      </mxCell>

      <mxCell id="c5f_l_auth" value="Transport / Auth" style="swimlane;horizontal=0;startSize=30;rounded=1;fillColor=#fff8f0;strokeColor=#d79b00;fontSize=12;fontStyle=1;" vertex="1" parent="c5f_det">
        <mxGeometry x="10" y="175" width="1540" height="130" as="geometry" />
      </mxCell>
      <mxCell id="c5f_a3" value="A3. runStdioServer: ELI_MODE=local,&#10;staticContext, agentName eli-mcp:local[-token],&#10;no per-call auth or rate limit (OS boundary)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=12;" vertex="1" parent="c5f_l_auth">
        <mxGeometry x="50" y="30" width="310" height="85" as="geometry" />
      </mxCell>
      <mxCell id="c5f_b2" value="B2. authForMcp: parseBearer, service-role&#10;prefix lookup, sha256 + timingSafeEqual,&#10;reject revoked / expired" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=12;" vertex="1" parent="c5f_l_auth">
        <mxGeometry x="830" y="30" width="300" height="85" as="geometry" />
      </mxCell>
      <mxCell id="c5f_b3" value="B3. checkRateLimit 60/min + 10k/day&#10;(in-memory, keyed patId) — over budget&#10;throws 'rate_limited' + retryAfterMs" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=12;" vertex="1" parent="c5f_l_auth">
        <mxGeometry x="1180" y="30" width="300" height="85" as="geometry" />
      </mxCell>

      <mxCell id="c5f_l_tool" value="Tool + Context" style="swimlane;horizontal=0;startSize=30;rounded=1;fillColor=#f2fbf0;strokeColor=#82b366;fontSize=12;fontStyle=1;" vertex="1" parent="c5f_det">
        <mxGeometry x="10" y="310" width="1540" height="130" as="geometry" />
      </mxCell>
      <mxCell id="c5f_a4" value="A4. edit handler: updateNote(patch,&#10;{authorKind:'agent', agentName, message})" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="c5f_l_tool">
        <mxGeometry x="50" y="30" width="310" height="80" as="geometry" />
      </mxCell>
      <mxCell id="c5f_b4" value="B4. GAP: defaultMcpContextProvider takes no&#10;args and never reads the PAT AuthInfo&#10;(lib/mcp/context.ts:79-91)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f8cecc;strokeColor=#b85450;fontSize=12;" vertex="1" parent="c5f_l_tool">
        <mxGeometry x="950" y="30" width="320" height="80" as="geometry" />
      </mxCell>

      <mxCell id="c5f_l_stor" value="Storage adapter" style="swimlane;horizontal=0;startSize=30;rounded=1;fillColor=#fafafa;strokeColor=#666666;fontSize=12;fontStyle=1;" vertex="1" parent="c5f_det">
        <mxGeometry x="10" y="445" width="1540" height="130" as="geometry" />
      </mxCell>
      <mxCell id="c5f_a5" value="A5. LocalAdapter: optional conflict snapshot,&#10;materialise title / wikilinks / tags / hash,&#10;atomic .md write (tmp + rename, echo marked)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=12;" vertex="1" parent="c5f_l_stor">
        <mxGeometry x="50" y="25" width="330" height="90" as="geometry" />
      </mxCell>
      <mxCell id="c5f_b5" value="B5. SupabaseAdapter.forActiveWorkspace&#10;needs session + eli_ws cookies —&#10;Bearer-only PAT call FAILS here&#10;('[eli/saas] No authenticated user')" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f8cecc;strokeColor=#b85450;fontSize=12;" vertex="1" parent="c5f_l_stor">
        <mxGeometry x="950" y="20" width="320" height="95" as="geometry" />
      </mxCell>

      <mxCell id="c5f_l_db" value="Index / DB / files" style="swimlane;horizontal=0;startSize=30;rounded=1;fillColor=#fffbef;strokeColor=#d6b656;fontSize=12;fontStyle=1;" vertex="1" parent="c5f_det">
        <mxGeometry x="10" y="580" width="1540" height="130" as="geometry" />
      </mxCell>
      <mxCell id="c5f_a6" value="A6. one SQLite TX: UPDATE notes, rewrite&#10;note_tags / note_links, INSERT agent-attributed&#10;versions row (FTS5 kept fresh by triggers)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=12;" vertex="1" parent="c5f_l_db">
        <mxGeometry x="50" y="25" width="330" height="90" as="geometry" />
      </mxCell>
      <mxCell id="c5f_b6" value="B6. (cookie-present browser case only)&#10;notes_save RPC under RLS — role&#10;enforcement happens in Postgres (ADR-0004)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=12;" vertex="1" parent="c5f_l_db">
        <mxGeometry x="950" y="25" width="320" height="90" as="geometry" />
      </mxCell>

      <mxCell id="c5f_l_fx" value="Side effects / telemetry" style="swimlane;horizontal=0;startSize=30;rounded=1;fillColor=#faf5fd;strokeColor=#9673a6;fontSize=12;fontStyle=1;" vertex="1" parent="c5f_det">
        <mxGeometry x="10" y="715" width="1540" height="130" as="geometry" />
      </mxCell>
      <mxCell id="c5f_a7" value="A7. SSE note:updated to open tabs (cross-process&#10;via chokidar rescan) + debounced git commit&#10;attributed to the agent" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=12;" vertex="1" parent="c5f_l_fx">
        <mxGeometry x="50" y="25" width="330" height="90" as="geometry" />
      </mxCell>
      <mxCell id="c5f_a8" value="A8. NOT fired: scheduleEmbed —&#10;semantic index waits for a UI save&#10;or pnpm embed:backfill" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f8cecc;strokeColor=#b85450;fontSize=12;" vertex="1" parent="c5f_l_fx">
        <mxGeometry x="430" y="25" width="280" height="90" as="geometry" />
      </mxCell>
      <mxCell id="c5f_b7" value="B7. PAT last_used_at telemetry only —&#10;no audit_log row for MCP tool calls&#10;(trail = versions rows + git commits)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=12;" vertex="1" parent="c5f_l_fx">
        <mxGeometry x="950" y="25" width="320" height="90" as="geometry" />
      </mxCell>

      <!-- Flow A edges -->
      <mxCell id="c5f_ea1" value="boot" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c5f_det" source="c5f_a1" target="c5f_a3">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c5f_ea2" value="handshake ready" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;dashed=1;" edge="1" parent="c5f_det" source="c5f_a3" target="c5f_a2">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c5f_ea3" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c5f_det" source="c5f_a2" target="c5f_a4">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c5f_ea4" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c5f_det" source="c5f_a4" target="c5f_a5">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c5f_ea5" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c5f_det" source="c5f_a5" target="c5f_a6">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c5f_ea6" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c5f_det" source="c5f_a6" target="c5f_a7">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c5f_ea7" value="gap" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;dashed=1;" edge="1" parent="c5f_det" source="c5f_a6" target="c5f_a8">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>

      <!-- Flow B edges -->
      <mxCell id="c5f_eb1" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c5f_det" source="c5f_b1" target="c5f_b2">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c5f_eb2" value="auth ok" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c5f_det" source="c5f_b2" target="c5f_b3">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c5f_eb3" value="dispatch tools/call" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c5f_det" source="c5f_b3" target="c5f_b4">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c5f_eb4" value="getStorage()" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c5f_det" source="c5f_b4" target="c5f_b5">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c5f_eb5" value="cookies present" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c5f_det" source="c5f_b5" target="c5f_b6">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c5f_eb6" value="fire-and-forget" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;dashed=1;" edge="1" parent="c5f_det" source="c5f_b2" target="c5f_b7">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
    </root>
  </mxGraphModel>
</diagram>
<diagram id="c6-system" name="C6 Versioning, History &amp; Recovery — System">
  <mxGraphModel dx="800" dy="600" grid="0" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1600" pageHeight="1200" math="0" shadow="0">
    <root>
      <mxCell id="0" />
      <mxCell id="1" parent="0" />

      <!-- ===================== SIMPLIFIED band ===================== -->
      <mxCell id="c6s_simp" value="SIMPLIFIED — C6 in one glance" style="swimlane;startSize=28;rounded=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=14;fontStyle=1;" vertex="1" parent="1">
        <mxGeometry x="20" y="20" width="1540" height="280" as="geometry" />
      </mxCell>
      <mxCell id="c6s_s1" value="Note saves&#10;(user / agent / clipper)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=13;" vertex="1" parent="c6s_simp">
        <mxGeometry x="30" y="60" width="190" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c6s_s2" value="versions table (append-only)&#10;SQLite / Postgres" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=13;" vertex="1" parent="c6s_simp">
        <mxGeometry x="290" y="60" width="200" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c6s_s3" value="Diff pages + DiffView&#10;/v/diff · /w/slug/diff" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=13;" vertex="1" parent="c6s_simp">
        <mxGeometry x="560" y="60" width="210" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c6s_s4" value="MCP get_diff /&#10;restore_version" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=13;" vertex="1" parent="c6s_simp">
        <mxGeometry x="830" y="60" width="200" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c6s_s5" value="Debounced commit loop&#10;(30s, local only)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=13;" vertex="1" parent="c6s_simp">
        <mxGeometry x="290" y="170" width="200" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c6s_s6" value="Vault .git repo&#10;(cold storage)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=13;" vertex="1" parent="c6s_simp">
        <mxGeometry x="560" y="170" width="180" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c6s_s7" value="Trash&#10;.eli/trash / trashed_at" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=13;" vertex="1" parent="c6s_simp">
        <mxGeometry x="830" y="170" width="200" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c6s_s8" value="30-day auto-prune cron&#10;(04:00 UTC)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=13;" vertex="1" parent="c6s_simp">
        <mxGeometry x="1100" y="170" width="210" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c6s_e1" value="every save" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c6s_s1" target="c6s_s2"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6s_e2" value="listVersions / diffVersions" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c6s_s2" target="c6s_s3"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6s_e3" value="same store" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c6s_s2" target="c6s_s4"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6s_e4" value="local mode only" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c6s_s1" target="c6s_s5"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6s_e5" value="one commit per flush" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c6s_s5" target="c6s_s6"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6s_e6" value="soft delete" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;dashed=1;" edge="1" parent="1" source="c6s_s3" target="c6s_s7"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6s_e7" value="updatedAt older than 30d" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c6s_s7" target="c6s_s8"><mxGeometry relative="1" as="geometry" /></mxCell>

      <!-- ===================== DETAILED band ===================== -->
      <mxCell id="c6s_det" value="DETAILED — full component graph (two independent layers + recovery)" style="swimlane;startSize=28;rounded=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=14;fontStyle=1;" vertex="1" parent="1">
        <mxGeometry x="20" y="330" width="1540" height="850" as="geometry" />
      </mxCell>

      <!-- Version store -->
      <mxCell id="c6s_g1" value="Version store (C1 boundary)" style="swimlane;startSize=26;rounded=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;fontStyle=1;" vertex="1" parent="c6s_det">
        <mxGeometry x="20" y="45" width="350" height="360" as="geometry" />
      </mxCell>
      <mxCell id="c6s_g1n1" value="LocalAdapter writes&#10;lib/storage/local/writes.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c6s_g1">
        <mxGeometry x="20" y="40" width="310" height="50" as="geometry" />
      </mxCell>
      <mxCell id="c6s_g1n2" value="notes_save RPC + conflict snapshot&#10;lib/storage/supabase/writes.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c6s_g1">
        <mxGeometry x="20" y="100" width="310" height="50" as="geometry" />
      </mxCell>
      <mxCell id="c6s_g1n3" value="versions table (append-only)&#10;SQLite / Postgres" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=11;fontStyle=1;" vertex="1" parent="c6s_g1">
        <mxGeometry x="20" y="165" width="310" height="50" as="geometry" />
      </mxCell>
      <mxCell id="c6s_g1n4" value="listVersions ordering (createdAt DESC, id DESC)&#10;lib/storage/local/versions.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c6s_g1">
        <mxGeometry x="20" y="230" width="310" height="50" as="geometry" />
      </mxCell>
      <mxCell id="c6s_g1n5" value="version reads (RLS-gated)&#10;lib/storage/supabase/queries.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c6s_g1">
        <mxGeometry x="20" y="295" width="310" height="50" as="geometry" />
      </mxCell>

      <!-- Diff & restore UI -->
      <mxCell id="c6s_g2" value="Diff &amp; restore UI (reads versions table only — never git)" style="swimlane;startSize=26;rounded=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=12;fontStyle=1;" vertex="1" parent="c6s_det">
        <mxGeometry x="400" y="45" width="560" height="360" as="geometry" />
      </mxCell>
      <mxCell id="c6s_g2n1" value="History card (Compare links)&#10;components/inspector/properties-panel.tsx" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c6s_g2">
        <mxGeometry x="20" y="40" width="250" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c6s_g2n2" value="Local diff page&#10;app/(local)/v/diff/[...path]/page.tsx" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c6s_g2">
        <mxGeometry x="290" y="40" width="250" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c6s_g2n3" value="SaaS diff page&#10;app/(saas)/.../w/[workspace]/diff/[...path]" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c6s_g2">
        <mxGeometry x="290" y="105" width="250" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c6s_g2n4" value="VersionPicker (From/To selects)&#10;components/diff/version-picker.tsx" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c6s_g2">
        <mxGeometry x="20" y="105" width="250" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c6s_g2n5" value="DiffView (section cards, hunks, restore)&#10;components/diff/diff-view.tsx" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c6s_g2">
        <mxGeometry x="20" y="170" width="250" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c6s_g2n6" value="diffSections (diff-match-patch, section-anchored)&#10;lib/storage/helpers/section-diff.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c6s_g2">
        <mxGeometry x="290" y="170" width="250" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c6s_g2n7" value="restoreSectionAction&#10;app/_actions/diff.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c6s_g2">
        <mxGeometry x="20" y="235" width="250" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c6s_g2n8" value="replaceSection (replace / delete / append)&#10;lib/storage/helpers/section-replace.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c6s_g2">
        <mxGeometry x="290" y="235" width="250" height="55" as="geometry" />
      </mxCell>

      <!-- Agent surface -->
      <mxCell id="c6s_g3" value="Agent surface (C5)" style="swimlane;startSize=26;rounded=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=12;fontStyle=1;" vertex="1" parent="c6s_det">
        <mxGeometry x="990" y="45" width="280" height="140" as="geometry" />
      </mxCell>
      <mxCell id="c6s_g3n1" value="MCP get_diff / restore_version&#10;lib/mcp/tools/diff.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d6b656;fontSize=11;" vertex="1" parent="c6s_g3">
        <mxGeometry x="15" y="45" width="250" height="60" as="geometry" />
      </mxCell>

      <!-- Bulk + pin -->
      <mxCell id="c6s_g6" value="Bulk + pin" style="swimlane;startSize=26;rounded=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=12;fontStyle=1;" vertex="1" parent="c6s_det">
        <mxGeometry x="990" y="205" width="280" height="200" as="geometry" />
      </mxCell>
      <mxCell id="c6s_g6n1" value="bulkMove / bulkTagRename / bulkArchive&#10;app/_actions/bulk.ts (no UI consumer)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#666666;fontSize=11;dashed=1;" vertex="1" parent="c6s_g6">
        <mxGeometry x="15" y="40" width="250" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c6s_g6n2" value="togglePinAction / listPinnedNotesAction&#10;app/_actions/notes.ts (_pinned field)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#666666;fontSize=11;" vertex="1" parent="c6s_g6">
        <mxGeometry x="15" y="115" width="250" height="60" as="geometry" />
      </mxCell>

      <!-- Git cold storage -->
      <mxCell id="c6s_g4" value="Git cold storage (local only — sole entry: writes.ts:331 enqueueCommit)" style="swimlane;startSize=26;rounded=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=12;fontStyle=1;" vertex="1" parent="c6s_det">
        <mxGeometry x="20" y="440" width="560" height="380" as="geometry" />
      </mxCell>
      <mxCell id="c6s_g4n1" value="Commit loop (30s debounce, self-disabling)&#10;lib/git/commit-loop.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c6s_g4">
        <mxGeometry x="20" y="40" width="250" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c6s_g4n2" value="Runtime detect (500ms probe, memoised)&#10;lib/git/detect.ts + index.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c6s_g4">
        <mxGeometry x="290" y="40" width="250" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c6s_g4n3" value="SimpleGitAdapter (system git, rename detect)&#10;lib/git/simple.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c6s_g4">
        <mxGeometry x="290" y="115" width="250" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c6s_g4n4" value="IsoGitAdapter (pure JS, push/pull stubbed)&#10;lib/git/iso.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c6s_g4">
        <mxGeometry x="290" y="190" width="250" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c6s_g4n5" value="GitAdapter contract&#10;lib/git/adapter.ts + types.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c6s_g4">
        <mxGeometry x="20" y="115" width="250" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c6s_g4n6" value="Conformance suite (tests only)&#10;lib/git/conformance.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;dashed=1;" vertex="1" parent="c6s_g4">
        <mxGeometry x="20" y="190" width="250" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c6s_g4n7" value="Vault .git repository&#10;(readable by any external git tooling)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=11;fontStyle=1;" vertex="1" parent="c6s_g4">
        <mxGeometry x="155" y="280" width="250" height="60" as="geometry" />
      </mxCell>

      <!-- Trash & recovery -->
      <mxCell id="c6s_g5" value="Trash &amp; recovery" style="swimlane;startSize=26;rounded=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;fontStyle=1;" vertex="1" parent="c6s_det">
        <mxGeometry x="610" y="440" width="560" height="380" as="geometry" />
      </mxCell>
      <mxCell id="c6s_g5n1" value="delete / restore / emptyTrash actions&#10;app/_actions/notes.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c6s_g5">
        <mxGeometry x="20" y="40" width="250" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c6s_g5n2" value="TrashList (optimistic UI, rollback toasts)&#10;components/trash-list.tsx" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c6s_g5">
        <mxGeometry x="290" y="40" width="250" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c6s_g5n3" value="Trash pages&#10;/v/trash + /w/slug/trash (force-dynamic)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c6s_g5">
        <mxGeometry x="290" y="115" width="250" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c6s_g5n4" value="Trash-prune cron (CRON_SECRET, 04:00 UTC)&#10;app/api/cron/trash-prune/route.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c6s_g5">
        <mxGeometry x="20" y="115" width="250" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c6s_g5n5" value="Trash storage&#10;.eli/trash file move + trashed_at column" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=11;fontStyle=1;" vertex="1" parent="c6s_g5">
        <mxGeometry x="155" y="280" width="250" height="60" as="geometry" />
      </mxCell>

      <!-- Detailed-band edges -->
      <mxCell id="c6s_de1" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c6s_g1n1" target="c6s_g1n3"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6s_de2" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c6s_g1n2" target="c6s_g1n3"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6s_de3" value="Compare links" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c6s_g2n1" target="c6s_g2n2"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6s_de4" value="diffVersions" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c6s_g2n2" target="c6s_g2n6"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6s_de5" value="diffVersions" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c6s_g2n3" target="c6s_g2n6"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6s_de6" value="reads version rows" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c6s_g2n6" target="c6s_g1n3"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6s_de7" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c6s_g2n5" target="c6s_g2n7"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6s_de8" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c6s_g2n7" target="c6s_g2n8"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6s_de9" value="updateNote → new version" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c6s_g2n7" target="c6s_g1n1"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6s_de10" value="same version store" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c6s_g3n1" target="c6s_g1n3"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6s_de11" value="enqueueCommit (sole bridge, writes.ts:331)" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;fontStyle=1;" edge="1" parent="1" source="c6s_g1n1" target="c6s_g4n1"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6s_de12" value="getGit" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c6s_g4n1" target="c6s_g4n2"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6s_de13" value="probe ok" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c6s_g4n2" target="c6s_g4n3"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6s_de14" value="probe failed / timed out" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c6s_g4n2" target="c6s_g4n4"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6s_de15" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c6s_g4n3" target="c6s_g4n7"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6s_de16" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c6s_g4n4" target="c6s_g4n7"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6s_de17" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c6s_g5n3" target="c6s_g5n2"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6s_de18" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c6s_g5n2" target="c6s_g5n1"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6s_de19" value="soft delete / restore / purge" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c6s_g5n1" target="c6s_g5n5"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6s_de20" value="hard delete older than 30d" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c6s_g5n4" target="c6s_g5n5"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6s_de21" value="updateNote per id" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;dashed=1;" edge="1" parent="1" source="c6s_g6n1" target="c6s_g1n1"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6s_de22" value="contract" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;dashed=1;" edge="1" parent="1" source="c6s_g4n6" target="c6s_g4n5"><mxGeometry relative="1" as="geometry" /></mxCell>
    </root>
  </mxGraphModel>
</diagram>
<diagram id="c6-flows" name="C6 Versioning, History &amp; Recovery — Flows">
  <mxGraphModel dx="800" dy="600" grid="0" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1600" pageHeight="1200" math="0" shadow="0">
    <root>
      <mxCell id="0" />
      <mxCell id="1" parent="0" />

      <!-- ===================== SIMPLIFIED band ===================== -->
      <mxCell id="c6f_simp" value="SIMPLIFIED — happy paths: save → version → git commit, and compare → restore" style="swimlane;startSize=28;rounded=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=14;fontStyle=1;" vertex="1" parent="1">
        <mxGeometry x="20" y="20" width="1540" height="300" as="geometry" />
      </mxCell>
      <mxCell id="c6f_s1" value="1. Save note&#10;(user / agent / clipper)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="c6f_simp">
        <mxGeometry x="30" y="55" width="200" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c6f_s2" value="2. updateNote: atomic .md write&#10;+ versions row (same tx)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="c6f_simp">
        <mxGeometry x="280" y="55" width="230" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c6f_s3" value="3. enqueueCommit&#10;(best-effort, local only)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=12;" vertex="1" parent="c6f_simp">
        <mxGeometry x="560" y="55" width="200" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c6f_s4" value="4. 30s sliding debounce&#10;(dedup by relPath)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=12;" vertex="1" parent="c6f_simp">
        <mxGeometry x="810" y="55" width="200" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c6f_s5" value="5. git add + ONE commit&#10;(agent-attributed)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=12;" vertex="1" parent="c6f_simp">
        <mxGeometry x="1060" y="55" width="200" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c6f_s6" value="Vault .git history" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=12;fontStyle=1;" vertex="1" parent="c6f_simp">
        <mxGeometry x="1310" y="55" width="180" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c6f_s7" value="A. Compare versions&#10;(?a &amp; ?b, default two newest)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=12;" vertex="1" parent="c6f_simp">
        <mxGeometry x="280" y="185" width="230" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c6f_s8" value="B. diffSections →&#10;SectionDiff[] hunks" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=12;" vertex="1" parent="c6f_simp">
        <mxGeometry x="560" y="185" width="200" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c6f_s9" value="C. Restore section →&#10;NEW version (append-only)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=12;" vertex="1" parent="c6f_simp">
        <mxGeometry x="810" y="185" width="200" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c6f_se1" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c6f_s1" target="c6f_s2"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6f_se2" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c6f_s2" target="c6f_s3"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6f_se3" value="fresh save resets timer" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c6f_s3" target="c6f_s4"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6f_se4" value="timer fires" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c6f_s4" target="c6f_s5"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6f_se5" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c6f_s5" target="c6f_s6"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6f_se6" value="versions table" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;dashed=1;" edge="1" parent="1" source="c6f_s2" target="c6f_s7"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6f_se7" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c6f_s7" target="c6f_s8"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6f_se8" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c6f_s8" target="c6f_s9"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6f_se9" value="updateNote re-enters save path" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;dashed=1;" edge="1" parent="1" source="c6f_s9" target="c6f_s2"><mxGeometry relative="1" as="geometry" /></mxCell>

      <!-- ===================== DETAILED band ===================== -->
      <mxCell id="c6f_det" value="DETAILED — swimlane per actor: Flow A save→commit (orange/blue), Flow B compare→restore (purple), Flow C trash lifecycle (green)" style="swimlane;startSize=28;rounded=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=14;fontStyle=1;" vertex="1" parent="1">
        <mxGeometry x="20" y="340" width="1540" height="850" as="geometry" />
      </mxCell>

      <!-- Lane 1: Author / UI -->
      <mxCell id="c6f_l1" value="Author / UI (browser)" style="swimlane;horizontal=0;startSize=28;rounded=1;fillColor=#ffffff;strokeColor=#666666;fontSize=12;fontStyle=1;" vertex="1" parent="c6f_det">
        <mxGeometry x="15" y="40" width="1510" height="155" as="geometry" />
      </mxCell>
      <mxCell id="c6f_a1" value="A1. Save note&#10;(editor / MCP agent / clipper)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c6f_l1">
        <mxGeometry x="45" y="45" width="210" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c6f_b1" value="B1. Click Compare in History card&#10;(properties-panel.tsx:281-288)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c6f_l1">
        <mxGeometry x="560" y="25" width="210" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c6f_b5" value="B5. Click 'Restore this section'&#10;(DiffView, useTransition)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c6f_l1">
        <mxGeometry x="790" y="90" width="210" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c6f_c1" value="C1. Delete note&#10;(confirm 'Move to .eli/trash/?')" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c6f_l1">
        <mxGeometry x="1255" y="25" width="230" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c6f_c4" value="C4. TrashList: Restore /&#10;hard delete / Empty trash" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c6f_l1">
        <mxGeometry x="1255" y="90" width="230" height="55" as="geometry" />
      </mxCell>

      <!-- Lane 2: Pages & server actions -->
      <mxCell id="c6f_l2" value="Pages &amp; server actions" style="swimlane;horizontal=0;startSize=28;rounded=1;fillColor=#ffffff;strokeColor=#666666;fontSize=12;fontStyle=1;" vertex="1" parent="c6f_det">
        <mxGeometry x="15" y="200" width="1510" height="155" as="geometry" />
      </mxCell>
      <mxCell id="c6f_b2" value="B2. Diff page resolves ?a &amp; ?b&#10;(defaults: two newest)&#10;v/diff/[...path]/page.tsx:57-62" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c6f_l2">
        <mxGeometry x="560" y="25" width="210" height="65" as="geometry" />
      </mxCell>
      <mxCell id="c6f_b4" value="B4. Render VersionPicker + DiffView&#10;(collapse runs of 2+ unchanged)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c6f_l2">
        <mxGeometry x="790" y="25" width="210" height="65" as="geometry" />
      </mxCell>
      <mxCell id="c6f_b6" value="B6. restoreSectionAction →&#10;replaceSection (diff.ts:33-66,&#10;section-replace.ts:21-49)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c6f_l2">
        <mxGeometry x="1020" y="25" width="210" height="65" as="geometry" />
      </mxCell>
      <mxCell id="c6f_c2" value="C2. deleteNoteAction (trash:true)&#10;+ cancel pending auto-embed&#10;(notes.ts:225-240)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c6f_l2">
        <mxGeometry x="1255" y="25" width="230" height="65" as="geometry" />
      </mxCell>

      <!-- Lane 3: Storage adapter -->
      <mxCell id="c6f_l3" value="Storage adapter (C1)" style="swimlane;horizontal=0;startSize=28;rounded=1;fillColor=#ffffff;strokeColor=#666666;fontSize=12;fontStyle=1;" vertex="1" parent="c6f_det">
        <mxGeometry x="15" y="360" width="1510" height="160" as="geometry" />
      </mxCell>
      <mxCell id="c6f_a2" value="A2. atomicWrite .md + versions row&#10;in one tx (writes.ts:160-174)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c6f_l3">
        <mxGeometry x="45" y="25" width="220" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c6f_a3" value="A3. enqueueCommit best-effort,&#10;errors swallowed (writes.ts:330-337)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c6f_l3">
        <mxGeometry x="300" y="25" width="220" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c6f_b3" value="B3. listVersions + diffVersions&#10;→ diffSections (section-diff.ts)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c6f_l3">
        <mxGeometry x="560" y="25" width="210" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c6f_b7" value="B7. updateNote → NEW version,&#10;authorKind user, msg 'restore section...'" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c6f_l3">
        <mxGeometry x="1020" y="25" width="210" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c6f_c3" value="C3. Move to .eli/trash + trashed_at&#10;stamp, markEcho (writes.ts:351-366);&#10;SaaS: RLS UPDATE trashed_at" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c6f_l3">
        <mxGeometry x="1255" y="25" width="230" height="65" as="geometry" />
      </mxCell>
      <mxCell id="c6f_note1" value="Side effect: expectedVersionId mismatch appends an 'auto-conflict-snapshot' system version before the write (writes.ts:255-277)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=10;dashed=1;" vertex="1" parent="c6f_l3">
        <mxGeometry x="45" y="100" width="475" height="45" as="geometry" />
      </mxCell>

      <!-- Lane 4: Git layer -->
      <mxCell id="c6f_l4" value="Git layer (lib/git — local only)" style="swimlane;horizontal=0;startSize=28;rounded=1;fillColor=#ffffff;strokeColor=#666666;fontSize=12;fontStyle=1;" vertex="1" parent="c6f_det">
        <mxGeometry x="15" y="525" width="1510" height="160" as="geometry" />
      </mxCell>
      <mxCell id="c6f_a4" value="A4. Gates (ELI_DISABLE_GIT, .git dir,&#10;git.auto) + dedupe + sliding 30s timer&#10;(commit-loop.ts:84-133)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c6f_l4">
        <mxGeometry x="45" y="25" width="230" height="65" as="geometry" />
      </mxCell>
      <mxCell id="c6f_a5" value="A5. getGit: 500ms probe →&#10;simple-git or iso-git fallback&#10;(detect.ts:19-92)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c6f_l4">
        <mxGeometry x="310" y="25" width="220" height="65" as="geometry" />
      </mxCell>
      <mxCell id="c6f_a6" value="A6. add + ONE commit for the batch;&#10;any agent in batch wins authorship&#10;(commit-loop.ts:153-176)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c6f_l4">
        <mxGeometry x="565" y="25" width="230" height="65" as="geometry" />
      </mxCell>
      <mxCell id="c6f_note2" value="Failure posture: disabled=true + lastError, no retry; future enqueues dropped until reenableCommitLoop — which has no UI caller (commit-loop.ts:177-199)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=10;dashed=1;" vertex="1" parent="c6f_l4">
        <mxGeometry x="830" y="25" width="330" height="65" as="geometry" />
      </mxCell>

      <!-- Lane 5: Cron scheduler -->
      <mxCell id="c6f_l5" value="Cron (vercel.json)" style="swimlane;horizontal=0;startSize=28;rounded=1;fillColor=#ffffff;strokeColor=#666666;fontSize=12;fontStyle=1;" vertex="1" parent="c6f_det">
        <mxGeometry x="15" y="690" width="1510" height="140" as="geometry" />
      </mxCell>
      <mxCell id="c6f_c5" value="C5. 04:00 UTC trash-prune: CRON_SECRET check,&#10;hard-delete trashed rows older than 30d&#10;(updatedAt proxy) route.ts:38-55; SaaS = service-role fan-out" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c6f_l5">
        <mxGeometry x="1150" y="25" width="335" height="70" as="geometry" />
      </mxCell>

      <!-- Detailed flow edges -->
      <mxCell id="c6f_de1" value="updateNote" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c6f_a1" target="c6f_a2"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6f_de2" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c6f_a2" target="c6f_a3"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6f_de3" value="enqueue" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c6f_a3" target="c6f_a4"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6f_de4" value="timer fires (flushNow)" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c6f_a4" target="c6f_a5"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6f_de5" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c6f_a5" target="c6f_a6"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6f_de6" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c6f_b1" target="c6f_b2"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6f_de7" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c6f_b2" target="c6f_b3"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6f_de8" value="SectionDiff[]" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c6f_b3" target="c6f_b4"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6f_de9" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c6f_b4" target="c6f_b5"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6f_de10" value="{noteId, sourceVersionId, anchor}" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c6f_b5" target="c6f_b6"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6f_de11" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c6f_b6" target="c6f_b7"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6f_de12" value="local mode: re-enters commit loop" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;dashed=1;" edge="1" parent="1" source="c6f_b7" target="c6f_a4"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6f_de13" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c6f_c1" target="c6f_c2"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6f_de14" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c6f_c2" target="c6f_c3"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6f_de15" value="listNotes onlyTrashed (trash pages)" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;dashed=1;" edge="1" parent="1" source="c6f_c3" target="c6f_c4"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6f_de16" value="restore reverses move / hard delete rm + cascade" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c6f_c4" target="c6f_c3"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c6f_de17" value="hard delete survivors older than cutoff" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c6f_c5" target="c6f_c3"><mxGeometry relative="1" as="geometry" /></mxCell>
    </root>
  </mxGraphModel>
</diagram>
<diagram id="c7-system" name="C7 SaaS Collaboration Platform — System">
  <mxGraphModel dx="800" dy="600" grid="0" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1600" pageHeight="1200" math="0" shadow="0">
    <root>
      <mxCell id="0" />
      <mxCell id="1" parent="0" />
      <mxCell id="c7s_simp" value="SIMPLIFIED — the SaaS collaboration shell in one glance" style="swimlane;startSize=32;rounded=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=14;fontStyle=1;" vertex="1" parent="1">
        <mxGeometry x="40" y="40" width="1520" height="320" as="geometry" />
      </mxCell>
      <mxCell id="c7s_member" value="Member browser" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=13;" vertex="1" parent="c7s_simp">
        <mxGeometry x="40" y="70" width="170" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c7s_mw" value="middleware.ts&#10;session refresh + auth wall" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=13;" vertex="1" parent="c7s_simp">
        <mxGeometry x="280" y="70" width="200" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c7s_app" value="SaaS app routes&#10;/w/[workspace]/*" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=13;" vertex="1" parent="c7s_simp">
        <mxGeometry x="550" y="70" width="190" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c7s_actions" value="Server Actions&#10;app/_actions/*" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=13;" vertex="1" parent="c7s_simp">
        <mxGeometry x="810" y="70" width="180" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c7s_pg" value="Postgres + RLS&#10;33 policies / 9 tables" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=13;" vertex="1" parent="c7s_simp">
        <mxGeometry x="1060" y="70" width="200" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c7s_supa" value="Supabase Auth&#10;magic link + OAuth" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=13;" vertex="1" parent="c7s_simp">
        <mxGeometry x="280" y="190" width="200" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c7s_cb" value="/api/auth/callback&#10;code exchange + routing" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=13;" vertex="1" parent="c7s_simp">
        <mxGeometry x="550" y="190" width="190" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c7s_resend" value="Resend&#10;invite email" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=13;" vertex="1" parent="c7s_simp">
        <mxGeometry x="810" y="190" width="180" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c7s_anon" value="Anonymous visitor&#10;/s/[token]" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=13;" vertex="1" parent="c7s_simp">
        <mxGeometry x="40" y="190" width="170" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c7s_e1" value="every request" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7s_member" target="c7s_mw"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7s_e2" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7s_mw" target="c7s_app"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7s_e3" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7s_app" target="c7s_actions"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7s_e4" value="RLS-gated SQL" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7s_actions" target="c7s_pg"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7s_e5" value="sign in" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7s_member" target="c7s_supa"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7s_e6" value="?code" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7s_supa" target="c7s_cb"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7s_e7" value="route to /w/slug or onboarding" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7s_cb" target="c7s_app"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7s_e8" value="invite email" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7s_actions" target="c7s_resend"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7s_e9" value="token — service-role resolve" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7s_anon" target="c7s_pg"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7s_det" value="DETAILED — full component graph by sub-area" style="swimlane;startSize=32;rounded=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=14;fontStyle=1;" vertex="1" parent="1">
        <mxGeometry x="40" y="400" width="1520" height="700" as="geometry" />
      </mxCell>
      <mxCell id="c7s_gAuth" value="Auth &amp; session" style="swimlane;startSize=26;rounded=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=13;fontStyle=1;" vertex="1" parent="c7s_det">
        <mxGeometry x="20" y="50" width="360" height="290" as="geometry" />
      </mxCell>
      <mxCell id="c7s_a1" value="login/signup + magic link + OAuth UI&#10;app/(saas)/(auth), components/auth" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c7s_gAuth">
        <mxGeometry x="12" y="40" width="160" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c7s_a2" value="callback route&#10;app/api/auth/callback/route.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c7s_gAuth">
        <mxGeometry x="185" y="40" width="160" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c7s_a3" value="middleware.ts&#10;refresh + auth wall" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c7s_gAuth">
        <mxGeometry x="12" y="130" width="160" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c7s_a4" value="client factories (server / cookie-adapter / service-role / browser)&#10;lib/auth/supabase.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c7s_gAuth">
        <mxGeometry x="185" y="130" width="160" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c7s_gWs" value="Workspace model &amp; shell" style="swimlane;startSize=26;rounded=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=13;fontStyle=1;" vertex="1" parent="c7s_det">
        <mxGeometry x="400" y="50" width="360" height="290" as="geometry" />
      </mxCell>
      <mxCell id="c7s_w1" value="workspace actions, reserved slugs&#10;app/_actions/workspaces.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c7s_gWs">
        <mxGeometry x="12" y="40" width="160" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c7s_w2" value="onboarding form&#10;components/saas/new-workspace-form.tsx" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c7s_gWs">
        <mxGeometry x="185" y="40" width="160" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c7s_w3" value="WorkspaceSwitcher + eli_ws cookie&#10;components/workspace-switcher.tsx" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c7s_gWs">
        <mxGeometry x="12" y="130" width="160" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c7s_w4" value="app shell + mobile nav&#10;app/(saas)/(app)/layout.tsx" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c7s_gWs">
        <mxGeometry x="185" y="130" width="160" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c7s_w5" value="rename / slug change&#10;app/_actions/workspaces-settings.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c7s_gWs">
        <mxGeometry x="12" y="215" width="160" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c7s_gMem" value="Invites &amp; memberships" style="swimlane;startSize=26;rounded=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=13;fontStyle=1;" vertex="1" parent="c7s_det">
        <mxGeometry x="780" y="50" width="360" height="290" as="geometry" />
      </mxCell>
      <mxCell id="c7s_m1" value="invite create/cancel/accept&#10;app/_actions/invites.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c7s_gMem">
        <mxGeometry x="12" y="40" width="160" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c7s_m2" value="role change / remove / leave, sole-owner guards&#10;app/_actions/memberships.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c7s_gMem">
        <mxGeometry x="185" y="40" width="160" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c7s_m3" value="InviteDialog + MembersTable&#10;components/members" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c7s_gMem">
        <mxGeometry x="12" y="130" width="160" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c7s_m4" value="accept page&#10;w/[ws]/invite/[token]/page.tsx" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c7s_gMem">
        <mxGeometry x="185" y="130" width="160" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c7s_gShare" value="Share links" style="swimlane;startSize=26;rounded=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=13;fontStyle=1;" vertex="1" parent="c7s_det">
        <mxGeometry x="1160" y="50" width="340" height="290" as="geometry" />
      </mxCell>
      <mxCell id="c7s_sh1" value="token primitives + adapter&#10;lib/share/tokens.ts, lib/storage/supabase/shares.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d6b656;fontSize=11;" vertex="1" parent="c7s_gShare">
        <mxGeometry x="10" y="40" width="152" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c7s_sh2" value="member + token-gated actions&#10;app/_actions/shares(-comment-edit).ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d6b656;fontSize=11;" vertex="1" parent="c7s_gShare">
        <mxGeometry x="175" y="40" width="152" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c7s_sh3" value="ShareLinkDialog&#10;components/share" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d6b656;fontSize=11;" vertex="1" parent="c7s_gShare">
        <mxGeometry x="10" y="130" width="152" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c7s_sh4" value="public renderer + clients&#10;app/(saas)/s/[token]/page.tsx" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d6b656;fontSize=11;" vertex="1" parent="c7s_gShare">
        <mxGeometry x="175" y="130" width="152" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c7s_gCol" value="Comments &amp; realtime" style="swimlane;startSize=26;rounded=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=13;fontStyle=1;" vertex="1" parent="c7s_det">
        <mxGeometry x="20" y="360" width="360" height="300" as="geometry" />
      </mxCell>
      <mxCell id="c7s_c1" value="CommentsThread: threads, resolve, orphans&#10;components/comments/comments-thread.tsx" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c7s_gCol">
        <mxGeometry x="12" y="40" width="160" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c7s_c2" value="MentionInput @-autocomplete&#10;components/comments/mention-input.tsx" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c7s_gCol">
        <mxGeometry x="185" y="40" width="160" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c7s_c3" value="comment CRUD + orphan scan&#10;lib/storage/supabase/comments.ts, app/_actions/comments.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c7s_gCol">
        <mxGeometry x="12" y="130" width="160" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c7s_c4" value="RealtimeNoteWatcher&#10;components/realtime/note-watcher.tsx" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c7s_gCol">
        <mxGeometry x="185" y="130" width="160" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c7s_gDb" value="Postgres schema, RLS &amp; triggers" style="swimlane;startSize=26;rounded=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=13;fontStyle=1;" vertex="1" parent="c7s_det">
        <mxGeometry x="400" y="360" width="360" height="300" as="geometry" />
      </mxCell>
      <mxCell id="c7s_d1" value="0001_rls.sql&#10;33 policies / 9 tables" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#666666;fontSize=11;" vertex="1" parent="c7s_gDb">
        <mxGeometry x="12" y="40" width="160" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c7s_d2" value="0002 profiles trigger&#10;(auth.users INSERT)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#666666;fontSize=11;" vertex="1" parent="c7s_gDb">
        <mxGeometry x="185" y="40" width="160" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c7s_d3" value="0003 workspace bootstrap&#10;(owner membership)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#666666;fontSize=11;" vertex="1" parent="c7s_gDb">
        <mxGeometry x="12" y="120" width="160" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c7s_d4" value="0005 audit_log + membership trigger" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#666666;fontSize=11;" vertex="1" parent="c7s_gDb">
        <mxGeometry x="185" y="120" width="160" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c7s_d5" value="0004 invites, 0007 storage buckets" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#666666;fontSize=11;" vertex="1" parent="c7s_gDb">
        <mxGeometry x="12" y="200" width="160" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c7s_d6" value="pgTAP conformance suite&#10;tests/rls" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#666666;fontSize=11;" vertex="1" parent="c7s_gDb">
        <mxGeometry x="185" y="200" width="160" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c7s_gOps" value="Audit, profile &amp; email" style="swimlane;startSize=26;rounded=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=13;fontStyle=1;" vertex="1" parent="c7s_det">
        <mxGeometry x="780" y="360" width="360" height="300" as="geometry" />
      </mxCell>
      <mxCell id="c7s_o1" value="audit viewer (admin-only, last 200)&#10;settings/audit, lib/storage/supabase/audit.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c7s_gOps">
        <mxGeometry x="12" y="40" width="160" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c7s_o2" value="AI audit bridge (ai.tool.*)&#10;lib/ai/audit.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c7s_gOps">
        <mxGeometry x="185" y="40" width="160" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c7s_o3" value="profile: display name + avatar&#10;app/_actions/profile.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c7s_gOps">
        <mxGeometry x="12" y="130" width="160" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c7s_o4" value="Resend wrapper + invite template&#10;lib/email" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c7s_gOps">
        <mxGeometry x="185" y="130" width="160" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c7s_gExt" value="External services" style="swimlane;startSize=26;rounded=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=13;fontStyle=1;" vertex="1" parent="c7s_det">
        <mxGeometry x="1160" y="360" width="340" height="300" as="geometry" />
      </mxCell>
      <mxCell id="c7s_x1" value="Supabase Auth" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#666666;fontSize=11;" vertex="1" parent="c7s_gExt">
        <mxGeometry x="10" y="40" width="152" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c7s_x2" value="Supabase Realtime" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#666666;fontSize=11;" vertex="1" parent="c7s_gExt">
        <mxGeometry x="175" y="40" width="152" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c7s_x3" value="Resend API" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#666666;fontSize=11;" vertex="1" parent="c7s_gExt">
        <mxGeometry x="10" y="120" width="152" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c7s_x4" value="Supabase Storage&#10;(avatars, attachments)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#666666;fontSize=11;" vertex="1" parent="c7s_gExt">
        <mxGeometry x="175" y="120" width="152" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c7s_de1" value="signInWithOtp / OAuth" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7s_a1" target="c7s_x1"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7s_de2" value="redirect ?code" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7s_x1" target="c7s_a2"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7s_de3" value="route by memberships + eli_ws" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7s_a2" target="c7s_w4"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7s_de4" value="INSERT fires trigger" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7s_w1" target="c7s_d3"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7s_de5" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7s_m3" target="c7s_m1"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7s_de6" value="invite template" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7s_m1" target="c7s_o4"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7s_de7" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7s_o4" target="c7s_x3"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7s_de8" value="trigger writes member.*" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7s_m2" target="c7s_d4"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7s_de9" value="comments_* policies" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7s_c3" target="c7s_d1"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7s_de10" value="postgres_changes per note" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7s_c4" target="c7s_x2"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7s_de11" value="service-role resolve" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7s_sh4" target="c7s_sh1"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7s_de12" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7s_sh3" target="c7s_sh2"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7s_de13" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7s_sh2" target="c7s_sh1"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7s_de14" value="avatars bucket" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7s_o3" target="c7s_x4"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7s_de15" value="pg_prove asserts" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7s_d6" target="c7s_d1"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7s_de16" value="ai.tool.* rows" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7s_o2" target="c7s_d4"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7s_de17" value="admin-only SELECT" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7s_o1" target="c7s_d4"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7s_de18" value="mentions feed thread" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7s_c2" target="c7s_c1"><mxGeometry relative="1" as="geometry" /></mxCell>
    </root>
  </mxGraphModel>
</diagram>
<diagram id="c7-flows" name="C7 SaaS Collaboration Platform — Flows">
  <mxGraphModel dx="800" dy="600" grid="0" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1600" pageHeight="1200" math="0" shadow="0">
    <root>
      <mxCell id="0" />
      <mxCell id="1" parent="0" />
      <mxCell id="c7f_simp" value="SIMPLIFIED — invite happy path (the flow that makes a workspace multi-user)" style="swimlane;startSize=32;rounded=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=14;fontStyle=1;" vertex="1" parent="1">
        <mxGeometry x="40" y="40" width="1520" height="260" as="geometry" />
      </mxCell>
      <mxCell id="c7f_f1" value="1. Admin invites&#10;email + role&#10;(owner not invitable)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="c7f_simp">
        <mxGeometry x="20" y="80" width="190" height="80" as="geometry" />
      </mxCell>
      <mxCell id="c7f_f2" value="2. createInviteAction&#10;32-byte token, sha256 hash&#10;to pending_invites, 7-day TTL" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=12;" vertex="1" parent="c7f_simp">
        <mxGeometry x="230" y="80" width="190" height="80" as="geometry" />
      </mxCell>
      <mxCell id="c7f_f3" value="3. Resend email&#10;accept URL carries the&#10;plaintext token" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=12;" vertex="1" parent="c7f_simp">
        <mxGeometry x="440" y="80" width="190" height="80" as="geometry" />
      </mxCell>
      <mxCell id="c7f_f4" value="4. Invitee clicks link,&#10;signs in via magic link&#10;or OAuth (?next preserved)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="c7f_simp">
        <mxGeometry x="650" y="80" width="190" height="80" as="geometry" />
      </mxCell>
      <mxCell id="c7f_f5" value="5. acceptInviteAction&#10;service-role validate hash + TTL,&#10;insert membership (idempotent)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=12;" vertex="1" parent="c7f_simp">
        <mxGeometry x="860" y="80" width="190" height="80" as="geometry" />
      </mxCell>
      <mxCell id="c7f_f6" value="6. audit_log 'member.added'&#10;via SECURITY DEFINER&#10;membership trigger" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=12;" vertex="1" parent="c7f_simp">
        <mxGeometry x="1070" y="80" width="190" height="80" as="geometry" />
      </mxCell>
      <mxCell id="c7f_f7" value="7. eli_ws cookie set,&#10;redirect /w/slug&#10;invitee is a member" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="c7f_simp">
        <mxGeometry x="1280" y="80" width="190" height="80" as="geometry" />
      </mxCell>
      <mxCell id="c7f_fe1" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7f_f1" target="c7f_f2"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7f_fe2" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7f_f2" target="c7f_f3"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7f_fe3" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7f_f3" target="c7f_f4"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7f_fe4" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7f_f4" target="c7f_f5"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7f_fe5" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7f_f5" target="c7f_f6"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7f_fe6" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7f_f6" target="c7f_f7"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7f_det" value="DETAILED — swimlane per actor, numbered steps and side effects" style="swimlane;startSize=32;rounded=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=14;fontStyle=1;" vertex="1" parent="1">
        <mxGeometry x="40" y="340" width="1520" height="1420" as="geometry" />
      </mxCell>
      <mxCell id="c7f_lblA" value="Flow A — Invite lifecycle: invite → email → accept → membership + audit" style="text;html=1;fontSize=13;fontStyle=1;align=left;" vertex="1" parent="c7f_det">
        <mxGeometry x="20" y="42" width="900" height="30" as="geometry" />
      </mxCell>
      <mxCell id="c7f_la1" value="Admin browser" style="swimlane;horizontal=0;startSize=26;rounded=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;fontStyle=1;" vertex="1" parent="c7f_det">
        <mxGeometry x="20" y="78" width="1480" height="130" as="geometry" />
      </mxCell>
      <mxCell id="c7f_s1" value="1. InviteDialog submit&#10;{email, role}" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c7f_la1">
        <mxGeometry x="40" y="35" width="200" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c7f_s6" value="6. Toast: delivery sent /&#10;logged (dev) / error" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c7f_la1">
        <mxGeometry x="520" y="35" width="200" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c7f_la2" value="Server actions (invites.ts, middleware)" style="swimlane;horizontal=0;startSize=26;rounded=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=12;fontStyle=1;" vertex="1" parent="c7f_det">
        <mxGeometry x="20" y="213" width="1480" height="130" as="geometry" />
      </mxCell>
      <mxCell id="c7f_s2" value="2. createInviteAction: 32-byte token,&#10;sha256 hash, 7-day TTL" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c7f_la2">
        <mxGeometry x="40" y="35" width="210" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c7f_s4" value="4. Build accept URL&#10;ELI_PUBLIC_URL/w/slug/invite/token" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c7f_la2">
        <mxGeometry x="280" y="35" width="210" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c7f_s8" value="8. middleware: anonymous hit →&#10;/login?next=invite path" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c7f_la2">
        <mxGeometry x="760" y="35" width="210" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c7f_s10" value="10. acceptInviteAction: SERVICE-ROLE&#10;hash lookup, expiry + accepted checks&#10;(email mismatch NOT blocked)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c7f_la2">
        <mxGeometry x="1010" y="30" width="230" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c7f_la3" value="Postgres (RLS + triggers)" style="swimlane;horizontal=0;startSize=26;rounded=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=12;fontStyle=1;" vertex="1" parent="c7f_det">
        <mxGeometry x="20" y="348" width="1480" height="130" as="geometry" />
      </mxCell>
      <mxCell id="c7f_s3" value="3. INSERT pending_invites&#10;(RLS invites_insert_admin, hash only)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c7f_la3">
        <mxGeometry x="40" y="35" width="210" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c7f_s11" value="11. SERVICE-ROLE INSERT memberships&#10;(23505 already-member tolerated),&#10;stamp accepted_at" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c7f_la3">
        <mxGeometry x="1010" y="30" width="230" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c7f_s12" value="12. SIDE EFFECT: trigger writes&#10;audit_log 'member.added'&#10;(actor null under service-role)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c7f_la3">
        <mxGeometry x="1260" y="30" width="200" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c7f_la4" value="Email (Resend)" style="swimlane;horizontal=0;startSize=26;rounded=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=12;fontStyle=1;" vertex="1" parent="c7f_det">
        <mxGeometry x="20" y="483" width="1480" height="110" as="geometry" />
      </mxCell>
      <mxCell id="c7f_s5" value="5. sendEmail via Resend — or console&#10;'logged' fallback when RESEND_API_KEY unset" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#666666;fontSize=11;" vertex="1" parent="c7f_la4">
        <mxGeometry x="280" y="25" width="240" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c7f_la5" value="Invitee browser" style="swimlane;horizontal=0;startSize=26;rounded=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;fontStyle=1;" vertex="1" parent="c7f_det">
        <mxGeometry x="20" y="598" width="1480" height="130" as="geometry" />
      </mxCell>
      <mxCell id="c7f_s7" value="7. Click accept link&#10;(anonymous)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c7f_la5">
        <mxGeometry x="520" y="35" width="200" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c7f_s9" value="9. Sign in (magic link / OAuth);&#10;callback honours safe ?next" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c7f_la5">
        <mxGeometry x="760" y="35" width="210" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c7f_s13" value="13. eli_ws cookie set;&#10;redirect /w/slug" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c7f_la5">
        <mxGeometry x="1260" y="35" width="200" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c7f_ae1" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7f_s1" target="c7f_s2"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7f_ae2" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7f_s2" target="c7f_s3"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7f_ae3" value="hash stored" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7f_s3" target="c7f_s4"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7f_ae4" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7f_s4" target="c7f_s5"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7f_ae5" value="delivery kind" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7f_s5" target="c7f_s6"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7f_ae6" value="email received" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7f_s5" target="c7f_s7"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7f_ae7" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7f_s7" target="c7f_s8"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7f_ae8" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7f_s8" target="c7f_s9"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7f_ae9" value="page auto-runs action" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7f_s9" target="c7f_s10"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7f_ae10" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7f_s10" target="c7f_s11"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7f_ae11" value="trigger" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;dashed=1;" edge="1" parent="1" source="c7f_s11" target="c7f_s12"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7f_ae12" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7f_s11" target="c7f_s13"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7f_lblB" value="Flow B — Concurrent edit → conflict snapshot → realtime toast" style="text;html=1;fontSize=13;fontStyle=1;align=left;" vertex="1" parent="c7f_det">
        <mxGeometry x="20" y="750" width="900" height="30" as="geometry" />
      </mxCell>
      <mxCell id="c7f_lb1" value="Member A editor" style="swimlane;horizontal=0;startSize=26;rounded=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;fontStyle=1;" vertex="1" parent="c7f_det">
        <mxGeometry x="20" y="786" width="1480" height="130" as="geometry" />
      </mxCell>
      <mxCell id="c7f_b2" value="2. Toast: 'This note changed elsewhere'&#10;+ Refresh action (buffer untouched)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c7f_lb1">
        <mxGeometry x="320" y="35" width="230" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c7f_b3" value="3. A saves with stale&#10;expectedVersionId v1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c7f_lb1">
        <mxGeometry x="580" y="35" width="200" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c7f_b7" value="7. ConflictBanner deep-links snapshot&#10;in history; markVersionAsLocal(v3)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c7f_lb1">
        <mxGeometry x="1200" y="35" width="240" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c7f_lb2" value="saveNoteAction + SupabaseAdapter" style="swimlane;horizontal=0;startSize=26;rounded=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=12;fontStyle=1;" vertex="1" parent="c7f_det">
        <mxGeometry x="20" y="921" width="1480" height="130" as="geometry" />
      </mxCell>
      <mxCell id="c7f_b4" value="4. updateNote reads row: v2 differs from v1 →&#10;INSERT versions 'auto-conflict-snapshot'&#10;(author_kind system, loser parked)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c7f_lb2">
        <mxGeometry x="580" y="30" width="250" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c7f_b6" value="6. SaveState {versionId v3, snapshotVersionId};&#10;SIDE EFFECT: fire-and-forget scheduleEmbed&#10;(30s debounce, semantic search)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c7f_lb2">
        <mxGeometry x="1140" y="30" width="250" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c7f_lb3" value="Postgres (notes_save RPC)" style="swimlane;horizontal=0;startSize=26;rounded=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=12;fontStyle=1;" vertex="1" parent="c7f_det">
        <mxGeometry x="20" y="1056" width="1480" height="130" as="geometry" />
      </mxCell>
      <mxCell id="c7f_b5" value="5. notes_save RPC — last write wins, note now v3&#10;(SECURITY INVOKER, RLS notes_update_editor;&#10;40001 race → snapshot + force retry)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c7f_lb3">
        <mxGeometry x="860" y="30" width="250" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c7f_lb4" value="Member B editor + Supabase Realtime" style="swimlane;horizontal=0;startSize=26;rounded=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;fontStyle=1;" vertex="1" parent="c7f_det">
        <mxGeometry x="20" y="1191" width="1480" height="130" as="geometry" />
      </mxCell>
      <mxCell id="c7f_b1" value="1. Member B saves first — note advances&#10;v1 → v2; markVersionAsLocal(v2)&#10;suppresses own realtime echo" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c7f_lb4">
        <mxGeometry x="40" y="30" width="250" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c7f_b8" value="8. Realtime broadcast v3 → toast for B;&#10;opt-in router.refresh — no auto-merge,&#10;no presence (subscribe() is a stub)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c7f_lb4">
        <mxGeometry x="860" y="30" width="250" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c7f_be1" value="postgres_changes: foreign v2" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7f_b1" target="c7f_b2"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7f_be2" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7f_b2" target="c7f_b3"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7f_be3" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7f_b3" target="c7f_b4"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7f_be4" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7f_b4" target="c7f_b5"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7f_be5" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7f_b5" target="c7f_b6"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7f_be6" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c7f_b6" target="c7f_b7"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c7f_be7" value="postgres_changes broadcast" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;dashed=1;" edge="1" parent="1" source="c7f_b5" target="c7f_b8"><mxGeometry relative="1" as="geometry" /></mxCell>
    </root>
  </mxGraphModel>
</diagram>
<diagram id="c8-system" name="C8 Capture, Templates &amp; Exchange — System">
  <mxGraphModel dx="800" dy="600" grid="0" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1600" pageHeight="1200" math="0" shadow="0">
    <root>
      <mxCell id="0" />
      <mxCell id="1" parent="0" />

      <!-- ===================== SIMPLIFIED BAND ===================== -->
      <mxCell id="c8s_band1" value="SIMPLIFIED — Capture, Templates &amp; Exchange at a glance" style="swimlane;startSize=28;rounded=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=14;fontStyle=1;" vertex="1" parent="1">
        <mxGeometry x="20" y="20" width="1560" height="300" as="geometry" />
      </mxCell>
      <mxCell id="c8s_s1" value="Bookmarklet / OS share sheet&#10;(browser side)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=13;" vertex="1" parent="c8s_band1">
        <mxGeometry x="40" y="50" width="220" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c8s_s2" value="Zip / JSON bulk import" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=13;" vertex="1" parent="c8s_band1">
        <mxGeometry x="40" y="130" width="220" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c8s_s8" value="PWA shell&#10;manifest + sw.js + offline.html" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=13;" vertex="1" parent="c8s_band1">
        <mxGeometry x="40" y="210" width="220" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c8s_s3" value="Clip ingest&#10;POST /api/clip + handleClip" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=13;" vertex="1" parent="c8s_band1">
        <mxGeometry x="340" y="50" width="240" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c8s_s4" value="POST /api/import&#10;(upsert, 5000-note cap)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=13;" vertex="1" parent="c8s_band1">
        <mxGeometry x="340" y="130" width="240" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c8s_s7" value="Template engine&#10;date / var / prompt placeholders" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=13;" vertex="1" parent="c8s_band1">
        <mxGeometry x="340" y="210" width="240" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c8s_s5" value="StorageAdapter&#10;vault notes (clipped/*, .eli/templates/*)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=13;" vertex="1" parent="c8s_band1">
        <mxGeometry x="700" y="120" width="250" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c8s_s6" value="Exports&#10;single-note .md / vault .zip (round-trips)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=13;" vertex="1" parent="c8s_band1">
        <mxGeometry x="1060" y="120" width="250" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c8s_se1" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c8s_band1" source="c8s_s1" target="c8s_s3">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c8s_se2" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c8s_band1" source="c8s_s2" target="c8s_s4">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c8s_se3" value="createNote + attachments" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c8s_band1" source="c8s_s3" target="c8s_s5">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c8s_se4" value="upsert notes" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c8s_band1" source="c8s_s4" target="c8s_s5">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c8s_se5" value="createNote from template" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c8s_band1" source="c8s_s7" target="c8s_s5">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c8s_se6" value="serialize frontmatter + body" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c8s_band1" source="c8s_s5" target="c8s_s6">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c8s_se7" value="makes /share installable" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;dashed=1;" edge="1" parent="c8s_band1" source="c8s_s8" target="c8s_s1">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>

      <!-- ===================== DETAILED BAND ===================== -->
      <mxCell id="c8s_band2" value="DETAILED — components by sub-area" style="swimlane;startSize=28;rounded=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=14;fontStyle=1;" vertex="1" parent="1">
        <mxGeometry x="20" y="350" width="1560" height="830" as="geometry" />
      </mxCell>

      <!-- Group: Clipper & Pairing -->
      <mxCell id="c8s_g1" value="Clipper &amp; Pairing (local)" style="swimlane;startSize=26;rounded=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;fontStyle=1;" vertex="1" parent="c8s_band2">
        <mxGeometry x="20" y="40" width="480" height="365" as="geometry" />
      </mxCell>
      <mxCell id="c8s_n1" value="/bookmarklet page&#10;app/(local)/bookmarklet/page.tsx" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c8s_g1">
        <mxGeometry x="20" y="40" width="210" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c8s_n2" value="Install UI (drag anchor)&#10;components/clipper/bookmarklet-install.tsx" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c8s_g1">
        <mxGeometry x="250" y="40" width="210" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c8s_n3" value="Bookmarklet builder&#10;lib/clipper/bookmarklet-source.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c8s_g1">
        <mxGeometry x="20" y="120" width="210" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c8s_n4" value="Pairing mint/verify/revoke&#10;lib/pair/extension.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c8s_g1">
        <mxGeometry x="250" y="120" width="210" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c8s_n5" value="/pair approval card&#10;app/(local)/pair + pair-approval.tsx" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c8s_g1">
        <mxGeometry x="20" y="200" width="210" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c8s_n6" value="/api/pair route&#10;app/api/pair/route.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c8s_g1">
        <mxGeometry x="250" y="200" width="210" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c8s_n7" value="~/.eli/config.json&#10;pairings[] (sha256 hashes)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=11;" vertex="1" parent="c8s_g1">
        <mxGeometry x="135" y="290" width="210" height="55" as="geometry" />
      </mxCell>

      <!-- Group: Clip ingest -->
      <mxCell id="c8s_g2" value="Clip ingest" style="swimlane;startSize=26;rounded=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;fontStyle=1;" vertex="1" parent="c8s_band2">
        <mxGeometry x="520" y="40" width="490" height="365" as="geometry" />
      </mxCell>
      <mxCell id="c8s_n8" value="POST /api/clip — app/api/clip/route.ts&#10;PAT / pairing / MCP_LOCAL_TOKEN auth, CORS *" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c8s_g2">
        <mxGeometry x="20" y="40" width="450" height="65" as="geometry" />
      </mxCell>
      <mxCell id="c8s_n9" value="handleClip core — lib/clipper/handler.ts&#10;title/path derivation clipped/&lt;slug&gt;-&lt;host&gt;.md, collision retry" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c8s_g2">
        <mxGeometry x="20" y="130" width="450" height="65" as="geometry" />
      </mxCell>
      <mxCell id="c8s_n10" value="60s idempotency Map (globalThis)&#10;handler.ts:40" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=11;" vertex="1" parent="c8s_g2">
        <mxGeometry x="20" y="225" width="210" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c8s_n11" value="Attachment ingest&#10;data: URL decode, 25MB cap, URL rewrite&#10;handler.ts:403-444" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c8s_g2">
        <mxGeometry x="255" y="225" width="215" height="70" as="geometry" />
      </mxCell>

      <!-- Group: PWA shell -->
      <mxCell id="c8s_g3" value="PWA shell &amp; share-target" style="swimlane;startSize=26;rounded=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=12;fontStyle=1;" vertex="1" parent="c8s_band2">
        <mxGeometry x="1030" y="40" width="510" height="365" as="geometry" />
      </mxCell>
      <mxCell id="c8s_n12" value="Manifest + share_target&#10;app/manifest.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d6b656;fontSize=11;" vertex="1" parent="c8s_g3">
        <mxGeometry x="20" y="40" width="225" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c8s_n13" value="/share confirm card&#10;app/share/page.tsx (session auth)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d6b656;fontSize=11;" vertex="1" parent="c8s_g3">
        <mxGeometry x="265" y="40" width="225" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c8s_n14" value="SW registration (prod only)&#10;components/pwa-register.tsx" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d6b656;fontSize=11;" vertex="1" parent="c8s_g3">
        <mxGeometry x="20" y="130" width="225" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c8s_n15" value="Service worker 'eli-v2'&#10;public/sw.js — network-first nav,&#10;/api /v1 _actions bypassed" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d6b656;fontSize=11;" vertex="1" parent="c8s_g3">
        <mxGeometry x="265" y="130" width="225" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c8s_n16" value="Offline fallback&#10;public/offline.html" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d6b656;fontSize=11;" vertex="1" parent="c8s_g3">
        <mxGeometry x="265" y="225" width="225" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c8s_n17" value="Install guidance (iOS/desktop)&#10;settings/about/page.tsx + app/layout.tsx" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d6b656;fontSize=11;" vertex="1" parent="c8s_g3">
        <mxGeometry x="20" y="225" width="225" height="60" as="geometry" />
      </mxCell>

      <!-- Group: Templates -->
      <mxCell id="c8s_g4" value="Templates" style="swimlane;startSize=26;rounded=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=12;fontStyle=1;" vertex="1" parent="c8s_band2">
        <mxGeometry x="20" y="425" width="770" height="330" as="geometry" />
      </mxCell>
      <mxCell id="c8s_n18" value="Parser (token stream)&#10;lib/templates/parser.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c8s_g4">
        <mxGeometry x="20" y="40" width="230" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c8s_n19" value="Apply engine — lib/templates/apply.ts&#10;dayjs-to-date-fns, '_' keys stripped" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c8s_g4">
        <mxGeometry x="270" y="40" width="230" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c8s_n20" value="Prompt runtimes&#10;lib/templates/prompt-runtime.ts&#10;verbatim / dialog / AI-stub" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c8s_g4">
        <mxGeometry x="520" y="40" width="230" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c8s_n21" value="apply_template MCP tool&#10;lib/mcp/tools/template.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c8s_g4">
        <mxGeometry x="20" y="130" width="230" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c8s_n22" value="LocalAdapter.applyTemplate&#10;lib/storage/local/writes.ts:451&#10;(Supabase: NotImplementedError)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c8s_g4">
        <mxGeometry x="270" y="130" width="230" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c8s_n23" value="Two-pane editor&#10;components/templates/template-editor.tsx" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c8s_g4">
        <mxGeometry x="520" y="130" width="230" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c8s_n26" value=".eli/templates/&lt;id&gt;.md&#10;files (local) / notes (saas)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=11;" vertex="1" parent="c8s_g4">
        <mxGeometry x="20" y="230" width="230" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c8s_n24" value="CRUD server actions&#10;app/_actions/templates.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c8s_g4">
        <mxGeometry x="270" y="230" width="230" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c8s_n25" value="AI generation (smart tier)&#10;app/_actions/templates-ai.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c8s_g4">
        <mxGeometry x="520" y="230" width="230" height="60" as="geometry" />
      </mxCell>

      <!-- Group: Import / Export -->
      <mxCell id="c8s_g5" value="Import / Export" style="swimlane;startSize=26;rounded=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=12;fontStyle=1;" vertex="1" parent="c8s_band2">
        <mxGeometry x="810" y="425" width="730" height="230" as="geometry" />
      </mxCell>
      <mxCell id="c8s_n27" value="POST /api/import&#10;app/api/import/route.ts&#10;zip (JSZip) or JSON, 5000 cap" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c8s_g5">
        <mxGeometry x="20" y="40" width="215" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c8s_n28" value="GET /api/export/vault&#10;zip + eli-export.json manifest" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c8s_g5">
        <mxGeometry x="255" y="40" width="215" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c8s_n29" value="GET /api/export/note/[id]&#10;markdown download" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c8s_g5">
        <mxGeometry x="490" y="40" width="215" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c8s_n30" value="Command palette 'Export vault as zip'&#10;command-palette.tsx:224" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c8s_g5">
        <mxGeometry x="255" y="140" width="215" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c8s_n31" value="Inspector 'Download as markdown'&#10;properties-panel.tsx:353" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c8s_g5">
        <mxGeometry x="490" y="140" width="215" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c8s_n32" value="OpenAPI docs of endpoints&#10;app/v1/openapi.json/route.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c8s_g5">
        <mxGeometry x="20" y="140" width="215" height="60" as="geometry" />
      </mxCell>

      <!-- Shared storage node inside detailed band -->
      <mxCell id="c8s_stor" value="StorageAdapter via getStorage() — lib/storage/adapter.ts (createNote / putAttachment / updateNote / listNotes / getNote / applyTemplate)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=12;fontStyle=1;" vertex="1" parent="c8s_band2">
        <mxGeometry x="810" y="690" width="730" height="60" as="geometry" />
      </mxCell>

      <!-- Detailed edges -->
      <mxCell id="c8s_e1" value="mint pairing per load" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="1" source="c8s_n1" target="c8s_n4">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c8s_e2" value="hash persisted" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="1" source="c8s_n4" target="c8s_n7">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c8s_e3" value="token + endpoint embedded" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="1" source="c8s_n1" target="c8s_n3">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c8s_e4" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="1" source="c8s_n1" target="c8s_n2">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c8s_e5" value="op approve / revoke" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="1" source="c8s_n5" target="c8s_n6">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c8s_e6" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="1" source="c8s_n6" target="c8s_n4">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c8s_e7" value="javascript: bookmarklet POSTs" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="1" source="c8s_n3" target="c8s_n8">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c8s_e8" value="verifyPairingToken (local)" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;dashed=1;" edge="1" parent="1" source="c8s_n8" target="c8s_n4">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c8s_e9" value="validated ClipBody" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="1" source="c8s_n8" target="c8s_n9">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c8s_e10" value="dedupe probe" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="1" source="c8s_n9" target="c8s_n10">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c8s_e11" value="data URLs" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="1" source="c8s_n9" target="c8s_n11">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c8s_e12" value="share sheet GET /share" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="1" source="c8s_n12" target="c8s_n13">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c8s_e13" value="server action feeds handleClip" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="1" source="c8s_n13" target="c8s_n9">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c8s_e14" value="register scope /" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="1" source="c8s_n14" target="c8s_n15">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c8s_e15" value="nav fallback" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="1" source="c8s_n15" target="c8s_n16">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c8s_e16" value="save / delete / list" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="1" source="c8s_n23" target="c8s_n24">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c8s_e17" value="Generate with AI" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="1" source="c8s_n23" target="c8s_n25">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c8s_e18" value="write template" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="1" source="c8s_n24" target="c8s_n26">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c8s_e19" value="write template" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="1" source="c8s_n25" target="c8s_n26">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c8s_e20" value="storage.applyTemplate" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="1" source="c8s_n21" target="c8s_n22">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c8s_e21" value="read template file" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="1" source="c8s_n22" target="c8s_n26">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c8s_e22" value="render tokens" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="1" source="c8s_n22" target="c8s_n19">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c8s_e23" value="parseTemplate" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="1" source="c8s_n19" target="c8s_n18">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c8s_e24" value="resolvePrompt" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="1" source="c8s_n19" target="c8s_n20">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c8s_e25" value="createNote / putAttachment / updateNote" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="1" source="c8s_n9" target="c8s_stor">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c8s_e26" value="upsert" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="1" source="c8s_n27" target="c8s_stor">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c8s_e27" value="listNotes / getNote" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="1" source="c8s_n28" target="c8s_stor">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c8s_e28" value="getNote" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="1" source="c8s_n29" target="c8s_stor">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c8s_e29" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;dashed=1;" edge="1" parent="1" source="c8s_n30" target="c8s_n28">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c8s_e30" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;dashed=1;" edge="1" parent="1" source="c8s_n31" target="c8s_n29">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
    </root>
  </mxGraphModel>
</diagram>
<diagram id="c8-flows" name="C8 Capture, Templates &amp; Exchange — Flows">
  <mxGraphModel dx="800" dy="600" grid="0" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1600" pageHeight="1200" math="0" shadow="0">
    <root>
      <mxCell id="0" />
      <mxCell id="1" parent="0" />

      <!-- ===================== SIMPLIFIED BAND ===================== -->
      <mxCell id="c8f_band1" value="SIMPLIFIED — bookmarklet clip, happy path" style="swimlane;startSize=28;rounded=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=14;fontStyle=1;" vertex="1" parent="1">
        <mxGeometry x="20" y="20" width="1560" height="250" as="geometry" />
      </mxCell>
      <mxCell id="c8f_s1" value="1. Click bookmarklet&#10;on any web page" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="c8f_band1">
        <mxGeometry x="30" y="70" width="170" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c8f_s2" value="2. Capture selection or&#10;innerText + confirm()" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="c8f_band1">
        <mxGeometry x="220" y="70" width="170" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c8f_s3" value="3. POST /api/clip&#10;Bearer eli_pair token" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="c8f_band1">
        <mxGeometry x="410" y="70" width="170" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c8f_s4" value="4. Auth verify&#10;pairing hash / PAT" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="c8f_band1">
        <mxGeometry x="600" y="70" width="170" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c8f_s5" value="5. handleClip: 60s dedupe,&#10;path clipped/slug-host.md" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=12;" vertex="1" parent="c8f_band1">
        <mxGeometry x="790" y="70" width="180" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c8f_s6" value="6. createNote + attachments&#10;via StorageAdapter" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=12;" vertex="1" parent="c8f_band1">
        <mxGeometry x="990" y="70" width="180" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c8f_s7" value="7. FTS trigger indexes&#10;+ note:created event" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=12;" vertex="1" parent="c8f_band1">
        <mxGeometry x="1190" y="70" width="170" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c8f_s8" value="8. viewUrl returned,&#10;note opens in eli" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="c8f_band1">
        <mxGeometry x="1380" y="70" width="160" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c8f_se1" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c8f_band1" source="c8f_s1" target="c8f_s2"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c8f_se2" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c8f_band1" source="c8f_s2" target="c8f_s3"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c8f_se3" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c8f_band1" source="c8f_s3" target="c8f_s4"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c8f_se4" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c8f_band1" source="c8f_s4" target="c8f_s5"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c8f_se5" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c8f_band1" source="c8f_s5" target="c8f_s6"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c8f_se6" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c8f_band1" source="c8f_s6" target="c8f_s7"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c8f_se7" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="c8f_band1" source="c8f_s7" target="c8f_s8"><mxGeometry relative="1" as="geometry" /></mxCell>

      <!-- ===================== DETAILED BAND ===================== -->
      <mxCell id="c8f_band2" value="DETAILED — clip lifecycle by actor (numbered) + template apply strip" style="swimlane;startSize=28;rounded=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=14;fontStyle=1;" vertex="1" parent="1">
        <mxGeometry x="20" y="300" width="1560" height="880" as="geometry" />
      </mxCell>

      <!-- Lane 1: Browser / Bookmarklet -->
      <mxCell id="c8f_L1" value="Browser / Bookmarklet" style="swimlane;horizontal=0;startSize=30;rounded=0;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;fontStyle=1;" vertex="1" parent="c8f_band2">
        <mxGeometry x="20" y="40" width="1520" height="135" as="geometry" />
      </mxCell>
      <mxCell id="c8f_a1" value="1. Click bookmark — capture href, title,&#10;selection or innerText (50k) + outerHTML (200k)&#10;bookmarklet-source.ts:35" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c8f_L1">
        <mxGeometry x="45" y="30" width="250" height="75" as="geometry" />
      </mxCell>
      <mxCell id="c8f_a2" value="2. confirm()&#10;'Clip page?'" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c8f_L1">
        <mxGeometry x="325" y="30" width="130" height="75" as="geometry" />
      </mxCell>
      <mxCell id="c8f_a3" value="3. fetch POST /api/clip&#10;Bearer token, CORS preflight&#10;OPTIONS first" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c8f_L1">
        <mxGeometry x="485" y="30" width="200" height="75" as="geometry" />
      </mxCell>
      <mxCell id="c8f_a12" value="12. confirm() open note?&#10;window.open(viewUrl)&#10;bookmarklet-source.ts:46" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c8f_L1">
        <mxGeometry x="1270" y="30" width="220" height="75" as="geometry" />
      </mxCell>

      <!-- Lane 2: /api/clip route -->
      <mxCell id="c8f_L2" value="/api/clip route" style="swimlane;horizontal=0;startSize=30;rounded=0;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;fontStyle=1;" vertex="1" parent="c8f_band2">
        <mxGeometry x="20" y="185" width="1520" height="135" as="geometry" />
      </mxCell>
      <mxCell id="c8f_b4" value="4. authenticateClip — local: pairing sha256&#10;constant-time, then MCP_LOCAL_TOKEN /&#10;saas: PAT lookup + revoked + expiry (route.ts:163-235)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c8f_L2">
        <mxGeometry x="485" y="30" width="280" height="75" as="geometry" />
      </mxCell>
      <mxCell id="c8f_b5" value="5. ClipBodySchema.safeParse&#10;400 with zod issues on failure&#10;(route.ts:56)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c8f_L2">
        <mxGeometry x="800" y="30" width="210" height="75" as="geometry" />
      </mxCell>
      <mxCell id="c8f_b11" value="11. 200 {noteId, path, viewUrl}&#10;Access-Control-Allow-Origin *&#10;(route.ts:95)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c8f_L2">
        <mxGeometry x="1270" y="30" width="220" height="75" as="geometry" />
      </mxCell>

      <!-- Lane 3: handleClip core -->
      <mxCell id="c8f_L3" value="handleClip core" style="swimlane;horizontal=0;startSize=30;rounded=0;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=12;fontStyle=1;" vertex="1" parent="c8f_band2">
        <mxGeometry x="20" y="330" width="1520" height="135" as="geometry" />
      </mxCell>
      <mxCell id="c8f_c6" value="6. idempotency probe — 60s window&#10;keyed workspaceKey::url&#10;(handler.ts:177, hit returns existing)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c8f_L3">
        <mxGeometry x="485" y="30" width="230" height="75" as="geometry" />
      </mxCell>
      <mxCell id="c8f_c7" value="7. derive title + path clipped/&lt;slug&gt;-&lt;host&gt;.md,&#10;attachments &lt;= 25MB pre-check, 413 otherwise&#10;(handler.ts:341, :197)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c8f_L3">
        <mxGeometry x="745" y="30" width="265" height="75" as="geometry" />
      </mxCell>
      <mxCell id="c8f_c10" value="10. putAttachment per file, rewrite attachment&#10;URLs to storage paths, best-effort updateNote,&#10;cache result (handler.ts:259-306)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c8f_L3">
        <mxGeometry x="1240" y="30" width="250" height="75" as="geometry" />
      </mxCell>

      <!-- Lane 4: StorageAdapter + SQLite -->
      <mxCell id="c8f_L4" value="StorageAdapter + SQLite" style="swimlane;horizontal=0;startSize=30;rounded=0;fillColor=#f5f5f5;strokeColor=#666666;fontSize=12;fontStyle=1;" vertex="1" parent="c8f_band2">
        <mxGeometry x="20" y="475" width="1520" height="135" as="geometry" />
      </mxCell>
      <mxCell id="c8f_d8" value="8. createNote — frontmatter source: 'clipper',&#10;path collision retry -YYYY-MM-DD then -ms&#10;(handler.ts:208, :363)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#666666;fontSize=11;" vertex="1" parent="c8f_L4">
        <mxGeometry x="745" y="30" width="265" height="75" as="geometry" />
      </mxCell>
      <mxCell id="c8f_d9" value="9. atomicWrite .md + SQLite tx&#10;notes / tags / links / versions rows&#10;(writes.ts:229-230)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#666666;fontSize=11;" vertex="1" parent="c8f_L4">
        <mxGeometry x="1040" y="30" width="230" height="75" as="geometry" />
      </mxCell>

      <!-- Lane 5: Side effects -->
      <mxCell id="c8f_L5" value="Side effects" style="swimlane;horizontal=0;startSize=30;rounded=0;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=12;fontStyle=1;" vertex="1" parent="c8f_band2">
        <mxGeometry x="20" y="620" width="1520" height="135" as="geometry" />
      </mxCell>
      <mxCell id="c8f_e1n" value="emit note:created&#10;events bus to SSE / live UI&#10;(writes.ts:234, events-bus.ts:24)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d6b656;fontSize=11;" vertex="1" parent="c8f_L5">
        <mxGeometry x="745" y="30" width="230" height="75" as="geometry" />
      </mxCell>
      <mxCell id="c8f_e2n" value="notes_fts_ai trigger auto-indexes&#10;title + body into FTS5&#10;(0001_fts.sql:23)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d6b656;fontSize=11;" vertex="1" parent="c8f_L5">
        <mxGeometry x="1040" y="30" width="230" height="75" as="geometry" />
      </mxCell>
      <mxCell id="c8f_e3n" value="NO auto-embed on clip — vectors via&#10;pnpm embed:backfill or later editor save&#10;(notes.ts:96, auto-embed-queue.ts)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d6b656;fontSize=11;dashed=1;" vertex="1" parent="c8f_L5">
        <mxGeometry x="1290" y="30" width="220" height="75" as="geometry" />
      </mxCell>

      <!-- Lane 6: Template apply strip -->
      <mxCell id="c8f_L6" value="Template apply (MCP, local)" style="swimlane;horizontal=0;startSize=30;rounded=0;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=12;fontStyle=1;" vertex="1" parent="c8f_band2">
        <mxGeometry x="20" y="765" width="1520" height="105" as="geometry" />
      </mxCell>
      <mxCell id="c8f_t1" value="A. agent calls apply_template&#10;{template, path, vars}&#10;(template.ts:53)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=10;" vertex="1" parent="c8f_L6">
        <mxGeometry x="45" y="18" width="215" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c8f_t2" value="B. LocalAdapter reads&#10;.eli/templates/&lt;id&gt;.md&#10;(writes.ts:456)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=10;" vertex="1" parent="c8f_L6">
        <mxGeometry x="290" y="18" width="200" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c8f_t3" value="C. parse tokens&#10;literal / date / var / prompt&#10;(parser.ts:53)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=10;" vertex="1" parent="c8f_L6">
        <mxGeometry x="520" y="18" width="190" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c8f_t4" value="D. dates via date-fns, vars substituted,&#10;prompts resolve to (TODO: question)&#10;(apply.ts:66, :128)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=10;" vertex="1" parent="c8f_L6">
        <mxGeometry x="740" y="18" width="240" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c8f_t5" value="E. '_' frontmatter keys stripped,&#10;createNote at destination path&#10;(apply.ts:115, writes.ts:475)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=10;" vertex="1" parent="c8f_L6">
        <mxGeometry x="1010" y="18" width="230" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c8f_t6" value="F. saas divergence:&#10;NotImplementedError&#10;(supabase.ts:195)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f8cecc;strokeColor=#b85450;fontSize=10;" vertex="1" parent="c8f_L6">
        <mxGeometry x="1270" y="18" width="220" height="70" as="geometry" />
      </mxCell>

      <!-- Detailed edges -->
      <mxCell id="c8f_de1" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="1" source="c8f_a1" target="c8f_a2"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c8f_de2" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="1" source="c8f_a2" target="c8f_a3"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c8f_de3" value="Bearer token" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="1" source="c8f_a3" target="c8f_b4"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c8f_de4" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="1" source="c8f_b4" target="c8f_b5"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c8f_de5" value="valid body" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="1" source="c8f_b5" target="c8f_c6"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c8f_de6" value="cache miss" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="1" source="c8f_c6" target="c8f_c7"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c8f_de7" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="1" source="c8f_c7" target="c8f_d8"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c8f_de8" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="1" source="c8f_d8" target="c8f_d9"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c8f_de9" value="trigger" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;dashed=1;" edge="1" parent="1" source="c8f_d9" target="c8f_e2n"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c8f_de10" value="event" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;dashed=1;" edge="1" parent="1" source="c8f_d8" target="c8f_e1n"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c8f_de11" value="note created" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="1" source="c8f_d9" target="c8f_c10"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c8f_de12" value="ClipResult" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="1" source="c8f_c10" target="c8f_b11"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c8f_de13" value="response" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="1" source="c8f_b11" target="c8f_a12"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c8f_de14" value="no embed" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;dashed=1;" edge="1" parent="1" source="c8f_c10" target="c8f_e3n"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c8f_de15" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="1" source="c8f_t1" target="c8f_t2"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c8f_de16" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="1" source="c8f_t2" target="c8f_t3"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c8f_de17" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="1" source="c8f_t3" target="c8f_t4"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c8f_de18" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;" edge="1" parent="1" source="c8f_t4" target="c8f_t5"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="c8f_de19" value="alt saas" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=10;dashed=1;" edge="1" parent="1" source="c8f_t1" target="c8f_t6"><mxGeometry relative="1" as="geometry" /></mxCell>
    </root>
  </mxGraphModel>
</diagram>
<diagram id="c9-system-page" name="C9 Platform Operations &amp; Delivery — System">
  <mxGraphModel dx="800" dy="600" grid="0" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1600" pageHeight="1300" math="0" shadow="0">
    <root>
      <mxCell id="0" />
      <mxCell id="1" parent="0" />

      <!-- ============ SIMPLIFIED band ============ -->
      <mxCell id="c9s_band_simple" value="SIMPLIFIED — C9 in one glance" style="swimlane;startSize=28;rounded=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=14;fontStyle=1;" vertex="1" parent="1">
        <mxGeometry x="40" y="40" width="1520" height="320" as="geometry" />
      </mxCell>
      <mxCell id="c9s_s1" value="Vercel Cron scheduler&#10;(vercel.json)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=13;" vertex="1" parent="c9s_band_simple">
        <mxGeometry x="30" y="60" width="180" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c9s_s2" value="Cron routes&#10;digest 13:00 UTC / trash-prune 04:00 UTC" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=13;" vertex="1" parent="c9s_band_simple">
        <mxGeometry x="280" y="60" width="220" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c9s_s3" value="Storage adapters&#10;(C1 Local / C7 Supabase)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=13;" vertex="1" parent="c9s_band_simple">
        <mxGeometry x="570" y="60" width="190" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c9s_s7" value="Publishers: chokidar watcher&#10;+ LocalAdapter writes" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=13;" vertex="1" parent="c9s_band_simple">
        <mxGeometry x="30" y="190" width="200" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c9s_s4" value="In-process events bus&#10;(globalThis singleton)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=13;" vertex="1" parent="c9s_band_simple">
        <mxGeometry x="300" y="190" width="190" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c9s_s5" value="SSE endpoint&#10;GET /api/events" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=13;" vertex="1" parent="c9s_band_simple">
        <mxGeometry x="570" y="190" width="180" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c9s_s6" value="Browser tabs&#10;debounced router.refresh (500ms)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=13;" vertex="1" parent="c9s_band_simple">
        <mxGeometry x="820" y="190" width="210" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c9s_s8" value="Dev/test endpoints&#10;rescan / reset / seed-note" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=13;" vertex="1" parent="c9s_band_simple">
        <mxGeometry x="1080" y="60" width="200" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c9s_s9" value="CLIs + tooling&#10;seed / bench / ensure-native / build:mcp" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=13;" vertex="1" parent="c9s_band_simple">
        <mxGeometry x="1080" y="190" width="200" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c9s_s10" value="Test pyramid&#10;+ CI gates (perf, pgTAP)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=13;" vertex="1" parent="c9s_band_simple">
        <mxGeometry x="1320" y="120" width="170" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c9s_se1" value="GET + Bearer CRON_SECRET" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c9s_s1" target="c9s_s2">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c9s_se2" value="runDigest / hard delete" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c9s_s2" target="c9s_s3">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c9s_se3" value="emit ChangeEvent" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c9s_s7" target="c9s_s4">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c9s_se4" value="subscribe" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c9s_s4" target="c9s_s5">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c9s_se5" value="SSE, 25s heartbeat" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c9s_s5" target="c9s_s6">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c9s_se6" value="Playwright POSTs" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c9s_s10" target="c9s_s8">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c9s_se7" value="CI runs CLIs" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c9s_s10" target="c9s_s9">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>

      <!-- ============ DETAILED band ============ -->
      <mxCell id="c9s_band_detail" value="DETAILED — every component, grouped by sub-area" style="swimlane;startSize=28;rounded=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=14;fontStyle=1;" vertex="1" parent="1">
        <mxGeometry x="40" y="400" width="1520" height="860" as="geometry" />
      </mxCell>

      <!-- Scheduled ops -->
      <mxCell id="c9s_grp_cron" value="Scheduled operations" style="swimlane;startSize=24;rounded=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;fontStyle=1;" vertex="1" parent="c9s_band_detail">
        <mxGeometry x="20" y="40" width="460" height="230" as="geometry" />
      </mxCell>
      <mxCell id="c9s_d1" value="vercel.json cron manifest&#10;digest 0 13 * * * / prune 0 4 * * *" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c9s_grp_cron">
        <mxGeometry x="15" y="40" width="200" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c9s_d2" value="digest route&#10;app/api/cron/digest/route.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c9s_grp_cron">
        <mxGeometry x="240" y="40" width="200" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c9s_d3" value="trash-prune route&#10;app/api/cron/trash-prune/route.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c9s_grp_cron">
        <mxGeometry x="240" y="115" width="200" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c9s_d4" value="runDigest (C4)&#10;lib/ai/digest-runner.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=11;" vertex="1" parent="c9s_grp_cron">
        <mxGeometry x="15" y="115" width="200" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c9s_d4b" value="service-role client (C7)&#10;lib/auth/supabase.ts — saas fan-out" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=11;" vertex="1" parent="c9s_grp_cron">
        <mxGeometry x="130" y="185" width="200" height="40" as="geometry" />
      </mxCell>

      <!-- Live delivery -->
      <mxCell id="c9s_grp_live" value="Live-update delivery" style="swimlane;startSize=24;rounded=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;fontStyle=1;" vertex="1" parent="c9s_band_detail">
        <mxGeometry x="20" y="290" width="460" height="330" as="geometry" />
      </mxCell>
      <mxCell id="c9s_d5" value="instrumentation.ts register()&#10;boot-time watcher start" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c9s_grp_live">
        <mxGeometry x="15" y="35" width="200" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c9s_d6" value="chokidar watcher&#10;lib/watch/chokidar.ts (markEcho 750ms)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c9s_grp_live">
        <mxGeometry x="240" y="35" width="200" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c9s_d7" value="adapter-write emits&#10;lib/storage/local/writes.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c9s_grp_live">
        <mxGeometry x="15" y="105" width="200" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c9s_d8" value="events bus (ring 256)&#10;lib/watch/events-bus.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c9s_grp_live">
        <mxGeometry x="240" y="105" width="200" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c9s_d9" value="SSE endpoint&#10;app/api/events/route.ts (no replay)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c9s_grp_live">
        <mxGeometry x="240" y="175" width="200" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c9s_d10" value="VaultEventsBridge&#10;components/vault-events-bridge.tsx" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c9s_grp_live">
        <mxGeometry x="15" y="175" width="200" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c9s_d11" value="useVaultEvents (unmounted)&#10;hooks/use-vault-events.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;dashed=1;fontSize=11;" vertex="1" parent="c9s_grp_live">
        <mxGeometry x="15" y="250" width="200" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c9s_d12" value="kill switches&#10;ELI_DISABLE_LIVE_EVENTS / window flag" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c9s_grp_live">
        <mxGeometry x="240" y="250" width="200" height="55" as="geometry" />
      </mxCell>

      <!-- Dev/test endpoints -->
      <mxCell id="c9s_grp_dev" value="Dev/test endpoints (.eli-test guard)" style="swimlane;startSize=24;rounded=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=12;fontStyle=1;" vertex="1" parent="c9s_band_detail">
        <mxGeometry x="500" y="40" width="280" height="230" as="geometry" />
      </mxCell>
      <mxCell id="c9s_d13" value="rescan — drop caches + scanVault&#10;app/api/dev/rescan/route.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c9s_grp_dev">
        <mxGeometry x="15" y="35" width="250" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c9s_d14" value="reset — closeAll sqlite + caches&#10;app/api/dev/reset/route.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c9s_grp_dev">
        <mxGeometry x="15" y="100" width="250" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c9s_d15" value="seed-note — mint fresh note&#10;app/api/dev/seed-note/route.ts" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c9s_grp_dev">
        <mxGeometry x="15" y="165" width="250" height="55" as="geometry" />
      </mxCell>

      <!-- CLIs and packaging -->
      <mxCell id="c9s_grp_cli" value="CLIs, install &amp; packaging (scripts/)" style="swimlane;startSize=24;rounded=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=12;fontStyle=1;" vertex="1" parent="c9s_band_detail">
        <mxGeometry x="500" y="290" width="280" height="330" as="geometry" />
      </mxCell>
      <mxCell id="c9s_d16" value="seed-vault.mjs&#10;deterministic mulberry32, seed 42" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c9s_grp_cli">
        <mxGeometry x="15" y="35" width="250" height="50" as="geometry" />
      </mxCell>
      <mxCell id="c9s_d17" value="seed-config.mjs&#10;ready-made ~/.eli/config.json (0600)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c9s_grp_cli">
        <mxGeometry x="15" y="93" width="250" height="50" as="geometry" />
      </mxCell>
      <mxCell id="c9s_d18" value="bench-search.mjs&#10;p95 budget, exit 3 on breach" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c9s_grp_cli">
        <mxGeometry x="15" y="151" width="250" height="50" as="geometry" />
      </mxCell>
      <mxCell id="c9s_d19" value="ensure-native.mjs (postinstall)&#10;better-sqlite3 ABI probe + rebuild" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c9s_grp_cli">
        <mxGeometry x="15" y="209" width="250" height="50" as="geometry" />
      </mxCell>
      <mxCell id="c9s_d20" value="build-mcp-bin.mjs (prepack)&#10;esbuild -&gt; bin/eli-mcp.mjs (C5)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#9673a6;fontSize=11;" vertex="1" parent="c9s_grp_cli">
        <mxGeometry x="15" y="267" width="250" height="50" as="geometry" />
      </mxCell>

      <!-- Test pyramid -->
      <mxCell id="c9s_grp_test" value="Test pyramid" style="swimlane;startSize=24;rounded=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=12;fontStyle=1;" vertex="1" parent="c9s_band_detail">
        <mxGeometry x="800" y="40" width="440" height="580" as="geometry" />
      </mxCell>
      <mxCell id="c9s_d21" value="~75 colocated *.test.ts (lib/ + app/)&#10;run by pnpm test (vitest.config.ts)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d6b656;fontSize=11;" vertex="1" parent="c9s_grp_test">
        <mxGeometry x="15" y="35" width="410" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c9s_d22" value="tests/unit — embed-backfill CLI args (1 suite)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d6b656;fontSize=11;" vertex="1" parent="c9s_grp_test">
        <mxGeometry x="15" y="105" width="410" height="45" as="geometry" />
      </mxCell>
      <mxCell id="c9s_d23" value="PGlite harness — tests/_helpers/pglite.ts&#10;in-process Postgres + pgvector, all 16 pg migrations, ~20 tests" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d6b656;fontSize=11;" vertex="1" parent="c9s_grp_test">
        <mxGeometry x="15" y="165" width="410" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c9s_d24" value="adapter contract — tests/adapter&#10;Local (favorites skipped) / Memory / JsonFile; no Supabase run" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d6b656;fontSize=11;" vertex="1" parent="c9s_grp_test">
        <mxGeometry x="15" y="235" width="410" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c9s_d25" value="MCP harness — tests/mcp&#10;16-tool surface over stdio + HTTP (in-memory, no server)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d6b656;fontSize=11;" vertex="1" parent="c9s_grp_test">
        <mxGeometry x="15" y="305" width="410" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c9s_d26" value="pgTAP RLS — tests/rls&#10;4 SQL files, 21 assertions, act_as role helpers" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d6b656;fontSize=11;" vertex="1" parent="c9s_grp_test">
        <mxGeometry x="15" y="375" width="410" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c9s_d27" value="Playwright e2e — tests/e2e (7 specs)&#10;port 3838, serial, chromium, .eli-test fixtures,&#10;ELI_DISABLE_LIVE_EVENTS=1, ELI_LEGACY_EDITOR=1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d6b656;fontSize=11;" vertex="1" parent="c9s_grp_test">
        <mxGeometry x="15" y="445" width="410" height="65" as="geometry" />
      </mxCell>
      <mxCell id="c9s_d28" value="eslint.config.mjs — flat config, next + ts-eslint" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d6b656;fontSize=11;" vertex="1" parent="c9s_grp_test">
        <mxGeometry x="15" y="525" width="410" height="40" as="geometry" />
      </mxCell>

      <!-- CI gates -->
      <mxCell id="c9s_grp_ci" value="CI gates (.github/workflows)" style="swimlane;startSize=24;rounded=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;fontStyle=1;" vertex="1" parent="c9s_band_detail">
        <mxGeometry x="1260" y="40" width="240" height="230" as="geometry" />
      </mxCell>
      <mxCell id="c9s_d29" value="perf.yml&#10;10k-note vault, p95 &lt;= 450ms, exit 3 fails" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c9s_grp_ci">
        <mxGeometry x="15" y="35" width="210" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c9s_d30" value="pgtap.yml&#10;pgvector:pg17 container + pg_prove" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c9s_grp_ci">
        <mxGeometry x="15" y="115" width="210" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c9s_note1" value="Note: no CI workflow runs lint,&#10;typecheck, vitest, or e2e" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;dashed=1;fontSize=11;" vertex="1" parent="c9s_band_detail">
        <mxGeometry x="1260" y="290" width="240" height="60" as="geometry" />
      </mxCell>

      <!-- Detailed edges -->
      <mxCell id="c9s_de1" value="GET + Bearer" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c9s_d1" target="c9s_d2">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c9s_de2" value="GET + Bearer" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c9s_d1" target="c9s_d3">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c9s_de3" value="delegates" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c9s_d2" target="c9s_d4">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c9s_de4" value="boot start" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c9s_d5" target="c9s_d6">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c9s_de5" value="emit" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c9s_d6" target="c9s_d8">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c9s_de6" value="emit direct" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c9s_d7" target="c9s_d8">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c9s_de7" value="subscribe" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c9s_d8" target="c9s_d9">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c9s_de8" value="EventSource" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c9s_d9" target="c9s_d10">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c9s_de9" value="disables" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;dashed=1;fontSize=11;" edge="1" parent="1" source="c9s_d12" target="c9s_d10">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c9s_de10" value="Playwright POSTs reset / seed / rescan" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c9s_d27" target="c9s_grp_dev">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c9s_de11" value="seeds + benches" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c9s_d29" target="c9s_d16">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c9s_de12" value="pg_prove" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c9s_d30" target="c9s_d26">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
    </root>
  </mxGraphModel>
</diagram>
<diagram id="c9-flows-page" name="C9 Platform Operations &amp; Delivery — Flows">
  <mxGraphModel dx="800" dy="600" grid="0" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1600" pageHeight="1360" math="0" shadow="0">
    <root>
      <mxCell id="0" />
      <mxCell id="1" parent="0" />

      <!-- ============ SIMPLIFIED band ============ -->
      <mxCell id="c9f_band_simple" value="SIMPLIFIED — live-update happy path (local mode)" style="swimlane;startSize=28;rounded=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=14;fontStyle=1;" vertex="1" parent="1">
        <mxGeometry x="40" y="40" width="1520" height="280" as="geometry" />
      </mxCell>
      <mxCell id="c9f_s1" value="1. External edit&#10;to note.md" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="c9f_band_simple">
        <mxGeometry x="20" y="90" width="160" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c9f_s2" value="2. chokidar&#10;detects change" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="c9f_band_simple">
        <mxGeometry x="205" y="90" width="160" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c9f_s3" value="3. markEcho check&#10;(skip own writes)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="c9f_band_simple">
        <mxGeometry x="390" y="90" width="160" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c9f_s4" value="4. updatePath&#10;re-indexes SQLite" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="c9f_band_simple">
        <mxGeometry x="575" y="90" width="160" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c9f_s5" value="5. emit ChangeEvent&#10;to events bus" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="c9f_band_simple">
        <mxGeometry x="760" y="90" width="160" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c9f_s6" value="6. SSE frame&#10;to every open tab" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="c9f_band_simple">
        <mxGeometry x="945" y="90" width="160" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c9f_s7" value="7. debounce&#10;500ms" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="c9f_band_simple">
        <mxGeometry x="1130" y="90" width="160" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c9f_s8" value="8. router.refresh&#10;fresh RSC render" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="c9f_band_simple">
        <mxGeometry x="1315" y="90" width="160" height="70" as="geometry" />
      </mxCell>
      <mxCell id="c9f_se1" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c9f_s1" target="c9f_s2">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c9f_se2" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c9f_s2" target="c9f_s3">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c9f_se3" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c9f_s3" target="c9f_s4">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c9f_se4" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c9f_s4" target="c9f_s5">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c9f_se5" value="data {kind,path,at}" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c9f_s5" target="c9f_s6">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c9f_se6" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c9f_s6" target="c9f_s7">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c9f_se7" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c9f_s7" target="c9f_s8">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>

      <!-- ============ DETAILED band ============ -->
      <mxCell id="c9f_band_detail" value="DETAILED — swimlane per actor, numbered steps + side effects" style="swimlane;startSize=28;rounded=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=14;fontStyle=1;" vertex="1" parent="1">
        <mxGeometry x="40" y="360" width="1520" height="960" as="geometry" />
      </mxCell>

      <!-- Flow A lanes -->
      <mxCell id="c9f_laneA1" value="FLOW A (live update) — Editor / LocalAdapter" style="swimlane;startSize=24;rounded=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;fontStyle=1;" vertex="1" parent="c9f_band_detail">
        <mxGeometry x="20" y="40" width="1480" height="100" as="geometry" />
      </mxCell>
      <mxCell id="c9f_a1" value="1. External editor writes note.md on disk" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c9f_laneA1">
        <mxGeometry x="15" y="32" width="220" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c9f_a1b" value="1'. In-app save: writes.ts emits directly&#10;+ markEcho so watcher skips fs echo" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c9f_laneA1">
        <mxGeometry x="260" y="32" width="250" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c9f_laneA2" value="FLOW A — Chokidar watcher (lib/watch/chokidar.ts)" style="swimlane;startSize=24;rounded=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;fontStyle=1;" vertex="1" parent="c9f_band_detail">
        <mxGeometry x="20" y="150" width="1480" height="100" as="geometry" />
      </mxCell>
      <mxCell id="c9f_a2" value="2. fs event (.md only,&#10;ignores .git / node_modules / .next)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c9f_laneA2">
        <mxGeometry x="120" y="32" width="220" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c9f_a3" value="3. Echo check — skip if markEcho&#10;entry fresher than 750ms TTL" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c9f_laneA2">
        <mxGeometry x="380" y="32" width="230" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c9f_a4" value="4. updatePath() — incremental&#10;SQLite re-index (side effect)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c9f_laneA2">
        <mxGeometry x="650" y="32" width="220" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c9f_laneA3" value="FLOW A — Events bus (lib/watch/events-bus.ts)" style="swimlane;startSize=24;rounded=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;fontStyle=1;" vertex="1" parent="c9f_band_detail">
        <mxGeometry x="20" y="260" width="1480" height="100" as="geometry" />
      </mxCell>
      <mxCell id="c9f_a5" value="5. emit ChangeEvent — push to 256-entry&#10;ring buffer, fan out to all listeners&#10;(per-listener errors swallowed)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c9f_laneA3">
        <mxGeometry x="650" y="30" width="280" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c9f_laneA4" value="FLOW A — SSE route (app/api/events/route.ts)" style="swimlane;startSize=24;rounded=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;fontStyle=1;" vertex="1" parent="c9f_band_detail">
        <mxGeometry x="20" y="370" width="1480" height="100" as="geometry" />
      </mxCell>
      <mxCell id="c9f_a6" value="6. data: {kind,path,at} frame per subscriber&#10;25s comment heartbeats, no backlog replay,&#10;unsubscribe + close on request abort" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c9f_laneA4">
        <mxGeometry x="950" y="30" width="300" height="60" as="geometry" />
      </mxCell>
      <mxCell id="c9f_laneA5" value="FLOW A — Browser tab (components/vault-events-bridge.tsx)" style="swimlane;startSize=24;rounded=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;fontStyle=1;" vertex="1" parent="c9f_band_detail">
        <mxGeometry x="20" y="480" width="1480" height="100" as="geometry" />
      </mxCell>
      <mxCell id="c9f_a7" value="7. onmessage — debounce 500ms&#10;(bursts collapse to one refresh)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#82b366;fontSize=11;" vertex="1" parent="c9f_laneA5">
        <mxGeometry x="1000" y="32" width="220" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c9f_a8" value="8. router.refresh() — RSC re-render&#10;reads fresh index; all tabs converge" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c9f_laneA5">
        <mxGeometry x="1250" y="32" width="220" height="55" as="geometry" />
      </mxCell>

      <!-- Flow A edges -->
      <mxCell id="c9f_ae1" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c9f_a1" target="c9f_a2">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c9f_ae2" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c9f_a2" target="c9f_a3">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c9f_ae3" value="not an echo" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c9f_a3" target="c9f_a4">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c9f_ae4" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c9f_a4" target="c9f_a5">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c9f_ae5" value="emit direct (bypasses watcher)" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;dashed=1;fontSize=11;" edge="1" parent="1" source="c9f_a1b" target="c9f_a5">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c9f_ae6" value="subscribe fan-out" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c9f_a5" target="c9f_a6">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c9f_ae7" value="EventSource stream" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c9f_a6" target="c9f_a7">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c9f_ae8" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c9f_a7" target="c9f_a8">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>

      <!-- Flow B lanes -->
      <mxCell id="c9f_laneB1" value="FLOW B (cron digest) — Vercel Cron scheduler (or manual curl)" style="swimlane;startSize=24;rounded=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;fontStyle=1;" vertex="1" parent="c9f_band_detail">
        <mxGeometry x="20" y="610" width="1480" height="100" as="geometry" />
      </mxCell>
      <mxCell id="c9f_b1" value="1. GET /api/cron/digest at 13:00 UTC&#10;Authorization: Bearer CRON_SECRET" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c9f_laneB1">
        <mxGeometry x="15" y="32" width="250" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c9f_b9" value="8. 200 {processed, errors, skipped}&#10;inspectable in Vercel dashboard" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c9f_laneB1">
        <mxGeometry x="1230" y="32" width="235" height="55" as="geometry" />
      </mxCell>
      <mxCell id="c9f_laneB2" value="FLOW B — Cron route (app/api/cron/digest/route.ts)" style="swimlane;startSize=24;rounded=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;fontStyle=1;" vertex="1" parent="c9f_band_detail">
        <mxGeometry x="20" y="720" width="1480" height="110" as="geometry" />
      </mxCell>
      <mxCell id="c9f_b2" value="2. GET aliased to POST.&#10;badAuth(): 401 if secret&#10;unset or mismatched" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c9f_laneB2">
        <mxGeometry x="120" y="32" width="200" height="65" as="geometry" />
      </mxCell>
      <mxCell id="c9f_b3" value="3. Window = ?date or yesterday,&#10;floored to UTC day start&#10;(invalid date -&gt; 400)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c9f_laneB2">
        <mxGeometry x="350" y="32" width="210" height="65" as="geometry" />
      </mxCell>
      <mxCell id="c9f_b4" value="4a. local: getActiveVault()&#10;-&gt; LocalAdapter.forVault&#10;(none -&gt; skipped: no-active-vault)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c9f_laneB2">
        <mxGeometry x="590" y="32" width="220" height="65" as="geometry" />
      </mxCell>
      <mxCell id="c9f_b5" value="4b. saas: service-role client&#10;-&gt; select all workspaces&#10;-&gt; SupabaseAdapter.fromClient each" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c9f_laneB2">
        <mxGeometry x="840" y="32" width="230" height="65" as="geometry" />
      </mxCell>
      <mxCell id="c9f_laneB3" value="FLOW B — Storage adapter + runDigest (lib/ai/digest-runner.ts)" style="swimlane;startSize=24;rounded=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;fontStyle=1;" vertex="1" parent="c9f_band_detail">
        <mxGeometry x="20" y="840" width="1480" height="105" as="geometry" />
      </mxCell>
      <mxCell id="c9f_b6" value="5. runDigest() per adapter&#10;(same path as the manual&#10;Generate-digest-now button)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c9f_laneB3">
        <mxGeometry x="590" y="30" width="220" height="65" as="geometry" />
      </mxCell>
      <mxCell id="c9f_b7" value="6. Upsert digest note — idempotent&#10;per UTC day (side effect);&#10;per-workspace errors collected" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=11;" vertex="1" parent="c9f_laneB3">
        <mxGeometry x="840" y="30" width="230" height="65" as="geometry" />
      </mxCell>
      <mxCell id="c9f_b8" value="7. Loop continues across&#10;workspaces despite failures" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#6c8ebf;fontSize=11;" vertex="1" parent="c9f_laneB3">
        <mxGeometry x="1100" y="30" width="200" height="65" as="geometry" />
      </mxCell>

      <!-- Flow B edges -->
      <mxCell id="c9f_be1" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c9f_b1" target="c9f_b2">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c9f_be2" value="authorized" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c9f_b2" target="c9f_b3">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c9f_be3" value="ELI_MODE=local" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c9f_b3" target="c9f_b4">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c9f_be4" value="saas" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c9f_b3" target="c9f_b5">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c9f_be5" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c9f_b4" target="c9f_b6">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c9f_be6" value="per workspace" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c9f_b5" target="c9f_b6">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c9f_be7" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c9f_b6" target="c9f_b7">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c9f_be8" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c9f_b7" target="c9f_b8">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
      <mxCell id="c9f_be9" value="JSON response" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="1" source="c9f_b8" target="c9f_b9">
        <mxGeometry relative="1" as="geometry" />
      </mxCell>
    </root>
  </mxGraphModel>
</diagram>
<diagram id="j1-local-loop" name="Journey — Local Knowledge Loop">
  <mxGraphModel dx="800" dy="600" grid="0" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="3200" pageHeight="1400" math="0" shadow="0">
    <root>
      <mxCell id="0" />
      <mxCell id="1" parent="0" />
      <mxCell id="j1_simp" value="SIMPLIFIED — Local-first knowledge loop (pnpm dev, ELI_MODE=local)" style="swimlane;startSize=32;rounded=1;html=1;fontSize=15;fontStyle=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1">
        <mxGeometry x="40" y="40" width="3080" height="220" as="geometry" />
      </mxCell>
      <mxCell id="j1_s1" value="pnpm dev boots Next on :3737&#10;watcher starts for active vault" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=13;" vertex="1" parent="j1_simp">
        <mxGeometry x="40" y="70" width="260" height="90" as="geometry" />
      </mxCell>
      <mxCell id="j1_s2" value="Pick vault&#10;initial scan into SQLite + FTS5" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=13;" vertex="1" parent="j1_simp">
        <mxGeometry x="370" y="70" width="260" height="90" as="geometry" />
      </mxCell>
      <mxCell id="j1_s3" value="Edit note in BlockNote&#10;debounced save to .md on disk" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=13;" vertex="1" parent="j1_simp">
        <mxGeometry x="700" y="70" width="260" height="90" as="geometry" />
      </mxCell>
      <mxCell id="j1_s4" value="Chokidar sees external edits&#10;re-index + SSE refresh" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=13;" vertex="1" parent="j1_simp">
        <mxGeometry x="1030" y="70" width="260" height="90" as="geometry" />
      </mxCell>
      <mxCell id="j1_s5" value="Auto-embed queue&#10;one 1536-dim vector per note" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=13;" vertex="1" parent="j1_simp">
        <mxGeometry x="1360" y="70" width="260" height="90" as="geometry" />
      </mxCell>
      <mxCell id="j1_s6" value="Hybrid search&#10;FTS + cosine KNN + RRF" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=13;" vertex="1" parent="j1_simp">
        <mxGeometry x="1690" y="70" width="260" height="90" as="geometry" />
      </mxCell>
      <mxCell id="j1_s7" value="RAG chat with tools&#10;map-reduce over top-8 notes" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=13;" vertex="1" parent="j1_simp">
        <mxGeometry x="2020" y="70" width="260" height="90" as="geometry" />
      </mxCell>
      <mxCell id="j1_s8" value="Git auto-commit loop&#10;+ diff / section restore" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=13;" vertex="1" parent="j1_simp">
        <mxGeometry x="2350" y="70" width="260" height="90" as="geometry" />
      </mxCell>
      <mxCell id="j1_s9" value="Daily digest note&#10;cron on Vercel, manual locally" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=13;" vertex="1" parent="j1_simp">
        <mxGeometry x="2680" y="70" width="260" height="90" as="geometry" />
      </mxCell>
      <mxCell id="j1_se1" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j1_simp" source="j1_s1" target="j1_s2"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j1_se2" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j1_simp" source="j1_s2" target="j1_s3"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j1_se3" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j1_simp" source="j1_s3" target="j1_s4"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j1_se4" value="every save" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j1_simp" source="j1_s4" target="j1_s5"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j1_se5" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j1_simp" source="j1_s5" target="j1_s6"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j1_se6" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j1_simp" source="j1_s6" target="j1_s7"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j1_se7" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j1_simp" source="j1_s7" target="j1_s8"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j1_se8" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j1_simp" source="j1_s8" target="j1_s9"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j1_det" value="DETAILED — swimlane per actor, numbered steps (file:line evidence in docs/architecture/10-end-to-end-journeys.md)" style="swimlane;startSize=32;rounded=1;html=1;fontSize=15;fontStyle=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1">
        <mxGeometry x="40" y="300" width="3080" height="1040" as="geometry" />
      </mxCell>
      <mxCell id="j1_l1" value="User + Browser UI" style="swimlane;horizontal=0;startSize=40;rounded=0;html=1;fontSize=13;fontStyle=1;fillColor=#dae8fc;strokeColor=#6c8ebf;swimlaneFillColor=#ffffff;" vertex="1" parent="j1_det">
        <mxGeometry x="10" y="40" width="3060" height="160" as="geometry" />
      </mxCell>
      <mxCell id="j1_l2" value="Server Actions + API routes" style="swimlane;horizontal=0;startSize=40;rounded=0;html=1;fontSize=13;fontStyle=1;fillColor=#e1d5e7;strokeColor=#9673a6;swimlaneFillColor=#ffffff;" vertex="1" parent="j1_det">
        <mxGeometry x="10" y="205" width="3060" height="160" as="geometry" />
      </mxCell>
      <mxCell id="j1_l3" value="Storage core (LocalAdapter + SQLite index)" style="swimlane;horizontal=0;startSize=40;rounded=0;html=1;fontSize=13;fontStyle=1;fillColor=#d5e8d4;strokeColor=#82b366;swimlaneFillColor=#ffffff;" vertex="1" parent="j1_det">
        <mxGeometry x="10" y="370" width="3060" height="160" as="geometry" />
      </mxCell>
      <mxCell id="j1_l4" value="Watcher + SSE eventing" style="swimlane;horizontal=0;startSize=40;rounded=0;html=1;fontSize=13;fontStyle=1;fillColor=#f5f5f5;strokeColor=#666666;swimlaneFillColor=#ffffff;" vertex="1" parent="j1_det">
        <mxGeometry x="10" y="535" width="3060" height="160" as="geometry" />
      </mxCell>
      <mxCell id="j1_l5" value="AI (EmbedQueue + Gateway)" style="swimlane;horizontal=0;startSize=40;rounded=0;html=1;fontSize=13;fontStyle=1;fillColor=#ffe6cc;strokeColor=#d79b00;swimlaneFillColor=#ffffff;" vertex="1" parent="j1_det">
        <mxGeometry x="10" y="700" width="3060" height="160" as="geometry" />
      </mxCell>
      <mxCell id="j1_l6" value="Git loop + Cron digest" style="swimlane;horizontal=0;startSize=40;rounded=0;html=1;fontSize=13;fontStyle=1;fillColor=#fff2cc;strokeColor=#d6b656;swimlaneFillColor=#ffffff;" vertex="1" parent="j1_det">
        <mxGeometry x="10" y="865" width="3060" height="160" as="geometry" />
      </mxCell>
      <mxCell id="j1_d1" value="1. pnpm dev, open localhost:3737" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="j1_l1">
        <mxGeometry x="60" y="30" width="170" height="100" as="geometry" />
      </mxCell>
      <mxCell id="j1_d2" value="2. instrumentation.register() starts chokidar for active vault" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=12;" vertex="1" parent="j1_l4">
        <mxGeometry x="245" y="30" width="170" height="100" as="geometry" />
      </mxCell>
      <mxCell id="j1_d3" value="3. Pick vault in VaultPicker (or sample vault)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="j1_l1">
        <mxGeometry x="430" y="30" width="170" height="100" as="geometry" />
      </mxCell>
      <mxCell id="j1_d4" value="4. pickVaultAction -&gt; scanVault initial index" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=12;" vertex="1" parent="j1_l2">
        <mxGeometry x="615" y="30" width="170" height="100" as="geometry" />
      </mxCell>
      <mxCell id="j1_d5" value="5. SQLite upserts notes/tags/links/versions, FTS5 triggers index" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="j1_l3">
        <mxGeometry x="800" y="30" width="170" height="100" as="geometry" />
      </mxCell>
      <mxCell id="j1_d6" value="6. Edit note in BlockNote, 1.5s debounce / Cmd+S" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="j1_l1">
        <mxGeometry x="985" y="30" width="170" height="100" as="geometry" />
      </mxCell>
      <mxCell id="j1_d7" value="7. saveNoteAction -&gt; updateNote (OCC conflict snapshot)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=12;" vertex="1" parent="j1_l2">
        <mxGeometry x="1170" y="30" width="170" height="100" as="geometry" />
      </mxCell>
      <mxCell id="j1_d8" value="8. atomicWrite .md + new version row + FTS re-index" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="j1_l3">
        <mxGeometry x="1355" y="30" width="170" height="100" as="geometry" />
      </mxCell>
      <mxCell id="j1_d9" value="9. enqueueCommit, 30s debounce, commit 'eli: update path'" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=12;" vertex="1" parent="j1_l6">
        <mxGeometry x="1540" y="30" width="170" height="100" as="geometry" />
      </mxCell>
      <mxCell id="j1_d10" value="10. scheduleEmbed 30s -&gt; embedMany 1536-dim -&gt; note_embeddings BLOB" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=12;" vertex="1" parent="j1_l5">
        <mxGeometry x="1725" y="30" width="170" height="100" as="geometry" />
      </mxCell>
      <mxCell id="j1_d11" value="11. External edit in Obsidian / vim" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="j1_l1">
        <mxGeometry x="1910" y="30" width="170" height="100" as="geometry" />
      </mxCell>
      <mxCell id="j1_d12" value="12. chokidar change -&gt; hash-skip re-scan -&gt; SSE -&gt; router.refresh" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=12;" vertex="1" parent="j1_l4">
        <mxGeometry x="2095" y="30" width="170" height="100" as="geometry" />
      </mxCell>
      <mxCell id="j1_d13" value="13. Hybrid search + RAG chat (tools, allow-writes)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="j1_l1">
        <mxGeometry x="2280" y="30" width="170" height="100" as="geometry" />
      </mxCell>
      <mxCell id="j1_d14" value="14. /api/search/hybrid FTS+KNN+RRF and /api/ai/chat map-reduce" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=12;" vertex="1" parent="j1_l2">
        <mxGeometry x="2465" y="30" width="170" height="100" as="geometry" />
      </mxCell>
      <mxCell id="j1_d15" value="15. Digest: cron 13:00 UTC or Generate now -&gt; digests/date.md" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=12;" vertex="1" parent="j1_l6">
        <mxGeometry x="2650" y="30" width="170" height="100" as="geometry" />
      </mxCell>
      <mxCell id="j1_d16" value="16. Diff view + restore section -&gt; new version re-enters loops" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="j1_l1">
        <mxGeometry x="2835" y="30" width="170" height="100" as="geometry" />
      </mxCell>
      <mxCell id="j1_de1" value="boot" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j1_det" source="j1_d1" target="j1_d2"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j1_de2" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j1_det" source="j1_d1" target="j1_d3"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j1_de3" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j1_det" source="j1_d3" target="j1_d4"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j1_de4" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j1_det" source="j1_d4" target="j1_d5"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j1_de5" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j1_det" source="j1_d5" target="j1_d6"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j1_de6" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j1_det" source="j1_d6" target="j1_d7"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j1_de7" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j1_det" source="j1_d7" target="j1_d8"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j1_de8" value="best-effort" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j1_det" source="j1_d8" target="j1_d9"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j1_de9" value="fire-and-forget" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j1_det" source="j1_d7" target="j1_d10"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j1_de10" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j1_det" source="j1_d11" target="j1_d12"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j1_de11" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j1_det" source="j1_d13" target="j1_d14"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j1_de12" value="digest is a normal note" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;dashed=1;" edge="1" parent="j1_det" source="j1_d15" target="j1_d8"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j1_de13" value="restore re-enters save loop" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;dashed=1;" edge="1" parent="j1_det" source="j1_d16" target="j1_d7"><mxGeometry relative="1" as="geometry" /></mxCell>
    </root>
  </mxGraphModel>
</diagram>
<diagram id="j2-saas-collab" name="Journey — SaaS Collaboration Loop">
  <mxGraphModel dx="800" dy="600" grid="0" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="3200" pageHeight="1400" math="0" shadow="0">
    <root>
      <mxCell id="0" />
      <mxCell id="1" parent="0" />
      <mxCell id="j2_simp" value="SIMPLIFIED — SaaS collaboration loop (ELI_MODE=saas, Supabase + RLS)" style="swimlane;startSize=32;rounded=1;html=1;fontSize=15;fontStyle=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1">
        <mxGeometry x="40" y="40" width="3080" height="220" as="geometry" />
      </mxCell>
      <mxCell id="j2_s1" value="Sign in via magic link or OAuth&#10;Supabase session cookie" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=13;" vertex="1" parent="j2_simp">
        <mxGeometry x="40" y="70" width="260" height="90" as="geometry" />
      </mxCell>
      <mxCell id="j2_s2" value="Create workspace&#10;RLS insert + owner-membership trigger" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=13;" vertex="1" parent="j2_simp">
        <mxGeometry x="370" y="70" width="260" height="90" as="geometry" />
      </mxCell>
      <mxCell id="j2_s3" value="Invite teammate&#10;Resend email, sha256 token stored" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=13;" vertex="1" parent="j2_simp">
        <mxGeometry x="700" y="70" width="260" height="90" as="geometry" />
      </mxCell>
      <mxCell id="j2_s4" value="Accept invite&#10;service-role membership insert" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=13;" vertex="1" parent="j2_simp">
        <mxGeometry x="1030" y="70" width="260" height="90" as="geometry" />
      </mxCell>
      <mxCell id="j2_s5" value="Concurrent editing&#10;notes_save RPC + conflict snapshots" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=13;" vertex="1" parent="j2_simp">
        <mxGeometry x="1360" y="70" width="260" height="90" as="geometry" />
      </mxCell>
      <mxCell id="j2_s6" value="Realtime refresh toast&#10;postgres_changes, no auto-merge" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=13;" vertex="1" parent="j2_simp">
        <mxGeometry x="1690" y="70" width="260" height="90" as="geometry" />
      </mxCell>
      <mxCell id="j2_s7" value="Comments + share links&#10;RLS-gated, /s/token service-role" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=13;" vertex="1" parent="j2_simp">
        <mxGeometry x="2020" y="70" width="260" height="90" as="geometry" />
      </mxCell>
      <mxCell id="j2_s8" value="Digest cron fan-out&#10;per-workspace note, no email" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=13;" vertex="1" parent="j2_simp">
        <mxGeometry x="2350" y="70" width="260" height="90" as="geometry" />
      </mxCell>
      <mxCell id="j2_s9" value="Audit log + admin settings&#10;member.* and ai.tool.* only" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=13;" vertex="1" parent="j2_simp">
        <mxGeometry x="2680" y="70" width="260" height="90" as="geometry" />
      </mxCell>
      <mxCell id="j2_se1" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j2_simp" source="j2_s1" target="j2_s2"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j2_se2" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j2_simp" source="j2_s2" target="j2_s3"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j2_se3" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j2_simp" source="j2_s3" target="j2_s4"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j2_se4" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j2_simp" source="j2_s4" target="j2_s5"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j2_se5" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j2_simp" source="j2_s5" target="j2_s6"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j2_se6" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j2_simp" source="j2_s6" target="j2_s7"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j2_se7" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j2_simp" source="j2_s7" target="j2_s8"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j2_se8" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j2_simp" source="j2_s8" target="j2_s9"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j2_det" value="DETAILED — swimlane per actor, numbered steps (file:line evidence in docs/architecture/10-end-to-end-journeys.md)" style="swimlane;startSize=32;rounded=1;html=1;fontSize=15;fontStyle=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1">
        <mxGeometry x="40" y="300" width="3080" height="1040" as="geometry" />
      </mxCell>
      <mxCell id="j2_l1" value="Users (Members A + B, invitee, admin)" style="swimlane;horizontal=0;startSize=40;rounded=0;html=1;fontSize=13;fontStyle=1;fillColor=#dae8fc;strokeColor=#6c8ebf;swimlaneFillColor=#ffffff;" vertex="1" parent="j2_det">
        <mxGeometry x="10" y="40" width="3060" height="160" as="geometry" />
      </mxCell>
      <mxCell id="j2_l2" value="Middleware + Supabase Auth" style="swimlane;horizontal=0;startSize=40;rounded=0;html=1;fontSize=13;fontStyle=1;fillColor=#f5f5f5;strokeColor=#666666;swimlaneFillColor=#ffffff;" vertex="1" parent="j2_det">
        <mxGeometry x="10" y="205" width="3060" height="160" as="geometry" />
      </mxCell>
      <mxCell id="j2_l3" value="Server Actions + API routes" style="swimlane;horizontal=0;startSize=40;rounded=0;html=1;fontSize=13;fontStyle=1;fillColor=#e1d5e7;strokeColor=#9673a6;swimlaneFillColor=#ffffff;" vertex="1" parent="j2_det">
        <mxGeometry x="10" y="370" width="3060" height="160" as="geometry" />
      </mxCell>
      <mxCell id="j2_l4" value="Postgres (RLS + triggers)" style="swimlane;horizontal=0;startSize=40;rounded=0;html=1;fontSize=13;fontStyle=1;fillColor=#d5e8d4;strokeColor=#82b366;swimlaneFillColor=#ffffff;" vertex="1" parent="j2_det">
        <mxGeometry x="10" y="535" width="3060" height="160" as="geometry" />
      </mxCell>
      <mxCell id="j2_l5" value="Realtime + Email (Resend)" style="swimlane;horizontal=0;startSize=40;rounded=0;html=1;fontSize=13;fontStyle=1;fillColor=#ffe6cc;strokeColor=#d79b00;swimlaneFillColor=#ffffff;" vertex="1" parent="j2_det">
        <mxGeometry x="10" y="700" width="3060" height="160" as="geometry" />
      </mxCell>
      <mxCell id="j2_l6" value="Cron + Audit / Admin review" style="swimlane;horizontal=0;startSize=40;rounded=0;html=1;fontSize=13;fontStyle=1;fillColor=#fff2cc;strokeColor=#d6b656;swimlaneFillColor=#ffffff;" vertex="1" parent="j2_det">
        <mxGeometry x="10" y="865" width="3060" height="160" as="geometry" />
      </mxCell>
      <mxCell id="j2_d1" value="1. Sign up: magic link or Google/GitHub OAuth" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="j2_l1">
        <mxGeometry x="60" y="30" width="170" height="100" as="geometry" />
      </mxCell>
      <mxCell id="j2_d2" value="2. /api/auth/callback exchanges code -&gt; session cookie, profiles trigger" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=12;" vertex="1" parent="j2_l2">
        <mxGeometry x="245" y="30" width="170" height="100" as="geometry" />
      </mxCell>
      <mxCell id="j2_d3" value="3. Create workspace (name + slug)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="j2_l1">
        <mxGeometry x="430" y="30" width="170" height="100" as="geometry" />
      </mxCell>
      <mxCell id="j2_d4" value="4. createWorkspaceAction INSERT workspaces (RLS insert_self)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=12;" vertex="1" parent="j2_l3">
        <mxGeometry x="615" y="30" width="170" height="100" as="geometry" />
      </mxCell>
      <mxCell id="j2_d5" value="5. Bootstrap trigger inserts owner membership (SECURITY DEFINER)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="j2_l4">
        <mxGeometry x="800" y="30" width="170" height="100" as="geometry" />
      </mxCell>
      <mxCell id="j2_d6" value="6. createInviteAction -&gt; pending_invites sha256(token), 7-day TTL" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=12;" vertex="1" parent="j2_l3">
        <mxGeometry x="985" y="30" width="170" height="100" as="geometry" />
      </mxCell>
      <mxCell id="j2_d7" value="7. Resend invite email (console log without API key)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=12;" vertex="1" parent="j2_l5">
        <mxGeometry x="1170" y="30" width="170" height="100" as="geometry" />
      </mxCell>
      <mxCell id="j2_d8" value="8. Invitee: login via next param -&gt; acceptInviteAction(token)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="j2_l1">
        <mxGeometry x="1355" y="30" width="170" height="100" as="geometry" />
      </mxCell>
      <mxCell id="j2_d9" value="9. Service-role membership insert -&gt; audit_log member.added (null actor)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="j2_l4">
        <mxGeometry x="1540" y="30" width="170" height="100" as="geometry" />
      </mxCell>
      <mxCell id="j2_d10" value="10. Member A edits note, 1.5s debounce save" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="j2_l1">
        <mxGeometry x="1725" y="30" width="170" height="100" as="geometry" />
      </mxCell>
      <mxCell id="j2_d11" value="11. saveNoteAction -&gt; notes_save RPC (OCC + conflict snapshot)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=12;" vertex="1" parent="j2_l3">
        <mxGeometry x="1910" y="30" width="170" height="100" as="geometry" />
      </mxCell>
      <mxCell id="j2_d12" value="12. postgres_changes -&gt; Member B refresh toast (no auto-merge, no presence)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=12;" vertex="1" parent="j2_l5">
        <mxGeometry x="2095" y="30" width="170" height="100" as="geometry" />
      </mxCell>
      <mxCell id="j2_d13" value="13. Comments with mentions, share link minted (shown once)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="j2_l1">
        <mxGeometry x="2280" y="30" width="170" height="100" as="geometry" />
      </mxCell>
      <mxCell id="j2_d14" value="14. share_links sha256, /s/token resolved via service-role" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="j2_l4">
        <mxGeometry x="2465" y="30" width="170" height="100" as="geometry" />
      </mxCell>
      <mxCell id="j2_d15" value="15. Digest cron 13:00 UTC fan-out per workspace -&gt; digest note (no email)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=12;" vertex="1" parent="j2_l6">
        <mxGeometry x="2650" y="30" width="170" height="100" as="geometry" />
      </mxCell>
      <mxCell id="j2_d16" value="16. Admin: audit log, members, AI usage, PATs, rename/slug" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=12;" vertex="1" parent="j2_l6">
        <mxGeometry x="2835" y="30" width="170" height="100" as="geometry" />
      </mxCell>
      <mxCell id="j2_de1" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j2_det" source="j2_d1" target="j2_d2"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j2_de2" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j2_det" source="j2_d2" target="j2_d3"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j2_de3" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j2_det" source="j2_d3" target="j2_d4"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j2_de4" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j2_det" source="j2_d4" target="j2_d5"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j2_de5" value="admin invites" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j2_det" source="j2_d5" target="j2_d6"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j2_de6" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j2_det" source="j2_d6" target="j2_d7"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j2_de7" value="accept URL" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j2_det" source="j2_d7" target="j2_d8"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j2_de8" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j2_det" source="j2_d8" target="j2_d9"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j2_de9" value="both members editing" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j2_det" source="j2_d9" target="j2_d10"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j2_de10" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j2_det" source="j2_d10" target="j2_d11"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j2_de11" value="notes UPDATE broadcast" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j2_det" source="j2_d11" target="j2_d12"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j2_de12" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j2_det" source="j2_d12" target="j2_d13"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j2_de13" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j2_det" source="j2_d13" target="j2_d14"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j2_de14" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j2_det" source="j2_d14" target="j2_d15"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j2_de15" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j2_det" source="j2_d15" target="j2_d16"><mxGeometry relative="1" as="geometry" /></mxCell>
    </root>
  </mxGraphModel>
</diagram>
<diagram id="j3-agent-loop" name="Journey — Agent-Native Loop">
  <mxGraphModel dx="800" dy="600" grid="0" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="3200" pageHeight="1400" math="0" shadow="0">
    <root>
      <mxCell id="0" />
      <mxCell id="1" parent="0" />
      <mxCell id="j3_simp" value="SIMPLIFIED — Agent-native loop (MCP stdio + HTTP, /v1 OpenAI-compatible surface)" style="swimlane;startSize=32;rounded=1;html=1;fontSize=15;fontStyle=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1">
        <mxGeometry x="40" y="40" width="3080" height="220" as="geometry" />
      </mxCell>
      <mxCell id="j3_s1" value="Setup dialog writes 5 agent configs&#10;(claude, cursor, codex, gemini, openclaw)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=13;" vertex="1" parent="j3_simp">
        <mxGeometry x="40" y="70" width="260" height="90" as="geometry" />
      </mxCell>
      <mxCell id="j3_s2" value="Agent spawns node bin/eli-mcp.mjs&#10;stdio JSON-RPC, no per-call auth" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=13;" vertex="1" parent="j3_simp">
        <mxGeometry x="370" y="70" width="260" height="90" as="geometry" />
      </mxCell>
      <mxCell id="j3_s3" value="SaaS PAT + HTTP MCP&#10;PAT auth, 60/min rate limit" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=13;" vertex="1" parent="j3_simp">
        <mxGeometry x="700" y="70" width="260" height="90" as="geometry" />
      </mxCell>
      <mxCell id="j3_s4" value="15 tools: read / write / search /&#10;template / daily / comment / diff / memory" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=13;" vertex="1" parent="j3_simp">
        <mxGeometry x="1030" y="70" width="260" height="90" as="geometry" />
      </mxCell>
      <mxCell id="j3_s5" value="StorageAdapter: .md + SQLite locally,&#10;notes_save RPC + RLS in SaaS" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=13;" vertex="1" parent="j3_simp">
        <mxGeometry x="1360" y="70" width="260" height="90" as="geometry" />
      </mxCell>
      <mxCell id="j3_s6" value="Side effects: agent versions, SSE,&#10;git commit as agent (no auto-embed)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=13;" vertex="1" parent="j3_simp">
        <mxGeometry x="1690" y="70" width="260" height="90" as="geometry" />
      </mxCell>
      <mxCell id="j3_s7" value="/v1 OpenAI-compatible API&#10;RAG injection + optional vault tools" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=13;" vertex="1" parent="j3_simp">
        <mxGeometry x="2020" y="70" width="260" height="90" as="geometry" />
      </mxCell>
      <mxCell id="j3_s8" value="Digest note (cron or manual)&#10;agents read via read_artifact" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=13;" vertex="1" parent="j3_simp">
        <mxGeometry x="2350" y="70" width="260" height="90" as="geometry" />
      </mxCell>
      <mxCell id="j3_s9" value="pnpm embed:backfill CLI&#10;bridges agent notes into vector search" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=13;" vertex="1" parent="j3_simp">
        <mxGeometry x="2680" y="70" width="260" height="90" as="geometry" />
      </mxCell>
      <mxCell id="j3_se1" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j3_simp" source="j3_s1" target="j3_s2"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j3_se2" value="or remote" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j3_simp" source="j3_s2" target="j3_s3"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j3_se3" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j3_simp" source="j3_s3" target="j3_s4"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j3_se4" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j3_simp" source="j3_s4" target="j3_s5"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j3_se5" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j3_simp" source="j3_s5" target="j3_s6"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j3_se6" value="alt surface" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j3_simp" source="j3_s6" target="j3_s7"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j3_se7" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j3_simp" source="j3_s7" target="j3_s8"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j3_se8" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j3_simp" source="j3_s8" target="j3_s9"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j3_det" value="DETAILED — swimlane per actor, numbered steps (file:line evidence in docs/architecture/10-end-to-end-journeys.md)" style="swimlane;startSize=32;rounded=1;html=1;fontSize=15;fontStyle=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1">
        <mxGeometry x="40" y="300" width="3080" height="1040" as="geometry" />
      </mxCell>
      <mxCell id="j3_l1" value="User + Browser UI" style="swimlane;horizontal=0;startSize=40;rounded=0;html=1;fontSize=13;fontStyle=1;fillColor=#dae8fc;strokeColor=#6c8ebf;swimlaneFillColor=#ffffff;" vertex="1" parent="j3_det">
        <mxGeometry x="10" y="40" width="3060" height="160" as="geometry" />
      </mxCell>
      <mxCell id="j3_l2" value="Agent (MCP client / OpenAI SDK)" style="swimlane;horizontal=0;startSize=40;rounded=0;html=1;fontSize=13;fontStyle=1;fillColor=#f5f5f5;strokeColor=#666666;swimlaneFillColor=#ffffff;" vertex="1" parent="j3_det">
        <mxGeometry x="10" y="205" width="3060" height="160" as="geometry" />
      </mxCell>
      <mxCell id="j3_l3" value="eli server (MCP + /v1 + Server Actions)" style="swimlane;horizontal=0;startSize=40;rounded=0;html=1;fontSize=13;fontStyle=1;fillColor=#e1d5e7;strokeColor=#9673a6;swimlaneFillColor=#ffffff;" vertex="1" parent="j3_det">
        <mxGeometry x="10" y="370" width="3060" height="160" as="geometry" />
      </mxCell>
      <mxCell id="j3_l4" value="Storage adapters + SQLite / Postgres" style="swimlane;horizontal=0;startSize=40;rounded=0;html=1;fontSize=13;fontStyle=1;fillColor=#d5e8d4;strokeColor=#82b366;swimlaneFillColor=#ffffff;" vertex="1" parent="j3_det">
        <mxGeometry x="10" y="535" width="3060" height="160" as="geometry" />
      </mxCell>
      <mxCell id="j3_l5" value="AI Gateway + EmbedQueue" style="swimlane;horizontal=0;startSize=40;rounded=0;html=1;fontSize=13;fontStyle=1;fillColor=#ffe6cc;strokeColor=#d79b00;swimlaneFillColor=#ffffff;" vertex="1" parent="j3_det">
        <mxGeometry x="10" y="700" width="3060" height="160" as="geometry" />
      </mxCell>
      <mxCell id="j3_l6" value="Git loop + Watcher + Cron" style="swimlane;horizontal=0;startSize=40;rounded=0;html=1;fontSize=13;fontStyle=1;fillColor=#fff2cc;strokeColor=#d6b656;swimlaneFillColor=#ffffff;" vertex="1" parent="j3_det">
        <mxGeometry x="10" y="865" width="3060" height="160" as="geometry" />
      </mxCell>
      <mxCell id="j3_d1" value="1. Palette: Set up external AI tools" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="j3_l1">
        <mxGeometry x="60" y="30" width="170" height="100" as="geometry" />
      </mxCell>
      <mxCell id="j3_d2" value="2. setupExternalToolsAction writes 5 agent configs (atomic merge)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=12;" vertex="1" parent="j3_l3">
        <mxGeometry x="245" y="30" width="170" height="100" as="geometry" />
      </mxCell>
      <mxCell id="j3_d3" value="3. SaaS: mint PAT at Settings -&gt; Developers (plaintext once)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="j3_l1">
        <mxGeometry x="430" y="30" width="170" height="100" as="geometry" />
      </mxCell>
      <mxCell id="j3_d4" value="4. Agent spawns node bin/eli-mcp.mjs (stdio JSON-RPC)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=12;" vertex="1" parent="j3_l2">
        <mxGeometry x="615" y="30" width="170" height="100" as="geometry" />
      </mxCell>
      <mxCell id="j3_d5" value="5. runStdioServer: 15 tools, cached LocalAdapter, no per-call auth" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=12;" vertex="1" parent="j3_l3">
        <mxGeometry x="800" y="30" width="170" height="100" as="geometry" />
      </mxCell>
      <mxCell id="j3_d6" value="6. ALT remote: POST /api/mcp/transport, Bearer PAT" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=12;" vertex="1" parent="j3_l2">
        <mxGeometry x="985" y="30" width="170" height="100" as="geometry" />
      </mxCell>
      <mxCell id="j3_d7" value="7. PAT auth + 60/min limit. GAP: context ignores PAT -&gt; SaaS tools fail" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;fontSize=12;" vertex="1" parent="j3_l3">
        <mxGeometry x="1170" y="30" width="170" height="100" as="geometry" />
      </mxCell>
      <mxCell id="j3_d8" value="8. tools/call read / list / search" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=12;" vertex="1" parent="j3_l2">
        <mxGeometry x="1355" y="30" width="170" height="100" as="geometry" />
      </mxCell>
      <mxCell id="j3_d9" value="9. FTS bm25; hybrid adds gateway embed + KNN + RRF" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="j3_l4">
        <mxGeometry x="1540" y="30" width="170" height="100" as="geometry" />
      </mxCell>
      <mxCell id="j3_d10" value="10. tools/call edit_artifact (agent-attributed, frontmatter is full replace)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=12;" vertex="1" parent="j3_l2">
        <mxGeometry x="1725" y="30" width="170" height="100" as="geometry" />
      </mxCell>
      <mxCell id="j3_d11" value="11. atomicWrite .md + agent version row + FTS (SaaS notes_save RPC)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontSize=12;" vertex="1" parent="j3_l4">
        <mxGeometry x="1910" y="30" width="170" height="100" as="geometry" />
      </mxCell>
      <mxCell id="j3_d12" value="12. SSE event + git commit as agent. GAP: no auto-embed from MCP writes" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=12;" vertex="1" parent="j3_l6">
        <mxGeometry x="2095" y="30" width="170" height="100" as="geometry" />
      </mxCell>
      <mxCell id="j3_d13" value="13. POST /v1/chat/completions (RAG topK 8 + optional vault tools)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontSize=12;" vertex="1" parent="j3_l2">
        <mxGeometry x="2280" y="30" width="170" height="100" as="geometry" />
      </mxCell>
      <mxCell id="j3_d14" value="14. Gateway streamText -&gt; OpenAI-shape SSE; SaaS audit ai.tool.* rows" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;fontSize=12;" vertex="1" parent="j3_l5">
        <mxGeometry x="2465" y="30" width="170" height="100" as="geometry" />
      </mxCell>
      <mxCell id="j3_d15" value="15. Digest cron -&gt; digest note; agents read via read_artifact (no MCP tool)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontSize=12;" vertex="1" parent="j3_l6">
        <mxGeometry x="2650" y="30" width="170" height="100" as="geometry" />
      </mxCell>
      <mxCell id="j3_d16" value="16. pnpm embed:backfill bridges agent notes into vector search" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontSize=12;" vertex="1" parent="j3_l1">
        <mxGeometry x="2835" y="30" width="170" height="100" as="geometry" />
      </mxCell>
      <mxCell id="j3_de1" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j3_det" source="j3_d1" target="j3_d2"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j3_de2" value="config points agent at bin" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j3_det" source="j3_d2" target="j3_d4"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j3_de3" value="PAT used as Bearer" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;dashed=1;" edge="1" parent="j3_det" source="j3_d3" target="j3_d6"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j3_de4" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j3_det" source="j3_d4" target="j3_d5"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j3_de5" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j3_det" source="j3_d6" target="j3_d7"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j3_de6" value="handshake, then tools" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j3_det" source="j3_d5" target="j3_d8"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j3_de7" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j3_det" source="j3_d8" target="j3_d9"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j3_de8" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j3_det" source="j3_d9" target="j3_d10"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j3_de9" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j3_det" source="j3_d10" target="j3_d11"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j3_de10" value="side-effect fan-out" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j3_det" source="j3_d11" target="j3_d12"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j3_de11" value="alt surface" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j3_det" source="j3_d12" target="j3_d13"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j3_de12" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j3_det" source="j3_d13" target="j3_d14"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j3_de13" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;" edge="1" parent="j3_det" source="j3_d14" target="j3_d15"><mxGeometry relative="1" as="geometry" /></mxCell>
      <mxCell id="j3_de14" value="closes the embed gap" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;fontSize=11;dashed=1;" edge="1" parent="j3_det" source="j3_d15" target="j3_d16"><mxGeometry relative="1" as="geometry" /></mxCell>
    </root>
  </mxGraphModel>
</diagram>
</mxfile>
