Skip to content

Commit 7a1f01c

Browse files
luisleo526claude
andauthored
Pine adapter: the same-pass position view after a close fill, the close's owed follow-up, open-marketable exits first, and same-side global exits, pinned by TradingView controls (#347)
* Pine adapter: a re-issued exit filled at its call keeps the pass's position view Under process_orders_on_close, exit() fills a re-issued strategy.exit of a one-lot short whose stop or limit is already through the bar's close at the call (its current-close path, execute_current). Unlike an ordinary close_all (KI-64), it did not freeze the script's position view, so the rest of the pass read strategy.position_size == 0 and a reset strategy.position_avg_price. A late observer, strategy.position_size[1] < 0 and strategy.position_size == 0, then fired one bar early, and an exit cooldown blocked the next bar's entry. The scraped job-2947 probe on BINANCE:ETHUSDT.P 15 lost its 2026-01-08 23:30 UTC short and every later trade this way. TradingView fills that exit at the close, after the pass: the pass keeps the pre-fill size and average. The adapter now freezes the script's position view before it executes the exit, as close_all does. Once the fill has left the book flat, the generated strategy.position_avg_price read (position_entry_price_ behind a non-zero signed_position_size()) keeps the pre-fill average until the pass ends. PineStrategyHost:: hold_script_average_price writes it, and release_script_average_price restores the flat book's 0 right after on_source_bar, before the orders the pass placed settle. No codegen change. Each part has its own switch, PoocCloseFillViewSwitches:: current_exit_keeps_position_view and current_exit_keeps_average_price (on; tests clear them). Both act only at that call site. close_all's own average read and the intraday-cap close at the call are unchanged. Pinned by 15 synthetic lab tv --no-note controls on BINANCE:ETHUSDT.P 15m, 2026-01-08..10. Each was exported twice, the two exports are byte-identical, rangeProof is covered on both, and every prediction was written before its export: 0 TradingView counterexamples. tests/fixtures/pooc_close_fill_view holds 11 of them with their frozen generated strategies (codegen c1df8a6): - Nine equal TradingView row for row, entry ids included. These are the re-issued stop exit's size read, its cooldown observer, its ATR-stop cooldown at 100 % of equity, its average read and its limit leg, plus the long mirror, strategy.close, close_all and a first-issue exit, which never moved. - Two are known divergences the rule leaves open. close_all's average read is AVGPRE on TradingView and AVGOTHER in the engine. After the re-issued exit, TradingView keeps the pre-fill strategy.opentrades, closedtrades, openprofit, netprofit and equity; the engine reads them after the fill. test_pooc_close_fill_view_tapes clears each part and requires the departures recorded in switch_off_departures.json. The average part moves 2 tapes; the view part moves the 5 re-issued short tapes. It also requires every tape's stream to equal its backtest with both parts on and off. Last, it records every tape's per-bar broker-state hash with the average part on and off: position_entry_price_ is hashed, so the hashes must be equal wherever the trades are, and otherwise first differ after the exit bar's fold. A hold that outlived its pass fails it: with the release_script_average_price() call removed, the trades stay the same and the hashes of the re-issued exit tapes differ from the exit bar's fold on. The four cooldown controls of tests/fixtures/margin_call_rules stay equal. Fail-before: the test module does not compile against the parent tree (pooc_close_fill_view_switches is not a member of detail). With both parts cleared, the five re-issued short tapes depart from TradingView, as on the parent. Whole-suite per-run trade dumps (%.17g, every field) against the parent: the dumps cover 670 processes and 56,558 runs. Every pre-existing run-pass keeps its trades with both parts on and with both off. The only differences are the new test, the repetition counts of timing-calibrated loops and the run order of a test that runs two hosts on two threads; their distinct runs are identical. No witness re-pin. The transient flag is waived in broker_state_hash_waivers.txt: it is false at every fold. Documentation anchors into the four edited files are carried by an exact line map from the parent (245 moved, 0 stuck). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * Pine adapter: a POOC close's owed follow-up booked after the script, frozen close sizes and their over-fill lot, and the open's lot-by-lot follow-up R-A (MarginScheduleSwitches::close_follow_up_after_script): a carried process_orders_on_close short's lagged follow-up owed to its bar's close is held through the close's own check (rule 7 still drops it where the close is short) and booked after the script, ahead of the close's fills, at the same print. A strategy.close(id) of the whole one-lot book (flush_pending_closes) or a close_all() placed there keeps the size the script saw: a transaction that crosses zero and opens the excess as a lot of its own, under the close order's label. That lot is credited to the close ledger and the pyramiding records ahead of the entry beside it, so the next open's nameless margin calls take it first in first out, as the kernel does from the book, and a later strategy.close of that entry closes all of the entry's units. A reversal entry's excess joins its own lot (apply_frozen_reversal_close). Partial closes, closes of several lots and the twin outside process_orders_on_close keep today's sizing (margin_schedule_rules frozen/close-id stays a known divergence). No tape runs pyramiding above 1, so the pyramiding-record credit is unexercised. Beside that lot only a market entry filling at the close it was placed at is exempt: from the pyramiding-0 refusal, and a default-sized one from the fill-time affordability check too (a scraped OANDA:EURUSD 15 probe, job-2550, 2026-04-09 01:45 UTC: TradingView fills a default-sized "LONG" of 18624.97 beside the 0.56 over-fill lot). Priced entries and later fills keep every gate; no tape decides those shapes. One of them changes against the parent tree, which opens no over-fill lot: an explicit stop entry placed at that close at pyramiding 0 fills on the next bar there, and is refused here as a same-side add beside the lot. R-B (MarginOpeningSwitches::lot_by_lot_open_follow_up): on a fractional lot grid, the close-sized call at the next open takes a book of several lots the close's fills opened, first in first out, and its follow-up is checked lot by lot (open_print_lot_follow_up_units). One-lot books keep open_print_follow_up_units, and whole-share books of several lots keep the previous rules. On a fractional book of several lots a short's booked re-check now runs as well (the parent tree never entered this schedule for several lots); nothing follows it, since no tape decides that follow-up. Tests: tests/fixtures/margin_open_rules lots/ holds 10 synthetic TradingView controls (62 trades), each exported twice with identical output and predicted before export. All 10 match row for row and stream to the backtest's trades; the parent tree matches none of the first 8. Two of them close the entry by id after the open's calls (strategy.close("L"), with an explicit and with a default-sized L). Off alone, close_follow_up_after_script loses 7 tapes and lot_by_lot_open_follow_up 9. margin_open_rules: 53 tapes, all match. The job-2550 probe's trades now equal TradingView's 3761 rows. Whole-suite per-run trade dumps (%.17g, every field) with both switches on and off: only the lots/ tapes move. Documentation: both switches' rows, the counts, and the anchor digits carried by an exact line map. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * Pine adapter: a market entry's opening check at its open fill follows the exit legs marketable there TradingView, pinned on 25 synthetic controls (each exported twice, byte-identical, every prediction written before its export): at a market entry that opens the book from flat at a bar's open, the exit legs it released that are already marketable at that open -- a short's stop at or below the open's tick or its limit at or above it, a long's mirror -- fill there first, and the opening margin check then runs on the book they leave (nothing after a whole exit). A leg the bar reaches only later on its path, one tick after the open included, never preempts: the check's call books at the fill first. Both sides. Four more controls make the strategy.exit global (no from_entry) and place it with the entry: TradingView books each exactly as its bound control. ab9714b's rule -- a 1x short skips the opening trim when an exit leg touches anywhere on the entry bar -- is refuted by TradingView on its own shape (test_margin_call_1x_long_entry_fill scenario E's settings and bar: 0.008 ETH called at the open, then the stop closes 3.492). For a market entry opening the book from flat at the open (one lot, no add, no book of several entries, neither process_orders_on_close nor calc_on_order_fills) the adapter asks the legs that fill released whether they are marketable at the open (priced_exit_precedes_opening). The released legs (opening_released_leg) are those bound to the entry's request, those bound to its id and materialized at the fill on the book's side, and a global leg placed while the book was flat whose request follows the entry's. Every other leg (a strategy.exit without from_entry placed before the entry or while a position was held, a leg carried from an earlier bar or lot) is still asked ab9714b's question, and every other fill (stop and limit entries, reversals, adds, books of several entries, process_orders_on_close, calc_on_order_fills) keeps that rule. The scope is narrower than the pin's wording because the wider form (every market fill at the open, every live leg) moved the state hashes of two synthetic witnesses, test_adapter_quiet_bar (18 runs) and test_publication_witness (10 runs): hash-only, every trade field equal in a whole-suite dump, through legs the kernel never fills at that open, whose owed check then lingered. Which exclusion each of the last 8 runs needed was not bisected. Known divergences of the kept rule: - Two are committed as tapes the test lists in kKnownDivergences: TradingView calls a short reversal (out of a 0.001 long) and a short stop entry gapped at the open (a sell stop above the close) before their stop on the path, as it does the market entry; the engine books the stop 3.5 with no call. - A global strategy.exit placed before the entry, while the book is flat, has no tape. TradingView voids an exit called while no position is held and no entry order is working (its exit-binding pins), so, by inference, it calls such a short at the open print. The engine keeps a leg there that never fills, at the open or later, and still asks ab9714b's question of it: the short's opening call is skipped whenever the bar touches the leg's stop, and the short is called at the path's extreme instead, the same with the switch off. The leg stays out of the released legs for an engine-only reason: counted, it defers the check to a fill that never comes, which drops the check, a long's too (in test_adapter_quiet_bar Random32 that moved only the state hash). - Adds, books of several entries, limit entries, process_orders_on_close and calc_on_order_fills stay on that rule without a tape. A partial exit at the open owes the check after its own fill (open_exit_first_bar_: 0.0032 called after a 0.0004 stop, as TradingView books it); the record is cleared at the next bar open if no released leg fills. The opening check's body moves unchanged into run_opening_checkpoint so both points run the same branch. Switch MarginOpeningSwitches::open_marketable_exit_first, default on; off restores the previous rule (every deterministic run-pass of the suite books the parent tree's trades, field for field). Tests: the 31 controls are tapes in tests/fixtures/margin_open_rules exit-order/ (53 trades). margin_open_rules now holds 84 tapes and 244 trades: 82 match, the 2 listed divergences still differ, forward == backtest on all 84, and the switch off loses 17 (15 of the 25 pinned controls, which the parent tree misses, and the two global controls that tell the rules apart). Scenario E of test_margin_call_1x_long_entry_fill (twin and base copy) books TradingView's shape, 0.1996 @100 "Margin call" then 99.7504 @105; its twin-parity rewrite entry is extended. Docs: the switch row and counts, and every anchor into the moved files re-anchored by an exact line map. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * Pine adapter: a global exit called while a position is held binds to it beside a same-side add too A strategy.exit with no from_entry, called while a position is held beside an entry order of the HELD side (an add resting at a limit or a stop, placed earlier in the same calculation, or queued by a fill recalculation), still took that pending add as its parent (observe_staged_parent in exit()): #345 skipped only an entry order of the other side. With the add's price basis, a profit or trail leg rested at the add's limit plus its ticks and filled at the next open, so a script booked thousands of one-bar trades; a loss leg, and any leg beside a stop add, waited for the add's fill, which never came, and the position ran to the end of the range. A market add at the pyramiding cap never became a pending parent. TradingView binds such an exit to the held position whatever the side of the order beside it. In 36 pairs of synthetic `lab tv --no-note` controls on NYSE:F 15m (a resting limit add, a resting stop add, or a market add at the cap; profit, loss, profit and loss, and trail legs; long and short; calc_on_order_fills off and on; every prediction written before its export), each add script's List of Trades is byte-identical to its control's: 0 counterexamples. The skip now drops its side term, so the exit keeps the held position's side and entry price. Under calc_on_order_fills one more path departed: the profit-and-loss bracket the exit stages in the entry's fill recalculation (the chart-tick scope) counted the resting add as a competing order of the source book, which took the bracket's chart-tick reach (its threshold moved half a tick beyond a level the on-grid test misreads by one ULP), so a limit the fill bar's high reaches exactly filled one bar late. flush_pending_bracket_legs now leaves the entry orders of the held side out of the census of a held global exit's leg. Two switches (ExitBindingRuleSwitches, on; tests clear them): global_exit_binds_held_position (extended, sizeof unchanged) and the new held_exit_bracket_ignores_same_side_entries (sizeof 5 -> 6). Kernel untouched; no stream gate. Not in scope: an add that fills while the exit works (TradingView gives each entry its own exit levels and books FIFO; the engine books one exit at the average price) is a separate rule. Tests: tests/fixtures/same_side_exit holds the 36 add tapes and their 20 controls (exact Pine bytes, TradingView's List of Trades, provenance, frozen generated C++ of codegen c1df8a69); test_same_side_exit_tapes requires 38 tapes equal to TradingView row for row and the other 18 to depart exactly at their recorded row (the same row in a control and its add tapes: the trailing leg and calc_on_order_fills re-entries, another rule's); with global_exit_binds_held_position off exactly the 32 resting-add tapes move, with held_exit_bracket_ignores_same_side_entries off exactly the 4 calc_on_order_fills profit-and-loss add tapes; no control and no cap tape moves. The calc_on_order_fills add tapes are refused by a forward stream; every other add tape streams (1 and 30 bars of history, every run of the feed between two nights) to the backtest's trades. test_exit_binding_tapes sets the new switch in every_part() and lists it. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
1 parent a9544d3 commit 7a1f01c

565 files changed

Lines changed: 100569 additions & 399 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.

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

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

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

Lines changed: 98 additions & 98 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 @@ them for the record only. "Linux aarch64" is the maintainers' Cortex-A725 host.
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:6153`), which still runs about three times a bar | PERF-D2, Linux aarch64 (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 | An unpublished prototype branch and its 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:6161`), which still runs about three times a bar | PERF-D2, Linux aarch64 (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 | An unpublished prototype branch and its 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, Linux aarch64 (Cortex-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)" | An unpublished prototype branch (five commits on L3's tree) and its patches | 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" | An unpublished measurement-only script | As S1a. Size L, parity risk high: TradingView's margin money rules |
@@ -183,7 +183,7 @@ them for the record only. "Linux aarch64" is the maintainers' Cortex-A725 host.
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, Linux aarch64 (Cortex-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" | Lane L3's code, merged by INT22 (#285); its profiles are unpublished | 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:16776`) takes the process timezone lock through `ScopedTimezone` and calls `localtime_r` on every bar, because `on_bar_open` (`src/source/pine_adapter.cpp:21475`) reads `chart_day_key` (`src/source/pine_adapter.cpp:21704`) 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:16760`) | Not measured on a zoned chart. The UTC path cost 134 instructions a bar before D2-D's memo and 68 after (D2-D, Linux aarch64, 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:16916`) takes the process timezone lock through `ScopedTimezone` and calls `localtime_r` on every bar, because `on_bar_open` (`src/source/pine_adapter.cpp:21797`) reads `chart_day_key` (`src/source/pine_adapter.cpp:22034`) 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:16900`) | Not measured on a zoned chart. The UTC path cost 134 instructions a bar before D2-D's memo and 68 after (D2-D, Linux aarch64, 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 (Linux 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 | Unpublished (AUDIT4's scratch) | 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:9460-9471`) 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:2784`). K4 still
202+
`NativeEventRetention::Window` (`src/source/pine_adapter.cpp:2792`). 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 Linux aarch64) 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:6153`) returns at its receipt gate when no
213+
(`src/source/pine_adapter.cpp:6161`) 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:2256-2257`), with their type
244+
(`include/pineforge/source/pine_adapter.hpp:2299-2300`), 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/native-engine.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1496,7 +1496,7 @@ adapter answers `margin_check_allowed` with TradingView's scheduling — which
14961496
includes the post-exit re-size: when a priced bracket leg of the script bar
14971497
fills, the slice resting at that bar's adverse extreme was sized on the
14981498
pre-exit book, and the legacy broker cancelled and re-scheduled it there
1499-
(`margin_check_allowed` `pine_adapter.cpp:17241-17274`), so the adapter admits
1499+
(`margin_check_allowed` `pine_adapter.cpp:17381-17414`), so the adapter admits
15001500
the kernel's own point for that driver point while (and only while) a slice
15011501
rests —
15021502
`resolve_margin_requirement` with its ten-significant-digit money and

0 commit comments

Comments
 (0)