Skip to content

feat(regime): wire weekly substrate handler to fill the drawdown block (PR 5)#179

Merged
cipher813 merged 1 commit into
mainfrom
feat/drawdown-regime-weekly-handler
May 19, 2026
Merged

feat(regime): wire weekly substrate handler to fill the drawdown block (PR 5)#179
cipher813 merged 1 commit into
mainfrom
feat/drawdown-regime-weekly-handler

Conversation

@cipher813
Copy link
Copy Markdown
Owner

What

PR 5 of the drawdown-regime arc — closes a sequencing gap I owe a note on: PR #176 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 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.pyblock_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 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 same spy/excess shape as the daily artifact (uniform drawdown key 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 isn't reproducible for an as_of backfill), pass to build_regime_substrate. A failure omits the key; the substrate is still written.
  • tests — +4 block_from_history (hysteresis replay distinct from 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).

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_regime to read) · dashboard observe panel · config EXPERIMENTS gate + SYSTEM_STATE/ROADMAP closeout.

🤖 Generated with Claude Code

…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>
@cipher813 cipher813 merged commit c23b727 into main May 19, 2026
1 check passed
@cipher813 cipher813 deleted the feat/drawdown-regime-weekly-handler branch May 19, 2026 03:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant