pub struct CaptureSession { /* private fields */ }Expand description
A run owns one ledger and at most one step of host records. Consumers must drain each step before another is started; there is no producer queue.
Implementations§
Source§impl CaptureSession
impl CaptureSession
Sourcepub fn checkpoint_storage_bytes(
&self,
discovery: &CaptureDiscovery,
) -> Option<u64>
pub fn checkpoint_storage_bytes( &self, discovery: &CaptureDiscovery, ) -> Option<u64>
Known logical host storage for a copied portable checkpoint. Includes all
admitted plan payloads and declarations, but no native estimator or handle.
Callers reserve this before checkpoint clones the admission data.
Sourcepub fn checkpoint(
&self,
discovery: &CaptureDiscovery,
) -> Result<CaptureCheckpoint, CaptureError>
pub fn checkpoint( &self, discovery: &CaptureDiscovery, ) -> Result<CaptureCheckpoint, CaptureError>
Saves portable schedule position only after the current records have been delivered and all intervention finish checks succeeded. The initial run is also a valid boundary. The caller supplies retained loaded discovery.
Sourcepub fn validate_restore(
&self,
checkpoint: &CaptureCheckpoint,
) -> Result<(), CaptureError>
pub fn validate_restore( &self, checkpoint: &CaptureCheckpoint, ) -> Result<(), CaptureError>
Checks a same-run restore before any native or portable mutation. Undelivered records must be consumed even when the previous operation failed.
Sourcepub fn restore(
&mut self,
checkpoint: &CaptureCheckpoint,
) -> Result<(), CaptureError>
pub fn restore( &mut self, checkpoint: &CaptureCheckpoint, ) -> Result<(), CaptureError>
Rewinds schedule state without refunding any consumed resource or publishing old records again. Native restoration must succeed before this is committed.
Sourcepub fn prepare_restore(
&mut self,
checkpoint: &CaptureCheckpoint,
) -> Result<PreparedCaptureRestore<'_>, CaptureError>
pub fn prepare_restore( &mut self, checkpoint: &CaptureCheckpoint, ) -> Result<PreparedCaptureRestore<'_>, CaptureError>
Validates restoration while exclusively borrowing the run until commit.
Sourcepub fn cumulative_usage(&self) -> CaptureUsage
pub fn cumulative_usage(&self) -> CaptureUsage
Cumulative usage of this run, including the explicitly inherited child base.
Source§impl CaptureSession
impl CaptureSession
Sourcepub fn new(plan: AdmittedCapturePlan) -> Self
pub fn new(plan: AdmittedCapturePlan) -> Self
Creates an unstarted capture run owning its admission and ledger.
Sourcepub fn plan(&self) -> &AdmittedCapturePlan
pub fn plan(&self) -> &AdmittedCapturePlan
Borrows this run’s immutable admission.
Sourcepub fn intervention_plan(&self) -> Option<&AdmittedInterventionPlan>
pub fn intervention_plan(&self) -> Option<&AdmittedInterventionPlan>
Immutable intervention admission currently paired with this shared owner.
Sourcepub fn begin_step(
&mut self,
phase: CapturePhase,
prediction: u64,
) -> Result<(), CaptureError>
pub fn begin_step( &mut self, phase: CapturePhase, prediction: u64, ) -> Result<(), CaptureError>
Reserves diagnostic envelopes before execution, including scheduled skips and missing values. Exhaustion here fails the step: emitting an unaccounted skip record would itself violate the export limit.
Sourcepub fn observe<B: CaptureBackend>(
&mut self,
backend: &mut B,
path: &str,
tensor: &B::Tensor,
) -> Result<(), CaptureExecutionError<B::Error>>
pub fn observe<B: CaptureBackend>( &mut self, backend: &mut B, path: &str, tensor: &B::Tensor, ) -> Result<(), CaptureExecutionError<B::Error>>
Invoked while the architecture borrows a tensor. A skipped point never calls the native transform and never clones a native tensor handle.
Sourcepub fn take_step(&mut self) -> Option<CapturedStep>
pub fn take_step(&mut self) -> Option<CapturedStep>
Moves the current bounded record batch to the consumer.
Source§impl CaptureSession
impl CaptureSession
Sourcepub fn enable_interventions(
&mut self,
plan: AdmittedInterventionPlan,
estimator: Arc<dyn InterventionEstimator>,
) -> Result<(), CaptureError>
pub fn enable_interventions( &mut self, plan: AdmittedInterventionPlan, estimator: Arc<dyn InterventionEstimator>, ) -> Result<(), CaptureError>
Installs an immutable intervention plan before the first step. Both plans share one ledger; capture-none budgets must still allow outcome metadata.
Sourcepub fn intervene<B: InterventionBackend>(
&mut self,
backend: &mut B,
path: &str,
tensor: &B::Tensor,
) -> Result<Option<B::Tensor>, CaptureExecutionError<B::Error>>
pub fn intervene<B: InterventionBackend>( &mut self, backend: &mut B, path: &str, tensor: &B::Tensor, ) -> Result<Option<B::Tensor>, CaptureExecutionError<B::Error>>
Applies scheduled activation operations in plan order. Ordinary observation must precede this call at the exact same hook. Returns no replacement when no operation is active, avoiding source cloning and native materialization.
Sourcepub fn finish_interventions(&self) -> Result<(), CaptureError>
pub fn finish_interventions(&self) -> Result<(), CaptureError>
Checks scheduled targets before committing a prediction. Missing targets are preserved in records and fail the attempt; this does not establish rollback.
Source§impl CaptureSession
impl CaptureSession
Sourcepub fn routing_control(
&mut self,
path: &str,
token_rows: u64,
) -> Result<Option<GroupSelectionControl>, CaptureError>
pub fn routing_control( &mut self, path: &str, token_rows: u64, ) -> Result<Option<GroupSelectionControl>, CaptureError>
Validates a scheduled routing operation against actual flattened token rows and reserves any original-decision work before the selector runs.
Sourcepub fn routing_applied<B: CaptureBackend>(
&mut self,
backend: &mut B,
path: &str,
original: Option<RoutingDecision<'_, B::Tensor>>,
effective: RoutingDecision<'_, B::Tensor>,
) -> Result<(), CaptureExecutionError<B::Error>>
pub fn routing_applied<B: CaptureBackend>( &mut self, backend: &mut B, path: &str, original: Option<RoutingDecision<'_, B::Tensor>>, effective: RoutingDecision<'_, B::Tensor>, ) -> Result<(), CaptureExecutionError<B::Error>>
Captures attributed IDs/coefficients before the expert provider runs.
Sourcepub fn routing_failed(&mut self, path: &str, message: &str)
pub fn routing_failed(&mut self, path: &str, message: &str)
Retains a bounded selector failure without treating it as proof of rollback.