fix(session_time): stop double-normalizing tz for fixed offsets (KI-35 follow-up)#72
Merged
Merged
Conversation
…KI-35 follow-up) The KI-35 fix (PR #70) passed an ALREADY-normalized tz string into pine_tz::ScopedTimezone, which normalizes again internally (normalize_timezone_for_posix, timezone.cpp). For fixed-offset tz inputs the normalizer flips the POSIX sign ("UTC+2" -> "UTC-2"), so normalizing twice flips it back ("UTC+2" -> "UTC-2" -> "UTC+2") and localtime_r then decodes the wrong wall-clock hour. IANA names and "UTC" are idempotent under normalize, so the bug was invisible to the corpus gate (0 offset-tz strategies), the lukeborgerding trade diff, and the NY/Phoenix/Kolkata DST unit test — every R7 probe used UTC or an IANA zone. Fix: detect UTC on the normalized string (as before) but hand the RAW tz to ScopedTimezone so it normalizes exactly once, matching the old inline lambda. Value-identity restored for offset zones: pine_hour/pine_dayofweek now equal the old setenv+tzset+localtime_r lambda for UTC±N / GMT±N as well as UTC/IANA (standalone A/B over 5 timestamps × {UTC+2,+3,+5,GMT+2,UTC}: all match; NY DST 8 EDT / 7 EST, Phoenix 5/5, Kolkata 17:30 unchanged). ctest 79/79. Blast radius = 5 data/draft strategies with offset-tz session logic (0 corpus). Re-verified all 5 with the fixed lib: mylivingedge-gold-asian-range minimal->excellent (its Asian window was mis-shifted by the double-flip), ananthanvelmurugan/evrinb7716/ltony excellent (held), andrewwieiw moderate (unchanged). Score 323->324, 0 minimal. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
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.
Bug (introduced by #70)
The KI-35 helper
decompose_ms_localpassed an already-normalized tz string intopine_tz::ScopedTimezone, which normalizes again internally. For fixed-offset tz inputs the normalizer flips the POSIX sign ("UTC+2"→"UTC-2"), so normalizing twice flips it back andlocaltime_rdecodes the wrong hour. IANA names and"UTC"are idempotent under normalize, so the bug was invisible to the corpus gate (0 offset-tz strategies), the lukeborgerding trade diff, and the NY/Phoenix/Kolkata DST unit test — every #70 probe used UTC or an IANA zone.Surfaced by the post-merge sweep flagging
mylivingedge-gold-asian-rangeexcellent→minimal: itstz = "UTC+2"Asian-session window (hour(time, tz)) was mis-shifted by the double-flip.Fix
Detect UTC on the normalized string (as before) but hand the raw
tztoScopedTimezoneso it normalizes exactly once — matching the old inlinesetenv+tzset+localtime_rlambda.Verification (fresh-context R7, GO)
pine_hour/pine_minute/pine_dayofweek== old lambda across {UTC, UTC+2, UTC+3, UTC+5, GMT+2, America/New_York, Asia/Kolkata, America/Phoenix} × 6 timestamps. DST anchors correct (NY 8 EDT / 7 EST, Phoenix 5/5, Kolkata 17:30).run_corpus.shrebuild → corpus submodule byte-identical, 0 changed outputs; NEW tiers == baseline (239 exc / 12 strong / 1 anomaly). Zero downward moves.Follow-up to #70.
🤖 Generated with Claude Code