Skip to content

cancellation: decide who reaps the process groups, worktrees, map slots, and claim locks a dropped future leaves #613

Description

@macanderson

What decision this asks for

Pick the ownership rule for resources created mid-flight when a future is dropped — Ctrl-C, a caller select!, a session timeout, or Esc in the deck — and then apply that one shape everywhere. The blocker is the same at every site: Drop cannot await, and no binary in this workspace installs a SIGINT/SIGTERM handler today, so tokio::spawn-from-Drop silently does nothing during runtime shutdown — precisely the case being fixed. The three candidate shapes are (a) a synchronous Drop guard that blocks on a sync syscall, (b) prune-on-next-start, and (c) an explicit runner/finally that owns teardown. Choose one, decide whether cancellation is in scope for stella-media at all, and rule separately on the escape hatch for worktrees and file_locks rows that have already leaked into user workspaces.

Every item below was re-checked against origin/main (092b2dda) before filing: all eleven are still present.

Items

Why these are together

These are not eleven independent leaks — they are one unanswered question asked at eleven call sites. Each is a resource created mid-flight (a process group, a git worktree, a map slot, a background task, a database row) whose teardown lives after an await that a dropped future never reaches, and each is blocked on the same two facts: Drop cannot await, and nothing in this workspace catches a signal. Fixing them one at a time invites eleven different guard shapes, and the wrong shape — tokio::spawn from Drop — looks correct in review while doing nothing in the exact scenario it claims to handle. Decide the rule once, then land it across all the sites, with the signal handler first so the guards can fire and the two reclaim hatches last so workspaces already broken in the field can recover.

Deferred during the #546 audit remediation. Put Closes #<this issue> in the PR description and as a commit trailer when it lands.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1Important — next in linearea:corestella-core — engine: step loop, budget, compaction, retry

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions