Repository navigation
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.
Preserve Pi message clocks and unified tool correlation #76103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Preserve Pi message clocks and unified tool correlation #76103
Changes from all commits
607e0997b418c17a9b0feFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
emit()returns the pre-mapping event, while it pushesmapLegacyEvent(event)when processing legacy observations. This mutation therefore updates an object that may not be present inevents; a cloning mapper (the normal session CLI path) drops the recovered clock for tool completions, snapshots, and errors. Return the mapped event (or apply the timestamp before mapping), and add a cloning-mapper regression covering these event types.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This promotes any string/number from archived
messageMetadata.timestampdirectly to canonicaltimestamp, including values such as"yesterday"or timezone-less ISO strings.sessionTimestampNs()then rejects the value, so the event publishes an invalid clock and loses its ordering key, contrary to the spec's timezone-qualified timestamp requirement. Validate with the same parser/range rules before promotion and add invalid-clock coverage.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[/diagnosing-bugs] Promoted
messageMetadata.timestampis only type-checked here, butsessionTimestampNs(unified_session_order.cjs:13) validates the same value strictly. Malformed clocks such as a no-TZ ISO string, an impossible date like 2026-02-30, or a huge number get projected ontotimestampyet are unorderable, so they silently fall back to a different order.💡 Suggested fix
Extract the validation from
sessionTimestampNsinto a shared helper and call it from both places, or promote the clock only when that helper accepts it. The projection and the ordering key then agree on what a valid clock is.@copilot please address this.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.