Skip to content

Gate that every spored notification event is handled by spore-bot (#1004) - #1011

Merged
scttfrdmn merged 3 commits into
mainfrom
fix/1004
Oct 16, 2026
Merged

scttfrdmn merged 3 commits into
mainfrom
fix/1004

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Fixes #1004

What

TestSporedNotifyEventsHandledBySporeBot (root package, spored_events_test.go) discovers every event spored sends and fails if spore-bot's handled-events list lacks one.

  • Discovery is AST-based, over every non-test Go file of the root module (nested modules skipped). It matches calls X.Notify(...) where X is not an imported package (excludes signal.Notify). That is sound only while (*Notifier).Notify is the module's one method named Notify, so it checks that too and fails on a second one. A .Notify method value fails as well.
  • The event argument is resolved, not skipped. String literals, package consts/vars, locals assigned anywhere in the enclosing function (handles action, event := "stop", "idle_stopped" / event = "idle_hibernated" from Back off a failed idle stop, announce only success, and restore DNS on failure (#948) #977, and switch-chosen values), and struct fields (every keyed-literal or x.f = v value of that field name in the package; covers Announce an on-complete stop once and back off a failed one, sharing the idle stop's backoff (#978) #1005's stopAttempt.failEvent). A parameter, a multi-value assignment, an unkeyed literal of a struct declaring the field, or anything else unresolvable fails the test with the call site.
  • Fails on empty discovery (no events, or no Go files parsed).

Vendored vs fetched

Vendored. testdata/spore-bot/spored_events.txt is a byte-exact copy of spore-host main:lambda/spore-bot/testdata/spored_events.txt (at 6177b57), so go test stays offline. TestSporeBotEventsVendoredCopyIsCurrent skips unless SPORE_BOT_EVENTS_SYNC=1; CI sets it in its own step, fetches upstream from raw.githubusercontent.com (3 attempts), compares the parsed event sets (comment-only edits don't trip it), and prints the curl re-vendor command on drift. Both run as named CI steps next to the API-surface gate.

Missing-from-bot fails. Bot-lists-but-spored-doesn't-send is only logged; spore-bot's own TestSporedEventsMatchSpawn covers that direction. On main that shows up for idle_stop_failed, which #977 adds.

Watched it fail

Each case below compiled and the test ran:

Open PRs that touch events

Checks

make check: the only failure is the known Docker-only TestGenerateWrapper_ChownFixesCrossUIDStickyUnlink_Docker. make check-nested: all 9 nested modules clean. Both ran with AWS credentials stripped (#968).

@codecov

codecov Bot commented Oct 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

scttfrdmn added a commit that referenced this pull request Oct 16, 2026
The Secret Scan job checked out with fetch-depth 0, which fetches every
branch, and ran `gitleaks detect` with no --log-opts, i.e. `git log --all`.
One open PR's finding therefore failed every other PR's Secret Scan until that
branch was force-pushed (seen with fix/968's old commit failing #1011).

Run `gitleaks git --log-opts="HEAD"` instead, keeping the full-history checkout:
on pull_request HEAD is the merge commit, so main plus every PR commit is
scanned (a secret added and removed within the PR is still caught); on push and
schedule it is main's full history.

workflow_secret_scan_test.go parses security.yml and fails if the gitleaks
invocation loses --log-opts="HEAD", widens with --all/--branches/--remotes/
--glob, stops scanning git history, its job loses fetch-depth 0, or no gitleaks
invocation is found.

Fixes #1024
scttfrdmn added a commit that referenced this pull request Oct 16, 2026
The Secret Scan job checked out with fetch-depth 0, which fetches every
branch, and ran `gitleaks detect` with no --log-opts, i.e. `git log --all`.
One open PR's finding therefore failed every other PR's Secret Scan until that
branch was force-pushed (seen with fix/968's old commit failing #1011).

Run `gitleaks git --log-opts="HEAD"` instead, keeping the full-history checkout:
on pull_request HEAD is the merge commit, so main plus every PR commit is
scanned (a secret added and removed within the PR is still caught); on push and
schedule it is main's full history.

workflow_secret_scan_test.go parses security.yml and fails if the gitleaks
invocation loses --log-opts="HEAD", widens with --all/--branches/--remotes/
--glob, stops scanning git history, its job loses fetch-depth 0, or no gitleaks
invocation is found.

Fixes #1024
)

TestSporedNotifyEventsHandledBySporeBot parses every non-test Go file of the
root module, finds each Notifier.Notify call and resolves its event argument
(string literals, consts, locals assigned in the function such as
idle_stopped/idle_hibernated, and struct fields such as #1005's
stopAttempt.failEvent). It fails on an event missing from spore-bot's list, on
an argument it cannot resolve, on a Notify method value, on a second Notify
method, and on empty discovery.

spore-bot's list is vendored at testdata/spore-bot/spored_events.txt so the
unit test is offline; TestSporeBotEventsVendoredCopyIsCurrent runs in CI with
SPORE_BOT_EVENTS_SYNC=1, fetches spore-host main and fails on drift.

(#1004)
@scttfrdmn
scttfrdmn merged commit c46f969 into main Oct 16, 2026
8 checks passed
@scttfrdmn
scttfrdmn deleted the fix/1004 branch October 16, 2026 19:36
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.

Gate: every spored notification event must be in spore-bot's handled-events list

1 participant