Skip to content

Fetch alpha-engine-lib PAT from SSM on the spot (not via .env on dispatcher)#45

Merged
cipher813 merged 1 commit into
mainfrom
fix/spot-launchers-fetch-token-from-ssm
Apr 16, 2026
Merged

Fetch alpha-engine-lib PAT from SSM on the spot (not via .env on dispatcher)#45
cipher813 merged 1 commit into
mainfrom
fix/spot-launchers-fetch-token-from-ssm

Conversation

@cipher813
Copy link
Copy Markdown
Owner

Summary

Followup fix on top of #44. The smoke test surfaced that `spot_data_weekly.sh` and `spot_drift_detection.sh` were requiring `ALPHA_ENGINE_LIB_TOKEN` in the dispatcher's `.env` — stale pattern copied from `spot_backtest.sh`. The correct source is SSM Parameter Store (`/alpha-engine/lib-token`), same as ae-trading's `boot-pull.sh`.

Change

Moves the PAT fetch from the dispatcher's `.env` (read by the launcher) → onto the spot itself (via `aws ssm get-parameter` in the DEPS step). Dispatcher never handles the secret.

  • Removed `ALPHA_ENGINE_LIB_TOKEN` preflight check from both launchers
  • Added SSM `get-parameter --with-decryption` inside the DEPS heredoc, scoped to a local shell var `LIB_TOKEN`, unset after `git config --global url.insteadOf` rewrite
  • Dispatcher `.env` no longer needs the token line — rotation happens once in SSM, all launchers pick it up

Why now

Blocks smoke test of the spot migration (#44). Without this the dispatcher fails preflight on missing `.env` token.

Not in this PR

`spot_backtest.sh` and `spot_train.sh` have the same stale pattern but live in their own repos (alpha-engine-backtester, alpha-engine-predictor). Worth the same refactor for consistency — opening as followups.

Test plan

  • `bash -n` on both launchers
  • Post-merge: `bash infrastructure/spot_data_weekly.sh --smoke-only` on ae-dashboard completes green (the run that failed pre-this-fix)
  • Same for `spot_drift_detection.sh --smoke-only`

🤖 Generated with Claude Code

….env

Prior pattern (copied from spot_backtest.sh) required the dispatcher's
.env to contain ALPHA_ENGINE_LIB_TOKEN, which the launcher then scp'd
to the spot. Stale convention — the correct source of truth is SSM
Parameter Store (/alpha-engine/lib-token), which is what ae-trading's
boot-pull.sh uses.

Moving the SSM fetch onto the spot itself:
  - Dispatcher no longer needs the secret in its .env file
  - Secret never rides across scp, ssh argv, or the dispatcher FS
  - Spot's IAM profile (alpha-engine-executor-profile) already grants
    ssm:GetParameter on /alpha-engine/*
  - Single source of truth: rotate SSM once, all launchers pick it up

Also unsets LIB_TOKEN after the git insteadOf rewrite so it doesn't
linger in the spot's environment during the actual workload.

Not modifying spot_backtest.sh / spot_train.sh in this PR — same
refactor applies but those are separate repos with their own merge
cycles. Worth doing for consistency in a follow-up.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@cipher813 cipher813 merged commit bfb1d0b into main Apr 16, 2026
1 check passed
@cipher813 cipher813 deleted the fix/spot-launchers-fetch-token-from-ssm branch April 16, 2026 18:03
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