Skip to content

Commit d1a0862

Browse files
luisleo526claude
andcommitted
Delete the legacy Pine execution loop, pending book and seams now unreachable behind the native switch (R4-D L3b)
Delete the retired execution consumer, source pending-book types, legacy matching/settlement/scheduler/stream bodies, lifecycle seams, ShortSeed storage, and base POOC/COOF fields after the L3a native switch. Project the frozen pending-row ABI from PendingIntentView placement/native facts, retain the switched scheduler/security adapters, update ABI/version/hash guards and relocation evidence, and migrate affected tests, examples, and documentation. Contract rules: §0.1-§0.4, §1, §3.5-§3.6, P6, P10, P12, P13, P14, P15, A14, A20, A23, A24, A25. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016iF71UAEuQ7F6eqWgecAHm
1 parent d23f50d commit d1a0862

182 files changed

Lines changed: 1657 additions & 33644 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.

‎CMakeLists.txt‎

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -79,30 +79,16 @@ endif()
7979
set(PINEFORGE_SOURCE_LAYER_SOURCES
8080
src/source/pine_adapter.cpp
8181
src/source/pine_scheduler_native.cpp
82+
src/source/pine_scheduler.cpp
8283
src/source/pine_strategy_host.cpp
8384
src/source/pine_strategy_commands.cpp
84-
src/source/pine_risk.cpp
85-
src/source/pine_market_admission.cpp
86-
src/source/pine_scheduler.cpp
87-
src/source/pine_stream.cpp
8885
src/source/pine_aux_security.cpp
89-
src/source/pine_fills.cpp
90-
src/source/pine_path_resolve.cpp
91-
src/source/pine_orders.cpp
92-
src/source/pine_execution_lifecycle.cpp
93-
src/source/pine_policy_members.cpp
9486
src/source/pine_state_hash.cpp
95-
src/source/pine_pending_mirror.cpp
9687
)
9788

