Skip to content

security: session-day calendar boundaries + mid-UTC-day tz-offset memo - #160

Merged
luisleo526 merged 1 commit into
mainfrom
sec-history-offset
Aug 23, 2026
Merged

luisleo526 merged 1 commit into
mainfrom
sec-history-offset

Conversation

@luisleo526

Copy link
Copy Markdown
Collaborator

Round 2 of the symbol campaign (follows #159). Two coupled defects kept FX daily/weekly request.security series wrong while equities looked fine.

Defect 1 — calendar clock. D/W/M keys split at symbol-local midnight; TV forex candles run 17:00-ET → 17:00-ET (measured: all 472 TV probe triggers satisfied by the session-day cut, zero by any midnight cut — reconstruction in ledger finding 402 follow-ups). Calendar periods now ride the session-day clock. Equities coincide with local midnight, so their series are unchanged.

Defect 2 — tz memo poisoning. The per-UTC-day offset memo paired the local midnight with the query instant's UTC floor. Any bar whose local date straddles UTC midnight (every FX evening bar) seeded the whole UTC day with −20h instead of +4h — splitting every HTF candle in two with a spurious boundary completion and a bogus evening-fragment close. The memo now samples at mid-UTC-day: constant and correct all day, DST-safe (transitions land while session markets are closed).

Evidence @ 46d4f64 (codegen unchanged at 726a0f4):

lane result
EURUSD probes htf-bucket-d 8.6% → 100% (471/471), 240m 76% → 100% (1296/1296)
EURUSD population e+s 307 → 327 (+20); ups 36 / downs 34
AAPL population e+s 241 → 246; ups 18 / downs 16
ETH scraped 396/396 excellent, 0 up / 0 down (fresh grade at this tree)
ETH corpus 312/312 ok, 309/2/1 identical tiers, zero regressions (fresh run)
unit tests 133/133

Known residual (next round): probe-vs-tv on the EURUSD daily probe reports 10 engine-only fills beyond TV's export window edge (window-edge mechanics, not level semantics); weekly FX anchor uses ISO-Monday of the session-day clock vs TV's Sunday-17:00 week start — W probe still divergent, queued.

Symbol-gate PASS · pr-gate PASS (tie carried by trendmatrix MATCH probe, 822/822).

Two defects kept FX daily/weekly request.security series wrong while
equities looked fine:

- Calendar D/W/M keys split at symbol-local midnight; TV forex candles
  run 17:00-ET -> 17:00-ET (measured 472/472 TV triggers satisfied by
  the 17:00 session-day cut, zero by local-midnight cuts). Calendar
  periods now ride the session-day clock; equities coincide with local
  midnight, so their series are unchanged.
- The per-UTC-day tz-offset memo paired the LOCAL midnight with the
  QUERY instant's UTC floor: any bar whose local date straddles UTC
  midnight (FX evenings) seeded the whole UTC day with a negative
  offset, splitting every HTF candle in two with a spurious boundary
  completion + bogus fragment close. Sample the offset at mid-UTC-day:
  constant, correct, DST-safe.

24x7 symbols return before the memo (ETH byte-identical); equity RTH
bars never straddle a UTC date (values identical).

Evidence @ this tree: EURUSD htf-bucket probes D 8.6%->100% (471/471),
240m 76%->100% (1296/1296); population e+s EURUSD 307->327 (+20), AAPL
241->246; ETH scraped 396/396 zero moves; corpus 309/2/1 identical,
zero regressions; 133/133 unit tests.
@luisleo526
luisleo526 merged commit 93d3e53 into main Aug 23, 2026
pull Bot pushed a commit to Malumbo21/pineforge-engine that referenced this pull request Sep 5, 2026
…kets live; REVIVE-B closes a frozen full leg (round 7 family N, M2)

Note log-20260905t112259z-33f32db4. On a bar whose OPEN carries a declined
all-in reversal, TradingView's sequence is decline -> brackets dormant ->
margin slice -> REVIVE-B, so the position's resting stop is live again for
the rest of the bar and fills at its level; at an adverse-extreme cascade a
revived, now-marketable bracket closes the remainder AT THE SLICE PRICE on
the same bar (finding-311 CASCADE).

Two engine gaps:

1. dispatch order. margin_call_slice_at_bar_open runs at the broker-open
   boundary (engine_run.cpp) BEFORE the order loop declines the reversal
   (mark_position_brackets_dormant_on_declined_reversal), so the open
   slice's revive found nothing dormant and the kill then silenced the
   stop for the bar: algoai 10-30 13:30Z printed 1 @271.96 then 176
   @274.11 at the cascade and a next-bar close, where TV (and the
   no-reversal lab tv tape scratchpad/r7/pins/aapl15-mcopen1-stop-algoai,
   identical rows) prints 1 @271.96 then 'X' 2814 @273.69 at its level.
   Now the kill stands down on a bar whose open slice left a survivor
   (open_margin_slice_bar_): kill + revive net to live.

2. REVIVE-B's marketable check accepted only a deferred default leg
   (qty NaN, 100%). fast-scalper's 'X' stop was re-issued in position at the
   07-18 18:45Z crossunder, so it carried the frozen whole-position qty and
   was skipped: 268 @214.86 'Margin call' then the remainder next bar
   @214.68, where TV (pineforge-4pass#160/161) closes 4621 @214.86 on the same bar. A
   frozen leg that was not a requested partial, or that covers the whole
   survivor, now cascades too. Control tape aapl15-mcext-stop-scalper-b
   (no reversal): the stop fills at its level 212.83, no 07-21 slice —
   unchanged.

tests/test_aapl15_margin_brackets.cpp: C. algoai 10-30 (the pin tape + the
probe's declined ema9/21 reversal: 76 / 1 @271.96 / 'X' 2814 @273.69),
D. fast-scalper 07-21 (268 @214.86 + 'X' 4621 @214.86 same bar, no long).
ctest 177/177; no existing expectation moved.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01K8DaPQu4hNi5SZR7r8FhJz
@luisleo526
luisleo526 deleted the sec-history-offset branch October 5, 2026 02:44
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