On p17, I ran a first "pc-switcher sync fleksi". Now, here on fleksi: janfr@Fleksi:~$…
- User
On p17, I ran a first "pc-switcher sync fleksi". Now, here on fleksi:
janfr@Fleksi:~$ pc-switcher sync p17 --dry-run A new stable version of pc-switcher is available: 0.3.0 -> 0.3.1 Upgrade now? [y/n] (n): y Updating pc-switcher to 0.3.1... Updated. Restarting with the new version... Target config matches source, skipping config sync. Connection: disconnected ⚠ 1 Step 10/10 — Post-sync snapshots folder_sync ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100%
╭──────────────────────────────────────────────────────────── Recent Logs ────────────────────────────────────────────────────────────╮ │ 15:50:46 [INFO] [orchestrator] (target) Syncing configuration to target │ │ 15:50:46 [INFO] [orchestrator] (target) Configuration sync completed │ │ 15:50:46 [INFO] [orchestrator] (source) Starting sync operations │ │ 15:50:46 [INFO] [folder_sync] (source) [dry-run] Syncing '/home/janfr' → 'p17' │ │ 15:51:19 [INFO] [folder_sync] (source) [dry-run] Completed sync of '/home/janfr': 6244 files transferred, 557587395 bytes, 2225 │ │ deletions │ │ 15:51:19 [INFO] [orchestrator] (source) Job folder_sync completed successfully │ │ 15:51:19 [INFO] [orchestrator] (source) Creating post-sync snapshots │ │ 15:51:19 [INFO] [btrfs_snapshots] (source) Creating post-sync snapshots │ │ 15:51:19 [INFO] [btrfs_snapshots] (source) Completed post-sync snapshots │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯⚠ 1 warning(s) this run: 15:50:46 [WARNING] [orchestrator] (source) Target Last Synced with a Different Machine — skipping confirmation in dry-run mode Run pc-switcher logs for the full log.
- User
On p17, I ran a first "pc-switcher sync fleksi". Now, here on fleksi syncing back. Why warning?
janfr@Fleksi:~$ pc-switcher sync p17 --dry-run A new stable version of pc-switcher is available: 0.3.0 -> 0.3.1 Upgrade now? [y/n] (n): y Updating pc-switcher to 0.3.1... Updated. Restarting with the new version... Target config matches source, skipping config sync. Connection: disconnected ⚠ 1 Step 10/10 — Post-sync snapshots folder_sync ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% ╭──────────────────────────────────────────────────────────── Recent Logs ────────────────────────────────────────────────────────────╮ │ 15:50:46 [INFO] [orchestrator] (target) Syncing configuration to target │ │ 15:50:46 [INFO] [orchestrator] (target) Configuration sync completed │ │ 15:50:46 [INFO] [orchestrator] (source) Starting sync operations │ │ 15:50:46 [INFO] [folder_sync] (source) [dry-run] Syncing '/home/janfr' → 'p17' │ │ 15:51:19 [INFO] [folder_sync] (source) [dry-run] Completed sync of '/home/janfr': 6244 files transferred, 557587395 bytes, 2225 │ │ deletions │ │ 15:51:19 [INFO] [orchestrator] (source) Job folder_sync completed successfully │ │ 15:51:19 [INFO] [orchestrator] (source) Creating post-sync snapshots │ │ 15:51:19 [INFO] [btrfs_snapshots] (source) Creating post-sync snapshots │ │ 15:51:19 [INFO] [btrfs_snapshots] (source) Completed post-sync snapshots │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Assistant· claude-opus-4-8
Let me look at the code behind that warning to explain it accurately.
Assistant· claude-opus-4-8
Now let me trace how source/target hostnames and peers are recorded, because the scenario should have been suppressed as clean.
Assistant· claude-opus-4-8
Confirmed the mechanism. Let me verify by reading the actual recorded peer values on both machines.
Assistant· claude-opus-4-8
Found it. This is a false positive caused by a case-sensitivity bug in the topology check, not a real out-of-order sync.
What happened
The two machines recorded each other's names with different casing:
- User
yes, both. Should have exactly the same way for getting the source hsotname and the target hostname. New branch and pr
Assistant· claude-opus-4-8
Let me explore the full picture before implementing. Let me create the branch and examine the relevant code.
Assistant· claude-opus-4-8
folder_sync.py:452usestarget_hostnameas the rsync destination host — so it must stay the SSH-connectable CLI arg. That confirms the design: keep_target_hostnameas the connection address, and add a separate canonical hostname (queried over SSH the same way the source gets its own) used only for history recording and the topology comparison. Let me look at the existing tests.Assistant· claude-opus-4-8
Now I have the full picture. Let me implement. Starting with
lock.py:Assistant· claude-opus-4-8
Now
sync_history.py— add the case-insensitive comparison helper:Assistant· claude-opus-4-8
Now the orchestrator. First the imports and
__init__:Assistant· claude-opus-4-8
Now
__init__— add the canonical hostname field. Let me update the field and its docstring/comment:Assistant· claude-opus-4-8
Now
_establish_connection— resolve the canonical hostname after the executor is ready:Assistant· claude-opus-4-8
Now update
_check_out_of_orderto use the canonical hostname and case-insensitive comparison:Assistant· claude-opus-4-8
Now
_update_sync_history— record the canonical hostname as the peer:Assistant· claude-opus-4-8
Let me run the type checker and the existing topology tests:
Assistant· claude-opus-4-8
All existing tests pass. Now let me add regression tests. First the
hostnames_equalunit tests intest_sync_history.py:Assistant· claude-opus-4-8
The diagnostic is stale (the append landed). Now the orchestrator regression tests. Let me add them to
test_consecutive_sync.py:Assistant· claude-opus-4-8
Let me add a test that
_update_sync_historyrecords the resolved canonical hostname, not the CLI arg:Assistant· claude-opus-4-8
All 76 pass (+13 new). Now full lint/format/typecheck and the broader suite:
Assistant· claude-opus-4-8
Full suite green. Let me check whether ADR-015 or docs describe the peer/hostname mechanism and need updating:
Assistant· claude-opus-4-8
The ADR needs a note on hostname acquisition/comparison. Per project rules I must read ADR-001 first for ADR-editing instructions:
Assistant· claude-opus-4-8
Line 30-31 is now incomplete — the target's hostname for history/topology is resolved from the target itself. Let me correct it:
Assistant· claude-opus-4-8
I'll append a brief refinement to ADR-015 (consistent with its existing "Refinement" pattern — additive, not editing prior text):
Assistant· claude-opus-4-8
The architecture diagram mentions
RemoteExecutor.get_hostname(). Let me check if that already exists — I may be duplicating:Assistant· claude-opus-4-8
No existing implementation — the diagram was aspirational. My
get_hostname_command()mirrors the existingget_record_role_command()pattern. Let me review the full diff:Assistant· claude-opus-4-8
The diff is complete and the regression test genuinely fails on old code (old
target_peer != src→"fleksi" != "Fleksi"→ W2 fires). Let me commit and open a draft PR:Assistant· claude-opus-4-8
Done. Draft PR: https://github.com/flaksit/pc-switcher/pull/188
Summary
The warning was a false positive — p17 really did last sync with this machine. It's safe; your dry-run correctly proceeded.
Root cause: the two ends recorded each other under different-cased names because they acquired hostnames two different ways:
- p17 stored its peer as the CLI arg you typed (
sync fleksi→"fleksi") - this machine's real hostname is
Fleksi - the topology check did exact
==, so"fleksi" != "Fleksi"→ W2 warning
- p17 stored its peer as the CLI arg you typed (