Harden maker notification layer: kind passthrough, webhook prefix/retry, config validation (fixes #221)#233
Merged
Merged
Conversation
Six small notification-layer fixes grouped together: 1. PositionRiskKind passthrough: position_jump() now reads event.kind and maps it to a distinct webhook kind (direction_flip / max_position_crossed / inventory_exit_crossed / position_jump), escalating DirectionFlip and MaxPositionCrossed to severity "critical" so a reversal or breach is no longer indistinguishable from an ordinary threshold jump. 2. Webhook text now carries the same [severity/kind] symbol: prefix the stderr line uses, so a phone alert identifies its source across instances. 3. MakerFileConfig gets serde(deny_unknown_fields) so a typo like `alert_los` errors instead of silently disabling a guard. 4. alert_loss / alert_inventory_pct / alert_uptime are range-validated at startup (reject negatives and percentages >100) via a testable validate_alert_thresholds helper, mirroring alert_position_change_pct. 5. Order-response stream now emits risk_notifications on disconnect, reconnect success, and reconnect failure, matching the account-stream path (previously entirely silent on the webhook). 6. Webhook POST retries twice with linear backoff on 5xx/timeout, and alert() gained an await-capable path so a firing alert on the final cycle before shutdown is not dropped with its spawned task. Tests: kind-descriptor mapping, deny_unknown_fields typo rejection, and alert threshold range validation. Co-Authored-By: Claude Opus 4.8 <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.
Summary
Six small notification-layer hardening fixes for the maker bot, grouped per issue #221:
position_jump()now readsevent.kindand emits distinct kinds (direction_flip/max_position_crossed/inventory_exit_crossed/position_jump), escalatingDirectionFlipandMaxPositionCrossedto severitycritical. Crossingmax_positionis no longer indistinguishable from an ordinary 20% jump.[severity/kind] symbol:prefix the stderr line carries, so alerts identify their source across multiple instances.MakerFileConfiggains#[serde(deny_unknown_fields)], so a typo likealert_loserrors at load instead of silently leaving the guard off.alert_loss/alert_inventory_pct/alert_uptimeare validated at startup (negatives and percentages >100 rejected) via a purevalidate_alert_thresholdshelper, mirroring the existingalert_position_change_pctcheck.risk_notificationon disconnect, reconnect success, and reconnect failure, matching the account-stream path (previously entirely silent on the webhook).post_webhookretries twice with linear backoff on 5xx/timeout;alert()gained an await-capable path so a firing alert on the final cycle before shutdown is not dropped with its spawned task.Test plan
cargo fmt -- --check(no diff)cargo clippy --workspace --all-targets -- -D warnings(clean)cargo test -p standx-cliandcargo test -p standx-maker(all pass)risk_kind_descriptormapping/severity escalation,deny_unknown_fieldstypo rejection, andvalidate_alert_thresholdsrange rejection.Fixes #221
🤖 Generated with Claude Code