feat: box lifecycle persistence and name support#38
Merged
Conversation
Signed-off-by: dorianzheng <xingzhengde72@gmail.com>
Major refactoring to support persistent box state with stop/restart capabilities. ## Core Changes ### Database Persistence - Add SQLite-based box state storage (db/boxes.rs, db/schema.rs) - Persist BoxConfig and BoxState across runtime restarts ### Box Lifecycle Management - Add BoxManager with state machine (Starting → Running → Stopped → Crashed) - Implement stop(), restart, and reattach operations - Add auto_remove option (like Docker --rm) for automatic cleanup ### Container Init Process - Add stdio pipes to keep container init alive (guest/container/stdio.rs) - Replace sleep infinity workaround with pipe-based blocking ### Architecture - Refactor init stages to tasks-based pipeline - Move controller to vmm/controller module - Add BoxBuilder for lazy initialization - Consolidate runtime types and state management ### SDK Updates - Expose auto_remove in Python BoxOptions - Update C SDK headers - Add lifecycle example scripts
- Add auto_remove field to BoxOptions with manual Default impl - Python SDK uses Option<bool> to inherit Rust default when None - All Python box classes (SimpleBox, CodeBox, BrowserBox, ComputerBox, InteractiveBox) default to auto_remove=True (ephemeral) - Low-level Rust BoxOptions defaults to false (persistent for debugging)
- Add optional user-defined name for boxes (unique, stored in BoxConfig) - Support get/remove by ID or name (name lookup as fallback) - Add name validation to prevent duplicates on create - Add InvalidArgument error variant for validation errors Refactor BoxliteRuntime to thin facade pattern: - Move all implementation to RuntimeInnerImpl (rt_impl.rs) - BoxliteRuntime delegates to self.inner for all operations - Enables LiteBox to call runtime methods directly via RuntimeInner Python SDK updates: - Add name parameter to create(), SimpleBox, InteractiveBox - Add name property to Box handle - Update get/remove to accept id_or_name Signed-off-by: dorianzheng <xingzhengde72@gmail.com>
- Add missing 'name: None' field to BoxConfig in test files - Change &PathBuf to &Path in vmm_spawn.rs - Implement FromStr trait for BoxStatus instead of inherent from_str method - Allow clippy::module_inception for pipeline module - Update lifecycle tests to use new create() signature with name parameter
G4614
added a commit
that referenced
this pull request
Jun 11, 2026
…rt PRIMARY TD Two fixes from run #38's symptoms: 1. Dockerfile.source ts-node startup failed with: TS5083: Cannot read file '/boxlite/apps/tsconfig.base.json' Root cause: codex PR #730 (Normalize monorepo Docker build paths) moved the apps Nx workspace root from repo-root to apps/. After that, apps/api/tsconfig.json's `extends: ../tsconfig.base.json` resolves to apps/tsconfig.base.json (not the repo-root one). Dockerfile.source still placed it at /boxlite/ with WORKDIR /boxlite, so the extends never resolved. Fix: mirror the codex production Dockerfile layout — WORKDIR /boxlite/apps, place tsconfig.base.json there, COPY apps/api/ to api/ and apps/libs/ to libs/. ENTRYPOINT paths drop the apps/ prefix (api/tsconfig.app.json, api/src/main.ts). 2. Deploy-Api step false-positive: ECS DeploymentCircuitBreaker auto-rolled back the broken Api:20 task definition, leaving the service stable on the previous Api:16. `aws ecs wait services-stable` returned success, ALB targets stayed healthy (old tasks were never deregistered), and /api/health responded 2xx — all answering from the OLD image. The workflow believed the deploy succeeded; pytest then ran against the old API, masking the broken new image. Fix: after `wait services-stable`, query the PRIMARY deployment's taskDefinition and assert it equals NEW_TD_ARN. If different, ECS rolled back — fail the step and dump stop reasons from the most recent stopped tasks for diagnosis. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Changes
Box Lifecycle Persistence
Box Naming
nameparameter oncreate()get(),get_info(),exists(),remove()Auto-remove
auto_removeoption in BoxOptions (default: false)Architecture Refactor
Python SDK
nameparameter tocreate(),SimpleBox,InteractiveBoxnameproperty to Box handleget(),remove()to accept ID or nameTest plan