feat: pre-trade hard gate — block no-stop BUYs, show blocked as non-actionable - #9
Merged
Merged
Conversation
…ctionable The checklist already hard-BLOCKED on earnings/size/regime, but everything else that failed a check (including a BUY with no stop plan) only became REVIEW and was still published as an actionable signal. And BLOCKED signals were suppressed entirely — the trader never saw what the gate filtered. - checklist: a plan with no valid stop is now a hard block (the MOH lesson); every block records human-readable block_reasons for the alert. - emit path: instead of suppressing BLOCKED BUYs, publish them MARKED BLOCKED (debounced) so alert-service can show them as NON-ACTIONABLE, and skip the actionable gates. HARD_GATE_ENABLED=false reverts to silent suppression. - config: hard_gate_enabled flag (default true). Only alert-service consumes trading.decisions, so publishing blocked signals has no downstream side effects. +9 tests; suite green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
risk-engine's pip install pulls trading-py-commons from a git URL, which needs git in the builder image. Latent since risk-engine adopted the git dependency; surfaced now because main hasn't rebuilt since April. Without this the image build fails and the Pi can't pull a new decision-engine. Co-Authored-By: Claude Opus 4.8 (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
Completes the pre-trade hard gate (Phase 1 remaining item). It was not display-only as the CLAUDE.md TODO claimed —
BLOCKEDalready suppressed on earnings/size/regime. The gaps this closes:REVIEWand still published as actionable. Now it's a hard block (the MOH lesson).block_reasons) so alert-service renders it as 🚫 NON-ACTIONABLE — real-time observability of exactly what the gate catches.Changes
checklist.py— no-valid-stop → hard block (scoped to when a plan exists; the plan-engine-disabled path stays REVIEW). Addsblock_reasonsto the result +to_dict.service.py— emit path publishes BLOCKED BUYs (debounced) instead of suppressing, and skips the actionable gates for them.HARD_GATE_ENABLED=falsereverts to suppression.config.py—hard_gate_enabledflag (default true).Safety
Verified only alert-service consumes
trading.decisions(trading-journal uses positions, stock-service uses trades/positions, reporting reads the DB) — so publishing blocked signals has no downstream side effects.+9 tests (no-stop block, block_reasons, emit publish-vs-suppress, debounce). Full suite green.
🤖 Generated with Claude Code