Commit c6dd228
committed
fix(ci): address Codex P1 findings — partial-dir retry + empty-ledger regression tests
Two P1 findings surfaced by the Codex reviewer on PR #355.
P1 #2 — partial-dir quarantine on retry (scripts/run_cross_asset_kuramoto_shadow.py):
When a prior run failed after _fail_closed() created run_dir with only
run_log.txt, the next invocation saw _already_written() == False and
fell through to run_dir.mkdir(parents=True, exist_ok=False), raising
FileExistsError and aborting the runner. This blocked clean retries
after any transient failure.
Fix: between _already_written() and mkdir(exist_ok=False), detect
run_dir.exists() — meaning prior attempt left partial evidence —
quarantine-rename it to <name>.incomplete.<YYYYMMDDTHHMMSSZ>, log an
operational_incident (incident_type=incomplete_dir_retry, severity=LOW),
then proceed with mkdir(exist_ok=False) on the now-clean path. The
quarantined dir stays on disk as append-only audit evidence of the
failed attempt.
P1 #1 — empty-ledger guard regression tests (tests/ops/test_codex_p1_regressions.py):
The guard itself landed in commit 2882850 ('fix(ci): guard evaluator
against empty live-ledger') — _compute_live_metrics now returns
empty_metrics when live.empty or 'net_ret' not in live.columns.
Codex is reading an earlier snapshot of the PR. Added three regression
tests pinning the fix:
* test_empty_ledger_returns_zero_bar_metrics_not_keyerror — direct
_compute_live_metrics(pd.DataFrame()) call returns 0-bar dict, no
KeyError.
* test_schema_only_ledger_returns_zero_bar_metrics — DataFrame with
the right columns but zero rows also returns 0-bar cleanly (the
n==0 branch).
* test_evaluator_cli_exits_0_with_missing_paper_equity — end-to-end
CLI with --paper-equity pointing at a tmp-path missing file must
exit 0 (BUILDING_SAMPLE / CONTINUE_SHADOW via the outer gate).
Plus two tests for P1 #2:
* test_runner_quarantines_partial_daily_dir — monkeypatches DAILY_ROOT/
SHADOW_DIR/INCIDENTS into tmp_path, simulates the partial-dir
scenario, confirms rename + fresh mkdir path without touching
real evidence.
* test_runner_retry_logic_matches_source_flow — meta-regression that
asserts the runner source contains the three markers of the fix
('incomplete_dir_retry', '.incomplete.', 'run_dir.rename(quarantine)'),
catching accidental reverts.
All 5 new tests pass locally. Full suite now 83 passed + 1 xfail (OBS-1
documented). mypy --strict, ruff, black all clean on changed files.
SOURCE_HASHES.json regenerated so the hashes-frozen test stays
consistent with the runner byte-change.
No signal logic touched. No frozen parameter modified. No evidence CSV
edited. combo_v1 closure enforcement intact.1 parent 56c710a commit c6dd228
3 files changed
Lines changed: 183 additions & 3 deletions
File tree
- results/cross_asset_kuramoto/offline_robustness
- scripts
- tests/ops
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
316 | 316 | | |
317 | 317 | | |
318 | 318 | | |
319 | | - | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
320 | 344 | | |
321 | 345 | | |
322 | 346 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
0 commit comments