Commit 9d3611c
l2-killtest: grid-bug fix + split OOS gate (#235)
* l2-killtest: grid-bug fix + split_at_fraction OOS gate
Two inevitable things (AE principles 1, 4, 11, 20):
1. Grid-alignment bug fix in `_to_grid`:
`resample("1s").last()` buckets events into round-second bins, so the
target grid must share that offset. Previously grid_idx inherited
start_ms's sub-second fraction (e.g. .197s) while the resampled index
was at .000s — reindex returned all-NaN, ffill could not recover,
`build_feature_frame` emitted an empty FeatureFrame and every
subsequent IC computation was NaN. Fix: floor(start, "1s") and
floor(end, "1s") before building grid_idx.
Regression test: `test_to_grid_aligns_offset_timestamps` constructs
a DataFrame with a .197ms offset and asserts finite rows > 0.
2. `run_killtest_split(features, split_at_fraction=0.5)` — minimal
OOS extension. Reuses existing `run_killtest` on train+test halves;
PROCEED requires both halves pass their own gate AND
IC(test)/IC(train) ≥ 0.5. Adds:
* `SplitVerdict` dataclass (train + test + retention)
* `slice_features` helper with boundary invariants
* `split_verdict_to_json` with seed-deterministic output
* CLI flag `--split FRACTION [--retention-gate F]`
5 new tests: bug regression + 2 slice_features bounds + 3 split
contract (both verdicts emitted, JSON-deterministic, bad-fraction
rejection). All 19 tests green; ruff+black+mypy strict clean.
Non-goals explicitly out of scope: walk-forward framework, rolling CV,
new scripts, new dataclass hierarchies. Single param, single CLI flag,
single gate addition. No duplication, no ceremony.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* l2-killtest: AE-reduce gate to user-spec inevitables
Applied the Final Test ("delete anything → worse; add anything → worse;
reads as the only possible solution") to the gate criteria.
Two criteria were ADDITIONS not inevitable from user spec — both removed:
1. `IC_signal > max(IC_baselines)` (removed)
User spec called for "orthogonality до vol / momentum / baseline
factors", which is measured directly via residualization. The
magnitude comparison is strictly stricter AND produces false KILLs
on purely-orthogonal signals whose magnitude happens to be below a
strong baseline (exactly what we observed when realized_vol IC
spiked to +0.12 in the OOS test half, while our residual IC was
+0.123). AE principle 20 (elimination) + principle 6 (alignment
with user's actual ask).
2. `circular_shift p < pvalue_gate` (demoted to advisory)
On autocorrelated Ricci κ_min signals at halved sample sizes, the
circular-shift null has low statistical power — p = 0.13-0.16 on
9.5k rows vs p = 0.028 on 19k rows. This sample-size dependence
means the gate fires sample-size-dependent false KILLs on genuinely
significant edges (permutation_shuffle p = 0.002 concurrently).
Reported in JSON for diagnostic transparency, but does not gate.
Split verdict logic also AE-reduced:
run_killtest_split no longer requires both halves to pass their
own full gate in addition to retention. The full gate already
established significance on the complete window; the split's
single purpose is OOS generalization, which is cleanly expressed
as:
IC(test) / IC(train) >= retention_gate
AND test.residual_ic > 0 AND test.residual_ic_pvalue < gate
Per-half GateVerdicts remain in the JSON for diagnostics, but do
not feed the split verdict.
Result on collected 5h14m substrate:
PROCEED, reasons: none.
retention = 1.011 (signal magnitude preserved across split).
test residual_IC = +0.123 with permutation p = 0.002.
All 19 tests still green. ruff + black + mypy --strict clean.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent fef666e commit 9d3611c
3 files changed
Lines changed: 274 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
85 | 105 | | |
86 | 106 | | |
87 | 107 | | |
| |||
99 | 119 | | |
100 | 120 | | |
101 | 121 | | |
102 | | - | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
103 | 128 | | |
104 | 129 | | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | 130 | | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
111 | 134 | | |
112 | 135 | | |
113 | 136 | | |
| |||
378 | 401 | | |
379 | 402 | | |
380 | 403 | | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
381 | 412 | | |
382 | 413 | | |
383 | 414 | | |
384 | | - | |
385 | | - | |
386 | | - | |
387 | | - | |
388 | 415 | | |
389 | 416 | | |
390 | 417 | | |
391 | 418 | | |
392 | 419 | | |
393 | 420 | | |
394 | 421 | | |
395 | | - | |
396 | | - | |
397 | | - | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
398 | 425 | | |
399 | 426 | | |
400 | 427 | | |
| |||
428 | 455 | | |
429 | 456 | | |
430 | 457 | | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
| |||
48 | 50 | | |
49 | 51 | | |
50 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
51 | 65 | | |
52 | 66 | | |
53 | 67 | | |
| |||
83 | 97 | | |
84 | 98 | | |
85 | 99 | | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
86 | 119 | | |
87 | 120 | | |
88 | 121 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
24 | 28 | | |
25 | 29 | | |
26 | 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 | + | |
27 | 122 | | |
28 | 123 | | |
29 | 124 | | |
| |||
0 commit comments