Skip to content

INT28: wave-J engine integration (TVDEF-DROPS, W3/W3B/W4/W5/W6/W6B/W8, R1-CONSOLIDATE, RUN-HARNESS) - #294

Merged
luisleo526 merged 71 commits into
mainfrom
r5/int28
Sep 28, 2026
Merged

luisleo526 merged 71 commits into
mainfrom
r5/int28

Conversation

@luisleo526

Copy link
Copy Markdown
Collaborator

INT28: wave-J engine integration (paired with codegen-oss TV-DEFAULTS)

This PR integrates the accepted wave-J engine lanes onto main 962960b: 50 picked commits, each carrying -x and an INT28 pick note: <lane> <n> trailer, plus 5 integration commits. It merges together with codegen-oss PR #147 (TradingView's Pine v6 defaults for an omitted capital and order size). The parity gate measures the two as a coordinated pair.

Lanes

  • TVDEF-DROPS R1–R3: default-percent stop reversals; an explicit-quantity reversal is never declined at the open; an entry reversal voids the reversed side's exits.
  • W3-ENG-EXIT-ALLOC: F05. The exit-queue position of a re-issued strategy.exit; exits armed before an opening; global exit voiding on reversal.
  • W3B-ENG-GRID: F02. The close ledger: a close site books against its first call's id, oldest first. Exits whose entry neither exists nor rests are void.
  • W5-ENG-MARGIN-V6: margin under v6 defaults (MR, M1, C1, M2, QP, C2, MK).
  • W6-ENG-FILL-ORDER and W6B-ENG-PAIRS: order at one fill point, pair costs, POOC pairs.
  • W8C-SECURITY, W8D-NOTRADES, W8E-EXITS (C1): targeted tail fixes.
  • W4-ENG-POOC-SAMEPASS: F08, F19a, REX, F19c, MCSIZE, BRK, F14, DORM.
  • W8A-SIGSTATE-1 (R4, R-B, R2, R3) and R1-CONSOLIDATE (R1, R-A, ADR keep_handle rows).
  • RUN-HARNESS:
    • TradingView's first bar opens the emit window.
    • A declared bar magnifier runs magnified.
    • syminfo.mincontract comes from the lane's quantity step.

Integration commits

  • Rule compositions: where two lanes' rules meet, the result is pinned by TradingView tapes that fail on the uncomposed merge (test_int28_rule_compositions, 29/0).
  • Test fixtures and pins:
    • Frozen twin copies are mirrored.
    • The behaviour pins that moved were re-harvested once, and every moved row is attributed to a pick.
    • The ctest floors are raised to the integrated tree's counts.
  • Docs: all 1,725 doc anchors were re-anchored and resolve.

Verification (head 4efcb8c)

Check Result
ci_preflight passed
release 748/748
sanitizers 729/729
debug 729/729
kernel 296 rows, residuals 0 findings
docs 0 Doxygen warnings
corpus parity 312/312 unchanged, 54-probe subset unchanged

🤖 Generated with Claude Code

https://claude.ai/code/session_01LifAW9e5J6gFx7gatuxETE

luisleo526 and others added 30 commits September 28, 2026 03:59
… fund keeps its closing leg

Pine v6 now sizes an omitted order at 100% of equity (lane TV-DEFAULTS). A
default percent_of_equity (<= 100) pure STOP entry is sized at its snapped
level and priced at the signal close; a sell stop sits below the close, so at
100% its short needs more margin than the equity. ab9714b kept such a
reversal as its closing leg (pine_strategy_commands.cpp:408-419). R4 slice C
(73817c1) split the default-stop arm off the affordability arm and dropped
the whole command, so the long was held to the end of the range.

TradingView, on synthetic probes written for this lane (lab tv --no-note,
BINANCE:ETHUSDT.P 15, 2025-04-01 .. 2025-05-01; tests/fixtures/tvdef_drops):
- tdd-r1-stop-reversal-close-only (v6 defaults): both long seeds close at
  their sell stops (1548, 1640) and no short opens;
- tdd-r1-stop-reversal-half (percent 50, declared): the same stops close the
  long and open the short.

The adapter now sets affordability_close_only for an unfunded reversal in the
default-stop arm; the fill-time terms already book a close-only entry as the
opposite book's close. A flat or same-side unfunded stop is still dropped.

Fail-before: tests/test_tvdef_drops_tapes.cpp built against d3b753c's
library: "FAIL ... lane.trades == tape.trades" on
tdd-r1-stop-reversal-close-only (each long exits at the 02:15 cleanup instead
of the stop), "49 passed, 1 failed"; the 50% control passes. After: "50
passed, 0 failed".

Population: scripts jaysharma-order-lifecycle-trace and
jaysharmaofficial-alphamojo-supertrend-strategy-ha-with-buffer (20 lanes) and
job-2910-cleightyp-claytp-sauce-v1-1 (ETHUSDT.P 1D), whose TradingView tapes
never open the short their stop reversals name.

Layer: the source-adapter parity runtime (ADR-0001, Decision, layer 2). No
kernel unit changes and no durable state is added (the flag already exists
and is hashed).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
(cherry picked from commit db077f39d54fafdc9ad7375b0762eb055607372e)
(cherry picked from commit 4ba35993e59fafa1a5938662ff5b00e5d5059283)
(cherry picked from commit 04ec289d5519910fadf11cf2221191067bcd2f90)

INT28 pick note: TVDEF-DROPS 1
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ersal at the open

The adapter decides at a bar open whether a live opposite entry is a reversal
TradingView declines (declined_reversal_at_open), and then cancels the
position's from_entry stops the bar's adverse extreme reaches
(defer_declined_reversal_exits_at_adverse). Both priced a candidate without
frozen default units at config_.default_qty_value. That is a fixed default's
own size, but an explicit qty=1 entry under Pine v6's default of 100 was
priced at 100 units, declined, and its from_entry bracket cancelled -- the
bracket TradingView scratches at the reversal's open fill.

ab9714b scoped the fill-time decline to a frozen default quantity
(pine_fills.cpp:5227-5235, frozen_default_qty), which
pine_strategy_commands.cpp:596-601 sets only when qty is omitted; an explicit
quantity never entered it. Both loops now skip a candidate whose quantity is
explicit; a default candidate is priced as before.

TradingView (lab tv --no-note, BINANCE:ETHUSDT.P 15, 2025-04-01 ..
2025-05-01; tests/fixtures/tvdef_drops): tdd-r2-explicit-reversal-bracket
(v6 default, every entry qty=1) and tdd-r2-explicit-reversal-bracket-fixed1
(fixed 1 declared) are one byte-identical tape: each one-unit reversal opens
and its bracket (stop already through at the open) scratches it there.

Fail-before, built against db077f39 (the R1 tree): "FAIL ... lane.trades ==
tape.trades" on tdd-r2-explicit-reversal-bracket (the short-to-long
reversal's long rides to the 02:15 cleanup), "111 passed, 1 failed"; the
fixed-1 control passes. After: "112 passed, 0 failed".

Population: order-market-reversal-resting-bracket-gap-01 (the ETH@15 hard
probe of the same shape: exitP90 0.086 under the v6 default).

Layer: the source-adapter parity runtime (ADR-0001, Decision, layer 2). No
kernel unit changes; no state added.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
(cherry picked from commit c53ad8aecb6462482dd005cc1e782fad193d11a4)
(cherry picked from commit 30943479884478945668a28cd0c7daa37b883843)
(cherry picked from commit 77b3f544bdfa089b5944819e4c22792dd092d315)

INT28 pick note: TVDEF-DROPS 2
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…y="" exits

A script that re-issues a from_entry="" exit for the side it holds issues it
once more on the bar it places a MARKET entry for the other side -- after the
entry, still for the held side. TradingView never applies that exit to the
side the reversal opens, on its entry bar or later. The kernel binds such an
Independent close to the book it first evaluates against. Under a fixed
default the adapter batches the market reversal behind the bar's commands, so
the exit is evaluated (and bound) first and the kernel cancels it with the
held book (OwnerGone). Under a percent or cash default the reversal reaches
the kernel first, the exit binds to the NEW position, and its levels --
marketable against the new side -- close it at its entry open.
purge_brackets_after_applied_reversal only ever purged from_entry cohorts (and
only for a reversal into a long: its guard reads the signed opened_units).

on_applied now cancels, at an applied reversing entry in either direction,
every still-working from_entry="" exit placed while the reversed position was
open (its side, its cycle). A leg the kernel already cancelled with the held
book is not among the host's working requests and is left to its terminal
receipt -- a cancel of it would record a NotWorking event -- so the fixed
default's path is unchanged, event for event.

TradingView (lab tv --no-note, BINANCE:ETHUSDT.P 15, 2025-04-01 ..
2025-05-01; tests/fixtures/tvdef_drops), both directions in each probe:
- tdd-r3-reversal-voids-global-exit (v6 default: percent 100, with the
  100% shorts' entry-bar margin calls): each reversed side exits later by its
  own exit;
- tdd-r3-reversal-voids-global-exit-half (percent 50): the same;
- tdd-r3-reversal-voids-global-exit-fixed1 (fixed 1 declared): the same
  timing; the engine already booked it.

Fail-before, built against c53ad8ae (the R1+R2 tree): "FAIL ... lane.trades
== tape.trades" on tdd-r3-reversal-voids-global-exit and on its -half (both
reversals scratched at their entry opens by the prior side's exit), "221
passed, 2 failed"; the fixed-1 control passes. After: "217 passed, 0 failed".

Population: job-2436-williamcleves-double-tap (NSE:NIFTY 15; 518 trades vs
TradingView's 517 under the v6 default: seven reversal-born positions closed
at their entry opens by "TP1 Short" / "TP1 Long", one of which re-entered).

Behaviour for explicitly sized scripts: an entry reversal whose market
request reaches the kernel ahead of the bar's re-issued from_entry="" exit
(any non-fixed default, or a fixed default outside the batched same-bar
scope: pyramiding > 1, process_orders_on_close, calc_on_order_fills,
close_entries_rule=ANY, a priced reversal) no longer lets that exit close the
new position.

Layer: the source-adapter parity runtime (ADR-0001, Decision, layer 2). No
kernel unit changes; no state added.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
(cherry picked from commit d1a39eb3f75169d2cda52ae764ee829c33af2f0d)
(cherry picked from commit c5e724ed1a1ad048694c0fe149d648e6a6d0e9f3)
(cherry picked from commit 3d12ef218cdf9bfa6ce45263f47ea82b0a4468e1)

INT28 pick note: TVDEF-DROPS 3
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ide its levels are on

R3's own tapes leave the reversal-bar exit's levels marketable against the new
side, so they cannot tell a void exit from one TradingView keeps but never
triggers. This tape settles it: on the bar a MARKET entry reverses the held
side, a from_entry="" exit is placed once, after the entry, with levels on the
correct side for the NEW position -- and it is void as well.

TradingView (lab tv --no-note, BINANCE:ETHUSDT.P 15, 2025-04-01 ..
2025-05-01; tests/fixtures/tvdef_drops/tdd-r3b-reversal-voids-right-side-exit,
v6 defaults): the reversal-born long (A: stop 1540 / limit 1570) and short
(B: stop 1490 / limit 1440) both ride to the cleanup (the 1570 limit the long
reaches at 01:30 and the 1440 limit the short reaches at 01:00 never fill);
C's exit, placed with an entry from flat, is that position's and closes it at
1640. The adapter's rule at d1a39eb3 books exactly these rows (no change here).

Fail-before, built against c53ad8ae (the R1+R2 tree): "FAIL ... lane.trades
== tape.trades" on this tape as on R3's two rule tapes (the engine closes the
long at 1570 and the short at 1440), "273 passed, 3 failed". After: "267
passed, 0 failed".

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
(cherry picked from commit 377cdce974d2f8ec3c5ece849ae7cdf49009cb0c)
(cherry picked from commit ed8a6e806bc76c3e8032ff17f58df6bb8bfbc075)
(cherry picked from commit 8633d9440282306f054488487780543ece5dd319)

INT28 pick note: TVDEF-DROPS 4
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
TradingView reserves an entry's quantity for its strategy.exit orders in
the order the exits were created. Re-issuing an exit modifies it in place
and keeps its place in that queue; a later-created exit gets only what the
earlier ones leave. Of two exits without qty on one entry, only the one
created first ever fills (TAIL-TRIAGE family F05: scalpulat0r's tapes show
946 stop exits and no target exit over twelve lanes).

compute_exit_reservation counted every other live exit against the one
being re-issued, the exits created after it included. A script that issues
a stop and then a target every bar keeps both live and unreserved while
flat. On the bar an explicit-quantity entry is placed under
process_orders_on_close, the pending entry gives them a basis; the stop,
re-issued first, saw the target's stale full reservation, was refused
(exit_cancel_bracket), and the target took the whole position. The engine
then filled targets TradingView never fills and never fired the stops.

compute_exit_reservation now skips exit families queued after the one being
re-issued, and reconcile_deferred_exit_reservations hands the position out
in queue order. exit_queue_rank reads the queue place from state the
adapter already keeps and hashes: the first row of the exit's replacement
chain (chain_origin_sequence, which remember() carries across re-issues), a
staged leg's predecessor, or the source_sequence a staged leg retained. A
new exit still yields to every exit already there, and a strategy.close
reservation still counts in full.

TradingView (lab tv --no-note, BINANCE:ETHUSDT.P 15, 2025-04-01 ..
2025-05-01; tests/fixtures/exit_queue, fixed 1 per long, five cells):
- rule tapes the engine missed: w3f05-s5 (stop A then target B every bar,
  process_orders_on_close, qty=1: only A fills, though B is reached first
  in four cells), -s6 (B then A: only B), -s8 (A 50%, B full: B gets the
  other half), -s8b (A full, B 50%: B nothing), -s13 (both in one
  oca_name: unchanged);
