pub struct RunUsage {
pub running: Option<DurationP>,
pub suspended: Option<DurationP>,
pub image_build: Option<DurationP>,
pub image_gb: Option<f64>,
pub image_retained: Option<DurationP>,
pub suspend_resume_cycles: u32,
pub snapshot_gb: Option<f64>,
pub launched: bool,
}Expand description
What to attribute cost to, for one sandbox’s lifecycle.
A struct rather than eleven parameters, because the Python’s keyword-only
signature has no direct Rust equivalent and eleven positional arguments is how a
caller passes image_gb where snapshot_gb was meant. Default gives the same
“pass only the phases that happened” ergonomics as the Python’s defaults.
Every duration is a DurationP, so a report built from timed phases and one
built from a plan are the same shape and are told apart by their own contents
rather than by which function produced them.
Fields§
§running: Option<DurationP>Wall-clock time in RUNNING. Bills at baseline whether or not anything is executing — unlike AgentCore Runtime there is no free I/O wait, which is why suspension rather than idleness is the lever.
suspended: Option<DurationP>Time held suspended. Pays storage only: a suspended VM is frozen.
image_build: Option<DurationP>How long the image build took, if it was timed. Always unpriced (COST-3).
image_gb: Option<f64>The image’s size. Passing this adds both an image-storage line and the
unpriced build line: an image that has storage cost was built, and the build’s
price is unknown, so a create-and-destroy report is never complete. A caller
reusing an existing image passes None and pays neither.
image_retained: Option<DurationP>How long the image was retained. Defaults to the documented minimum, marked
Provenance::Projected — nobody timed that week either.
suspend_resume_cycles: u32Each cycle pays a snapshot write plus a read.
snapshot_gb: Option<f64>The suspend snapshot’s size. Defaults to the baseline memory footprint, which
is what docs/PLATFORM.md’s own worked figures use (“a suspended 2 GB VM pays
about $0.16 a month” is 2 GB at the storage rate). Whether a suspend snapshot
is baseline-sized or peak-sized is not documented; override it if you have
measured otherwise.
launched: boolWhether a launch happened. A launch reads a snapshot.
Implementations§
Source§impl RunUsage
impl RunUsage
Sourcepub fn launched() -> RunUsage
pub fn launched() -> RunUsage
A usage record for a sandbox that launched, with no phase attributed yet.
launched: true matches the Python’s default, and it is the right default:
almost every report is of a VM that ran, and the comparison path that does not
launch says so explicitly.
Sourcepub fn infer_launched(&self) -> bool
pub fn infer_launched(&self) -> bool
Whether this usage implies a launch: running time, or an image of non-zero size.
The rule every surface applies when its caller doesn’t say (#255). A launch reads a
snapshot, so claiming one that didn’t happen adds a transfer line. A zero-sized image
isn’t one: Some(0.0) claims no snapshot read the run never paid for, which is the
retired Python CLI’s bool(running_sec or image_gb).