Add automatic dedup suffix stripping to enhance syncback functionality

- Introduced a new plan to automatically strip `~N` dedup suffixes from filenames during forward sync, eliminating the need for redundant `.meta.json5` files.
- Implemented the `strip_dedup_suffix()` utility in `dedup_suffix.rs` to handle suffix removal.
- Updated `file_name_for_path()` and `get_dir_middleware()` to utilize the new stripping functionality.
- Modified syncback logic to skip writing meta `name` fields for dedup-only cases, ensuring cleaner instance naming.
- Enhanced existing tests and added new tests to cover the updated dedup behavior, ensuring robustness and correctness.

These changes aim to streamline the handling of deduplicated instances, improving overall system efficiency and clarity in naming conventions.
This commit is contained in:
Joe 2026-02-19 01:15:28 -06:00
parent 17d52e3edf
commit 7d0232c430
19 changed files with 269 additions and 84 deletions

View file

@ -1556,8 +1556,9 @@ impl JobThreadContext {
// Always update the name field when the
// instance name changed, even if the path didn't
// change (e.g. "Foo/Bar" → "Foo|Bar" both slugify
// to "Foo_Bar"). Use deduped_new_name because
// dedup may have appended ~N.
// to "Foo_Bar"). Only slugification requires a
// meta name -- dedup suffixes (~N) are stripped
// automatically by forward sync.
//
// For .model.json5/.model.json files, the name
// field lives INSIDE the model file, not in
@ -1566,7 +1567,7 @@ impl JobThreadContext {
let model_file = overridden_source_path
.as_deref()
.unwrap_or(path.as_path());
if deduped_new_name != *new_name {
if slugified_new_name != *new_name {
self.upsert_model_name_field(
model_file, new_name,
);
@ -1578,7 +1579,7 @@ impl JobThreadContext {
"{}.meta.json5",
effective_meta_base
));
if deduped_new_name != *new_name {
if slugified_new_name != *new_name {
self.upsert_meta_name_field(
&current_meta,
new_name,