Skip to content

fix(scripts): compare the bundle by bytes, not a timestamp cache - #17

Merged
Atri10 merged 1 commit into
mainfrom
fix/sync-engine-byte-compare
Oct 19, 2026
Merged

Atri10 merged 1 commit into
mainfrom
fix/sync-engine-byte-compare

Conversation

@Atri10

@Atri10 Atri10 commented Oct 19, 2026

Copy link
Copy Markdown
Owner

The main-branch Windows run failed one test after the merge: test_sync_rewrites_a_stale_bundle_and_drops_orphans saw stale in the bundle: a.py immediately after sync() had rewritten it.

Root cause

filecmp.cmp(f1, f2, shallow=False) caches its verdict keyed on (type, size, int(st_mtime)). Whole-second mtimes mean a drift check that follows a same-second rewrite can reuse the pre-write False:

before rewrite: False
after rewrite: filecmp says False | bytes equal: True

The Windows runner is slow enough that setUp, sync, and drift share one second; the faster local runs usually crossed a second boundary, which is why this flaked only in CI.

Fix

  • sync_engine.same() compares read_bytes() directly; drift() and sync() use it. No more metadata cache.
  • Regression test forces identical mtimes with os.utime and asserts stale → synced → clean, so the scenario is deterministic on every platform.

Verification

  • python3 scripts/run_tests.py — 742 tests, 100% branch coverage
  • python3 scripts/sync_engine.py --check — in sync (byte comparison)
  • python3 scripts/validate_skills.py — clean
  • python3 scripts/lint-prompt-injection.py skills/ — clean

This lands before v2.0.3 is tagged, so the release covers all three Windows failures.

filecmp.cmp(shallow=False) keys its cached verdict on int(st_mtime), so
a drift check that followed a same-second sync returned the pre-write
answer. The Windows runner hit this: test_sync_rewrites_a_stale_bundle
_and_drops_orphans saw 'stale in the bundle: a.py' right after sync()
had rewritten it.

sync_engine.same() now compares read_bytes() directly, and a regression
test forces identical mtimes with os.utime to pin the same-second case.
@Atri10
Atri10 merged commit 03d3c97 into main Oct 19, 2026
5 checks passed
@Atri10
Atri10 deleted the fix/sync-engine-byte-compare branch October 19, 2026 11:33
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