Skip to content

api: record requested size for activations and resumes - #1577

Merged
gilalon-pplx merged 10 commits into
mainfrom
gil/requested-size-4-activation
Nov 6, 2026
Merged

gilalon-pplx merged 10 commits into
mainfrom
gil/requested-size-4-activation

Conversation

@gilalon-pplx

@gilalon-pplx gilalon-pplx commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Extend requested vCPU and memory recording to lifecycle activations and resumes, using the sandbox row’s effective size. Record successful actions and explicit admission rejections; exclude callers joining another activation, unrelated failures, and unresolved or invalid sizes.

Document admission during resume recovery, eligible implicit wakes, and distribution counts representing eligible recorded calls rather than total incoming requests. Reuse the existing metric definitions and admission classification without adding telemetry-assertion tests.

Also has some style updates. Renamed requested_metrics to requested_size_metrics, and removed requested.rs since that code can just live inside api.rs with the rest of the metrics.

Validation

  • cargo test -p pplx-space-metrics -p pplx-space-api --all-features: passed locally.
  • cargo fmt --all -- --check: passed locally.
  • pre-commit run --all-files: passed.
  • git diff --check: passed.
  • Verified the published tree matches the reviewed Cloud commit and includes the updated PR3 as an ancestor.

Runtime metric ingestion has not been validated.

Severity and risk

Severity does not apply: this adds observability rather than fixing application behavior. The main risk is incorrect sample counting or classification; admission decisions and lifecycle behavior are intended to remain unchanged.

Rollback: revert this PR’s lifecycle recording changes. The parent metric definitions, admission classification, and create recording can remain.

Stack

