fix(weather): guard the single clock reading on the weather view - #143
Merged
Conversation
Hoisting time.Now out of the per-city loop shipped without a test: moving the call back inside passed the whole suite, so the next refactor could undo it silently and two cities either side of a midnight would get baselines a calendar day apart inside one response. Give the service the clock seam chart.NewService and digest.NewService already use — an explicit trailing now func() time.Time, time.Now in cmd/web. The guard hands it a clock that steps over a local midnight between calls and asserts both cities were measured against the same instant, and that the clock was read exactly once. The forecast stub now records the window lower bound of every call, which is what makes the baseline observable from outside at all. Refs: #127 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01U6jNuzK5PZrhDWBxB3t2gY
The forecast agent gained a deferred= field when failed fetches started being throttled, so the two places quoting the healthy-looking line — the decoder comment that explains why an unstorable batch must be an error, and the same passage in the collection skill — were describing a line the collector no longer prints. Nothing parses the format; a grep for the old form outside the frozen plans now returns nothing. Refs: #132 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01U6jNuzK5PZrhDWBxB3t2gY
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two follow-ups recorded during the outlook review, neither of which had an owner until now.
The clock seam (was: the one fix that shipped without a guard)
Hoisting
time.Nowout ofObtainMeCurrent's per-city loop was correct and untested. Movingthe call back inside passed the entire suite, so the next refactor could undo it in silence
and two cities either side of a midnight would be handed baselines a calendar day apart
inside one response — each one's 16-day window starting somewhere different.
weather.Servicenow takes the clock seamchart.NewServiceanddigest.NewServicealreadyuse: an explicit trailing
now func() time.Time, wired astime.Nowincmd/web. No newpattern invented.
The guard hands it a clock that steps over a local midnight between calls and asserts two
things — both cities were measured against the same instant, and the clock was read exactly
once. Verified by re-inlining the call per city: both assertions fail.
stubForecastsnow records the window lower bound of every call, which is what makes thebaseline observable from outside at all.
The log line
The forecast agent gained a
deferred=field in #138. Two places quoted the oldhealthy-looking line — the decoder comment explaining why an unstorable batch must be an error,
and the same passage in
beacon-collection. Both now quote what the collector actuallyprints. Nothing parses the format: a grep for the old form outside the frozen plans returns
nothing.
Gate
go vet,scripts/lint-checks.shandgolangci-lintclean; 41 packages green.Refs #127, #132