Background
`test_web_hot_reload.py` has 17 failures on Windows — the entire file. The recurring symptom is the config signature (`(path, mtime_ns)` tuple) not changing across two writes that should have updated it.
Symptoms
```
FAILED TestSignature::test_signature_changes_on_config_write
AssertionError: assert (('C:\Users\...\config.json', 1777609014603566900), ...)
!= (('C:\Users\...\config.json', 1777609014603566900), ...)
FAILED test_concurrent_patches_are_serialised_by_lock
assert 10 in (42, 99)
FAILED test_reload_if_stale_cas_yields_to_concurrent_writer_bump
AssertionError: writer's signature was overwritten by the reader's tail
```
The `mtime_ns` value is identical across the two snapshots — meaning the second `write_text` didn't bump the modification time. Several possibilities:
- NTFS lazy timestamp: NTFS may defer mtime updates briefly; `os.fsync` doesn't always flush metadata immediately on Windows.
- Test timing: writes in the same millisecond report the same `mtime_ns` (Windows mtime resolution is finer than that, but the OS may round to FILE_ATTRIBUTE_TIMESTAMP granularity).
- Cache layer: `config_signature` might be cached at a level that doesn't invalidate on Windows (e.g., `stat` result caching).
Affected files
- `packages/memtomem/tests/test_web_hot_reload.py` — 17 failures (entire file's relevant tests)
- Possibly: `test_storage.py` (1 failure), other mtime-sensitive tests
Investigation needed
- Confirm whether the issue is (a) production code's mtime read missing a flush, (b) test timing assumption (writes-too-fast-to-distinguish), or (c) Windows file-attribute cache not invalidating.
- If (a): fix `config_signature` to read mtime via `os.stat(path)` after `fsync` in the writer, or via `Path.stat()` with `follow_symlinks=False` consistently.
- If (b): tests should sleep `time.sleep(0.01)` between writes, or use a monotonic counter instead of mtime for tests.
- If (c): may need `FlushFileBuffers` (via `ctypes` to `kernel32`) on Windows, but that's a heavy hammer.
Refs
🤖 Generated with Claude Code
Background
`test_web_hot_reload.py` has 17 failures on Windows — the entire file. The recurring symptom is the config signature (`(path, mtime_ns)` tuple) not changing across two writes that should have updated it.
Symptoms
```
FAILED TestSignature::test_signature_changes_on_config_write
AssertionError: assert (('C:\Users\...\config.json', 1777609014603566900), ...)
!= (('C:\Users\...\config.json', 1777609014603566900), ...)
FAILED test_concurrent_patches_are_serialised_by_lock
assert 10 in (42, 99)
FAILED test_reload_if_stale_cas_yields_to_concurrent_writer_bump
AssertionError: writer's signature was overwritten by the reader's tail
```
The `mtime_ns` value is identical across the two snapshots — meaning the second `write_text` didn't bump the modification time. Several possibilities:
Affected files
Investigation needed
Refs
🤖 Generated with Claude Code