Enhance audit documentation and improve Ref property handling

- Added a detailed section in the audit documentation outlining the sync system layout for both CLI syncback and two-way sync pipelines, including file mappings and processing steps.
- Updated `init.meta.json5` to include the `Rojo_Ref_PrimaryPart` attribute for better reference tracking.
- Improved the `ChangeProcessor` to populate the `RefPathIndex` from existing meta/model files at startup, ensuring accurate handling of pre-existing `Rojo_Ref_*` attributes during renames.
- Refactored the `remove_file` method in `RefPathIndex` to `remove_all_for_file`, enhancing the re-indexing process after attribute removals.
- Added tests to verify the correct behavior of the `RefPathIndex` and ensure robustness against edge cases.

These changes improve the clarity of the audit process and enhance the reliability of reference path management in the synchronization system.
This commit is contained in:
Joe 2026-02-14 15:55:24 -06:00
parent c3efb0e560
commit e617e8fcda
9 changed files with 638 additions and 54 deletions

View file

@ -212,9 +212,9 @@ impl RefPathIndex {
}
/// Remove `meta_file` from ALL entries in the index.
/// Used when a Rojo_Ref_* attribute is removed and we don't know the old
/// path value.
pub fn remove_file(&mut self, meta_file: &Path, _attr_name: &str) {
/// Used when re-indexing a file: first remove all old entries, then
/// re-add entries for the attributes that remain.
pub fn remove_all_for_file(&mut self, meta_file: &Path) {
let mut empty_keys = Vec::new();
for (path, files) in &mut self.paths_to_files {
files.remove(meta_file);
@ -516,17 +516,39 @@ mod tests {
}
#[test]
fn ref_path_index_remove_file() {
fn ref_path_index_remove_all_for_file() {
let mut index = RefPathIndex::new();
let file = Path::new("/a.meta.json5");
index.add("Workspace/Part1", file);
index.add("Workspace/Part2", file);
index.remove_file(file, "Rojo_Ref_PrimaryPart");
index.remove_all_for_file(file);
assert!(index.find_by_prefix("Workspace/Part1").is_empty());
assert!(index.find_by_prefix("Workspace/Part2").is_empty());
}
#[test]
fn ref_path_index_remove_all_for_file_preserves_other_files() {
let mut index = RefPathIndex::new();
let file_a = Path::new("/a.meta.json5");
let file_b = Path::new("/b.meta.json5");
// Both files share the same ref path entry
index.add("Workspace/Part1", file_a);
index.add("Workspace/Part1", file_b);
// file_a also has another ref
index.add("Workspace/Part2", file_a);
index.remove_all_for_file(file_a);
// file_b's entry should be preserved
let results = index.find_by_prefix("Workspace/Part1");
assert_eq!(results.len(), 1);
assert_eq!(results[0], PathBuf::from("/b.meta.json5"));
// file_a's other entry should be gone
assert!(index.find_by_prefix("Workspace/Part2").is_empty());
}
#[test]
fn ref_path_index_update_prefix() {
let mut index = RefPathIndex::new();