- controls it already booked: -s1/-s2 (s5/s6 without
  process_orders_on_close), -s7 (50% each), -s10 (B created first on the
  entry bar keeps the position although A is issued first on every later
  bar), -s14 (A issued once), -s15 (a cancelled A issued again is new, behind
  B), -s16 (an exit's place does not carry into a later trade), -s18/-s21
  (an exit issued before its entry exists is void), -s20 (one issued while
  its limit entry rests is the entry's).

tests/test_exit_queue_tapes.cpp replays every tape through the Pine
adapter. Fail-before, against 8633d944's library: "564 passed, 5 failed"
(s5, s6, s8, s8b, s13 differ from the tape); after: "569 passed, 0 failed".

Population (Cloud Run, against exp-r5-tvdd-measure-20260927): the twelve
scalpulat0r-0dte-scalper-v4 lanes move moderate -> excellent (trade counts
unchanged, every trade now the tape's). Their exits name their entries, so
of the lane's rules only this one acts there.
exp-w3-eng-exit-alloc-c1-20260927 (this rule with a first, broader form of
the next) moved these twelve and no other of the 62 F05/F02 probes; the 40
seeded excellent controls of the same lanes stay byte-identical in every
experiment of the lane.

Layer: the source-adapter parity runtime (ADR-0001, Decision, layer 2). No
kernel unit changes; no state added (the queue place is read from
chain_origin_sequence / source_sequence, both already hashed).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
(cherry picked from commit 2b259623a488e582fb2853882e0817d0a52d9337)

INT28 pick note: W3-ENG-EXIT-ALLOC 1
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
An exit with from_entry="" armed before its position opens (issued on the
entry bar under process_orders_on_close, or while flat) queues for the
position like a named one: TradingView fills only the one created first.
The opening fill reconciled the reservations of named cohorts only, so two
such exits each kept a dynamic reservation of the whole position and the
kernel filled whichever level the market reached first.

At an opening, on_applied now orders the global exits still unreserved by
their place in the queue (exit_queue_rank) and cancels every one behind an
exit that claims the whole position (no qty, qty_percent 100). The one in
front keeps its dynamic reservation, as its later re-issues do (the
unchanged bracket path); a new exit yields to it as before.

TradingView (lab tv --no-note, BINANCE:ETHUSDT.P 15, 2025-04-01 ..
2025-05-01): tests/fixtures/exit_queue/w3f05-s11-pooc-qty-any-entry, s5 with
both exits from_entry="": only stop A fills (the rows are s5's, byte for
byte).

Fail-before, the test at this commit against the previous commit's library:
"603 passed, 1 failed" (s11 differs from the tape); after: "604 passed,
0 failed".

The rule acts in no run of the three behaviour batteries
(test_adapter_quiet_bar, test_adapter_live_state_equivalence,
test_publication_witness; an instrumented copy of the adapter counted it).
Population: exp-w3-eng-exit-alloc-c4-20260928 (the lane's final tree
without this rule) and exp-w3-eng-exit-alloc-c3-20260928 (with it) book
byte-identical trades on all 62 F05/F02 probes and the 40 controls.

Layer: the source-adapter parity runtime (ADR-0001, Decision, layer 2). No
kernel unit changes; no state added.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
(cherry picked from commit 110b270938afb719bd8e4e6bc7e6f0471e8b37c7)

INT28 pick note: W3-ENG-EXIT-ALLOC 2
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… too

Lane TVDEF-DROPS' R3 cancels, at an applied entry reversal, every
from_entry="" exit placed while the reversed position was open and still
working on the book: TradingView never applies it to the side the reversal
opens. When a second entry of the reversal bar is still pending, the
reversal's fill first parks that exit's legs -- marketable against the new
side -- in delayed_market_orders_ for the next open, their requests already
cancelled. R3 did not see them there: the adapter released them at the next
open and closed the new position with the reversed side's levels.
Meanwhile they also stood as reservations against the new side's own exit.

The R3 block now also drops such parked legs (and staged bracket legs of
the same kind) from their queues. They left the book when they were parked,
so dropping them records no kernel event.

TradingView (lab tv --no-note, BINANCE:ETHUSDT.P 15, 2025-04-01 ..
2025-05-01): tests/fixtures/exit_queue/w3f05-r1-two-parent-reversal-global-exit
(40% of equity; a long re-issues exit XL, from_entry="", at close -/+ 20
every bar; at 00:30 two short entries S1 and S2 and XL again; the short
re-issues XS at avg -/+ 15): every short exits by XS or the cleanup, never
by XL. Population witness: job-2436-williamcleves-double-tap on
OANDA:XAUUSD 15, 2026-01-16 15:30 UTC (PUT_SCOUT and PUT_BOS both placed
at 15:15; TP1 Long's parked legs closed the short at 16:00 open, where
TradingView's TP1 Short stop fills at 4579.32).

Fail-before, the test at this commit against the previous commit's library:
"684 passed, 1 failed" (r1 differs from the tape); after: "673 passed,
0 failed". lab tv tapes of tests/fixtures/tvdef_drops still replay (267
passed).

Population (Cloud Run, against exp-r5-tvdd-measure-20260927):
exp-w3-eng-exit-alloc-c4-20260928 (the first rule and this one) and
exp-w3-eng-exit-alloc-c3-20260928 (the lane's final tree) move four
job-2436-williamcleves-double-tap lanes that exp-w3-eng-exit-alloc-c1-20260927
(the first rule and a first form of the second, without this one) left
alone: OANDA:XAUUSD 15 strong -> excellent (the witness above: that short
now exits at 4579.316; 4 unmatched pairs -> 0), NYSE:F 1D strong ->
excellent, NASDAQ:AAPL 1D strong at match 96.3 -> 98.1 %, OANDA:EURUSD 15
excellent with TradingView's 651 trades (650 before). No metric of the 62
F05/F02 probes worsens; the 40 controls stay byte-identical.

Layer: the source-adapter parity runtime (ADR-0001, Decision, layer 2). No
kernel unit changes; no state added.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
(cherry picked from commit 977da92e464bbf74e3f875ad2c5694ddea16ab91)

INT28 pick note: W3-ENG-EXIT-ALLOC 3
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ills oldest first

Under the default FIFO close_entries_rule TradingView sizes a
strategy.close(id) without qty from a ledger of the units entered under the
id that no fill has booked yet. The grid bots of population family F02
(TAIL-TRIAGE, 43 probes: pyramiding up to 200, one strategy.close call site
in a loop over the grid levels) read that ledger on every take-profit, and
TradingView keeps it by three rules, pinned by the tapes in
tests/fixtures/grid_close:

- one call site places one order per bar; a later call of the site re-sizes
  that order for its own id and comment, but the fill books against the id of
  the site's first call on the bar (w3f02-x2, w3bf02-a2);
- a fill books against its id's unbooked units, oldest first, and what they
  cannot cover spills over every id's unbooked units in the order the entries
  filled -- not by id name, and a re-entered id's new units behind every older
  entry's (w3bf02-a1, -b1);
- a call whose id has no unbooked units places nothing and leaves the site's
  order as it was (w3bf02-c1, -c2, -c3).

The adapter kept a per-id ledger but erased the first id's units whole and
held the survivor's fill as a standing reservation against the other ids
instead of booking it, with a carried "first target" for exact two-call
batches. The units the first id could not cover stayed on the books:
close("L38") closed 0.19 where TradingView closes 0.18 (w3f02-x2) or nothing
(w3f02-x1), and a loop closing D then C booked C (w3bf02-a2). Replaying the
43 probes' own call logs through the three rules reproduces every close bar
of TradingView's tapes before the first script-state divergence; the
reservation model missed 120 of them.

The ledger now keeps, beside the per-id totals, the same units by opening
fill in fill order (close_ledger_records_; adjacent records of one id
merge). enqueue_pooc_fifo_close sizes a call from the id's ledger against the
position less the bar's other close orders, as before, and skips a call with
nothing to close; the site keeps its first id. The fill books through
book_close_ledger. The reservation and first-target maps, the site's carry
and deferred-cleanup fields and close_reserved_other_units are gone; their
fixture reads answer none. The state fold keeps its layout: the records fold
only when there are two or more (one record is what the per-id map already
folds), the four retired maps fold as the empty maps they were outside a
multi-call site, and the five retired PlacementSnapshot close fields stay at
their defaults.

tests/test_grid_close_tapes.cpp replays 18 tapes (lane W3's w3f02-x1, -x2
and -g2 .. -g9, this lane's w3bf02-a1 .. -e2) and requires every trade,
exit signal included. Against 75fc4b90's library: "1046 passed, 3 failed"
(x2, x1, a2). After: "1046 passed, 0 failed".

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
(cherry picked from commit 5334a42db7c208b66aa21c79272dfbbb31944d3b)

INT28 pick note: W3B-ENG-GRID 1
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
TradingView's close ledger (previous commit) sums to the position: every
fill that reduces it books units, not only a strategy.close(id) without qty.
A fill books against the entry it names -- strategy.close(id, qty=q) against
id (tape w3bf02-f3: close("B", qty=0.1) takes A's lot physically, yet
close("B") then closes B's 0.1 left and close("A") A's whole 0.1) and a
strategy.exit against its from_entry -- and spills what that entry cannot
cover over the oldest entries' units. A fill that names no entry books the
oldest entries' units: a strategy.order sell (w3bf02-f1: after it
close("A") is void) and a margin call. The margin call's booking has no
synthetic tape; replaying the F02 probes' call logs, only oldest-first
booking reproduces TradingView's closes after the one margin call inside an
evaluable window (3commas-eth-grid ETHUSDT.P 1D, 2026-03-09): leaving the
ledger unbooked misses three later close bars, booking the liquidated lots'
own ids six.

The adapter booked only process_orders_on_close strategy.close(id) sites.
observe_close_ledger now books every fill that leaves its side open (a
reversal or a flat clears the ledger first): a Close row against the site's
first id or its own id, an exit leg against its from_entry, anything else --
an order, a margin call, a risk action, a fill with no placement row --
against nothing. Under the ANY rule the ledger sizes nothing and books
nothing (a close is bound to its id's own entries there), and it keeps no
records.

tests/test_grid_close_tapes.cpp gains the two rows. On the previous
commit's library: "1104 passed, 2 failed" (f1, f3). After: "1100 passed,
0 failed". The host's strategy_order passes no comment (nor does the
generated call), so f1's TRIM exit compares unsigned.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
(cherry picked from commit 93c16ce8c0a684a50c9f074f6c0e1e9855a582d2)

INT28 pick note: W3B-ENG-GRID 2
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…se ledger

W3-ENG-EXIT-ALLOC's open finding g1. Without process_orders_on_close
TradingView sizes a strategy.close(id) without qty from the same close
ledger as with it: the units entered under the id that no fill has booked,
filled at the next open, whether or not the FIFO rule has already closed the
lots that carried the id. Tape w3f02-g1: after close("B") takes A's lot,
close("A") still closes 1. The first-call booking holds there too (w3bf02-d1:
the loop's order fills 0.22 at the next open, booked against L45, and
close("L38") closes 0.18), and so do the spill order (w3bf02-d2) and an
exit's booking against its from_entry (w3bf02-f2: the exit for B closes A's
lot but books B's units, so close("A") closes A's 0.1 and close("B")
nothing).

The adapter sized the call from the lots still carrying the id
(cohort_exposure_for) and dropped it when the FIFO rule had closed them all
(pine_adapter.cpp, "compute_close_target_qty drops close when target unclosed
quantity is zero"). A default FIFO close (no qty, no qty_percent, not
immediately, not the ANY rule) now sizes from the ledger, capped at the
position, and is dropped only when the ledger holds nothing for its id. The
ledger is a running sum of fills: where it differs from the id's own live
lots by no more than kQtyEpsilon, the lots are the quantity, so a close of
every lot of the id leaves no rounding dust (a streamed run of
test_adapter_host_view_memo closed 3 ULP less otherwise). A later call of the
same call site on the bar replaces the site's order, as before, and now
carries the site's first id (close_first_id, set only when it differs from
the call's own id), which the fill books against. Under
process_orders_on_close the batched path already sized from the ledger; its
other routes keep their basis.

tests/test_grid_close_tapes.cpp gains the four rows. On the previous
commit's library: "1306 passed, 4 failed" (d1, d2, f2, g1). After: "1310
passed, 0 failed".

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
(cherry picked from commit 34656aa3071db7eec841893b3f692f1c524ba03e)

INT28 pick note: W3B-ENG-GRID 3
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
W3-ENG-EXIT-ALLOC's open finding (tapes s17, s19; s12 interacts).
TradingView voids a strategy.exit(from_entry = X) when the call runs while X
has neither an open trade nor an entry order waiting to fill: the exit does
not wait for a later entry of that id. w3f05-s17 (process_orders_on_close)
and -s19 (next open) issue target B once, on the bar before each entry, and
TradingView never fills it; lane W3's s18 and s21 already showed the same on
the entry's own bar, before the entry call, and its s20 that an exit issued
while its limit entry rests is the entry's when it fills. A new synthetic
tape, w3bf05-v1, shows the void call issued between two trades of L never
filling in the next one, where the engine filled it (04-10).

The adapter kept such an exit in the book, cohort-bound, and filled it
against the next position X opened (B at 00:15 on three of s17's five days).
The same flat-time exits cost s12 its stops: B, re-issued while flat after
the previous trade, kept a queue place ahead of the next trade's stop A,
issued first on the entry bar (lane W3's rule A queues exits by creation), so
A never fired inside the hour on 04-09 and B took 04-14 at 00:15.

exit() now marks a call void (PlacementSnapshot::void_issue) when a named
from_entry has no live lot -- read off the book too (open_lot_of), since a
reversal by an entry of the reversed side's own id clears that id's cohort
facts after recording its new lot -- no unbooked close-ledger units (under
FIFO), no entry order pending anywhere the adapter holds one
(entry_order_pending) and no exit of the pair issued while the entry rested
or was open (standing_exit). The void call's request is still placed, so
every later request keeps its incarnation (a script that issues both sides'
exits on every bar exports the same entry incarnations), but it acts on
nothing: it reserves nothing (compute_exit_reservation, the reconciliation
and the named-exit projection skip it), holds no place in the exit queue
(exit_queue_rank, remember and the staged paths start a re-issue made once
the entry exists afresh, without the void request's leg lifecycle), rests
for no margin checkpoint, is passed over by the post-calculation bracket
execution, the delayed open release and the declined-reversal stop scan,
stays bound to its entry's cohort, and the entry's opening withdraws it
wherever it waits (withdraw_void_exits). Where the process_orders_on_close
close pass or the recalculation's same-close fill takes it up, the close it
places is withdrawn instead of executed (execute_or_withdraw_close): that
pass used to flatten the book on the other side's void exit (a short closed
by an exit of an entry that never existed, in the publication witness's
storms), and it still places the close, so the numbering stays. A call made once the entry exists
that leaves a void request unchanged takes it over, queued from that call
(unvoid_exit). A void relative exit leaves nothing for the fill to resolve.
The state hash folds void_issue only when set. An all-NaN exit keeps its
cancel of a prior bracket; exits for every entry (from_entry="") are not
touched.

v1 also shows TradingView keeping an exit issued while its limit entry
rested when strategy.cancel cancels that entry, for the next entry of that
id, and ignoring a void call over it (04-08, 04-09). The adapter withdraws
such an exit with its entry: an open finding outside this rule, recorded in
tests/fixtures/exit_queue/README.md; until it is fixed a void call over an
exit the adapter still holds for its pair re-issues it as before. v1's row
compares the engine's trades from 04-10 on.

tests/test_exit_queue_tapes.cpp gains the four rows. On the previous
commit's library: "841 passed, 4 failed" (s12, s17, s19, v1). After: "845
passed, 0 failed". tests/test_flat_coof_exit_tapes.cpp's five tapes of an
exit placed for an id with no order yet (lane PAR-ORDERS-2), whose
recalculation rows it recorded as divergences, now book TradingView's rows
exactly; the recorded marks go.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
(cherry picked from commit 9568c524b7afb56331d49fc975eaac46d6960c89)

INT28 pick note: W3B-ENG-GRID 4
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…e leaves

Lane W3's review finding: rule B (110b2709) queues the exits for every entry
(from_entry="") at the opening only by cancelling the unreserved ones behind a
full one. A full exit behind partial ones kept its dynamic reservation of the
whole position. TradingView queues them like a named entry's exits
(w3bf05-g8, lane W3's s8 with both exits from_entry=""): behind the 50% stop
A, target B takes the other half and never the whole position -- its rows are
s8's, byte for byte. The engine closed all of it by B on four of five days.

When an unreserved full global exit has partial ones ahead of it in the queue,
the opening now hands the position out through
reconcile_deferred_exit_reservations with an empty from_entry, the path a
named entry's exits take (rule A); every other shape keeps rule B's cancel as
it was (a reserved exit neither triggers nor suffers it).

Two more review findings show no trade effect on TradingView's tapes and stay
open, pinned by rows: w3bf05-p1 (the reservation caps ignore queue order: a
front exit raising its qty_percent still takes the whole position the bar it
is raised) and w3bf05-r1c (rule C leaves the recalculation queue alone: lane
W3's r1 under calc_on_order_fills books TradingView's rows). The fourth -- rule
B cancelling a request the kernel already ended -- changes a hash, not a
trade; tests/fixtures/exit_queue/README.md records it.

tests/test_exit_queue_tapes.cpp gains the three rows. On the previous
commit's library: "1008 passed, 1 failed" (g8). After: "1021 passed, 0
failed".

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
(cherry picked from commit 3bce6bf342f88e2a62064793f174866bb3ac9120)

INT28 pick note: W3B-ENG-GRID 5
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…gView pins

The close model of this lane (its F02 and g1 commits) retires the
adapter's close reservation maps: a call site's order books against its
first call's id and spills over the oldest ledger records, and every
reducing fill books the ledger. test_integration_l4d (the frozen twin of
test_integration) pinned that reservation model's own bookkeeping in its
L4d close-replacement probes, several of whose values TradingView
contradicts. Six synthetic lab tv --no-note tapes of those probes' shapes
(tests/fixtures/grid_close, w3bl-*) pin TradingView's rows:

- w3bl-s6: one site closes F7 then L7, F15 then L15, then L3 then L4: the
  last order closes L4's whole 0.4159 (the reservation model capped it at
  0.3560; the twin's debt 0.5629 -> 0.6228, admitted 0.3560 -> 0.4159, final
  position 0.8982 -> 0.8383);
- w3bl-s7: a sell of 1 uses A up, so two sites' closes of A are void and the
  second site's close of B takes the book (the model rejected it: no exit,
  no debt; site B / REJECTED_FULL_B, two trades);
- w3bl-s8: a later close of D closes D's 3 (the model capped it at 2);
- w3bl-s9: after a sell of 1, a close of D closes D's 4 and flattens the
  book (the model closed 3);
- w3bl-s10a, -s10b: two sites on B's re-entries in either order, a sell of
  2, one site closing B, C then D: B's and C's calls are void and D's order
  closes D's 4, in two trades of 3 and 1 (the model closed 3, or 3.4).

tests/test_grid_close_tapes.cpp gains the six rows and the fixture README
their table. The twin's probes keep only the ledger view (its
reservation-map fixture accessors, and l4d_native_route_guard's, go with
the maps); its thirteen affected tests are renamed for what they now pin and
their assertions follow the tapes. tests/twin_parity_inventory.json extends
test_integration's observable rewrite (569 twin assertions, digest
re-derived, reason citing the tapes) and scripts/check_twin_parity.py
re-pins INVENTORY_SHA256; tests/test_integration.cpp, which the twin had
already left behind, stays as it is.

On the base 75fc4b90's library the six rows fail, beside the nine rows of
the lane's F02 and g1 commits ("1562 passed, 15 failed"); on this tree:
"1556 passed, 0 failed". test_integration_l4d: "1178 passed, 0 failed".

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
(cherry picked from commit 92348938d568d376b8019ea800ee6aaf14aee8a8)

INT28 pick note: W3B-ENG-GRID 6
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The lane's void rule (an exit whose entry neither exists nor rests is
void, TradingView's tapes w3f05-s17 / -s19 on top of lane W3's s18 / s21)
reaches two frozen twins whose scenarios issue an exit before its entry's
call, while the entry neither exists nor rests:

- test_dual_entry_placement_sizing_l4b, test_MM_pair_defers_percent_exit_
  reconciliation_until_net: the pair's 40% and 60% exits for LAY-L are issued
  between LAY-S's and LAY-L's calls, so nothing rests for them after the
  pair (1.0 and 1.5 -> 0 and 0); its legacy copy
  tests/test_dual_entry_placement_sizing.cpp follows;
- test_prearmed_exit_path_cursor_l4c, the FreshChild book of
  check_missing_provenance_is_inert: X is issued after the parent's cancel
  and before the fresh parent's call, so the fresh parent's trade has no X
  to close it (one closed trade -> none); the MissingParentCancel and
  PostCancelDoubleReissue books keep theirs.

tests/twin_parity_inventory.json records both as observable rewrites (their
twin assertion counts and digests, the reason citing the tapes) and
scripts/check_twin_parity.py re-pins INVENTORY_SHA256: "155 tests, 8298 base
assertions, ..., 404 pinned observable rewrites, ... OK". On this tree:
"178 passed, 0 failed" and "553 passed, 0 failed"; on the previous
commit's tree each fails its corrected assertions (2 and 2).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
(cherry picked from commit effb648d0e396673ffd91f5ad4ae5b39ca23aae7)

INT28 pick note: W3B-ENG-GRID 7
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…r a declined reversal and a margin-call revival

At Pine v6's defaults a MARKET reversal the next open cannot fund is declined
there, and its same-bar reversal pair holds the reversed side's brackets
dormant until a margin-call slice revives them. The adapter did this only for
a bracket naming the held entry: follows_same_bar_declined_reversal returned
early for a from_entry="" exit, suspend_brackets_for_reversal skipped it, and
revive_brackets_after_margin required a named cohort's exposure. A global exit
names every entry, so it is always the held position's; TradingView books a
global exit exactly as it books the named one.

TradingView, on synthetic probes written for this lane (lab tv --no-note;
tests/fixtures/margin_v6):
- w5-mr-global and w5-mr-once-global (BINANCE:ETHUSDT.P 15, v6 defaults):
  shorts reversed on their fill bar by a default long, with a from_entry=""
  exit already through at the next open -- the same file as the named-exit
  controls w5-mr-named and w5-mr-once-named;
- w5-rv-global-held (NYSE:F 15, the V19D-P1 shape): the stop exit placed
  from_entry="" while short is revived by the 05-02 09:30 margin call and
  closes the rest (12 @10.39 called, 928 @10.39 through X) -- the same file as
  the named control w5-rv-named-control.

Fail-before (tests/test_margin_v6_tapes.cpp against the base 8633d944):
w5-mr-global, w5-mr-once-global and w5-rv-global-held fail; the three named
controls pass. After: every row passes. The test row is registered here,
with the release floor 718 and the PR registration floors 699/699/708 counted
with ctest -N on this lane's tree (wave J's two tape rows: TVDEF-DROPS' and
this one).

Population (Cloud Run, exp-w5-eng-margin-v6-s4-20260928 against
exp-r5-tvdd-measure-20260927): job-2436-williamcleves-double-tap
(ETHUSDT.P 15) strong -> excellent.

Layer: the source-adapter parity runtime (ADR-0001, Decision, layer 2). No
kernel unit changes and no durable state is added.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
(cherry picked from commit 5aac65a65ffe3cbaba10ba31976797c2fe3bfec3)

