feat(regime): drawdown leg daily-stage wiring (PR 2, observe-only)#177
Merged
Conversation
…, observe-only)
PR 2 of the drawdown-regime arc. The producer-side daily acting path,
deferred from PR 1. Still observe-only, non-critical, zero behavior
change. Plan: regime-drawdown-hysteresis-260518.md; ROADMAP config #230.
- regime/drawdown.py: add seed_state() — cold-start seeding from price/
NAV history (true trailing peak via cummax + conservative initial
tier from current depth). Prevents the naive-cold-start failure where
peak=today reports ~0% drawdown mid-crash (feedback_no_silent_fails).
- inference/stages/regime_fast_signal.py: _advance_drawdown(ctx, s3,
dual, run_id) invoked from run() on the same daily rail (post
run_inference: ctx.macro['SPY'] populated, ctx.regime_forced_bear just
stamped). Reads SPY from ctx.macro (no extra S3), eod_pnl NAV via the
graceful-degrading reader, advances regime.drawdown.step, composes the
daily effective regime = most-protective over {drawdown legs, Stage-F
forced_bear} (HMM argmax is composed at the weekly substrate layer),
persists rolling state + forensic artifact + latest sidecar, stamps
ctx.drawdown_effective_regime, logs the counterfactual. Fully
self-contained + non-raising: never affects fast-signal or
predictions. No new Lambda / SF state.
- inference/pipeline.py: ctx.drawdown_effective_regime field (observe
-only; the executor / predictor-veto consumer PRs, gated
drawdown_regime_enabled default-off, will read it).
- tests: +9 cases (seed_state true-peak/tier/nav/empty; stage observe
-only stamps ctx + persists 3 keys + leaves fast-signal/predictions
untouched; SPY-missing graceful skip).
393 regime/inference-suite tests pass, zero failures.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced May 19, 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.
What
PR 2 of the drawdown-regime arc — the producer-side daily acting path deferred from PR 1 (#176, merged). Still observe-only, non-critical, zero behavior change. Plan:
regime-drawdown-hysteresis-260518.md; ROADMAP alpha-engine-config #230 (P1).Changes
regime/drawdown.py—seed_state(): cold-start seeding from price/NAV history. Uses the true trailing peak (cummax) + a conservative initial tier from current depth, so the first onlinestep()reports the real drawdown instead of ~0% mid-crash (thefeedback_no_silent_failsfailure mode — naive cold start would silently fabricate "no drawdown").inference/stages/regime_fast_signal.py—_advance_drawdown(ctx, s3, dual, run_id)invoked fromrun()on the same daily rail (post-run_inference:ctx.macro["SPY"]is populated,ctx.regime_forced_bearjust stamped). Reads SPY fromctx.macro(no extra S3 read),eod_pnlNAV via the graceful-degrading reader, advancesregime.drawdown.step, composes the daily effective regime = most-protective over {drawdown legs, Stage-Fforced_bear} (HMM argmax is composed at the weekly substrate layer, PR 1), persists rolling state + forensic artifact + latest sidecar, stampsctx.drawdown_effective_regime, logs the counterfactual. Fully self-contained + non-raising — a failure here never touches fast-signal or predictions. No new Lambda / Step Function state.inference/pipeline.py—ctx.drawdown_effective_regimefield (observe-only; the executor / predictor-veto consumer PRs, gateddrawdown_regime_enableddefault-off, will read it).seed_state(true-peak / conservative-tier / NAV-excess / empty); stage observe-only (stamps ctx + persists 3 keys + leaves fast-signal & predictions untouched); SPY-missing graceful skip.Tests
393 regime/inference-suite tests pass, zero failures (
-k "regime or substrate or drawdown or backfill or pipeline or inference"). Pre-existing sklearn matmul RuntimeWarnings only.Observe-only invariant
Nothing reads
ctx.drawdown_effective_regimeor the new S3 artifacts yet. The daily stage produces + logs the counterfactual; consumers (executorsignal_readerposture override + predictor-veto clamp, both gateddrawdown_regime_enableddefault-off) are the next PRs in the arc.🤖 Generated with Claude Code