Skip to content

fix: limit plugin telegram alerts to manual review#171

Merged
Pigbibi merged 2 commits into
mainfrom
codex/fix-plugin-telegram-manual-review-20260703
Jul 3, 2026
Merged

fix: limit plugin telegram alerts to manual review#171
Pigbibi merged 2 commits into
mainfrom
codex/fix-plugin-telegram-manual-review-20260703

Conversation

@Pigbibi

@Pigbibi Pigbibi commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Summary\n- limit strategy plugin Telegram alerts to manual-review/notification-only signals\n- skip auto-consumable plugin signals so platform cycle notifications carry them\n- remove platform context from plugin Telegram messages and add a unified manual-review header\n\n## Tests\n- python3 -m pytest tests/test_strategy_plugin_telegram_notifications.py tests/test_strategy_plugins.py::StrategyPluginsTests::test_strategy_plugin_auto_position_control_signal_stays_with_strategy_notification tests/test_strategy_plugins.py::StrategyPluginsTests::test_strategy_plugin_manual_review_strategy_signal_still_alerts_plugin_bot tests/test_strategy_plugins.py::StrategyPluginsTests::test_strategy_plugin_notification_target_still_alerts_plugin_bot -q\n- python3 -m ruff check src/quant_platform_kit/notifications/strategy_plugin_telegram.py tests/test_strategy_plugin_telegram_notifications.py\n- git diff --check

Co-Authored-By: Codex <noreply@openai.com>
@Pigbibi Pigbibi force-pushed the codex/fix-plugin-telegram-manual-review-20260703 branch from 7746e43 to 636f2b1 Compare July 3, 2026 04:37

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7746e4383c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +257 to +260
return (
_coerce_bool(controls.get("position_control_allowed"), default=False)
or _coerce_bool(policy.get("position_control_allowed"), default=False)
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Require runtime metadata before suppressing Telegram alerts

For defend/delever signals where consumption_evidence_status='automation_approved' and position_control_allowed=True but strategy_runtime_metadata_allowed=False, should_alert_strategy_plugin_signal() still emits an alert because _is_strategy_position_control_notice() only hands signals to the platform cycle when runtime metadata is allowed. This new predicate suppresses Telegram based only on position-control permission, so those defensive/delever signals are neither carried by the platform cycle notification nor sent to the plugin Telegram channel.

Useful? React with 👍 / 👎.

if target_type == "notification_target":
return True
action = str(getattr(signal, "suggested_action", None) or "").strip().lower()
if action in _MANUAL_REVIEW_ACTIONS:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve blocked guard alerts in Telegram filtering

When a guard/data-quality signal arrives with suggested_action='blocked' and no notification_only controls, the shared alert builder still treats it as an alert (blocked is in STRATEGY_PLUGIN_ALERT_ACTIONS), but this new prefilter only lets notify_manual_review or notification-only signals reach build_strategy_plugin_alert_messages(). That makes market_regime_control/blocked or crisis guard-blocked alerts produce zero Telegram deliveries, so operators miss the alert that tells them to fix the blocked data/source condition.

Useful? React with 👍 / 👎.

Comment on lines +170 to +174
manual_review_signals = tuple(
signal for signal in signals if _is_manual_review_telegram_signal(signal)
)
messages = build_strategy_plugin_alert_messages(
signals,
manual_review_signals,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep ordinary Telegram channel alerts dispatchable

When publish_strategy_plugin_alerts() is configured with channels=("telegram",) for a regular alerting plugin signal such as the existing crisis_response_shadow true_crisis/defend signal with no notification-only controls, this prefilter drops the signal before the shared alert-builder logic can send it. The other channels still deliver it and the dispatcher tests now lose the Telegram send/count, so Telegram-only alert deployments silently miss these ordinary plugin alerts.

Useful? React with 👍 / 👎.

@Pigbibi Pigbibi enabled auto-merge (squash) July 3, 2026 04:44
Co-Authored-By: Codex <noreply@openai.com>
@Pigbibi Pigbibi merged commit 0063af3 into main Jul 3, 2026
2 checks passed
@Pigbibi Pigbibi deleted the codex/fix-plugin-telegram-manual-review-20260703 branch July 3, 2026 04:45

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3ccc2abb18

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

_DEFAULT_TELEGRAM_BODY_MAX_CHARS = 3900
_MARKET_REGIME_CONTROL_PLUGIN = "market_regime_control"
_AUTOMATED_POSITION_ACTIONS = frozenset({"defend", "delever"})
_MANUAL_REVIEW_ACTIONS = frozenset({"notify_manual_review"})

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Include watch-only signals in Telegram filtering

The runtime contract in docs/strategy_plugin_runtime_contract.md:203-205 lists watch_only as remaining in the plugin-alert stream, but this new action set only allows notify_manual_review. For a strategy-mounted watch signal with canonical_route='watch', suggested_action='watch_only', and the default controls (no notification_profile/capital_impact), build_strategy_plugin_alert_messages() would create an alert because the route is not no_action, yet the Telegram prefilter rejects it before the builder runs, so documented watch-only Telegram alerts disappear.

Useful? React with 👍 / 👎.

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