Skip to content

Commit 0411892

Browse files
luisleo526claude
andauthored
INT30: engine integration of the tail lanes (TAIL-A, B, C, D, E, G, H) (#297)
* TAIL-B AS: a bar's adds are each judged beside the held position, and the grown book is called once after the last TradingView treats the MARKET entries one bar places on top of a position of their own side (a grid bot's adds) as a group: - AS: each add is judged against the position held when it was placed plus its own units, not against a sibling filled a moment earlier at the same point. Rule COQ admitted a next-open add that way; under process_orders_on_close the adds fill at the close and are admitted alike (validate_precommit, same_point_as_placed, src/source/pine_adapter.cpp:14000). - AC: the grown book is margin-called once, after the last add has filled, four times its lot-floored shortfall -- not a call after each add. A market add's call is taken at that fill (on_applied :20011-:20105, add_entry_row :15381, add_sibling_fill_follows :15477, add_sibling_lots :15495), a commissioned explicit short's too, at the print its fill slipped from (:20037). Under process_orders_on_close the call is taken at the next open, sized at the close the adds filled at, long (:17828, :17834) or short (:17944). Tapes: tests/fixtures/add_sibling_margin, ten lab tv --no-note exports of synthetic probes on BINANCE:ETHUSDT.P 15 (tailb-adds-{pooc,mkt}-* x8, tailb-loss-{pooc-c6s3,mkt-c10s2}); tests/test_add_sibling_margin_tapes.cpp replays each and requires every closed trade to be the engine's. Built against 8988faff's library: 5919 passed, 10 failed (every row); on this commit: 6916 passed, 0 failed. No new durable state: the rules read the placement rows and the book's live lots. The shape is the 3Commas grid bots' (job-2758 BTCUSDT 15, ETHUSDT.P 1D and 15; the ena, ton, eth, nvdax, trx and eurusd grid bots on the daily lanes). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit 921ffd643cbf25cc263a277ce359bcdedb7acf0d) INT30 pick note: TAIL-B 1 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * TAIL-B LF: a call that closes several lots of a long takes the broker's follow-up After a margin call that closes several lots of a long, TradingView's broker checks the book again after each lot, first in first out, on a state that has taken the lot out of the book but not yet booked its P&L: that lot relieves the shortfall by its cost (its entry fee was booked when it opened), each lot before it, booked, by what its sale fetched net of its exit fee. The last check that is still short is called again, four times its lot-floored shortfall. A call that starts inside a lot costing more than the shortfall is not followed, which is why the one-seed and two-seed books of rule AS take none. Mechanism: lagged_margin_follow_up_units (src/source/pine_adapter.cpp:14746), taken for the adds' book at the same open under process_orders_on_close (on_bar_open :17907) and at the bar's next path point after a market call (on_applied :20233). A long on a fractional lot grid only, at a percent commission or none; a whole-unit book's follow-up stays whole_unit_follow_up_due's. Tapes: tests/fixtures/add_sibling_margin tailb-lots12-pooc-c0s0, tailb-lots30-pooc-c10s3, tailb-lots30-mkt-c10s2 (lab tv --no-note, synthetic, BINANCE:ETHUSDT.P 15). The same rule reproduces both calls of seven further scratch lots probes (12 to 50 seeds, fees or none) and every call pair of the 3Commas grid bots on the BTCUSDT and ETHUSDT.P daily lanes (ton 2025-12-02 0.00808 + 0.0062, eth-grid 2026-03-09 0.8144 + 0.2784, ena 2026-02-06 0.606 + 0.032, ...). The test built against 921ffd64's library: 7438 passed, 3 failed (the three LF rows); on this commit: 7450 passed, 0 failed. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit f5a0cf9afc42aaf9bbe35d10e06ab7701b4e924a) INT30 pick note: TAIL-B 2 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * TAIL-A ND: an N-day request.security bar groups the symbol's trading dates N at a time from each year's first TradingView builds request.security(syminfo.tickerid, "<N>D", expr) bars from the symbol's trading dates, N at a time, counting from the first trading date of every calendar year; the year's last bar ends at the year's end. The trading dates are the session calendar's: every day on a 24x7 symbol, every weekday on OANDA's (a holiday too: the 8D bars of EURUSD and XAUUSD open on 2025-12-25 and 2026-01-01, dates their charts have no bar of), the exchange's sessions on a stock or an index (NYSE:F's 8D bar of 2025-04-17 runs through 04-29 over Good Friday; NSE's 2025-10-21 Muhurat session opens its bucket at 13:45 IST, its own daily bar's time). Pinned by six lab tv --no-note tapes of a synthetic read-out probe, 2024-01-01 .. 2026-05-01 on the 1D chart (tests/fixtures/multi_day_buckets): every "2D", "3D", "5D", "8D" and "13D" bucket open, on every chart bar. The Pine host's calendar aggregator keyed "8D" as "D" (crosses_boundary ignores the multiplier), so an 8D request read one day: talaeaelhussein-prop- scalper-v2-final's non-repainting "8D" stream crossed daily. The source adapter now installs TradingView's buckets as the aggregator's period partition (the existing TimeframeAggregator::set_native_periods seam), from the trading dates the run holds -- the chart's bars and the auxiliary feed's, an exchange calendar's sessions, a weekday outside them -- through the year after the last held date. An N-day site stays on the host's drive: the kernel's N-day period is a fixed grid of calendar days. No kernel file changes. The stamps are a function of the run's inputs; no durable state is added. One session-day resolution per trading date keeps an OANDA 1D run with its 1m auxiliary feed at 4 s (a resolution per auxiliary bar took 140 s). tests/test_security_multi_day_buckets_tapes.cpp replays the six tapes through a port of the probe: 3321 checks pass. Against 8988faff it fails 3295 of them (first: ETHUSDT.P bar 2024-01-02, engine 19724 where TradingView reads 19723). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit 2fda37686cd7c1a82fc7606902704f715d719192) INT30 pick note: TAIL-A 1 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * TAIL-G: requests of other symbols on a daily chart stamped in its session's break read the chart bar's own period OANDA stamps its XAUUSD daily bars at 17:00 ET, inside the break of the 1800-1700 session. The kernel hands an instrument series the feed bars visible at its input's calendar interval, and reads such a raw label as the session that closes at it (test_daily_stamp_in_the_break pins that generic reading). So on the OANDA:XAUUSD 1D chart a lookahead-off request of another symbol read the bars closed by 17:00 ET on the label's day, one requested bar late, and a lookahead-on hourly or four-hour request the bars opened by the previous session's 18:00 ET, a session early. TradingView merges by the chart bar's own period: the last requested bar closed by the chart bar's time_close, the next 17:00 ET (lookahead off), and the last one opened by its time, 17:00 ET (lookahead on, an intraday requested timeframe). The five xauusd-1d probes of alcivooo (minimal), curiousmacrox, job-2123, job-2586 and job-2942 (weak) read their VIX, US10Y, USDT.D and DXY requests one bar late or a session early; each of those scripts is strong or better on every other lane, where the chart bar's stamp opens its own session and the two readings agree. The Pine adapter now gives TradingView's reading on a D, W or M chart (read_ahead_foreign_security_sites, src/source/pine_security_eval.cpp): at each chart bar's open, after the input's deliveries and before the bar's calc_on_order_fills checkpoint, it runs every feed bar that rule makes visible and the kernel has not handed over yet, in feed order, against the chart bar's time_close (chart_bar_close_ms, the rule chart_time_close already reads); the kernel hands those bars over again on a later input and the site skips them by feed index (ForeignSecuritySite::handed, folded into the source symbol-data hash). The kernel's delivery rule is unchanged, and a lookahead-on request of a D/W/M timeframe, which TradingView aligns by trading date, keeps the kernel's reading. TradingView tape (lab tv --no-note, OANDA:XAUUSD 1D, 2025-04-01.. 2026-05-01, tests/fixtures/daily_break_close/tg-xau1d-requests): the nine request shapes of those probes, each read bar's time and time_close spelled per chart bar; all 277 readings of each shape follow the rule. With the probes' pinned feeds the lane's replay of the tape matches 277 of 277 exit comments (base: 0). tests/test_foreign_break_stamp_tapes.cpp rebuilds, per shape, the bars each reading names and reads them back through a Pine host's foreign site on the tape's chart bars, for this tape and the two TVC:DXY tapes of lane W11-ENG-TIME-COLOR: 12 shapes, 0 reads differ. Compiled against the base 9e6196ca it fails, 12 failures (first: tg-xau1d-requests field 1 at 1743627600000 reads na where TradingView reads [1743664500000, 1743711360000]; 275 of 277 differ there). The lane's replica of the Cloud Run grade (lab c67929cc, the probes' pinned requests manifests): the five xauusd-1d probes grade excellent, 100% match (base: minimal, weak 55.6, 40, 37.5, 33.3). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit bded86be1cf10835b4832513b7ec8ef1ab70f14e) INT30 pick note: TAIL-G 1 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * TAIL-B: the fixture README names every scratch probe the follow-up rule was checked on Rule LF's README section said "seven further lots probes (12 to 50 seeds, fees or none)". The rule was checked on thirteen scratch lots tapes: seven without fees (12 to 50 seeds), three at commission 0.1 % and slippage 3 (10, 30 and 60 seeds; the 10-seed book takes no follow-up because its oldest seed costs more than the shortfall), two with the commission or the slippage alone (30 seeds) and one market twin (30 seeds). Documentation only; no code or tape changes. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit f95385fbd16933904e37ac92349493f75a69fe12) INT30 pick note: TAIL-B 3 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * TAIL-D M1: a close the recalculation of a mid-leg fill places fills at the end of that leg, `immediately` or not Under calc_on_order_fills a fill inside a leg of the bar's path starts a recalculation there, and TradingView fills a close that recalculation places at the END of the leg (the next extreme), at its print, with `immediately = true` as without it: the td-m1a, -c and -d tapes are one trade list. - close(): an `immediately` close placed by the recalculation of a fill inside a leg (not the first open's, and not a fill on a point of the path) takes the path of the same close without it; the adapter executed it at the recalculating fill's own price. A fill on a path point keeps the close there, as test_calc_on_order_fills' PoocCursorTimingProbe and RecalcChainBudgetProbe (fills at the open) require. - close_all(): the trigger rests at the raw extreme when the next waypoint is one, the booked tick riding forced_execution_price, as close(id) already did. On NYSE:F the next extreme can sit between two cents (H 9.445 booked 9.45): the close_all rested at the booked tick, which the path never reaches, and rolled to the bar's close. Target: niravdpatel5588-nifty-spot-fibonacci-signals-2-lots-t1-and-t2-quote-ccy (NYSE:F 15). Tapes: tests/fixtures/coof_immediate_close, td-m1a .. -d on BINANCE:ETHUSDT.P 15, td-m1h and -i on NYSE:F 15. test_coof_immediate_close_tapes against the base 8988faff: -a, -b and -d book the rest at TP's fill price (8, 22 and 8 rows), -h books 5 rows at the bar's close or TP's price; here every row passes. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit 3ce9e116a66441c13a1677d95fb877c862bb2c6f) INT30 pick note: TAIL-D 1 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * TAIL-D M1e: every exit one path point triggers fills there before that point recalculates Under calc_on_order_fills TradingView fills every exit of one entry that the same path point triggers before the point recalculates: two exits of one position sharing a stop level both fill at it, even when the recalculation of the first fill calls strategy.cancel_all() and strategy.close_all(). The engine recalculated after the first fill, whose cancel_all() withdrew the second exit before the kernel reached it. - suppress_grouped_stop_recalc: a filled exit of a from_entry whose sibling exit (another id of the same entry) is triggered at the same price -- on the tick grid, the kernel's raw print against the script's level -- defers the recalculation to that sibling's fill. Target: niravdpatel5588-nifty-spot-fibonacci-signals-2-lots-t1-and-t2-quote-ccy (NYSE:F 15). Tapes: tests/fixtures/coof_same_point_exits td-m1e, -f and the control -g (BINANCE:ETHUSDT.P 15). test_coof_same_point_exits_tapes against the base: -f closes X2's unit at the next extreme (-e's failure is masked at the base by the immediately close); here every row passes. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit 7cccb1fa2b24a8a0402d4d21e6dff87f8f08ccf4) INT30 pick note: TAIL-D 2 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * TAIL-D M2: a resting entry's bracket the recalculation of its mid-leg fill re-issues keeps its stop live at its level Under calc_on_order_fills a limit entry that fills inside a leg starts a recalculation there; the bracket the script placed while the entry rested becomes live at the fill, and TradingView fills its stop at its level on the rest of that leg -- also when the recalculation re-issues the bracket, its limit changed or unchanged and the stop the same. The adapter took the re-issued stop for an exit born in the recalculation (KI-67), held it to the end of the leg and booked it at the extreme. - exit(): a stop leg the recalculation re-issues at the level its live, unforced order already rests at is not held on the in-flight leg; one an earlier recalculation holds stays held. Target: mehmettopbas-ict-10am-first-fvg-daily-strategy (NSE:NIFTY 15). Tapes: tests/fixtures/coof_resting_bracket td-m2a, -b and the control -c (BINANCE:ETHUSDT.P 15). test_coof_resting_bracket_tapes against the base: -a and -b book the stop at the leg's extreme; here every row passes. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit df6a44bec5c9f8fd2cf5675001414153a26b29e8) INT30 pick note: TAIL-D 3 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * TAIL-D M3: timeframe.change() compares every calculation of a recalculated bar with the bar before it timeframe.change("D") compares the script bar with the bar before it, on every calculation of the bar. Under calc_on_order_fills a fill's recalculation publishes its bar ahead of the bar's close, and the host moved the previous-bar clock (prev_bar_timestamp_) onto the bar itself there: the bar's close calculation then saw no day change. TradingView resets a day's counter on the close of a day's first bar that a fill recalculated. - PineScheduler::recalculate restores the previous-bar clock after the recalculation (and on its error path); the close of a bar that was recalculated moves the clock once the close has published. Target: niravdpatel5588-nifty-spot-fibonacci-signals-2-lots-t1-and-t2-quote-ccy (NYSE:F 15). Tape: tests/fixtures/coof_timeframe_change td-m3a (BINANCE:ETHUSDT.P 15, 2025-04-01 .. 2025-04-15). test_coof_timeframe_change_tapes against the base: no B enters on the 13 days A's stop filled on the first bar; here every row passes. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit 3ac1210f03e309e60c72074554ad4738ae897422) INT30 pick note: TAIL-D 4 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * TAIL-D M6: a qty= exit of an entry a reversal holds in the adapter waits for that entry TradingView reserves a qty= strategy.exit on its own entry's quantity and pairs the position it closes first in, first out: an exit of entry B that fills while entry A still holds its last unit closes A's lot, and A's own second exit still fills later, closing B's oldest lot. When A is the reversal a strategy.close() of the held short and strategy.entry("A") place on one bar, A waits in the adapter for that close; its exits reached the book at once, bound to A's cohort, and after the FIFO close left that cohort no lot, A's second exit never filled. - flush_pending_bracket_legs (pyramiding 2 rebinding): a leg whose parent cohort has no lot yet while an opening entry of the same id, placed on the same script bar and earlier in command order, waits in pending_entries_, stays pending with its projection bar pinned, as the legs of an entry pending on a flat book do; the parent's opening settles them against the whole position. Target: thulashimohanr-prev-day-week-levels-or-vwap-strategy (OANDA:XAUUSD 15). Tapes: tests/fixtures/exit_fifo_cross td-m6a (control) and td-m6g (BINANCE:ETHUSDT.P 15). test_exit_fifo_cross_tapes against the base: -g holds B's first lot to the 14:30 close_all; here every row passes. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit a93610cd41e3ffad6d0ca60fa695669f78a0d246) INT30 pick note: TAIL-D 5 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * TAIL-D FP17: an exit limit the recalculation of an entry's open fill places at or through the open print fills there Under calc_on_order_fills the recalculation of an entry's fill at the bar's open places the exits a script issues once a position exists. TradingView fills such an exit limit at once when it sits at or through the open print -- at the print, without slippage, on the entry bar -- and rests one short of the print at its own level for the rest of that bar. The adapter judged both against the slipped entry fill and held them for the next bar. - exit(): in a first-open recalculation, a limit at or through the open print executes there (trigger at its level, booked at the open's tick, held as a leg-end newborn); one short of it rests at its level instead of being deferred. Target: finnp17-cleantradequantum-v7-2-ob-fvg-integrated (NSE:NIFTY 1D). Tape: tests/fixtures/coof_open_limit td-fp17-coof-open (NSE:NIFTY 1D, 2025-05-01 .. 2025-08-01, slippage 2). test_coof_open_limit_tapes against the base: cells LA, SB, LE and LG exit on a later bar; here they pass. Recorded, not fixed: cells LC and SD (a strategy.close at that recalculation), which TradingView fills at the open print minus / plus its own slippage and the engine books from the slipped entry fill, two ticks off. The frozen twin test_calc_on_order_fills_l4c (and its legacy copy) pinned the adapter's carry on two rows: RecalcEntryBarBracketProbe's through limit (104 on bar 2) and the through limit ahead of a valid stop (the stop's 95). Both now book the open print 100 on bar 1, as cells LE and LA do on TradingView; the rows are corrected with that attribution, the two test functions renamed after what they now show, and the twin inventory's observable rewrite for test_calc_on_order_fills carries the reason and the new assertion digest (INVENTORY_SHA256 re-pinned in check_twin_parity.py). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit e3cc6f68f2916a02f22695bea13e5df79758b636) INT30 pick note: TAIL-D 6 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * TAIL-D X1: a strategy.exit call that names a level withdraws the price leg it leaves na A strategy.exit call that names a level replaces the whole exit order: a price leg the new call leaves na is withdrawn on TradingView, a stop and a limit alike. The adapter re-issued only the levels the call named and kept the old leg resting; the legacy route erased every leg of the exit id before re-creating it (ab9714be pine_strategy_commands.cpp clear_existing_exit_order). - exit(): after an absolute leg is placed without a trail request, a live or pending leg of the same exit id and from_entry whose family the call leaves na (no price and no ticks) is cancelled and retired, and dropped from pending_bracket_legs_ and delayed_market_orders_. Targets: fran-pineda-strategy-501-de-franpineda and fran-pineda-strategy-502-de-franpineda (OANDA:XAUUSD 15). Tape: tests/fixtures/exit_reissue_na fran-x1-exit-reissue-na-limit (OANDA:XAUUSD 15). test_exit_reissue_na_tapes against the base: CX's dropped stop fills at 3336 and AX's dropped limit at 3332.95; here the row passes. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit e0bb1d7abf32b4db4b48791b0bbf69691f0b1563) INT30 pick note: TAIL-D 7 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * TAIL-D H1: a flat pair of opposite fixed-quantity market entries over the equity keeps only its earlier call, with costs and without COOF A flat script that places two opposite fixed-quantity market entries on one bar keeps only the earlier call on TradingView when the pair's gross is over the equity at full margin; a pair that fits keeps its two-leg shape. The adapter's gross decline held only under calc_on_order_fills, without slippage and without commission; under process_orders_on_close alone, or with costs, the later call became a full reversal. - apply_terminal_explicit_market_policy: the clean pair no longer requires calc_on_order_fills, zero slippage or zero commission. Target: officialjackofalltrades-helios-institutional-synthesis-strategy-joat (OANDA:EURUSD 1D: slippage 1, a 0.01 % commission, two engine-only reversals). Tapes: tests/fixtures/pooc_pair_gross hel-h1-pooc-pair-gross-slip and hel-h2-pooc-pair-gross-zero (OANDA:EURUSD 1D). test_pooc_pair_gross_tapes against the base: every over-equity pair books a reversal (long first) or a double-size buy (short first), 188 engine rows against 140; here both rows pass. The frozen twin test_pooc_coof_reversal_gross_admission_l4c (and its legacy copy) listed the three configurations as scope exclusions keeping the legacy two-trade result; they now expect the decline (one trade), and the header says so. The assertion texts are unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit 486c517a99fd9e956ea3e4e16c59ccbd8a790f09) INT30 pick note: TAIL-D 8 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * TAIL-D JD: a default all-in entry whose whole lots tie the rounded equity is dropped flat and keeps its closing leg as a reversal, whatever the next open does A default percent_of_equity (100 %) market entry on whole lots is sized on the signal's equity rounded to ten significant digits. When that rounding ties -- the whole lots it sizes cost more than the equity -- TradingView drops a flat entry and keeps only the closing leg of a reversal, whatever the next open does. The adapter applied the tie only when the next open equalled the signal close (ab9714be's no-gap clause) and dropped a reversal whole, so a gapped reversal went on to the all-in fill check and was refused: the long was held. - resolve_terms, whole_lot_tie_scope: the equity is compared exactly with the units times the signal close, the next open aside; a reversal keeps its closing leg (opposite_book_units, CloseOpposite), a flat entry is dropped. - The equity is the capital plus the realized profit plus the open profit in floating point, whose residue decides an exact tie: the jd-drift tapes, where a realized loss and the capital sum one ulp under or over their cent value, tie and do not. A running sum of many closed profits carries a residue of its own the engine does not reproduce. On the population, an exact tie on which the engine's sum and that sum on the money grid (source_money_round, read while the book is still the signal's) disagree is taken by TradingView on some books and not on others: antoniolinux-obv-with-sma-and-max-50gg (NASDAQ:AAPL 15) and taro-s-rsi-ma-signals-on-chart (NYSE:F 15) not, with the engine's sum under and over its cent value; job-2553-ttagkoin-adaptive-multi-factor-v1- update-9-years (NYSE:F 15) yes. There the adapter keeps the no-gap rule it had; the rule above applies where both agree. Comparing either sum alone moved one (the engine's) or seven (the money grid's) excellent NYSE:F and NASDAQ:AAPL probes to strong on Cloud Run replays; with both, the local lane replicas of all eight are excellent again. Target: jaydeepp095-candle-harry (NYSE:F 1D). Tapes: tests/fixtures/whole_lot_tie jd-rev-tie-pair, -notie-pair (control), -tie-bare, -tie-gapdown, -tie-nogap, jd-flat-tie-gapdown, jd-drift-under and jd-drift-over (NYSE:F 1D). test_whole_lot_tie_tapes against the base: the tie-pair, -bare, -nogap and -drift-under reversals hold the long, the gapdown reversal fills whole, the flat tie entry fills (6 rows fail); here every row passes. The frozen twin test_high_value_signal_cost_l4d (and its legacy copy) expected the integer-lots context of its XAU flat entry -- 300 lots at the 3443.625 signal close, 1033087.5 against 1033087.4999 -- to be admitted; that is jd-flat-tie-gapdown's tie, which TradingView drops. The context leaves the admitted loop and its own two rows assert the drop; the loop's assertion texts are unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit 1292f4ff7b1fc6a5d7b014816eb3c587957c8932) INT30 pick note: TAIL-D 9 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * TAIL-D M7: what the recalculation of a mid-leg fill cancels or closes applies at the end of that leg Under calc_on_order_fills TradingView applies what the recalculation of a mid-leg fill cancels or closes -- strategy.cancel, strategy.cancel_all, a full strategy.close -- at the END of that leg: an exit resting from before whose level the rest of the leg reaches still fills there, at its level, and one the leg does not reach is gone after it. The adapter withdrew the exit at once. Since M1 holds the recalculation's close to the leg's end, that close then took the position at the extreme instead of the exit at its level: job-2898-repost64-orb-meeeeeks-quote-ccy (BINANCE:BTCUSDT 15, TP1's recalculation calls cancel_all() and close(immediately = true)) fell from strong to moderate on M1 alone. - coof_leg_reaches_exit: in a mid-leg recalculation (not the first open's), an ExitLimit or ExitStop whose level lies strictly past the current print and no further than the leg's end, on the side it waits on. - cancel(), cancel_all() and cancel_exit_orders_for_full_close() leave such an exit live; the kernel fills it on the rest of the leg. Tapes: tests/fixtures/coof_inflight_cancel td-m7a (cancel_all and close immediately), -b (cancel_all), -c (cancel("TP2")), -d (close immediately, no cancel), BINANCE:ETHUSDT.P 15. test_coof_inflight_cancel_tapes against the base: -a and -d close the rest at TP1's fill price in four cells, -b and -c withdraw TP2 in the two cells whose TP2 the rest of TP1's leg reaches; with M1 alone -a and -d took those two cells' rest at the leg's end; here every row passes, and the job-2898 BTC probe replays excellent (strong at the base). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit f0cc890df48d7314e0fd2f24bdde26665dd158d2) INT30 pick note: TAIL-D 10 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * ta.percentile_*: TradingView's persistent window; ta.percentrank reads an na bar as 0 (TAIL-H) TradingView keeps the window of ta.percentile_nearest_rank and ta.percentile_linear_interpolation in one array across bars: once `length` values are held, the value `length` bars back leaves at its first occurrence (na matching na) and the new value enters before the first held element greater than it, so the non-na values stay ascending and an na enters last. The engine re-sorted a copy of the chronological window every bar with std::sort, whose order is unspecified once na is in the window: the mm-mitsuya norn-weave scripts' ta.percentile_nearest_rank(adx, 300, 50) read 24.4017 where TradingView reads 24.3961 on the 27 bars its ADX warmup na sits in the window (BTCUSDT 15 from 2025-04-01). Linear interpolation reads the array at k = p/100 * n - 0.5 clamped to [0, n - 1] (element n - 1 at the top; otherwise a[lo] * (1 - f) + a[lo + 1] * f, na if either element is na even at f = 0), not at p/100 * (n - 1). ta.percentrank, na until `length` values precede the bar, counts an na current value and an all-na lookback as 0 instead of na. TradingView tapes (lab tv --no-note, BINANCE:BTCUSDT 15, synthetic probes, tests/fixtures/percentile_window): tailh-pct-warmup-btc15 (price-free sources without na, with na holes and with a warmup na, and ta.dmi's ADX over 300), tailh-pct-fullwin-btc15 (every element of the window of two na-holed sources, ta.percentrank of an na-led source) and tailh-pct-edges-btc15 (integral ranks beside na, percentages 0 and 100, windows of 70 and 100). The new test_percentile_window_tapes replays all three through the ta:: classes, one instance per Pine call site: on 9e6196ca 375 of 383, 183 of 191 and 375 of 383 bars differ; now 0. test_percentile's pl2 row read the old interpolation rank (27.5 for 25% of {20, 30, 40, 50}); it now reads TradingView's 25. ta::PercentileWindow keeps the array and undoes a bar's push for recompute(), so a bar recomputed any number of times reads and leaves what one compute of its final value does (test_percentile_recompute_is_one_computation). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit 1a2f6be906a8494943aa24e18ec4c67caf1e2f25) INT30: git's clean merge put this pick's fixture block inside TAIL-G's (`if(TARGET test_foreign_break_stamp_tapes)` lost its `endif()` to `if(TARGET test_ta_indicators_extras)`); tests/CMakeLists.txt closes each block on its own. INT30 pick note: TAIL-H 1 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * A percentage exit keeps one quantity step on a fractional grid too (TAIL-H rule PS) TradingView floors a percentage exit's share of the position to the symbol's quantity step, but a share that floors to nothing keeps one step while the position holds one. The adapter kept that step only on integer-lot grids (ab9714be's rule) and floored a fractional grid's share to zero: 50 % of one 0.01 lot of OANDA:XAUUSD reserved nothing, so the stop exit created after it held the whole lot and fired. That is the dragon-oscillation XAUUSD 15 probe's first divergence: trades 1-21 match, then TradingView holds the 0.01 long of 2025-10-21 08:45 to its 50 % target on 2025-12-12 while the engine stopped it out at 12:00 the same day. quantize_percent_exit_units now keeps the step on every grid; strategy.close's qty_percent share (quantize_close_units) is sized by it too. TradingView tapes (lab tv --no-note, OANDA:XAUUSD 15, synthetic probes, tests/fixtures/exit_reservation): tailh-d1a (0.01, the 50 % exit before the stop exit), tailh-d1b (0.03), tailh-d1c (0.01, the stop exit first), tailh-d1e-01 / tailh-d1e-03 (strategy.close qty_percent = 50 of 0.01 / 0.03). The new test_exit_reservation_tapes replays each through the Pine adapter: on 9e6196ca tailh-d1a and tailh-d1e-01 differ, the other three are the same; now all five replay. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit a81e41efd764399925741063f74278d2b0549465) INT30 pick note: TAIL-H 2 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * A margin call leaves a percentage exit its reserved share (TAIL-H rule PK) A margin call shrinks the position under its exits without filling any of them. TradingView keeps each percentage exit's reserved share and hands the remaining position to the exits in creation order again, each taking what the ones before it leave (the queue lane W3-ENG-EXIT-ALLOC pinned). The adapter left each exit the units it reserved at placement and let the kernel cap the fill at the position: after the dragon-oscillation ES1! 15 probe's first two margin calls left 8 of 25 contracts, its stop exit (created after the 50 % target, holding 13) fired for all 8 at 2025-04-03 14:15, where TradingView's 50 % exit holds the 8 of its 12, the stop holds nothing, and the position is margin-called on 04-04 (1, 1, 1, 4 and 1 contracts). After a margin call's units leave their cohorts, on_applied now reconciles every exit family's reservations against the position that remains (reconcile_exit_reservations_after_margin, through the existing reconcile_deferred_exit_reservations: queue order, a family left nothing is cancelled). TradingView tapes (lab tv --no-note, CME_MINI:ES1! 15, synthetic probes, tests/fixtures/exit_reservation): tailh-d2a (25 contracts at 1 % margin, the 50 % exit before the stop exit) and tailh-d2b (the stop exit first). On the parent tailh-d2a differs (the engine's stop closes 8 at 14:15) and tailh-d2b is the same; now both replay, and the five PS rows still do. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit 3981a3964a8b4cc55959f9cbe3346bb12c2a8ac0) INT30 pick note: TAIL-H 3 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * TAIL-D: the lane's tape tests read an open trade's entry bar only once it is booked The sanitizers profile (lab remote rj-20260929t014505-666927, CLOUD) failed test_coof_immediate_close_tapes on UBSan: `k - open_trade_entry_bar_index(0)` overflowed, 46 - INT_MIN, in a fill's recalculation that ran before the open trade's lot was booked, where the accessor returns na<int>(). The script's `bar_index - strategy.opentrades.entry_bar_index(0) >= N` is na there and compares false; the Release build reached false only through the wrapped subtraction. The four tape tests that spell it (immediate close, in-flight cancel, same-point exits, resting bracket) now test is_na first; every row still passes (18, 12, 9 and 9 checks). The time-frame test already reads the entry bar behind an entry-id check that fails first. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit d706c91a967280f44db19aa1614dd0a4138f4d92) INT30 pick note: TAIL-D 11 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * TAIL-E: time() / time_close() read another bar (PineStrategyHost::pine_time_offset) Pine v6's time(timeframe, [session, [timezone,]] bars_back, timeframe_bars_back) and its time_close twin read another bar's time: the chart bar bars_back names (a negative one counts forward), then the timeframe's bar holding it, stepped timeframe_bars_back of its own bars. Codegen refused them ("the engine exposes no other chart bar's time"), so job-2660-pinecoderstasc-tasc-2026-06-one-percent-a-week-adaptive (12 probes), which reads the weekday of the next bar, never transpiled. TradingView's tapes of two synthetic probes on six charts (lab tv --no-note, tests/fixtures/time_bars_back) pin the rule: it steps forward, and steps requested bars, on its symbol calendar, closed days included (NASDAQ:AAPL's next bar after Thursday 2025-04-17 15:45 ET is Monday 04-21 09:30 over Good Friday; after the 01-08 daily bar 01-10 over the 01-09 closure; a holiday Monday's week opens on its Tuesday); a past chart bar is the chart's history, na before its first; a timeframe finer than the chart's, stepped, reads the chart bar holding the instant it reaches. PineStrategyHost::pine_time_offset (the Pine host, src/source) reads the bars from the input its scheduler retains -- a batch's whole input, a stream's warmup (PineScheduler::retained_input, the input session.islastbar already reads its next bar from) -- and past its edges walks the symbol's session calendar (session_trades_at, session_time.cpp: a session's windows on its days, Monday to Friday for one naming none). No kernel call is involved and no state is added. The host holds no calendar of closed days: the chart's history holds exactly the calendar's bars on every tape but OANDA:XAUUSD's, whose history has no bar in the 17:00-18:00 ET slot or on Good Friday where TradingView's calendar holds sessions. tests/test_time_bars_back_tapes.cpp replays every cell of the twelve tapes (and the ETH tapes streamed after a warmup): 0 differ; the XAUUSD cells of that class (484) and two AAPL 1D first-bar cells TradingView read from a bar before its range are named in the test. Fail-before: the test does not compile against 8988faff ("use of undeclared identifier 'pine_time_offset'"). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit 1b67b6c62a4cba05ce55671c20d441cc61268e33) INT30: include/pineforge/source/pine_strategy_host.hpp takes this pick's pine_time_offset declaration beside lane TAIL-G's chart_bar_close_ms, both added at the same place (a textual conflict only). INT30 pick note: TAIL-E 1 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * W8E-EXITS: strategy.netprofit and strategy.equity charge the open lots' paid entry fees TradingView charges an entry's commission when the entry fills. While lots are open, the entry fees they have paid (the share still on each lot after a partial close) are already out of strategy.netprofit, and so out of strategy.equity and the netprofit / openprofit percentages; strategy.openprofit stays gross of them. The Pine host read BacktestEngine's closed-trade figures, so every script that sizes or decides from strategy.equity while a position is open, with a commission declared, ran one open entry fee too rich. On the definededge probes (Risk % sizing capped at 90% of equity, commission 0.06%) every reversal entry is 0.054% larger than TradingView's (eurusd-15: 20+ of the first 25 reversals, flat entries exact). TradingView, on synthetic probes written for this lane (lab tv --no-note, BINANCE:ETHUSDT.P 15, 2025-04-01 .. 2025-04-03; tests/fixtures/ open_entry_fee_charged), each reading the accessors while a position is open and encoding them as trade quantities: - s5-equity-fee-pct (percent 1): open profit -2.1 (gross), net profit -186.883 (the entry fee), equity - capital -188.983, netprofit_percent -0.186883, openprofit_percent -2.1 / 99813.117; - s5c-equity-nofee-pct (percent 0, control): open profit and equity -2.1, net profit 0; - s2-netprofit-pyramid-partial (pyramiding 2, half of one lot closed): net profit = the closed row less the fee left on both open lots, pro rata; - s3-netprofit-cash-order / s4-netprofit-cash-contract: the cash fees alike. PineStrategyHost now spells net_profit() and current_equity() (the names the generated code calls for strategy.netprofit and strategy.equity) with the open lots' paid entry fees charged; closed_trade_equity() keeps the old figure for the adapter's affordability and margin money, whose formulas are unchanged. BacktestEngine's own accessors, the report, the C ABI and every native host are untouched. Two unit helpers read the host's current_equity() / net_profit() as the closed trades' balance ("equity stays at the overridden initial_capital", "realized_balance"); they now read closed_trade_equity(), so their frozen checks keep their meaning and value: test_run_inputs_overrides(_l4d) PyramidEntryStrat::equity() (the two open legs' 0.5% entry fees moved it off 250000) and test_l8b_exact_reversal_literals realized_balance() (the open lot's cash entry fee). check_twin_parity.py: OK. docs/pages/pine-to-native.md: the paragraph Wave G wrote (0d76a09) said `strategy.equity` adds the gross open profit to realized equity and told a native host to add the open lots' `entry_commission` back to reproduce Pine's figures; TradingView's equity is net of those fees, so "strategy.equity adds that gross amount to realized equity", "A native open lot's unrealized_pnl and native_marked_equity(mark) deduct its remaining entry commission" and "To recover the Pine figures from those native values, add the open lots' entry_commission once" are rewritten: the marked equity IS Pine's equity, and only the gross open profit needs the fees added back. The openprofit_percent row (7328f4d, L14-B) said "Pine's denominator is the realized equity"; it is the initial capital plus strategy.netprofit, fees charged (s5's OPP row). Fail-before: tests/test_open_entry_fee_charged.cpp built against 8633d944's library and headers: "FAIL ... engine == tape.trades" on the four fee tapes (EQ and NP read the fee-free values), the control passes, "24 passed, 4 failed". After: "28 passed, 0 failed". Population: the definededge-supertrend-regime-confluence reversal quantities (5 lanes); every probe that reads strategy.equity / netprofit with an open position and a declared commission (census in the lane report). Layer: the source-adapter parity runtime (ADR-0001, Decision, layer 2): a Pine accessor on the Pine host. No kernel unit changes; no durable state is added (the fees are read off the open lots the host already keeps and hashes). Picked onto INT29 8988faff by lane TAIL-C (the TAIL-C targets read strategy.equity with a declared commission): docs/pages/pine-to-native.md is resolved against INT29's re-anchored lines, and the pick's CMake block closes the same_open_reversal block it follows with its own endif(). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit 10280ed81fb7d67d4a87623c4030f00a9a1622ec) (cherry picked from commit 33b7f570914bfb0591dc70e40f8e9c92aa72e417) INT30 pick note: TAIL-C 1 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * TAIL-C: a calc_on_order_fills refill after a fill forced onto a leg's end is live from TradingView's next fill point Under calc_on_order_fills the adapter fills an exit the path reaches only at a leg's end at that extreme's print (a fill forced onto the point). The recalculation that fill starts places a priced entry R; the engine released R at the recalculation, where the kernel booked a stop already through at its level on the rest of the bar. TradingView (lab tv tapes of the lane's own synthetic script, tests/fixtures/coof_w2_refill, tailc-w2r-a..f, BINANCE:BTCUSDT 15, 2025-04-01 .. 2025-05-01): - after a fill forced onto the bar's SECOND extreme, R is live only from the next bar's open -- filled at that open when it is executable there, otherwise at its own level later -- executable at the forced fill or not, and even when the leg to the close crosses its level: 1013 refills after such a fill, none on its bar (coof_priced_next_open parks it with the recalculation's market orders); - after a fill forced onto the FIRST extreme, R executable at the second extreme fills there at its print; one that is not rests at its own level from the second extreme on; - an entry executable at its birth but not at the next extreme rests at its level from that extreme (lane W8D-NOTRADES's w8d-coof2-d/e/f residuals, now exact): a limit arms there as StopLimit{extreme, level}, a stop as a trail armed at the extreme at its level's distance, filled at its level plus slippage (no print beyond the extreme follows on the bar); on_bar_open hands the next bar the plain stop back; - an armed pure limit entry books its own level: the StopLimit's resolved price was the level's directional tick, one ulp past the level, which the kernel refused as InvalidTerms. Tests: tests/test_coof_w2_refill_tapes.cpp replays the six tapes over the btcusdt-15 lane's first four days (18 checks); on 8988faff it fails 6 of 18 (12 passed). tests/test_coof_refill_waypoint_tapes.cpp: the w8d-coof2-d/-e rows the lane recorded as divergences now require TradingView's trades (6213 checks, 0 failures). Probes: job-759 PVRPLE oracle 250 (quote-ccy BTCUSDT 1D weak 11.7, BTCUSDT 15 weak 67.3, ETHUSDT.P 1D weak 77.1; EURUSD 1D weak 31.2) -> excellent on the lane replica. Layer: the Pine adapter (src/source); no kernel unit changes, no durable state added. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit 1fcbf2415e776b12ad0794b12b5256dbb6e155a1) INT30 pick note: TAIL-C 2 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * TAIL-C: an exit stop born through by the recalculation of a later open fill is live from the bar's first extreme Under calc_on_order_fills the recalculation of a bar's first open fill can place a market entry the same open executes (a newborn, here reversing that first fill). The recalculation of that second fill places an exit stop already through at the open. The engine held such a stop for the next bar (a wrong-side stop deferred to the next epoch). TradingView (lab tv tape tests/fixtures/coof_open_newborn_exit/tailc-1856-open-newborn, the lane's own stateless synthetic script, BINANCE:ETHUSDT.P 15, 2025-04-01 .. 2025-04-15) makes it live from the bar's first extreme: filled at the extreme's print when still through there (cells A, B), at the open when that extreme is the open, otherwise at its own level from the extreme on (cell C: a trail armed at the extreme at the level's distance, filled at the level plus slippage, handed back as the plain stop at the next open -- the entry-stop revert of the previous commit now covers an exit stop that names no trail, rested_stop_family). After a single open fill the through stop still fills at that open (cell D; lane W4's LA/SA). Tests: tests/test_coof_open_newborn_exit_tape.cpp replays the tape over the corpus 15m feed's first four days (84 closed trades, 3 checks); on 8988faff it fails 1 of 3. The twin test_cascade_exit_gapjump_l4c's G3 row (and its frozen legacy base) is TradingView's now: the short's buy stop 97, not through at the low 95, fills at its level on the entry bar rather than at the next open (renamed ..._rests_from_first_extreme); recorded as a pinned observable rewrite in tests/twin_parity_inventory.json, INVENTORY_SHA256 re-pinned, check_twin_parity.py OK. Probes: job-1856 DPO (quote-ccy ETHUSDT.P 1D weak 88.9, EURUSD 1D weak 80) -> excellent on the lane replica. Layer: the Pine adapter (src/source); no kernel unit changes, no durable state added. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit 22f3be6e1fca89a8a68c7f69264a3d7928f17389) INT30: scripts/check_twin_parity.py pins the sha256 of tests/twin_parity_inventory.json, which lane TAIL-D's FP17 pick and this pick each re-pinned on their own base; git merged the inventory's two new rows, and the pin is the merged file's, a3c9c46408c1b61f0b8542f4ce0cb5c43e4873ed685cc7b8e7d8d91caa3de8a6 (check_twin_parity OK). INT30 pick note: TAIL-C 3 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * TAIL-C: with the bar magnifier, a calc_on_order_fills refill is live from the next point of TradingView's intrabar path Lane W8D-NOTRADES's leg-end rule (an entry a mid-leg recalculation places is live from the leg's end) was applied off the magnified path only (!coof_lower_path). With use_bar_magnifier TradingView walks its own intrabars (lane MAG-INTRABAR) and makes a limit or stop entry the recalculation of a fill places live from the next fill point of that path (PineScheduler::next_input_waypoint): the end of the intrabar leg the fill was on, or the next intrabar's open after its second extreme -- the birth point itself for the refill of a first open fill. Executable there, it fills at the point's print (a stop keeps its slippage); a limit that is not rests at its own level from the point on (StopLimit{point, level}); a stop that is not keeps its level. After a fill on the chart bar's last path point, its close print, the next fill point is the next bar's open, and the entry waits for that open with the recalculation's market orders (lab tv tape tests/fixtures/magnified_coof_refill/tailc-mag-coof-refill-leg, the lane's own stateless synthetic script, BINANCE:ETHUSDT.P 15 magnified, 2025-04-01 .. 2025-05-01: 534 of 534 trades, 2025-04-05 02:30 UTC the close-print case). Tests: tests/test_magnified_coof_refill_tape.cpp replays the tape's 2025-04-05 on the eth-scraped-15 lane's 1-minute feed with the magnifier on (15 trades: 9 P, 4 cell-A refills filled at the leg-end print, a cell-B refill resting at its level, a cell-B refill filled at the next bar's open); on 8988faff it fails (the four cell-A refills fill at their own level on the exit's leg). Probes: bystry1991 EMA200 regime BOS/CHoCH 2x FVG (declares the magnifier), CME_MINI:ES1! 15 moderate 90.6 -> excellent 85/85 on the lane replica; test_magnified_aggregated_tape (hm-mag-diff-v2) and the MAG-INTRABAR tapes unchanged. Layer: the Pine adapter (src/source); no kernel unit changes, no durable state added. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit 30d4432aca3c6c9ab5c1b1924f9d36f05c361d57) INT30 pick note: TAIL-C 4 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * TAIL-C: the process_orders_on_close pass fills priced adds and reversing limits the close reaches, then decides the exits after them Under process_orders_on_close the close pass fills every priced entry the bar's calculation placed whose price the close's tick reaches: limits at that tick unslipped, stops slipped -- a limit or stop ADD placed while its own side is held, a flat limit or stop, and a limit placed against the held side, reversing it; an add the close does not reach rests. The pass then decides every exit the calculation placed against that same close, the exits that name an entry the pass just filled included. The engine filled only flat entries and reversing stops there (fill_pooc_close_entries), and decided the exits before the close-pass entries had filled (flush_pooc_marketable_exit_fills): the adds and their exits came a bar late. pooc_close_entry_immediate_pending holds the exit pass while such an entry is pending, and on_applied lets the pass run after a close-pass entry fill. TradingView: lane W10-DIAG-UNKNOWN's diag-w5r synthetic script (tests/fixtures/pooc_add_close/w5r-pooc-add-close, BINANCE:ETHUSDT.P 15, 2025-04-01 .. 2025-05-01; cells A..J and N on 2025-04-14 .. 04-16; the W10 lane ported the rule on its own tree and measured 51 POOC/COOF tapes, where only w4-f08 moved). Cell N reads strategy.equity net of the open lot's paid entry fee, the W8E-EXITS rule picked before this commit. Tests: tests/test_pooc_add_close_tape.cpp replays all 23 trades over the corpus 15m chart feed (bars.inc, 2025-04-14 .. 04-16); on 8988faff it fails 1 of 3 checks. Probes: job-2847 adaptive S/R reversal RSI divergence DCA (its pyramid add S2 and exit xS2), ETHUSDT.P 1D weak 50 -> excellent on the lane replica (with the W8E-EXITS equity rule). Layer: the Pine adapter (src/source, include/pineforge/source); no kernel unit changes, no durable state added. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit 437af07ea4d427ad379c4b692e5d0e30704c826a) INT30 pick note: TAIL-C 5 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * TAIL-C: an explicit-quantity market buy from flat is admitted at its signal close's tick plus the slippage its fill carries TradingView admits an explicit-quantity MARKET entry placed from flat at its placement against strategy.equity, costing a BUY at its signal close's tick plus the slippage ticks its fill will carry and a SELL at the close's tick, never lowered by the slippage (the fill-time check of the fill's own tick applies as well). The engine costed the buy at the plain close, so an all-in long whose slipped fill came in under that close opened. Under process_orders_on_close the order fills at that close and its own fill-time check decides it: the TV controls of test_pooc_money_admission_l4b (phase-b/-c) admit such buys, so the term is off there. TradingView (lab tv tapes of the lane's own synthetic script, tests/fixtures/explicit_market_admission, NYSE:F 15, 2025-04-01 .. 2025-10-01, one all-in cell per session sized floor(strategy.equity / close), long on even sessions, short on odd ones): at slippage 2 no long cell ever opens (-a), without slippage longs open with or without a 0.05 % commission (-b, -c) -- the commission is no term of it. Tests: tests/test_explicit_market_admission_tapes.cpp replays the three tapes over the f-15 lane feed (tests/fixtures/slipped_short/bars.inc; -a through 2025-05-16, before a one-unit margin-call shape the slipped_short README leaves open); on 8988faff the -a row fails (7 extra longs) and the controls pass. test_explicit_qty_fill_admission_l4b (GREEN-G) and test_pooc_money_admission_l4b stay green. Probes: blitz-locked MACD pullback sniper, OANDA:EURUSD 15 moderate -> excellent; NYSE:F 15 moderate (count 7 -> 3; its margin-call shapes remain, see the lane report). Layer: the Pine adapter (src/source); no kernel unit changes, no durable state added. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit da151a28a4dbef69d4e3a9e49aab982b2b42f4ad) INT30 pick note: TAIL-C 6 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * TAIL-E: an immediate close the bar's calculation executes is final for the bar strategy.close / strategy.close_all with immediately = true fill at the close of the bar whose calculation sends them. Under calc_on_order_fills the Pine scheduler recalculated after that fill, and the adapter released a market entry the same pass had sent behind the close at the close's own fill price: the entry filled on the closing bar, and when the recalculation closed again the close / entry pair looped without end. job-2660-pinecoderstasc-tasc-2026-06-one-percent-a-week-adaptive closes everything immediately at a week's last bar and re-enters behind it: TradingView enters at the next session's open, the engine re-entered at Friday's close (its AAPL and F probes weak, 61.5 to 86.5). TradingView's tapes of a synthetic probe with and without calc_on_order_fills (lab tv --no-note, tests/fixtures/coof_immediate_close) are the same bytes: no recalculation follows such a close. The entry sent behind it fills once, at the next bar's open; one sent before it while the position held the pyramiding limit never fills. - PineScheduler::coof_recalculation_due (pine_scheduler_native.cpp) schedules no recalculation for a fill PineExecutionAdapter::immediate_calculation_close names: a Close / CloseAll placement sent with immediately = true, filled at the calculation coordinate (NativePriceProvenance::Calculation). Other fills the calculation executes (risk caps, margin units, bracket legs executed after the calculation) keep their recalculation. - PineExecutionAdapter::on_applied releases the paired entry behind such a close to the next bar instead of forcing it onto the close's fill price. Both hunks are needed: with the scheduler's alone the loop ends but every entry behind a close still fills on the closing bar (23 of 47 trades differ). tests/test_coof_immediate_close_tapes.cpp replays both tapes through the Pine adapter: every trade TradingView closes, times, prices in ticks, quantities and names, is the engine's. Fail-before: on 8988faff the calc_on_order_fills case does not return (killed after 60 s). No kernel file is touched and no state is added. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit b6246fc19679fa8dc023a9897bc45ee7190765e5) INT30: lane TAIL-D's M1 pick had already added a test and a fixture README of the same names (tests/test_coof_immediate_close_tapes.cpp, tests/fixtures/coof_immediate_close/README.md; add/add conflict). TAIL-D's test keeps its name; this pick's test is tests/test_coof_immediate_close_final_tapes.cpp (its registration, its fixture-directory define and docs/pine_v6_coverage_detail.md's citation follow it); the shared README holds TAIL-D's section and then this lane's. Both lanes' tapes of that directory replay on the integrated tree, which holds TAIL-D's M1/M1e/M7 and this rule together. INT30 pick note: TAIL-E 2 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * TAIL-C: an infinite strategy.entry quantity trades the default quantity, as na does TradingView enters every +Infinity, -Infinity and na strategy.entry quantity at the strategy's default quantity (lab tv tape tests/fixtures/nonfinite_entry_qty/tailc-a-qty-nonfinite2, the lane's own synthetic script, BINANCE:BTCUSDT 15, 2025-04-01 .. 2025-04-08: legs 100 / 0, -100 / 0, na, int na, math.floor(100 / 0) and math.floor(0 / 0) in an int, all at the default 0.01; a 1e12 leg is refused with RE10024 and is off). The adapter dropped an infinite quantity at placement. The int legs are the codegen's (pineforge-codegen cg/tail-c: a global int fed only by math.floor/ceil/round keeps the infinity for ordering comparisons and hands the order its na). Tests: tests/test_nonfinite_entry_qty_tape.cpp replays the legs whose quantity reaches the adapter as a double (C 0.02, FINF, FNA, NINF; 44 trades over the btcusdt-15 lane's first four days); on 8988faff it fails (24 of 44: FINF and NINF enter nothing). Two switched-route twins pinned the old refusal and follow TradingView now: test_unbounded_margin_admission_l4a keeps its refusal checks for a finite quantity whose notional overflows or whose margin the capital cannot fund, and checks that +Infinity and -Infinity leave the default-quantity order pending, as na does; test_pooc_coof_reversal_gross_admission_l4c's signal-rejected extra call beside a same-close pair is a finite overflow (an infinite quantity is no longer refused). check_twin_parity.py: every base assertion still matched, two additional twin assertions. Probes: job-2545 MR VWAP SVP TDV (with the codegen half), BTCUSDT 15 minimal, NASDAQ:AAPL 15 weak 63.6, OANDA:XAUUSD 15 weak 62.2 -> excellent (1/1, 12/12, 38/38) on the lane replica. Layer: the Pine adapter (src/source); no kernel unit changes, no durable state added. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit dcbf9aab59e6a2656c73f351c9a502aefd03610e) INT30 pick note: TAIL-C 7 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * INT30: the behaviour pins the picks move, re-harvested once on the integrated tree and attributed The thirteen harvest-switched tables (INT29's harvest.py: each pinned TU compiled with its own harvest switch, with the build's own compile and link lines) were harvested on engine main 7239ab37, on the final tree, and at each lane boundary of the integrated history: after TAIL-A/TAIL-B/TAIL-G, after TAIL-D's picks (08745e26), after TAIL-H's rule PS (46b626c7) and rule PK (80b601b7), after TAIL-E's time() pick (da3c0f21), after TAIL-C's picks through ADM (739d1f6a), after TAIL-E's immediate-close pick (dd1ce762) and after TAIL-C's INF pick (0a3ed090, the final tree). - main reproduces every pinned row; so do the tree with TAIL-A, TAIL-B and TAIL-G picked, TAIL-H's rule PS, TAIL-E's time() pick and TAIL-C's INF pick (no line moves at those steps). Eight of the thirteen tables never move. - at TAIL-D's picks 50 lines move, each to TAIL-D's own harvest (quiet_bar 40 of 276 runs, publication_witness 4 of 156, live_state 6 of 108); - at TAIL-H's rule PK 21 lines move (quiet_bar 2, lookup_index_witness 4, receipts_in_place 8, live_state 7), each to TAIL-H's own harvest but one; - at TAIL-C's picks 25 lines move (quiet_bar 8, publication_witness 4, live_state 13), each to TAIL-C's own harvest (TAIL-C-scratch g7) but the ones below; - at TAIL-E's immediate-close pick 4 live-state digests move (TAIL-E's own three and reversals seed 314187). Rows moved at several lanes' picks, each no single lane's value because both rules act in the run (every step placed by the boundary harvests): - quiet_bar Random44/0/0, 0/1 and Random45/0/0, 0/1: TAIL-D then TAIL-C; - live_state reversals seed 314187 (TAIL-D, TAIL-H PK, TAIL-C, TAIL-E M5), reversals 1780393 (TAIL-C, TAIL-E M5), reversals 3770244 (TAIL-H PK, TAIL-C), brackets 1780394 (TAIL-D, TAIL-C), chains 314189 (TAIL-D, TAIL-C, TAIL-E M5), chains 1780395 (TAIL-C, TAIL-E M5); and reversals 2199309, moved at TAIL-C's picks alone to TAIL-C's counts but another transcript. Each table carries the lanes' ledgers (TAIL-D 839a4295, TAIL-H 647c9db7, TAIL-C 1d4fef1b, TAIL-E 1c1da276, none picked) and an INT30 note naming these rows; the values are this tree's harvest. test_coof_recalc_security_tapes takes TAIL-E's re-pin of the INT28-FIX late-close case (one callback per bar where the immediate close is final). All six rows pass: quiet_bar, publication_witness, live_state_equivalence, lookup_index_witness, receipts_in_place, coof_recalc_security_tapes. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * INT30: where TAIL-B's calls for a bar's adds meet TAIL-H's rule PK, TradingView's tapes of the composition Lane TAIL-B's AS/AC/LF (which adds of a bar fill, the one call after the last add, the follow-up call after a call that closes several lots) and lane TAIL-H's PK (after a margin call the exits hold the remaining position in queue order again) meet in PineExecutionAdapter::on_applied: every call AC or LF takes applies there as a Margin-family fill, and PK re-reserves the exits of the entry it shrank there, before LF sizes its follow-up. Neither lane's tapes held both: TAIL-B's probes carry no exits, TAIL-H's add nothing. Two lab tv --no-note tapes of a synthetic probe written for INT30 (tests/fixtures/int30_compositions, BINANCE:ETHUSDT.P 15, 2025-04-01 .. 05-01, rangeProof covered): forty 6-hour cells sized from the realized equity rounded to 100; older seed lots, then "L" with a 50 % exit TP and a stop exit SL (either first), then three adds on one bar, so that 23 cells per tape are called (111 call rows, 16 calls closing two lots or more) and "L" then exits by SL in 13 cells and by TP in 2. int30-c4-grid-pk-pooc (process_orders_on_close) matches trade for trade (351 trades). int30-c4-grid-pk-mkt matches but for one recorded call, AC's sizing price and not the composition: at margins of 100 the shortfall money is the book's cost plus fees less the equity whatever the mark; TradingView floors it over the print the adds' fill slipped from, AC over the slipped fill, and in cell 37 the two straddle a lot (2.1404 of "L" called on the tape, 2.1400 here; SL then exits what the call left, 2.3111 and 2.3115). PK's split is TradingView's after every call. Kept as the lane's rule, reported for TAIL-B's follow-up. test_int30_rule_compositions: 4224 checks, 0 failures on this tree. Built against engine main 7239ab37 and lane TAIL-H's final tree 647c9db7 it fails both tapes from their first trade (352 and 283 trades against 351), and against lane TAIL-B's final tree f95385fb too (358 and 359). An earlier probe seeded "L" itself in several lots. TradingView then books the 50 % exit and the stop per lot of "L" (per-lot floors, one closed row per lot and exit order), the engine per entry; that predates INT30 (main and this tree book identical trades in a cell without a call), so the kept probe gives "L" one lot. The fixture README records both findings. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * INT30: the ctest floors are the integrated tree's own counts Counted once, on the integrated tree, with ctest -N over each profile's own configure argv (ci_verify.build_config / cmake_configure_argv), against engine main 7239ab37 counted the same way: profile main 7239ab37 INT30 release 761 785 kernel 299 reg / 298 299 reg / 298 (unchanged) debug 742 766 sanitizers 742 766 native 751 775 The twenty-four rows are source-bound tape rows, which the kernel profile builds none of: TAIL-A test_security_multi_day_buckets_tapes; TAIL-B test_add_sibling_margin_tapes; TAIL-G test_foreign_break_stamp_tapes; TAIL-D test_coof_immediate_close_tapes, test_coof_same_point_exits_tapes, test_coof_resting_bracket_tapes, test_coof_timeframe_change_tapes, test_exit_fifo_cross_tapes, test_coof_open_limit_tapes, test_exit_reissue_na_tapes, test_pooc_pair_gross_tapes, test_whole_lot_tie_tapes, test_coof_inflight_cancel_tapes; TAIL-H test_exit_reservation_tapes (its percentile tapes add checks to the existing test_ta_indicators_extras); TAIL-E test_time_bars_back_tapes, test_coof_immediate_close_final_tapes (TAIL-E's test_coof_immediate_close_tapes, renamed at its pick: TAIL-D's test holds that name); TAIL-C test_open_entry_fee_charged, test_coof_w2_refill_tapes, test_coof_open_newborn_exit_tape, test_magnified_coof_refill_tape, test_pooc_add_close_tape, test_explicit_market_admission_tapes, test_nonfinite_entry_qty_tape; INT30 test_int30_rule_compositions. - scripts/ci_verify.py…
1 parent 7239ab3 commit 0411892

510 files changed

Lines changed: 63442 additions & 725 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎CONTRIBUTING.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ What each gate refuses:
153153

154154
`ci_verify.py` counts the CTest rows that actually **ran** and fails below a
155155
floor — `KERNEL_MIN_TESTS` ci_verify.py:313 and `RELEASE_MIN_TESTS`
156-
ci_verify.py:537.
156+
ci_verify.py:572.
157157
A deleted or silently skipped row is a failure, not a quieter run. If your
158158
change adds rows, raise the floor in the same commit and say by how much; if it
159159
legitimately removes one, lower it deliberately and say why. `--min-tests`

‎docs/adr/0001-kernel-adapter-boundary.md‎

Lines changed: 38 additions & 38 deletions
Large diffs are not rendered by default.

‎docs/ci.md‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,13 @@ requires the rows that actually ran to equal the second count, and records
102102
`registered`, `labelled = registered - selected`, and `ran` in
103103
`ctest-exclusion.log` and `ci-summary.json`. A skip, missing executable, lost
104104
registration below the PR registration floor, unreadable enumeration, or
105-
missing label fails. The PR registration floors after INT29 are 740 for
106-
Debug and sanitizers and 749 for native (653 and 662 at the INT24 base, plus
107-
wave G's six rows, wave H's twenty-four, INT26's own tape row, INT27's
105+
missing label fails. The PR registration floors after lane TAIL-I are 767
106+
for Debug and sanitizers and 776 for native (653 and 662 at the INT24 base,
107+
plus wave G's six rows, wave H's twenty-four, INT26's own tape row, INT27's
108108
thirteen, XSYM-D's four, K-SESSION-WINDOWS' four, INT28's twenty-four,
109-
INT28-FIX's four and INT29's seven). The full-run release and kernel floors
110-
are 759 and 296 rows that ran; full runs do not exclude a label.
109+
INT28-FIX's four, INT29's seven, W15-KERNEL-CAL's two, INT30's twenty-four
110+
and TAIL-I's one). The full-run release and kernel floors are 786 and 298
111+
rows that ran; full runs do not exclude a label.
111112

112113
Preflight also runs the detached-comment census of the kernel compile closure
113114
(`detached-comments`: `scripts/measure_detached_comments.py --check-ceiling`)

‎docs/coverage.md‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,11 @@ order, each with the close the feed gives it
612612
(`NativeRunSpec::instrument_feeds`); the source host runs the payload on each
613613
in the requested context -- its own history, `bar_index`, `time_close` and
614614
`syminfo.*` -- and fails the run closed, naming the symbol and the timeframe,
615-
when no feed is installed. Codegen still refuses a symbol that is not the
615+
when no feed is installed. On a D, W or M chart the source host judges the
616+
merge against the chart bar's own `time` and `time_close`, as TradingView
617+
does, where the kernel reads a daily label stamped in its session's break
618+
(OANDA:XAUUSD at 17:00 ET) as the session that closes at it
619+
(`tests/test_foreign_break_stamp_tapes.cpp`). Codegen still refuses a symbol that is not the
616620
chart's until its lowering onto this surface lands (lane XSYM-E); see
617621
@ref native_engine, "Instrument feeds: another symbol's bars".
618622

‎docs/design/native-feature-parity.md‎

Lines changed: 123 additions & 102 deletions
Large diffs are not rendered by default.

‎docs/native-refactor-progress.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ repository and were never pushed.
173173

174174
| Item | What it is | Measured size | Deferred by | Prototype and evidence | Reopens when |
175175
| --- | --- | --- | --- | --- | --- |
176-
| D2-B, the quiet-bar protocol and one receipt read per bar | PERF-D2's lane: a per-bar bar-open request, a bulk fold of quiet driver points, the adapter's quiet-open predicate with lazy open bookkeeping, and a gate before the receipt poll. D2-A landed the hook declarations and the O(1) `has_command_after` (`src/native_execution_consumer.hpp:269`). PERF-L4 gated the read inside `observe_terminal_receipts` (`src/source/pine_adapter.cpp:5489`), which still runs about three times a bar | PERF-D2, spark Cortex-A725, callgrind and GBench: about ×0.88 on the 14 probes (an estimate from a measured −13 to −14 % floor bound for the bar-open request alone); after PB the receipt poll still costs about 250 instructions a bar on the no-order floor. On this tree the quiet-bar probe asks the receipt gate 40,996 times and each once-per-bar-open gate 13,248 times: 3.09 reads a bar, 82 % of them stopped at the gate (macOS arm64, AppleClang 17, Release) | "R5 PERF-D2 DONE 2026-09-24 19:56" (D2-B after V19-D); "R5 SUPERVISOR RULING 2026-09-25 00:15 Taipei": "D2-B (quiet-bar protocol) waits for PERF-D3's verdict"; TRIAGE1 §D | Branch `perf-d2/proto-throwaway` (`92e85571`); `$EV/exec/PERF-D2-scratch/patches/`. PERF-D3's S1 (next row) prototyped the request and the lazy opening | A post-release performance epoch. Done when the receipt gate is asked as often as the once-per-bar gates |
176+
| D2-B, the quiet-bar protocol and one receipt read per bar | PERF-D2's lane: a per-bar bar-open request, a bulk fold of quiet driver points, the adapter's quiet-open predicate with lazy open bookkeeping, and a gate before the receipt poll. D2-A landed the hook declarations and the O(1) `has_command_after` (`src/native_execution_consumer.hpp:269`). PERF-L4 gated the read inside `observe_terminal_receipts` (`src/source/pine_adapter.cpp:5525`), which still runs about three times a bar | PERF-D2, spark Cortex-A725, callgrind and GBench: about ×0.88 on the 14 probes (an estimate from a measured −13 to −14 % floor bound for the bar-open request alone); after PB the receipt poll still costs about 250 instructions a bar on the no-order floor. On this tree the quiet-bar probe asks the receipt gate 40,996 times and each once-per-bar-open gate 13,248 times: 3.09 reads a bar, 82 % of them stopped at the gate (macOS arm64, AppleClang 17, Release) | "R5 PERF-D2 DONE 2026-09-24 19:56" (D2-B after V19-D); "R5 SUPERVISOR RULING 2026-09-25 00:15 Taipei": "D2-B (quiet-bar protocol) waits for PERF-D3's verdict"; TRIAGE1 §D | Branch `perf-d2/proto-throwaway` (`92e85571`); `$EV/exec/PERF-D2-scratch/patches/`. PERF-D3's S1 (next row) prototyped the request and the lazy opening | A post-release performance epoch. Done when the receipt gate is asked as often as the once-per-bar gates |
177177
| S1a, kernel quiet-bar driving (PERF-D3) | A bar with nothing live, a flat book and a declined opening is driven in a quiet form: the kernel writes the bookkeeping its four price points would leave (ordinals, the last two driver marks, the floor, the point epochs) without walking them or calling the bar-open callback. Additive host cadence declarations; C hosts declare from their callback table; one C symbol under the PF_API checklist | PERF-D3, spark A725, GBench time and `perf stat` instructions, on the L3 tree `b33ea659`, S1a with S1b: no-order floor 0.764 / 0.660 in time (0.718 / 0.656 in instructions), 14 probes 0.958 / 0.921 (0.892 / 0.856), 100 slots 0.972 / 0.956 per slot. A bare kernel host that opts in: idle 0.545× (35 % fewer instructions a bar), market 0.81×, bracket 0.92×. Byte-identical: corpus 312/312, the 132-configuration battery with its hash columns | "FINDING PERF-D3 (filed for a post-release epoch per the owner's cap)" (ledger, 2026-09-24 16:58 UTC); "OWNER DECISION 2026-09-25 00:20 Taipei"; TRIAGE1 §D: "PERF-D3 S1/S2 (post-release epoch)" | Branch `perf-d3/proto-throwaway` (`a820b7df`, five commits on `b33ea659`); `$EV/exec/PERF-D3-scratch/patches/`; spark `~/perf-d3/` | The post-release epoch, with the owner calls PERF-D3 lists (the API under the existing ruling, the restated gate count) |
178178
| S1b, the Pine lazy opening | The Pine host records what its skipped opening and its uncalled input callback would have written, at the bar's first host callback. Member functions only, no layout change | Measured with S1a. A quiet bar then asks 15 gates, not 30, so the quiet-bar cost check `CHECK(asked >= 20 * o.boundary.size())` (`tests/test_adapter_quiet_bar.cpp:1054`) must be restated | As S1a | As S1a. The in-script hash witnesses caught the prototype's one miss (`awaiting_legacy_script_open_ms_`) | As S1a |
179179
| S1c, the held-position wake band | S1 for bars that hold a position with nothing live, 41 % of the median public slot's bars. The host declares a price band, and the kernel calls the opening only when the bar's range leaves it. The adapter derives the band from its margin model and declines when it cannot bound it | PERF-D3, a measurement-only upper bound without the band, which is not sound in general: 100 slots 0.776 / 0.716 per slot, 14 probes 0.830 / 0.761, cumulative against L3 with S1, S2 and D2-A | As S1a; the owner call "Fund the price band" | `$EV/exec/PERF-D3-scratch/patches/hold-ub-measurement-only.py` | As S1a. Size L, parity risk high: TradingView's margin money rules |
@@ -183,7 +183,7 @@ repository and were never pushed.
183183
| Compact journal records and a history ring buffer (L3) | Smaller command records and a ring buffer for the request core's history. `WorkingRequestCore::history` (`include/pineforge/native_order.hpp:1709`) hands out the whole vector and the core holds `history_` (`include/pineforge/native_order.hpp:2197`) inside `native_order_v7`, so both are a layout and API change | L3, spark A725, `perf` call graphs, inclusive shares: at most 3.68 % of bracket, 11.99 % of re-issue, 4.26 % of market and 3.42 % of the 14 probes (retiring the history alone: 1.64, 4.51, 2.53 and 1.00 %); only part is realisable, since records must still be written | "R5 L3 DONE + ACCEPTED 2026-09-24 22:10 Taipei", ruling 1: "DEFERRED to the PERF-D3 structural plan"; TRIAGE1 §D: "compact journal records" | `r5/l3` (`b33ea659`, merged by INT22); `$EV/exec/L3-scratch/`; spark `~/l3/prof` | A `native_order` layout epoch |
184184
| A checked-values handoff for executions (L3) | `execution_values` runs twice, in `check_execution` (`src/native_order.cpp:4791`) and again in `apply_execution` (`src/native_order.cpp:4805`); handing the checked values across needs a public type, an API addition with no layout change | L3, as above: 2.21 % of bracket for the two together, about 1.1 % recoverable | L3 ruling 2: "a public checked-values handoff for executions (~1.1% bracket) -> DEFERRED" | As above | An owner decision on the API addition |
185185
| A chunked `trades_` store (L3) | Closed trades in chunks rather than one vector; `trades_` (`include/pineforge/engine.hpp:546`) is protected `BacktestEngine` state, so script ABI | L3, as above: on bracket, vector growth 0.64 %, `Trade` moves 0.74 % and `record_close_trade` 0.43 % (at most about 1.4 %); at most 0.35 % on the 14 probes | L3 ruling 4: "chunked trades_ store (ABI) -> DEFERRED" | As above | An `engine_script_run` epoch that changes the engine's protected layout |
186-
| A zoned chart-day memo (D2-D finding 4) | On a chart with a timezone, `libc_chart_day_key` (`src/source/pine_adapter.cpp:14425`) takes the process timezone lock through `ScopedTimezone` and calls `localtime_r` on every bar, because `on_bar_open` (`src/source/pine_adapter.cpp:17567`) reads `chart_day_key` (`src/source/pine_adapter.cpp:17730`) unconditionally. The non-UTC monthly Sharpe/Sortino walk, `month_key_local` (`src/engine_metrics.cpp:33`), pays one `localtime_r` per equity point. UTC charts use D2-D's memo, `civil_chart_day_key` (`src/source/pine_adapter.cpp:14409`) | Not measured on a zoned chart. The UTC path cost 134 instructions a bar before D2-D's memo and 68 after (D2-D, spark, callgrind on the floor). PERF-K1: `ScopedTimezone` copies the zone name, which allocates for names of 16 or more characters under libstdc++ | TRIAGE1 §D: "D2-D finding 4 (the timezone `localtime_r` memo)", under the owner's cap. D2-D's report: an exact zoned memo "would need the zone's transition table, which belongs in `timezone.cpp`" | None; the UTC memo's witness is `tests/test_chart_day_memo.cpp` | A lane that owns `src/timezone.cpp` and builds an exact zone-transition memo (PERF-K1's Sitka case shows why a shortcut is not exact), byte-identical, with the zoned keys of `test_chart_day_memo` still equal to the computed ones |
186+
| A zoned chart-day memo (D2-D finding 4) | On a chart with a timezone, `libc_chart_day_key` (`src/source/pine_adapter.cpp:14869`) takes the process timezone lock through `ScopedTimezone` and calls `localtime_r` on every bar, because `on_bar_open` (`src/source/pine_adapter.cpp:18134`) reads `chart_day_key` (`src/source/pine_adapter.cpp:18323`) unconditionally. The non-UTC monthly Sharpe/Sortino walk, `month_key_local` (`src/engine_metrics.cpp:33`), pays one `localtime_r` per equity point. UTC charts use D2-D's memo, `civil_chart_day_key` (`src/source/pine_adapter.cpp:14853`) | Not measured on a zoned chart. The UTC path cost 134 instructions a bar before D2-D's memo and 68 after (D2-D, spark, callgrind on the floor). PERF-K1: `ScopedTimezone` copies the zone name, which allocates for names of 16 or more characters under libstdc++ | TRIAGE1 §D: "D2-D finding 4 (the timezone `localtime_r` memo)", under the owner's cap. D2-D's report: an exact zoned memo "would need the zone's transition table, which belongs in `timezone.cpp`" | None; the UTC memo's witness is `tests/test_chart_day_memo.cpp` | A lane that owns `src/timezone.cpp` and builds an exact zone-transition memo (PERF-K1's Sitka case shows why a shortcut is not exact), byte-identical, with the zoned keys of `test_chart_day_memo` still equal to the computed ones |
187187
| Thread-local reads that remain per call | D2-C moved the three scopes' writes onto the pump's block, `pump_ambient` (`src/native_execution_consumer.hpp:444`). A reader still reaches the block through `tl_runtime_ambient` (`src/ta_extremes_volume.cpp:29`): `bar_context` (`src/ta_extremes_volume.cpp:82`), read by every `ExtremeRing::update` (`src/ta_extremes_volume.cpp:117`), which backs `ta.highest`, `ta.lowest`, `ta.highestbars` and `ta.lowestbars` and, through an embedded `Highest` and `Lowest`, `ta.stoch`, `ta.wpr` and `ta.range`; and `matching_day_partition` (`src/timeframe.cpp:605`), read by the default-anchored `ta.vwap` through `session_day_index`, by `crosses_boundary` on a DAY period (`timeframe.change("D")`) and by the session-period helpers. `decompose_ms_local` (`src/session_time.cpp:250`) reads two thread-locals per call on a zoned clock, and the prepared order storage's `free_blocks` (`src/native_order.cpp:605`) one per prepared mutation. `ema_na_warmup_flag` is read once per EMA, at its first compute | One thread-local access per reader call. AUDIT4, macOS arm64, a dlopen'd tutorial-MACD probe, counted by `_tlv_get_addr` breakpoints and by descriptor patching: 1.000 a bar for one `ta::Highest` and for one default `ta::VWAP`, 1.999 for one `pine_hour` on a New York clock, 0.000 on the no-order floor and with orders. On Linux a TLS-descriptor call costs about 20 instructions: D2-C's 13 → 4 calls a bar was 260 → 80 instructions (spark aarch64, GCC 13, callgrind). INT23: 2.00 a bar on the zoned probe 064, 0.08 on probe 008 | None for the TA and day-partition readers: "RULING: INT23 ACCEPTED" (ledger, 2026-09-24 23:30 UTC) reads "dlopen TLS 13->0/bar", and INT23's report names only the timezone and order-core residuals. This row is their record | `$EV/exec/AUDIT4-opus-scratch/perf/tls/` | A byte-identical lane that hands these readers the pump's block without a thread-local read. `ta::bar_context()` is script ABI, so its public declaration stays as it is |
188188
| "audit-off mode", "LTO", "data-oriented layout" | Named in "OWNER DECISION 2026-09-25 00:20 Taipei" among the post-release structural items: "S1 bulk quiet bars, S2 per-strategy specialization, audit-off mode, LTO+PGO, data-oriented layout". No engine or campaign document defines, designs or measures the three | None | The owner decision | None | Struck from this inventory until a design note defines one of them |
189189

@@ -199,7 +199,7 @@ unless the retention is Full, and `presize_logs`
199199
(`src/native_execution_consumer.cpp:9331-9342`) sizes no journal under Window.
200200
`NativeRunSpec::event_retention` (`include/pineforge/native_run_spec.hpp:714`)
201201
defaults to Window, and the Pine adapter declares
202-
`NativeEventRetention::Window` (`src/source/pine_adapter.cpp:2410`). K4 still
202+
`NativeEventRetention::Window` (`src/source/pine_adapter.cpp:2411`). K4 still
203203
sizes Full runs (driver log and journal) and Commands runs (journal), and its
204204
witness, `tests/test_native_batch_log_presize.cpp`, runs under Full. PERF-K24's
205205
replay figure (14.9 % less CPU on spark) describes the tree before V19-B. In
@@ -210,7 +210,7 @@ or more, and the same run under Full holds 66,000 points in one block of
210210
**PERF-L4 reads the receipts about three times a bar, not once.** PERF-L4's
211211
brief asked it to "read the receipts ONCE per bar instead of three times". The
212212
lane gated the read instead: `observe_terminal_receipts`
213-
(`src/source/pine_adapter.cpp:5489`) returns at its receipt gate when no
213+
(`src/source/pine_adapter.cpp:5525`) returns at its receipt gate when no
214214
command lies above its cursor. `every_gate_is_taken_both_ways`
215215
(`tests/test_adapter_quiet_bar.cpp:1061`) prints
216216
`gate ReceiptRead asked 40996 quiet 33552 live 7444`, against `asked 13248`
@@ -241,7 +241,7 @@ Mac's 489 and 412 and 1003 of 1249, and no Mac output moved.
241241

242242
- **PERF-L4's retired reader slots.** `event_high_water_reader_` and
243243
`terminal_receipt_high_water_reader_`
244-
(`include/pineforge/source/pine_adapter.hpp:1976-1977`), with their type
244+
(`include/pineforge/source/pine_adapter.hpp:1991-1992`), with their type
245245
`ReceiptHighWaterReader`, are storage nothing reads or writes since PERF-L4:
246246
they keep `PineExecutionAdapter`'s layout, which is part of
247247
`PineStrategyHost`'s and so of the generated script's ABI. They go at the next

‎docs/pages/contributing-llm.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ finding to report, not a step to take.
118118

119119
10. **A test row never silently disappears.** Each profile counts the rows that
120120
*ran* against a floor: `KERNEL_MIN_TESTS` ci_verify.py:313 and
121-
`RELEASE_MIN_TESTS` ci_verify.py:537. Adding rows means raising the floor
121+
`RELEASE_MIN_TESTS` ci_verify.py:572. Adding rows means raising the floor
122122
in the same commit.
123123

124124
## The recipe for a lane
@@ -264,7 +264,7 @@ measurement that produced it, so a later change to it is visible as a change to
264264
the record, not as an edit to a literal.
265265

266266
**floor** — the minimum number of CTest rows a profile must actually run
267-
(`KERNEL_MIN_TESTS` ci_verify.py:313, `RELEASE_MIN_TESTS` ci_verify.py:537). It
267+
(`KERNEL_MIN_TESTS` ci_verify.py:313, `RELEASE_MIN_TESTS` ci_verify.py:572). It
268268
counts rows that ran, so a skipped row does not pad it.
269269

270270
**receipt** — the recorded evidence an ABI-comparison row needs (a prepared

0 commit comments

Comments
 (0)