INT28: the rule, the tape row and its fixtures apply unchanged (each file's
patch is byte-identical to the lane's). Its floor hunks (docs/ci.md,
scripts/ci_verify.py, scripts/test_ci_verify.py: release 718, PR registration
699/699/708 on the lane's tree) are not applied; INT28 recounts the floors
once on the integrated tree. tests/CMakeLists.txt: git's clean merge put this
lane's fixture if() inside W3-ENG-EXIT-ALLOC's block (its endif() fell below
the new block); each block is closed on its own.

INT28 (with W3B-ENG-GRID picked before it): composed with W3B's tape
w3bf05-r1c (W3 rule C under calc_on_order_fills, tests/fixtures/exit_queue).
There S1 reverses the long and S2, a second short MARKET entry of the bar,
is rejected at the same open; is_declined_market_reversal() reads S2's
placement (a short over a long) as a declined reversal, and this rule's
from_entry="" extension held the short's own exit XS, placed in the
recalculation after S1 filled, so XS missed its entry-bar limit
(1020 passed, 1 failed). A from_entry="" exit placed under the side the
rejected entry would open is that side's, not the held position's:
follows_same_bar_declined_reversal() and suspend_brackets_for_reversal()
leave it be, as bracket_belongs_to_reversal() already leaves a named exit
of that side. The w5-mr-* and w5-rv-* exits, placed under the held side,
are held as before: test_margin_v6_tapes 3081/0, test_exit_queue_tapes
1021/0.

INT28 pick note: W5-ENG-MARGIN-V6 1
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…its combined margin

A default percent_of_equity (<= 100) MARKET add to a held position of its own
side reached the kernel unjudged: the placement affordability rule covered
explicit, fixed, cash and above-100 % sizes only. Where an exit or a close
placed on the same bar took the next open first, the add then opened a new
position from flat. TradingView drops, when it is placed, an add whose margin
on top of the held units exceeds the equity.

TradingView, on synthetic probes (lab tv --no-note, BINANCE:ETHUSDT.P 15;
tests/fixtures/margin_v6):
- w5-m1-addexit-p100 (100 %, pyramiding 10): every add, placed with an exit
  the next open is already through, is dropped; the exit alone fills;
- w5-m1-addexit-p60 (60 %, the control): 60 % + 60 % exceeds the equity too;
- w5-m1-addclose (100 %, pyramiding 2): an add followed by strategy.close of
  the held id, or by strategy.close_all, never opens.

entry() now drops such an add inside the pyramiding cap
(add_margin_exceeds_equity: the held units plus its own at the signal close's
tick against the placement equity, with the one-lot slack the fill-time add
arm keeps -- test_reversal_admission_float_guard pin E, a sub-lot shortfall
add admitted, still passes). An over-cap all-in add the cap check lets
through stays a request, as before; apply_open_market_admission, which keeps
such a row only where an earlier opposite command of its batch reverses the
book first, now also retires it when that placement judgement failed and the
batch holds this bar's market entries and closes alone (the priced, raw and
carried controls of test_live_position_market_gross_admission keep their
ordinary fills). Judged there, the row keeps its request incarnation, so a
script whose over-cap rows never fill books byte-identical output.

test_declined_reversal_close_leg_l4c R6 (an all-in add followed by a close of
the held id, pyramiding 2) expected the add to re-open from flat after the
close, LONG 100: expectation corrected to TradingView's w5-m1-addclose -- the
close fires and the book is flat.

Fail-before (the MR tree): w5-m1-addexit-p100 and w5-m1-addclose fail, the p60
control passes. After: all three pass.

