swactor/docs/transport_routing.svg
zacheryasc 9c866b51a6 feat: transport protocol (#27)
Address actors via ID, send messages over transport (TCP, QUIC, etc)


Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-02-09 19:05:37 +00:00

173 lines
11 KiB
XML

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1100 880" font-family="system-ui, sans-serif">
<defs>
<filter id="shadow" x="-4%" y="-4%" width="108%" height="108%">
<feDropShadow dx="1" dy="2" stdDeviation="3" flood-color="#000" flood-opacity="0.10"/>
</filter>
<marker id="arrow-gray" viewBox="0 0 10 7" refX="10" refY="3.5"
markerWidth="10" markerHeight="7" orient="auto-start-reverse" fill="#5f6368">
<polygon points="0 0, 10 3.5, 0 7"/>
</marker>
<marker id="arrow-green" viewBox="0 0 10 7" refX="10" refY="3.5"
markerWidth="10" markerHeight="7" orient="auto-start-reverse" fill="#34a853">
<polygon points="0 0, 10 3.5, 0 7"/>
</marker>
<marker id="arrow-blue" viewBox="0 0 10 7" refX="10" refY="3.5"
markerWidth="10" markerHeight="7" orient="auto-start-reverse" fill="#4285f4">
<polygon points="0 0, 10 3.5, 0 7"/>
</marker>
<marker id="arrow-purple" viewBox="0 0 10 7" refX="10" refY="3.5"
markerWidth="10" markerHeight="7" orient="auto-start-reverse" fill="#9334e6">
<polygon points="0 0, 10 3.5, 0 7"/>
</marker>
<marker id="arrow-red" viewBox="0 0 10 7" refX="10" refY="3.5"
markerWidth="10" markerHeight="7" orient="auto-start-reverse" fill="#ea4335">
<polygon points="0 0, 10 3.5, 0 7"/>
</marker>
</defs>
<!-- Background -->
<rect width="1100" height="880" rx="8" fill="#f8f9fb" stroke="#e0e3e8" stroke-width="1.5"/>
<!-- Title -->
<text x="550" y="40" text-anchor="middle" font-size="20" font-weight="bold" fill="#202124">Transport Routing Chain</text>
<text x="550" y="60" text-anchor="middle" font-size="12" fill="#5f6368">src/runtime.rs · src/worker.rs · src/transport.rs</text>
<!-- ============================================ -->
<!-- ORIGIN -->
<!-- ============================================ -->
<rect x="30" y="80" width="1040" height="100" rx="6" fill="#e8f0fe" fill-opacity="0.25" stroke="#4285f4" stroke-width="1" stroke-opacity="0.4"/>
<text x="50" y="100" font-size="13" font-weight="700" fill="#4285f4" letter-spacing="1">ORIGIN</text>
<rect x="200" y="110" width="220" height="48" rx="12" fill="#e8f0fe" stroke="#4285f4" stroke-width="1.8" filter="url(#shadow)"/>
<text x="310" y="130" text-anchor="middle" font-size="13" font-weight="600" fill="#1a73e8">runtime.send_to(addr, msg)</text>
<text x="310" y="147" text-anchor="middle" font-size="10" fill="#5f6368">or ctx.send(addr, msg)</text>
<!-- Box<dyn Any + Send> annotation -->
<rect x="640" y="110" width="230" height="48" rx="12" fill="#f1f3f4" stroke="#9aa0a6" stroke-width="1.2" filter="url(#shadow)"/>
<text x="755" y="132" text-anchor="middle" font-size="11" font-weight="600" fill="#5f6368">msg type-erased to</text>
<text x="755" y="148" text-anchor="middle" font-size="12" font-weight="600" fill="#5f6368" font-style="italic">Box&lt;dyn Any + Send&gt;</text>
<line x1="420" y1="134" x2="630" y2="134" stroke="#9aa0a6" stroke-width="1.2" stroke-dasharray="4,3"/>
<!-- Arrow down from origin -->
<line x1="310" y1="158" x2="310" y2="206" stroke="#5f6368" stroke-width="1.8" marker-end="url(#arrow-gray)"/>
<!-- ============================================ -->
<!-- STEP 1: AddressMap -->
<!-- ============================================ -->
<rect x="30" y="195" width="1040" height="130" rx="6" fill="#e6f4ea" fill-opacity="0.2" stroke="#34a853" stroke-width="1" stroke-opacity="0.4"/>
<text x="50" y="215" font-size="13" font-weight="700" fill="#34a853" letter-spacing="1">STEP 1</text>
<!-- Decision diamond -->
<polygon points="310,218 415,260 310,302 205,260" fill="#e6f4ea" stroke="#34a853" stroke-width="1.8" filter="url(#shadow)"/>
<text x="310" y="256" text-anchor="middle" font-size="11" font-weight="600" fill="#137333">AddressMap</text>
<text x="310" y="270" text-anchor="middle" font-size="11" font-weight="600" fill="#137333">::lookup(addr)</text>
<!-- Found → local delivery -->
<line x1="415" y1="260" x2="590" y2="260" stroke="#34a853" stroke-width="1.8" marker-end="url(#arrow-green)"/>
<text x="500" y="252" text-anchor="middle" font-size="11" fill="#34a853" font-weight="600">found</text>
<rect x="600" y="237" width="250" height="46" rx="12" fill="#e6f4ea" stroke="#34a853" stroke-width="1.8" filter="url(#shadow)"/>
<text x="725" y="257" text-anchor="middle" font-size="12" font-weight="600" fill="#137333">Local Worker Delivery</text>
<text x="725" y="273" text-anchor="middle" font-size="10" fill="#5f6368">transfer_txs[wid] — zero-copy, no serialize</text>
<!-- Not found → continue -->
<line x1="310" y1="302" x2="310" y2="348" stroke="#5f6368" stroke-width="1.8" marker-end="url(#arrow-gray)"/>
<text x="322" y="328" font-size="11" fill="#5f6368" font-weight="600">not found</text>
<!-- ============================================ -->
<!-- STEP 2: InboxRegistry -->
<!-- ============================================ -->
<rect x="30" y="340" width="1040" height="130" rx="6" fill="#fef7e0" fill-opacity="0.2" stroke="#f9ab00" stroke-width="1" stroke-opacity="0.4"/>
<text x="50" y="360" font-size="13" font-weight="700" fill="#e37400" letter-spacing="1">STEP 2</text>
<!-- Decision diamond -->
<polygon points="310,363 415,405 310,447 205,405" fill="#fef7e0" stroke="#f9ab00" stroke-width="1.8" filter="url(#shadow)"/>
<text x="310" y="401" text-anchor="middle" font-size="11" font-weight="600" fill="#e37400">InboxRegistry</text>
<text x="310" y="415" text-anchor="middle" font-size="11" font-weight="600" fill="#e37400">::contains(addr)</text>
<!-- Found → inbox delivery -->
<line x1="415" y1="405" x2="590" y2="405" stroke="#34a853" stroke-width="1.8" marker-end="url(#arrow-green)"/>
<text x="500" y="397" text-anchor="middle" font-size="11" fill="#34a853" font-weight="600">found</text>
<rect x="600" y="382" width="250" height="46" rx="12" fill="#fef7e0" stroke="#f9ab00" stroke-width="1.8" filter="url(#shadow)"/>
<text x="725" y="402" text-anchor="middle" font-size="12" font-weight="600" fill="#e37400">External Inbox Delivery</text>
<text x="725" y="418" text-anchor="middle" font-size="10" fill="#5f6368">inbox_registry.try_deliver(addr, msg)</text>
<!-- Not found → continue -->
<line x1="310" y1="447" x2="310" y2="493" stroke="#5f6368" stroke-width="1.8" marker-end="url(#arrow-gray)"/>
<text x="322" y="473" font-size="11" fill="#5f6368" font-weight="600">not found</text>
<!-- ============================================ -->
<!-- STEP 3: Transport (NEW) -->
<!-- ============================================ -->
<rect x="30" y="485" width="1040" height="190" rx="6" fill="#f3e8fd" fill-opacity="0.25" stroke="#9334e6" stroke-width="1" stroke-opacity="0.4"/>
<text x="50" y="505" font-size="13" font-weight="700" fill="#9334e6" letter-spacing="1">STEP 3 — TRANSPORT (feature-gated)</text>
<!-- Decision diamond -->
<polygon points="310,518 415,560 310,602 205,560" fill="#f3e8fd" stroke="#9334e6" stroke-width="1.8" filter="url(#shadow)"/>
<text x="310" y="553" text-anchor="middle" font-size="11" font-weight="600" fill="#7627bb">TransportRouter</text>
<text x="310" y="567" text-anchor="middle" font-size="11" font-weight="600" fill="#7627bb">::lookup(addr)</text>
<!-- Found → encode + send -->
<line x1="415" y1="560" x2="500" y2="560" stroke="#9334e6" stroke-width="1.8" marker-end="url(#arrow-purple)"/>
<text x="455" y="552" text-anchor="middle" font-size="11" fill="#9334e6" font-weight="600">found</text>
<!-- Encode box -->
<rect x="510" y="525" width="210" height="44" rx="12" fill="#f3e8fd" stroke="#9334e6" stroke-width="1.8" filter="url(#shadow)"/>
<text x="615" y="544" text-anchor="middle" font-size="12" font-weight="600" fill="#7627bb">CodecRegistry::encode()</text>
<text x="615" y="560" text-anchor="middle" font-size="10" fill="#5f6368">TypeId → type_tag + Vec&lt;u8&gt;</text>
<!-- Arrow to transport.send -->
<line x1="720" y1="547" x2="780" y2="547" stroke="#9334e6" stroke-width="1.8" marker-end="url(#arrow-purple)"/>
<!-- Transport send box -->
<rect x="790" y="520" width="215" height="55" rx="12" fill="#f3e8fd" stroke="#9334e6" stroke-width="1.8" filter="url(#shadow)"/>
<text x="897" y="540" text-anchor="middle" font-size="12" font-weight="600" fill="#7627bb">transport.send(</text>
<text x="897" y="556" text-anchor="middle" font-size="12" font-weight="600" fill="#7627bb">WireEnvelope)</text>
<text x="897" y="570" text-anchor="middle" font-size="10" fill="#5f6368">→ remote runtime</text>
<!-- WireEnvelope annotation -->
<rect x="570" y="590" width="300" height="42" rx="8" fill="none" stroke="#9aa0a6" stroke-width="1" stroke-dasharray="4,3"/>
<text x="720" y="607" text-anchor="middle" font-size="10" fill="#9aa0a6">WireEnvelope { dest, type_tag, payload: Vec&lt;u8&gt; }</text>
<text x="720" y="623" text-anchor="middle" font-size="10" fill="#9aa0a6">Transport impl decides the wire format</text>
<!-- Not found → fallback -->
<line x1="310" y1="602" x2="310" y2="698" stroke="#5f6368" stroke-width="1.8" marker-end="url(#arrow-gray)"/>
<text x="322" y="650" font-size="11" fill="#5f6368" font-weight="600">not found</text>
<!-- ============================================ -->
<!-- STEP 4: Fallback -->
<!-- ============================================ -->
<rect x="30" y="690" width="1040" height="110" rx="6" fill="#fce8e6" fill-opacity="0.2" stroke="#ea4335" stroke-width="1" stroke-opacity="0.4"/>
<text x="50" y="710" font-size="13" font-weight="700" fill="#ea4335" letter-spacing="1">FALLBACK</text>
<rect x="210" y="715" width="200" height="50" rx="12" fill="#fce8e6" stroke="#ea4335" stroke-width="1.8" filter="url(#shadow)"/>
<text x="310" y="736" text-anchor="middle" font-size="12" font-weight="600" fill="#c5221f">InboxRegistry</text>
<text x="310" y="752" text-anchor="middle" font-size="10" fill="#5f6368">::try_deliver(addr, msg)</text>
<line x1="410" y1="740" x2="590" y2="740" stroke="#ea4335" stroke-width="1.8" marker-end="url(#arrow-red)"/>
<rect x="600" y="720" width="220" height="40" rx="10" fill="#fce8e6" stroke="#ea4335" stroke-width="1.5" filter="url(#shadow)"/>
<text x="710" y="744" text-anchor="middle" font-size="12" font-weight="600" fill="#c5221f">Err("Address not found")</text>
<!-- ============================================ -->
<!-- Legend -->
<!-- ============================================ -->
<rect x="50" y="820" width="1000" height="45" rx="8" fill="none" stroke="#e0e3e8" stroke-width="1"/>
<text x="70" y="842" font-size="12" font-weight="600" fill="#202124">Legend</text>
<line x1="140" y1="840" x2="175" y2="840" stroke="#34a853" stroke-width="1.8" marker-end="url(#arrow-green)"/>
<text x="185" y="844" font-size="11" fill="#34a853">Local delivery</text>
<line x1="310" y1="840" x2="345" y2="840" stroke="#9334e6" stroke-width="1.8" marker-end="url(#arrow-purple)"/>
<text x="355" y="844" font-size="11" fill="#9334e6">Transport path (new)</text>
<line x1="510" y1="840" x2="545" y2="840" stroke="#ea4335" stroke-width="1.8" marker-end="url(#arrow-red)"/>
<text x="555" y="844" font-size="11" fill="#ea4335">Error</text>
<line x1="630" y1="840" x2="665" y2="840" stroke="#5f6368" stroke-width="1.8" marker-end="url(#arrow-gray)"/>
<text x="675" y="844" font-size="11" fill="#5f6368">Fallthrough</text>
<text x="850" y="844" font-size="10" fill="#9aa0a6">runtime.rs · worker.rs · transport.rs</text>
</svg>