Skip to content

Commit 7bbf93e

Browse files
luisleo526claude
andcommitted
Fence the v16 host epoch, split the pending mirror and hash sinks, and enforce native include independence (R4-C L3)
Remove the residual source-only include closure from engine.hpp, make the generic and source includes explicit, and prove the installed native header boundary. Add source-state fingerprint/reset/replay coverage and the frozen C-v1 PendingOrder canary; retain the L2 v16 mirror/hash split through direct runtime checks. Wire the identifier guard into preflight and the installed include-independence proof into the release/native verifier profiles, with dependency and nm evidence output. Update the v16/source-adapter and O1-gap documentation. Contract rules: §6.2, §6.3, §6.4, §6.5, §8.8; A11, A24, A25. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016iF71UAEuQ7F6eqWgecAHm
1 parent 0a4ed0e commit 7bbf93e

21 files changed

Lines changed: 598 additions & 101 deletions

‎docs/ci.md‎

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ prepares the real historical ABI providers, runs CTest, installs the package,
2323
and builds and runs the `find_package` consumer. The smoke test compares the
2424
installed library's reported version with `VERSION`. After a successful build,
2525
a failing test suite does not hide a separate install or package failure.
26+
Release and native profiles also install into a disposable prefix, remove the
27+
source-only header trees, and compile the native public roots and examples;
28+
the preflight source guard rejects those includes before a build.
2629

2730
CI pins Ubuntu 24.04 and macOS 26, the platforms used by the preceding green
2831
refactor PR, and selects Python 3.12 explicitly. CMake uses the same interpreter as the
@@ -33,10 +36,10 @@ Python. CTest must discover tests; an empty suite is a failure.
3336

3437
| Profile | Build | Additional coverage |
3538
| --- | --- | --- |
36-
| `release` | Release, tutorial enabled | Standard CI checks and installed package |
39+
| `release` | Release, tutorial enabled | Standard CI checks, installed package, and installed native include-independence proof |
3740
| `debug` | Debug, tutorial enabled | The same checks without Release optimization |
3841
| `sanitizers` | Debug, ASan and UBSan | Instrumented library, tests and installed consumer; Linux CI also requires leak detection |
39-
| `native` | Release, live runner enabled | Parser, journal, transport tests and installed runner help |
42+
| `native` | Release, live runner enabled | Parser, journal, transport tests, installed runner help, and installed native include-independence proof |
4043

4144
By default each profile uses `build-ci-<profile>`. Keep separate build directories
4245
for different profiles and toolchains. The verifier never deletes a build tree
@@ -86,23 +89,24 @@ their matching prepared receipts under `settlement-abi-base/`,
8689
configuration and version-source mismatches refuse reuse without deleting the old evidence.
8790
Each profile needs matching providers; a Mac Release archive cannot replace
8891
a Linux sanitizer build. CTest itself performs no network fetch.
89-
The full settlement matrix uses those five archives plus live v15. Its
90-
host/order matrix rejects cross-epoch links among v13, v14 and v15; the
91-
unchanged driver v4 requires positive links in both v14→v15 and v15→v14
92-
directions, while frozen v15 and live v15 positively pair in every matching
93-
owner domain. Current-execution callers compile from v14 and both v15 header
94-
closures.
92+
The full settlement matrix uses those five archives plus live v16. Its
93+
host/order matrix retains the historical v13/v14/v15 verdicts and requires
94+
both v15→v16 and v16→v15 rejection pairs; matching v16 callers/providers
95+
succeed. The unchanged driver v4 keeps its historical positive links where its
96+
owner domain is unchanged. Current source callers authenticate the
97+
`pineforge-source-adapter/v1` domain, while the frozen v15 provider remains an
98+
immutable historical identity.
9599
The [ABI guide](../tests/fixtures/settlement_cpp_abi/README.md) describes the
96100
actual old/new library pairs and their immutable inputs.
97101

