Skip to content

fix(validate): stop reporting a deployed Lambda as missing, and point remediation somewhere real (#790) - #791

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/790-validate-infrastructure
Oct 10, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/790-validate-infrastructure

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Fixes the two decision-free defects in #790. Refs #790 rather than closing
it — the third defect (the spawn alerts CLI accepting alerts nothing can
deliver) is still open and is independent of the #783 product call.

Before and after, against the live shared account

 before                                              after
 ✗ spawn-scheduler-handler  (404)                     ✓ scheduler-handler
 ✗ spawn-alert-handler      (404)                     ✗ spawn-alert-handler  (404, real)
 (2/4 accessible)                                     (3/4 accessible)
 Status: ✗ 2 errors found                             Status: ✗ 1 errors found

 1. Deploy Lambda functions using CloudFormation:     1. Lambda spawn-alert-handler: nothing in this
    spawn config deploy-infrastructure                   repo deploys this function; alerts created
    ^ not a command                                      with `spawn alerts create` cannot fire until
                                                         it is (see issue #783)

1. The false error

The function is deployed as scheduler-handler, no prefix —
scripts/deploy-scheduler-handler.sh defaults to
SPAWN_LAMBDA_NAME:-scheduler-handler. The resolver rebuilt the name from the
prefix convention and asked for spawn-scheduler-handler, which has never
existed.

Scheduling was never broken; cmd/schedule.go has always invoked the unprefixed
name. Only the health check was wrong — the worse place for it, since an operator
who can't trust the report has to re-derive which half to believe.

Three places agreed with the bug: the resolver, its unit test, and the
Substrate fixture. The fixture now provisions from the same constants the
resolver uses; the unit test deliberately keeps literal ARNs, because a test
that restates the value under test cannot notice it being wrong. That split is
the point — resolver_test trips when a name changes, lambda_names_test
decides whether the new name is real.

2. The dead-end remediation

spawn config deploy-infrastructure and spawn config init --self-hosted do not
exist, and both predate every other commit. Because config is an alias for
instance-config, following the advice didn't even yield "unknown command" — it
tried to read runtime config over SSH from an instance named
deploy-infrastructure.

Recommendations now name the real mechanism per resource, and where nothing in
the repo deploys a function they say so instead of inventing a command.

Gates, and the one that didn't work first time

  • TestEveryHardcodedLambdaNameIsCreatedByADeployMechanism — reads names out of
    every deploy script and template, fails when Go source hardcodes one none of
    them create. Discovered, not listed: writing the convention down a second time
    is what drifted the first time. It found ten created names, two of which nobody
    had enumerated by hand.
  • TestValidateRecommendationsNameOnlyRealCommandsAndPaths — resolves every
    command against the real cobra tree and checks every path exists. In cmd/
    because the cobra tree is the only authority. Checking the first word wouldn't
    have helped: config is real; the defect was the subcommand.

The second gate initially missed two of the three defects, and running the
reverts is the only reason I know. The Lambda branch names mechanisms per
function when it has resource detail and falls back to one generic line when it
doesn't; my fixture populated Resources, so the fallback string was
unreachable and restoring the original text there passed. That is the #787
shape precisely — a gate that cannot reach the string it guards. The fixture now
drives both shapes and asserts the fallback is non-empty; all three original
strings now fail it (bare, backticked, and --self-hosted on a command with no
such flag). The name gate was confirmed against a revert that builds and vets
clean.

Verification

make check green including all 12 nested modules; check-docs, API surface,
changelog and semgrep (0 findings, 414 rules) clean. Public API surface
unchanged, correctly — pkg/infrastructure is not imported by another repo.
Live run above is read-only; no AWS state was changed.

… remediation somewhere real (#790)

`spawn validate --infrastructure` is the command whose whole job is saying
whether the control plane is healthy. Against the live shared account it
reported two errors, one of which was false, and then recommended a
command that does not exist.

## The false error

The scheduler handler is deployed as `scheduler-handler`, with no prefix:
scripts/deploy-scheduler-handler.sh defaults to
`SPAWN_LAMBDA_NAME:-scheduler-handler`. The resolver rebuilt the name from
the prefix convention and asked for `spawn-scheduler-handler`, which has
never existed anywhere.

Scheduling itself was never broken — cmd/schedule.go has always invoked
the unprefixed name. Only the health check was wrong, which is the worse
place for it to be: an operator who cannot trust the report has to
re-derive which half to believe.

Three places agreed with the bug: the resolver, its unit test, and the
Substrate fixture. The fixture now provisions from the same constants the
resolver uses. The unit test deliberately keeps LITERAL ARNs — a test that
restates the value under test cannot notice it being wrong, which is how
this survived. Division of labour: resolver_test trips when a name
changes; lambda_names_test decides whether the new name is real.

## The dead-end remediation

It recommended `spawn config deploy-infrastructure` and
`spawn config init --self-hosted`. Neither exists; both have been there
since the initial commit. And because `config` is an alias for
`instance-config`, following the advice did not even give an
"unknown command" error — it tried to read runtime config over SSH from an
instance named "deploy-infrastructure".

Now: missing Lambdas are named one per line with the script that deploys
each; missing tables with the setup script or template that creates them;
self-hosted mode with the config keys and SPAWN_LAMBDA_*_ARN variables
that actually drive it. Where nothing in the repo deploys a function, it
says so instead of inventing a command — which is the honest answer for
alert-handler, and names #783.

## Gates

TestEveryHardcodedLambdaNameIsCreatedByADeployMechanism reads function
names out of every deploy script and template and fails when Go source
hardcodes one that none of them create. Discovered, not listed: writing
the convention down a second time is what drifted the first time. It found
ten created names, two of which nobody had enumerated by hand
(dashboard-websocket, dashboard-websocket-processor).

TestValidateRecommendationsNameOnlyRealCommandsAndPaths resolves every
command a recommendation mentions against the real cobra tree, and checks
every path exists. It lives in cmd/ because the cobra tree is the only
authority on what exists, and checking the first word would not have
helped: `config` IS a real command and the defect was the subcommand.

## Verifying the gates, which took two attempts

Reverting the name passes `go build` and `go vet`, and the name gate
fails on it with the right diagnostic.

The recommendation gate initially did NOT catch two of the three defects.
The Lambda branch names mechanisms per function when it has resource
detail and falls back to one generic line when it does not; my fixture
populated Resources, so the fallback string was unreachable and restoring
the original text there PASSED. That is the #787 shape exactly. The
fixture now drives both shapes and asserts the fallback is non-empty, and
all three original strings fail it — bare, backticked, and the
`--self-hosted` flag on a command with no such flag.

## Verified against the live account

Before: 2 errors, 2/4 Lambdas accessible, remediation to a nonexistent
command.
After: 1 error (alert-handler, which is real), 3/4 accessible,
`✓ scheduler-handler`, and a recommendation naming `spawn alerts create`
and issue #783.

make check green including all 12 nested modules; check-docs, API surface,
changelog and semgrep (0 findings, 414 rules) clean. Public API surface
unchanged, correctly: pkg/infrastructure is not imported by another repo.
@codecov

codecov Bot commented Oct 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 71.42857% with 12 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/infrastructure/validator.go 70.27% 10 Missing and 1 partial ⚠️
pkg/config/infrastructure.go 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

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