Skip to content

Commit 39cc605

Browse files
luisleo526claude
andcommitted
Docs: F7's records and the citations its src edits moved (R5 lane F7)
design/native-feature-parity.md: * MG9 -- the kernel's FxRoll point stays refused for the measured MG-FX reason; §4.4's two N6 follow-ups are closed (the leveraged carried roll takes TradingView's broker-open checkpoint; a staged FX series keeps Sized wherever the acceptance coordinate converts at the source's rate) with their named expectations; * §4.1 E3 -- the conversion exists once, in the kernel, for default AND typed quantities; what the adapter keeps is listed with its witnesses; * OL4 -- M27's measured reason (same-call source commands the kernel has not seen; the __close__<id> label); * §4.1 E8 -- M26 recorded: the pre-run TimeframeAggregator pass is kept because its count is needed before the first input and the kernel offers no pre-run interval query (a kernel capability F7 did not add); * row g -- pine_path_resolve.cpp is 83 lines, the override-reading overload is gone; * §3.6.2 -- anchored relative trailing legs name no best_seed and no tape measures them: recorded as an open measurement with the tape it needs, not changed. MG7, L3, L4 and E2 were corrected with the D2 commit. Citations: every pine_adapter.cpp / pine_path_resolve.cpp anchor in the published pages moved through an exact difflib line map from fd78592's copy to this tree (164 moved; E20's reanchor tool). Three sat in changed blocks and were set by hand: SZ3's default_sizing_units span, row g's entry_stop_first_touch, and OL13's reversal-gap bracket policy, whose two symbol-less anchors (:12912, :12940 at fd78592) pointed into carried_pooc_short_margin_before_script_scope -- deleted by this lane as dead -- and now name apply_reversal_gap_bracket_policy and reaccept_gapped_bracket_behind_same_id_add. docs/pages/native-engine.md carries one moved digit (pine_path_resolve.cpp:41 -> :36). check_doc_anchors: 1563/1563 resolve; check_doc_lint, design inventory, feature rulings and spec shadowing unchanged and passing. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit 0e050d115a77ebdb4e72e9d02a3d06542cab2cb0)
1 parent 433d6ed commit 39cc605

3 files changed

Lines changed: 109 additions & 98 deletions

