Skip to content

Pre-exec self-healing cleanup for sandbox#396

Merged
robinaugh merged 1 commit intomainfrom
jason/pre-exec-cleanup
Mar 5, 2026
Merged

Pre-exec self-healing cleanup for sandbox#396
robinaugh merged 1 commit intomainfrom
jason/pre-exec-cleanup

Conversation

@robinaugh
Copy link
Contributor

@robinaugh robinaugh commented Mar 5, 2026

This addresses the "Known limitation" described in https://github.com/rwx-cloud/mint/pull/3616, where a forcibly-stopped sandbox command (i.e. running Ctrl+C or killing the pid locally) can leave the sandbox in a dirty state, making it impossible for the local environment to push a patch to it.

In this PR, the CLI starts from a defensive position and cleans the git state on the sandbox before applying its new patch.

Summary

  • Adds a cleanSandboxState() step that runs after lock acquisition but before syncChangesToSandbox(), resetting the sandbox working tree with git checkout . && git clean -fd
  • If a previous exec was interrupted (Ctrl+C, crash, network drop) between command execution and revertSandbox(), the next exec now self-heals instead of failing with a stale patch
  • Only runs when sync is enabled (--no-sync skips it)

Test plan

  • Unit test: cleanup commands run in correct order (after lock, before sync/exec)
  • Unit test: cleanup is skipped when Sync: false
  • Existing sync and lock tests pass with no regressions
  • Manual: start a sandbox exec, Ctrl+C mid-execution, run another exec and verify it succeeds without manual reset

Clean up dirty sandbox state before syncing so interrupted execs
(Ctrl+C, crash, network drop) don't leave the sandbox in a broken
state requiring manual reset. Only runs when sync is enabled.
@robinaugh robinaugh self-assigned this Mar 5, 2026
@robinaugh robinaugh marked this pull request as ready for review March 5, 2026 17:39
@robinaugh robinaugh merged commit d5bda41 into main Mar 5, 2026
1 check passed
@robinaugh robinaugh deleted the jason/pre-exec-cleanup branch March 5, 2026 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants