Merge pull request #5194 — de-flake test_skills_stats_cache (#5178)

Release v0.51.742 — de-flake test_skills_stats_cache (#5178)
This commit is contained in:
nesquena-hermes authored and GitHub committed 2026-06-28 23:11:58 -07:00
commit 3b120e70cc
2 files changed
+12

No files matched your search

+1
View File
@@ -22,6 +22,7 @@
### Changed
- **Internal: de-flaked `test_skills_stats_cache`** — the test verifies that adding a skill bumps the skills-dir mtime so the cheap per-call probe recomputes counts, but two writes inside the same coarse filesystem mtime tick could leave the dir mtime byte-identical, making it fail intermittently under full-suite ordering (it passed in isolation, so it added noise to unrelated PRs' gate runs). The test now forces the skills-dir mtime strictly forward before the recompute assertion, so it exercises a genuine mtime change without racing filesystem granularity. Assertion unchanged; test-only. (#5178)
- **Internal: added a runtime-journal ↔ settled-hydration parity regression test** for anchor activity scenes. The test drives a real `RunJournalWriter` through a full turn (token / reasoning / tool / tool_complete) and asserts that `_run_journal_live_snapshot(...).anchor_activity_scene` and the persisted-then-`_hydrate_anchor_activity_scenes(...)` settled scene expose identical visible semantics — locking in the invariant that a live-streaming turn and a reloaded settled turn render the same anchor activity. Test-only; no behavior change. Thanks @franksong2702. (#5183)
- **Internal: CI test suite now runs across 5 shards per Python version (up from 3) for faster feedback.** Two latent test-isolation leaks that a finer partition would have exposed were fixed at the root so every shard passes independently regardless of execution order: (1) `tests/test_auth_session_persistence.py` now binds `api.auth`'s `STATE_DIR`/`_SESSIONS_FILE`/`_LOGIN_ATTEMPTS_FILE` to its own temp state in `setUp` and restores them in `tearDown` (previously it relied on a sibling reload test having rebound them, so a shard without that test read the wrong key dir and the warning assertion failed); (2) `tests/test_request_diagnostics_cache.py` pins the session-list cache source stamp via an autouse fixture (matching `test_session_sidebar_cache.py`) so a leaked `state.db` WAL sidecar can't cause a spurious cache-miss. Verified all shards green under 3-, 4-, and 5-way partitions. CI infra + test-harness only; no application behavior change. (internal)
+11
View File
@@ -144,6 +144,17 @@ def test_skills_stats_cache(tmp_path):
# Adding a skill bumps the skills-dir mtime; the cheap probe detects it on
# the very next call and the counts update immediately (no stale TTL window).
_write_skill(tmp_path, "beta")
# Guarantee the skills-dir mtime is STRICTLY newer than the cached probe value.
# A real FS-backed skill-add always advances the dir mtime, but two writes inside
# the same coarse mtime tick can leave it byte-identical under full-suite timing —
# the source of this test's intermittent flake (order-dependent: passes in
# isolation, fails ~intermittently under full-suite ordering). Forcing it forward
# keeps the assertion honest (the probe must recompute on a genuine mtime change)
# without racing the filesystem's mtime granularity.
import os as _os, time as _time
_skills_dir = tmp_path / "skills"
_future = _time.time() + 5
_os.utime(_skills_dir, (_future, _future))
enabled, compat = profiles._get_profile_skills_stats(tmp_path)
assert enabled == 2 and compat == 2