Carry verified suffix checkpoints into later native edits
This commit is contained in:
1 parent
1cf985469c
commit
c42a1a72aa
5 files changed
+208
-28
No files matched your search
@@ -404,6 +404,56 @@ impl<'a> CapturedEntries<'a> {
|
||||
self.changed = true;
|
||||
}
|
||||
|
||||
fn replay_settled_suffix(
|
||||
&mut self,
|
||||
page: usize,
|
||||
current: &EntryCheckpoint,
|
||||
prior: &SettledCheckpoint,
|
||||
completed: &CompletedExecution,
|
||||
host: &mut RecordingHost,
|
||||
cancellation: &Cancellation,
|
||||
) -> Result<(), String> {
|
||||
let project = self.request.project.as_deref().expect("settled replay uses a project");
|
||||
let bytes = project.file(&completed.guard.entry).expect("settled entry").data.len();
|
||||
let stride = bytes.div_ceil(SOURCE_INTERVALS).max(1);
|
||||
let mut later = [const { None }; SOURCE_INTERVALS];
|
||||
let rebase = current.prepare_suffix_rebase(&prior.entry);
|
||||
// Keep the deepest compatible settled continuation per source interval.
|
||||
for (&page, anchor) in completed.settled.range((std::ops::Bound::Excluded(page), std::ops::Bound::Unbounded)).rev() {
|
||||
let interval = (anchor.entry.frontier() - 1) / stride;
|
||||
if later[interval].is_some() {
|
||||
continue;
|
||||
}
|
||||
check(cancellation).map_err(|error| error.to_string())?;
|
||||
if let Some(entry) = rebase(&anchor.entry) {
|
||||
later[interval] = Some((page, anchor, entry));
|
||||
}
|
||||
}
|
||||
|
||||
let mut replayed = prior.call_count;
|
||||
for (interval, (page, anchor, entry)) in later.into_iter().enumerate()
|
||||
.filter_map(|(interval, anchor)| anchor.map(|anchor| (interval, anchor)))
|
||||
{
|
||||
let Some(calls) = completed.calls.get(replayed..anchor.call_count) else {
|
||||
continue;
|
||||
};
|
||||
host.replay_suffix(calls, cancellation)?;
|
||||
replayed = anchor.call_count;
|
||||
if anchor.host == host.files().replay_boundary() {
|
||||
let regular = CaptureSlots {
|
||||
interval,
|
||||
early: false,
|
||||
page: true,
|
||||
edit: false,
|
||||
next_page: page.saturating_add(1),
|
||||
};
|
||||
self.capture(Capture::Settled { page, regular: Some(regular) }, Arc::new(entry), host);
|
||||
}
|
||||
}
|
||||
host.replay_suffix(&completed.calls[replayed..], cancellation)?;
|
||||
completed.guard.verify_replayed_inputs(host.files(), project).map_err(|error| error.to_string())
|
||||
}
|
||||
|
||||
fn finish(
|
||||
self,
|
||||
recording: RecordingHost,
|
||||
@@ -928,10 +978,8 @@ impl SelectedCheckpoint {
|
||||
return CheckpointDecision::Continue;
|
||||
};
|
||||
let calls = &completed.calls[old.call_count..];
|
||||
let replayed = host.replay_suffix(calls, &cancellation)
|
||||
.and_then(|()| completed.guard.verify_replayed_inputs(
|
||||
host.files(), request.project.as_deref().expect("settled replay uses a project"),
|
||||
).map_err(|error| error.to_string()));
|
||||
let replayed =
|
||||
captures.replay_settled_suffix(page, &entry, old, completed, host, &cancellation);
|
||||
if let Err(error) = replayed {
|
||||
let discarded = entry.completed_steps().saturating_sub(work.reused_steps);
|
||||
*suffix_failure = Some((error.clone(), discarded));
|
||||
|
||||
Reference in new issue
Block a user