Pass run IDs directly into detached start services

This commit is contained in:
Bryan Helmkamp 2026-04-01 21:29:44 -07:00
parent 92dc29a897
commit f39255594c
No known key found for this signature in database
3 changed files with 5 additions and 4 deletions

View file

@ -51,6 +51,7 @@ pub(crate) async fn execute(
let runtime_state = RuntimeState::new(&run_dir);
let services = StartServices {
run_id: run_record.run_id,
cancel_token: None,
emitter: Arc::new(EventEmitter::new(run_record.run_id)),
interviewer: Arc::new(FileInterviewer::new(

View file

@ -738,6 +738,7 @@ async fn execute_run(state: Arc<AppState>, run_id: RunId) {
}
};
let services = operations::StartServices {
run_id,
cancel_token: Some(Arc::clone(&cancel_token)),
emitter: Arc::clone(&emitter),
interviewer: Arc::clone(&interviewer) as Arc<dyn Interviewer>,

View file

@ -65,6 +65,7 @@ struct RunSession {
}
pub struct StartServices {
pub run_id: RunId,
pub cancel_token: Option<Arc<AtomicBool>>,
pub emitter: Arc<EventEmitter>,
pub interviewer: Arc<dyn Interviewer>,
@ -118,15 +119,12 @@ pub(super) async fn execute_persisted_run(
mut services: StartServices,
) -> Result<Started, FabroError> {
let cancel_token = services.cancel_token.clone();
let run_id = services.run_id;
let inner_store = Arc::clone(&services.run_store);
let projection_run_dir = run_dir.to_path_buf();
services.run_store = Arc::new(
DiskProjectingRunStore::new(inner_store, run_dir.to_path_buf()).on_projection_error(
Arc::new(move |projection_error: ProjectionError| {
let Some(run_id) = load_run_id(&projection_run_dir) else {
return;
};
// Write directly to progress.jsonl/live.json so projection failures do not
// recurse back through the decorated store.append_event() path.
let envelope = canonicalize_event(
@ -947,6 +945,7 @@ mod tests {
registry: Arc<HandlerRegistry>,
) -> StartServices {
StartServices {
run_id: fixtures::RUN_1,
cancel_token: None,
emitter,
interviewer: Arc::new(fabro_interview::AutoApproveInterviewer),