Skip to content

Add selected native closes and synchronous current-point execution - #250

Merged
luisleo526 merged 5 commits into
mainfrom
refactor/native-current-selected-20260913
Sep 13, 2026
Merged

luisleo526 merged 5 commits into
mainfrom
refactor/native-current-selected-20260913

Conversation

@luisleo526

@luisleo526 luisleo526 commented Sep 13, 2026 •

Copy link
Copy Markdown
Collaborator

Native strategies could not close a chosen subset of open provenances with one execution, nor consume a newly accepted market request synchronously at the callback point; both had to be emulated through singleton fan-out (two tickets) or whole-book flatten (closes unrelated exposure). This slice adds those two native capabilities through the existing execution coordinator and exposes committed fills through a generic notification, without introducing a Pine scheduler, a second matcher or a second cash path.

  • BindOpenings / OpeningsClose: one immutable canonical opening cohort bound at request time, the live subset derived at execution, one selected execution = one ticket = one Applied/Account observation = one fee. Selected fills cannot open exposure; an unrelated opening stays untouched. Financial Action and two-way CloseScope are unchanged; the call-local SelectedOpeningSet exists only at the financial boundary.
  • Guarded current-point execution: current_execution_point, inspect_current_execution, execute_current. The target must be a live request accepted or replaced in the same callback; waiting/priced/budgeted requests are refused, never silently deferred. Ordinary submission keeps its queued behaviour. The synthetic execution coordinate copies the factual frame and clamps only effective time to the decision floor, so a modeled-open or interior notification can never execute before the target's birth.
  • Read-only preview with independent settlement_readiness and AccountEffectProjection status; exact pinned-ticket row PnLs; no saved apply authority and no history copy.
  • Generic on_native_applied after financial/request/Account and owner/group/dependency effects; nested current commands complete synchronously and their notifications drain FIFO at depth 1 after the outer callback returns. Notification storage keeps stable identities and owned values, never references into the mutable history vector; queue/receipt capacity is reserved geometrically before financial effects and any late allocation failure latches the host.
  • Epochs: engine/host v13→v14, native order values v2→v3, native driver v3→v4 (adds CurrentExecution), native consumer semantic v4→v5. Identity v1, NativeRunSpec v1, public C ABI v4 and the pending C v1 prefix are unchanged. A real v13 header/archive provider frozen from c3ed455 joins the e60 and 0e providers; cross-epoch callers must fail at the declared symbols and old-old/new-new controls still link. The checker tolerates the exact caller-owner RTTI that sanitizer instrumentation emits only for a sanitized cross-epoch negative link, and derives each provider's epoch from the archive's own symbols rather than from which command-line role named it.
  • Continuation hashing covers the added owner/authority/scope members, canonical cohorts, current frame and pending notification facts. CI diagnostics retain the v13 provider receipt and build logs.

Generated Pine strategies still take their existing route: this is one native capability slice, not R4 completion. Source-host/adapter ownership, late quantity/price resolution, exact reversal routing, FX/rollover policy and deferred ANY binding remain mandatory R4 work.

Validation: all ten hosted checks passed on the first run at c2d911b (preflight, four build profiles, sanitizers, native-live, required build, two code-scanning analyses). Local Release and Debug profiles passed 334 tests with no skips; the native profile passed 342 (Linux, required WebSocket) and 44 real-library ABI links per profile with no caller executed. The settlement ABI checker now compares engine storage declarations, the virtual inventory and every layout word against the v13 providers unconditionally (252/252, 10/10, 789/789 and 793/793 equal), with the four native headers this slice changed as the only enumerated, receipted and byte-pinned v13→v14 exemptions. Four new floor regressions fail against the pre-repair build. Exact-candidate independent reviews (two per candidate) are GREEN on the final bytes. A fresh depth-1 checkout passes the shared preflight.

The complete Cloud sweep measured all 72 cases and 4,190 observations/verifier reports for this exact head against the accepted exp-ci-preflight-0679210-20260913 reference: zero trade, grade, substantive-verifier, configuration or coverage differences (the two runtime-identical predecessors 899977a and 01e23ba measured the same).

The actual gate returned FAIL target.not-positive with the candidate snapshot grade-identical to the active baseline (0 of 4,190 grades differ). The neutral refactor is accepted under the user's standing zero-improvement authorization; the real FAIL is retained and baseline promotion stays deferred. Squash-tree equality and post-merge CI are verified separately.

🤖 Generated with Claude Code

https://claude.ai/code/session_013y1CvsXqLFMRgAW7TXJQMs

