agentmux_srv/drone/executor/scheduler/replay.rs
1// Copyright 2026, AgentMux Corp.
2// SPDX-License-Identifier: Apache-2.0
3
4//! The part of a replay that the scheduler decides: which blocks are stubbed
5//! (docs/specs/SPEC_DRONE_GENERAL_AUTOMATION_2026_11_11.md ยง3.3, `drone::replay`).
6
7use serde_json::Value;
8
9use super::Scheduler;
10use crate::drone::executor::effect::Effect;
11use crate::drone::types::{BlockKind, FlowNode};
12
13impl Scheduler<'_> {
14 /// What `node` says instead of running, when this run replays an earlier one and the block
15 /// would do something to the world (it sends, files, starts, writes or calls a drone that may).
16 /// A block that only reads runs as it always does, and so does every block of a run that
17 /// was asked to do it for real.
18 pub(super) fn stub_of(&self, node: &FlowNode, kind: BlockKind) -> Option<Result<Value, String>> {
19 let replay = self.replay.as_ref().filter(|r| !r.fork.real)?;
20 (self.real_effect_of_node(node, kind) != Effect::ReadOnly).then(|| replay.said(&node.id))
21 }
22
23 /// A stubbed block's output is as tainted as it was in the run replayed.
24 pub(super) fn keep_stub_bits(&mut self, id: &str) {
25 if let Some(bits) = self.replay.as_ref().and_then(|r| r.bits.get(id).copied()) {
26 self.scope.bits.insert(id.to_string(), bits);
27 }
28 }
29}
30
31#[cfg(test)]
32#[path = "replay_tests.rs"]
33mod tests;