Skip to content

spawn validate --infrastructure reports 2 errors against the real infra account; one is false, one means spawn alerts is a dead surface, and the remediation names a command that does not exist #790

Closed

Description

@scttfrdmn

Found while gathering evidence for #783. spawn validate --infrastructure is the
command whose whole job is to tell you whether the shared infrastructure is
healthy. Run against the live infra account (966362334030) today:

$ AWS_PROFILE=spore-host-infra spawn validate --infrastructure --region us-east-1
Lambda Functions:
  ✗ …:function:spawn-alert-handler:    ResourceNotFoundException: Function not found
  ✓ spawn-dashboard-api
  ✗ …:function:spawn-scheduler-handler: ResourceNotFoundException: Function not found
  ✓ spawn-sweep-orchestrator
  (2/4 accessible)

Status: ✗ 2 errors found

Recommendations:
  1. Deploy Lambda functions using CloudFormation: spawn config deploy-infrastructure

Three separate defects, in increasing order of how much they matter.

1. spawn-scheduler-handler is a FALSE error

The function is deployed. It is called scheduler-handler, with no spawn-
prefix, because scripts/deploy-scheduler-handler.sh defaults to
SPAWN_LAMBDA_NAME:-scheduler-handler.

pkg/infrastructure/resolver.go:88 hardcodes the prefixed name:

return fmt.Sprintf("arn:aws:lambda:%s:966362334030:function:spawn-scheduler-handler", r.region)

This is the same trap already recorded in docs/infra-account.md and
scripts/lambda-deploy-census.sh — a filter built from the naming convention
cannot find the one function that does not follow it. Here it does not merely
miss the function, it actively reports it as missing.

A health check that cries wolf is worse than no health check: the next person to
run this has to re-derive which of the two errors is real.

2. spawn-alert-handler is a TRUE error — and it means spawn alerts never fires

This is #783's stranded lambda/alert-handler/, but the consequence is larger
than "unused code". Tracing the path:

  • spawn alerts create <sweep-id> exists and validates five trigger types
    (complete, failure, cost_threshold, long_running, instance_failed —
    pkg/alerts/alerts.go:27-31), then writes to spawn-alerts.
  • spawn alerts history <alert-id> reads spawn-alert-history.
  • The only consumer of spawn-alerts and the only writer of
    spawn-alert-history is lambda/alert-handler/main.go.
  • That function is deployed nowhere, under any name, in either account.
  • The live spawn-alert-evaluator is not a substitute: it reads
    spawn-alert-preferences + spawn-cost-history and publishes to
    COST_ALERTS_TOPIC_ARN. It never reads spawn-alerts, and it covers cost
    alerts only — not the sweep triggers the CLI accepts.

So spawn alerts create succeeds and no alert can ever fire, and
spawn alerts history is permanently empty.
Nothing in the CLI says so. This
is the same shape as #774's advertised-and-ignored --region.

Checked rather than assumed: sweep-orchestrator's only lambda.Invoke is
reinvokeSelf (main.go:833), not alert delivery. Nothing in the repo invokes
the alert handler.

3. The remediation names a command that does not exist

pkg/infrastructure/validator.go:255 and :279 both recommend:

Deploy Lambda functions using CloudFormation: spawn config deploy-infrastructure

There is no such command. spawn config takes two arguments (get/set), and
deploy-infrastructure appears nowhere in the tree except those two strings. So
the one actionable line in a failing report sends you to a dead end.

