Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(session_time): stop double-normalizing tz for fixed offsets (KI-35 follow-up)#72

Merged
luisleo526 merged 1 commit into
mainfrom
fix/ki35-offset-tz-double-normalize
Jul 7, 2026
Merged

fix(session_time): stop double-normalizing tz for fixed offsets (KI-35 follow-up)#72
luisleo526 merged 1 commit into
mainfrom
fix/ki35-offset-tz-double-normalize

Conversation

@luisleo526

Copy link
Copy Markdown
Collaborator

Bug (introduced by #70)

The KI-35 helper decompose_ms_local passed an already-normalized tz string into pine_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 and localtime_r decodes 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-range excellent→minimal: its tz = "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 tz to ScopedTimezone so it normalizes exactly once — matching the old inline setenv+tzset+localtime_r lambda.

Verification (fresh-context R7, GO)

  • Value-identity 48/48: 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).
  • Corpus: full run_corpus.sh rebuild → corpus submodule byte-identical, 0 changed outputs; NEW tiers == baseline (239 exc / 12 strong / 1 anomaly). Zero downward moves.
  • ctest 79/79.
  • Sentinels: lukeborgerding exc, stockhunter strong, 3commas-pol-grid exc — unchanged.
  • Blast radius = 5 data/draft offset-tz strategies, 0 corpus: mylivingedge minimal→excellent, ananthanvelmurugan/evrinb7716/ltony excellent (held), andrewwieiw moderate (unchanged). Score 323→324, 0 minimal.

Follow-up to #70.

🤖 Generated with Claude Code

…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]>
@luisleo526 luisleo526 merged commit 725067f into main Jul 7, 2026
5 checks passed
@luisleo526 luisleo526 deleted the fix/ki35-offset-tz-double-normalize branch July 7, 2026 05:22
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