luisleo526 and others added 5 commits September 13, 2026 15:08
The sanitized cross-epoch RTTI allowance inferred the provider's engine
epoch from whether the runtime path equalled --library. In
--old-rejections-only mode the authenticated e60 v13 archive may itself be
supplied as --library, so a current v14 caller's expected rejection was
misclassified as same-epoch and its exact-owner RTTI refused (false
failure, never a false acceptance).

Read the epoch from the archive's defined BacktestEngine symbols instead,
memoized per archive, and keep the allowance decision in one tested
predicate: exact caller-owner RTTI is tolerated only for a sanitized
cross-epoch negative link. Full-matrix behaviour is unchanged.

Add a tooling test for symbol-derived epochs (none/several refused) and
for the allowance predicate across both directions and sanitizer states.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_015wvgEP9WUyEQhta7ZDqUB4
… review gaps

The settlement ABI checker skipped the engine storage-declaration, virtual-
inventory and most layout-word comparisons whenever the provider epoch
differed from the current one. With every real provider at epoch 13 that
bypass would have let any later epoch-14 commit change BacktestEngine
storage, its vtable or the compared aggregate layouts without an epoch bump,
even though all of those compare equal today.

Compare them unconditionally: storage declarations, the virtual inventory
and every emitted layout word must match the v13 providers; a mismatch
names the differing words. The four native headers that the v14 slice
deliberately changed are the only enumerated exemptions for the v13->v14
transition, each recorded in the receipt with both digests and pinned to
its reviewed bytes, so a further change within v14 fails until the epoch
is bumped and the pin re-recorded. Hoist the per-link decision into
link_outcome() with a really memoized provider_engine_for(), and record the
provider epoch on every link row.

Tests: three tooling tests drive the review-2 --old-rejections-only alias
configuration through the production link decision (memo reads once per
archive), the header exemption matrix and the full layout comparison, plus
one for the exempted-header pins. The waiting-owner current-execution
refusal is asserted exactly through both preview and execute_current, and
the resting replay contract gains a selected BindOpenings close scenario
(cohort of two, unrelated opening untouched, cancelled cohort close carrying
OpeningsClose authority) compared across two hosts at every boundary.

Docs: the settlement ABI fixture guide lists all three real providers, the
--v13-receipt flag and what the v13->v14 comparison actually checks;
abi-stability.md states the exemption and pin rules.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_013y1CvsXqLFMRgAW7TXJQMs
@luisleo526
luisleo526 marked this pull request as ready for review September 13, 2026 09:29
@luisleo526
luisleo526 merged commit f736676 into main Sep 13, 2026
10 checks passed
luisleo526 added a commit that referenced this pull request Sep 14, 2026
…commit view, FX curve (R4-B) (#251)

* Freeze the epoch-14 native provider header closure from f736676

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 native epochs to v15/v4 and wire the frozen v14 provider

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 the native FX-curve value header and its validation

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]>

* Add native_order_v4 execution terms core with deferred sizing and exact 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]>

* Declare the v15 native host terms, precommit and FX-curve surface

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]>

* Pin the A-R6 reversal accounting witnesses fully

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]>

* Implement native execution terms coordinator

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]>

* Add native terms coordinator witnesses

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]>

* Cover native terms provenance and serialization

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]>

* Validate native host terms before receipt

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]>

* Expand native terms acceptance matrix

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]>

* Add literal W2 terms acceptance rows

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]>

* Broaden W2 acceptance witnesses

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]>

* Complete W2 replay and serializer controls

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]>

* Strengthen current facts and FX sink coverage

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]>

* Exercise precommit cycle exhaustion boundary

Add the W2 A-P4 pre-effects cycle-exhaustion witness with zero validator calls.

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

* Fix native terms review defects

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]>

* Complete durable terms serialization and replay tests

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]>

* Preserve zero-unit terms across price fences

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]>

* docs: correct carried FX rollover support

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 native FX curve C ABI transport

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]>

* docs: describe native execution terms v15

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]>

* test: add native selected strategy example

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]>

* docs: correct the native refactor progress record

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]>

* docs: add native refactor worker guidance

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]>

* fix: re-pin reviewed native ABI headers

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]>

* Drop identity attempted terms and complete the terms acceptance rows

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]>

---------

Co-authored-by: Claude Fable 5.1 <[email protected]>
Co-authored-by: Codex gpt-6-astra <[email protected]>
@luisleo526
luisleo526 deleted the refactor/native-current-selected-20260913 branch October 5, 2026 02:43
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