Refactor Reconciler tests and update path handling logic

- Updated test descriptions in `diff.spec.lua` and `diff.stress.spec.lua` to reflect changes in behavior regarding duplicate-named children in both real and virtual DOM contexts.
- Adjusted assertions to ensure that duplicate-named children are correctly removed or added based on the new matching logic.
- Refactored `hydrate.lua` and `matching.lua` to streamline the matching process by removing unnecessary parameters, enhancing clarity and maintainability.
- Updated metadata references in various test files to include the `.model.json5` extension for consistency in path handling.

These changes improve the accuracy of reconciliation tests and enhance the overall robustness of the Reconciler's path handling logic.
This commit is contained in:
Joe 2026-02-17 04:46:54 -06:00
parent 3ad3c21c01
commit bb9d241253
18 changed files with 129 additions and 94 deletions

View file

@ -628,6 +628,17 @@ pub fn syncback_project<'sync>(
}
}
// Project children with $path are expected in the old DOM (loaded
// from their own path) AND may also appear as filesystem children of
// the parent's scanned directory. Exclude them from duplicate
// detection so the project child loop below can match them.
let project_path_child_names: HashSet<String> = node
.children
.iter()
.filter(|(_, child_node)| child_node.path.is_some())
.map(|(name, _)| name.to_lowercase())
.collect();
let mut old_duplicate_names: HashSet<String> = HashSet::new();
{
let mut seen: HashSet<String> = HashSet::new();
@ -636,6 +647,9 @@ pub fn syncback_project<'sync>(
.get_old_instance(*child_ref)
.expect("all children of Instances should be in old DOM");
let lower = child.name().to_lowercase();
if project_path_child_names.contains(&lower) {
continue;
}
if !seen.insert(lower.clone()) {
old_duplicate_names.insert(lower);
}