98102
CTest writes `settlement-abi-receipt.json` for the six-archive matrix and
99103
`native-abi-receipt.json` for native controls. The native receipt includes the
100-
active `v14_current_execution_shape_agnostic_compile` and the frozen-v15
101-
surface controls against authenticated tar closures. `CURRENT_TERMS_SURFACE_READY = True`:
102-
the complete current-execution, FX, and missing-Cancelled controls are
103-
active, and the good caller compiles before its intentional negative compile
104-
control. Ordinary compile failures remain failures, separate from ABI link
105-
rejections.
104+
active `v14_current_execution_shape_agnostic_compile`, frozen-v15 surface
105+
controls, and v16-current rejection controls against authenticated tar
106+
closures. `CURRENT_TERMS_SURFACE_READY = True`: the complete current-execution,
107+
FX, and missing-Cancelled controls are active, and the good caller compiles
108+
before its intentional negative compile control. Ordinary compile failures
109+
remain failures, separate from ABI link rejections.
106110

107111
## Failure evidence
108112

‎docs/native-refactor-progress.md‎

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ improvement resumes after the final native audit.
1818
| R3 observation | Source-day observation isolation | Complete ([PR #248](https://github.com/pineforge-4pass/pineforge-engine/pull/248)) |
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 |
21-
| Slice B | Source-layer cut, including the generic native FX broker-open epoch clock | Not started |
21+
| Slice B | Source-layer cut, including the generic native FX broker-open epoch clock | Intermediate ownership boundary landed; no R4 credit |
2222
| Slice C | Pine compatibility adapter lowering onto the native seams | Not started |
2323
| R5 | Final requirement and compatibility audit | Open |
2424
| R6 | Resume the parity improvement campaign after the audit | Queued |
@@ -105,12 +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-
## Current R4-B epoch baseline
108+
## R4-C intermediate source hierarchy
109+
110+
```text
111+
Generated strategy / handwritten Pine fixture
112+
-> source::PineStrategyHost
113+
-> BacktestEngine
114+
NativeStrategyHost
115+
-> BacktestEngine
116+
```
117+
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.
125+
126+
## Current R4-C epoch baseline
109127

110-
The current R4-B baseline uses `native_order_v4`, engine/host
111-
`engine_script_run_v15`, `native-consumer/v6`, and broker/stream version 15.
112-
Identity values remain `native_order_v1`; native run-spec and calendar remain
113-
v1, the driver remains v4, and `PF_ABI_VERSION` remains 4.
128+
The current baseline uses `native_order_v4`, engine/host
129+
`engine_script_run_v16`, `native-consumer/v6`, broker/stream version 16, and
130+
the source extension domain `pineforge-source-adapter/v1`. The frozen e7cdf05
131+
provider remains v15. Identity values remain `native_order_v1`; native run-spec
132+
and calendar remain v1, the driver remains v4, and `PF_ABI_VERSION` remains 4.
114133

115134
## Completed R3 settlement and observation milestones
116135

‎docs/pages/abi-stability.md‎

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -116,31 +116,41 @@ notice:
116116
- The shape of internal log lines (use them for humans, not parsers).
117117

118118
Rebuild generated and native C++ objects against matching engine headers and
119-
runtime. R4-B advances `PendingOrder`, `BacktestEngine`, `NativeStrategyHost`,
120-
and the private consumer to `engine_script_run_v15`; the host capability macro
121-
is `PINEFORGE_HAS_NATIVE_STRATEGY_HOST_V15`. Native request/core/event values
122-
are `native_order_v4`, the private consumer identity is
119+
runtime. R4-C advances `BacktestEngine`, `NativeStrategyHost`, and the private
120+
consumer to `engine_script_run_v16`; the host capability macro is
121+
`PINEFORGE_HAS_NATIVE_STRATEGY_HOST_V16`. `PendingOrder` is no longer an engine
122+
epoch type: it is `pineforge::source::PendingOrder`, with the explicit
123+
`pineforge-source-adapter/v1` source-hash domain. Native request/core/event
124+
values remain `native_order_v4`, the private consumer identity remains
123125
`native-consumer/v6`, and driver types remain `native_driver_v4`.
124126

125-
The current v15 archive is checked with four archived provider inputs: the
126-
real e60 R2 and 0e R3 providers plus authenticated c3ed455 v13 and f736676 v14
127-
host closures. The verifier prepares real archives from immutable sources with
128-
the current profile's compiler and settings. Constructor/vtable,
129-
return-only `native_events()`, host observation, core request, driver and
130-
current-execution callers compile before links are interpreted. The v14→v15
131-
transition is deliberate: host and order callers use their matching epoch,
132-
while unchanged driver v4 callers link positively across v14 and v15 in both
133-
directions. Current-execution callers use v14 or v15 only; v15 terms and
134-
FX-curve callers require the v15 host surface. No ABI caller executable is
135-
run.
127+
| Matrix role | Internal identity |
128+
| --- | --- |
129+
| Live engine/host library | `engine_script_run_v16` |
130+
| `host-e7cdf05` immutable provider | `engine_script_run_v15` |
131+
| Source extension | `pineforge-source-adapter/v1` |
132+
133+
The current v16 archive is checked with five archived provider inputs: the real
134+
e60 R2 and 0e R3 providers, authenticated c3ed455 v13 and f736676 v14 host
135+
closures, and the immutable e7cdf05 v15 source-layer-base closure. The verifier
136+
prepares real archives from immutable sources with the current profile's
137+
compiler and settings. Constructor/vtable, return-only `native_events()`, host
138+
observation, core request, driver and current-execution callers compile before
139+
links are interpreted. The v15↔v16 host/source pair is a required rejection in
140+
both directions; v16↔v16 succeeds. Existing historical v13/v14/v15 verdicts,
141+
including the unchanged driver-v4 positive links where applicable, remain
142+
required. No ABI caller executable is run.
136143

137144
For the 0.14.x line, this is an internal C++ epoch transition rather than a
138145
public C ABI break: `PF_ABI_VERSION` remains 4 and the append-only C ABI
139146
guarantee remains in force.
140147

141-
The transitions from the two frozen host epochs to `engine_script_run_v15`
142-
drop no check. Against each historical provider the checker still compares,
143-
in full and unconditionally:
148+
The historical transitions retain their full comparisons. The reviewed v15→v16
149+
transition additionally consumes the authenticated relocation manifest: it
150+
allows exactly the listed relocated source storage and source seams, measures
151+
`sizeof(source::PendingOrder)` in the source-layer row, and rejects every other
152+
storage, vtable, layout, header, compile, or link difference. Against the older
153+
providers the checker still compares, in full and unconditionally:
144154

145155
* every engine named data declaration in source order (252 declarations, 251
146156
of them non-static data members) and the entire virtual method inventory —
@@ -156,11 +166,12 @@ in full and unconditionally:
156166
* every frozen native header's text, with exactly four enumerated exemptions —
157167
`native_order.hpp`, `native_host.hpp`, `market_driver.hpp` and
158168
`execution_consumer.hpp`, the headers that legitimately advance with
159-
`native_order_v4`, host v15, `native_driver_v4` and consumer v6. Each actual
169+
`native_order_v4`, host v16, `native_driver_v4` and consumer v6. Each actual
160170
difference is recorded in `frozenShape.exemptedHeaders` with both digests and
161171
its transition; an exempted header that did not change records nothing, and
162172
any other differing header still raises. The exemption table lives in one
163-
module constant keyed by the two reviewed transitions, v13→v15 and v14→v15.
173+
module constant keyed by the reviewed historical transitions, including
174+
v15→v16.
164175
Every recorded exemption must also match the pinned current header bytes.
165176

166177
`native_order_identity.hpp`, `native_run_spec.hpp` and `native_calendar.hpp`
@@ -210,8 +221,9 @@ validate an erased `pf_strategy_t` handle. Use a handle only with functions from
210221
its creating strategy module. A fully self-contained old module can still use
211222
its own matching runtime; this check does not turn it into a v11 module.
212223

213-
The integrated representation advances the broker fingerprint domain to
214-
`pineforge-broker-state/v15` and stream fingerprint version to 15. Native
224+
The integrated representation advances the generic broker fingerprint domain to
225+
`pineforge-broker-state/v16` and stream fingerprint version to 16; the source
226+
extension begins with `pineforge-source-adapter/v1`. Native
215227
consumer identity is `native-consumer/v6`; driver v4 is unchanged, while
216228
`close_scope_v1` and `native_run_spec_v1` stay frozen. Stable `RunIdentity` /
217229
`RequestHandle` / `Birth` remain `native_order_v1`; request, core, and event

‎docs/pages/live-surface.md‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,12 @@ array, freed by `report_free` — same ownership rule as `trades` /
239239
## The pending-order mirror {#live_surface_pending_mirror}
240240

241241
`pf_pending_order_v1_t` is a **generated**, C-compatible POD mirror of the
242-
engine's internal `PendingOrder` record, produced by
243-
`scripts/gen_pending_order_mirror.py` from `include/pineforge/engine.hpp`
244-
into `include/pineforge/pending_order_mirror.hpp` — never hand-edited. It
242+
source-owned `source::PendingOrder` record, produced by
243+
`scripts/gen_pending_order_mirror.py` from
244+
`include/pineforge/source/pine_pending_intent.hpp` into
245+
`include/pineforge/pending_order_mirror.hpp` — never hand-edited. The generator
246+
emits a source-free descriptor/layout TU (`src/pending_order_mirror.cpp`) and a
247+
source projection TU (`src/source/pine_pending_mirror.cpp`). It
245248
starts with `struct_version` and `size` (a self-describing header),
246249
followed by 98 mirrored `PendingOrder` members (scalars by value, strings
247250
as the fixed `char[64]` + truncated-flag + hash64 triple above, enums as

‎docs/pages/native-engine.md‎

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ Always set, with documented defaults in the header:
100100
- `chart_timezone`: optional observation metadata; empty stays empty and is
101101
not the scheduling calendar
102102
- `slippage_ticks`: `0` .. `INT_MAX`. Buy adds, sell subtracts
103-
`ticks * price_tick` **once** to form the kernel default price. A v15 terms
103+
`ticks * price_tick` **once** to form the kernel default price. A v16 terms
104104
resolver receives that default; an accepted override is final and is not
105105
slipped a second time. No mintick snap.
106106
- `fee_kind` / `fee_value`: `Percent`, `CashPerUnit`, `CashPerExecution`;
@@ -165,7 +165,7 @@ cycle identity through scoped settlement. Group cancellation/reduction is
165165
caused by committed execution events. See the request header for the exact
166166
value types; source-specific Pine lowering remains codegen/adapter work.
167167
168-
At host epoch v15, general requests also support explicit
168+
At host epoch v16, general requests also support explicit
169169
`native_order::ReverseTo{signed_units}` and `HostSized`. A `HostSized{Open,
170170
Side}` request binds its units at a matching candidate through the host's
171171
`resolve_execution_terms` override. The host may choose `Transact`, exact
@@ -598,7 +598,8 @@ Empty timeframe strings are also valid (`run(bars, n)` and
598598
599599
## Terms, reversal, precommit, FX curve
600600
601-
Epoch v15 adds two const host hooks. `resolve_execution_terms` sees read-only
601+
The two const host hooks introduced at v15 remain present at the current v16
602+
host epoch. `resolve_execution_terms` sees read-only
602603
candidate facts and returns a resolved price plus units only for an unresolved
603604
`HostSized` request. Its default is the identity price with no units. A
604605
`NativePrecommitView` is then available to
@@ -613,6 +614,21 @@ ticket and one settlement cycle. A `HostSized{Open}` is sized once; later
613614
candidate rematches may re-resolve price but not size. `CloseOpposite` uses the
614615
existing whole-book Flatten path when it must close an absorbed roster.
615616
617+
### Source-layer boundary (R4-C)
618+
619+
Pine/generated hosts now derive from `pineforge::source::PineStrategyHost`,
620+
which derives from the v16 `BacktestEngine`; handwritten native hosts continue
621+
to derive from `NativeStrategyHost`. `source::PendingOrder` and the
622+
`pineforge-source-adapter/v1` hash domain belong to the source layer, while the
623+
public C ABI remains version 4.
624+
625+
This is an ownership boundary, not completion of Pine lowering: the source host
626+
still uses the moved legacy compatibility loop (`LegacyCompatibilityConsumer`).
627+
The installed-header check removes `source/` and `compat/pine/`, then compiles
628+
the declared native roots and native examples; its dependency files and `nm`
629+
output are the evidence for this include boundary. It does not establish a
630+
broader policy or runtime-independence claim.
631+
616632
The second runner module is a deliberately small example of those public
617633
seams. It contains no Pine command calls, formula, or protected engine write:
618634

‎docs/reservation-expansion-candidate.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# Reservation expansion ownership
22

33
Reservation expansion and typed Pine instructions change the internal order
4-
layout relative to ff54. The engine/PendingOrder namespace is
5-
`engine_script_run_v7`, with broker/stream fingerprint epoch7. Standalone capture,
4+
layout relative to ff54. This candidate's historical engine/PendingOrder
5+
namespace is `engine_script_run_v7`, with broker/stream fingerprint epoch7.
6+
In the current source-layer layout, `PendingOrder` is source-owned as
7+
`pineforge::source::PendingOrder`, not an engine-namespace type. Standalone capture,
68
expansion and growth-source types establish `reservation_expansion_v1`.
79
Public C ABI4, stream API1 and pending-mirror schema1 remain unchanged. The
810
142-field shipped mirror prefix is preserved; seven reservation facts and six

‎include/pineforge/engine.hpp‎

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,13 @@
2424
#include "execution_close_selection.hpp"
2525
#include "execution_projection.hpp"
2626
#include "execution_reverse_to.hpp"
27+
#include "position_close_obligation.hpp"
2728
#include "market_admission.hpp"
2829
#include "reservation_expansion.hpp"
2930
#include "order_cancellation.hpp"
30-
#include "compat/pine/frozen_market_instruction.hpp"
3131
#include "leg_activation.hpp"
3232
#include "exit_leg_lifecycle.hpp"
33-
#include "compat/pine/exit_activation.hpp"
3433
#include "order_birth.hpp"
35-
#include "compat/pine/order_birth.hpp"
36-
#include "compat/pine/intraday_cap.hpp"
37-
#include "compat/pine/order_priority.hpp"
3834
#include "series.hpp"
3935
#include "timeframe.hpp"
4036
#include "magnifier.hpp"
@@ -1012,7 +1008,7 @@ class BacktestEngine {
10121008
// Source coordinator for one execution plus lifecycle effects and source days.
10131009
// Pre-close operations, then close observations and old-cycle unbind, then
10141010
// the listed pending removals, then the quoted opening path which binds
1015-
// only remaining exits. Native settlement does not call compat::pine
1011+
// only remaining exits. Native settlement does not call source-layer
10161012
// selectors; the effects value is not retained.
10171013
execution::Result settle_execution_with_lifecycle(
10181014
const execution::Action& action, const execution::Fill& fill,
@@ -2007,7 +2003,7 @@ class BacktestEngine {
20072003
// Chart-timezone-aware decomposition for the existing loss-day clocks
20082004
// and the continuous/unconfigured-session order-counter fallback. The
20092005
// order counter on an explicitly timed session instead consumes
2010-
// compat::pine::IntradayCap::risk_day(), which follows the symbol's trading day.
2006+
// source-layer intraday-cap risk-day policy, which follows the symbol's trading day.
20112007
//
20122008
// Falls back to plain ``_decompose_bar_time()`` (UTC) when no chart
20132009
// timezone has been set, preserving the legacy fast path for
@@ -3697,8 +3693,8 @@ class BacktestEngine {
36973693
// predicates. They default to UTC / 24x7 (crypto); a data feed pushes
36983694
// the real values via these setters before run().
36993695
//
3700-
// max_intraday_filled_orders consumes a valid explicit session and this
3701-
// timezone through compat::pine::IntradayCap::risk_day(). Other risk-day rules keep
3696+
// The source-layer intraday cap consumes a valid explicit session and this
3697+
// timezone through its risk-day policy. Other risk-day rules keep
37023698
// chart_timezone_, as do continuous/unconfigured order-counter clocks;
37033699
// the existing crypto-on-shifted-chart contract therefore remains intact.
37043700
void set_syminfo_timezone(const std::string& tz) {

‎include/pineforge/source/pine_adapter.hpp‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#pragma once
22

33
#include <pineforge/engine.hpp>
4+
#include <pineforge/compat/pine/intraday_cap.hpp>
5+
#include <pineforge/compat/pine/order_priority.hpp>
46

57
namespace pineforge::source {
68

0 commit comments

Comments
 (0)