Repository navigation
[flows-tinyflows] flows bug: resume and cancel races mislabel or tear down a live run #45
Description
Moved from tinyhumansai#8023, which is closed in favour of this issue. Part of tinyhumansai#8055.
Two races in run bookkeeping, both rooted in a "finish" write that also matches running rows (drivers LIVE = ["running", "pending_approval"], tinyflows-drivers/src/catalog/runs.rs:34).
- Resume's stale-graph refusal cancels a run another resume is executing (
flows/ops/resume.rs:95-163). Resume B claims the run (mark_run_resuming→running); resume A sees a graph-hash mismatch, itsfinish_flow_run_row("cancelled")still matches, so A recordscancelledand drops B's live checkpoint. B's side effects still fire; its final write (:417) returns false. The compat-rejection branch (:180-200) relabels B's row tofailedwith no matched-write check. - Cancel can tear down a resume that is starting (
flows/ops/run_management.rs:25-89). Cancel readspending_approval,run_registry::cancelreturns false (resume not registered yet,resume.rs:247), resume registers and setsrunning, then cancel's finish write matches anddrop_checkpointruns. The resume's token is never signalled. - Related:
RunRowFinalizer::drop(flows/ops/run_rows.rs:74) recordsinterruptedon the flow summary even when the row was already terminal.
Fix: refuse when run_registry::is_in_flight holds, or use a parked-only (pending_approval) guarded write; only record the flow summary when the row write matched. Regression tests reproduce each interleaving first.
Done when: each defect above has a regression test that fails on the unfixed code and passes after the fix. Gates: cargo check (root + crates/openhuman-app), pnpm rust:layout, node scripts/ci/check-feature-forwarding.mjs, pnpm debug rust flows, and the touched crates' tests. RPC namespace strings, model-facing tool names and DomainEvent variant names stay unchanged unless the issue says otherwise.
Agent brief
- Files to consider (paths under
crates/openhuman-core/src/unless rooted):flows/ops/resume.rs,flows/ops/run_management.rs,flows/ops/run_rows.rs - Research: Interleavings above;
tinyflows_catalog::run_registry; driversfinish_flow_run/mark_run_resuming. - Workflow: an
implementing-an-epicstep. - Subagent:
systematic-debugger. - Dependencies: none.
Parent: tinyhumansai#8055
Activity
senamakel commentedon Oct 16, 2026
Merged into epic/8055-flows-bus in #99 (ca12953) and #102 (8d5468e), with owning TinyFlows changes in PRs #13 and #14. Deterministic old-behavior regressions fail before the fixes and pass afterward; full serial flow suite passes 608/608 with the test shell descriptor limit raised to 4096. Strict Clippy remains limited by 40 diagnostics in unchanged files, documented in PR #102.