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:
- 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). - 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).
- Server-restart safety: an orphaned
runningrow signals “drain was interrupted” — a future startup task can mark stale rows asinterrupted(cleaner than the prior fire-and-forget that left no row at all).