Population (Cloud Run, against exp-r5-tvdd-measure-20260927):
masayanfx-scalping-london-new-york-strategy on all ten lanes moderate/strong
-> excellent (pyramiding 10: the add behind the same bar's exit),
van007trader-quick-reversal-candles-dyna on four lanes strong -> excellent (a
default over-cap add paired with the reversal before it: TradingView never
reverses back).

Layer: the source-adapter parity runtime (ADR-0001, Decision, layer 2). No
kernel unit changes and no durable state is added.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
(cherry picked from commit 79782e9268bd74e09e374830d73ac10ef519be18)

INT28 pick note: W5-ENG-MARGIN-V6 2
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…d at its high before the script

ab9714b checked a commissioned or slipped short carried under
process_orders_on_close only after the script had run at the close
(on_bar_close), skipped the check once a slice had been taken at the bar's
open, and deferred it behind a close-time market order to the post-fill book.
TradingView calls the carried short at the bar's high before the script runs:
the script reads the called book and equity, and its close fills meet what
the call left.

TradingView, on synthetic probes (lab tv --no-note, BINANCE:ETHUSDT.P 15,
process_orders_on_close, commission 0.05 %, slippage 1;
tests/fixtures/margin_v6):
- w5-m2-pooc-short-comm: a call at the next open and another at the high of
  the same bar;
- w5-c1-seen-size: the 12:00 short called at the 12:30 high (1.5312
  @1802.01); a reversal on that bar by math.abs(strategy.position_size) opens
  53.645, the size after the call;
- w5-m2-pooc-carried-close / -none / -reverse: the same call whatever the
  close does (close_all, nothing, a default reversal sized from the equity
  after it).

The new hook PineExecutionAdapter::on_bar_close_before_script, which
PineStrategyHost::on_native_bar calls ahead of the scheduler's script
callback, takes that check for the commissioned or slipped carried short
(submit_margin_call_slice at the bar's high). A fee-free carried short keeps
the kernel's path check and the checkpoint after the script, with its
deferral, unchanged.

test_adapter_margin_schedule_differential expected, for a carried POOC short
with a fee closed by the script on the bar whose high calls it (M7-C, and the
closing run of E20 f1), no margin call: the check ran after the close had
emptied the book. Expectations corrected to TradingView's
w5-m2-pooc-carried-close: 1.7504761904761923 @105 at the calculation point,
the kernel's own slice, then the close of the 7.7495238095238079 left.

Fail-before (the M1 tree): w5-m2-pooc-short-comm fails. After: it passes.
The carried tapes also need the next open's call of M2 (and
w5-m2-pooc-carried-reverse the long's call of C2); the test replays them from
those commits on.

Layer: the source-adapter parity runtime (ADR-0001, Decision, layer 2); the
host only calls the adapter's hook. No kernel unit changes and no durable
state is added.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
(cherry picked from commit 8577227977b61959d32a4c64f397cf450fcf3224)

INT28 pick note: W5-ENG-MARGIN-V6 3
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ts signal close

A 100 %-of-equity short that process_orders_on_close fills one tick under its
signal close is short of margin by its slipped fill and its entry fee.
TradingView sizes that call at the signal close's mark and executes it at the
next open (re-sized at the open only when the close's units no longer cover
the open's own shortfall), then checks the survivor again at the call's
slipped fill. The adapter sized the opening slice at the open alone and took
no re-check at the fill.

TradingView, on synthetic probes (lab tv --no-note, BINANCE:ETHUSDT.P 15;
tests/fixtures/margin_v6):
- w5-m2-pooc-short-open (commission 0.05 %, slippage 1): fifteen shorts whose
  next open is one tick above, at or below the signal close -- each first
  call sized at the close;
- w5-m2-pooc-short-plain: the fee- and slippage-free control;
- every first opening call of the 258 such shorts in lab tv tape
  officialjackofalltrades-caldera-meridian-strategy-joat follows the close's
  mark; marking at the open alone books 118.

on_bar_open keeps the script bar the opening follows (prior_policy_bar) and
sizes a short filled at that bar's close from its close
(close_margined_units); on_applied re-checks the survivor of such an opening
call at its slipped fill (recheck_at_fill) before the remaining path.

Fail-before (the C1 tree): w5-m2-pooc-short-open, w5-c1-seen-size,
w5-m2-pooc-carried-close and w5-m2-pooc-carried-none fail; the plain control
passes. After: every row passes.

Population (exp-w5-eng-margin-v6-s4-20260928 against
exp-r5-tvdd-measure-20260927): officialjackofalltrades-caldera-meridian-
strategy-joat (ETHUSDT.P 15) strong 99.2 -> 99.8, with C1, QP and C2.

Layer: the source-adapter parity runtime (ADR-0001, Decision, layer 2). No
kernel unit changes and no durable state is added.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
(cherry picked from commit c4f79213d684550d7468922eb007505a9409e6b3)

INT28 pick note: W5-ENG-MARGIN-V6 4
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… took from its entry

TradingView sizes a percent strategy.exit on the quantity its entry filled:
the slices margin calls took from the position are not taken off that basis.
The adapter reserved a percent exit on the position left after the calls.

TradingView, on synthetic probes (lab tv --no-note, BINANCE:ETHUSDT.P 15,
process_orders_on_close, commission 0.05 %, slippage 1;
tests/fixtures/margin_v6):
- w5-qp-pooc-reissue: a 62.3911 short called 0.0028 and 1.6712 before its
  TP1/TP2 (35 % each, re-issued every bar) are placed -- each closes 21.8368,
  35 % of the 62.3911;
- w5-qp-pooc-once: the control, placed once at the entry (the same file).

exit() adds the units closed by margin calls since the position opened
(Trade rows labelled kMarginCallLabel on its side, its FIFO entry for a named
exit) to the book basis of a qty_percent reservation below 100 %.

Fail-before (the M2 tree): w5-qp-pooc-reissue fails, the once control passes.
After: both pass.

Population (exp-w5-eng-margin-v6-s4-20260928 against
exp-r5-tvdd-measure-20260927): officialjackofalltrades-caldera-meridian-
strategy-joat's TP rows (ETHUSDT.P 15), with M2.

Layer: the source-adapter parity runtime (ADR-0001, Decision, layer 2). No
kernel unit changes and no durable state is added (the basis is read off the
host's closed trades).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
(cherry picked from commit 39961733ed662a19a2cca8f1b75f2bcd4df416f8)

INT28 pick note: W5-ENG-MARGIN-V6 5
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…s called at the next open

The close fill that opens, or reverses into, a commissioned
process_orders_on_close position was margin-called at the fill: a reversal's
closing fee leaves the new 100 % side short of margin. TradingView takes no
call there; it calls that book at the next open -- a long for the units the
fill's checkpoint would have taken, a short at the close's mark (M2).

TradingView, on synthetic probes (lab tv --no-note, BINANCE:ETHUSDT.P 15,
process_orders_on_close; tests/fixtures/margin_v6):
- w5-c2-pooc-rev-long (commission 0.05 %, slippage 1) and
  w5-c2-pooc-rev-long-noslip (commission alone): fifteen shorts reversed to
  longs, each long called at the next open, never at the fill;
- w5-c2-pooc-rev-short: fifteen longs reversed to shorts, each called at the
  next open at the close's mark;
- w5-c2-pooc-flat-explicit-long / -short (commission 0.1 %): fifteen
  explicit-quantity positions of strategy.equity / close each, short of
  margin by their entry fee, every one called at the next open;
- w5-c2-pooc-long-open: the control, a 100 % long from flat, never called;
- w5-m2-pooc-carried-reverse: C1's carried short reversed, the long called at
  the next open.

on_applied skips the fill-time opening checkpoint for a commissioned
process_orders_on_close close fill that opens the position
(called_at_next_open); on_bar_open calls such a full-margin long at the open
(submit_margin_call_slice at the open's tick). A short is called there by M2's
opening slice.

test_margin_call_1x_long_entry_fill_l4a F (a POOC long of explicit 99.95 @100
under a 0.1 % fee) expected the 0.1996 trim on the fill bar, and
test_pooc_open_money_event_l4b's fee compatibility scope expected its opening
event at the entry close: both now book it at the next open, as
w5-c2-pooc-flat-explicit-long does.

Fail-before (the QP tree): w5-c2-pooc-rev-long, -rev-long-noslip,
-rev-short, -flat-explicit-long, -flat-explicit-short and
w5-m2-pooc-carried-reverse fail; the long-open control passes. After: every
row passes.

Population (exp-w5-eng-margin-v6-s4-20260928 against
exp-r5-tvdd-measure-20260927): job-2550-spiritedcheeta2101-quanloki-qqe-
system-opposite-signal-only-points (process_orders_on_close, commission
0.05 %, slippage 1) on OANDA:XAUUSD 15 and 1D strong -> excellent, on
OANDA:EURUSD 15 94 fewer trades (3553 against TradingView's 3551), with C1.

Layer: the source-adapter parity runtime (ADR-0001, Decision, layer 2). No
kernel unit changes and no durable state is added.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
(cherry picked from commit 64decc5c57e0e9ae059061e4c3f10cdb7e2d2c08)

INT28 pick note: W5-ENG-MARGIN-V6 6
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…t its print

A 100 % market short filled one tick under the open (slippage 1) was checked
at its slipped fill price, where its fee-short margin is still covered.
TradingView sizes the opening call at the print the fill slipped from and
executes it there with the call's own slippage; the high then calls the
survivor.

TradingView, on synthetic probes (lab tv --no-note, BINANCE:ETHUSDT.P 15,
commission 0.05 %, slippage 1; tests/fixtures/margin_v6):
- w5-qp-mkt-once and w5-qp-mkt-reissue: a short filled at 1611.06 under the
  1611.07 open is called 0.0028 @1611.08 there, then 0.4716 at the high;
- w5-mk-short-rev: fifteen longs reversed to market shorts at the next open,
  each short called at its open print first.

on_applied's fill-time opening checkpoint takes a slipped market short's call
at the print (source_bar_fill_tick of the fill plus the slippage), not at the
fill; every other opening keeps the fill's checkpoint.

Fail-before (the C2 tree): all three rows fail. After: they pass.

Population (exp-w5-eng-margin-v6-s4-20260928 against
exp-r5-tvdd-measure-20260927): job-2634-tetradprotocol-tetrad-elektro-
community-v1-0 (commission 0.05 %, slippage 3) on ETHUSDT.P 15 weak ->
excellent and on OANDA:EURUSD 15 strong -> excellent,
job-2764-zhangwenjian810-mgc-wyckoff-second-breakout-v3-candle-rr (commission
0.02 %, slippage 2) on BINANCE:BTCUSDT 15 strong -> excellent.

Layer: the source-adapter parity runtime (ADR-0001, Decision, layer 2). No
kernel unit changes and no durable state is added.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
(cherry picked from commit 266a28bec5ae383f2805f7219d0d3de85caffc24)

INT28 pick note: W5-ENG-MARGIN-V6 7
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ket, buy stop, sell market, sell stop, buy limit, sell limit

Two strategy.entry calls placed on one bar from flat, both already
marketable, fill at one price, and TradingView fills them in a fixed order
of side and kind -- buy market, buy stop, sell market, sell stop, buy limit,
sell limit -- one rank in placement order. The later of two opposite calls
is one transaction of its own quantity plus the earlier pending MARKET
call's; the earlier call trades only its own. So a marketable buy stop
placed after a sell market fills first as a buy of both quantities, and the
sell then closes part of that lot: TradingView's two rows carrying the buy's
signal, which the grader consolidates into one qty-2 trade (TAIL-TRIAGE
F10-KI65-DUAL-ENTRY).

The engine queued the calls in the order they were placed, apart from the
market pair the same-bar batch already materializes buy first and the
pure-stop pair defer_open_marketable_sells re-sequences at the open, and it
sized a buy stop placed after a sell market as a reversal against it.

- PineExecutionAdapter::order_same_point_entries (src/source/pine_adapter.cpp:19780),
  called after every source evaluation (src/source/pine_strategy_host.cpp:1521):
  within the flat explicit-quantity family same_bar_market_tx_scope() settles
  as one broker batch, the bar's entries that are already marketable at the
  evaluation's price are queued in TradingView's order. Every request from
  the first one out of order on is re-priced in place
  (ReplaceOptions::keep_handle, the kernel's V19-D capability), which keeps
  its handle and ranks it newest; the kernel breaks a tie at one cursor oldest
  request first. A pure-stop book is left to defer_open_marketable_sells.
- entry() (src/source/pine_adapter.cpp:6625): a marketable buy stop that
  follows a pending sell market on its flat bar is one Transact of its own
  quantity plus the market's (pending_opposite_market_units,
  src/source/pine_adapter.cpp:19737), not a reversal sized at its fill.

TradingView (lab tv --no-note, BINANCE:ETHUSDT.P 15, 2025-04-01 .. 2025-05-01;
tests/fixtures/same_point_entries):
- w6-f10a-open-pair: 14 cells (MM/MS/SM/SS/ML/LM/LL/LS/SL x LF/SF, MS-SF-Q),
  twice each; the engine booked MS-SF, SM-SF, LM-SF, LL-SF, LS-SF and MS-SF-Q
  sell first.
- w6-f10b-limit-class: a limit leg declared first or second, and the Q cells;
  the engine booked LM-LF, LS-LF, LM-LF-Q and LM-SF-Q in placement order.
- w6-f10c-same-side-class (pyramiding 2): a market lot fills before a stop or
  limit lot of the same side placed before it. Read off the tape only: the
  scope excludes pyramiding 2, where the engine keeps placement order (README).

tests/test_same_point_entries_tapes.cpp replays f10a and f10b under the
configuration their generated constructors declare, and reads the order and
the buy's quantity off TradingView's rows of every pair tape. Fail-before,
built against 8633d944: "FAIL tests/test_same_point_entries_tapes.cpp:376
got == want" on both rows, "765 passed, 2 failed". After: 767 passed.

test_dual_entry_placement_sizing R2 (MS-SF-A) had pinned the engine's
sell-first decomposition beside TV's net position, noting TradingView's split
differs; it now pins TradingView's: the closed trade is a slice of E2's long,
closed by E1. A frozen twin assertion, so tests/twin_parity_inventory.json
records the observable rewrite with its reason (and the checker its sha).

Layer: the source-adapter parity runtime (ADR-0001, Decision, layer 2); the
kernel is untouched and keep_handle is its generic re-price, no new
capability. No state added: the order lives in the kernel's queue and the
live-handle roster, both already folded.

Population: Cloud Run experiment exp-w6-eng-fill-order-a-20260927 on this lane's
final engine tree, 2,166 probes (the 24 of families F10 and F12, 40 seeded
excellent controls and the static census of every rule's shape), against
exp-r5-tvdd-measure-20260927: pf-probe-ki65-dual-entry-precedence on es1-15,
eurusd-15 and xauusd-15 moderate -> excellent (550, 554 and 550 unmatched
engine trades -> 0); its nq1-15 row needs the next commit too. The 40
controls are byte-identical.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
(cherry picked from commit 443e760598bd2ba2aef7fbc5212e9f55c0320722)

INT28: every code, header, test and fixture hunk applies unchanged (each
file's patch is byte-identical to the lane's). scripts/check_twin_parity.py:
INVENTORY_SHA256 is the merged inventory's own sha256 (W5-ENG-MARGIN-V6's and
this lane's observableRewrites entries both stand); check_twin_parity.py: OK.
tests/twin_parity_inventory.json: W3B-ENG-GRID's rewrite of the same twin
(test_dual_entry_placement_sizing_l4b, its MM_pair_defers row) met this
lane's (its R2 MS-SF-A row) in one entry; the twin carries both hunks, the
entry names both reasons, and its twinAssertionSha256 is the merged twin's
(173 assertions).
tests/CMakeLists.txt: git's clean merge put this lane's fixture if() inside
W5-ENG-MARGIN-V6's block; each block is closed on its own.

INT28 pick note: W6-ENG-FILL-ORDER 1
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ding market's quantity

The later of two opposite strategy.entry calls placed on one flat bar is one
transaction of its own quantity plus the earlier pending MARKET call's, and
TradingView costs that transaction at the signal close: past the equity it
drops the later call, however affordable its own quantity is. The engine's
explicit placement admission (entry(), src/source/pine_adapter.cpp:6019-6071)
priced the later call's own quantity only, so it kept calls TradingView
drops.

The admission now adds pending_opposite_market_units -- the own units of the
opposite market entries still pending on that bar -- for a flat
explicit-quantity call in the same_bar_market_tx_scope() family
(src/source/pine_adapter.cpp:6045-6055).

TradingView (lab tv --no-note, BINANCE:ETHUSDT.P 15, 2025-04-01 .. 2025-05-01;
tests/fixtures/same_point_entries): w6-f10g-pair-gross, one-contract MM-LF /
MM-SF / MS-LF / MS-SF pairs on 3000 of equity, seven passes: the later call
trades in exactly the 10 cells whose own-plus-pending transaction at the
signal close is within the equity (the other 18 book the earlier call alone).
w6-f10h-pair-gross-pyramiding1 is the same tape at pyramiding 1. The KI-65
probe on CME_MINI:NQ1! 15 (two contracts above ~25,000 cost more than its
equity) books the same rule: 145 later calls dropped, each transaction
costing more than the equity at its signal close -- or, for one buy that
fills first, at its fill, which the kernel's opening check already refuses.

Fail-before, the test built against 443e7605 (this lane's R1 tree): "FAIL
tests/test_same_point_entries_tapes.cpp:389 got == want" on both rows, "1549
passed, 2 failed". After: 1491 passed, 0 failed (its tape reading covers the
two new tapes).

test_dual_entry_placement_sizing's scope fence had pinned the NON_P2 mode
(pyramiding 1, a 55% wedge) as ungated: "a leaked gross gate would reject the
second". TradingView gates it (w6-f10h), so the fence now expects the later
call dropped; against 443e7605 it fails ("FAIL ... :674 non_p2.queued == 1 &&
non_p2.metadata_clean"). The observable rewrite's evidence and reason are
updated in tests/twin_parity_inventory.json.

Layer: the source-adapter parity runtime (ADR-0001, Decision, layer 2). No
kernel unit changes; no state added.

Population: Cloud Run experiment exp-w6-eng-fill-order-a-20260927 on this lane's
final engine tree, 2,166 probes (the 24 of families F10 and F12, 40 seeded
excellent controls and the static census of every rule's shape), against
exp-r5-tvdd-measure-20260927: pf-probe-ki65-dual-entry-precedence nq1-15
moderate -> excellent (engine 5091 trades -> TradingView's 4979).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
(cherry picked from commit 04368aa5e197223fcca90bf36293fb28781fd303)

INT28: every code, test and fixture hunk applies unchanged (each file's patch
is byte-identical to the lane's). scripts/check_twin_parity.py:
INVENTORY_SHA256 is the merged inventory's own sha256 (W5-ENG-MARGIN-V6's and
this lane's observableRewrites entries both stand); check_twin_parity.py: OK.
tests/twin_parity_inventory.json: the test_dual_entry_placement_sizing entry
carries this lane's reason and W3B-ENG-GRID's (its MM_pair_defers row), and
the merged twin's twinAssertionSha256 (173 assertions).

INT28 pick note: W6-ENG-FILL-ORDER 2
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… market pair fills first

At a process_orders_on_close close, with or without calc_on_order_fills,
TradingView fills a flat pair of opposite explicit-quantity MARKET entries in
the same order as at an open: the buy first, as one transaction of its own
quantity plus the pending sell's, then the sell of its own quantity. The
tape's two long rows both carry the buy's signal (TAIL-TRIAGE
F10-KI65-DUAL-ENTRY, the COOF+POOC opposite-market probes).

The adapter's close pass for such a pair,
apply_terminal_explicit_market_policy (src/source/pine_adapter.cpp:15986),
re-executes the candidates in source order with every later opposite call a
full ReverseTo, so a sell-then-buy pair booked a zero-length short closed by
the buy. For exactly that pair from flat the pass now executes the buy first
as Transact(own + pending sell), then the sell as Transact(-own)
(src/source/pine_adapter.cpp:16094-16119). The net position is unchanged; a
buy-then-sell pair keeps the source order, event for event.

TradingView (lab tv --no-note, BINANCE:ETHUSDT.P 15, 2025-04-01 .. 2025-05-01;
tests/fixtures/same_point_entries): w6-f10d-pooc-pair and
w6-f10e-pooc-coof-pair are one file; their market cells (MM-LF, MM-SF,
MM-SF-Q) are replayed. Their priced cells and w6-f10f-coof-pair
(calc_on_order_fills alone) are read off the tape only: the adapter's POOC
close pass neither orders a priced leg against the market nor adds the
pending market's quantity there, and outside same_bar_market_tx_scope() the
open pair is not ordered (README).

Fail-before, the test built against 04368aa5 (this lane's R1+R1b tree):
"FAIL tests/test_same_point_entries_tapes.cpp:415 got == want" on both rows,
"2106 passed, 2 failed". After: 2108 passed.

test_pooc_coof_reversal_gross_admission pinned the scratch row's side as the
first call's ("scratch.is_long == first_long", while its header said the side
is only report attribution and not asserted); TradingView's scratch row is
the buy's either way, so it asserts scratch.is_long. Against 04368aa5 it fails
("FAIL ...:160 scratch.is_long", 146 passed, 2 failed). A frozen twin
assertion: tests/twin_parity_inventory.json records the observable rewrite.

Layer: the source-adapter parity runtime (ADR-0001, Decision, layer 2). No
kernel unit changes; no state added.

Population: Cloud Run experiment exp-w6-eng-fill-order-a-20260927 on this lane's
final engine tree, 2,166 probes (the 24 of families F10 and F12, 40 seeded
excellent controls and the static census of every rule's shape), against
exp-r5-tvdd-measure-20260927: pf-probe-coof-pooc-opposite-market-ordering on
es1-15, eurusd-15, nq1-15 and xauusd-15 and
pf-probe-coof-pooc-opposite-market-fran-factors on eurusd-15 and xauusd-15
moderate -> excellent.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
(cherry picked from commit cdbeb0b0e80238617f88cce087c95730ca9bec1b)

INT28: every code, test and fixture hunk applies unchanged (each file's patch
is byte-identical to the lane's). tests/twin_parity_inventory.json: this
lane's test_pooc_coof_reversal_gross_admission entry and W5-ENG-MARGIN-V6's
test_pooc_open_money_event entry met at one place; both stand, in key order.
scripts/check_twin_parity.py: INVENTORY_SHA256 is the merged inventory's own
sha256; check_twin_parity.py: OK.

INT28 pick note: W6-ENG-FILL-ORDER 3
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…n a default reversal is declined

On one bar a held position's protective strategy.exit stop and a reversing
strategy.entry stop on the same side of the price fill in the order the bar's
path reaches them: the reversal at its level first when its level comes first
(and the exit is then void), the exit first otherwise, the magnifier changing
nothing. When both are already through at one opening TradingView fills the
exit first there, whichever was placed first, and the entry then trades its
own frozen quantity from flat (TAIL-TRIAGE F12-INTRABAR-STOP-PRIORITY). The
engine books every one of those cells at a fixed size.

Under the v6 default size a reversal can be declined at that opening, and
defer_declined_reversal_exits_at_adverse (src/source/pine_adapter.cpp:14803)
cancelled every full-position exit stop the bar's adverse extreme reaches, or
re-issued it at that extreme -- a stop the open was already through included.
TradingView fills such a stop at the open. It is no longer deferred
(src/source/pine_adapter.cpp:14887-14893); a stop the open has not reached
keeps the legacy deferral.

TradingView (lab tv --no-note, BINANCE:ETHUSDT.P 15, 2025-04-01 .. 2025-05-01;
tests/fixtures/same_point_entries):
- w6-f12a-stop-priority (fixed 1): A1/A2 (a falling bar, open nearer the high
  / the low), A3 (exit above the entry), A4/A5 (both through, entry / exit
  placed first), A6/A7 (only one through), B1/B2 (short mirrors). The engine
  already booked all of them.
- w6-f12c-stop-priority-magnifier: the same trades with use_bar_magnifier.
- w6-f12b-stop-priority-default (v6 default): in B2 the short, margin-called
  in part on its entry bar, declines its reversal at the open, and the
  protective stop fills there (1477.89); the engine had cancelled it and held
  the short to the cleanup. A4 stays out of the row: after the exit
  TradingView opens the reversal's frozen 2x short and margin-calls it at the
  same price, which the engine's margin model refuses (README).

Fail-before, the test built against cdbeb0b0 (this lane's F10 tree): "FAIL
tests/test_same_point_entries_tapes.cpp:492 got == want" on the w6-f12b row,
"2386 passed, 1 failed"; the fixed-size and magnifier rows pass before and
after. After: 2387 passed.

test_adapter_live_state_equivalence: 4 of its 108 transcript digests move,
re-harvested with PINEFORGE_V19E_HARVEST (the base 8633d944 reproduces every
old value) -- exactly the four "reversals" configurations in which this rule
acts, counted by an instrumented copy of the adapter over the battery;
listed in tests/test_adapter_live_state_equivalence_data.hpp.

Layer: the source-adapter parity runtime (ADR-0001, Decision, layer 2). No
kernel unit changes; no state added.

Population: Cloud Run experiment exp-w6-eng-fill-order-a-20260927 on this lane's
final engine tree, 2,166 probes (the 24 of families F10 and F12, 40 seeded
excellent controls and the static census of every rule's shape), against
exp-r5-tvdd-measure-20260927: no F12 probe's trades move (10 excellent; the 4 strong
ones first diverge at TradingView margin calls, family F09). 27 census
probes change only their 'Engine entry incarnation' column, by -1 per
firing: the stop the rule leaves in place is one request the old deferral
re-issued. Their trades and grades are identical.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
(cherry picked from commit d46096ecabc655f0b64e15368142b8bf1f4952ba)

INT28: the rule, the tape rows and the fixture README apply unchanged (each
file's patch is byte-identical to the lane's). Its re-pin of four
tests/test_adapter_live_state_equivalence_data.hpp digests (harvested on the
lane's tree) is not applied here: INT28 re-harvests every behaviour pin once,
on the integrated tree, and attributes each moved row to its rule.

INT28 pick note: W6-ENG-FILL-ORDER 4
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…r as one transaction, admitted without its commission

TradingView books a flat opposite pair with a commission exactly as W6-ENG-FILL-ORDER's
zero-cost tapes: the same order at one fill point, the later call as one transaction of its
own quantity plus the pending market's, that order's fee split across its rows by quantity
(w6-f10i, w6-f10j, w6b-p1d). The transaction is admitted against the equity at the signal
close with the commission left out: every pair under the equity by less than its fee trades
both legs, every pair just over it drops the later call, with and without a commission
(w6b-p1a/p1b/p1c). A pair whose first fill is the whole transaction is booked with no margin
call although the fee leaves the equity short of that fill: TradingView checks the margin
once both legs have filled.

The pair rules now hold on same_point_pair_scope(), the configurations of the zero-cost batch
scope with a commission; same_bar_market_tx_scope() is that scope with zero cost, so the batch
itself is unchanged. Outside the batch the later market call is one Transact of both
quantities, and the opening margin checkpoint of a pair's first fill waits for the opposite
leg filling at the same price (same_point_pair_fill_follows).

test_same_point_entries_tapes replays the six tapes (4217 passed); against b3132a52 the five
commissioned rows fail at :603 (got == want) and the no-commission control passes.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
(cherry picked from commit 2fc453375636132da3be6db5200885f9a45afa7d)

INT28: every code, header, test and fixture hunk applies unchanged (each
file's patch is byte-identical to the lane's), beside W5-ENG-MARGIN-V6's
margin code in on_applied's opening checkpoint, which git merged without a
conflict. The two are scope-disjoint at that fill:
same_point_pair_scope() excludes process_orders_on_close and slippage,
which W5's C2 and M2, and MK, require; both lanes' tapes pass.

INT28 pick note: W6B-ENG-PAIRS 1
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… and a flat pair books as under 0

At one fill point TradingView fills lots of one side by rank -- market, stop, limit -- under
pyramiding 2 (w6-f10c) and 3 (w6b-p2c: three legs in all six placement orders), and books
both W6 pair tapes under pyramiding 2 byte for byte as under 0 (w6b-p2a, w6b-p2b).

same_point_pair_scope() now covers any pyramiding (the zero-cost batch scope keeps
pyramiding <= 1), so order_same_point_entries ranks same-side lots and the pair rules hold. The
legacy pyramiding-2 route for a book that is not an exact market pair re-sized a pair's market
leg into a full reversal at the fill (SM-LF: the sell reversed the buy stop's long); for the
exact pair book -- one market call beside one priced opposite call of its bar, nothing replaced,
cancelled or resting from an earlier bar -- flush_pending_same_bar_commands keeps the market
leg's frozen transaction, told by its priced opposite caller when that one follows. Every other
pyramiding-2 book keeps the legacy source order and batch-time admission the MM cases of
test_dual_entry_placement_sizing_l4b pin.

test_same_point_entries_tapes adds four rows (5744 passed); against f4148f9d exactly those four
fail at :650 (got == want).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
(cherry picked from commit 63fabaa19ab9b17dbd1f3c43185ee69bff038017)

INT28 pick note: W6B-ENG-PAIRS 2
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…inst the market leg in TradingView's order

At a process_orders_on_close close TradingView fills a flat pair of one market call and one
priced opposite call the close has reached in W6's rank order, the later call one transaction
of its own quantity plus the earlier call's when that one is the market (w6-f10d-pooc-pair and
w6-f10e-pooc-coof-pair: MS-SF buys 2 with the stop first, ML-SF sells the market first and buys
2 with the limit, SM-SF / LM-SF buy the market before the sell stop or limit, LM-LF sells the
market before the buy limit).

The close pass filled the priced leg first (fill_pooc_close_entries) and the market leg after it,
each with its own quantity. fill_pooc_close_pair now fills exactly that pair -- pyramiding 0,
fixed default, explicit quantities, nothing else entry-like on the book -- at the close in rank
order before the rest of the pass; a market pair keeps apply_terminal_explicit_market_policy.

test_same_point_entries_tapes now covers every cell of both tapes (5768 passed); against
07c87619 the two rows fail at :650 (got == want).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
(cherry picked from commit 287a1ffee358f06444485c93152a7627ad363d9d)

INT28 pick note: W6B-ENG-PAIRS 3
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ngView's order as one transaction

With calc_on_order_fills and without process_orders_on_close TradingView books a flat pair placed
once per bar exactly as without it: W6's two open-pair tapes re-exported under
calc_on_order_fills are byte-identical (w6b-p4a, w6b-p4b), and so is the close-pair tape's
next-open counterpart (w6-f10f).

same_point_pair_scope() now covers calc_on_order_fills for calls placed outside a fill
recalculation (the zero-cost batch scope keeps excluding it), so the later market call trades
its own quantity plus the pending market's and order_same_point_entries fills a buy placed after
a sell first. The engine had booked MM-LF, MM-SF, MS-SF, SM-LF, LL-SF and MS-SF-Q in placement
order with own quantities.

test_same_point_entries_tapes adds three rows (6582 passed); against 57c17300 w6-f10f and
w6b-p4a fail at :660 (got == want), and w6b-p4b, which the engine already booked, passes.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
(cherry picked from commit 50152b883d396e3d9d17e4a833cdf24c06e245cc)

INT28 pick note: W6B-ENG-PAIRS 4
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ed bar at or before the calling bar's time

request.security(<tf finer than the chart>, expr, lookahead_on) merges the
requested series at the calling chart bar's time: TradingView reads the
requested bar that opens at or before that instant, the latest such bar.
Where a requested bar opens at the chart bar's time that is the first
intrabar (the round-7 rule, test_ltf_lookahead_first_bucket, BTCUSDT 1D).
OANDA stamps its XAUUSD daily bars at 17:00 ET, inside the 17:00-18:00
break, an hour before the session each bar carries: no requested bar opens
at the stamp, and TradingView reads the previous chart bar's last one.

TradingView, on synthetic read-out probes written for this lane (lab tv
--no-note, 1D, 2025-04-01 .. 2026-05-01; tests/fixtures/ltf_lookahead_calling_open):
- w8c-ltfon-xau1d (OANDA:XAUUSD): "15" lookahead_on merges the 16:45 ET bar
  on 211 bars (-15 min), Friday's 16:45 on the 46+4 Sunday stamps (-2895),
  and the last bar of an early close or long weekend otherwise; gaps_on +
  lookahead_on reads the same bar; lookahead_off the chart bar's last.
  "The latest 15m bar opening at or before the stamp", on the xauusd-15
  lane's own TradingView bars, reproduces all 278 read-outs.
- w8c-ltfon-tfs-xau1d: "60" reads 16:00 ET (-60), "5" 16:55 ET (-5); "240"
  reads 0 on every bar, because TradingView's 4h grid opens at the 17:00 ET
  stamp itself (lookahead_off: 13:00 ET).
- controls w8c-ltfon-eth1d, -eur1d, -aapl1d: a 15m bar opens at the stamp
  (00:00 UTC, 17:00 ET, 09:30 ET), and every bar reads it (0).

- w8c-ltfon-3m-xau1d ("3"): 16:57 ET on 215 bars; on the Black Friday bar it
  reads Thanksgiving's 21:57Z bucket, which holds the 21:59 minute alone and no
  completion rule closes, and on 2025-07-08 the 20:57Z bucket of two minutes: a
  pending last bucket is still the bar at or before the stamp.

The engine's first-bucket latch (calling_open_latches_first) always fed the
slice until its first bucket was published, so on the XAUUSD daily stamp it
read the 18:00 ET bucket: one requested bar late ("15": +60 where TradingView
reads -15; "60": +60 for -60). feed_aux_security_for_chart_bar now closes the
latch before feeding an auxiliary bar whose requested bucket opens after the
calling bar's time, so the chart body reads the previous slice's last bucket
and the slice follows the body. The same closing applies whenever the next
auxiliary bar opens a bucket after the calling bar's time while the latch is
still open, and a bucket no completion rule has closed yet -- the previous
slice's last (the Thanksgiving singleton) or this slice's first, when its last
minute did not print -- is that bar: it is finalized and published first.
lookahead_on already evaluated it on its sub-bars, so its completion rewrites
that slot (sub-bar count at least 2, as a boundary emission does). Before,
such a bucket was emitted only on the next bucket's first bar, whose partial
evaluation then reached the chart body. Heikin-Ashi sites keep the
established path. The host header's comment says the rule in the same two
lines.

Moved pin: tests/test_split_feed_partial_bucket.cpp case (e) asserted that
the lookahead_on "3" twin reads each XAUUSD daily bar's own first bucket; its
header says the tape behind it pinned lookahead_off only. It now asserts
TradingView's reads from w8c-ltfon-3m-xau1d: nothing on the range's first
bar, the 16:57 ET bucket (close 4163.575) on Thanksgiving, the finalized
21:57Z singleton (close 4158.8) on Black Friday. Its lookahead_off cases are
unchanged. The test is an A24 row (scripts/check_twin_parity.py A24_NAMES),
outside the twin-parity freeze.

Fail-before: tests/test_ltf_lookahead_calling_open_tapes.cpp built against
8633d944's library: "44 passed, 10 failed" (4 XAUUSD "15" bars, 4 XAUUSD
"60" bars, the synthetic 1m -> "5" aggregation twice); every control bar
passes. After: "54 passed, 0 failed". test_split_feed_partial_bucket's case
(e) fails on 8633d944 ("dense.on_count == 0") and, without the tail
finalization, on Black Friday ("friday.on_count == 459 + 438"); it passes. Engine read-outs of the same probes on
the xauusd-1d lane feeds (1D chart + the 1m auxiliary slice): 277/278 equal to
the tape for both XAUUSD probes (the one left is the first bar, where no
auxiliary bar precedes the chart), the controls unchanged.

Population, Cloud Run exp-w8c-security-fix2-20260928 (this tree) against
exp-r5-tvdd-measure-20260927, 139 probes: security-rsi-cross-threshold
(xauusd-1d, "15" ta.rsi(close, 14)[1] with lookahead_on) weak 33.3% (engine
4 / TV 6 trades) -> excellent 100% (6 / 6);
3commas-3commas-triple-rsi-dca-long-risk-adjusted-averaging-strategy and
triple-rsi-dca-trace (eurusd-1d, "5" / "15" / "30" ta.rsi(close, 7)[1]
with lookahead_on: on 36 days the first 15m bucket, and on 24 the first 30m
bucket, loses its last minute after the 17:00 ET rollover and stays pending
until the next bucket) strong 83.3% -> excellent 100%. The 14 other W8C targets,
40 seeded random excellent probes of the same lanes and the other 82
population probes with a finer lookahead_on site are byte-identical
(trade-set sha).

Layer: the source-adapter parity runtime (ADR-0001, Decision, layer 2). No
kernel unit changes and no durable state is added (first_bucket_published
already exists and is hashed).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
(cherry picked from commit 1fa82e94d6794a3d8a94bf2cb3e5c7179e517001)

INT28: every code, header, test and fixture hunk applies unchanged (each
file's patch is byte-identical to the lane's). tests/CMakeLists.txt: git's
clean merge put this lane's fixture if() inside W6-ENG-FILL-ORDER's block;
each block is closed on its own.

INT28 pick note: W8C-SECURITY 1
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
luisleo526 and others added 29 commits September 28, 2026 06:44
…ainst the closed position

Under process_orders_on_close, a strategy.close_all() or a whole-position
strategy.close(id) the script issues in the same pass as a strategy.entry
settles first. A same-side entry called after the close is judged against
the position the close flattens: its margin is the resulting position,
(held + own) x close x pointvalue x margin %, and TradingView drops it
when that exceeds the equity. An opposite-side entry is not charged for
the held lots. An admitted entry opens after the close as a fresh
position, so pyramiding=0 does not block it; and a same-side entry the
script called before the close survives it too, when the cap admitted it
at its call.

The adapter charged the entry for its own quantity only (an ordinary POOC
close_all fills at its call, so the affordability gate saw a flat book).
After a strategy.close(id) it dropped entries TradingView fills: under
pyramiding=0 as a same-side add at the call, and in every case when the
queued close flattened the position -- flush_pending_closes cancelled the
pass's same-side market entries whichever call came first (ab9714b kept
that blanket cancellation for flush-time close(id) while preserving
under-cap entries for a POOC close_all).

entry() now charges a same-side entry for the position before the pass's
closes (the script's position view, which the close_all froze when it
filled) without changing the recorded projection, and waives the
pyramiding=0 same-side no-op when the pass's queued closes flatten the
position; flush_pending_closes no longer cancels the pass's entries.

Scraped pf-probe-concord-frangestate (CME_MINI:NQ1! 15, strong) closes
its position with close_all and re-enters on the same side in one pass
on 22 bars: TradingView drops the entry on the 15 bars where (held + qty)
x close x 20 exceeds the equity; the engine re-entered on all 22 (its 15
engine-only trades).

Tapes, tests/fixtures/pooc_same_pass_close (lab tv --no-note,
BINANCE:ETHUSDT.P 15, the corpus 15m bars of 2025-04-01 .. 04-09
embedded):
- w8a-pooc-sameside-closeall: A (close_all + long 50 %), D (close("H") +
  long 50 %) and E (the short mirror) are dropped; B (30 %) and D2
  (close("H") + 30 % under pyramiding=0) fill after the close; C
  (opposite) is not charged; V pins the held lots at the close price.
  The whole year replays 589/589 (lane scratch).
- w8a-pooc-close-reentry-pyr2 (pyramiding=2): close("L") then
  entry("L_add") on even days, the other order on odd days; L_add opens
  at the close and is held to the cleanup on every day.
Pinned by tests/test_pooc_same_pass_close_tape.cpp: 1906 passed, 2
failed on 8633d944; 1926 passed, 0 failed here.

The legacy integration row test_strategy_close_pooc_cancels_same_bar_
market_reentry (close("L") then entry("L_add"), pyramiding=2) pinned the
blanket cancellation; it is the second tape's close-first shape, so it
becomes test_strategy_close_pooc_keeps_same_bar_market_reentry and
expects the held L_add (position 1). Its frozen twin assertion is an
observable rewrite citing the tape (tests/twin_parity_inventory.json,
INVENTORY_SHA256 re-pinned in scripts/check_twin_parity.py; the legacy
base copy is edited alike): check_twin_parity OK, 380 pinned observable
rewrites.

Pine policy, adapter only: no kernel change, no ADR-0001 ruling.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
(cherry picked from commit c19ad463408aabd01510acb8123cab3b8e276e3b)

INT28 (with W3B-ENG-GRID picked before it): tests/twin_parity_inventory.json:
W3B-ENG-GRID's rewrite of the same twin (test_integration_l4d, its
close-reservation rows) met this rule's (its
test_strategy_close_pooc_keeps_same_bar_market_reentry row) in one entry;
the twin carries both hunks, the entry names both reasons, and its
evidence is the merged twin's (569 assertions); check_twin_parity.py: OK.

INT28 pick note: W8A-SIGSTATE-1 3
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…every call

TradingView checks a default-quantity LIMIT strategy.entry that opens from
flat at every call -- its placement and each re-issue -- against the
calling bar's close: a call whose quantity costs more than the equity
there is rejected, and it takes the resting order of that id with it,
however affordable the order's own level is. A call it admitted is not
re-checked on later bars, and the fill-time check still refuses a fill
whose own notional exceeds the equity. The adapter left LIMIT entries out
of its placement check (affordability_scope), so a re-issue TradingView
rejected kept its resting order alive.

entry() now prices a flat pure-LIMIT entry under a default fixed
quantity at the calling close, and drops the call and cancels the
resting same-id request when it is unaffordable, as it already did for a
pure STOP entry. The order's own affordability flags are unchanged.

Scraped algotorma-algo-torma-orb-strategy (BINANCE:BTCUSDT 15, strong)
re-issues its breakout limit every bar while armed; its last re-issue
(2026-01-14 23:45, close 96951.78 over an equity of 96846.71) was
rejected in TradingView, and the engine filled the resting order on
01-15 03:15, its one engine-only trade.

Tape: tests/fixtures/limit_entry_affordability/w8a-btc15-limafford (lab
tv --no-note, BINANCE:BTCUSDT 15, equity 95000, default fixed 1; the
btcusdt-15 lane's bars of 2025-04-25 .. 04-30 embedded). A (re-issued,
last calls unaffordable) never fills; C (placed once affordable, later
closes above the equity) fills; E (level above the equity) never fills;
B is the control. Pinned by tests/test_limit_entry_affordability_tape.cpp:
27 passed, 1 failed on 8633d944; 25 passed, 0 failed here.

Pine policy, adapter only: no kernel change, no ADR-0001 ruling.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
(cherry picked from commit 62bc9cb0bb388b3dcf7e65d1d0559e8028617801)

INT28: every code, test and fixture hunk applies unchanged (each file's patch
is byte-identical to the lane's). src/source/pine_adapter.cpp, entry(): this
rule's block and W5-ENG-MARGIN-V6 M1's placement check were inserted at the
same place; both stand, M1's first. Their scopes are disjoint -- M1 judges a
default percent_of_equity MARKET add to a held position of its side, R3 a
default FIXED LIMIT entry from flat -- so no call reaches both.
tests/CMakeLists.txt: each fixture block is closed on its own.

INT28 pick note: W8A-SIGSTATE-1 4
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…es only its own quantity

A strategy.entry called again with the same id on the same bar replaces the
order its first call placed. When that first order is a MARKET order that
reverses the position, TradingView sizes the reissue against the position
the first order would leave: the reissue is a plain transaction of its own
quantity X against the held side P -- it closes up to X of P and opens only
the excess -- not a reversal. It does so on either side, for every quantity
kind (default percent, fixed and cash defaults, an explicit qty), with and
without process_orders_on_close. On the buy side the held short keeps its
bracket; on the sell side a default-size reissue voids the held long's
bracket. A single call, a LIMIT first call re-issued as MARKET and a
strategy.cancel between the calls keep the full reversal.

Lanes W8A-SIGSTATE-1 (7d668c80) and W8B-SIGSTATE-2 (aa9ee275 + d339b4de)
wrote this rule independently; each failed the other's tapes (W8A's missed
the fixed-default sell that voids the held long's bracket, W8B's the
explicit qty and cash reissues). This is the one rule both tape sets pin:

- entry(): a same-id MARKET reissue of a reversal whose predecessor is still
  staged in the callback's same-bar batch (every fixed default, and a
  variable size over a single-lot short) records the replacement
  (replaced_opening, replacement_predecessor_market), so a default-size
  sell voids the held long's brackets as the live-predecessor path already
  did; its staged transaction carries its own units only, and the batch row
  records the held units it left out (PendingSameBarCommand::staged_reversal,
  staged_reversal_held_units, folded into the source state hash only when
  set) -- W8B's mechanism, widened from percent/fixed defaults to every
  quantity kind the batch admits;
- flush_pending_same_bar_commands(): the round-8 short-seed book (short seed,
  then Long, Short, close(Long), close(Short) on one bar) keeps its full
  reversal -- the flush puts the held units back and clears the replacement
  facts, W8B's d339b4de scope (tests/oracle/test_oracle_short_seed.cpp,
  GateControl::SameIdReplacement);
- resolve_terms(): replacement_transaction covers every MARKET reissue of a
  live MARKET predecessor, on either side and for every quantity kind --
  W8A's mechanism; a priced reissue keeps the old sell default-percent scope.

Layer: the source-adapter parity runtime (ADR-0001, Decision, layer 2); no
kernel unit changes.

Tapes: the fifteen lab tv --no-note exports of both lanes (BINANCE:ETHUSDT.P
15), byte-identical copies, in tests/fixtures/same_bar_reissue, replayed by
one test, tests/test_same_bar_reissue_tapes.cpp. Built against 8633d944's
library: "679 passed, 10 failed" (5 of 15 tapes: the four single-call
controls and w8b-flip-double-sell); on this commit: "689 passed, 0 failed"
(15 of 15).

test_replaced_percent_short_market and its oracle twin pinned an explicit-qty
reissue as a full reversal to SHORT 2 with no tape behind it; the row now
expects TradingView's 3 - 2 = 1 LONG (tapes w8a-dbl-p10 cell C, w8a-dbl-scope3
cells G and H; same CHECK count), and tests/oracle.sha256 re-pins that file's
digest and the tree digest.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
(cherry picked from commit 93c840f58b5232f56d8ce969a4b750c1885a1292)

INT28 pick note: R1-CONSOLIDATE 1
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…e the buy LIMIT entries it reached

At one opening price TradingView fills every MARKET order first, entries
and exits alike (a strategy.close_all queued at the previous close among
them), then the buy LIMIT entries the open has already reached, lowest limit
first -- whether a limit was placed at the previous close or has rested
since an earlier bar; neither the order they were placed in nor their ids
decide. A limit filled that way keeps the quantity it was placed with. The
native matcher breaks a same-point tie by queue order, so the engine filled
them in placement order: a limit resting beside a close opened and was
closed by it at once, and limits placed in descending order filled in that
order.

This is lane W8A-SIGSTATE-1's pinned patch R-A. Measured on a scratch tree
that also carries W6 (b3132a52), W6B (25ed4413) and W8A's R-B (6c5de611,
which R-A's patch was written on): without R-A the engine books w8a-dca-open
E1 as B, A, C (TradingView: B, C, A), closes E2a's L1 with the close_all at
once (TradingView holds it) and fills E4b's HL before HM; W6's same-rank
tie-break is placement order and W6B's rules leave these books alone. With
it, W6/W6B's tape test passes 6582/0 and W8A's full w8a-dca-open test 140/0.

on_bar_open() now re-prices every live pure-limit buy entry the open has
reached in place (order_open_marketable_limit_entries, over the kernel's
existing ReplaceOptions::keep_handle), lowest limit first, whenever a MARKET
request stands behind one of them or they are not already in ascending limit
order; a re-priced entry books the opening print (forced_execution_price).
Not under process_orders_on_close, calc_on_order_fills, streams or a fill
recalculation; sell limits and stop entries keep the queue order (no tape
covers them). A flat book holding MARKET entries of both sides is left to
the opposite-pair route (lanes W6/W6B): TradingView fills that pair before
the limit too but also books the pair's later call as one transaction
admitted at its gross (tape r1c-ra-prior-limit cells M and N), which is not
this rule; the frozen legacy pin of that shape
(test_dual_entry_placement_sizing's MM prior-bar gapped limit) keeps its
route.

Tapes (tests/fixtures/open_fill_order): w8a-dca-open (a byte-identical copy
of W8A's pyramiding_open_order tape) and r1c-ra-prior-limit, a new lab tv
--no-note export (NYSE:F 1D, 2024-12-01 .. 2025-08-01): buy limits resting
since d0 inside the gap between d1's low and d2's open, market orders placed
at d1's close. tests/test_open_fill_order_tapes.cpp replays cells E1, E2a,
E2b and E, X, O trade for trade. Built against cd634e62's library: "213
passed, 5 failed" (E2b, the control, passes); on this commit "218 passed, 0
failed". The R-B cells (E3, E4a, E4b) and the pair cells (M, N, P) are read
off TradingView's rows only.

Pine policy in the adapter over the kernel's existing keep_handle re-price:
no kernel change, no ADR-0001 ruling.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
(cherry picked from commit 2239825045e2326b5b27ccf5ce3b53a4178650f1)

INT28 pick note: R1-CONSOLIDATE 2
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
ADR-0001's rows for ReplaceOptions::keep_handle (R5 lane V19-D's replace
row, and K-OCA-KEEP's group-effect receipt order) said the Pine adapter
never sets keep_handle. R-A's opening-price order re-prices the buy limits
an opening price reached with it (order_open_marketable_limit_entries), so
the V19-D row now names that use, the K-OCA-KEEP row says the adapter
reaches the group-effect order only when such a limit is a group member,
and K-OCA-KEEP's own "corpus parity unchanged by construction" reads "the
Pine adapter then never setting keep_handle". Wording only; no anchor on
these cells.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
(cherry picked from commit 5ce0dd28e2aeb0cb33781a464d288d7813e6d679)

INT28 pick note: R1-CONSOLIDATE 3
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…es from it

TradingView's deep backtest (ws report channel) computes the script from the
first chart bar at or after the requested range start and from no earlier
bar -- metrics.json records it as wsProvenance.returnedRange.from -- and its
broker is live from there: an order placed on any bar before the tape's
first fill can make that fill. run_strategy.py gated every tape-graded run
at the bar before TradingView's first entry, so such an order was never
placed (jaysharma x2: a supertrend stop placed before 08:00 UTC fills at
08:15; ki62 eurusd-15/xauusd-15: phase A's stop, armed once).

Pinned by 13 lab tv --no-note tapes of synthetic probes
(tests/fixtures/run_harness_window): bar_index 0 is the returned range
start on ETHUSDT.P / EURUSD / XAUUSD / ES1! 15 (00:00 UTC), NYSE:F 15
(13:30), NSE:NIFTY 15 (03:45), BTCUSDT 1D (00:00), XAUUSD 1D (21:00); a
stop, a limit and two market entries placed on 2025-03-31 bars never
trade; a stop placed at 01:00 UTC makes the 06:30 first fill.

The rule (_tv_first_bar, _tv_entry_emit_window, main): a run whose loaded
feed starts on TradingView's first bar opens its window there; unless it
enters before the bar the tape reports from (TradingView's first entry
less one bar) -- TradingView filled nothing before its first entry, so its
state is not TradingView's -- when it runs again from the signal bar
(_entered_before_tv); a re-run whose signal-bar gate would still admit the
feed's first bar (the engine admits one bar before a gate) would repeat the
run and is skipped. A warmed, padded or later-starting feed keeps the
signal-bar start. Reported rows are unchanged.

Measured on Cloud Run over the whole population f30f1ab8 (7994 probes,
codegen d7e095f): 141 trade sets move, 10 up (jaysharma x2 on data,
NIFTY-15 and EURUSD-1D; ki62 eurusd-15, xauusd-15, btcusdt-15; job-2738),
0 down, 0 probes with any worse canonical metric
(exp-run-harness-win-nf-20260928 vs exp-run-harness-before-20260928).
Without the entered-before fallback the same rule drops one probe
(exp-run-harness-win-b); opening the gate on every run holding TV's first
bar drops nine (exp-run-harness-win-a).

tests/test_run_harness_window_tapes.cpp replays the ETH tapes through the
Pine adapter; scripts/test_run_strategy_emit_window.py pins the harness
decision and reads the rule off every tape (fails on the base: 1 failure,
7 errors).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

(cherry picked from commit b0976fa7117c8179ed8a13eec7df0b73cdc94df1)

INT28 pick note: RUN-HARNESS 1
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…magnified

TradingView backtests a script that declares strategy(..., use_bar_magnifier
= true) on its bar magnifier: its tape of mi-fx-eth-15 and of the same
script declared off (w9mag-fx-eth-15-off, lane CG-W9-MISC, copied here)
enter alike and part on 7 of the 23 replayed exits. Codegen e8f6648
(cg/w9-misc) makes a declaring library export
int strategy_declares_bar_magnifier(void); this is the host half of
CG-W9-MISC's proposal.

- run_strategy.py reads the export (Strategy.declares_bar_magnifier). On an
  intraday chart coarser than 1m, with the case runner's
  PINEFORGE_RUN_MAGNIFIER_FEED (held to _SHA256 when set) and
  runtime_overrides.bar_magnifier not false, the engine's input becomes
  that 1m feed with input_tf=1, script_tf=<chart>, the magnifier on, read
  over exactly the chart feed's loaded bars (from the first chart bar's
  open to the last minute of the last one, so the range-end bar is whole
  and an earlier 1m start warms nothing the chart run does not);
  TradingView's window is still walked on the chart feed, and the trace
  JSON names the feed the engine read. Daily, weekly
  and monthly charts log `declared-not-run` (TradingView keeps its own
  daily bars as chart bars; no engine input yet pairs them with a 1m
  intrabar source), as do a run with an auxiliary request.security feed
  and a missing feed. --runner docker never reads the export and says so
  when the environment names a magnifier feed.
- pineforge.h declares the export in the codegen-emitted group;
  check_c_abi_runtime.py: 67 public declarations (was 66), 58 runtime
  implementations; README and the ABI pages count it. Two count sentences
  are rewritten, not dropped: docs/coverage.md's "Every compiled PineForge
  strategy `.so` exports that public set." (e7cdf05) now names the one
  export only a declaring script has, and docs/pages/index.md's
  "`<pineforge/pineforge.h>` -- **66**: 58 runtime implementations plus
  eight per-strategy generated exports." (3cb0a18, INT23) counts 67 and
  nine.
- tests: scripts/test_run_strategy_magnifier.py (fails on the base at
  import); test_adapter_magnifier_intrabar_tapes section 4 replays the
  twin on the 15m chart bars (23 of 23 exits the twin's).

Measured on Cloud Run with codegen e8f6648 and a measurement-only copy
that also reads the verifier's PINEFORGE_VERIFY_FEED_1M (the file the
runner will name; the deployed runner does not set the new variable yet):
bystry1991 btcusdt-15 strong->excellent, es1-15 weak->moderate,
xauusd-15 moderate->strong, eth-scraped-15 (hard) moderate->strong; the
five corpus magnifier probes stay excellent (price-exact 99.5->100); the
daily lanes are unchanged; 18 controls byte-identical; 0 down
(exp-run-harness-mag-item2-20260928 vs exp-run-harness-mag-base-20260928).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>


(cherry picked from commit 2c397248fbb9d107bc3a75c4f9e12677db1d1de5)

INT28: main 962960b already carries lane XSYM-D's four runtime setters (62
runtime implementations, 70 public declarations of pineforge.h, 113 exports
with the native host's 43); this lane adds the ninth generated export, so the
integrated counts are 71 declarations (62 runtime implementations plus nine
generated exports) and 114 with the magnifier export.
scripts/check_c_abi_runtime.py (EXPECTED_PUBLIC_DECLARATIONS 71,
EXPECTED_RUNTIME_IMPLEMENTATIONS 62), scripts/test_ci_verify.py (both counts,
XSYM-D's setter checks and this lane's generated-export assertions),
README.md, docs/coverage.md, docs/pages/abi-stability.md and
docs/pages/index.md carry both lanes' text with those counts;
check_c_abi_runtime.py: exit 0.
scripts/test_run_strategy_requests.py (lane XSYM-D, on main): its
_FakeStrategy gains declares_bar_magnifier = False, as this lane gave the
fakes of its own base, since run_strategy.main() now reads the flag (15 of
15 pass).

INT28 pick note: RUN-HARNESS 2
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ty step

TradingView reports syminfo.mincontract equal to the symbol's quantity step
on every campaign lane: 18 lab tv --no-note read-outs of one synthetic
script (lane W2-CG-LOWERING-TRIO, finding F06; tests/fixtures/
syminfo_mincontract) -- BINANCE:ETHUSDT.P 0.0001, BINANCE:BTCUSDT 0.00001,
OANDA:EURUSD / XAUUSD 0.01, NASDAQ:AAPL, NYSE:F, NSE:NIFTY, CME_MINI:ES1!,
NQ1! 1, on 15 and 1D. Codegen with F06 reads it through
get_syminfo_metadata("mincontract").

inputs_run_kwargs declares syminfo_metadata["mincontract"] from the lane
template's step, PINEFORGE_VERIFY_QTY_STEP in the environment the case
runner builds for every case (lane_input_templates.environment), when it is
a positive finite number -- a probe that declares its own keeps it.
--runner docker passes no syminfo_metadata (a documented gap) and now says
so. Only a declared step counts: the two ETH
15m templates declare none, and the Lab's 0.0001 there is its own default,
which its provenance records as not lane evidence; with it, the hard probe
data/blitz-locked-macd-pullback-sniper-trend-adx-filtered-strategy drops
strong->moderate (exp-run-harness-mc-item3-20260928), so the rule is
narrowed to templates that name their step.

Measured on Cloud Run on the 12 blitz probes (the population's only
mincontract readers, census over 1384 sources) and 12 excellent controls,
codegen d7e095f + W2's F06 lowering: btcusdt-1d, btcusdt-15, ethusdtp-1d,
xauusd-1d minimal->excellent, xauusd-15 strong->excellent, 0 down,
controls byte-identical (exp-run-harness-mc-item3b-20260928 vs
exp-run-harness-mc-base-20260928). With codegen d7e095f alone
(mincontract lowered to na) nothing moves.

scripts/test_run_strategy_mincontract.py reads every read-out (fails on the
base at import).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

(cherry picked from commit 966df9b50eb695761de4301d087682941eb4c19c)

INT28 pick note: RUN-HARNESS 3
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… composition

Git merged every wave-J lane into src/source/pine_adapter.cpp without a
textual conflict, but several lanes changed the same functions:

- on_applied: TVDEF-DROPS R3, W3-ENG-EXIT-ALLOC rules B and C,
  W5-ENG-MARGIN-V6 M2, C2 and MK, W8E-EXITS C1;
- the exit-reservation functions (W3 rule A) beside W5's MR and W8E C1;
- entry: W5 M1, W6-ENG-FILL-ORDER F10 (1 and 2) and W8D-NOTRADES. Their
  scopes exclude one another -- M1 needs a percent_of_equity default and a
  held position of the add's side outside process_orders_on_close and
  calc_on_order_fills; F10 needs a flat book inside
  same_bar_market_tx_scope(), which admits a percent default only beside a
  held short seed and never calc_on_order_fills; W8D needs a
  calc_on_order_fills recalculation -- so no script reaches two of them.
- defer_declined_reversal_exits_at_adverse: TVDEF-DROPS R2 and W6 F12, which
  W6 already built on.
- on_bar_open: R1-CONSOLIDATE's R-A (the buy limits an opening price reached
  fill after the market orders, lowest first) and the entries W8A-SIGSTATE-1's
  R-B admits (a pending limit does not count against pyramiding).

test_int28_rule_compositions replays four TradingView tapes through the Pine
host and requires every trade each tape closes to be the engine's -- three
synthetic probes written for INT28 (lab tv --no-note, BINANCE:ETHUSDT.P 15,
2025-04-01 .. 04-17; tests/fixtures/int28_compositions) and lane
R1-CONSOLIDATE's w8a-dca-open (tests/fixtures/open_fill_order, same chart,
same corpus bars). An instrumented copy of the adapter (scratch only) names
the rules acting in each run:

- int28-c1-two-parent-reversal-v6 (40 trades): W3's r1 cells every day at
  v6's defaults -- W3 rule C 9 times (a reversal voids the long's global
  exit) and W5 MR 24 times (a declined reversal leaves it the held long's);
- int28-c2-pooc-global-pair-opening (8 trades): W3 rule B and W5 C2 at each
  of the eight commissioned process_orders_on_close openings, at the same
  fill;
- int28-c3-exit-queue-explicit-pair-add (2 trades), a control: the KI-62
  cover stands behind a queued explicit exit pair;
- w8a-dca-open (18 trades), c4: R-B admits E3's P3 and E4b's HM and R-A
  fills E1's limits B, C, A, E2a's close_all before L1 and E4b's HM before
  HL; in E4b both act on one fill point. R-A's own test reads the R-B cells
  off TradingView's rows only (its tree has no R-B) and W8A's compares them
  in any order, so c4 pins the composed order, with every entry id.

Fail-before, each built against the tree's own library and headers: on main
962960b and at the TVDEF-DROPS boundary c1, c2 and c4 fail ("25 passed, 4
failed"); at W3's last pick and at W8A's c4 alone fails ("27 passed, 2
failed": B, A, C in E1, L1 closed at once in E2a, HL before HM in E4b); from
R-A's pick on "29 passed, 0 failed". W5's rules act in c1 and c2 without
moving a trade TradingView books.

R1-CONSOLIDATE's R1 (entry()'s same-bar batch, flush_pending_same_bar_commands()
and resolve_terms()) acts beside W4 DORM, W4 F08 and W5 M2 on its own tapes
(tests/fixtures/same_bar_reissue, all green on this tree); it only reverses a
held position, while W6 F10's and W6B's pair rules, which share the batch's
scope, act from flat. R-A leaves a flat book holding MARKET entries of both
sides to the pair route, so on r1c-ra-prior-limit W6B's checkpoint acts in the
pair cells and R-A in the others.

W3B-ENG-GRID, picked right after W3, meets W4 F19a (resolve_terms() and
fill_pooc_close_exits(): the fill-time size of a partial from_entry "" exit)
and W5 MR (follows_same_bar_declined_reversal() and
suspend_brackets_for_reversal(): a from_entry "" exit under a declined
reversal). Both are composed in those picks (their INT28 notes say how) and
pinned by W3B's own tapes w3bf05-g8 and w3bf05-r1c in
tests/test_exit_queue_tapes.cpp, which fail on the uncomposed merge ("1022
passed, 2 failed") and pass composed ("1021 passed, 0 failed", W3B's own
count); the header and the fixture README carry the reasoning.

Not a composition, and not fixed here: a first version of c3 (AX2 a full
exit created after an explicit qty=1 AX1 on the entry's bar) is booked by
main and fails from W3 rule A's pick on -- rule A ranks exits by the kernel's
acceptance order, and a full exit of a pending entry is accepted before an
explicit-quantity one created before it. INT28's report carries the tape.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
W4-ENG-POOC-SAMEPASS rewrote the frozen legacy twins
test_pooc_global_full_exit_l4c (F19a) and test_calc_on_order_fills_l4c
(F19c) to TradingView's rows and recorded both in the twin-parity inventory,
leaving the uncompiled base copies as they were. W5-ENG-MARGIN-V6,
W6-ENG-FILL-ORDER and W8A-SIGSTATE-1 applied their observable rewrites to
both copies; INT28 does the same for W4's, byte for byte (the twins' hunks
apply unchanged to the base files), so every rewritten row reads the same in
the pair. The checker reads the pinned base manifest, not these files:
check_twin_parity.py: OK, unchanged.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… the integrated tree and attributed

Nine pinned tables move on the integrated tree (main 962960b and the 50
wave-J picks). Each lane's own re-pin (TVDEF-DROPS 62d53f04, W3 16f1e370,
W3B-ENG-GRID 7488d33e, W5 7c2753a5, W6's digests in d46096ec, W8D 7ed4ca0c,
W8E's in bf4a0ba2, W4 9eac1f56, W8A d238a9d6, R1-CONSOLIDATE cd634e62 and
6b9a7ae8) was harvested on its own tree and is not applied; each table is
re-harvested here once, with its TU's own switch, and the same harvest against
main 962960b reproduces every old row of all nine (and of
test_adapter_brackets_relower's R4 section, which does not move). The command
allocations, calendar and host-view-memo witnesses do not move.

W3B-ENG-GRID's void rule took the only quiet-bar run that reached the
ThrottledReopens gate live, so test_adapter_quiet_bar_probe ("every gate taken
both ways") needs the ThrottledStopEntry fixture that lane added to the battery
in its re-pin; it is carried here, four new runs of the pinned table.

Attribution: a harvest at every pick boundary (the 46 through
R1-CONSOLIDATE R-A; 5ce0dd28 is ADR text only, and RUN-HARNESS's three picks
change scripts, tests, docs and one pineforge.h declaration: a harvest at the
last of them equals R-A's, table for table) marks each moved row with the
pick(s) at which it changed, and an
instrumented copy of the adapter (scratch only: a RULE marker wherever a picked
rule decides differently from the code it replaced, folds new state, or, for
the two compositions INT28 made in W5 MR's and W4 F19a's picks, takes the
composed branch) shows the rule of each such pick firing in that run on the
final tree. Where it does not, the pick is marked superseded by a named later
pick, and the census at the boundary before that pick shows the rule firing in
the run and the census after it does not: W3 rule A in 20 live-state digests,
TVDEF-DROPS R3 in two (bracket seeds 1675665 and 2199310) and W3B's ledger
booking in two quiet-bar runs (Random36 magnified, recording off and on) are superseded by W3B's
void rule; W8D in chains seed 314189 by W8A R-B; W3B's ledger booking in
Storm12 (magnifier off and on) by R1-CONSOLIDATE R1.

- test_adapter_quiet_bar (PINEFORGE_QUIET_BAR_HARVEST): 216 of 272 runs move
  and 4 are new -- W3B void exit 188, W3B F02 ledger booking 138, W3B F02
  first id 135, W4 F08 52, W8A R4 44, R1-CONSOLIDATE R1 26, W5 C1 21, W8A R-B
  20, W3B g1 12, W4 F19a 10, W4 F19c 10, TVDEF-DROPS R2 8, TVDEF-DROPS R1 4,
  W3 rule C 4, W5 M1 4, W5 C2 4, W8E C1 4, W4 F14 4, W8A R2 4, W5 M2 2; 174
  move at two picks or more. Its own margin-call floor goes 24 -> 10: the
  battery books 62 margin-call rows on main and after W3B, 54 after W5, 46
  after W4's F08 to BRK and 10 from W4 F14 on (the entry-bar calls on the
  slipped percent shorts TradingView never opens).
- test_publication_witness (PINEFORGE_D2D_PUBLICATION_HARVEST): 142 of 156
  runs -- W3B void exit 112, W3B ledger booking 105, W3B first id 95, W4 F08
  30, W3B g1 18, W5 C1 12, W8A R-B 8, R1-CONSOLIDATE R1 8, TVDEF-DROPS R1 6,
  W4 F19c 4, W5 MK 2, W8E C1 2, W4 MCSIZE 2, W8A R3 2, R1-CONSOLIDATE R-A 2,
  W8D 1; 105 move at two picks or more.
- test_adapter_live_state_equivalence (PINEFORGE_V19E_HARVEST): 108 of 108
  digests -- W3B void exit 108, W3 rule A 30, W8A R-B 26, W4 F08 21, W8A R3 11,
  W8E C1 5, R1-CONSOLIDATE R-A 5, W8D 4, W4 F19c 4, R1-CONSOLIDATE R1 4,
  TVDEF-DROPS R3 3, W5 C1 3, W4 F19a 1, W4 DORM 1; 71 move at two picks or more.
- test_adapter_lookup_index_witness (PINEFORGE_P7_HARVEST): kFlip, kBrackets
  and kMargin -- W3B ledger booking 3, void exit 2, first id 1, W8E C1 1.
- test_adapter_recording_hash_witness (PINEFORGE_F9_HARVEST): Submit (W3B first
  id and ledger booking) and Oca (W8A R-B); no trade moves.
- test_adapter_receipts_in_place (PINEFORGE_P4_HARVEST): Revive, Groups and
  StopLimit (the last two magnifier off and on) -- W3B ledger booking 5, first
  id 2, W8A R-B 2, R1-CONSOLIDATE R-A 2 (three of Groups' trades).
- test_adapter_report_relower (PINEFORGE_R1_HARVEST): 16 hashes of the three
  scenarios, W3B first id; no trade moves.
- test_adapter_continuation_view (PINEFORGE_P1_HARVEST): 196 reads over nine
  tables, W3B void exit.
- test_adapter_brackets_relower (PINEFORGE_R4D_HARVEST): rel-exit-before-entry's
  book digest, and by hand its leg counts {4,4,0} -> {0,0,0} (the test prints
  them), W3B void exit; its rows and equity do not move.

Each table's note lists every moved row, value or declaration with its picks.
Unmoved runs where a marker fires are the rules' no-effect cases (a margin
check with no shortfall, a close call whose ledger booking matches the old
reservation, a close pass with nothing to fill).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Counted with ctest -N per ci_verify profile, each build dir configured with
ci_verify's own argv (configure only, no compiler launcher), on main 962960b
and on the integrated tree:

  profile     main  INT28  floor
  release      724    748  RELEASE_MIN_TESTS 748 (no release row skips)
  kernel       294    296  KERNEL_MIN_TESTS 295 (the WebSocket row skips on a
                           system libcurl)
  debug        705    729  EXCLUDED_REGISTERED_MIN 729
  sanitizers   705    729  EXCLUDED_REGISTERED_MIN 729
  native       714    738  EXCLUDED_REGISTERED_MIN 738

The same twenty-four rows join every profile but kernel, and none leaves:
TVDEF-DROPS 1, W3-ENG-EXIT-ALLOC 1 (W3B-ENG-GRID adds to that row),
W3B-ENG-GRID 1, W5-ENG-MARGIN-V6 1, W6-ENG-FILL-ORDER 1 (W6B-ENG-PAIRS adds to
that row), W8C-SECURITY 1, W8D-NOTRADES 1, W8E-EXITS 1, W4-ENG-POOC-SAMEPASS
6, W8A-SIGSTATE-1 4, R1-CONSOLIDATE 2, RUN-HARNESS 3 and INT28's composition
row; two of RUN-HARNESS's (test_run_strategy_magnifier,
test_run_strategy_mincontract) are source-free and join kernel too. The lanes'
own floor hunks, counted on their own trees, are not applied. The self-test's
pinned table and docs/ci.md follow (scripts/test_ci_verify.py: 145 tests OK).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Every anchor resolved on main 962960b (1725 of 1725). The picks changed no
cited page but W8A-SIGSTATE-1 R-B's rows (design row MG3, the ADR-0001
max_open_lots row, the pine-to-native and contributor rows; merged at their
pick with the integrated tree's digits), R1-CONSOLIDATE's two ADR-0001
keep_handle rows (no line anchors), RUN-HARNESS's ABI counts and runner notes
(README.md, docs/coverage.md, docs/pages/abi-stability.md, docs/pages/index.md,
the runtime cheatsheet; no line anchor moves with them) and docs/ci.md's floor
paragraph (same line count). Each anchor into a file the picks changed is carried through an exact
difflib line map from its origin's copy of the cited file to the integrated
tree's (int24_exact_reanchor.py --origin 962960b --origin 5f1afd58 --origin
89fcbcd7 --exclusive-first; the second origin, R-B's pick before W3B-ENG-GRID
joined the stack, decides only R-B's rows, and RUN-HARNESS's re-anchored tip
decides none): 303 moved, 1410 kept, 12 stuck, set by hand from the same line
map:
- the KERNEL_MIN_TESTS and RELEASE_MIN_TESTS citations (CONTRIBUTING.md:155
  and :156, contributing-llm.md:120, :121 and :267), whose lines the floor
  commit rewrote: ci_verify.py:293 -> ci_verify.py:301 and ci_verify.py:463 ->
  ci_verify.py:500;
- max_open_lots (ADR-0001:708 and design MG3): 2199-2201 -> 2267-2269;
- design MG3 accepted_in_cycle 6220-6269 -> 6387-6440 (R-B rewrote a line
  inside) and fifo_named_entry 8981-8987 -> 9390-9417 (W5 QP's basis lines);
- design TR5 trail_one_shot 9798-9927 -> 10258-10347: the span ran 38 lines
  into the process_orders_on_close exit block W4 F08 deleted, and now ends
  where the retained code ends;
- design SZ11 enqueue_pooc_fifo_close 7242-7592 -> 7588-7827: the span began
  in the close-reservation helper W3B-ENG-GRID retired; it now starts at
  enqueue_pooc_fifo_close and ends at the old end's image in
  flush_pending_closes.
Digit changes only.

check_doc_anchors: 1725 1725 0, "every documentation anchor resolves to its
symbol". Carry check against the origins: 1689 cite the same text, 36 cite
regions a pick rewrote (W3B-ENG-GRID's close ledger and void exit among them);
stale carries 0. check_doc_lint: clean.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…gs to that reversal

At Pine v6's defaults a default-size reversal entry is declined at the next
open when its units at that open cost more than the equity they were sized
from (declined_reversal_at_open). A strategy.close_all() placed on the same
bar after that reversal entry belongs to it, as a strategy.close() of the
held id already does (opposite_reversal_pair / the paired close): TradingView
flattens the held position through neither. Where the open funds the
reversal it closes the position and opens the other side, and the close_all
does not flatten that side; where the open declines it the position is held
and the close_all does not fill either. The lowering placed the close_all as
a Flatten request of its own, which flattened the held position at a
declined open.

src/source/pine_adapter.cpp, close(), the empty-id (close_all) branch: the
close_all is kept as a source observation (shadowed, as the empty-id entry
pair's close_all already is) when an opening default-size entry of the
other side was placed on the same script bar, under a percent_of_equity
default of 100 or more, outside process_orders_on_close and
calc_on_order_fills, on a fractional (or absent) lot grid.

Pinned by five lab tv --no-note tapes of synthetic probes on
BINANCE:ETHUSDT.P 15, 2025-04-01 .. 2025-04-17 (tests/fixtures/
reversal_close_all), twelve cells each, eight of them declined at 100 %:
int28fix-ca2-rev (reversal entry, close_all) and int28fix-ca2-frosty
(job-2614's order: long entry, short entry, close of the held id,
close_all) give TradingView's one tape, the same as the control
int28fix-ca2-close-id (the pair the adapter already holds); the controls
int28fix-ca2-first (close_all first: it flattens at the open) and
int28fix-ca2-p99 (99 %: nothing is declined) bound the rule.
tests/test_reversal_close_all_tapes.cpp replays them: 25 passed, 4 failed
on 4efcb8c (both rule rows), 29 passed, 0 failed with the rule.

tests/test_declined_reversal_close_leg_l4c.cpp R5 froze the close_all firing
beside a declined all-in reversal (a characterization row, with no tape); it
now holds the long, as these tapes do. The twin inventory records the
observable rewrite, and INVENTORY_SHA256 is re-pinned.

Hard-lane target job-2614-andrewwieiw-frosty-alerts on BINANCE:ETHUSDT.P 15
(TV-DEFAULTS codegen b33c9dc, lane replica of the lab verifier): its first
divergence from TradingView on INT28 is the 2025-04-04 00:00 New York bar,
whose end-of-evening strategy.close_all() follows the script's reversal
entries; the 04:15 UTC open declines the reversal and the engine flattened
the short. With the rule the run books TradingView's 40207 trades:
weak 84.4 % / countAbsDelta 651 / pnl p90 144.8457 -> excellent 100 % / 0 /
0 (baseline weak 80.7 % / 3867 / 123.2267).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…nd their book is called once

At Pine v6's defaults a script that places several same-side entries on one bar
while flat -- each within the equity alone, together over it -- lost every entry
after the first: validate_precommit judged each later fill on the book the
earlier ones had just opened and refused it, and nothing was margin-called.

TradingView, on synthetic probes (lab tv --no-note, BINANCE:ETHUSDT.P 15;
tests/fixtures/margin_residual):
- w5b-sb-market-60x2 (two explicit 60 % entries per cell, pyramiding 2): both
  fill at the next open and the 120 % book is called there, 4 x the lot-floored
  shortfall, FIFO (all of A, part of B);
- w5b-sb-pooc-60x2: under process_orders_on_close both fill at the close and
  the book is called at the next open, sized at that close;
- w5b-sb-default-x3 / -pooc-default-x3 (three default 100 % entries,
  pyramiding 3): all three fill and are called whole; where the next open gaps
  over the signal close all three are refused, as the first always was;
- w5b-sb-market-40x2 (the control): an 80 % book fills with no call.
The CG-LINUX-RED env_facts export of 2026-09-26 is the same shape.

validate_precommit now admits a MARKET entry placed while flat that meets, at
the point it fills, a book only its own bar's earlier flat market entries
opened (flat_sibling_book) on its own cost against the equity it was sized
from, the pyramiding cap still applied. A flat bar's priced entries keep their
route: two flat-armed stops that fire on one bar pyramid past the cap
(test_integration's probe-80 row). The opening checkpoint in on_applied waits for
the last such sibling (flat_sibling_fill_follows) and then calls the combined
book, a zero-fee all-in book included; under process_orders_on_close the call
is taken at the next open (called_at_next_open), a long sized at the close as
M2 sizes a short.

tests/test_margin_residual_tapes.cpp (new) replays the five tapes: on the base
1ed0a9e4 the four rule rows fail and the control passes.
test_pyramiding_count_differential P6 (three market entries on one flat bar at
pyramiding 2) now books TradingView's two fills instead of three; its pinned
adapter outcome moves to the tape's.

Pinned hashes moved by this rule alone, re-harvested at this commit (the base
reproduces every old row): publication witness 6 of 156, quiet bar 16 of 272,
live-state equivalence 7 of 108. Doc anchors re-anchored on this tree.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

(cherry picked from commit d6d7b7a9f6c7e87c7bae610b8e4f6e92c831a3b8)

INT28-FIX: src/source/pine_adapter.cpp, on_applied's opening-margin
checkpoint: this rule's `!sibling_book` and W6-ENG-FILL-ORDER F10's
`same_point_pair_fill_follows(...)` (picked into INT28) guard the same
condition; both stand. The pyramiding differential (M13 / G2-15) takes both
lanes' moves: W8A-SIGSTATE-1's R-B moved P4, P4b and D1 to TradingView, this
rule moves P6, so the adapter's count is 13 of 15 -- the test header, the
fixture README, the ADR-0001 `max_open_lots` row and the design row MG3 say
so. tests/CMakeLists.txt: git's clean merge put this lane's fixture if()
inside INT28-FIX CA's block; each block is closed on its own. The digest
pins (live_state, quiet_bar, publication witness) keep INT28's rows here and
are re-harvested once on the integrated tree; the doc anchors likewise.

INT28-FIX pick note: W5B-ENG-MARGIN-RESIDUAL 1
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…s checked over its path before the script

A short carried under process_orders_on_close took no path margin check on a
bar with a competing pending entry, nor on a rounded-money short (lot value
under one unit, pyramiding <= 1): ab9714b's schedule sliced it after the
script instead, at the bar's high, and deferred that slice behind the close's
market fills to the book they left. So the script read the uncalled size, a
close or a bracket that emptied the book first left no call at all, and an add
filled at the close was called at that bar's high on the grown book.

TradingView, on synthetic probes (lab tv --no-note, BINANCE:ETHUSDT.P 15, a
fee- and slippage-free 100 % default short at each of fifteen signal closes;
tests/fixtures/margin_residual):
- w5b-pc-seen-size: at the next close the script buys back
  math.abs(strategy.position_size): the call at the bar's high comes first and
  the script reads the called size, so the buy closes exactly the rest;
- w5b-pc-seen-size-parked: the same with a far long limit entry parked beside
  each short -- the same tv_trades.csv, byte for byte;
- w5b-pc-carried-close / -carried-reverse: the call at the high, then the
  close's close_all, or the reversal sized from the called book's equity;
- w5b-pc-bracket-tp: a take-profit the bar reaches after its high fills the
  rest of what the call at the high left;
- w5b-pa-pooc-p50 (50 %, pyramiding 2): a short add filled at the close is not
  called at that bar's high; the grown book is called at the next open;
- w5b-pc-carried-none (the control): nothing at the close, unchanged.

schedule_margin_call_path now takes the path check on a carried POOC short
beside a competing entry, on_bar_open no longer defers it for a rounded-money
short (defer_rounded_pooc_short_margin_until_close is deleted, with its quiet
gate), and on_bar_close drops the fee-free carried-short checkpoint and its
deferral to the last close fill (on_applied). Commissioned or slipped shorts
keep lane W5-ENG-MARGIN-V6's check before the script (C1).
pooc_close_checkpoint_deferred_ms_ is never set now; it stays, as the constant
it folds into the broker-state hash, so no digest moves for its removal.

tests/test_margin_residual_tapes.cpp gains the seven rows: on the rule SB
commit the six rule rows fail and the control passes. Behaviour pins that
recorded ab9714b's schedule move to the tapes (legacy twin copies kept in
sync; observableRewrites + INVENTORY_SHA256 re-pinned):
- test_carried_pooc_short_margin_state: the competing-entry control reads
  -12.33168 (was -12.44432), the rounded-money one -12.44432 with two rows
  closed (was -12.60172, one);
- test_rounded_carried_short_trail: the other order shapes and the competing
  entry see the margin before the script (-888216.89 / -884473.25, two
  closed), as the trailing exits already did;
- test_l9a_carried_pooc_competing_checkpoint: every parked variant books its
  unparked control's rows.

Pinned hashes moved by this rule alone, re-harvested at this commit (the SB
commit reproduces every old row): publication witness 21 of 156, quiet bar 10
of 272, live-state equivalence 1 of 108. The MG15 anchor of
native-feature-parity.md points at the exception left; doc anchors re-anchored.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

(cherry picked from commit 819b4ce75d409ca85c6f2f94d5e2995caed059e3)

INT28-FIX: src/source/pine_adapter.cpp, schedule_margin_call_path(): this
rule retires the legacy competing-entry predicate; INT28's picks had kept
it, with W3B-ENG-GRID's void-call test in the resting_order scan that
follows (a void call's request rests for no one). The retirement stands and
the void_issue test stays. scripts/check_twin_parity.py: the twin inventory
takes both INT28's and this rule's observable rewrites (key order), and
INVENTORY_SHA256 is the combined file's. docs/design/native-feature-parity.md
row MG15 takes this rule's chronology-exception sentence over INT28's
anchor-only edit. The digest pins keep INT28's rows here and are
re-harvested once on the integrated tree; the doc anchors likewise.

INT28-FIX pick note: W5B-ENG-MARGIN-RESIDUAL 2
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ith no lot of slack

An add to a held position of its own side kept one lot of slack: lane
W5-ENG-MARGIN-V6's placement judgement (add_margin_exceeds_equity) and the
fill-time add arm of validate_precommit both admitted an add whose held-plus-own
margin exceeded the equity by less than one lot's notional, and the adapter then
margin-called a whole unit of the book (the "family R" band). Under
process_orders_on_close, where M1 does not judge at placement, the add was
admitted at its close fill the same way.

TradingView, on synthetic probes (lab tv --no-note, NYSE:F 15, whole shares;
tests/fixtures/margin_residual):
- w5b-pa-f-pooc-p50 (process_orders_on_close, 50 %, pyramiding 2): a long E1
  at 09:30 .. 14:30 New York and an add E2 at the next close; every add whose
  margin on top of the held long's exceeds the equity at the close's tick is
  dropped -- by $1.90 .. $9.95 against a $9.9 .. $10.8 share as by more;
- w5b-pa-f-market-p50: the market twin, judged at the signal close;
- controls: w5b-pa-pooc-p40 (40 % + 40 % fits), w5b-pa-market-p50 and
  w5b-pa-pooc-p50-tick (BINANCE:ETHUSDT.P, 0.0001 lots).
The margin-basis-frac probes of the population are the same shape.

add_margin_exceeds_equity drops its lot term, and validate_precommit's frozen
arm keeps one lot of slack for a flat opening only (same_side_add); the
reversal arm had none already.

tests/test_margin_residual_tapes.cpp gains the five rows and the NYSE:F bars
(f15_bars.inc, the lab lane f-15 chart feed 80f404ae..., 2025-04-15 ..
2025-05-19): on the rule PC commit the two rule rows fail and the three
controls pass. test_reversal_admission_float_guard pin E moves: its sub-lot
shortfall add ($88 against a $106 lot) is now DECLINED (the legacy twin copy
kept in sync; observableRewrites + INVENTORY_SHA256 re-pinned). No pinned hash
moves (re-harvested at this commit). Every doc citation of the adapter is
carried through the exact line map from the lane's base.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

(cherry picked from commit 32fae161f95f9d2f9e830d33e80453e2eff058b1)

INT28-FIX: every code, test and fixture hunk applies unchanged. The twin
inventory takes this rule's observable rewrite beside INT28's and
INVENTORY_SHA256 is the combined file's. The docs keep INT28-FIX's
composition of the pyramiding rows (W8A-SIGSTATE-1 R-B and this lane's SB);
the doc anchors are re-anchored once on the integrated tree.

INT28-FIX pick note: W5B-ENG-MARGIN-RESIDUAL 3
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… money, not the equity

A default percent-of-equity quantity on an instrument with a lot grid was
the lot floor of pct/100 * round10(equity): the adapter put the equity on
TradingView's ten-significant-digit money grid before taking the percentage.
TradingView rounds the order's money -- the percentage of the equity -- and
floors that. At 100 % the two are one number; below it they part whenever the
equity carries more decimals than ten digits keep.

TradingView, on synthetic probes (lab tv --no-note, OANDA:EURUSD 15, 0.01
lots, initial_capital 10000000; tests/fixtures/margin_residual):
- w5b-sz-eur-p50-10m and -p33-10m: every 4 bars from flat a default long
  filled at the close under process_orders_on_close, flattened two bars
  later; the equity rounded first floors 44 of the 504 quantities at 50 % and
  37 at 33 % one lot off TradingView's, no rounding at all 8 and 18, the
  money rounded none;
- the control w5b-sz-eur-p100-10m-0410: at 100 % both roundings reproduce all
  130 quantities (no rounding misses 98).
The population probe margin-basis-frac on OANDA:EURUSD (50 %) is the same
shape: replayed from TradingView's first bar, all 3352 closed quantities
match under the money rounded; under the equity rounded 1327 are a lot off.
Rule PA exposed it there: an E1 one lot above TradingView's made the add
TradingView admits exceed the equity by $0.007, and PA drops it (control
data-OANDA-EURUSD/margin-basis-frac excellent -> strong on the PA head).

default_sizing_cash (the non-cash-fee percentage) now rounds the money. The
cash-fee branch (R5 lane PAR-CASHFEE's tapes) is unchanged.

tests/test_margin_residual_tapes.cpp gains the OANDA:EURUSD chart (the lab
lane eurusd-15 feed f945f31a..., 2025-04-01 .. 2025-04-29, eur15_bars.inc)
and the three rows: on the commit before this one the two rule rows fail and
the control passes; after, every row passes. No pinned hash moves
(re-harvested at this commit). Every doc citation of the adapter is carried
through the exact line map from the commit before. native-feature-parity's
SZ3 row said "TV parts stay A: rounded equity `source_money_round`" (introduced
by 2dd9834, R5 lane F2); it now names the percentage's money it rounds.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

(cherry picked from commit 0c11fd62ef860a54093ced6502a291e3e376d02f)

INT28-FIX: every code, test and fixture hunk applies unchanged. The design
row that names `source_money_round` takes this rule's sentence (the
percentage's money is rounded, not the equity) over INT28's anchor-only
edit; the docs keep INT28-FIX's composition of the pyramiding rows, and the
doc anchors are re-anchored once on the integrated tree.

INT28-FIX pick note: W5B-ENG-MARGIN-RESIDUAL 4
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…by one contract

On a whole-unit lot grid TradingView follows a margin call of four times the
floored restore with a call of one more unit at its next check point when
the book's oldest lot is one unit and the first call left part of the book.
The adapter took the first call only.

TradingView, on synthetic probes (lab tv --no-note; tests/fixtures/margin_residual):
- w5b-sb-es-fixed-n (CME_MINI:ES1! 15, point value 50, 1000000): every 2
  hours 3 + cell % 5 one-contract MARKET longs from flat fill at the next
  open; a book whose restore floors to 1 or 2 contracts is called 4 or 8 at
  the open and one more at the bar's next path point (5641.5 open, 4 called
  there, 1 at the 5642.5 high); a sub-lot restore (one contract) or a call of
  the whole book takes none;
- w5b-sb-es-pooc-fixed-n: under process_orders_on_close both at the next open;
- w5b-es-short-q111111 and -pooc-short-q111111: shorts alike;
- w5b-es-q1122, -pooc-q1122 and -q115 (1, 1, 5: the call ends inside the
  third lot): the oldest lot one contract, 4 then 1;
- w5b-f-q1x12 (NYSE:F, 100 of capital, twelve one-share entries): 4 then 1
  in all 70 cells;
- controls: w5b-es-q21111, -pooc-q21111 and -q222 (oldest lot two contracts:
  4, no follow-up) and w5b-eth-q111 (BINANCE:ETHUSDT.P, three 1 ETH entries on
  0.0001 lots: 1.1848 called, none more).
The population's CME_MINI:ES1! pf-probe-close-callsite-* probes (five
one-contract process_orders_on_close longs, called 4 + 1 at the next open)
are the same shape.

whole_unit_follow_up_due decides it on the book before the call (the grid,
a call of at least four units short of the book, the oldest open lot of one
unit). The three places a flat sibling book (rule SB) is called take the
follow-up: the market opening checkpoint in on_applied books it at the bar's
next path point (next_source_path_waypoint, the forced execution price a
path print books), on_bar_open books it at the same open for a
process_orders_on_close long and short. No durable state is added.

tests/test_margin_residual_tapes.cpp gains the CME_MINI:ES1! chart (the lab
lane es1-15 feed 766e8149..., 2025-04-01 .. 2025-04-29, es15_bars.inc) and
the twelve rows: on the commit before this one the eight rule rows fail and
the four controls pass; after, every row passes. No pinned hash moves
(re-harvested at this commit). Every doc citation of the adapter is carried
through the exact line map; MG7 names the follow-up.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

(cherry picked from commit 38eee6c4a1d18b8670d29d2142adbcb2beba9ccd)

INT28-FIX: every code, test and fixture hunk applies unchanged. The design
row MG7 takes this rule's sentence (the whole-unit follow-up call) beside
INT28's anchor-only edit; the docs keep INT28-FIX's composition of the
pyramiding rows, and the doc anchors are re-anchored once on the integrated
tree.

INT28-FIX pick note: W5B-ENG-MARGIN-RESIDUAL 5
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…amiding

A full-margin long of one lot takes TradingView's one-unit money call (the
ten-significant-digit residual, submit_tv_money_long_margin_call). Under
process_orders_on_close the adapter refused it whenever the strategy declared
pyramiding above 1, a scope ab9714b pinned only for pyramiding 1.

TradingView, on synthetic probes (lab tv --no-note, OANDA:EURUSD 15,
initial_capital 10000000, 0.01 lots; tests/fixtures/margin_residual):
- w5b-ms-eur-p100-pyr2: every 4 bars from flat one default 100 % long filled
  at the close, flattened two bars later, pyramiding=2: the same file as the
  pyramiding-1 w5b-sz-eur-p100-10m-0410, fourteen one-unit money calls
  included; the adapter booked none of them (122 trades against 130);
- the control w5b-ms-eur-p99-pyr2 (99 %): no margin call at all, the
  adapter's 168 trades already TradingView's.
The population probe margin-basis-allin on OANDA:EURUSD (100 %, pyramiding
2, process_orders_on_close) is the same shape: its first divergence is such a
one-unit call the adapter does not book.

The pyramiding term leaves the call's scope; the book must still hold one
lot. tests/test_tv_money_carried_pooc_l4b.cpp's preserved-scope case
pyramiding(2) -- a compatibility control that made no TradingView claim --
now takes the call carried() pins (the legacy copy kept in sync;
observableRewrites + INVENTORY_SHA256 re-pinned).

tests/test_margin_residual_tapes.cpp gains the two rows: on the commit before
this one the rule row fails and the control passes; after, every row passes.
No pinned hash moves (re-harvested at this commit). Every doc citation of the
adapter is carried through the exact line map.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

(cherry picked from commit 3408c0ca5e6b378dabf67f00ea551431496cccf8)

INT28-FIX: every code, test and fixture hunk applies unchanged. The twin
inventory takes this rule's observable rewrite beside INT28's and
INVENTORY_SHA256 is the combined file's; the docs keep INT28-FIX's
composition of the pyramiding rows, and the doc anchors are re-anchored once
on the integrated tree. This lane's floors commit (3c90030d) is not picked:
the ctest floors are counted once on the integrated tree.

INT28-FIX pick note: W5B-ENG-MARGIN-RESIDUAL 6
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…e its units fit at the signal close

At Pine v6's defaults (100 % of equity, margin 100) a default-quantity
percent_of_equity MARKET short is sized at the signal close less the
slippage ticks, and the commission, which puts more units in it than the
equity buys at the close itself. Under process_orders_on_close the adapter
already refused such a short when those units' margin at the close exceeds
the equity (lane W4-ENG-POOC-SAMEPASS, tests/fixtures/pooc_short_slip_admission).
TradingView does the same when the short fills at the next open, whatever
that open: it opens only while the units at the signal close, on its tick,
fit the equity there. The adapter placed the short and filled it.

TradingView, on synthetic probes (lab tv --no-note, NYSE:F 15, 2025-04-01 ..
2025-07-01; tests/fixtures/slipped_short):
- int28fix-adm-s-s (10000, slippage 1): 6 of 124 cells open; all 10000 at a
  close of 9.905 sizes 1010 at 9.90 and does not open (1010 x 9.91 =
  10009.1 over 10000);
- int28fix-ou-s4 (4000, commission 0.04 %, slippage 4): none of 310 opens;
- controls int28fix-adm-s-0 and -adm-s-c (no slippage: sized at the close,
  only the fill-time admission) and int28fix-adm-l-cs (a long, sized above
  the close) are unchanged.
The lane's other probes (int28fix-adm-s-cs, int28fix-ou-s1, -s2, -s2b, -s3b
and -s3, slippage 1 to 3; lane scratch) agree on every cell: 2479 cells,
TradingView's decision and share count each, read at its own equity.

src/source/pine_adapter.cpp, entry(): outside process_orders_on_close and
calc_on_order_fills, a default percent_of_equity MARKET short with slippage
placed from a flat book with no entry pending is dropped at placement when
its frozen units at the tick-rounded signal close, times the short margin,
exceed the sizing equity. A reversal and a book with an entry pending are not
measured and keep their paths.

tests/test_slipped_short_tapes.cpp replays the tapes (the SS rows compare
TradingView's openings; their margin-call slices are rules OU and OF): 6138
passed, 2 failed on the commit before (both SS rows), 3530 passed, 0 failed
with the rule.

Leaver target job-2558-finnp17-silver-surfer on NYSE:F 15 (commission 0.04 %,
slippage 1; TV-DEFAULTS codegen b33c9dc, lane replica of the lab verifier):
its first divergence on INT28 is the 2025-04-03 14:15 short TradingView does
not open; with this rule alone moderate 94.4 % / countAbsDelta 2 / exit p90
0.0058 / pnl p90 8.3262 -> moderate 94.1 % / 1 / 0.0041 / 4.4177, the rest
of the gap being the entry-bar margin slicing rules OU and OF close.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…nit restores the book at its fill

On a whole-unit lot grid a margin call whose restore floors below one lot
takes one unit (the family R whole-drop band in source_margin_units). With
slippage TradingView takes that unit only where it restores the book at the
call's own fill: it prices the whole position's requirement at the
liquidation's slipped print -- a short's buy is the slippage ticks above the
mark, a long's sell below it -- against the equity at the mark, and closes
nothing when that requirement exceeds the equity by a unit's margin or more.
The adapter took the unit whenever the restore floored below one lot, on
every all-in short with slippage: a one-share call at nearly every entry bar.

TradingView, on synthetic probes (lab tv --no-note, NYSE:F 15, 2025-04-01 ..
2025-07-01; tests/fixtures/slipped_short):
- int28fix-adm-s-s (10000, slippage 1): no one-share call at all; a short of
  968 shares filled at 10.32, 9.12 short of its margin at the 10.33 print,
  takes none (968 x 10.34 exceeds the equity by 18.80);
- int28fix-ou-s3 (4000, commission 0.04 %, slippage 3): a short of 382
  filled at 10.43, 8.77 short at 10.46, takes none either;
- controls int28fix-adm-s-c (no slippage: 22 one-share calls) and
  int28fix-adm-l-cs (a long's sell: 5) keep every call, as the formula
  gives them.
Across the lane's other probes (int28fix-adm-s-cs, int28fix-ou-s1, -s2, -s2b
and -s3b, slippage 1 to 3; lane scratch) and the leaver's own tape, a model
of the entry bar with this formula, rule OF's follow-ups and, at slippage 2
and more, a short's check at the bar's low reproduces every call TradingView
books there: 1671 entry bars.

src/source/pine_adapter.cpp, source_margin_units(): the band's one unit now
also requires the position's requirement at the liquidation's slipped print
to exceed the equity at the mark by less than one unit's margin. At zero
slippage the test is the band's own, and a long's sell always passes it, so
slippage-free and long books are unchanged. The design row MG7 names the
band's new condition.

tests/test_slipped_short_tapes.cpp: the int28fix-adm-s-s row now compares
TradingView's trades, not only its openings, and int28fix-ou-s3 joins: 3640
passed, 2 failed on the commit before (both rows), 3630 passed, 0 failed
with the rule.

Leaver target job-2558-finnp17-silver-surfer on NYSE:F 15 (lane replica of
the lab verifier, codegen b33c9dc): with SS and this rule the engine matches
TradingView's entry-bar calls up to its first one-unit follow-up (2025-05-21),
moderate 94.1 % / countAbsDelta 1 -> 92.7 % / 4 (exit p90 0.0041 -> 0.0044,
pnl p90 4.4177 -> 2.7382): the follow-ups TradingView books after these calls
are rule OF, the next commit.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…is followed by one more unit

On a whole-unit lot grid with slippage TradingView follows a one-unit margin
call with one more unit at the bar's next path point when that unit did not
restore the book at its own fill: the book it called, re-marked at the
call's fill price, is still short of margin by more than a unit's margin and
two slippage steps. The next point books the unit where its own check calls
nothing and its print is inside the call's fill (below it, for a short's
buy); a print at or beyond the fill is judged by its own check alone. A unit
so taken is followed alike, and the close is the last point a bar offers. A
long's call is never followed (its sell lowers the requirement with the
equity), nor is a call at zero slippage. The adapter took the first unit
only (W5B's follow-up, whole_unit_follow_up_due, covers a four-times call on a
book whose oldest lot is one unit).

TradingView, on synthetic probes (lab tv --no-note, NYSE:F 15, 2025-04-01 ..
2025-07-01; tests/fixtures/slipped_short):
- int28fix-ou-s1 (4000, commission 0.04 %, slippage 1), through 2025-04-30:
  29 follow-ups after 55 one-unit calls; a short of 352 shares filled at
  9.86, called at 9.88 off the 9.87 open print and 0.068 short re-marked
  there, gives up one more at the 9.855 low; one of 359 filled at 9.63 and
  called at 9.65, 0.001 inside its margin re-marked there, takes none; one of
  396 filled at 9.97 and called at 9.99 meets the 9.995 high at that fill,
  whose own check calls the next share, followed at the 9.94 low;
- int28fix-adm-s-cs (10000, commission 0.04 %, slippage 1), through
  2025-06-25: 3 follow-ups.
The lane's slippage 2 and 3 probes (int28fix-ou-s2, -s2b, -s3b; lane scratch)
place the threshold at two slippage steps: 0.038 short at slippage 2 takes
none, 0.0445 takes one; 0.0439 at slippage 3 takes none, 0.21 takes one.
Their replay also needs two shapes this rule does not model, left open in
the fixture README with a third the leaver's tape holds.

src/source/pine_adapter.cpp: follow_one_unit_margin_call() decides the
follow-up after a one-unit call on the book the call left (the unit's own
exit fee added back is the book it called, re-marked at its fill) and books
it at the next path point through submit_margin_call_units, as W5B's
follow-up does; on_applied calls it after the slipped market short's opening
checkpoint and after every kernel liquidation of one unit. The design row
MG7 names the follow-up beside W5B's.

tests/test_slipped_short_tapes.cpp: rows int28fix-adm-s-cs and
int28fix-ou-s1 join, each over the window that ends before the first
unmodelled shape its tape holds: 6834 passed, 2 failed on the commit before
(both rows), 6860 passed, 0 failed with the rule.

Leaver target job-2558-finnp17-silver-surfer on NYSE:F 15 (lane replica of
the lab verifier, codegen b33c9dc): with SS, OU and this rule the engine
books TradingView's 481 trades, strong 97.9 % / countAbsDelta 0 / entry p90
0 / exit p90 0 / pnl p90 0 (INT28 moderate 94.4 % / 2 / 0 / 0.0058 /
8.3262; baseline strong 96.5 % / 10 / 0 / 0.0264 / 99.8631). Its remaining
divergences are calls on the later bars of a held position (the close-to-
open shape among them).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Counted with ctest -N per ci_verify profile, each build dir configured with
ci_verify's own argv (configure only, no compiler launcher), on INT28
4efcb8c and on this tree:

  profile     INT28  INT28-FIX  floor
  release       748        751  RELEASE_MIN_TESTS 751 (no release row skips)
  kernel        296        296  KERNEL_MIN_TESTS 295 (unchanged)
  debug         729        732  EXCLUDED_REGISTERED_MIN 732
  sanitizers    729        732  EXCLUDED_REGISTERED_MIN 732
  native        738        741  EXCLUDED_REGISTERED_MIN 741

The same three rows join every profile but kernel, and none leaves:
test_reversal_close_all_tapes (rule CA), test_margin_residual_tapes
(W5B-ENG-MARGIN-RESIDUAL, picked) and test_slipped_short_tapes (rules SS, OU
and OF). W5B's own floors commit is not applied. The self-test's pinned table
and docs/ci.md follow (scripts/test_ci_verify.py: 145 tests OK).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…e integrated tree and attributed

Three pinned tables move on the integrated tree (INT28 4efcb8c and
INT28-FIX's ten commits). W5B-ENG-MARGIN-RESIDUAL's own re-pin was harvested
on its own tree and is not applied; each table is re-harvested here once,
with its TU's own switch, and the same harvest against INT28 4efcb8c
reproduces every old row of all thirteen tables. The report re-lowering,
recording hash, continuation view, receipts, command allocations, lookup
index, host-view memo, calendar and both brackets re-lowering witnesses do
not move.

Attribution: a harvest at every commit boundary (CA, SB, PC, PA, SZ, FU, MS,
SS, OU, OF) marks each moved row with the commit(s) at which it changed. Only
the picked W5B rules SB and PC move any row; CA, PA, SZ, FU, MS, SS, OU and
OF move none, and no row moves and comes back.

- test_adapter_quiet_bar (PINEFORGE_QUIET_BAR_HARVEST): 26 of 276 runs --
  W5B SB 18, W5B PC 10 (Random16 recording on, magnifier off and on, at
  both).
- test_publication_witness (PINEFORGE_D2D_PUBLICATION_HARVEST): 27 of 156
  runs -- W5B PC 21, W5B SB 6.
- test_adapter_live_state_equivalence (PINEFORGE_V19E_HARVEST): 4 of 108
  digests -- W5B SB 3, W5B PC 1.

Each table's ledger names the moved rows' old and new values.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The picks and this lane's rules move lines in src/source/pine_adapter.cpp,
include/pineforge/source/pine_adapter.hpp and scripts/ci_verify.py that the
pages, the ADR and the design notes cite. check_doc_anchors.py --fix placed
the citations whose symbol occurs once; reanchor_doc_citations.py carried
112 more across the line map from INT28 4efcb8c (where every anchor
resolved) and W5B-ENG-MARGIN-RESIDUAL's tip 3408c0ca (for the sentences its
picks wrote). Seven were set by hand: RELEASE_MIN_TESTS ci_verify.py:507
(three citations), MG4's AdmitWithHostMargin span 13755-13856 (the INT28
map; the W5B tip's reading of a row that predates it was not taken), MG7's
whole_unit_follow_up_due 15276, and MG15's `4.0 * minimum` 14505 and
resting_order 15375-15390. Every re-anchored span starts and ends on the
lines it did at 4efcb8c; the four that change length hold code inserted
inside them (W5B's picks and rule OU).

check_doc_anchors: every documentation anchor resolves to its symbol; doc
lint and doc reverts are clean.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…'s finer request.security values

TradingView runs a calc_on_order_fills recalculation of a historical bar on
the whole bar: a recalculation reads the bar's close, high and low, and a
request.security on a timeframe finer than the chart reads the bar's own slice
of it, as the bar's close calculation does. The native scheduler fed a chart
bar's slice of the auxiliary finer feed only in its close callback, after the
bar's fill recalculations, so a recalculation read the chart bar's close, high
and low but the previous chart bar's finer values. (ab9714b fed the slice
before dispatch_bar, ahead of the bar's fills.)

TradingView, on three synthetic read-out probes (lab tv --no-note,
BINANCE:ETHUSDT.P 15, 2025-04-01 .. 2025-05-01;
tests/fixtures/coof_recalc_security): a recalculation closes the position
with a comment naming what it read.
- int28fix-rc, the open fill's recalculation, 2025-04-11 00:30 UTC: close
  1520.73, high 1523.56, low 1514.04 (the bar's own) and a lookahead_off 5m
  close of 1520.73 (the 5m bar closing with the chart bar); the engine read
  1519.95, the previous bar's. The same on the 02:30 short (1538.66; the
  engine read 1545.13).
- int28fix-rc2, the recalculation of a take-profit filled on the bar's path
  (1520.95): the same values.
- int28fix-rc3, the open fill's recalculation: a lookahead_on 5m site reads
  the bar's first 5m bar (1521.55) and a 5m request.security_lower_tf array
  the bar's three (1521.55 .. 1520.73).

src/source/pine_scheduler_native.cpp: PineScheduler::recalculate feeds the
bar's auxiliary slice at the bar's first recalculation before its close
callback (callback_advances_source_bar), through scheduler_feed_aux_security,
which rebases the script-state checkpoint on the fed values;
PineScheduler::bar feeds it only when no recalculation did. A recalculation
after the close callback (a fill the close books, strategy.close(immediately
= true)) finds the slice that callback fed and feeds nothing: fed again, the
finer sites step twice, and on the run's last bar the slice's routing is
already cleared. The design row HT4 names the rule.

tests/test_coof_recalc_security_tapes.cpp: ports of the three probes over the
corpus 15m and 1m bars, checkpointing their sites' values and the 5m site's
completed-bar count as a generated strategy does, require every trade and
every read-out the tapes carry to be the engine's, and every callback of
every bar to read that bar's own 5m close with its slice fed once; a fourth
probe closes positions immediately at a bar's close, mid-run and on the last
bar. 158 passed, 38 failed on the commit before (every recalculation reads
the previous bar's slice); 196 passed, 0 failed with the rule. Gated on the
first recalculation alone (without the close-callback guard) the fourth probe
fails 12 of 194: from the mid-run close on, the 5m site is three bars ahead,
and the last bar's run fails ("auxiliary request.security chart routing is
not initialized").

Leaver LV3, finnp17-cleantradequantum-v7-2-ob-fvg-integrated on NASDAQ:AAPL 15
(lane replica of the lab verifier, codegen 2440321): strong 99.0 % /
countAbsDelta 2 / entry p90 0 / exit p90 0 / pnl p90 0 (INT28 moderate
94.9 % / 3 / 0 / 0.0038 / 0; baseline strong 95.1 % / 1 / 0 / 0.0037 / 0).
The script closes a short in its open fill's recalculation when a finer
request.security turns its signal long; reading the previous bar's values,
the engine never did, and since W4 F19c books the through stop that
recalculation places at the open, the stop took the trade instead of the
close and the reversal the script set with the close was lost.

Layer: source-adapter parity runtime (ADR-0001, Decision, layer 2); no
kernel unit changes.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Counted with ctest -N per ci_verify profile, each build dir configured with
ci_verify's own argv (configure only, no compiler launcher), on 3332347 and
on this tree:

  profile     3332347  INT28-FIX  floor
  release          751        752  RELEASE_MIN_TESTS 752 (no release row skips)
  kernel           296        296  KERNEL_MIN_TESTS 295 (unchanged)
  debug            732        733  EXCLUDED_REGISTERED_MIN 733
  sanitizers       732        733  EXCLUDED_REGISTERED_MIN 733
  native           741        742  EXCLUDED_REGISTERED_MIN 742

The one row that joins every profile but kernel, and none leaves:
test_coof_recalc_security_tapes (rule RC). The self-test's pinned table and
docs/ci.md follow (scripts/test_ci_verify.py: 145 tests OK).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
RC adds two lines to PineScheduler::bar and twelve to
PineScheduler::recalculate (src/source/pine_scheduler_native.cpp), and the
floors commit four comment lines above RELEASE_MIN_TESTS
(scripts/ci_verify.py), so the anchors below them moved:
- check_doc_anchors.py --fix: coof_recalculation_due 611 -> 613 and
  PineScheduler::applied 606 -> 608 (docs/design/native-feature-parity.md);
- reanchor_doc_citations.py --ref 3332347 (line map, each result verified
  on this tree): kFirstOpenLoopGuard 729 -> 743 (ADR-0001 and two design
  rows) and PineScheduler::recalculate 636 -> 638 (two design rows);
- by hand, where the line map found no reference placing the symbol:
  RELEASE_MIN_TESTS ci_verify.py:507 -> :511 (CONTRIBUTING.md,
  docs/pages/contributing-llm.md twice).
check_doc_anchors.py: every documentation anchor resolves to its symbol;
check_doc_lint.py, check_design_inventory.py, check_kernel_seam_rows.py,
check_dangling_comment_names.py: 0 findings.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@luisleo526
luisleo526 merged commit 74491fa into main Sep 28, 2026
18 checks passed
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