pub struct ExperimentRunner { /* private fields */ }website only.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>,
) -> ExperimentRunner
pub fn new( site: Uuid, charters: Arc<dyn CharterStore>, store: Arc<dyn ExperimentStore>, ) -> ExperimentRunner
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>) -> ExperimentRunner
pub fn with_source(self, source: Arc<dyn KpiSource>) -> ExperimentRunner
Reads per-arm counts from source for plans that name it (beacon by default).
Sourcepub fn with_kpis(self, kpis: Arc<dyn KpiStore>) -> ExperimentRunner
pub fn with_kpis(self, kpis: Arc<dyn KpiStore>) -> ExperimentRunner
Reads the baselines the KPI tracker locked, beside the charter’s own.
Sourcepub fn with_control(self, control: Arc<dyn JobControl>) -> ExperimentRunner
pub fn with_control(self, control: Arc<dyn JobControl>) -> ExperimentRunner
Pauses the job through control on a guardrail breach (A-I15).
Sourcepub fn with_ladder(self, ladder: AutonomyLadder) -> ExperimentRunner
pub fn with_ladder(self, ladder: AutonomyLadder) -> ExperimentRunner
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>) -> ExperimentRunner
pub fn with_events(self, sink: Arc<dyn CharterEventSink>) -> ExperimentRunner
Emits the pause on sink, such as the product’s alarm router (P2).
Sourcepub fn with_audit(self, trail: AuditTrail) -> ExperimentRunner
pub fn with_audit(self, trail: AuditTrail) -> ExperimentRunner
Records website.job.paused on trail.
Sourcepub fn with_stop_hook(
self,
hook: Arc<dyn ExperimentStopHook>,
) -> ExperimentRunner
pub fn with_stop_hook( self, hook: Arc<dyn ExperimentStopHook>, ) -> ExperimentRunner
Calls hook when an experiment stops.
Sourcepub fn with_clock(self, clock: Arc<dyn Clock>) -> ExperimentRunner
pub fn with_clock(self, clock: Arc<dyn Clock>) -> ExperimentRunner
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, AdkError>
pub async fn start( &self, plan: ExperimentPlan, ) -> Result<ExperimentRecord, AdkError>
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 look(&self, id: &str) -> Result<Option<LookOutcome>, AdkError>
pub async fn look(&self, id: &str) -> Result<Option<LookOutcome>, AdkError>
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>, AdkError>
pub async fn look_all(&self) -> Result<Vec<LookOutcome>, AdkError>
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: HashMap<String, Value>,
cancel_token: CancellationToken,
) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
ExperimentRunner: 'async_trait,
fn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
workflow_id: &'life1 str,
input: HashMap<String, Value>,
cancel_token: CancellationToken,
) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
ExperimentRunner: '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> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.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> ⓘ
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 moreimpl<T> MaybeSend for Twhere
T: Send,
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.