[codex] canonicalize client timestamps#4112
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
ApprovabilityVerdict: Approved This PR adds server-side timestamp canonicalization to ensure consistent timestamps regardless of client clock drift. The change is focused, well-tested, and follows a standard pattern for data integrity. You can customize Macroscope's approvability policy. Learn more. |
Fixes #3983.
What changed
Why
Clients currently generate
createdAtfrom their local clocks. If a client clock is ahead, that future timestamp reaches persisted events and projections, so an older user message can sort after its assistant response and after genuinely newer prompts.Canonicalizing at the server boundary keeps persisted chronology consistent across web and desktop clients while leaving internal server-generated command timestamps unchanged.
This is forward-only: it prevents new skewed records but does not migrate timestamps that are already persisted.
Verification
vp check(passes with 10 pre-existing warnings in unrelated web files)vp run typecheckvp test(4,756 passed, 7 skipped)git diff --checkNote
Canonicalize client timestamps in
normalizeDispatchCommandwith server receipt timecanonicalizeClientCommandTimestampsin Normalizer.ts that replaces client-suppliedcreatedAtwith the server's receipt timestamp.thread.turn.startcommands that includebootstrap.createThread, the bootstrap'screatedAtis also overwritten.normalizeDispatchCommandnow calls this before any other normalization logic.createdAtvalues on all dispatched commands are now silently overwritten with the server receipt time.Macroscope summarized 3337346.
Note
Medium Risk
Silently overwrites client timestamps on every dispatched command, which changes persisted event ordering for all clients but is scoped to the normalization boundary and covered by tests.
Overview
Client orchestration commands no longer persist client-supplied
createdAtvalues.normalizeDispatchCommandnow stamps commands with the server’s receipt time via newcanonicalizeClientCommandTimestamps, applied before workspace and attachment normalization on both HTTP and WebSocket dispatch paths.For
thread.turn.startcommands that bootstrap a new thread, the nestedbootstrap.createThread.createdAtis overwritten with the same receipt timestamp so thread creation and the first turn stay in order when client clocks are skewed. Regression tests cover a plain timestamped command and a bootstrap turn.This is forward-only: existing persisted timestamps are unchanged.
Reviewed by Cursor Bugbot for commit 3337346. Bugbot is set up for automated code reviews on this repo. Configure here.