Skip to main content

insert_run_placeholder

Function insert_run_placeholder 

Source
pub(crate) fn insert_run_placeholder(
    state: &AppState,
    run_id: &str,
    drone_id: &str,
    started_at: i64,
) -> Result<(), String>
Expand description

Persist a running placeholder row synchronously BEFORE returning. Guarantees:

  1. The frontend’s refreshRuns (called right after this RPC resolves) always sees the row, no spawn-race against the drain (codex+reagent P2 from earlier rounds).
  2. The drain can run as a background spawn again — so drones longer than the RPC timeout (5s default) don’t get their drain truncated mid-flight (codex P1 v0.33.842).
  3. Server-restart safety: an orphaned running row signals “drain was interrupted” — a future startup task can mark stale rows as interrupted (cleaner than the prior fire-and-forget that left no row at all).