Skip to content

Record allocation phase time and document per-provider sandbox fields - #123

Merged
SaladDay merged 4 commits into
mainfrom
codex/sandbox-backend-semantics
Sep 25, 2026
Merged

SaladDay merged 4 commits into
mainfrom
codex/sandbox-backend-semantics

Conversation

@SaladDay

@SaladDay SaladDay commented Sep 25, 2026 •

Copy link
Copy Markdown
Collaborator

This completes the consolidated sandbox API request: allocation phase time, the Docker retained-limit semantics, and one documented per-provider field table.

Change

  • Allocation phase time. GET /core/v1/sandbox/nodes/{node_id}/allocations items gain compute_phase_changed_at: when the allocation entered its current compute_phase.
    • Migration 000074 adds the column. Existing rows stay null until their next phase change; no values are invented.
    • SetRuntimeCompute updates the time only when the phase actually changes.
    • The migration is numbered after Observe E2B sandboxes and show their template build #118's 000073, so databases that already applied 000073 upgrade without an out-of-order error.
  • Docker retained limit. Docker never suspends, so a Docker node's max_retained always equals max_active.
    • Enrollment tokens, node PATCH, enrollment, node identity, node configuration and the node list all apply this.
    • Microsandbox keeps both limits.
    • Invalid capacity is rejected with 400 before deployment-state conflicts (409).
  • Per-provider table. A new section in contracts/agents-api/sandbox-deployment.md, "What each field means per sandbox provider", covers E2B, Docker and microsandbox. It includes the deployment specification and runtime, e2b.template_build, suspension, allocations/pending, enrollment tokens, nodes, diagnostics, host disk, allocation phases, observation cpu/memory/disk, sleeping, and history CPU. Every cell was checked against the code.
  • Management OpenAPI and packages/agents-client types updated. The public /v1 OpenAPI is unchanged. The docs/web/protocol-coverage.md wording for the Docker retained limit is corrected.

Validation

  • Directed store tests, including Drain deployments saved before sandbox specifications #114's unspecified-deployment drain and all enrollment/capacity tests; the migration tests plus an upgrade from 000073 to 000074; API tests; 612 client tests; pnpm typecheck.
  • Full make check (server mode) passed on 7dd3bafd. Playwright browser cases were skipped on the server (Chrome unavailable; user-approved skip).
  • An independent blind review by a fresh Claude subagent found no P0/P1. The fixes were small and verified by tests and the gate, without a second review round:
    • P2: Docker retained limit on node identity, configuration and enrollment;
    • P3: capacity-before-conflict ordering, the null wording, and lean API tests.

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith with what you need. Autofix is disabled.

…tained limit equal to its active limit

- Migration 000072 adds runtime_allocations.compute_phase_changed_at (NULL for
  existing rows, clock_timestamp() for new ones). SetRuntimeCompute moves it only
  when the phase actually changes.
- GET /core/v1/sandbox/nodes/{node_id}/allocations returns
  compute_phase_changed_at (nullable) per item; the management OpenAPI and the
  SandboxAllocation client type include it.
- Docker never suspends, so a Docker node's max_retained always equals its
  max_active. Enrollment tokens and node PATCH replace any submitted value inside
  the deployment transaction before validating; the node list reports it that
  way. Provider-independent limits are still rejected before the transaction.
- Capacity tests: the approved-capacity test now runs on microsandbox, which uses
  both limits; TestDockerRetainedLimitFollowsActive covers Docker, and
  TestRuntimeComputePhaseChangedAt covers the phase time.
- Documentation describes the new field and the Docker retained limit.
…ck capacity before deployment state

- Node identity, node configuration (token and node credential) and enrollment
  apply the Docker rule, so a token or node stored before it existed also
  reports and stores max_retained equal to max_active.
- CreateRuntimeEnrollment normalizes and validates capacity before the
  mode/maintenance conflict check, so invalid capacity is still a 400.
- compute_phase_changed_at is described as null when unknown; an allocation
  that existed before Core recorded it reports null until its next phase change.
- Tests: Docker reads with legacy 2/8 token and node rows; microsandbox PATCH
  with max_retained below max_active is rejected and writes nothing; invalid
  capacity under maintenance is invalid input; the node allocation list returns
  the phase time and null for a NULL column.
Add a table to the deployment contract covering E2B, Docker and microsandbox:
deployment specification, template build, suspension and resource counts;
enrollment limits; node counts, diagnostics and host disk; allocation phases;
runtime observation CPU, memory, disk and sleeping state; and runtime history
CPU. Link it from the Hosted Sandbox Manager guide.
000073 from #118 is already on main. Numbering this branch's migration after
it lets databases that applied 000073 upgrade without goose's out-of-order
migration error. No test or document references the version.
@SaladDay
SaladDay merged commit cc4acc1 into main Sep 25, 2026
2 of 3 checks passed
SaladDay added a commit that referenced this pull request Sep 25, 2026
…125)

Keep #124's Core-key sign-in, fixed console actor label and configuration
names; the console still forwards every signed-in /core/v1 request by the
prefix rule instead of the removed allowlists. Installer, console tests and
docs take #124's wording with /core/v1 paths in place of /core/v1/admin.
#123's allocation test uses automatic placement, since P4 removed explicit
node selection.
@SaladDay
SaladDay deleted the codex/sandbox-backend-semantics branch October 7, 2026 06:38
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