Reuse verified native suffixes after settled output routines

This commit is contained in:
gloamxun committed 2026-11-29 07:51:37 +08:00
1 parent f387b1db61
commit 0117449023
30 files changed
+791 -77

No files matched your search

+55
View File
@@ -157,6 +157,20 @@ struct DraftLedger {
staged: PreparedOutput,
}
#[derive(PartialEq, Eq)]
pub(super) struct ReplayBoundary {
inputs: Vec<(u8, u64, PathBuf, u64, std::collections::VecDeque<u8>)>,
outputs: Vec<(u8, u64, PathBuf, u64)>,
next_handle: u64,
columns: [usize; 2],
terminal_enabled: bool,
generated_reads: BTreeMap<PathBuf, ResourceVersion>,
generated_before: BTreeMap<PathBuf, Option<ResourceVersion>>,
generated_written: BTreeSet<PathBuf>,
trace: texrra_tex_core::resources::ResourceTrace,
stream_events: Vec<crate::native_stream::StreamEvent>,
}
pub struct Files {
world: FileWorld,
#[cfg(all(target_os = "linux", target_env = "gnu"))]
@@ -654,6 +668,47 @@ impl Files {
.operation(name, path, result);
}
pub(super) fn replay_boundary(&self) -> ReplayBoundary {
let mut trace = self.resource_trace().clone();
trace.project_version = None;
// The caller compared the live scanner bytes and validates later
// whole-file reads separately. Keep this entry's path and length.
if let Some(entry) = trace.reads.first_mut() {
entry.sha256.clear();
}
let mut stream_events = self.stream_io.events().to_vec();
for event in &mut stream_events {
if let crate::native_stream::StreamEffect::OutputOpened {
descriptor: Ok(identity), ..
} = &mut event.effect
{
// A fresh draft has a different inode. The stream path,
// opening version, accepted bytes and handle remain in the journal.
identity.unix_identity = None;
}
}
ReplayBoundary {
inputs: self.inputs.iter().map(|(&index, input)| {
(index, input.handle, input.path.clone(), input.offset, input.xe_lookahead.clone())
}).collect(),
outputs: self.outputs.iter().map(|(&index, output)| {
(index, output.handle, output.path.clone(), output.accepted)
}).collect(),
next_handle: self.next_handle,
columns: [self.log_column, self.terminal_column],
terminal_enabled: self.terminal_enabled,
generated_reads: self.generated_reads.clone(),
generated_before: self.generated_before.clone(),
generated_written: self.generated_written.clone(),
trace,
stream_events,
}
}
pub(super) fn replay_world(&self) -> &FileWorld {
&self.world
}
pub(super) fn generated_outputs(&self) -> &BTreeSet<PathBuf> {
&self.generated_written
}