refactor(storage): drop the dead shared agent-sandbox tables (R2 of #5240) - #5269
Merged
Conversation
…5240) #5240 restored per-user hosted sandboxes and deleted every reader/writer of agent_sandbox_sessions and agent_sandbox_runner_state, but deliberately kept both tables so the rollout had a rollback window. This is R2: the forward migration that drops them. agent_sandbox_runner_state.state holds plaintext credentials (an x-access-token:ghs_... clone URL, submodule tokens, the resolved env bag) and the table has no organization FK, so nothing ever GCs a row -- dormant rows are a standing secret leak, not just dead weight.
pedrofrxncx
enabled auto-merge (squash)
July 27, 2026 17:05
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
R2 of the #5240 revert. #5240 restored per-user hosted sandboxes and deleted every reader/writer of
agent_sandbox_sessionsandagent_sandbox_runner_state(created by migrations 137/138 for the shared model), but deliberately left both tables in place so the rollout had a rollback window. This drops them.One new migration,
147-drop-agent-sandbox-tables.ts, plus itsindex.tsregistration. No other code changes — R1 already removed every reference (grepfor either table name outside 137/138 returns nothing).Why not just leave them dormant
agent_sandbox_runner_state.stateholds plaintext credentials: anx-access-token:ghs_…clone URL, submodule tokens, and the resolved env bag. The table has no organization FK, so nothing ever garbage-collects a row — not org deletion, not any sweep. Dormant rows are a standing secret leak, not merely dead weight.agent_sandbox_sessionsis ordinary dead state.Deploy ordering — must not ship in the same release as #5240
#5240 is already on
main(5bfa8508f, released at0d1097643). This PR must go out in a later release, after that one has fully rolled out. Dropping in the same release lets a not-yet-rolled pod hitrelation "agent_sandbox_sessions" does not existonSANDBOX_START, and migrations run from the app CMD (apps/api/src/settings/pipeline.ts:52), so there is no natural barrier between migrate and serve.Merging this collapses the rollback window for #5240 — while both tables exist, rolling back is just re-promoting the previous image. Worth confirming #5240 is happy in prod first.
Notes for review
ifExists()on both drops: keeps this a no-op for installs that never provisioned the shared tables, and makes a partial re-run safe.down()is intentionally a no-op, following the 084/097 precedent for retired sandbox state. Recreating the schema would restore two empty tables no code reads, while the rows are unrecoverable; duplicating 137/138's DDL would just create a second copy to drift. Easy to change if you'd rather have a structuraldown()— say so and I'll add it.agent_sandbox_runner_state_handle_idx,agent_sandbox_sessions_vm_updated_idx,agent_sandbox_sessions_thread_idx) are dropped with their tables; no explicitdropIndexneeded.134-drop-task-board-enabled— the closest precedent for a pure DDL drop.migrations/index.test.tscovers file↔registration parity, andstorage-integration.ymlmigrates a fresh Postgres from an empty ledger in CI.Testing
bun run --cwd=apps/api checkclean ·bun run lint0 errors ·bun run fmtclean ·bun test apps/api/migrations/index.test.ts2 pass.Not run locally: the real-Postgres integration suite — CI covers it.
Summary by cubic
Drop the dead shared agent-sandbox tables
agent_sandbox_sessionsandagent_sandbox_runner_statevia migration 147. This removes dormant plaintext tokens and closes a security risk.apps/api/migrations/147-drop-agent-sandbox-tables.tsand register inapps/api/migrations/index.ts.dropTable(...).ifExists()for safety on fresh installs and re-runs.down()is a no-op; tables are intentionally not recreated.Written for commit 6aba45b. Summary will update on new commits.