Skip to content

State the trip day-key contract where callers actually read it - #1338

Merged
ericgriffin merged 2 commits into
mainfrom
worktree-tdw-key-docs
Aug 28, 2026
Merged

ericgriffin merged 2 commits into
mainfrom
worktree-tdw-key-docs

Conversation

@ericgriffin

Copy link
Copy Markdown
Member

Addresses the remaining review comments on #1319. Stacked on worktree-trip-day-weather. Comments only, no behaviour change.

What was stale

Moving the day key to UTC left three doc comments describing the old contract:

  • tripDayWeatherProvider: "keyed by date.millisecondsSinceEpoch"
  • TripDayWeatherRepository.getForTrip: the same
  • TripDayWeather.date: "Local midnight for the day this describes"

All three were true before the key moved and are now exactly the wrong thing to believe. This is worth fixing rather than tolerating because the failure is silent: a caller that keys a lookup with local-midnight millis finds nothing on any device not running UTC, and the day just renders no badge. Nothing throws. That is the same shape as the bug caught during the UTC change, where the story view computed the key inline and would have dropped every badge.

Each comment now states the contract and why it is UTC.

One that was correct and stays

TripDayWeatherTarget.date genuinely is local midnight, and should be: localNoon reads its calendar fields to ask the archive for noon at the dive site. But it sits one call away from the key derivation, so it is the easiest place to conflate the two. Its doc now says why local is right there and irrelevant to identity: nothing keys a stored row off that instant, and tripDayMillis takes the same calendar fields and pins them to UTC.

Already fixed

The fourth comment, on the backfill test seeding stored with local-midnight millis, was already addressed on the branch by "fix(trips): ask for a stored day with the key it was stored under". That fixture keys through tripDayMillis now and carries a comment explaining why any other key would assert a contract production never offers. Nothing further needed.

634 trips tests pass. flutter analyze clean.

Three doc comments still said the stored-weather map is keyed by
date.millisecondsSinceEpoch, and the entity still called its date field
local midnight. Both were true before the key moved to UTC and are now
exactly the wrong thing to believe: local-midnight millis differ in every
timezone, so a caller keying a lookup that way finds nothing and the day
renders no badge. Nothing throws, which is what makes a stale comment here
worth fixing rather than tolerating.

TripDayWeatherTarget.date genuinely is local midnight and stays that way:
localNoon reads its calendar fields to ask the archive for noon at the dive
site. Its doc now says why that is unrelated to identity, since it sits one
call away from the key derivation and is the easiest place to conflate the
two.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates documentation comments to accurately state the UTC-based “trip day key” contract used for stored trip-day weather lookups, preventing silent mismatches when callers use local-midnight epoch millis.

Changes:

  • Clarify that trip-day weather is keyed by tripDayMillis(date) (UTC-midnight day key), not date.millisecondsSinceEpoch.
  • Explain why local-midnight keys silently miss stored rows on non-UTC devices.
  • Distinguish between “local midnight is fine for archive lookup inputs” vs “UTC-midnight is required for storage identity”.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
lib/features/trips/presentation/providers/trip_day_weather_providers.dart Updates provider doc comment to state the UTC key contract and the failure mode when mis-keyed.
lib/features/trips/domain/services/trip_day_weather_backfill.dart Clarifies why the backfill target date is local-midnight for archive querying but not identity.
lib/features/trips/domain/entities/trip_day_weather.dart Updates entity doc comment for the day/identity contract (noting UTC normalization).
lib/features/trips/data/repositories/trip_day_weather_repository.dart Updates repository doc comment to state the UTC key contract and silent-miss behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread lib/features/trips/domain/entities/trip_day_weather.dart Outdated
Base automatically changed from worktree-trip-day-weather to main August 27, 2026 22:39
@ericgriffin ericgriffin moved this from Backlog to In review in Submersion Release Tracker Aug 28, 2026
@ericgriffin ericgriffin added the bug Something isn't working label Aug 28, 2026
@ericgriffin ericgriffin self-assigned this Aug 28, 2026
The entity's date doc asserted the field is UTC midnight, which the type
does not enforce and one in-tree writer does not honour: the backfill
builds a row with the target's local DateTime(y, m, d), and only the
repository hands back a normalized UTC instant. A comment stating an
invariant the code does not hold is worse than none, because it is what a
reader keys their next lookup off.

It now states the contract that is actually enforced. Identity is
tripDayMillis(date), which reads y/m/d and pins them to UTC midnight, and
every path that stores, keys, or looks a row up derives it that way, so
the differing isUtc flag is invisible to all of them.

With one exception, now named: date is in props, and DateTime equality
compares the epoch value and isUtc, so two entities for the same day
compare unequal across provenance. That is the same silent shape as the
key bug this branch fixed. A test asserting entity equality across a
repository read and a freshly fetched row fails for a reason that looks
nothing like a timezone problem, so the doc says to compare day keys.

Comments only. flutter analyze clean, 634 trips tests pass.
Copilot AI review requested due to automatic review settings August 28, 2026 01:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@github-actions

Copy link
Copy Markdown
Contributor

📦 Build artifacts for this PR · commit f6f2636

Platform Download
Android (APK) android-apk
macOS macos-build
Windows windows-build
Linux linux-build

Artifacts expire in 7 days. Downloading requires being signed in to GitHub. macOS needs two extractions: unzip the downloaded artifact, then unzip the submersion-macos.zip inside it to get a runnable submersion.app. The build is ad-hoc signed — right-click → Open on first launch.

Updated automatically on each push.

@codecov

codecov Bot commented Aug 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@ericgriffin
ericgriffin merged commit 4fad669 into main Aug 28, 2026
26 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in Submersion Release Tracker Aug 28, 2026
@ericgriffin
ericgriffin deleted the worktree-tdw-key-docs branch August 28, 2026 02:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants