Skip to content

Scope sandbox ownership and make cleanup reliable - #344

Merged
mintuhouse merged 8 commits into
mainfrom
mintuhouse/sandbox-run-leases
Oct 22, 2026
Merged

mintuhouse merged 8 commits into
mainfrom
mintuhouse/sandbox-run-leases

Conversation

@mintuhouse

@mintuhouse mintuhouse commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor
  • Make existing sandbox commands, files, uploads, and workspace reuse reliable under concurrency, cancellation, and shutdown. Main already supports these capabilities, but its lifecycle bookkeeping can lose ownership or remove a workspace while it is still being used.
  • Protect long and overlapping chat runs with active leases. Start the 15-minute idle period only after the final run closes, rather than expiring a workspace based on its last provisioning timestamp.
  • Reserve capacity before contacting the provider, so pending creations count toward the per-process limit of 25. Evict only idle workspaces and wait for deletion before admitting a replacement, preventing bursts from bypassing the cap or evicting active work.
  • Track native provider operations through cancellation and timeouts. Clean up late creation results, keep workspaces fenced until deletion actually settles, and retain reported deletion failures for retry instead of forgetting them.
  • Include the configured provider connection in workspace identity, so switching an agent between connections starts a separate workspace instead of colliding with an older cached allocation.
  • Await bounded cleanup during development-server shutdown and reload, including repeated SIGINT or SIGTERM signals, so the worker can release its sandboxes before exiting.
  • Express run ownership through Effect scopes, separate lease management from session setup, and inject the provider factory through an Effect service and layer.
  • Stabilize the existing browser toast assertions and preserve lifecycle, isolation, cancellation, and shutdown regression coverage.
  • Keep ownership process-local in this PR. Durable recovery after abrupt process loss, its database migration, and provider-specific adapter fixes belong to follow-up #348, which uses a 15-minute ownership deadline.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-22T18:16:37.015962Z 791ff62 New commits
🔒 Security Review ✅ Completed 2026-10-22T10:53:18.134637Z 70c8df8 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@mintuhouse

mintuhouse commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor Author

Final validation for head 791ff6216ab22aa5193032f9f03bbeec407349fc, integrated with main 373aa29b8:

  • Thorough final review found no new blocking issues. Both reported lifecycle races remain fixed, covered, and resolved. The requested Cursor review of preceding head acee0f489 and automated code review of this exact head completed with no new issues.
  • Preserved main's pricing lookup and usage-cost persistence when resolving the chat conflict. The diff remains 16 sandbox-related files, with no migration, dependency, or AGENTS changes relative to main.
  • Local Platform full gate: 648 tests passed, 2 skipped, 109.48s. Formatting, OpenAPI consistency, type-aware lint, Knip, production build including /docs prerendering, and compiled-binary smoke passed against a freshly migrated disposable database. The database was dropped.
  • Platform browser suite with the real Docker connection test: 15 passed, 7.6m, zero retries.
  • Todos deterministic browser suite: 65 passed, 2.4m on an unchanged-head full rerun. Its first run had 64 passes and an inherited directory-test route-response teardown failure (Response has been disposed). The trace placed the error after test-body completion, and the isolated case passed before the full rerun. The test and its SDK/API implementation match main, so no unrelated source change was added here.
  • Container inventory matches the pre-run baseline exactly. All five test-server ports were released.
  • All current-head hosted checks pass. No actionable review feedback remains.

Durable recovery, its database migration, and provider patches remain in follow-up #348.

@mintuhouse

Copy link
Copy Markdown
Contributor Author

@cursor review

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
www-astralbeam-ai 791ff62 Commit Preview URL

Branch Preview URL
Oct 22 2026, 06:17 PM

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread platform/src/lib/chat/sandbox/leases.ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d5781fdf63

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread platform/src/lib/chat/sandbox/leases.ts Outdated
@mintuhouse mintuhouse changed the title Scope sandbox ownership and make cleanup reliable Scope sandbox ownership and recover cleanup after crashes Oct 22, 2026
@mintuhouse mintuhouse changed the title Scope sandbox ownership and recover cleanup after crashes Scope sandbox ownership and make cleanup reliable Oct 22, 2026
@mintuhouse

Copy link
Copy Markdown
Contributor Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit acee0f4. Configure here.

@mintuhouse
mintuhouse merged commit 4802666 into main Oct 22, 2026
11 checks passed
@mintuhouse
mintuhouse deleted the mintuhouse/sandbox-run-leases branch October 22, 2026 18:25
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.

1 participant