Skip to content

Read commit timestamps in UTC via linq2db and remove NormalizeTimestamp#2391

Draft
myieye wants to merge 7 commits into
developfrom
claude/date-parity-comments
Draft

Read commit timestamps in UTC via linq2db and remove NormalizeTimestamp#2391
myieye wants to merge 7 commits into
developfrom
claude/date-parity-comments

Conversation

@myieye

@myieye myieye commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Makes every DateTimeOffset we persist round-trip to the same UTC instant through both EF Core and linq2db, and removes the hand-rolled HistoryService.NormalizeTimestamp workaround for #2092.

Root cause: lexbox's second UseLinqToDB created a fresh MappingSchema that shadowed Harmony's, dropping Harmony's Commit.HybridDateTime.DateTime UTC converter — so linq2db read commit timestamps in local time and HistoryService reinterpreted the ticks by hand. The fix is to extend Harmony's existing schema (its own get-or-create pattern) instead of replacing it; the converter then applies, the redundant Commit column re-declaration is deleted, and NormalizeTimestamp is gone.

  • DateTimeOffsetOrmParityTests locks this in: the commit timestamp (EF + both HistoryService linq2db paths) and the plain columns (comment CreatedAt/UpdatedAt, UnreadComment.MarkedUnreadAt) must all report the same UTC instant at offset zero.
  • These bugs shift the instant by exactly the local UTC offset, so they're invisible on UTC (why Linq2Db uses wrong timezone when reading commit timestamps #2092 reached production). The FwLite test job now runs under Eastern (non-UTC, DST, negative offset) via a Set-TimeZone step; the test fails loudly rather than passing vacuously if ever run on UTC.

Draft because it's based on #2382 (comment-model) for the non-Harmony comment-date coverage — it can't merge until that does, and CI won't run on this base.

Note for review: LcmCrdt.Tests has 4–5 pre-existing failures on comment-model that are not from this change (regression baselines don't yet include the new comment types; one perf test is timing-flaky). Those belong to #2382. With this change the suite is otherwise green, and the kernel fix added no new failures.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: ab5e2a42-2cea-487b-8f7b-b36628adf26f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/date-parity-comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the 💻 FW Lite issues related to the fw lite application, not miniLcm or crdt related label Jun 30, 2026
@myieye myieye mentioned this pull request Jun 30, 2026
@myieye myieye changed the title Add date-parity test and run FwLite tests under a non-UTC timezone Read commit timestamps in UTC via linq2db and remove NormalizeTimestamp Jun 30, 2026
Comment thread backend/FwLite/LcmCrdt.Tests/DateTimeOffsetOrmParityTests.cs Outdated

@hahn-kev hahn-kev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nice catch. I have some suggestions.

Comment thread backend/FwLite/LcmCrdt.Tests/DateTimeOffsetOrmParityTests.cs
Comment thread backend/FwLite/LcmCrdt.Tests/DateTimeOffsetOrmParityTests.cs Outdated
@myieye myieye requested a review from hahn-kev July 1, 2026 12:59
Comment thread backend/FwLite/LcmCrdt/LcmCrdtKernel.cs Outdated
Base automatically changed from comment-model to develop July 6, 2026 09:11
myieye and others added 7 commits July 6, 2026 12:00
Locks in that every persisted DateTimeOffset round-trips to the same UTC
instant through both EF Core and linq2db (#2092). linq2db skips the converter
for the Harmony commit timestamp so HistoryService normalizes it by hand;
comment dates use the global EF converter, which linq2db also applies. These
errors equal the local UTC offset, so they vanish on UTC — hence the FwLite
test job now runs under Eastern time (non-UTC, DST, negative offset).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
lexbox's second UseLinqToDB created a fresh MappingSchema that shadowed
Harmony's, dropping Harmony's Commit.HybridDateTime.DateTime UTC converter.
linq2db then read commit timestamps in local time, so HistoryService
normalized them by hand (#2092).

Extend Harmony's existing schema instead of replacing it: the converter now
applies, the redundant Commit column re-declaration is gone, and
HistoryService.NormalizeTimestamp is deleted. The parity test now also covers
UnreadComment.MarkedUnreadAt and fails loudly instead of a silent no-op when
run on UTC.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Collapse the repetitive per-column tuples into a generic AssertColumnsAreUtc<T>
helper, and add a DeletedAt test that reads it from the deleted snapshot
(EntityIsDeleted column) since it is never non-null in a projected column.
Tightened comments.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
All plain DateTimeOffset columns share one global converter, so testing many
proves nothing extra. Drop the generic helper and MarkedUnreadAt; keep one
comment timestamp, the commit timestamp, and DeletedAt — the three distinct
mechanisms.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Explain the conditional AddMappingSchema (UseLinqToDbCrdt already registered
the schema); drop the duplicated DeletedAt note from the test header and state
it once at the call site, including why that test isn't gated on a non-UTC zone.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- Move RequireNonUtc() into InitializeAsync so it guards every test in the class
  (per hahn-kev); DeletedAt is now gated too, fine since it still round-trips
  correctly under a non-UTC zone.
- Add an explicit linq2db read of the commit timestamp so the linq2db path stays
  covered even if HistoryService ever moves to EF.
- Set the comment thread CreatedAt to a known non-UTC-offset instant and assert
  it exactly, testing that the write is recorded (not just the round-tripped
  return).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Falling back to a fresh MappingSchema silently dropped Harmony's Commit UTC conversion, reintroducing local-time timestamps (#2092). Fail loudly.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@myieye myieye force-pushed the claude/date-parity-comments branch from 2cb4964 to 1d8ffe9 Compare July 6, 2026 10:03
@myieye

myieye commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator Author

Rebased and resolved merge conflicts

@argos-ci

argos-ci Bot commented Jul 6, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ✅ No changes detected - Jul 6, 2026, 10:06 AM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💻 FW Lite issues related to the fw lite application, not miniLcm or crdt related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants