fix: clamp _epoch_to_iso to representable range; repair regen tests#172
Conversation
Found by /check-and-test (nightly CI). Application fix: - _epoch_to_iso raised ValueError when callers passed sentinel "open" window bounds (e.g. to_ts=10**12 used by the evaluation-overview API as a far-future upper bound) because datetime.fromtimestamp cannot represent year > 9999. The new get_agent_success_evaluation_results_in_window query (added in #168) hit this and 500'd the evaluation overview endpoint on a fresh app. Clamp the input to [0, 253402300799] centrally in _epoch_to_iso so all current and future callers are protected. _shadow_verdicts.py had already worked around this at two call sites with a local _MAX_SAFE_EPOCH_TS clamp; that constant now lives in _base.py and the redundant per-call clamps are removed. Test fix (stale drift from #168): - The force_regenerate runner now captures prior result ids via the targeted get_agent_success_evaluation_result_ids lookup instead of reading full result rows. test_group_evaluation_runner_regen.py still mocked the old method, so the by-id delete asserted the wrong argument (MagicMock tests) or bound a MagicMock into SQL (real-sqlite tests). Seed the new lookup and patch get_extractor_name so the capture query's evaluation_name matches the seeded rows.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
ChangesCentralize epoch clamping in
Fix regen runner test wiring
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@tests/server/services/agent_success_evaluation/test_group_evaluation_runner_regen.py`:
- Around line 132-137: The mock for
storage.get_agent_success_evaluation_result_ids currently uses a static
return_value that returns all seeded IDs regardless of input arguments, which
doesn't match the actual storage layer filtering behavior based on session_id,
evaluation_name, and agent_version. Replace the static return_value with a
side_effect that defines a function to filter and return only the matching
result IDs from prior_results based on the provided arguments, ensuring the test
validates that the runner passes the correct arguments to this method.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: e784cbb0-6b37-47b8-8794-3ef363ea6f25
📒 Files selected for processing (3)
reflexio/server/services/storage/sqlite_storage/_base.pyreflexio/server/services/storage/sqlite_storage/_shadow_verdicts.pytests/server/services/agent_success_evaluation/test_group_evaluation_runner_regen.py
The _make_storage mock returned all seeded result_ids from a static return_value regardless of arguments, so the tests would pass even if the runner wired the wrong (session_id, evaluation_name, agent_version) tuple into get_agent_success_evaluation_result_ids. Replace it with a side_effect that mirrors the storage layer's own identity-tuple filtering. test_force_regenerate_deletes_prior_results now also patches get_extractor_name to "overall_success" (as the SQLite e2e tests already do): without it the runner computes evaluation_name from a MagicMock config, which would never match the seeded row under the now-strict filter. With it, the [42] delete assertion proves the runner passed the matching identity tuple — a stronger check than the original static mock.
|
Re: the Docstring Coverage 77.78% pre-merge warning — the undocumented functions in |
Summary
Found by
/check-and-test(nightly CI). Two related fixes surfaced by the new evaluation-overview query added in #168.Application fix — clamp
_epoch_to_isoto a representable range:_epoch_to_isoraisedValueErrorwhen callers passed sentinel "open" window bounds (e.g.to_ts=10**12, used by the evaluation-overview API as a far-future upper bound) becausedatetime.fromtimestampcannot represent year > 9999.get_agent_success_evaluation_results_in_windowquery (fix: optimize evaluation overview reads #168) hit this and 500'd the evaluation overview endpoint on a fresh app.[0, 253402300799]centrally in_epoch_to_isoso all current and future callers are protected._shadow_verdicts.pyhad already worked around this at two call sites with a local_MAX_SAFE_EPOCH_TSclamp; that constant now lives in_base.pyand the redundant per-call clamps are removed.Test fix — stale drift from #168:
force_regeneraterunner now captures prior result ids via the targetedget_agent_success_evaluation_result_idslookup instead of reading full result rows.test_group_evaluation_runner_regen.pystill mocked the old method, so the by-id delete asserted the wrong argument (MagicMock tests) or bound aMagicMockinto SQL (real-sqlite tests). Seed the new lookup and patchget_extractor_nameso the capture query'sevaluation_namematches the seeded rows.Changes
reflexio/services/storage/sqlite_storage/_base.py— central clamp in_epoch_to_iso; host_MAX_SAFE_EPOCH_TS.reflexio/services/storage/sqlite_storage/_shadow_verdicts.py— drop the now-redundant local clamps.tests/.../test_group_evaluation_runner_regen.py— align mocks with the by-id lookup path.Test Plan
test_group_evaluation_runner_regen.pypasses under both MagicMock and real-sqlite paths.to_tson a fresh app.Provenance
Generated by the nightly AI-driven CI run on 2026-06-18. The enterprise-side submodule bump + companion test changes are in ReflexioAI/reflexio-enterprise#263 — that PR's
open_source/reflexiopointer should be repointed to this PR's mergedmaincommit once it lands.Summary by CodeRabbit
Release Notes
Bug Fixes
Tests