File tree

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

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -195,35 +195,35 @@ kernel and own these quirks, each at its site:
195195
- **Seams the adapter overrides.** The kernel is driven, not patched. `PineStrategyHost` overrides
196196
`resolve_execution_terms` (`pine_strategy_host.cpp:730`) for TV sizing and fill spelling;
197197
`validate_execution_precommit` (`pine_strategy_host.cpp:755`), whose
198-
`validate_precommit` (`pine_adapter.cpp:11433`) returns `AdmitWithHostMargin`
199-
(`pine_adapter.cpp:11678`) to own the opening margin decision; `owns_lot_excursions() = true`
198+
`validate_precommit` (`pine_adapter.cpp:11339`) returns `AdmitWithHostMargin`
199+
(`pine_adapter.cpp:11584`) to own the opening margin decision; `owns_lot_excursions() = true`
200200
(`pine_strategy_host.hpp:284-285`) with `closed_lot_excursion` (`pine_strategy_host.cpp:869`), so
201201
MFE/MAE are measured on TV tick-quantized prices; and `on_native_tick`
202202
(`pine_strategy_host.cpp:361`) / `on_native_applied` (`pine_strategy_host.cpp:457`) for
203203
`calc_on_order_fills` re-entry. `process_orders_on_close` becomes
204-
`NativeCloseExecution::AfterCalculation` in the projected spec (`pine_adapter.cpp:1515-1516`);
204+
`NativeCloseExecution::AfterCalculation` in the projected spec (`pine_adapter.cpp:1499-1500`);
205205
calc cadence and language publication are `PineScheduler`'s (`pine_scheduler.hpp:20`).
206206
- **Batching and open-order priority.** Same-bar command batching and its deferred queues
207207
(`pine_adapter.hpp:1219-1232`); the retained parent-before-child ordering of live handles — an
208208
exactly-shaped entry and its `from_entry` exit, re-created after a named cancel, on a flat book
209209
under `process_orders_on_close` (`src/compat/pine/order_priority.cpp:13-59`, applied by
210-
`pine_adapter.cpp:821-880`). Kernel priority is acceptance/incarnation order.
210+
`pine_adapter.cpp:805-864`). Kernel priority is acceptance/incarnation order.
211211
- **Exit-leg lifecycle.** Activation / suspension / revival barriers
212212
(`src/compat/pine/exit_activation.cpp:42-60`) and historical birth reach
213213
(`src/compat/pine/order_birth.cpp:5-14`).
214214
- **Trail and tick conventions.** The half-tick arm threshold measured against tick-quantized
215-
extremes while the raw running best is retained (`pine_adapter.cpp:7655-7660`); the half-tick
216-
trigger threshold (`pine_adapter.cpp:328-340`) and raw-vs-booked fill spelling, behind the
217-
adapter's terms seam (`pine_adapter.cpp:9310`).
218-
- **Money arithmetic.** Ten-significant-digit half-up money (`pine_adapter.cpp:396-403`, twin
215+
extremes while the raw running best is retained (`pine_adapter.cpp:7566-7571`); the half-tick
216+
trigger threshold (`pine_adapter.cpp:322-334`) and raw-vs-booked fill spelling, behind the
217+
adapter's terms seam (`pine_adapter.cpp:9221`).
218+
- **Money arithmetic.** Ten-significant-digit half-up money (`pine_adapter.cpp:390-397`, twin
219219
`pine_policy_support.hpp:9-15`).
220220
- **Close reservations.** `strategy.close` callsite batching, two-call provenance and the entry-id
221221
ledger (`pine_adapter.hpp:1247-1258`); the POOC reservation-growth population predicate
222222
(`src/compat/pine/reservation_expansion.cpp:9-20`).
223223
- **Margin.** The kernel owns the margin *mechanism* — the level solve, the check points, the
224224
kernel request, its re-pricing, the receipt — and the adapter answers its three policy hooks
225-
with TradingView's: `margin_check_allowed` (`pine_adapter.cpp:12413`) for the scheduling,
226-
`resolve_margin_requirement` (`pine_adapter.cpp:12446`) for the ten-significant-digit money,
225+
with TradingView's: `margin_check_allowed` (`pine_adapter.cpp:12319`) for the scheduling,
226+
`resolve_margin_requirement` (`pine_adapter.cpp:12355`) for the ten-significant-digit money,
227227
and `resolve_margin_call_units` for the lot-floored 4x restore. That hook answers every call
228228
on purpose (R5 lane F7): TradingView floors the restore onto the lot grid before the multiple,
229229
so on a gridded tape the kernel's own `ShortfallMultiple 4` books 5 lots where TradingView
@@ -234,17 +234,17 @@ kernel and own these quirks, each at its site:
234234
margin since F7), while the roll point measures at the remaining path's adverse mark (MG-FX:
235235
0.4116 @ 97 there against TradingView's 0.3996 @ 100). What has no kernel check point at all
236236
stays adapter-side: the `process_orders_on_close` chronology exception
237-
(`non_pooc_commissioned_short` `pine_adapter.cpp:14992`), the pre-open admission slice and
237+
(`non_pooc_commissioned_short` `pine_adapter.cpp:14816`), the pre-open admission slice and
238238
the 1x-long money call — plus the TV admission scopes
239239
(`src/compat/pine/market_admission.cpp:33-46`) and the review fold they feed (`:67-72`,
240240
`:79-136`).
241241
- **Calculation timing.** The cadence itself is the kernel's: a `calc_on_order_fills` strategy
242242
projects `NativeCalculationTrigger::BarCloseAndFills` with TradingView's guard literal as
243243
`max_recalculations_per_point`. What stays are the specifics COOF adds on top —
244244
the language-state snapshot/restore around a recalculation, the waypoint-only refill deferral
245-
(`next_source_path_waypoint` `pine_adapter.cpp:6686`), the first-open execution chain and its
245+
(`next_source_path_waypoint` `pine_adapter.cpp:6597`), the first-open execution chain and its
246246
own loop guard (`pine_scheduler_native.cpp:688`), and the two fills Pine refuses to
247-
recalculate on (`suppress_grouped_stop_recalc` `pine_adapter.cpp:4036`).
247+
recalculate on (`suppress_grouped_stop_recalc` `pine_adapter.cpp:3973`).
248248
- **Pine language state and harness flags.** Series and position-view freezing
249249
(`PineLanguageState` `pine_language_state.hpp:12`); the three session flags generated code
250250
reads, `PineStrategyHost` members since R5 lane F5 (`session_ismarket_`
@@ -291,7 +291,7 @@ citations, 264 are in `src/source/` and its headers; 6 sit in kernel files
291291
between `round_to_mintick` and `bar_fill_price`), deleted by R5 lane E6; the `:73-180` span
292292
earlier drafts cited is and was live code (`ClosedLotExcursionFacts`, `PyramidEntry`,
293293
`Trade`, each with its own doc). The arithmetic is
294-
adapter-side (`pine_adapter.cpp:396-403`). `strategy.close` batching and the entry-id ledger
294+
adapter-side (`pine_adapter.cpp:390-397`). `strategy.close` batching and the entry-id ledger
295295
are **gone** from the kernel — the ledger is adapter state (`pine_adapter.hpp:1247-1258`) and
296296
only names survive in comments. The TradingView margin-call toggle is **gone**: there is no
297297
`set_margin_call_enabled` in the tree, and what enables the model is the presence of
@@ -517,13 +517,13 @@ Every line number in this section names its symbol on this tree, which
517517
<!-- native-feature-rulings:begin -->
518518
| `NativeRunSpec` field | ruling | what the adapter runs instead | measurement and ruling of record | executed native consumers |
519519
|---|---|---|---|---|
520-
| `price_grid`, `grid_rounding` | **native-only** | TradingView's per-order-kind tick rules on top of `None`: `source_trigger_threshold` (`pine_adapter.cpp:329`), `source_level_on_price_grid` (`:315`), `nearest_tick` (`:253`) / `source_bar_fill_tick` (`:274`) / `directional_tick` (`:298`), behind the terms seam | R5-3 and design risk E7 ruled `None` for the adapter before the lane ran; lanes R7 and N13 measured the alternative anyway (raw levels submitted, `QuantizeFillsAndTriggers` with `HalfUp` declared). L8b closed the first blocker (no run aborts). The second has no remedy on either side: TradingView quantizes per order kind (stop and limit legs and a trail's activation on the quantized bar; the trail stop, the running best, stop-limit entries and the `calc_on_order_fills` cursors raw), the grid is one rule for the run, and it still moves 30 pinned checks in 4 units; a per-kind mask would spell that inconsistency into the kernel. The corpus cannot arbitrate (every probe runs a 0.01 tick on an on-grid feed; 5 of 312 differ in an engine-only column). Permanent witness: `tests/test_adapter_grid_relower.cpp`, whose section 5 pins the trail stop the grid fires a bar early. Design row PG and §3.6 | `examples/native/native_price_grid_strategy.cpp`, `examples/native/native_price_grid_c.c`, `tests/test_native_price_grid.cpp` |
521-
| `risk` | **native-only** | all of `strategy.risk.*` but the direction: `update_risk_state` (`pine_adapter.cpp:12211`), `SourceDayLedger`, `submit_intraday_loss_close` (`pine_adapter.cpp:13291`), `chart_day_key` (`pine_adapter.cpp:12105`), `compat::pine::IntradayCap` with `IntradayOrderBudget` (337 lines) | Structural first: Pine's risk calls are per-bar statements, so a limit reaches the adapter on script bar 0, after `project()` (`pine_strategy_host.cpp:314`) and `configure_native` (`pine_strategy_host.cpp:315`) have fixed and digested the spec. In substance (lane N12, `tests/test_adapter_risk_relower.cpp`, 62 checks over nine paired scenarios): the drawdown latch samples at the close only and still admits a reversal; the loss-day streak counts trades, not days; the intraday loss closes at the path's adverse extreme, refuses every placement and withdraws the book; the fill cap charges slots, transfers quota and closes at the bar's better extreme on the chart timezone's day. With the kernel seeded on the corpus, 3 of 4 cap probes diverge (3840 of 3916, 312 of 604, 2370 of 2384 rows). `strategy.risk.allow_entry_in` is the one rule that is the kernel's already (`allowed_open_directions`). Design §3.6 | `examples/native/native_risk_limits_strategy.cpp`, `examples/native/native_trail_risk_strategy.cpp`, `tests/test_native_risk_limits.cpp`, `tests/test_native_c_api.c` |
522-
| `max_abs_units` | **adapter-policy** | `strategy.risk.max_position_size` as a gate on the LIVE book before the fill (`pine_adapter.cpp:11499-11500`): an entry is refused once the book already holds the limit | design row MG2 (R5-1): the resulting-book cap is the generic one. Measured by N12's scenario `PS` in `tests/test_adapter_risk_relower.cpp`: two-unit entries against a limit of 3 leave the adapter at 4 and the kernel cap at 2 | `tests/test_native_resting_matching_contract.cpp`, `tests/test_native_run_spec.cpp` |
523-
| `max_open_lots` | **adapter-policy** | Pine pyramiding is a per-cycle entry count in the adapter's command policy; a resting source entry must not consume a physical-lot cap before it fills (`pine_adapter.cpp:1494-1496`) | design row MG3 (R5-1); the contract comment in `project()` | `tests/test_native_resting_matching_contract.cpp`, `tests/test_native_margin_model.cpp` |
524-
| `initial_margin_fraction` | **adapter-policy** | TradingView's ten-significant-digit money admission against the signal-time tuple, answered as `AdmitWithHostMargin`; the `margin` model the adapter does declare is maintenance-only (`NativeMarginModel` `pine_adapter.cpp:1583-1591`, `margin.maintenance_long` `pine_adapter.cpp:1598`) | design row MG4 and the wave-4 ruling recorded in `project()`: a positive initial requirement would decline openings TradingView takes | `tests/test_native_precommit_view.cpp`, `tests/test_native_margin_model.cpp` |
525-
| `report_open_position_at_end` | **adapter-policy** | TradingView's range-end report re-marks the curve's last point and re-folds every extreme from it (`scheduler_record_range_end`): report shape, not a mark-to-market row (`pine_adapter.cpp:1530-1537`) | design row RP5; the kernel reads the field under `KernelRecorded` only, which `scripts/check_adapter_spec_shadowing.py` gates | `examples/native/native_sized_report_strategy.cpp`, `tests/test_native_report_truth.cpp` |
526-
| `open_bar_view` | **adapter-policy** | `Complete`: TradingView's bar-open scheduling and its `calc_on_order_fills` callback read the whole script bar (`pine_adapter.cpp:1521-1522`) | design rows CT4 and E5: the open-only view is opt-in because the adapter needs the full bar | `examples/native/native_calc_on_fills_strategy.cpp`, `tests/test_native_calc_timing.cpp` |
520+
| `price_grid`, `grid_rounding` | **native-only** | TradingView's per-order-kind tick rules on top of `None`: `source_trigger_threshold` (`pine_adapter.cpp:323`), `source_level_on_price_grid` (`:309`), `nearest_tick` (`:247`) / `source_bar_fill_tick` (`:268`) / `directional_tick` (`:292`), behind the terms seam | R5-3 and design risk E7 ruled `None` for the adapter before the lane ran; lanes R7 and N13 measured the alternative anyway (raw levels submitted, `QuantizeFillsAndTriggers` with `HalfUp` declared). L8b closed the first blocker (no run aborts). The second has no remedy on either side: TradingView quantizes per order kind (stop and limit legs and a trail's activation on the quantized bar; the trail stop, the running best, stop-limit entries and the `calc_on_order_fills` cursors raw), the grid is one rule for the run, and it still moves 30 pinned checks in 4 units; a per-kind mask would spell that inconsistency into the kernel. The corpus cannot arbitrate (every probe runs a 0.01 tick on an on-grid feed; 5 of 312 differ in an engine-only column). Permanent witness: `tests/test_adapter_grid_relower.cpp`, whose section 5 pins the trail stop the grid fires a bar early. Design row PG and §3.6 | `examples/native/native_price_grid_strategy.cpp`, `examples/native/native_price_grid_c.c`, `tests/test_native_price_grid.cpp` |
521+
| `risk` | **native-only** | all of `strategy.risk.*` but the direction: `update_risk_state` (`pine_adapter.cpp:12117`), `SourceDayLedger`, `submit_intraday_loss_close` (`pine_adapter.cpp:13118`), `chart_day_key` (`pine_adapter.cpp:12011`), `compat::pine::IntradayCap` with `IntradayOrderBudget` (337 lines) | Structural first: Pine's risk calls are per-bar statements, so a limit reaches the adapter on script bar 0, after `project()` (`pine_strategy_host.cpp:314`) and `configure_native` (`pine_strategy_host.cpp:315`) have fixed and digested the spec. In substance (lane N12, `tests/test_adapter_risk_relower.cpp`, 62 checks over nine paired scenarios): the drawdown latch samples at the close only and still admits a reversal; the loss-day streak counts trades, not days; the intraday loss closes at the path's adverse extreme, refuses every placement and withdraws the book; the fill cap charges slots, transfers quota and closes at the bar's better extreme on the chart timezone's day. With the kernel seeded on the corpus, 3 of 4 cap probes diverge (3840 of 3916, 312 of 604, 2370 of 2384 rows). `strategy.risk.allow_entry_in` is the one rule that is the kernel's already (`allowed_open_directions`). Design §3.6 | `examples/native/native_risk_limits_strategy.cpp`, `examples/native/native_trail_risk_strategy.cpp`, `tests/test_native_risk_limits.cpp`, `tests/test_native_c_api.c` |
522+
| `max_abs_units` | **adapter-policy** | `strategy.risk.max_position_size` as a gate on the LIVE book before the fill (`pine_adapter.cpp:11405-11406`): an entry is refused once the book already holds the limit | design row MG2 (R5-1): the resulting-book cap is the generic one. Measured by N12's scenario `PS` in `tests/test_adapter_risk_relower.cpp`: two-unit entries against a limit of 3 leave the adapter at 4 and the kernel cap at 2 | `tests/test_native_resting_matching_contract.cpp`, `tests/test_native_run_spec.cpp` |
523+
| `max_open_lots` | **adapter-policy** | Pine pyramiding is a per-cycle entry count in the adapter's command policy; a resting source entry must not consume a physical-lot cap before it fills (`pine_adapter.cpp:1478-1480`) | design row MG3 (R5-1); the contract comment in `project()` | `tests/test_native_resting_matching_contract.cpp`, `tests/test_native_margin_model.cpp` |
524+
| `initial_margin_fraction` | **adapter-policy** | TradingView's ten-significant-digit money admission against the signal-time tuple, answered as `AdmitWithHostMargin`; the `margin` model the adapter does declare is maintenance-only (`NativeMarginModel` `pine_adapter.cpp:1567-1575`, `margin.maintenance_long` `pine_adapter.cpp:1582`) | design row MG4 and the wave-4 ruling recorded in `project()`: a positive initial requirement would decline openings TradingView takes | `tests/test_native_precommit_view.cpp`, `tests/test_native_margin_model.cpp` |
525+
| `report_open_position_at_end` | **adapter-policy** | TradingView's range-end report re-marks the curve's last point and re-folds every extreme from it (`scheduler_record_range_end`): report shape, not a mark-to-market row (`pine_adapter.cpp:1514-1521`) | design row RP5; the kernel reads the field under `KernelRecorded` only, which `scripts/check_adapter_spec_shadowing.py` gates | `examples/native/native_sized_report_strategy.cpp`, `tests/test_native_report_truth.cpp` |
526+
| `open_bar_view` | **adapter-policy** | `Complete`: TradingView's bar-open scheduling and its `calc_on_order_fills` callback read the whole script bar (`pine_adapter.cpp:1505-1506`) | design rows CT4 and E5: the open-only view is opt-in because the adapter needs the full bar | `examples/native/native_calc_on_fills_strategy.cpp`, `tests/test_native_calc_timing.cpp` |
527527
| `subscriptions` | **adapter-hook** | `declare_timeframe_subscriptions` from the begin-time hook (`pine_strategy_host.cpp:1661`): a plain `request.security` site is a kernel subscription | lane R3b over the L6c hook: 21 of the corpus's 23 `request.security` probes run their sites on the kernel, byte-identical; the sites the predicate leaves out (lower timeframe, lookahead, auxiliary, streams) keep the source evaluator | `examples/native/native_htf_strategy.cpp`, `tests/test_native_htf_subscriptions.cpp` |
528528
| `auxiliary_feed` | **adapter-policy** | the adapter's own auxiliary drive: the chart-slice mapping and the deferred first bucket (`src/source/pine_aux_security.cpp`) | lane N7, retained on three measurements: 0 of 312 corpus probes install an auxiliary feed; TradingView's chart slice leaves pre-range coverage inert where the kernel folds it by time, and evaluates after the bar's matching pass where the kernel delivers before it (`tests/test_native_auxiliary_feed_twin.cpp`, rows B and C). Design §2.iv | `tests/test_native_auxiliary_feed.cpp`, `tests/test_native_auxiliary_feed_stream.cpp` |
529529
<!-- native-feature-rulings:end -->
@@ -601,7 +601,7 @@ The comment survived the code. They are not rule-2 questions at all; they are ru
601601
| `src/engine_run.cpp:162-186` | `process_orders_on_close` semantics | `reset_run_state()` at `:85`, unrelated | **residue.** The live mechanism is the spec field `NativeCloseExecution::AfterCalculation` (`native_run_spec.hpp:27`) |
602602
| `include/pineforge/engine.hpp:1136-1204` | TradingView freezes default market-order sizing at the signal bar | `net_profit()` at `:935`; `:1136`-`:1255` is one comment block | **residue.** The live mechanism is `native_order::SizePrice` (`Signal`, `SignalOnTick`) with `SizeTime::AtAcceptance` — a request value that names no platform |
603603
| `include/pineforge/engine.hpp:1226-1255` | TradingView liquidates intrabar, before the bar-close script body | `net_profit()` at `:935` | **residue.** The live mechanism is `NativeLiquidationCheck` (`native_run_spec.hpp:157`), whose three values are three broker models |
604-
| `include/pineforge/engine.hpp:896-916` (the row first named `:73-180`, which is and was live code: `ClosedLotExcursionFacts`, `PyramidEntry`, `Trade`) | the ten-significant-digit money rule | `bar_fill_price`, whose own live doc was kept | **residue** (already recorded above): the arithmetic is `pine_adapter.cpp:396-403`. **Deleted by R5 lane E6.** |
604+
| `include/pineforge/engine.hpp:896-916` (the row first named `:73-180`, which is and was live code: `ClosedLotExcursionFacts`, `PyramidEntry`, `Trade`) | the ten-significant-digit money rule | `bar_fill_price`, whose own live doc was kept | **residue** (already recorded above): the arithmetic is `pine_adapter.cpp:390-397`. **Deleted by R5 lane E6.** |
605605

606606
**For a code lane, not this document:** these blocks total **312 lines** — `engine_orders.cpp`
607607
`:200-224` and `:556-697`, `engine_run.cpp` `:162-186`, `engine.hpp` `:1262-1381` — and not one

0 commit comments

Comments
 (0)