Skip to content

sandbox-store: move the wake path's writes of the sandboxes row into a wake module - #1336

Merged
ac-pplx merged 1 commit into
ac/lifecycle-move-createfrom
ac/lifecycle-move-wake
Nov 3, 2026
Merged

ac-pplx merged 1 commit into
ac/lifecycle-move-createfrom
ac/lifecycle-move-wake

Conversation

@ac-pplx

@ac-pplx ac-pplx commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Mechanical move, no functional change. The sandboxes row writes listed below move into pplx-space-sandbox-store with their SQL byte-for-byte; callers keep their locks, transactions and error handling. Everything else is doc comments. Part of the wave-2 stack (2 of 10, on #1329); it lands with the stack.

Summary

Moves the wake path's writes of the sandboxes row from the api and internal-api crates into a new wake module of pplx-space-sandbox-store. One executor-generic function per transition; each doc comment names the fact it writes. Behaviour is unchanged. Callers keep their FOR UPDATE reads, transactions and error mapping. The SQL is byte-identical except for one whitespace change, noted below.

Moved (old → sandbox_store::wake::*):

  • api sandbox/lifecycle.rs complete_wake_lifecycle CAS → complete_wake (operation step)
  • api sandbox/wake_completion.rs fenced_completion_cas + its redrive_loop call → fenced_completion_cas (private) + complete_redriven_wake (operation step)
  • api kubernetes/store/activation_fence.rs K8sStore::clear_command_ready_pending → clear_command_ready_pending (observed projection)
  • internal-api data_plane_sessions/service_route.rs clear_sandbox_command_ready_pending → the same clear_command_ready_pending
  • api kubernetes/store/execution_rows.rs lease renewal in ensure_active_execution_claim_for_lifecycle → renew_restore_lease_for_execution_claim (operation step)
  • api kubernetes/store/pod_placement.rs write in persist_pod_node_placement → record_pod_node_placement (observed projection)

The two command-ready clears were one statement indented differently; they now share one function with the substrate copy's text, so the internal-api copy changes only in leading whitespace. The guards are documented on each function: complete_wake checks no lease, generation or owner, and no locking read precedes it; record_pod_node_placement has no lifecycle predicate and relies on the caller's row lock; the lease renewal checks only token and expiry, under the caller's lock.

Not moved: update_and_fetch_post_wake_sandbox in responses.rs. Its UPDATE … RETURNING * CTE decodes into the api's joined Sandbox row, built from api-owned SANDBOX_COLUMNS/SANDBOX_JOIN_TAIL, which the store can't decode or own; responses.rs stays at 3 in the ratchet.

sql! locators change: the moved statements now carry pplx_space_sandbox_store::wake, which is what pg_stat_activity and query monitoring show.

Baseline: removes the sandbox_writes entries for lifecycle.rs, wake_completion.rs, activation_fence.rs, execution_rows.rs, pod_placement.rs and service_route.rs; the lifecycle.rs file_size cap goes from 1793 to 1775.

Validation

  • cargo nextest run --locked --all-features -p pplx-space-db-test-fixtures -p pplx-space-sandbox-store -p pplx-space-internal-api-server: 465 passed, 0 skipped.
  • … -p pplx-space-db-test-fixtures -p pplx-space-api: 2160 passed, 1 skipped (an #[ignore] benchmark). Postgres tests ran (no opt-out).
  • No test files changed.
  • Mutations (local, not committed): dropping lifecycle = 'started' from clear_command_ready_pending fails k8s_store_postgres_behaviors; dropping 'suspending' from complete_wake fails wake_completion_cas_outcome_for_every_prior_lifecycle.
  • cargo clippy --locked --all-targets --all-features -p <the 3> -- -D warnings: clean.
  • cargo arch --base-baseline <main> --base-architecture <main>: 0 required findings.
  • Fresh Kind from this change's code (infra/space/kind/scripts/up.sh, 730 s; later edits change only comments), then scripts/tests/smoke-kind-typed.sh all (3076 s):
    • ECW: 85 passed, 0 failed, 3 inconclusive. ecw.cold_create_environment and ecw.warm_pool_environment needed SPACE_SMOKE_KIND_COLD_RECEIPTS; with it set, both passed.
    • local.restarted_btrfs_send_is_rejected_and_retried needs telemetry mode otel; not run.
    • Native: 35 passed.
  • Final head: nextest (fixtures + sandbox-store) 30 passed, 0 skipped; clippy clean; cargo arch 0 required.

Severity and risk

Severity: does not apply (refactor). Risk: low: the same statements, locks and transactions. Roll back by reverting the commit.

Rollout

No migration. Mixed-version pods issue the same statements apart from the locator comment and that whitespace. Monitoring keyed on the old locator paths needs the new one.

Open PRs that will need to rebase

AI assistance: Claude Code (an AI agent) wrote the code, ran the validation and drafted this description.

After the wave-2 restack

This PR is one layer of a 10-PR stack, restacked onto main c5fdf0c7 (which includes #826) and then rebased mechanically onto 42a99002, which changed only baseline context lines, in order #1329 → #1336 → #1338 → #1339 → #1342 → #1347 → #1333 → #1335 → #1328 → #1332. The validation earlier in this description ran at pre-restack heads; this layer's head is e0b4d257.

@github-actions github-actions Bot added the triage:pending Waiting for a maintainer to triage label Nov 2, 2026
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

Thanks for opening this pull request! A SPACE maintainer will take a look.

CONTRIBUTING.md explains how we review outside contributions.

@ac-pplx
ac-pplx force-pushed the ac/lifecycle-move-wake branch from c6098b7 to 1560388 Compare November 2, 2026 21:06
@ac-pplx
ac-pplx force-pushed the ac/lifecycle-move-wake branch from 1560388 to 1b40b1f Compare November 2, 2026 23:25
@ac-pplx
ac-pplx changed the base branch from main to ac/lifecycle-move-create November 3, 2026 03:50
@ac-pplx
ac-pplx added this pull request to stack #1382 November 3, 2026 03:50
@ac-pplx
ac-pplx marked this pull request as ready for review November 3, 2026 03:51
@ac-pplx
ac-pplx marked this pull request as draft November 3, 2026 03:52
@ac-pplx
ac-pplx force-pushed the ac/lifecycle-move-wake branch from 1b40b1f to 7cfd3c8 Compare November 3, 2026 06:00
@ac-pplx
ac-pplx marked this pull request as ready for review November 3, 2026 06:29
…a wake module

Five sandboxes writes that finish bringing a sandbox up were still inline in
the api and internal-api crates: the wake-completion CAS, the cancelled-wake
redrive's fenced completion, the command-ready clear (written twice, once
per access path), the restore-lease renewal while claiming the active
Kubernetes execution, and the pod node placement, which cold creates record
too. They move into pplx-space-sandbox-store's new wake module, one function
per transition, each documented with the kind of fact it writes.

The SQL text is unchanged except that the internal-api command-ready clear
now issues the substrate copy's whitespace; both callers share one function.
Locking reads and transactions stay with the callers. The sql! locators of
the moved statements now name the store module.

The pooled post-wake update in responses.rs stays: it returns the api's
joined Sandbox response row, built from api-owned column and join fragments,
which the store cannot own or decode.

The sandbox_writes ratchet drops the six files whose only write moved, and
lifecycle.rs's file_size cap falls to 1777.
@ac-pplx
ac-pplx force-pushed the ac/lifecycle-move-wake branch from 7cfd3c8 to e0b4d25 Compare November 3, 2026 21:23
@ac-pplx
ac-pplx added this pull request to the merge queue Nov 3, 2026
Merged via the queue into main with commit b43f2b6 Nov 3, 2026
27 checks passed
@ac-pplx
ac-pplx deleted the ac/lifecycle-move-wake branch November 3, 2026 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

triage:pending Waiting for a maintainer to triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants