|
| 1 | +# Explicit Pine execution attachment and order priority |
| 2 | + |
| 3 | +`BacktestEngine::attach_pine_execution_adapter()` explicitly selects two |
| 4 | +compatibility components: the existing intraday cap and retained-parent order |
| 5 | +priority. It is idempotent, preserves configuration and outstanding cap state, |
| 6 | +and does not imply that all Pine behavior has been extracted from the engine. |
| 7 | +`enable_pine_intraday_cap()`, the cap constructor argument and legacy integer |
| 8 | +cap assignments remain cap-only operations. |
| 9 | + |
| 10 | +Bare construction leaves order priority detached. Syminfo metadata, including |
| 11 | +`flat_retained_child_fresh_parent_order=1`, cannot attach it. The Pine component |
| 12 | +owns that key's finite-positive interpretation and retains a supplied value |
| 13 | +while detached; explicit attachment preserves a prior off override. Under Pine |
| 14 | +attachment, an absent key enables the exact historical exception. Zero, negative |
| 15 | +and nonfinite supplied values disable it. Copy/reset preserve attachment and |
| 16 | +configuration without retaining a cached scheduling decision. |
| 17 | + |
| 18 | +The full predicate lives in `src/compat/pine/order_priority.cpp`: exact two-object |
| 19 | +book, ordinary POOC context, flat placement, named-cancel and exact child-reissue |
| 20 | +receipts, adjacent incarnations, default quantities, full absolute stop+limit |
| 21 | +child, pure-stop parent, prior-bar age and all OCA/callback/magnifier/stream |
| 22 | +exclusions. Three/four unrelated orders and an intervening accepted-and-canceled |
| 23 | +order remain exclusions. This is one active rule transferred to Pine ownership, |
| 24 | +not a claim that its source-shape policy disappeared globally. |
| 25 | + |
| 26 | +The comparator consumes an immutable `broker::OrderPriorityDecision` bound to |
| 27 | +exact incarnations. It substitutes two sequence tie-breaks at their former |
| 28 | +location, after fill phase. It does not change eligibility, fill prices, OCA |
| 29 | +mutation, callbacks, admission or financial accounting. Shared incarnation |
| 30 | +receipts and their other compatibility consumers remain unchanged. |
| 31 | + |
| 32 | +## Pairing and regeneration |
| 33 | + |
| 34 | +New codegen calls the fully qualified attachment method in the constructor, |
| 35 | +before `strategy_create` returns and host metadata arrives: |
| 36 | + |
| 37 | +```cpp |
| 38 | +#if defined(PINEFORGE_HAS_EXPLICIT_PINE_EXECUTION_ADAPTER_V1) |
| 39 | + pineforge::BacktestEngine::attach_pine_execution_adapter(); |
| 40 | +#elif defined(PINEFORGE_HAS_EXPLICIT_PINE_CAP_V1) |
| 41 | + pineforge::BacktestEngine::enable_pine_intraday_cap(); |
| 42 | +#endif |
| 43 | +``` |
| 44 | + |
| 45 | +The fallback preserves existing cap-only engines' native-to-Pine cap selection |
| 46 | +and their old default retained-parent rule. Engines lacking both capabilities |
| 47 | +use their established defaults. This is generated-source portability with |
| 48 | +matching headers/runtime, not binary compatibility across engine versions. |
| 49 | + |
| 50 | +Old cap-only generated source can compile with current headers but does **not** |
| 51 | +select the priority exception. Regenerate it with the paired codegen, or |
| 52 | +explicitly update a maintained C++ Pine frontend to call the attachment method |
| 53 | +before metadata. Neither metadata nor an implicit constructor default repairs |
| 54 | +old source. Existing checked-in corpus/tutorial C++ must likewise be regenerated |
| 55 | +before using it for Pine behavior measurements; compilation alone is insufficient. |
| 56 | + |
| 57 | +Rebuild every C++ consumer with matching current headers and archive. The class |
| 58 | +namespace is `engine_script_run_v4`; frozen v2/base38 and v3/f864 callers are |
| 59 | +compile/link rejection controls. Broker fingerprint domain and stream fingerprint |
| 60 | +version are now 4 and include priority attachment/configuration. Prior hashes |
| 61 | +are not comparable. Public C functions, PODs and ABI/API versions are unchanged; |
| 62 | +an erased handle still belongs to its creating module. |
| 63 | + |
| 64 | +## Remaining native gap and evidence limits |
| 65 | + |
| 66 | +Bare native execution retains the ordinary phase/sequence scan. An older child |
| 67 | +visited while flat can still be skipped until a later pass, exposing a transient |
| 68 | +position to the intervening close-time observer. No identity-bound child |
| 69 | +activation/event queue has been added. That causal scheduler is a separate next |
| 70 | +slice, not an unused reducer in this extraction. |
| 71 | + |
| 72 | +Literal C++ controls preserve the old Pine price, quantity, timing and financial |
| 73 | +assertions with explicit fixture attachment; they separately pin native metadata |
| 74 | +inertness, exclusions, OCA, copy/reset/hash and current lifetime safety. Codegen |
| 75 | +checks compile source only. None establishes TV truth, measured campaign |
| 76 | +neutrality, actualZERO, absence of population regressions or readiness to publish. |
0 commit comments