feat(regime): wire weekly substrate handler to fill the drawdown block (PR 5)#179
Merged
Merged
Conversation
…k (PR 5)
PR 5 of the drawdown-regime arc — closes a sequencing gap: PR 1 added
the optional drawdown_block hook to build_regime_substrate but nothing
filled it weekly, so the substrate the macro agent reads (regime/
latest.json) was still drawdown-less. This wires the weekly handler so
the brief/macro-agent PRs have data to consume. Additive, S3-contract
-safe; the daily acting path (PR 2) is unchanged. Plan §4.1; ROADMAP
config #230.
- regime/drawdown.py: block_from_history() — the forensic weekly view.
Replays the full SPY series through step() for the hysteresis-correct
current tier (NOT seed_state's cold-start shortcut), reproducible from
the price cache like the HMM refit. Excess leg = point-in-time
NAV-vs-SPY (NAV is executor-produced + short; its hysteresis history
is not reproducible here — point-in-time is the honest forensic
surface). Returns the daily-artifact spy/excess shape so the
substrate `drawdown` key is uniform weekly vs daily; None ⇒ caller
omits the key.
- regime/handler.py produce_regime_substrate: best-effort assemble
drawdown_block from _read_parquet_close("SPY") + read_eod_pnl_nav,
honour as_of truncation (excess live-only — point-in-time eod_pnl is
not reproducible for an as_of backfill), pass to build_regime
_substrate. A failure omits the key (substrate still written).
- tests: +4 block_from_history (hysteresis replay vs seed_state, still
-in-drawdown, excess point-in-time, empty→None) + 2 handler (weekly
block assembled with the seeded cache; substrate survives a block
-assembly failure with the key omitted).
327 regime/substrate/handler/backfill tests pass, zero failures.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
What
PR 5 of the drawdown-regime arc — closes a sequencing gap I owe a note on: PR #176 added the optional
drawdown_blockhook tobuild_regime_substrate, but nothing filled it weekly, so the substrate the macro agent reads (regime/latest.json) was still drawdown-less. This wires the weekly handler so the upcoming brief/macro-agent + dashboard PRs have data to consume. Additive, S3-contract-safe; the daily acting path (PR #177) is unchanged. Plan §4.1; ROADMAP alpha-engine-config #230.Changes
regime/drawdown.py—block_from_history(): the forensic weekly view. Replays the full SPY series throughstep()for the hysteresis-correct current tier (notseed_state's cold-start shortcut), reproducible from the price cache exactly like the HMM refit-from-history. Excess leg = point-in-time NAV-vs-SPY (NAV is executor-produced + short; its hysteresis history isn't reproducible here — point-in-time is the honest forensic surface). Returns the samespy/excessshape as the daily artifact (uniformdrawdownkey weekly vs daily);None⇒ caller omits the key.regime/handler.pyproduce_regime_substrate— best-effort assembledrawdown_blockfrom_read_parquet_close("SPY")+read_eod_pnl_nav, honouras_oftruncation (excess live-only — point-in-time eod_pnl isn't reproducible for anas_ofbackfill), pass tobuild_regime_substrate. A failure omits the key; the substrate is still written.block_from_history(hysteresis replay distinct fromseed_state, still-in-drawdown, excess point-in-time, empty→None) + 2 handler (weekly block assembled with the seeded cache; substrate survives a block-assembly failure with the key omitted).Tests
327 pass (
-k "regime or substrate or drawdown or backfill or handler"), zero failures.Arc status
#176 ✅ · #177 ✅ · #178 ✅ · #193 ✅ (executor) · #this (weekly-handler fill) · remaining: research brief + macro-agent prompt (now has
substrate["drawdown"]/effective_regimeto read) · dashboard observe panel · config EXPERIMENTS gate + SYSTEM_STATE/ROADMAP closeout.🤖 Generated with Claude Code