<svg width="100%" viewBox="0 0 760 240" role="img" xmlns="http://www.w3.org/2000/svg">
  <title>Heartbeat keeps the agent warm; the idle reaper would otherwise stop it</title>
  <desc>A paired powered Pi sends a heartbeat every ~30s that touches last_active_at; the idle reaper would stop the hermes container after RUNTIME_IDLE_SEC (1800s) of true idle.</desc>
  <style>
    text{font-family:"Anthropic Sans",-apple-system,system-ui,"Segoe UI",sans-serif}
    .t{font-size:14px;font-weight:500;text-anchor:middle;dominant-baseline:central}
    .s{font-size:12px;text-anchor:middle;dominant-baseline:central}
    .lbl{font-size:11px;fill:#9c9a92;text-anchor:middle}
    rect{stroke-width:.5}
    .green{fill:#27500a;stroke:#97c459}   .gt{fill:#c0dd97} .gs{fill:#97c459}
    .blue{fill:#1f3b7a;stroke:#8aaef0}    .bt{fill:#cfdcf4} .bs{fill:#8aaef0}
    .orange{fill:#712b13;stroke:#f0997b}  .ot{fill:#f5c4b3} .os{fill:#f0997b}
    .arrow{fill:none;stroke:#9c9a92;stroke-width:1.5}
    .arrow-ok{fill:none;stroke:#1d9e75;stroke-width:1.5}
    .arrow-warn{fill:none;stroke:#d97757;stroke-width:1.5}
  </style>
  <defs>
    <marker id="a" viewBox="0 0 10 10" refX="8" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse">
      <path d="M2 1L8 5L2 9" fill="none" stroke="context-stroke" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
    </marker>
  </defs>

  <rect class="green" x="40" y="80" width="200" height="80" rx="8"/>
  <text class="t gt" x="140" y="106">Pi heartbeat</text>
  <text class="s gs" x="140" y="126">every ~30s · touch()</text>
  <text class="s gs" x="140" y="144">+ ensure_runtime (FF)</text>

  <rect class="blue" x="290" y="80" width="200" height="80" rx="8"/>
  <text class="t bt" x="390" y="106">last_active_at</text>
  <text class="s bs" x="390" y="126">kept fresh</text>
  <text class="s bs" x="390" y="144">in Postgres</text>

  <rect class="orange" x="540" y="80" width="200" height="80" rx="8"/>
  <text class="t ot" x="640" y="106">idle reaper</text>
  <text class="s os" x="640" y="126">stop if idle ≥</text>
  <text class="s os" x="640" y="144">RUNTIME_IDLE_SEC (1800s)</text>

  <path class="arrow-ok" d="M 240 120 L 288 120" marker-end="url(#a)"/>
  <path class="arrow-warn" d="M 490 120 L 538 120" marker-end="url(#a)" stroke-dasharray="4 3"/>
  <text class="lbl" x="514" y="108">only fires if no heartbeat</text>
</svg>
