Skip to content

[P0.15] Make batch cancellation authoritative (worker _save_batch overwrites CANCELLED with RUNNING) #726

Description

@frankbria

Severity: high | Category: correctness | Phase: P0.15

Problem

cancel_batch/stop_batch write status=CANCELLED, but the executing loop's in-memory batch stays RUNNING and every task completion does a whole-row INSERT OR REPLACE INTO batch_runs ... batch.status — overwriting the cancel. The next loop iteration reads RUNNING and keeps launching tasks (spending LLM tokens). Force-stop only SIGTERMs the current subprocess; the loop starts the next.

Evidence

codeframe/core/conductor.py:2210 (INSERT OR REPLACE), :820/:858 (cancel/stop)

Acceptance criteria

  • _save_batch refuses to downgrade CANCELLED→RUNNING (re-read status, or persist only the results column from workers).
  • CANCELLED is preserved as the final status when the loop exits due to cancellation.
  • Test: cancel during an in-flight task stops subsequent tasks from starting.

Dependencies

None


Filed from the SaaS launch-readiness audit. Atomic: one developer, one session. Work order: strictly P0.1 → P3.12 (no forward dependencies).

Metadata

Metadata

Assignees

No one assigned

    Labels

    P0-blocker-betaCritical blocker - must fix before beta testingpriority:hightype:bugSomething is broken and needs fixing

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions