r/devops • • 16d ago

Tools I built an open-source tool to solve polyrepo config drift without clobbering local overrides

Hey r/devops!

If you maintain multiple repositories (microservices, polyrepos, or SDKs), you probably know the pain of keeping shared configuration files in sync:

  • .github/workflows/*.yml
  • .editorconfig
  • Cargo.toml / package.json

Existing file-copying bots usually clobber legitimate repo-specific overrides.

I built driftsync, an open-source CLI engine in Rust that solves this using stateful 3-way structural merging:

  • Tracks baseline ancestors in .driftsync.lock
  • Structural merging for TOML (via toml_edit, preserving comments and formatting), JSON, and YAML blocks
  • Preserves local customizations while pulling upstream updates
  • Git automation: checks out branches, commits per repo, and opens PRs
  • Secret scanner to prevent accidental token leaks during template sync

You can install it directly via Cargo: cargo install driftsync

GitHub: https://github.com/liqttt/driftsync Crates.io: https://crates.io/crates/driftsync

Feedback, critique, and feature suggestions are very welcome!

0 Upvotes

4 comments sorted by

1

u/MongooseWonderful198 15d ago

In evaluate_file, a missing target hits (_, None) => Create before the strategy check. That includes a file recorded in .driftsync.lock that someone deliberately deleted locally, even with KeepLocal. With the file still mapped in the manifest, apply_workspace(..., write=true) recreates it from upstream.

If local deletion should count as an override, (Some(base), None) needs a separate decision from a file that never existed, such as preserving the deletion or reporting a conflict. This is from reading the source; I haven't run the CLI.

1

u/Many_Location3380 13d ago

You hit the nail right on the head. Thank you so much for actually digging into the source code and spotting that!

That (_, None) => Create match was indeed a blind spot that bypassed the strategy check and caused apply --write to resurrect intentionally deleted files, even under KeepLocal.

We just shipped a fix based on your exact suggestion in commit 7f3ea36 (documented as ADR-006 in DECISIONS.md and updated in SPEC.md):

Really appreciate this kind of thorough, high-signal code review. Huge thanks!

1

u/Steel_half2 13d ago

Does the lock file actually distinguish a tracked deletion from a file that just never existed?

1

u/Many_Location3380 13d ago

That's an excellent question, and to be completely honest: it didn't until today.

Previously, the evaluation engine collapsed both cases under (_, None), treating any missing target file as MissingInTarget and scheduling a Create. That meant if a developer intentionally deleted a tracked file in their local repo, running driftsync apply would resurrect it from upstream.

Following your question and u/MongooseWonderful198's breakdown of the source, we just pushed a fix in commit 7f3ea36:

Now, .driftsync.lock explicitly differentiates them:

Thanks for asking this — it directly helped close a real architectural blind spot!