test(decay): deflake reinforced-memory guard against coarse clocks - #190
Merged
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
The test simulated reinforcement by setting last_access = now_ts(), then asserted the next decay pass leaves stability bit-identical (1e-9). On hosts with coarse clock resolution (observed on Windows: consecutive time.time() calls can return the same value), last_access can equal the just-written last_decay anchor, so the strict 'last_access > anchor' guard misses and the pass legitimately decays one tick's interval (~2.1e-9 stability drift) — a race, not the compounding regression this test pins. Set last_access one second past the pass anchor so the guard condition holds deterministically on every host, and extend coverage to 50 rapid passes to pin the guard, not just the first one after the update. Reproduced: full-suite runs failed this test intermittently (stability drift 2.13e-9 vs 1e-9 threshold) while it passed in isolation; 20/20 same-tick stress trials now stable across 8 consecutive test runs.
Coding-Dev-Tools
force-pushed
the
fix/decay-test-timestamp-race
branch
from
September 3, 2026 14:27
f07c93f to
12f6bf1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
tests/test_decay_idempotent.py::test_reinforced_memory_is_not_decayed_that_intervalfailed intermittently in full-suite runs on this Windows host:It always passed in isolation.
Root cause
The test simulated reinforcement with
last_access = now_ts()immediately after a decay pass had writtenlast_decay = now_ts()as its anchor. On hosts with coarse clock resolution (consecutivetime.time()calls can return the same value — observed on Windows),last_access == last_decay, so the production guarddoes not fire, and the pass legitimately decays one clock tick's interval. At a 7-day half-life, one ~1 ms tick decays stability by ~2.1e-9 — just over the test's
1e-9bit-identity threshold. This is a test race against wall-clock granularity, not a recurrence of the compounding-decay regression the test exists to pin.Fix (test-only)
last_access = now + 1.0(one second past the pass anchor) so the guard condition holds deterministically on every host, regardless of clock resolution.No production code changed. The strict
>guard is correct: withlast_access == anchoron a first pass (last_decay IS NULL, anchor derived fromlast_access), the 10-day interval must decay; changing it to>=would break first-pass decay.Verification
tests/test_decay_idempotent.pypasses 8/8 consecutive runs (previously flaked ~1 in 3 full-suite runs).4503 passed, 39 skipped, ruff clean, pyright 0 errors, all eval gates green.