Skip to content

bug(sandbox): erasure succeeds before trash bytes are deleted #4090

Closed

Description

@yannickmonney

Sandbox erasure can acknowledge success while workspace bytes are still present, and permanent background deletion failures never reach the erasure receipt.

Found by Tale agent #2 in the independent #4088 review. Root independently traced the callers and reproduced the acknowledgement/retained-bytes mismatch locally at 7afc5b349325a1d10fcd3daff4aa2d396430fdf0; the affected sandbox code is unchanged from main eee0a1098f433c96fe2d3c9b83779f6eed32d6cc. No production test or deletion was performed.

Evidence

  • services/sandbox/src/session/workspace-trash.ts: discard() resolves after renaming into .trash and starts void this.empty(). empty() deliberately never rejects, including when RemoveTree keeps failing.
  • services/sandbox/src/backend/docker/docker-session-backend.ts: destroySession() awaits only discard() and returns the normal destroyed acknowledgement.
  • services/platform/backend/domains/sandbox/workspace-cleanup.ts: destroyOnSpawner() translates this to destroyed; auditRetired() writes sandbox_workspace.deleted with success; eraseMemberWorkspaces() counts it as erased. Its documented contract requires a failed deletion to throw so the receipt stays partial/retryable.

The local probe imported the actual WorkspaceTrash, created one fresh synthetic workspace, and injected the existing RemoveTree seam to throw EIO. Observed: discardResolved: true, two failed removal attempts, one retained trash entry, original synthetic content still readable. All created files were retained. The complete platform erasure flow was traced in source, not executed by this probe.

Expected repair and acceptance

Keep fast interactive Destroy admission, but distinguish taking a workspace out of use from completing byte deletion. Erasure/retirement receipts must remain pending/partial until the applicable deletion contract is satisfied; persistent removal failure must have a visible, retryable outcome. Do not fix this solely by renaming the success label.

Add local causal regressions for delayed deletion and permanently failing deletion through the erasure caller, then successful retry and restart recovery. Verify isolation from a fresh session with the same deterministic ID, and preserve the bounded background delete behavior. Inspect the full audit/erasure/retirement call graph and update the matching docs and UI where the outcome becomes visible.

Suggested triage: Medium. The separate delayed-Destroy/resume race is a different root cause. Assign implementation through normal fleet intake and use a distinct reviewer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions