Skip to content

Add native execution terms: host-resolved sizing, exact reversal, precommit view, FX curve (R4-B) - #251

Merged
luisleo526 merged 27 commits into
mainfrom
refactor/native-terms-20260913
Sep 14, 2026
Merged

luisleo526 merged 27 commits into
mainfrom
refactor/native-terms-20260913

Conversation

@luisleo526

Copy link
Copy Markdown
Collaborator

R4-B: native execution terms

Engine-only slice of the native-engine refactor (R4). A hand-written NativeStrategyHost can now, in batch and forward:

  • submit a HostSized opening/close whose units are resolved by the host at the match candidate through one const virtual (resolve_execution_terms), with the opening's physical shape (Transact / exact ReverseTo / CloseOpposite) chosen at the candidate on the then-current book;
  • submit an explicit queued ReverseTo (any trigger) or execute one at the current point, settled by the existing reversal owner with one ticket, one cycle and exact opened units;
  • receive a read-only precommit view of every fill and refuse it before any physical effect (validate_execution_precommit);
  • stage an immutable account-currency FX curve for a native run (native_fx_curve.hpp, strategy_configure_native_fx_curve_v1), hashed and projection-guarded, with a deterministic activation instant at every financial read.

One truthful epoch bump: native_order v3→v4, engine_script_run v14→v15, native-consumer v5→v6, broker-state/stream 14→15; driver stays v4. The v14 provider closure (frozen from f736676) joins the settlement ABI matrix (five providers, zero pending rows). A second native example (native-selected-example) and docs at v15.

Byte identity by construction

src/engine_strategy_commands.cpp, engine_fills.cpp, engine_orders.cpp, engine_risk.cpp, engine_run.cpp, engine_market_admission.cpp are untouched (empty diff vs f736676). engine.hpp / engine_execution.cpp change by namespace tokens, one private declaration and one additive overload. No call site of the new virtuals is reachable from generated code; codegen pin 7410c87 unchanged.

Verification so far (candidate ed75f55)

  • Release 341/341, Debug 341/341, Native 350/350 (+1 expected WebSocket skip); shallow depth-1 preflight; R-EPOCH; C++17 only.
  • Settlement ABI matrix: 5 providers, 51 compiles, 124 links, zero pending rows; exemption pins re-recorded.
  • Event-sequence identity vs the pre-slice tree under the identity host (journal, driver/account logs, trades, positions).
  • Independent reviews: gemini GREEN; Codex and Fable each 1–2 P1 on witness coverage / one identity attempted_terms edge — repairs land on this branch next.
  • Linux sanitizers + native profile on the AWS verification host: running.
  • Campaign sweep (fixed 4190 parity) on this exact head: running (exp-native-r4-b-ed75f55-20260914); the gate's target.not-positive FAIL is the expected neutral outcome of a refactor and will be recorded, not waived.

Draft until the sweep readback and the review repairs are attached. Contract, amendments, briefs and every receipt live in the campaign evidence root.

🤖 Generated with Claude Code

https://claude.ai/code/session_016iF71UAEuQ7F6eqWgecAHm

