feat(backtest): Tier-1 backtest index + iaf index/list/rank CLI (epic #540 phases 1-2)#543
Merged
Merged
Conversation
Closes the remaining Phase 2 gaps for epic #540: - Backtest.scalar_summary() alias (canonical Phase 1 naming). - SqliteBacktestIndex tracks bundle_mtime_ns + bundle_size (schema v2); is_up_to_date() lets the indexer skip unchanged bundles. - build_index(..., incremental=True) skips up-to-date bundles by default; 'iaf index --rebuild' forces a full reindex. - 4 new tests covering skip, re-ingest on mtime bump, --rebuild, and the scalar_summary alias. - scripts/bench_540_phase2.py: acceptance benchmark. At 12,500 bundles: cold build 86s, incremental 536ms, list top-20 in 8.3ms (12x under the 100ms target), index footprint 2.5 MiB. - examples/storage_layer_demo/: end-to-end walkthrough of write -> index -> list -> rank -> open-with-summary-only, plus inline backtest report.
This was referenced May 11, 2026
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.
Closes the remaining Phase 1 + Phase 2 gaps for epic #540 — promotes scalar summary metrics out of every
.iafbtbundle into a queryable SQLite index, makes the indexer incremental, and ships the CLI to build / query it.What's in this commit
Phase 1 — naming gap
Backtest.scalar_summary() -> BacktestSummaryMetrics— canonical spec alias forget_backtest_summary().Phase 2 — incremental indexing
SqliteBacktestIndexschema bumped to v2 with two new identity columns:bundle_mtime_ns,bundle_size.SqliteBacktestIndex.is_up_to_date(bundle_path, mtime_ns, size)— single-row lookup keyed on the bundle path.build_index(..., incremental=True)(default) skips bundles whose mtime+size match the existing row.iaf index --rebuildforces a full reindex (passesincremental=False).Phase 2 — acceptance benchmark
scripts/bench_540_phase2.pygenerates synthetic bundles and times the hot paths. Measured on a 2024 MacBook Pro:build_index(cold)build_index(incremental, all unchanged)list --sort sharpe_ratio --limit 20list --sort sharpe_ratio(full scan)Index footprint at 12,500 bundles: 2.5 MiB (~0.21 KiB / bundle).
The headline ranking workload (
list --limit 20) returns in 8 ms over 12.5k rows — 12× under the 100 ms acceptance target and constant in bundle count.Storage-layer demo
examples/storage_layer_demo/is an end-to-end walkthrough: write bundles → build index →iaf list/iaf rank→Backtest.open(summary_only=True)→ inline backtest report. Runnable withpython demo.py.Tests
tests/cli/test_index_command.py: incremental skip, re-ingest on mtime bump,--rebuilddisables incremental,scalar_summary()alias parity.Out of scope (Phase 3, follow-up PRs)
BacktestStoreProtocol +LocalDirStore+LocalTieredStore(Tier-2 Parquet datasets + Tier-3 content-addressed chunks) and theFinterionStoreadapter are tracked separately under #540. They will land as a stacked series on top of #537.