fix(eod-sf): hardcode SNS ARN + Catch on HandleFailure (cost-guard)#240
Merged
Conversation
2026-05-14 EOD recovery surfaced a real design gap in the EOD SF.
When HandleFailure's SNS publish fails for any reason — malformed
$.sns_topic_arn (today's recovery payload had a colon → space
substitution between us-east-1 and the account ID), SNS throttling,
IAM drift, transient outage — the entire SF aborted before reaching
ForceStopInstance, leaving the trading EC2 running until manual stop.
The state's own comment ("Failure alert via SNS — instance still
stops to avoid cost") was unenforced.
Two-part defensive fix:
1. Hardcode the SNS topic ARN (no $.sns_topic_arn indirection). The
ARN is fixed; per-execution variability buys nothing and creates
a corruption surface. Today's recovery-input space-instead-of-colon
would have been impossible.
2. Catch States.ALL on HandleFailure → ForceStopInstance so the
cost-guard fires regardless of alert delivery (defense-in-depth
even with #1 in place — covers SNS outages, IAM drift, future
failure modes).
Live verification: deployed via update_eod_pipeline_sf.sh; describe-
state-machine confirms `TopicArn` is literal + Catch routes to
ForceStopInstance.
Tests: full alpha-engine-data suite 1035 passed (was 1032; +3 wiring
pins in test_sf_eod_substrate_check_wiring.py — TopicArn-is-literal,
HandleFailure-has-States.ALL-catch-to-ForceStopInstance, no-state-
binds-$.sns_topic_arn).
Composes with PR #238 (today's daily_append column-order hotfix).
Co-Authored-By: Claude Opus 4.7 (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.
Summary
HandleFailurehad noCatch, so any SNS publish failure aborted the SF before reachingForceStopInstance, leaving the trading EC2 running. Today's specific trigger was a malformedsns_topic_arnin the recovery payload (colon → space substitution between region and account ID), but the design has zero defense against any SNS-side failure (throttling, IAM drift, outage).States.ALLCatch onHandleFailure→ForceStopInstance. Defense-in-depth so the cost-guard fires regardless of alert delivery.Live verification
Deployed via
update_eod_pipeline_sf.sh.describe-state-machineconfirms:HandleFailure.Parameters.TopicArn= literalarn:aws:sns:us-east-1:711398986525:alpha-engine-alerts(no.$indirection)HandleFailure.Catch=[{ErrorEquals: [States.ALL], Next: ForceStopInstance}]Tests
tests/test_sf_eod_substrate_check_wiring.py— 3 new pins underTestHandleFailureCostGuardHardening:test_topic_arn_is_literal_not_jsonpathtest_handle_failure_has_catch_to_force_stop_instancetest_input_schema_no_longer_requires_sns_topic_arnTest plan
pytest tests/test_sf_eod_substrate_check_wiring.py(20 passed)pytest tests/(1035 passed)bash infrastructure/update_eod_pipeline_sf.sh— JSON valid, definition updated on live SFaws stepfunctions describe-state-machineconfirms hardcoded ARN + Catch on live SFsns_topic_arn)Composes with
alpha-engine-data#238(today's daily_append column-order hotfix)alpha-engine#181(today's eod_reconcile macro-lib dispatch)alpha-engine-configcommit.🤖 Generated with Claude Code