luisleo526 and others added 26 commits September 13, 2026 17:32
Track the exact 55-file include closure of the last engine_script_run_v14
commit (PR #250 squash f736676, tree c69421f) as a fixture, authenticated
per file by size, SHA-256 and Git blob, before any epoch-15 edit begins.
The preparation tool will build the real immutable source with each
profile's compiler and configuration; nothing here is wired yet.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_013y1CvsXqLFMRgAW7TXJQMs
Rename engine/host and order namespaces, the host capability macro, and
consumer/broker/stream identity markers without changing engine behavior
or existing C++ numeric assertions. Preserve the six measured files and
normalize only the identity header's stale namespace comment.

Generalize the ABI fence to the reviewed v13/v14-to-v15 pairs, pin the
Phase-0 header bytes, and derive authenticated provider owners and each
caller's order shape. Prepare and verify the frozen f736676 v14 archive
alongside e60, 0e, v13 and current v15, including unchanged-driver links.

Stage complete execution-terms/FX callers and the named negative compile
control behind the Phase-1c readiness gate. Activate the authenticated
v14 compile control, retain all old order-v1 pairs, and update registered
Python mirrors, CMake receipts, CI diagnostics and epoch documentation.

Validation: ci_preflight passed; full Release ci_verify passed all 334
registered tests with zero failures/skips; the unregistered native-feed
mirror passed 5 tests. The five-archive matrix passed 49 compiles and
118 links. R-EPOCH matches the 16 recorded historical/control residuals.

Co-Authored-By: Codex gpt-6-astra <[email protected]>
Add NativeFxCurve v1 values, ordered validation, and the total length-prefixed FNV digest. Register the source and validation/digest test, plus exact ownership, include-freedom, and introduced-at controls.

Contract: §3.4, §6, §7 1a, Appendix C rows 32 and 40, amendment A5.

Co-Authored-By: Codex gpt-6-astra <[email protected]>
…ct reversal

Add the v4 order terms surface, deferred allowance and authenticated binding receipts, exact reversal and whole-close accounting, durable receipt hashing, ABI shape pins, and core witnesses.

Contract: §3.1, §4.1–§4.2, §6, §7 (landing 1b), §8 (A-T1, A-T3, A-T4, A-T4d, A-R5, A-R6, A-S2, A-S3, A-S4, A-H1, A-1).

Co-Authored-By: Codex gpt-6-astra <[email protected]>
Add the complete v15 host values, identity resolver and precommit defaults, plus Ready-only FX-curve staging with a durable continuation-hash fold. Register the five phase-1 seed witnesses, re-pin the host ABI bytes, and activate the V15 ABI controls and mirrors.

Contract: §3.2, §3.5, §4.4, §6, §7 (Landing 1c), A-1, A-A2.

Co-Authored-By: Codex gpt-5.6-terra <[email protected]>
Fully assert reversal allowance and remaining projections, including the absorbed-turnover witness.

Contract rules: §3.1, §4.2, §8 A-R6, §9 A-0.

Co-Authored-By: Codex gpt-5.6-terra <[email protected]>
Add the W2 resolver, matcher provenance, plan dispatch, precommit, and FX activation seams under R4-B §§3.2, 3.3, 3.5, 4.1–4.4, 5, and amendment A1/A2.\n\nA6: append and hash the durable shared_cursor_collision receipt field.

Co-Authored-By: Codex gpt-5.6-terra <[email protected]>
Exercise host-sized terms, provenance collisions, reversal/whole-close plans, precommit barriers, FX activation, and durable replay/serializer branches under R4-B §7–§8 and amendments A1–A4.

Co-Authored-By: Codex gpt-5.6-terra <[email protected]>
Add test-only oracle, current terms facts, deferred cancellation, collision replay, projection barriers, and executable replay/market/calendar serializer controls for R4-B §7–§10 and amendments A1–A4.

Co-Authored-By: Codex gpt-5.6-terra <[email protected]>
Reject invalid opening-shape values and limit-breaching host prices before receipt installation under R4-B §4.1.

Co-Authored-By: Codex gpt-5.6-terra <[email protected]>
Add literal W2 coordinator witnesses for R4-B §8 terms, reversal, precommit, FX, provenance, and post-hook rows.

Co-Authored-By: Codex gpt-5.6-terra <[email protected]>
Cover expanded R4-B §8 terms, price provenance, reversal, precommit, FX, and hash/replay witnesses in the assigned W2 test files.

Co-Authored-By: Codex gpt-5.6-terra <[email protected]>
Add queued cancellation, price-kind, price-boundary, exact reversal, barrier, and fresh-replay acceptance rows required by R4-B §8.

Co-Authored-By: Codex gpt-5.6-terra <[email protected]>
Add assigned W2 provenance, precommit barrier, replay hash, and calendar binary64 serializer acceptance coverage under R4-B §7–§8.

Co-Authored-By: Codex gpt-5.6-terra <[email protected]>
Add all current fact-shape comparisons and native candidate timestamp sink witnesses for assigned R4-B W2 rows.

Co-Authored-By: Codex gpt-5.6-terra <[email protected]>
Add the W2 A-P4 pre-effects cycle-exhaustion witness with zero validator calls.

Co-Authored-By: Codex gpt-5.6-terra <[email protected]>
Address zero-unit nonpositive terms, callback activation timestamp, provenance invalidation, and complete TermsResolved serializer coverage per W2 review D1-D3.

Co-Authored-By: Codex gpt-5.6-terra <[email protected]>
Serialize complete TermsResolved identities/projections and add real market/calendar lifecycle plus appended-history replay witnesses for D3/D4.

Co-Authored-By: Codex gpt-5.6-terra <[email protected]>
Ensure valid HostSized zero terminals install their receipt and NoEffect even at nonpositive or limit-side prices.

Co-Authored-By: Codex gpt-5.6-terra <[email protected]>
Correct the public C ABI documentation to state that carried 1× long and short positions are supported while leveraged positions fail closed.

Contract: §3.4, §6, §11, Appendix C row 35.

Co-Authored-By: Codex gpt-6-astra <[email protected]>
Add the Ready-only FX curve C entry, runtime export inventory, and direct and dynamic C caller coverage.

Extend the v15 ownership and exact-count ABI fences with registered mirrors.

Contract: §3.4, §6, §7; A-F1, A-A1, A-A2, A-E2.

Co-Authored-By: Codex gpt-5.6-terra <[email protected]>
Document the R4-B native terms, exact reversal, precommit, FX-curve, ABI transition, and runner examples.

Contract: §3.2, §3.4, §3.6, §6, §7 W4, §11; A-E1, A-E2.

Co-Authored-By: Codex gpt-6-astra <[email protected]>
Add the v15 selected native runner module, its dynamic batch/stream test, and the final ABI/example documentation refinements.

Contract: §7 W4, §8 fail-before protocol, A-E1, A-E2, and R-EPOCH.

Co-Authored-By: Codex gpt-5.6-terra <[email protected]>
Record PR #247 and PR #248 as completed R3 milestones, and separate PR #246 historical epoch-13 state from the current R4-B baseline.

Contract: §6 R-EPOCH rule 3; Appendix A; A-E2.

Co-Authored-By: Codex gpt-5.6-terra <[email protected]>
Apply the root-authored worker guidance patches for the R4-B integration.

Contract: R4-B §§0, 7, 8, 9.

Co-Authored-By: Codex gpt-5.6-terra <[email protected]>
Re-pin the recorded A6 native_order and integrated native_host bytes after phase-3 review.

Contract: R4-B §§6–7; amendment A6.

Co-Authored-By: Codex gpt-5.6-terra <[email protected]>
import unittest
from unittest import mock

import check_settlement_cpp_abi as checker
Repair the explicit identity ReverseTo rejection metadata and add literal A-T5, A-T6, A-T9, A-S2, A-P1, and A-F7 witnesses.

Contract: §3.1, §4.1-§4.4, §8; A-T5, A-T6, A-T9, A-S2, A-P1, A-F7.

Co-Authored-By: Codex gpt-5.6-terra <[email protected]>
@luisleo526

Copy link
Copy Markdown
Collaborator Author

Campaign sweep on the exact candidate ed75f55 — no regression

  • Experiment exp-native-r4-b-ed75f55-20260914 (execution pineforge-experiment-run-nfzj8, runner j58d5): 72/72 cases, 4190/4190 probes measured, 0 failed.
  • Readback vs the accepted reference exp-ci-preflight-0679210-20260913: 0 trade differences, 0 grade differences, 0 substantive verifier differences, coverage identical, configuration identical → accepted_non_regression.
  • Candidate snapshot 0a745769… (4190 graded) is grade-identical to the active baseline e5e887ed… (0 differences).
  • Actual pr-gate (pineforge-pr-gate-kqvx2, run cloudrun__pr_gate__fb961c2ffaef901d): FAIL target.not-positive — the expected neutral outcome of a zero-improvement refactor, recorded as-is (no PASS receipt, no baseline promotion). Baseline pointer unchanged.
  • Local: Release 341/341, Debug 341/341, Native 350/350; five-provider settlement ABI matrix, zero pending rows; event-sequence identity vs the pre-slice tree.

Evidence: campaign evidence root measurement/R4-B-ED75F55/ (readback/SUMMARY.json, snapshot-grade-equality.json, GATE-EVIDENCE.json). 45b8280 on top of the swept head changes the consumer's identity attempted_terms edge and tests only; the six measured sources are untouched on every commit of this branch.

@luisleo526
luisleo526 marked this pull request as ready for review September 14, 2026 01:01
@luisleo526
luisleo526 merged commit e7cdf05 into main Sep 14, 2026
10 checks passed
@luisleo526
luisleo526 deleted the refactor/native-terms-20260913 branch October 5, 2026 02:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant