Skip to content

fix(glue): count prints on the printer's clock when it runs behind (Refs #770) - #775

Merged
alex-mextner merged 2 commits into
mainfrom
fix/770-printer-clock-skew
Nov 18, 2026
Merged

alex-mextner merged 2 commits into
mainfrom
fix/770-printer-clock-skew

Conversation

@alex-mextner

Copy link
Copy Markdown
Owner

Moonraker job start times are on the printer's clock; the glue time is on this computer's. The history reader now reads the printer clock from the first history reply's Date header. A printer behind by more than the Date rounding (2 s) moves the glue cutoff onto the printer clock and re-reads the history from there (one shared 15 s deadline; a failed second read keeps the first read's jobs and failure). A printer ahead keeps the host cutoff, so a clock that jumped after the glue cannot hide prints. A skew over a minute makes the count an estimate (~N) with a note shown by 3d glue status: "the printer clock is 1h 00m behind this computer's; the count may include prints from up to 1h 00m before the glue".

Regression tests: printer one hour behind (5 prints counted, ~5 with the note), one hour ahead, within a minute (exact), Date-rounding, failed/metric-less second read, shared deadline, malformed/overflowing Date.

Refs #770

@alex-mextner

Copy link
Copy Markdown
Owner Author

Acceptance proof for #770 (head of this PR):

tests/test_printer_ops_glue.py::test_prints_after_a_clock_rollback_are_still_read PASSED
tests/test_printer_ops_glue.py::test_prints_after_the_glue_on_a_printer_clock_an_hour_behind_are_counted PASSED
tests/test_printer_ops_glue.py::test_a_printer_clock_within_a_minute_keeps_the_count_exact PASSED
tests/test_printer_ops_glue.py::test_the_reply_date_header_is_read_as_the_printer_clock PASSED
tests/test_printer_ops_glue.py::test_a_failed_read_on_the_printer_clock_keeps_the_prints_the_first_read_saw PASSED
tests/test_printer_ops_glue.py::test_the_read_on_the_printer_clock_shares_the_history_deadline PASSED
tests/test_printer_ops_glue.py::test_an_overflowing_date_header_is_ignored PASSED
tests/test_printer_ops_glue.py::test_a_printer_clock_ahead_never_hides_prints_after_the_glue PASSED
tests/test_printer_ops_glue.py::test_a_print_just_after_the_glue_on_a_clock_seconds_behind_is_counted_exactly PASSED
tests/test_printer_ops_glue.py::test_date_header_rounding_keeps_the_exact_glue_cutoff PASSED
tests/test_printer_ops_glue.py::test_a_first_read_failure_stays_after_a_clean_read_on_the_printer_clock PASSED
====================== 11 passed, 93 deselected in 0.43s =======================

Criterion 1: test_prints_after_the_glue_on_a_printer_clock_an_hour_behind_are_counted — printer 1h behind, 5 prints after the glue: asserts (count, exact) == (5, False) and the note "printer clock is 1h 00m behind".
Criterion 2: 3d glue status prints prints.note under the prints line (lib/printer_ops/glue.py, status renderer); the note is set whenever the clocks differ by more than a minute (test_a_printer_clock_within_a_minute_keeps_the_count_exact pins the under-a-minute side).

@alex-mextner
alex-mextner force-pushed the fix/770-printer-clock-skew branch from 8a8b20f to 8ac3369 Compare November 18, 2026 13:42
@alex-mextner
alex-mextner merged commit 6e2de8c into main Nov 18, 2026
11 checks passed
@alex-mextner
alex-mextner deleted the fix/770-printer-clock-skew branch November 18, 2026 14:38
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