Resume native editor jobs through verified checkpoints

This commit is contained in:
gloamxun committed 2026-11-19 09:35:33 +08:00
1 parent 31364ae33e
commit 0abf700817
19 files changed
+2311 -93

No files matched your search

+26 -3
View File
@@ -509,6 +509,7 @@ pub struct FileWorld {
deferred_probes: BTreeMap<PathBuf, DeferredProbe>,
namespace_observations: usize,
live_paths: BTreeSet<PathBuf>,
staged_generated: BTreeMap<PathBuf, PathBuf>,
/// Actual host resource promotions, never inferred from serialized cache.
protected_paths: BTreeSet<PathBuf>,
replay_gaps: Vec<String>,
@@ -642,6 +643,7 @@ impl FileWorld {
deferred_probes: BTreeMap::new(),
namespace_observations: 0,
live_paths: BTreeSet::new(),
staged_generated: BTreeMap::new(),
protected_paths: BTreeSet::new(),
replay_gaps: Vec::new(),
project: None,
@@ -680,6 +682,7 @@ impl FileWorld {
deferred_probes: BTreeMap::new(),
namespace_observations: 0,
live_paths,
staged_generated: BTreeMap::new(),
protected_paths: BTreeSet::new(),
replay_gaps: Vec::new(),
project: Some(project),
@@ -763,6 +766,7 @@ impl FileWorld {
.as_ref()
.map(|p| p.generated().map(Path::to_path_buf).collect())
.unwrap_or_default(),
staged_generated: BTreeMap::new(),
protected_paths: BTreeSet::new(),
replay_gaps: Vec::new(),
project: snapshot.project.clone(),
@@ -880,6 +884,21 @@ impl FileWorld {
pub fn generated_paths(&self) -> impl Iterator<Item = &Path> {
self.live_paths.iter().map(PathBuf::as_path)
}
/// Bind private storage to a host-authorized mutable project path. Resource
/// resolution, observations and source names still use the project path.
pub fn stage_generated(&mut self, path: &Path, storage: PathBuf) -> Result<(), String> {
if !self.live(path)
|| !self.project.as_ref().is_some_and(|p| p.permits_generated(path))
|| self.protected_paths.contains(path)
{
return Err("staged native storage requires a mutable project file".into());
}
self.staged_generated.insert(path.to_owned(), storage);
Ok(())
}
pub fn generated_storage<'a>(&'a self, path: &'a Path) -> &'a Path {
self.staged_generated.get(path).map_or(path, PathBuf::as_path)
}
fn project_paths(&self) -> BTreeSet<PathBuf> {
self.live_paths
.union(&self.protected_paths)
@@ -905,7 +924,11 @@ impl FileWorld {
let location = project.locate(path, &self.project_paths())?;
let result = if location.kind == Some(project::NodeKind::File) {
if self.live_paths.contains(&location.path) {
Self::existing(&location.path)
if let Some(storage) = self.staged_generated.get(&location.path) {
Self::existing(storage).map(|found| found.map(|_| location.path))
} else {
Self::existing(&location.path)
}
} else {
Ok(Some(location.path))
}
@@ -1111,7 +1134,7 @@ impl FileWorld {
));
}
}
let value = fs::read(&path)
let value = fs::read(self.generated_storage(&path))
.map(|data| SnapshotFile {
version: ResourceVersion {
path: path.clone(),
@@ -1530,7 +1553,7 @@ impl FileWorld {
}
let time = match project_time {
Some(time) => Some(time),
None => fs::metadata(path)
None => fs::metadata(self.generated_storage(path))
.and_then(|metadata| metadata.modified())
.ok()
.map(FileModificationTime::from_system_time)