Skip to content

feat(regime): drawdown leg daily-stage wiring (PR 2, observe-only)#177

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

feat(regime): drawdown leg daily-stage wiring (PR 2, observe-only)#177
cipher813 merged 1 commit into
mainfrom
feat/drawdown-regime-daily-stage

Conversation

@cipher813
Copy link
Copy Markdown
Owner

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.pyseed_state(): cold-start seeding from price/NAV history. Uses the true trailing peak (cummax) + a conservative initial tier from current depth, so the first online step() reports the real drawdown instead of ~0% mid-crash (the feedback_no_silent_fails failure mode — naive cold start would silently fabricate "no drawdown").
  • 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"] is populated, ctx.regime_forced_bear just stamped). Reads SPY from ctx.macro (no extra S3 read), 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, PR 1), persists rolling state + forensic artifact + latest sidecar, stamps ctx.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.pyctx.drawdown_effective_regime field (observe-only; the executor / predictor-veto consumer PRs, gated drawdown_regime_enabled default-off, will read it).
  • tests — +9: 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_regime or the new S3 artifacts yet. The daily stage produces + logs the counterfactual; consumers (executor signal_reader posture override + predictor-veto clamp, both gated drawdown_regime_enabled default-off) are the next PRs in the arc.

🤖 Generated with Claude Code

…, 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>
@cipher813 cipher813 merged commit 66effa0 into main May 19, 2026
1 check passed
@cipher813 cipher813 deleted the feat/drawdown-regime-daily-stage branch May 19, 2026 01:44
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