fix(kernel): stamp each start when journaled, not when its batch was elected
Problem
The scheduler elects an independent batch at one instant; the drive loop then runs it serially. Each step.attempt.started was built with the election-time now_ms and kept it, even when journaled after a deterministic peer had run. Found while building the observer run projection (#570). Journal of a fan-out run (fetch → {lint: sleep 10, test: sleep 14} → report), elapsed seconds per entry:
7 18.06 step.completed lint 10023
8 18.06 step.routed test
9 8.03 step.attempt.started test <- stamped at election, journaled at 18.06
10 32.09 step.completed test 24055 <- wallclock_ms for a `sleep 14`
Two consequences:
- Wrong wall clock. It includes the peer's runtime (24055ms for a 14s step), feeding spend/budget accounting and every surface that reports durations.
- A lease spent in advance.
lease_deadline_mscomes from the same stale time. With the 30s default, a step started 10s late holds a 20s lease and can be judged expired while it is running. An llm/agent step dispatched later in the same batch gets the same shortened lease in itsStepDispatch.
Change
engine/drive.rs: when a start is appended, stamp it with the current clock and move its lease_deadline_ms by the delay. The batch's Dispatch for that step/attempt moves by the same delay, so the worker and the journal agree. Lease ids are unchanged (identity, not time).
Serial execution is unchanged on purpose. deterministic_spend_and_wallclock_limit_gate_parallel_batch_starts and stop_after_one_holds_for_an_independent_deterministic_batch pin it: the budget gate re-folds between starts, and crash injection stops after one completion. Under a simulated clock the delay is zero, so deterministic replay is unaffected.
Evidence
- New tests in
relayflowd/tests/parallel_driver.rs:a_start_after_a_slow_deterministic_peer_is_stamped_when_journaled: the start is not earlier than the peer's completion; wall clock < 300ms for a no-op after asleep 0.4peer; lease deadline − start = 30000 for both steps.a_dispatch_after_a_slow_deterministic_peer_keeps_its_full_lease:StepDispatch.lease_deadline_msequals the start entry's, and is 30000 after it.
- Mutation check (
if delay > 0→if false && delay > 0):
Restored (test a_dispatch_after_a_slow_deterministic_peer_keeps_its_full_lease ... FAILED test a_start_after_a_slow_deterministic_peer_is_stamped_when_journaled ... FAILED quick started at 1790259503865 before slow completed at 1790259504277 test result: FAILED. 0 passed; 2 failedcmpidentical):test result: ok. 2 passed. sh ../ops/cargo.sh test --workspace --no-fail-fast→cargo_exit=0, 26 test binaries allok, crash-injection suites included.
🤖 Generated with Claude Code
[!NOTE]
Cursor Bugbot is generating a summary for commit 2fa82dd183dd7e4e23e6f1f1f42f7c341abd864b. Configure here.
Summary by cubic
Fixes the scheduler stamping step.attempt.started entries with election time even when journaled after a deterministic peer ran, so wall-clock duration and lease deadlines no longer include the peer's runtime.
- Each start is now stamped when appended, after placement, and its
lease_deadline_msplus the matchingStepDispatchdeadline are extended by the delay. - Serial batch execution and deterministic replay under a simulated clock are unchanged.
- Adds two regression tests, moved to their own file, covering a start and a dispatched model step after a slow deterministic peer; they assert ordering and lease structure rather than wall-clock bounds so a loaded CI host cannot fail them.
Agent Relay sessions
claudesession110a8f49· opened viagh pr create· last active 2026-09-24