<?xml version="1.0" encoding="UTF-8"?>
<mxfile host="drawio" version="26.0.0">
  <diagram name="012 base+overlay TO-BE">
    <mxGraphModel dx="1422" dy="794" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1400" pageHeight="1100" math="0" shadow="0">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />

        <mxCell id="2" value="012 TO-BE — Base + Overlay Index Model (live_index::view)" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontStyle=1;fontSize=16;" vertex="1" parent="1">
          <mxGeometry x="250" y="10" width="900" height="40" as="geometry" />
        </mxCell>
        <mxCell id="3" value="SC-002 shared base · SC-003 overlay isolation · IV stale fence" style="text;html=1;strokeColor=none;fillColor=none;align=center;fontSize=12;fontColor=#666666;" vertex="1" parent="1">
          <mxGeometry x="300" y="52" width="800" height="24" as="geometry" />
        </mxCell>

        <!-- BaseKey + IndexBase (center hub) -->
        <mxCell id="10" value="BaseKey&#xa;canonical_root + commit (head_sha)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="560" y="90" width="200" height="50" as="geometry" />
        </mxCell>
        <mxCell id="11" value="IndexBase (immutable, shared)&#xa;key + Arc&lt;LiveIndex&gt; + base_generation&#xa;ONE allocation per BaseKey (SC-002)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;fontStyle=1;strokeWidth=2;" vertex="1" parent="1">
          <mxGeometry x="500" y="180" width="320" height="80" as="geometry" />
        </mxCell>
        <mxCell id="12" value="Arc&lt;LiveIndex&gt;&#xa;(existing snapshot — store.rs)" style="shape=cylinder3;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1">
          <mxGeometry x="560" y="300" width="200" height="80" as="geometry" />
        </mxCell>
        <mxCell id="13" value="files · symbols · refs · trigram (base)" style="text;html=1;strokeColor=none;fillColor=none;align=center;fontSize=11;" vertex="1" parent="1">
          <mxGeometry x="520" y="390" width="280" height="20" as="geometry" />
        </mxCell>

        <!-- Consumer A -->
        <mxCell id="20" value="Consumer A (session / embedder)" style="swimlane;startSize=30;fillColor=#dae8fc;strokeColor=#6c8ebf;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="40" y="440" width="380" height="320" as="geometry" />
        </mxCell>
        <mxCell id="21" value="WorkingSet A&#xa;entries: [{ project_id, base, overlay }]" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="20">
          <mxGeometry x="20" y="45" width="340" height="50" as="geometry" />
        </mxCell>
        <mxCell id="22" value="Overlay A (private)&#xa;HashMap&lt;path, Upsert|Tombstone&gt;&#xa;uncommitted / dirty deltas only" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;" vertex="1" parent="20">
          <mxGeometry x="20" y="120" width="340" height="70" as="geometry" />
        </mxCell>
        <mxCell id="23" value="IndexView A&#xa;base + overlay A&#xa;get_file: overlay shadows base" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontStyle=1;" vertex="1" parent="20">
          <mxGeometry x="20" y="210" width="340" height="60" as="geometry" />
        </mxCell>
        <mxCell id="24" value="A edits foo.rs (uncommitted)&#xa;→ Upsert in Overlay A only" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;" vertex="1" parent="20">
          <mxGeometry x="20" y="285" width="340" height="40" as="geometry" />
        </mxCell>

        <!-- Consumer B -->
        <mxCell id="30" value="Consumer B (another session)" style="swimlane;startSize=30;fillColor=#dae8fc;strokeColor=#6c8ebf;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="980" y="440" width="380" height="320" as="geometry" />
        </mxCell>
        <mxCell id="31" value="WorkingSet B" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="30">
          <mxGeometry x="20" y="45" width="340" height="50" as="geometry" />
        </mxCell>
        <mxCell id="32" value="Overlay B (private)&#xa;empty OR own deltas&#xa;NEVER reads Overlay A (SC-003)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;" vertex="1" parent="30">
          <mxGeometry x="20" y="120" width="340" height="70" as="geometry" />
        </mxCell>
        <mxCell id="33" value="IndexView B&#xa;base + overlay B&#xa;sees clean base for foo.rs" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontStyle=1;" vertex="1" parent="30">
          <mxGeometry x="20" y="210" width="340" height="60" as="geometry" />
        </mxCell>
        <mxCell id="34" value="B query cross-project:&#xa;WorkingSet iterates entries, tags project_id" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;" vertex="1" parent="30">
          <mxGeometry x="20" y="285" width="340" height="40" as="geometry" />
        </mxCell>

        <!-- Shared Arc edges -->
        <mxCell id="40" value="same Arc&lt;IndexBase&gt;&#xa;(SC-002: ptr_eq)" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;exitX=0;exitY=0.5;entryX=0.5;entryY=0;strokeWidth=2;flowAnimation=1;" edge="1" parent="1" source="11" target="21">
          <mxGeometry relative="1" as="geometry"><Array as="points"><mxPoint x="420" y="220" /><mxPoint x="230" y="220" /><mxPoint x="230" y="485" /></Array></mxGeometry>
        </mxCell>
        <mxCell id="41" value="same Arc&lt;IndexBase&gt;" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;entryX=0.5;entryY=0;strokeWidth=2;flowAnimation=1;" edge="1" parent="1" source="11" target="31">
          <mxGeometry relative="1" as="geometry"><Array as="points"><mxPoint x="900" y="220" /><mxPoint x="1170" y="220" /><mxPoint x="1170" y="485" /></Array></mxGeometry>
        </mxCell>
        <mxCell id="42" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;entryX=0.5;entryY=0;" edge="1" parent="1" source="10" target="11">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="43" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;entryX=0.5;entryY=0;" edge="1" parent="1" source="11" target="12">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="44" value="private" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;entryX=0.5;entryY=0;dashed=1;" edge="1" parent="1" source="21" target="22">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="45" value="private" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;entryX=0.5;entryY=0;dashed=1;" edge="1" parent="1" source="31" target="32">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="46" value="compose" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;entryX=0.5;entryY=0;" edge="1" parent="1" source="22" target="23">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="47" value="compose" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;entryX=0.5;entryY=0;" edge="1" parent="1" source="32" target="33">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="48" value="read" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;exitX=0;exitY=0.5;entryX=0;entryY=0.75;dashed=1;" edge="1" parent="1" source="23" target="12">
          <mxGeometry relative="1" as="geometry"><Array as="points"><mxPoint x="80" y="680" /><mxPoint x="80" y="360" /><mxPoint x="560" y="360" /></Array></mxGeometry>
        </mxCell>
        <mxCell id="49" value="read" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;entryX=1;entryY=0.75;dashed=1;" edge="1" parent="1" source="33" target="12">
          <mxGeometry relative="1" as="geometry"><Array as="points"><mxPoint x="1320" y="680" /><mxPoint x="1320" y="360" /><mxPoint x="760" y="360" /></Array></mxGeometry>
        </mxCell>

        <!-- overlay: None migration seam -->
        <mxCell id="50" value="Migration seam: overlay: None == today's LiveIndex reads (no-regression)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;dashed=1;fontStyle=2;" vertex="1" parent="1">
          <mxGeometry x="460" y="420" width="400" height="36" as="geometry" />
        </mxCell>

        <!-- Lifecycle / invalidation -->
        <mxCell id="60" value="Overlay lifecycle &amp; invalidation" style="swimlane;startSize=28;fillColor=#fff2cc;strokeColor=#d6b656;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="40" y="790" width="1320" height="200" as="geometry" />
        </mxCell>
        <mxCell id="61" value="fresh(base)&#xa;overlay empty" style="ellipse;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="60">
          <mxGeometry x="30" y="45" width="120" height="60" as="geometry" />
        </mxCell>
        <mxCell id="62" value="dirty&#xa;consumer edit → Upsert/Tombstone" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="60">
          <mxGeometry x="200" y="50" width="180" height="50" as="geometry" />
        </mxCell>
        <mxCell id="63" value="base commit advances&#xa;NEW IndexBase + generation++&#xa;Overlay::rebase(dirty set) O(dirty)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;" vertex="1" parent="60">
          <mxGeometry x="430" y="45" width="240" height="60" as="geometry" />
        </mxCell>
        <mxCell id="64" value="watcher → base ONLY&#xa;(never touches overlays)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="60">
          <mxGeometry x="720" y="50" width="200" height="50" as="geometry" />
        </mxCell>
        <mxCell id="65" value="StaleOverlay (IV)&#xa;fence mismatch → must rebase&#xa;IndexView::new returns Err" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f8cecc;strokeColor=#b85450;" vertex="1" parent="60">
          <mxGeometry x="970" y="45" width="220" height="60" as="geometry" />
        </mxCell>
        <mxCell id="66" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;endArrow=block;" edge="1" parent="60" source="61" target="62">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="67" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;endArrow=block;" edge="1" parent="60" source="62" target="63">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="68" value="other consumers untouched" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;endArrow=open;dashed=1;" edge="1" parent="60" source="63" target="64">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>

        <!-- AS-IS vs TO-BE -->
        <mxCell id="70" value="AS-IS today" style="swimlane;startSize=24;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1">
          <mxGeometry x="40" y="1010" width="620" height="70" as="geometry" />
        </mxCell>
        <mxCell id="71" value="One LiveIndex per process/session reload;&#xa;daemon registry but no overlay primitive;&#xa;N projects ≈ N copies or reload storms" style="text;html=1;strokeColor=none;fillColor=none;align=left;spacingLeft=8;" vertex="1" parent="70">
          <mxGeometry x="10" y="28" width="600" height="36" as="geometry" />
        </mxCell>
        <mxCell id="72" value="012 TO-BE" style="swimlane;startSize=24;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1">
          <mxGeometry x="680" y="1010" width="680" height="70" as="geometry" />
        </mxCell>
        <mxCell id="73" value="IndexBase shared by Arc keyed (root, commit); per-consumer Overlay;&#xa;cross-project WorkingSet; daemon shim = thin multiplex over primitive" style="text;html=1;strokeColor=none;fillColor=none;align=left;spacingLeft=8;" vertex="1" parent="72">
          <mxGeometry x="10" y="28" width="660" height="36" as="geometry" />
        </mxCell>

      </root>
    </mxGraphModel>
  </diagram>
</mxfile>
