Skip to content

Commit ab9714b

Browse files
luisleo526claude
andauthored
Cut the Pine source layer out of BacktestEngine (R4-C, roadmap slice B) (#253)
* Freeze the v15 host provider and add the source-layer relocation tooling (R4-C L0) Freeze the e7cdf05 v15 host closure and extend the real provider matrix with same-epoch v15 pairing controls. Add the native include-independence fail-before checker, its tooling tests, and the relocation-proof handoff tooling. Contract: §6.1, §6.5, §8.1, §8.9. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016iF71UAEuQ7F6eqWgecAHm * Add the source-layer headers and the empty PineStrategyHost (R4-C L1 step 1) Add the five source-layer header placeholders and the empty PineStrategyHost hook/constructor implementation. Register the source translation-unit group after the existing pineforge sources (R4-C §3.1, §4, §7 L1; amendment A8). Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016iF71UAEuQ7F6eqWgecAHm * Introduce source::PineStrategyHost and the on_source_bar hook; port Pine tests and the example (R4-C L1) Port Pine-facing test fixtures and helper headers to source::PineStrategyHost, preserving direct engine.on_bar calls through the final forwarding hook. Retarget the handwritten runner example and committed tutorial consumers; leave NativeStrategyHost and pure native request/settlement/position/account fixtures untouched. Contract rules: R4-C §2 P1/P2, §3.1, §7 L1; amendments A5 and A8. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016iF71UAEuQ7F6eqWgecAHm * Add native source-seam default witnesses (R4-C L2) Add pre-transfer native-host witnesses for the S11, S19, S20-S24, and S35 defaults. (A28) Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016iF71UAEuQ7F6eqWgecAHm * Relocate source scheduler and policy bodies (R4-C L2 WIP) Move ledger-classified source-route bodies to src/source and add initial native-default seam dispatch scaffolding. (A13, A16, A17, A23, A28) Settlement coordinators remain on the base under the recorded A15 conflict. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016iF71UAEuQ7F6eqWgecAHm * Introduce Pine language-state mixin and source reset hook (R4-C L2 WIP) Add data-only PineLanguageState and route F6 source-series reset through the source host while preserving native empty defaults. (A13, A17, F6) Use source-qualified relocated definitions for moved-only normalization. (3.7) Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016iF71UAEuQ7F6eqWgecAHm * Route pending lifecycle and C observers through the source host (R4-C L2 WIP) Introduce source lifecycle hooks, F1-F5/F7-F12 position hooks, and source-owned pending observer routing. (A15, A17, A22) Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016iF71UAEuQ7F6eqWgecAHm * Materialize source pending intent and observer seams (R4-C L2 WIP) Move source PendingOrder compatibility interfaces, source lifecycle hooks, reset fragments, and C observer projections onto PineStrategyHost. (A5, A15, A17, A22) Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016iF71UAEuQ7F6eqWgecAHm * Move Pine language storage behind source state hooks (R4-C L2 WIP) Remove source language fields from BacktestEngine and route metadata, reset, position-view, and C observation behavior through PineStrategyHost. (A13, A17, A20) Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016iF71UAEuQ7F6eqWgecAHm * Split broker state hash through source extension (R4-C L2 WIP) Move the shared FNV sink into a source-free internal header and route relocated Pine state through S34. Keep the A31 settlement coordinator context generic and hash it there. Port the native physical-position test helper.\n\nContract rules: A24, S34, A31, A5.\n\nCo-Authored-By: Claude Fable 5.1 <[email protected]>\nClaude-Session: https://claude.ai/code/session_016iF71UAEuQ7F6eqWgecAHm * Move source pending intent behind the host (R4-C L2 WIP) Relocate PendingOrder ownership and public pending accessors into PineStrategyHost, re-key StrategyOverrides to the source adapter, and route stream entry comments through S33.\n\nContract rules: A5, A21, A22, S13-S18, S33.\n\nCo-Authored-By: Claude Fable 5.1 <[email protected]>\nClaude-Session: https://claude.ai/code/session_016iF71UAEuQ7F6eqWgecAHm * Split source mirror and advance source host epoch (R4-C L2 WIP) Make base construction source-free, move remaining adapter-owned state into PineStrategyHost, split the PendingOrder descriptor and source projection TUs, and advance internal ownership/hash fingerprints to v16 with matching local guard parsing.\n\nContract rules: A21, A24, S10, S33, S34, §6.4, EPOCH-LEDGER.\n\nCo-Authored-By: Claude Fable 5.1 <[email protected]>\nClaude-Session: https://claude.ai/code/session_016iF71UAEuQ7F6eqWgecAHm * Advance source ABI relocation proof and generic evaluator ownership (R4-C L2 WIP) Move S37 auxiliary-feed storage behind source views, restore P10 generic security evaluation, and complete v15-to-v16 relocation-manifest tooling. Port affected source-host test accessors and split hash/mirror coverage checks.\n\nContract rules: A3, A5, A11, A15, A18, A19, A24, A30, A31.\n\nCo-Authored-By: Claude Fable 5.1 <[email protected]>\nClaude-Session: https://claude.ai/code/session_016iF71UAEuQ7F6eqWgecAHm * Re-key source PendingOrder outside the engine epoch (R4-C L2 WIP) Remove the v16 engine PendingOrder alias, re-key residual bridge signatures and test fixtures to source::PendingOrder, and keep the aggregate and settlement epoch checks fail-closed.\n\nContract rules: A3, A5, A11, A13, A19, A21, A24.\n\nCo-Authored-By: Claude Fable 5.1 <[email protected]>\nClaude-Session: https://claude.ai/code/session_016iF71UAEuQ7F6eqWgecAHm * Move source path-resolution helpers beside the pending book (R4-C L2 WIP) Relocate the PendingOrder-specific path helper cluster into the source layer and register its source translation unit.\n\nContract rules: A5, A11, A19.\n\nCo-Authored-By: Claude Fable 5.1 <[email protected]>\nClaude-Session: https://claude.ai/code/session_016iF71UAEuQ7F6eqWgecAHm * Retire duplicate base lifecycle ownership (R4-C L2 WIP) Keep source lifecycle helpers behind S22-S24 host overrides and remove their duplicate generic implementation unit.\n\nContract rules: A15, A19.\n\nCo-Authored-By: Claude Fable 5.1 <[email protected]>\nClaude-Session: https://claude.ai/code/session_016iF71UAEuQ7F6eqWgecAHm * Move Pine policy free helpers out of engine.hpp (R4-C L2 WIP) Relocate tv-money and enum-string free helpers to source policy support, re-key their consumers, and complete the v15/v16 settlement matrix caller split.\n\nContract rules: A3, A11, A14, A18, A19.\n\nCo-Authored-By: Claude Fable 5.1 <[email protected]>\nClaude-Session: https://claude.ai/code/session_016iF71UAEuQ7F6eqWgecAHm * Cut the Pine source layer out of BacktestEngine: relocate policy, pending route, scheduler and hash; fence engine_script_run_v16 (R4-C L2) Complete the L2 atomic source-layer relocation: language and policy storage, pending route, scheduler seams, adapter/configuration ownership, state-hash extension, mirror projection, and engine_script_run_v16 epoch fencing.\n\nContract rules: A2, A3, A5, A11, A13, A15, A17, A18, A20, A21, A22, A23, A24, A28, A30, A31; §3.7; §6.4.\n\nCo-Authored-By: Claude Fable 5.1 <[email protected]>\nClaude-Session: https://claude.ai/code/session_016iF71UAEuQ7F6eqWgecAHm * Isolate source hash mutation fixture from native checker temp state (R4-C L2 WIP) Ignore the native-version checker’s transient authenticated-fixture directory while the A24 source-hash mutation suite materializes its disposable repository copy. This is test-fixture isolation only; no product or moved-body behavior changes.\n\nContract rule: A24.\n\nCo-Authored-By: Claude Fable 5.1 <[email protected]>\nClaude-Session: https://claude.ai/code/session_016iF71UAEuQ7F6eqWgecAHm * 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 * Scan the native source guard with Python instead of ripgrep (R4-C L3c) Replace the ripgrep subprocess scan with equivalent standard-library regex scans. Preserve the source/Pine include and C-ABI diagnostics, enforce the A18 identifier-bound scan with its comment and frozen-export exclusions, and exercise a forbidden identifier in a temporary-tree self-test. Contract rules: §6.5; A18. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016iF71UAEuQ7F6eqWgecAHm * Add the intraday-cap limit setter to the Pine source host (R4-C L3b) Add the public PineStrategyHost risk setter and route integer limits through adapter_.cap, preserving IntradayCap attachment and ledger semantics (R4-C A32). Add a focused source-host test and register it in the CTest suite. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016iF71UAEuQ7F6eqWgecAHm (cherry picked from commit 3d6035f1572bd1928a35b364103d38f43173b2c0) * Repair the source-host writer surface, restore generic trail/fold context, drop the dead Pine declarations and add real native witnesses (R4-C L5) Repair A33/A34 Pine risk writer semantics and cover direction plus sticky percent state. Restore A37 generic trail/fold ownership and hash folds, update the v15→v16 relocation manifest, and remove F8/F10/S28. Apply A35 waiver coverage enforcement, A36 source-only declaration cleanup and guard, and A38/A39 native and metadata witnesses/surface repairs. Contract rules: A33, A34, A35, A36, A37, A38, A39, A40. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016iF71UAEuQ7F6eqWgecAHm * Value-initialise partial pending orders and pin the is_long audit (R4-C L5b) Value-initialise partial PendingOrder test fixtures before vector relocation and mirror use (A41). Audit the five product construction paths; each assigns is_long before it can be read, so preserve the relocated member declaration verbatim and add no allow-list exception (A41). Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016iF71UAEuQ7F6eqWgecAHm --------- Co-authored-by: Claude Fable 5.1 <[email protected]>
1 parent 66d9dc4 commit ab9714b

327 files changed

Lines changed: 20929 additions & 16835 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: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,23 @@ else()
7676
endif()
7777

7878
# === pineforge library =================================================
79+
set(PINEFORGE_SOURCE_LAYER_SOURCES
80+
src/source/pine_strategy_host.cpp
81+
src/source/pine_strategy_commands.cpp
82+
src/source/pine_risk.cpp
83+
src/source/pine_market_admission.cpp
84+
src/source/pine_scheduler.cpp
85+
src/source/pine_stream.cpp
86+
src/source/pine_aux_security.cpp
87+
src/source/pine_fills.cpp
88+
src/source/pine_path_resolve.cpp
89+
src/source/pine_orders.cpp
90+
src/source/pine_execution_lifecycle.cpp
91+
src/source/pine_policy_members.cpp
92+
src/source/pine_state_hash.cpp
93+
src/source/pine_pending_mirror.cpp
94+
)
95+
7996
add_library(pineforge STATIC
8097
src/c_abi.cpp
8198
src/compat/pine/order_birth.cpp
@@ -88,18 +105,14 @@ add_library(pineforge STATIC
88105
src/engine_metrics.cpp
89106
src/engine_orders.cpp
90107
src/engine_execution.cpp
91-
src/engine_execution_lifecycle.cpp
92108
src/engine_path_resolve.cpp
93109
src/engine_report.cpp
94-
src/engine_risk.cpp
95110
src/engine_run.cpp
96111
src/engine_security.cpp
97112
src/engine_state_hash.cpp
98113
src/engine_stream.cpp
99114
src/market_admission.cpp
100-
src/engine_market_admission.cpp
101115
src/compat/pine/market_admission.cpp
102-
src/engine_strategy_commands.cpp
103116
src/engine_trade_accessors.cpp
104117
src/reservation_expansion.cpp
105118
src/compat/pine/reservation_expansion.cpp
@@ -123,6 +136,7 @@ add_library(pineforge STATIC
123136
src/native_calendar.cpp
124137
src/native_run_spec.cpp
125138
src/native_fx_curve.cpp
139+
${PINEFORGE_SOURCE_LAYER_SOURCES}
126140
)
127141

128142
# Canonical alias for downstream find_package(PineForge) consumers.

‎docs/ci.md‎

Lines changed: 26 additions & 21 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
@@ -75,33 +78,35 @@ separate. Git tags and checkout depth cannot change the smoke-test expectation.
7578
Ordinary CMake builds retain `AUTO`, the existing git-describe-first behavior.
7679
No release tag or VERSION value is rewritten by verification.
7780

78-
The verifier fetches the pinned historical ABI commits `e60e571` (R2),
79-
`0e18690` (selected settlement, before exact reversal), `c3ed455` (native
80-
host v13), and `f736676` (native host v14) without tags only when each object
81-
is missing. It builds all four full historical static libraries with tests
82-
disabled, or validates and reuses
81+
The verifier fetches the pinned ABI commits `e60e571` (R2), `0e18690`
82+
(selected settlement, before exact reversal), `c3ed455` (native host v13),
83+
`f736676` (native host v14), and `e7cdf052` (the frozen v15 source-layer
84+
base) without tags only when each object is missing. It builds all five
85+
prepared static libraries with tests disabled, or validates and reuses
8386
their matching prepared receipts under `settlement-abi-base/`,
84-
`settlement-abi-prior/`, `native-abi-v13/`, and `native-abi-v14/`. Compiler,
87+
`settlement-abi-prior/`, `native-abi-v13/`, `native-abi-v14/`, and
88+
`native-abi-v15-frozen/`. Compiler,
8589
configuration and version-source mismatches refuse reuse without deleting the old evidence.
8690
Each profile needs matching providers; a Mac Release archive cannot replace
8791
a Linux sanitizer build. CTest itself performs no network fetch.
88-
The full settlement matrix uses these four archives plus current v15. Its
89-
host/order matrix rejects cross-epoch links among v13, v14 and v15; the
90-
unchanged driver v4 requires positive links in both v14→v15 and v15→v14
91-
directions. Current-execution callers compile only from v14 and v15 headers.
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.
9299
The [ABI guide](../tests/fixtures/settlement_cpp_abi/README.md) describes the
93100
actual old/new library pairs and their immutable inputs.
94101

95-
CTest writes `settlement-abi-receipt.json` for the five-archive matrix and
102+
CTest writes `settlement-abi-receipt.json` for the six-archive matrix and
96103
`native-abi-receipt.json` for native controls. The native receipt includes the
97-
active `v14_current_execution_shape_agnostic_compile` against the authenticated
98-
frozen v14 tar closure. During native-terms phase 0 through phase 1b,
99-
`CURRENT_TERMS_SURFACE_READY = False` retains the complete
100-
`CURRENT_EXECUTION_V15_CALLER` and `NATIVE_FX_CURVE_CALLER` templates as pending
101-
surface rows. The named good v15 compile and missing-Cancelled compile rejection
102-
also remain pending. Phase 1c activates every row with the actual host surface;
103-
the good caller must compile before its intentional negative compile control.
104-
Ordinary compile failures remain failures, separate from ABI link 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.
105110

106111
## Failure evidence
107112

‎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,33 +116,43 @@ 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
The v15 current-execution controls have been active since landing 1c.
138145

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

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

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

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

215-
The integrated representation advances the broker fingerprint domain to
216-
`pineforge-broker-state/v15` and stream fingerprint version to 15. Native
226+
The integrated representation advances the generic broker fingerprint domain to
227+
`pineforge-broker-state/v16` and stream fingerprint version to 16; the source
228+
extension begins with `pineforge-source-adapter/v1`. Native
217229
consumer identity is `native-consumer/v6`; driver v4 is unchanged, while
218230
`close_scope_v1` and `native_run_spec_v1` stay frozen. Stable `RunIdentity` /
219231
`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

0 commit comments

Comments
 (0)