Suggested

  1. Resolve the scheduler-handler name from the same place the deploy script does,
    rather than reconstructing it. A gate that the validator's expected names match
    the names the deploy scripts/templates actually create would prevent the class
    — this is the "discover, don't list" rule in CLAUDE.md.
  2. Decide alert-handler (this is Two stranded artifacts: self-hosted-stack.yaml (354 lines, deployed nowhere) and lambda/alert-handler (builds in CI, runs nowhere) #783's decision): deploy it, or remove the
    spawn alerts CLI surface. Whichever is chosen, the CLI must not keep
    accepting alerts it cannot deliver
    — that half is a bug independent of the
    product call.
  3. Point the recommendation at a real command, or drop it.

Each of the three is independently verifiable by running the command above.

Activity

  1. added
    bug
    on Oct 10, 2026
  2. scttfrdmn commented on Oct 10, 2026

    @scttfrdmn
    ContributorAuthor

    Defects 1 and 3 are fixed and merged in #791 (b5f90d5). Leaving this
    open for defect 2's remaining half.

    Fixed

    1. The false spawn-scheduler-handler error. The resolver now resolves the
    deployed name (scheduler-handler) from a constant, and three places that
    agreed with the bug were corrected: the resolver, its unit test, and the
    Substrate fixture. Verified live, read-only — 1 error instead of 2, 3/4
    accessible instead of 2/4, ✓ scheduler-handler.

    3. The dead-end remediation. spawn config deploy-infrastructure and
    spawn config init --self-hosted are gone. Recommendations name the actual
    script or template per resource, and where nothing in the repo deploys a
    function they say so rather than inventing a command.

    Two gates landed with it:

    • TestEveryHardcodedLambdaNameIsCreatedByADeployMechanism — reads function
      names out of every deploy script and template and fails when Go source
      hardcodes one none of them create. Discovered, not listed. Found ten created
      names, two of which nobody had enumerated by hand.
    • TestValidateRecommendationsNameOnlyRealCommandsAndPaths — resolves every
      command a recommendation mentions against the real cobra tree, and checks
      every path exists. Checking the first word would not have caught this:
      config is a real command; the defect was the subcommand.

    Worth recording because it nearly shipped as a no-op: the second gate missed
    two of the three defects on its first run
    . The Lambda branch names mechanisms
    per function when it has resource detail and falls back to one generic line when
    it does not, and the fixture populated Resources — so the fallback string was
    unreachable, and restoring the original text there passed. Same shape as #787.
    The fixture now drives both shapes and asserts the fallback is non-empty.

    Still open — defect 2's second half

    The missing spawn-alert-handler is now reported honestly, but the CLI half is
    untouched: spawn alerts create still accepts alerts that nothing can
    deliver, and spawn alerts history is still permanently empty.
    Reporting it in
    a health check is not the same as refusing to accept it at the point of use.

    That half does not depend on #783: whether the answer there is "deploy the
    handler" or "remove the feature", the CLI should not silently accept an alert it
    cannot deliver in the meantime.

  3. scttfrdmn commented on Oct 11, 2026

    @scttfrdmn
    ContributorAuthor

    Defect 2's remaining half is fixed and merged in #793 (82d286d). All three
    code items in this issue are now done
    ; what is left is not code.

    spawn alerts create refuses when the consumer is absent — verified live against
    the shared account: exit 1, and an independent DynamoDB scan of spawn-alerts
    for the probe sweep ID returns Count=0, so nothing is written.

    The refusal is conditional on knowing, not on guessing:

    state action
    function absent (404) refuse, non-zero, nothing written
    AccessDenied / no network warn, create anyway
    function present silent

    Refusing on an undetermined result would break working installs to protect them
    from a defect they may not have. A self-hosted install pointing
    SPAWN_LAMBDA_ALERT_HANDLER_ARN at its own deployed function is unaffected, and
    there is a test for that so "refuse when the shared function is missing" cannot
    quietly become "always refuse".

    What remains, and where it belongs

    This issue can close once #783 is decided. The reporting is now honest in all
    three places it was not — the health check, the remediation, and the point of
    use — but the underlying feature is still inert in the shared account. That is
    #783's call: deploy alert-handler, or withdraw spawn alerts.

    Worth noting for whoever picks that up: with this change, "withdraw the command"
    is now a smaller step than it was. The command already refuses in every
    shared-mode install, so removing it would not take away working behaviour from
    anyone.

    One thing this surfaced

    #792 — Tier 0 e2e uses an existing bin/spawn unconditionally rather than
    building. It gave me a passing TestTier0_AlertsRoundTrip from a nine-hour-old
    binary containing none of this change. The failing new test is what sent me
    looking; the passing one would not have.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions