Repository navigation
Unify CEL today() onto the UTC clock - #2914
Merged
Merged
Conversation
today() read Local::now() while days_since()/days_until() read Utc::now(), so a condition like `node.due_date == today()` and `days_until(node.due_date) == 0` could disagree near a day boundary depending on the host's timezone offset. Make today() read Utc::now() too. UTC wins over local because a rule can run on any device in a synced setup, and there is no single "local" all devices could agree on; a UTC day boundary is the same instant everywhere. The rationale is recorded as a comment at the function definitions in cel.rs. Adds tests pinning the agreement (days_until(today()) == 0, days_since(today()) == 0) and a direct check that today() reads the UTC clock, verified under a non-UTC TZ. Co-Authored-By: Claude Sonnet 5 <[email protected]>
- today_and_days_until_zero_agree_on_the_same_clock / today_and_days_since_zero_agree_on_the_same_clock evaluate `days_until(today())`/`days_since(today())`, which makes two unsynchronized Utc::now() reads. A UTC midnight tick landing between them would make a correct implementation observe a 1-day mismatch; retry once rather than accept that sub-microsecond-window flake. - The UTC-clock rationale comment was a `///` doc comment with no blank line before `fn cel_days_since`, so rustdoc attached it to that function alone rather than as a standalone section comment, making cel_today()'s "see the module comment above" cross-reference misleading. Changed it to a plain `//` comment block and reworded the cross-reference. Addresses reviewer recommendations from /pragmatic-code-review on PR #2914 (both low severity). Co-Authored-By: Claude Sonnet 5 <[email protected]>
Contributor
Author
Address ReviewRan `/pragmatic-code-review` (medium effort) on PR #2914. Both findings were low severity; addressed both:
Re-Review DecisionDecision: NO RE-REVIEW NEEDED Rationale: Both changes are low-risk, localized, non-functional fixes to test robustness and doc-comment accuracy within the same file already reviewed — no new logic, no architectural change, no new call sites. Full test suite ( Ready for merge. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
today()readLocal::now()(the host machine's local timezone) whiledays_since()/days_until()readUtc::now(). Near a day boundary, that means a condition likenode.due_date == today()anddays_until(node.due_date) == 0— which read as equivalent to a Play author — could disagree, depending on the host's offset from UTC.Change
today()now readsUtc::now(), matchingdays_since()/days_until(). All three CEL date functions now agree on the same clock.chrono::Localimport frompackages/core/src/playbook/cel.rs.today()no longer matches a user's own calendar day exactly at the UTC boundary.architecture/playbook-system.mdandarchitecture/playbook-engine.mdinnodespace-docs(pushed directly tomainper that repo's own workflow) to state the UTC clock explicitly for all three functions —playbook-engine.mdwas also stale, still describingtoday()aschrono::Local::now().Tests
today_reads_the_utc_clock_not_the_host_local_clock— direct check thattoday()'s value matches an independently computedUtc::now()date, not local time.today_and_days_until_zero_agree_on_the_same_clock/today_and_days_since_zero_agree_on_the_same_clock— pin the exact agreement the issue describes (days_until(today()) == 0/days_since(today()) == 0), reproducing the Play-author scenario from the issue.TZ=Pacific/Auckland(the timezone the issue's linked flake reproduced under) to confirm the fix holds outside UTC.Closes #2843
Co-Authored-By: Claude Sonnet 5 [email protected]