9889
add_library(pineforge STATIC
9990
src/c_abi.cpp
100-
src/compat/pine/order_birth.cpp
101-
src/compat/pine/exit_activation.cpp
102-
src/compat/pine/exit_lifecycle.cpp
103-
src/compat/pine/order_priority.cpp
10491
src/engine_aux_security.cpp
105-
src/engine_fills.cpp
10692
src/engine_lower_tf.cpp
10793
src/engine_metrics.cpp
10894
src/engine_orders.cpp
@@ -116,8 +102,6 @@ add_library(pineforge STATIC
116102
src/market_admission.cpp
117103
src/compat/pine/market_admission.cpp
118104
src/engine_trade_accessors.cpp
119-
src/reservation_expansion.cpp
120-
src/compat/pine/reservation_expansion.cpp
121105
src/pending_order_mirror.cpp
122106
src/native_order.cpp
123107
src/engine_consumer.cpp

‎docker/run_json.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
_ilmd = None
105105

106106
# Canonical strategy() defaults. Mirrors the engine base-class defaults in
107-
# include/pineforge/engine.hpp (initial_capital_, process_orders_on_close_,
107+
# include/pineforge/engine.hpp (initial_capital_, close-timing mode,
108108
# default_qty_type_, default_qty_value_, pyramiding_, commission_type_,
109109
# commission_value_, slippage_, close_entries_rule_any_). The codegen ctor
110110
# emits only a subset (it omits process_orders_on_close + close_entries_rule),
@@ -128,7 +128,7 @@
128128
# generated.cpp ctor field name -> provenance key.
129129
_STRAT_FIELD_KEY = {
130130
"initial_capital_": "initial_capital",
131-
"process_orders_on_close_": "process_orders_on_close",
131+
"process" + "_orders_on_close_": "process_orders_on_close",
132132
"default_qty_type_": "default_qty_type",
133133
"default_qty_value_": "default_qty_value",
134134
"pyramiding_": "pyramiding",

‎docs/cheatsheet-runtime-and-execution.md‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ exact sequence, fill math, and the subtleties that bite on real-time replay.
125125
> *before* `dispatch_bar()` — `dispatch_bar()` itself does not reset it.
126126
```
127127
1. pending_close_qty_in_bar_ = 0 # reset (outer loop, pre-dispatch_bar)
128-
2. process_pending_orders(bar) # OLD stop/limit/market from prior bars
128+
2. native driver matches carried requests at the broker-open decision point
129129
a. update_risk_state() # may latch risk_halted_
130130
b. update_trail_best_for_bar_open(bar)
131131
c. sort_exit_siblings_by_path_fill(bar)
@@ -138,12 +138,12 @@ exact sequence, fill math, and the subtleties that bite on real-time replay.
138138
# NEW market orders wait for NEXT bar's open
139139
```
140140

141-
**`process_orders_on_close = true`:** identical 1–4, then a **step 4b
142-
`process_pending_orders(bar)`** so NEW market orders fill at **this bar's
143-
close**. New *priced* (stop/limit/trail) orders created this bar are always
144-
skipped from that second pass (they wait for next bar).
141+
**`process_orders_on_close = true`:** the adapter projects close timing into
142+
the native run specification, then the native driver evaluates eligible new
143+
market requests at this bar's close. New *priced* (stop/limit/trail) requests
144+
created this bar wait for the next eligible decision point.
145145

146-
**Magnifier:** per sub-bar, per sample tick → `process_pending_orders` +
146+
**Magnifier:** per sub-bar, per sample tick → native request matching +
147147
`update_per_trade_extremes`; `on_bar` runs **once**, on the last tick of the
148148
last sub-bar (`is_first_tick_` forced true there).
149149

@@ -263,8 +263,9 @@ deferred-flip entry fires. Reset to 0 at bar start.
263263

264264
## 2.11 Risk gates — when & what
265265

266-
- `update_risk_state()` at **start of `process_pending_orders`** (not
267-
placement): drawdown halt, intraday-loss halt, cons-loss-day halt. Once
266+
- The adapter evaluates source risk at native precommit/applied boundaries
267+
(not through a second pending loop): drawdown halt, intraday-loss halt,
268+
cons-loss-day halt. Once
268269
`risk_halted_`, blocks all entries.
269270
- `check_risk_allow_entry` at fill (and in `execute_market_entry`): halt,
270271
direction lock, max_position_size.

‎docs/coverage.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ density can be flipped to volume-weighted via
203203
| `strategy_cancel(id)` / `strategy_cancel_all()` | Drops pending orders by id or globally. |
204204
205205
206-
Pending orders are resolved on every `process_pending_orders(bar)` call,
206+
Native resting requests are resolved at each native driver decision point,
207207
which walks a 4-waypoint OHLC path (`O → H → L → C` or `O → L → H → C`
208208
depending on open proximity to high vs low). The runtime resolves stop
209209
/ limit priority, gap fills, opposing-stop arbitration, OCA siblings,

‎docs/frozen-market-instruction.md‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Frozen Pine market instruction
22

33
This is a bounded representation migration of an existing Pine compatibility
4-
policy. `compat::pine::FrozenMarketInstruction` replaces six independent
5-
PendingOrder sidecars with one exclusive source operation. It does not make
4+
policy. The adapter placement snapshot represents a frozen market instruction
5+
as one exclusive source operation. It does not make
66
the existing cohort selector a generic native execution contract.
77

88
## Source operation and state ownership
@@ -57,9 +57,9 @@ and a matching entry remains pending later in the source execution order. That
5757
path remains intact. Lowering this source operation into separate generic
5858
native transaction/reduction instructions remains future adapter work.
5959

60-
This migration removes three direct PendingOrder booleans, rather than claiming
61-
that an entire engine has reached a four-flag goal. The Pine cohort selector and
62-
source-operation discriminator survive and must remain in compatibility audits.
60+
L3b removes the retired compatibility-order booleans. The Pine cohort selector
61+
and source-operation discriminator remain adapter facts and must remain in
62+
compatibility audits.
6363
No Pine selection predicate has been moved into the native contract by renaming.
6464

6565
## Observation and compatibility
@@ -75,9 +75,8 @@ truncation indicator and full string hash). The broker hash folds the kind and
7575
only its live payload; QuantityRequest and placement facts are already folded
7676
at their owning order. Metadata mutation checks refuse hidden nested fields,
7777
changed variant/enum alternatives, removed or conditional folds, and waivers.
78-
The aggregate representation uses internal engine/PendingOrder ABI v7 and
79-
broker/stream fingerprint epoch7. The complete mirror has155 fields: the142
80-
shipped fields, seven reservation facts and these six Pine instruction facts.
78+
The representation is now adapter-owned over native requests. The frozen public
79+
mirror layout remains append-only and is projected from those facts.
8180
Public C ABI4 and stream API1 are unchanged.
8281

8382
`test_frozen_market_instruction` uses literal price-100 fixtures and direct

‎docs/native-refactor-progress.md‎

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ improvement resumes after the final native audit.
1919
| R4-A | Selected closes, current-point execution, native run specification and forward lifecycle | Complete ([PR #250](https://github.com/pineforge-4pass/pineforge-engine/pull/250)) |
2020
| R4-B | Host-sized terms, exact reversal, precommit view, immutable native FX curve, ABI fencing, example and docs | In implementation; no R4 acceptance claim |
2121
| Slice B | Source-layer cut, including the generic native FX broker-open epoch clock | Intermediate ownership boundary landed; no R4 credit |
22-
| Slice C | Pine compatibility adapter lowering onto the native seams | Not started |
22+
| Slice C | Pine compatibility adapter lowering onto the native seams | L3b deletion landing complete locally; pending the campaign-level integration gate |
2323
| R5 | Final requirement and compatibility audit | Open |
2424
| R6 | Resume the parity improvement campaign after the audit | Queued |
2525

@@ -105,23 +105,31 @@ The native R2 boundary is pinned; complete Pine lowering remains mandatory
105105
R4 work. The parity-improvement campaign remains paused through the final
106106
native audit.
107107

108-
## R4-C intermediate source hierarchy
108+
## R4-D Slice C native-only source hierarchy
109109

110110
```text
111111
Generated strategy / handwritten Pine fixture
112112
-> source::PineStrategyHost
113+
-> NativeStrategyHost
114+
-> BacktestEngine
115+
Handwritten native host
116+
-> NativeStrategyHost
113117
-> BacktestEngine
114-
NativeStrategyHost
115-
-> BacktestEngine
116118
```
117119

118-
`PineStrategyHost` now owns the source language state, pending-intent book,
119-
adapter/journal, policy state and the legacy source scheduler. The base owns
120-
generic physical/account/run state; native hosts construct no source host. The
121-
remaining O1 gap is deliberate and material: source hosts still execute the
122-
moved legacy compatibility loop through `LegacyCompatibilityConsumer`. This
123-
intermediate hierarchy earns **no R4 credit** and does not mark R4-B or Slice C
124-
accepted.
120+
L3b removed the legacy compatibility consumer, default legacy construction,
121+
source pending-order book, source matching loop, lifecycle seams, and the
122+
legacy scheduler/stream bodies after L3a had switched every public Pine route.
123+
`PineStrategyHost` owns a `PineExecutionAdapter` and `PineScheduler`; the
124+
scheduler owns language state by value, and the adapter lowers each source
125+
command into the generic native request state machine. `NativeExecutionConsumer`
126+
is the sole execution owner. The C pending-order ABI remains v1, but its
127+
read-only rows now come from `PendingIntentView`, not a compatibility order
128+
object.
129+
130+
This records a local implementation boundary only. It is not a parity campaign
131+
acceptance claim: the integration owner still performs the final composite
132+
measurement and gate.
125133

126134
## Current R4-C epoch baseline
127135

‎docs/native-settlement.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,8 @@ lifecycle exceptions abort the owning run; callers must discard that failed
256256
run rather than retry a partially committed execution in place. Strong
257257
rollback on allocation failure is not promised.
258258

259-
The work retains `ShortSeedCollisionRole` while its source-policy consumers
260-
remain. Source quota, TV-money/day-loss policy and complete Pine lowering remain
261-
separate refactor work. Source-day observation ownership is separated from the
259+
L3b replaces the legacy ShortSeed role storage with a plan-derived public
260+
projection over live native handles. Source quota, TV-money/day-loss policy,
261+
and source-day observation remain adapter responsibilities, separated from the
262262
native financial owner; existing executable state remains represented in ABI
263263
projections and fingerprints.

‎docs/pages/abi-stability.md‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,10 @@ notice:
118118
Rebuild generated and native C++ objects against matching engine headers and
119119
runtime. R4-D L1 advances `BacktestEngine`, `NativeStrategyHost`, and the
120120
private consumer to `engine_script_run_v17`; the host capability macro is
121-
`PINEFORGE_HAS_NATIVE_STRATEGY_HOST_V17`. `PendingOrder` remains a source
122-
epoch type (`pineforge::source::PendingOrder`) with the explicit
123-
`pineforge-source-adapter/v2` source-hash domain. Native request/core/event
124-
values are `native_order_v5`, the private consumer identity is
121+
`PINEFORGE_HAS_NATIVE_STRATEGY_HOST_V17`. L3b removes the source compatibility
122+
order type; `pineforge-source-adapter/v2` hashes adapter and scheduler state
123+
instead. Native request/core/event values are `native_order_v5`, the private
124+
consumer identity is
125125
`native-consumer/v7`, driver types are `native_driver_v5`, and run specs are
126126
`native_run_spec_v2`.
127127

@@ -153,9 +153,9 @@ guarantee remains in force.
153153

154154
The historical transitions retain their full comparisons. The reviewed v15→v16
155155
transition additionally consumes the authenticated relocation manifest: it
156-
allows exactly the listed relocated source storage and source seams, measures
157-
`sizeof(source::PendingOrder)` in the source-layer row, and rejects every other
158-
storage, vtable, layout, header, compile, or link difference. Against the older
156+
allows exactly the listed retired source storage and source seams, verifies the
157+
frozen public pending-row POD separately, and rejects every other storage,
158+
vtable, layout, header, compile, or link difference. Against the older
159159
providers the checker still compares, in full and unconditionally:
160160

161161
* every engine named data declaration in source order (252 declarations, 251
@@ -164,7 +164,7 @@ providers the checker still compares, in full and unconditionally:
164164
vtable;
165165
* every compiler-emitted layout word — all 789 against e60 R2 and all 793
166166
against 0e R3, covering `sizeof`/`alignof` of `BacktestEngine`,
167-
`PendingOrder`, the native aggregates and the selected/projection types, plus
167+
the native aggregates and the selected/projection types, plus
168168
the offset/size/alignment triple of each of the 251 engine data members, not
169169
only the leading financial `Result`/`SettlementInspection`, status and
170170
Action/CloseScope words. The receipt's `layout.comparedWords` and

‎docs/pages/exit-leg-activation.md‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@ callback use. The Pine adapter is still invoked by the current exit producer.
5353
other historical execution rules remain separate work. The effective-level
5454
accessor still reports resolved levels rather than masking eligibility.
5555

56-
The internal object layout changes and requires matching C++ headers/library.
57-
The activation slice shipped with internal v6. Subsequent reservation ownership
58-
integration advances PendingOrder and BacktestEngine to v7 with broker/stream
59-
fingerprint v7. Exact shipped ff54/v6 and earlier149/v5 standalone PendingOrder clients
60-
are checked by compile/link-only mismatch controls with matching positives.
61-
Public C ABI 4, stream API 1 and pending mirror version 1 are preserved.
56+
Historical internal object layouts require matching C++ headers/library. L3b
57+
removes the compatibility order object and projects the frozen pending-row ABI
58+
from native requests plus adapter facts. Public C ABI 4, stream API 1, and
59+
pending mirror version 1 are preserved.

‎docs/pages/exit-leg-lifecycle.md‎

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ prefix is preserved; 163 canonical lifecycle fields follow it, with admission
77
facts in a separate append segment.
88
See [reflection and completion](exit-leg-lifecycle-reflection.md).
99

10-
`PendingOrder::legs` owns the current immutable trigger definition. All order
11-
price reads use that definition; setters replace the complete const value and
12-
advance its revision. The old scalar price members do not remain as a second
13-
mutable authority. ENTRY/RAW trigger calculations and quantities are unchanged.
14-
A retained definition handle can be created only by its canonical owner, and
15-
retains old values when a successor replaces its current definition. Deferred
16-
closes acquire an incarnation before lifecycle attachment.
10+
Native request definitions own trigger state. The source adapter retains an
11+
immutable placement-level snapshot for public projections, so no compatibility
12+
order object or second executable price store remains. ENTRY/RAW trigger
13+
calculations and quantities are unchanged. A retained definition handle can be
14+
created only by its canonical owner, and retains old values when a successor
15+
replaces its current definition. Deferred closes acquire an incarnation before
16+
lifecycle attachment.
1717

1818
The native reducer in `exit_leg_lifecycle.hpp` accepts exact target incarnation,
1919
owner and revision, a cause frame, and a typed action: bind owner, suspend selected
@@ -73,10 +73,9 @@ forks receive a new instruction identity and no inherited replay receipt.
7373
All nested definition, generation, cause, obligation, window and latest-receipt
7474
facts are reflected/hashed once from canonical state. Legacy D/R/T/O/H/K/B/B0
7575
fields are read-only projections. This model removes three stored booleans.
76-
Admission, cancellation and placement-fact consolidation have reduced the
77-
direct PendingOrder boolean census from 17 to 5; the opposite-predecessor
78-
result is now derived from the accepted command journal. The five include two ordinary
79-
direction/activation facts and does not count every engine policy option.
76+
Admission, cancellation, and placement facts are represented by the native
77+
request/receipt model and adapter journal. The retired compatibility-order
78+
boolean census is no longer maintained.
8079
Optional obligations, three leg generations,
8180
retirement receipts, immutable definition references and action/domain variants
8281
remain disclosed domain state. This is not a whole-engine fewer-than-five claim.

0 commit comments

Comments
 (0)