Skip to content

cleanup(tcfs-sync): dead-code + DRY in the conflict/reconcile chokepoints (pre .git-aware-resolution)#512

Draft
Jesssullivan wants to merge 1 commit into
mainfrom
cleanup/tcfs-sync-conflict-dead-dry
Draft

cleanup(tcfs-sync): dead-code + DRY in the conflict/reconcile chokepoints (pre .git-aware-resolution)#512
Jesssullivan wants to merge 1 commit into
mainfrom
cleanup/tcfs-sync-conflict-dead-dry

Conversation

@Jesssullivan

Copy link
Copy Markdown
Owner

What

A small, behavior-preserving dead-code + DRY cleanup of the conflict-resolution / reconcile chokepoints in crates/tcfs-sync, prepping them for the (separate, later) .git-aware conflict-resolution feature. No sync/conflict behavior changes.

Items (each behavior-preserving)

  1. reconcile.rs classify_path — delete stale dead comment block. Removed the trailing comment after the (None, None, None) match arm describing a "Local exists, not remote, but was tracked" case that is already handled by the (Some, None, Some) arm above. Comment-only; no logic change.

  2. reconcile.rs list_remote_index — use DIR_MARKER_SUFFIX const. Replaced the literal "/.tcfs_dir" with the existing const DIR_MARKER_SUFFIX: &str = "/.tcfs_dir" (byte-identical value, already used in list_remote_empty_dirs). Value-identical.

  3. conflict.rs compare_clocks — collapse two identical Conflict arms. The Some(Ordering::Equal) and None arms built byte-identical ConflictInfo; merged into one Some(Ordering::Equal) | None => arm with a single now / unwrap_or_default(). Both inputs still produce the same SyncOutcome::Conflict with the same ConflictInfo. Logically identical.

  4. reconcile.rs — extract the shared outcome -> ReconcileAction tail. The four-arm match mapping SyncOutcome to ReconcileAction was byte-identical in compare_both_exist and compare_both_exist_symlink. Extracted into one private helper and called from both sites. Pure code motion, zero behavior change.

    Helper signature:

    fn outcome_to_action(
        outcome: crate::conflict::SyncOutcome,
        rel_path: &str,
        local_path: &Path,
        remote_entry: &RemoteIndexEntry,
    ) -> ReconcileAction
  5. git_safety.rs — delete dead pub fn restore_git_from_bundle. grep -rn restore_git_from_bundle crates/ tests/ showed zero callers; it is superseded by restore_git_bundle_into (the fn actually used by tcfs-cli and engine.rs). Removed.

Deliberately excluded (rejected as unsafe — left exactly as-is)

These are behavior-changing / feature-PR territory and were intentionally not touched:

  • reconcile.rs Conflict arm / mark_conflict swap (behavior-changing).
  • conflict.rs (true, true) => None (needed for match exhaustiveness).
  • AutoResolver / ConflictResolver / Resolution variants / compare_clocks signature / partial_cmp_vc / is_concurrent / chunk_hashes / is_legacy (all live, incl. integration tests).
  • reconcile.rs UpToDate-on-hash-failure policy + the SystemTime double-compute.
  • The refs/heads/*.lock literal-not-glob in git_safety.rs (left for the feature PR).

Why now

These are the chokepoints the upcoming .git-aware conflict-resolution feature will modify. Clearing dead code and the duplicated outcome -> action mapping first keeps the two reconcile paths (regular file + symlink) in lockstep and shrinks the feature PR's blast radius. See the G5-git-5 CONCURRENT-WRITE CORRUPTION gap in docs/ops/repo-roam-test-plan-2026-06-08.md, which is expected to fail until conflict resolution is made .git-aware.

Validation (full local CI gate)

  • cargo fmt --all -- --check — clean (exit 0).
  • cargo clippy --workspace --all-targetszero warnings in tcfs-sync; the only workspace warnings are 2 pre-existing needless_borrow in crates/tcfsd/src/grpc.rs (lines 1442, 1876), confirmed identical on origin/main and unrelated to this diff.
  • cargo test -p tcfs-sync — 324 passed, 0 failed.
  • cargo test -p tcfsd — 58 passed, 0 failed (run because conflict.rs is consumed by tcfsd).

…ints

Behavior-preserving cleanup of the conflict-resolution chokepoints ahead of
the (separate) .git-aware conflict-resolution feature. No sync/conflict
behavior changes.

- reconcile.rs classify_path: delete the stale dead comment block trailing the
  match (the case it describes is already handled by the (Some, None, Some)
  arm). Comment-only.
- reconcile.rs list_remote_index: use the existing DIR_MARKER_SUFFIX const
  instead of the byte-identical literal "/.tcfs_dir". Value-identical.
- conflict.rs compare_clocks: collapse the Some(Ordering::Equal) and None arms
  into one Some(Ordering::Equal) | None arm; their ConflictInfo construction was
  byte-identical, so both still produce the same Conflict outcome.
- reconcile.rs: extract the identical outcome -> ReconcileAction tail shared by
  compare_both_exist and compare_both_exist_symlink into one private helper
  outcome_to_action(). Pure code motion.
- git_safety.rs: delete the dead pub fn restore_git_from_bundle (zero callers;
  superseded by restore_git_bundle_into).

Deliberately excludes the rejected-unsafe items (the Conflict-arm/mark_conflict
swap, the (true,true)=>None exhaustiveness arm, the UpToDate-on-hash-failure
policy, and the refs/heads/*.lock literal) — those are feature-PR territory.

Refs the G5-git-5 concurrent-write corruption gap in
docs/ops/repo-roam-test-plan-2026-06-08.md.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant