Add scoped native settlement for opening exposure - #244
Merged
Conversation
luisleo526
marked this pull request as ready for review
September 12, 2026 11:57
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A native close currently drains the whole position in FIFO order. This change adds an explicit opening-exposure scope, so reducing B by one unit in a book [A:2, B:3] leaves [A:2, B:2]. Every surviving fragment of B's opening request is selected within its exact position cycle, with one execution fee and preserved historical entry costs.
The existing settlement methods keep their signatures and whole-book behavior. New scoped methods share target validation and allocation arithmetic between inspection and settlement; stale owners and selected Transact actions are refused before effects. This is the internal prerequisite for owner-bound orders; resting-order matching and child/group lifecycles remain later R2 work.
Validation at candidate 794d1f2:
All nine CI checks on this exact runtime candidate passed. Snapshot b0e03f3b48f6353228d9873b4793c9ce5bb19bc6ec33b75e7786d91a8cff4c3a is published. Actual gate pineforge-pr-gate-m6j9h returned FAIL target.not-positive only: no improvement, no regression. Merge uses the standing neutral-refactor authorization; this remains a FAIL and does not promote the campaign baseline.
The first Cloud attempt ended 71/72 because task15 failed before application startup. Its evidence is retained and the experiment is abandoned; fresh attempt2 completed all 72 cases without code changes. This PR completes the R2a prerequisite, not the full R2 resting-order phase.