Skip to content

fix(plugins): every default registration carries the simulated clock (#904) - #1027

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/plugin-time-controller-904
Sep 17, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/plugin-time-controller-904

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

RegisterDefaultPlugins spelled a PluginConfig out per registration, and fifteen
of the sixty-seven left Options["time_controller"] out. The fallback every
plugin takes for an absent key is a private NewTimeController(time.Now()) and
it is silent by design, so a registration that forgot the key looked exactly
like one that supplied it — and eleven services stamped their timestamps from
the wall clock, ignoring both the time control endpoints and the clock a replay
sets per event.

The config is now built in one place, pluginWiring.register, and the
registrations are a table of {plugin, name, extra} in the original order with
the original error-wrap names. A registration can no longer spell its own
config out, which is what made the omission invisible at each call site.

A nil *TimeController is left out of the map rather than stored: every plugin
reads the value with a type assertion that succeeds for a typed nil and would
hand the plugin a clock that panics on first use, where an absent key takes the
documented fallback instead.

Kinesis needed a second fix. generateKinesisSeqNo called time.Now() from a
function with no receiver, so it could not reach any plugin's clock however
that clock was supplied — and a SequenceNumber is observable, reported by
PutRecord and PutRecords and echoed back by GetRecords. It now takes the
instant as a parameter and both call sites pass the plugin's clock.

The new test asserts exact equality against a stopped clock for each of the
eleven plugins whose registration used to omit it, through the server rather
than through a hand-initialized plugin, plus that POST /v1/control/time reaches
two of them. All eleven fail against the parent commit. The four remaining
registrations of the fifteen — Tagging, Health, Price List and the API Gateway
proxy — have no clock field at all, so the option is a deliberate no-op there.

#886's workaround, which re-registered SES v2 by hand with the server's clock
in order to assert a whole MessageId, is deleted.

Closes #904.

Verification

The nine-command gate is clean: gofmt/go build/go vet, golangci-lint run ./..., make test, GOTOOLCHAIN=go1.26.6 make test, GOTOOLCHAIN=go1.26.6 make coverage, the four docs targets, npm --prefix docs run build, and the e2e suite. Coverage holds the baseline at 85.0% emulator / 84.5% total.

The premise corrections behind this change are recorded on the issue: only eleven of the fifteen have a clock field at all, the Kinesis bypass, the three uncounted callers of RegisterDefaultPlugins (including the debug UI, whose zero-time clock the eleven now inherit), and why AC 4 is answered by central wiring rather than by making Initialize fail.

…904)

RegisterDefaultPlugins spelled a PluginConfig out per registration, and fifteen
of the sixty-seven left Options["time_controller"] out. The fallback every
plugin takes for an absent key is a private NewTimeController(time.Now()) and
it is silent by design, so a registration that forgot the key looked exactly
like one that supplied it — and eleven services stamped their timestamps from
the wall clock, ignoring both the time control endpoints and the clock a replay
sets per event.

The config is now built in one place, pluginWiring.register, and the
registrations are a table of {plugin, name, extra} in the original order with
the original error-wrap names. A registration can no longer spell its own
config out, which is what made the omission invisible at each call site.

A nil *TimeController is left out of the map rather than stored: every plugin
reads the value with a type assertion that succeeds for a typed nil and would
hand the plugin a clock that panics on first use, where an absent key takes the
documented fallback instead.

Kinesis needed a second fix. generateKinesisSeqNo called time.Now() from a
function with no receiver, so it could not reach any plugin's clock however
that clock was supplied — and a SequenceNumber is observable, reported by
PutRecord and PutRecords and echoed back by GetRecords. It now takes the
instant as a parameter and both call sites pass the plugin's clock.

The new test asserts exact equality against a stopped clock for each of the
eleven plugins whose registration used to omit it, through the server rather
than through a hand-initialized plugin, plus that POST /v1/control/time reaches
two of them. All eleven fail against the parent commit. The four remaining
registrations of the fifteen — Tagging, Health, Price List and the API Gateway
proxy — have no clock field at all, so the option is a deliberate no-op there.

#886's workaround, which re-registered SES v2 by hand with the server's clock
in order to assert a whole MessageId, is deleted.

Closes #904.
@codecov

codecov Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.97980% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
emulator/plugins.go 97.89% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 6310963 into main Sep 17, 2026
14 checks passed
@scttfrdmn
scttfrdmn deleted the fix/plugin-time-controller-904 branch September 17, 2026 14:54
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.

15 of 67 default plugin registrations omit time_controller, so those plugins run on wall-clock time

1 participant