Requested-size metrics stack; merge from bottom to top:

  1. [#1505: Metric definitions and emitter](metrics: add requested vCPU and memory distributions #1505).
  2. [#1506: Shared admission-error constructor](api: centralize cluster admission rejection construction #1506).
  3. [#1510: Create recording and admission classification](api: record requested vCPU and memory for creates #1510).
  4. This PR: activation and resume recording, based on gil/requested-size-3-create.

AI assistance: Perplexity Computer reviewed and updated the implementation, restacked the branch, and drafted this description.

Move RequestedKind, RequestedSize and requested() from their own
sandbox/api/requested.rs into sandbox/api.rs, next to the other
sandbox API metrics, and delete the file. The file's module
documentation becomes the doc comment on requested(). The public
paths under pplx_space_metrics::sandbox::api are unchanged.
The controller module maps create, activation and resume outcomes onto
the requested-size distributions; name it for them.
Move the entry-lifecycle classification into
SandboxAction::requested_kind, next to activation_class, and let
record_lifecycle_action decide whether a result counts: it now takes
the optional kind and the action's result and records only an
eligible kind that succeeded or was refused by cluster admission.
action() keeps the async block and the three exits that clear the
kind for a joined activation. Recording behavior is unchanged.
@coderabbitai

coderabbitai Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The requested-size metrics API now records vCPU and memory distributions for eligible creates, activations, and resumes. The lifecycle controller classifies actions and records samples based on their final results. The observability documentation describes recording rules and exclusions.

Possibly related PRs

  • perplexityai/SPACE#1068: Changes restore-claim recovery charges and admission policy, which connect to this PR’s requested-size metrics for admission rejections.
Merge Risk: Low · up to f7344

This adds metrics for sandbox activation and resume. Lifecycle behavior is intended to stay the same, but the action flow was restructured and the new samples have no telemetry tests, so owners should check the new metrics after rollout.

Security architecture risk: Low · up to f7344

The change expands observability without an identified authorization bypass or change to sandbox ownership and admission behavior. Remaining uncertainty concerns production metric ingestion and operational coverage, rather than a demonstrated security defect.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The demonstrated exposure increase is additional requested-size telemetry from eligible controller-mediated lifecycle calls, including implicit wakes. The inspected changes do not grant callers additional sandbox, tenant, credential, or infrastructure authority. Data-plane paths bypassing this controller remain outside the documented metric population.

Trust Boundaries and Controls

  • observed — Inspected E2B callers retain scoped sandbox lookup before dispatch. Ingress implicit wake retains access and lifecycle-policy validation. The controller retains drain checks, activation validation, admission enforcement, and recovery charging; the new metric classification does not replace these controls.

Resilience and Maintainability Implications

  • observed — These distributions are operational observations, not a complete admission or security audit ledger. They intentionally exclude unrelated failures, joined activations, unresolved sizes, restoring-state actions, and paths outside the controller; retry samples are not deduplicated.
Pre-merge checks: Passed 5

Check name Status Explanation
Title check Passed The title identifies the API area and summarizes the main change. It meets the specified formatting requirements.
Description Follows The Pr Template Passed The description contains all four required items: Summary, Validation, Severity and risk, and AI assistance.
Bug Fixes Name A Regression Test Passed This PR adds lifecycle metrics and documentation. The reviewed changes do not fix a defect in application behavior, so the regression-test requirement does not apply.
Weakened Safeguards Are Justified Passed The diff does not weaken a test, assertion, lint, CI check, or repository guard. The renamed metrics test module remains connected, and the lifecycle change adds a test.
Public-Safe Content Passed The diff, title, and description contain no identified content covered by the failure conditions.
Recent review info

Automatic approval policy

Commit: f734438e890b.

Setting Effective value Source
Automatic approvals Enabled Global configuration
Merge risk Low Override 2
Security risk Not set Global configuration

Matching overrides (numbered as in the resolved configuration):

  • Override 2 — any author; paths: **, !ui/**; merge risk: Low.

Any matching disabled override withholds approval, regardless of risk. Otherwise, the strictest explicitly set limit wins for each score. Limits omitted by all matching overrides inherit the global configuration.

Not set means no limit was configured after inheritance. Use @coderabbitai configuration to inspect the resolved settings and their sources.

Run configuration

Commits

Reviewing files that changed from the base of the PR and between f1f2405 and f734438.

Files selected for processing: 9

  • crates/l40_api/api/src/controllers/sandbox/lifecycle.rs
  • crates/l40_api/api/src/controllers/sandbox/lifecycle/tests.rs
  • crates/l40_api/api/src/controllers/sandbox/mod.rs
  • crates/l40_api/api/src/controllers/sandbox/queries.rs
  • crates/l40_api/api/src/controllers/sandbox/requested_size_metrics.rs
  • crates/l40_api/api/src/controllers/sandbox/requested_size_metrics/tests.rs
  • crates/libs/metrics/src/sandbox/api.rs
  • crates/libs/metrics/src/sandbox/api/requested.rs
  • docs/observability.md
Files with no reviewable changes: 1

  • crates/libs/metrics/src/sandbox/api/requested.rs

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.

Name the requested-size emitter for what it records, matching its
RequestedSize argument and the requested_size_metrics module that
calls it.
An ECW connect reaches the lifecycle controller as a wake. From a
paused sandbox, which is still resident in memory, that wake resumes
it as a native resume would, yet only the native resume verb was
recorded as kind:resume, so ECW callers never produced one. Classify
a resume, wake or implicit wake from paused as kind:resume.

Rename SandboxAction::requested_kind to requested_size_kind, document
what it classifies, and pin its table in a unit test. The docs' kind
row now names the wake and the ECW connect, and a wake of a paused
sandbox leaves the not-recorded list.
@gilalon-pplx
gilalon-pplx marked this pull request as ready for review November 6, 2026 14:53

@nikhilbirmiwal-pplx nikhilbirmiwal-pplx left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed the lifecycle refactor and requested-size recording at f734438. No blocking correctness findings.

The inner async block preserves the existing lifecycle/admission/event flow while allowing the outer recording point to observe early returns. Eligible activations and paused resumes record the stored effective CPU/memory on success or explicit admission rejection; joined activations clear the sample, and unrelated failures or invalid/unknown sizes are excluded. Metric names and tags remain unchanged by the emitter move.

Validation: inspected the diff and supporting call paths; GitHub CI reports Rust tests, clippy and formatting successful. Kind smoke was skipped. I did not rerun tests locally or validate runtime metric ingestion.

Created with Perplexity

@gilalon-pplx
gilalon-pplx added this pull request to the merge queue Nov 6, 2026
Merged via the queue into main with commit 7c48013 Nov 6, 2026
43 checks passed
@gilalon-pplx
gilalon-pplx deleted the gil/requested-size-4-activation branch November 6, 2026 15:30
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.

2 participants