Skip to content

Carry the input time with each SSE event and mode change - #518

Merged
jclark merged 2 commits into
masterfrom
sse-event-time
Oct 24, 2026
Merged

jclark merged 2 commits into
masterfrom
sse-event-time

Conversation

@jclark

@jclark jclark commented Oct 24, 2026

Copy link
Copy Markdown
Owner

Preliminary refactor for #497, with no change in behaviour. The fix for #497 will give each SSE write a deadline counted from when the data it carries was produced, so that a client that falls behind is disconnected; that needs each event on the daemon's SSE event bcast to carry that time.

  • phcsync.Observer.ModeChanged takes the system time of the event behind the transition: the sample's Sys (the estimated time of the pulse), the read time of the time message that triggered leap detection, or when carrier loss was seen. It is zero for the initial transition at startup.
  • Controller.TimeMessage and Controller.Pause take those times from their callers, so phcsync still never reads the clock. The ts pause event records when carrier loss was seen.
  • sseobs.sendSSE takes the time, and events go on the bcast as sseobs.TimedEvent, an sse.Event plus that time: the GPS message's read time, the PHC sample's Sys, or the mode change's time. sseHandleRequest still writes the event as before and ignores the time.

Tests check that the controller passes the right time on the sample, leap-detection and carrier-loss paths, and that SSE events carry their handler's time. make test and the http smoke tests pass.

The fix for #497 will bound how far an SSE client can fall behind by
giving each write a deadline counted from when the data it carries was
produced. Neither the SSE events nor the PHC mode-change notifications
carried such a time.

Observer.ModeChanged now takes the system time of the event behind the
transition: the sample's Sys (the estimated time of the pulse), the
read time of the time message that triggered leap detection, or when
carrier loss was seen, which the ts pause event now records. It is zero
for the initial transition at startup. Controller.TimeMessage and
Controller.Pause take those times from their callers, so phcsync still
never reads the clock itself.

sseobs sends a TimedEvent, an sse.Event with that time, on the event
bcast: the read time of the GPS message, the sample's Sys, or the mode
change's time. The SSE handler still writes the event as before and
ignores the time, so there is no change in behaviour.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-24T06:54:57.720064Z e210fb0 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

modeProc and TestSampleModeChangeTime were inserted between
TestTimeMessageDetectsLeap and its doc comment, so the comment
documented modeProc instead and the test had none.
@jclark
jclark merged commit 9168d6e into master Oct 24, 2026
10 checks passed
@jclark
jclark deleted the sse-event-time branch October 24, 2026 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant