pub struct ExperimentRunner { /* private fields */ }Expand description
Runs a site’s experiments (spec 3.5 §7.12, A-I15).
| Step | What it does |
|---|---|
start | Maps the plan onto the charter in force: the primary KPI’s metric and direction, each guardrail with its tolerance from the KPI baselines; fixes the analysis; refuses while the job is paused, an id already used, or a page another running experiment holds |
look | Reads the per-arm counts of the whole days since the last look from the plan’s KPI source, adds them to the totals, and analyses the totals as one cumulative Look, resuming the stored ExperimentState |
| Guardrail breach | Pauses the job through the kernel’s JobControl before anything else, records website.job.paused, emits CharterEvent::JobPaused (P2) and lowers the job one level on the ladder (A-I15, §7.11) |
| Any final decision | Stops the experiment: the next build serves the control alone; the stop hook can publish that release at once |
review | One entry per experiment that ran in the week: its decision and the analyzer’s evidence block |
Run look_all once a day: register the runner with
KernelBuilder::workflows and its trigger with KernelBuilder::trigger,
or call it from the product’s own loop.
§Example
let runner = ExperimentRunner::new(site, charters, experiments)
.with_source(Arc::new(BeaconKpi::new(edge.beacon())))
.with_kpis(kpis)
.with_control(kit.pauses.clone())
.with_ladder(ladder)
.with_events(alarms);
runner.start(plan).await?;
let outcomes = runner.look_all().await?;Implementations§
Source§impl ExperimentRunner
impl ExperimentRunner
Sourcepub fn new(
site: Uuid,
charters: Arc<dyn CharterStore>,
store: Arc<dyn ExperimentStore>,
) -> Self
pub fn new( site: Uuid, charters: Arc<dyn CharterStore>, store: Arc<dyn ExperimentStore>, ) -> Self
A runner of site’s experiments under its charters, keeping records in store, with
no sources, job control, ladder, events, audit or stop hook, on the system clock.
Sourcepub fn with_source(self, source: Arc<dyn KpiSource>) -> Self
pub fn with_source(self, source: Arc<dyn KpiSource>) -> Self
Reads per-arm counts from source for plans that name it (beacon by default).
Sourcepub fn with_kpis(self, kpis: Arc<dyn KpiStore>) -> Self
pub fn with_kpis(self, kpis: Arc<dyn KpiStore>) -> Self
Reads the baselines the KPI tracker locked, beside the charter’s own.
Sourcepub fn with_control(self, control: Arc<dyn JobControl>) -> Self
pub fn with_control(self, control: Arc<dyn JobControl>) -> Self
Pauses the job through control on a guardrail breach (A-I15).
Sourcepub fn with_ladder(self, ladder: AutonomyLadder) -> Self
pub fn with_ladder(self, ladder: AutonomyLadder) -> Self
Lowers the job one level on ladder on a guardrail breach (spec 3.5 §7.11).
Sourcepub fn with_events(self, sink: Arc<dyn CharterEventSink>) -> Self
pub fn with_events(self, sink: Arc<dyn CharterEventSink>) -> Self
Emits the pause on sink, such as the product’s alarm router (P2).
Sourcepub fn with_audit(self, trail: AuditTrail) -> Self
pub fn with_audit(self, trail: AuditTrail) -> Self
Records website.job.paused on trail.
Sourcepub fn with_stop_hook(self, hook: Arc<dyn ExperimentStopHook>) -> Self
pub fn with_stop_hook(self, hook: Arc<dyn ExperimentStopHook>) -> Self
Calls hook when an experiment stops.
Sourcepub fn with_clock(self, clock: Arc<dyn Clock>) -> Self
pub fn with_clock(self, clock: Arc<dyn Clock>) -> Self
Reads time from clock.
Sourcepub fn store(&self) -> &Arc<dyn ExperimentStore> ⓘ
pub fn store(&self) -> &Arc<dyn ExperimentStore> ⓘ
The record store, which the ExperimentGenerator reads.
Sourcepub async fn start(&self, plan: ExperimentPlan) -> Result<ExperimentRecord>
pub async fn start(&self, plan: ExperimentPlan) -> Result<ExperimentRecord>
Starts plan under the charter in force (spec 3.5 §7.12).
§Errors
Returns website.experiment.invalid for an invalid plan or one the charter cannot
measure (see ExperimentPlan::config), website.experiment.exists for an id
already used on the site or a page another running experiment holds,
website.experiment.paused while the job is paused (A-I15), and
website.experiment.no_charter before the first charter commit.
Sourcepub async fn list(&self) -> Result<Vec<ExperimentRecord>>
pub async fn list(&self) -> Result<Vec<ExperimentRecord>>
Sourcepub async fn look(&self, id: &str) -> Result<Option<LookOutcome>>
pub async fn look(&self, id: &str) -> Result<Option<LookOutcome>>
Looks at experiment id (spec 3.5 §7.12): adds the whole days since the last look
to its totals and analyses them; None when no whole day has passed since the last
look. A stopped experiment returns its final record unchanged.
§Errors
Returns website.experiment.unknown for an unknown id,
website.experiment.no_source when the plan’s source is not registered, a source’s
or the store’s error, and the analyzer’s refusal of a look; a failed look changes
nothing.
Sourcepub async fn look_all(&self) -> Result<Vec<LookOutcome>>
pub async fn look_all(&self) -> Result<Vec<LookOutcome>>
Looks at every running experiment once (spec 3.5 §7.12); one experiment’s failure is logged and does not stop the others.
§Errors
Returns the store’s error.
Trait Implementations§
Source§impl Debug for ExperimentRunner
impl Debug for ExperimentRunner
Source§impl WorkflowExecutor for ExperimentRunner
impl WorkflowExecutor for ExperimentRunner
Source§fn has_workflow(&self, workflow_id: &str) -> bool
fn has_workflow(&self, workflow_id: &str) -> bool
workflow_id can be executed. Read moreSource§fn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
workflow_id: &'life1 str,
input: WorkflowState,
cancel_token: CancellationToken,
) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
workflow_id: &'life1 str,
input: WorkflowState,
cancel_token: CancellationToken,
) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn execute_durable<'life0, 'life1, 'async_trait>(
&'life0 self,
workflow_id: &'life1 str,
input: HashMap<String, Value>,
run: WorkflowRunContext,
) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn execute_durable<'life0, 'life1, 'async_trait>(
&'life0 self,
workflow_id: &'life1 str,
input: HashMap<String, Value>,
run: WorkflowRunContext,
) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
workflow_id as one attempt of a durable run. Read moreAuto Trait Implementations§
impl !Freeze for ExperimentRunner
impl !RefUnwindSafe for ExperimentRunner
impl !UnwindSafe for ExperimentRunner
impl Forget for ExperimentRunner
impl Move for ExperimentRunner
impl Send for ExperimentRunnerwhere
Arc<dyn CharterStore>: Send,
Arc<dyn ExperimentStore>: Send,
NodeRef<Owned, String, Arc<dyn KpiSource>, LeafOrInternal>: Send,
BoxRaw<(String, Arc<dyn KpiSource>)>: Send,
Arc<dyn KpiStore>: Send,
Arc<dyn JobControl>: Send,
Arc<dyn AutonomyStore>: Send,
Arc<dyn Clock>: Send,
Arc<dyn AuditRecorder>: Send,
Arc<dyn CharterEventSink>: Send,
Arc<dyn ExperimentStopHook>: Send,
Mutex<()>: Send,
impl Sync for ExperimentRunnerwhere
Arc<dyn CharterStore>: Sync,
Arc<dyn ExperimentStore>: Sync,
NodeRef<Owned, String, Arc<dyn KpiSource>, LeafOrInternal>: Sync,
BoxRaw<(String, Arc<dyn KpiSource>)>: Sync,
Arc<dyn KpiStore>: Sync,
Arc<dyn JobControl>: Sync,
Arc<dyn AutonomyStore>: Sync,
Arc<dyn Clock>: Sync,
Arc<dyn AuditRecorder>: Sync,
Arc<dyn CharterEventSink>: Sync,
Arc<dyn ExperimentStopHook>: Sync,
Mutex<()>: Sync,
impl Unpin for ExperimentRunnerwhere
Arc<dyn CharterStore>: Unpin,
Arc<dyn ExperimentStore>: Unpin,
*const LeafNode<String, Arc<dyn KpiSource>> is !null: Unpin,
Box<(String, Arc<dyn KpiSource>)>: Unpin,
Arc<dyn KpiStore>: Unpin,
Arc<dyn JobControl>: Unpin,
Arc<dyn AutonomyStore>: Unpin,
Arc<dyn Clock>: Unpin,
Arc<dyn AuditRecorder>: Unpin,
Arc<dyn CharterEventSink>: Unpin,
Arc<dyn ExperimentStopHook>: Unpin,
Align4<u32>: Unpin,
Align1<u8>: Unpin,
*const Waiter is !null: Unpin,
Align8<usize>: Unpin,
impl UnsafeUnpin for ExperimentRunnerwhere
*const ArcInner<dyn CharterStore> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn CharterStore>>: UnsafeUnpin,
*const ArcInner<dyn ExperimentStore> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn ExperimentStore>>: UnsafeUnpin,
*const LeafNode<String, Arc<dyn KpiSource>> is !null: UnsafeUnpin,
PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin,
PhantomData<Box<(String, Arc<dyn KpiSource>)>>: UnsafeUnpin,
*const ArcInner<dyn KpiStore> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn KpiStore>>: UnsafeUnpin,
*const ArcInner<dyn JobControl> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn JobControl>>: UnsafeUnpin,
*const ArcInner<dyn AutonomyStore> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn AutonomyStore>>: UnsafeUnpin,
*const ArcInner<dyn Clock> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn Clock>>: UnsafeUnpin,
*const ArcInner<dyn AuditRecorder> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn AuditRecorder>>: UnsafeUnpin,
*const ArcInner<dyn CharterEventSink> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn CharterEventSink>>: UnsafeUnpin,
*const ArcInner<dyn ExperimentStopHook> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn ExperimentStopHook>>: UnsafeUnpin,
Align4<u32>: UnsafeUnpin,
Align1<u8>: UnsafeUnpin,
*const Waiter is !null: UnsafeUnpin,
Align8<usize>: UnsafeUnpin,
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more