Skip to content

Let capacity pressure expire idle unattached Environments - #936

Merged
SaladDay merged 1 commit into
mainfrom
codex/pressure-expires-unattached-environments
Nov 7, 2026
Merged

SaladDay merged 1 commit into
mainfrom
codex/pressure-expires-unattached-environments

Conversation

@SaladDay

@SaladDay SaladDay commented Nov 7, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

The pinned Agents API has no Environment delete. Today, an idle suspended standalone Environment with no Session attached holds its node's retained slot until snapshot retention ends (24 h). With more prewarms than max_retained, the node blocks new placement for that whole time.

This change makes such an Environment eligible for capacity-pressure release. When a node's retained slots are full and waiting placement is blocked by them, pressure can release the node's oldest idle suspended allocation of an unattached standalone Environment. The Environment then expires exactly as at its deadline: status expired, workspace and placement released.

  • New query IsUnattachedRuntimeEnvironment: the Environment is active and no live Session is attached.
  • AllocationTx.CanReleaseCheckpoint is CanRetainEnvironment or unattached. It is checked under the same Environment lock as before.
  • It is used by ExpireCheckpointForDemand, by the full-node suspension gate and by the oldest-peer scan.
  • Cleanup, revoke, lost compute and demand qualification keep CanRetainEnvironment.
  • Docs (en/zh): the cold-replacement rule in docs/sandbox-provider.md, the lifecycle without a Session in environments.md, and a ledger entry in index.md.

Verification

  • go vet passes on the deployment and deploymentpg packages, and go test ./internal/deployment/ passes.
  • The deploymentpg tests for pressure, cleanup and expiry pass against Postgres.
  • Two new tests: an unattached Environment expires under pressure; a full node suspends an unattached owner. Both fail with the unattached branch removed.
  • check-translations passes.
  • Independent blind review: no blocking findings. Its five wording and redundancy nits are fixed.

Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@SaladDay
SaladDay merged commit 2f7aa01 into main Nov 7, 2026
19 checks passed
@SaladDay
SaladDay deleted the codex/pressure-expires-unattached-environments branch November 7, 2026 05:16
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