Skip to content

Pine adapter: eight parity changes, 35 probes strong to excellent - #315

Merged
luisleo526 merged 18 commits into
mainfrom
px/wave1-integration
Oct 3, 2026
Merged

luisleo526 merged 18 commits into
mainfrom
px/wave1-integration

Conversation

@luisleo526

@luisleo526 luisleo526 commented Oct 3, 2026 •

Copy link
Copy Markdown
Collaborator

What

This PR carries eight Pine adapter changes in one integration. Each was reviewed and measured on its own; together they get one full-population sweep and one gate verdict. All the changes are in the Pine adapter (src/source/, include/pineforge/source/) or in tests, fixtures and docs. The kernel, the grader and codegen are untouched.

Component What it changes Its own measurement (family probes up / guard probes unchanged) Independent review
Same-bar market entries under pyramiding Several market strategy.entry orders placed on one bar are booked as TradingView does (sizing fixed at placement, buys before sells, frozen adds). The batch falls back to the previous path whenever a same-bar request depends on a batched entry exp-px-f1-thirdfix-20261003 (final head): 16/16 up, 173/173 unchanged MERGE-WITH-FIXES, fixes applied; re-review MERGE-WITH-FIXES, fixes applied; the integration-defect fix is reviewed in the delta review below
Opening margin checkpoints and frozen stop reversals Margin checks follow TradingView's opening schedule; gap-open checks are kept; a frozen stop reversal is sized from its placed units exp-px-f2-review-20261003: 9/21 up, 458/458 unchanged MERGE-WITH-FIXES, fixes applied
FIFO closes at live lot boundaries One FIFO boundary tolerance; normalization only for ambiguous live lot prefixes; literal close requests kept, so a split lot never leaves a zero-quantity remainder (correctness fix) exp-px-f3-review-head-20261003: 0/10 up (no grade change expected), 302/302 unchanged MERGE-WITH-FIXES, fixes applied
Stream report at range boundaries The cumulative stream mark is kept when a stream report closes a range; range-end presentation moves behind an adapter hook the Pine host owns Batch path byte-identical: corpus parity 312/312 and subset unchanged; forward/batch equivalence end-to-end tests MERGE-WITH-FIXES, fixes applied
Carried trail, closing stop and fill-callback projections The trail extreme and closing stop are carried through opening fill callbacks on the taped paths exp-px-f4-fix1-review-20261003: 3/5 up, 350/350 unchanged MERGE-WITH-FIXES, fixes applied
Source-time all-in buying power All-in openings are admitted against the source-time buying power TradingView uses exp-px-f4-pka-review-20261003: 3/8 up, 150/150 unchanged MERGE-WITH-FIXES, fixes applied
Percentage exits sized from live entry ancestry A named percentage exit target is sized from the live entry ancestry, restricted to the taped shapes; all 108 frozen bracket transcripts unchanged exp-px-f4-pkcd-narrow-20261003: 2/8 up, 200/200 unchanged MERGE-WITH-FIXES, fixes applied
Request-context clock Native calendar request history no longer depends on auxiliary feeds; full-day minute requests publish at the session close (early closes included); requested periods are preserved exp-px-px-f4-pkbg-review-final-20261003: 2/7 up, 252/252 unchanged MERGE-WITH-FIXES, fixes applied

The 35 probes these measurements predict to rise (all strong → excellent) are the only grade changes the sweep may show.

Integration

  • One code conflict. Two components touched the same admission branch in validate_precommit. Both are kept. Their scopes cannot overlap: one requires margin 0, the other margin 100.
  • Docs. The documentation citation conflicts were re-anchored mechanically: all 1,744 anchors resolve, and the doc lint and revert checks pass.
  • A defect found in integration. Running the components' tests together exposed one. Under pyramiding ≥ 2 with fixed quantity and margin 0, a single entry with same-bar exits booked no trades. No population script has that shape, so its own sweep could not see it. It was fixed and re-measured before this integration was built (row 1).
  • One generic kernel hook, owner-approved. include/pineforge/engine.hpp gains virtual void present_report(ReportC*) const {}, called once in src/engine_report.cpp before the metric blocks.
    • It is empty by default, and batch output is byte-identical.
    • Its purpose is to move Pine's range-end re-mark out of the kernel and into the Pine host, the only override. The Pine host acts only for a realtime stream or a stream end.
    • These are the only kernel files this PR touches.
  • Known stream exceptions. Three rules added here apply to batch runs only, gated on stream mode:
    • pine_adapter.cpp, all-in admission;
    • the open-tick carried-trail conversion;
    • the opening margin-check schedule.
      Like the 46 such gates already on main, they are being classified and closed by a follow-up that keeps batch output byte-identical. Until then, a confirmed-bar live stream of a script that hits them can differ from its backtest.
  • One known target-lane leaver, filed as a follow-up. OANDA:EURUSD vasudevshenoy-manoj-betrayed-me drops from excellent to strong: it books 278 engine trades against TradingView's 274, with every TradingView trade still matched.
    • Bisect: the carried-trail/closing-stop component alone reproduces it; every other component alone keeps it excellent.
    • First divergence: trade test(orders): cover multi-tier exit precedence #45 on 2025-06-11, entry at 14:30 instead of TradingView's 14:45, and everything after it shifts.
    • That rule lifts the same strategy on NSE:NIFTY and two other probes, so it stays in this PR. Narrowing it for 5-decimal FX ticks is the follow-up.
    • The drop is one tier, on a target lane, and it is the only probe that drops in the full population. The hard lane has no drop.
  • Cross-mechanism tests. Nine new synthetic TradingView tapes exercise the mechanisms together (tests/test_cross_mechanism_tapes.cpp, fixtures under tests/fixtures/cross_mechanism/): same-bar batches with exits, cancels and partial FIFO closes; pyramiding with margin at 100 and 50; a margin call on fractional lots; all-in admission with a percentage exit target; a carried trail on a batched entry. Six match TradingView and are asserted — three of those are cases main gets wrong and this PR fixes. Three do not match TradingView on this PR or on main (a 2e-19 close fragment in an opposite-side partial FIFO close; missed checkpoints at 50% margin; a whole-book liquidation under fractional margin); they are recorded, not asserted, and filed as follow-ups. None is a regression.
  • Delta review. An independent delta review of the integrated tree checked the conflict resolution, that every squashed component equals its own branch outside that one hunk, the documentation re-anchoring, and cross-component interactions (65 probe scripts give identical output on the same-bar component alone and on the integration). It found three cases where the same-bar component's fallback differed from main; two further fix rounds and two re-reviews made the fallback byte-identical to main outside the taped shape, with each reviewer probe committed as a fixture pinned to main and one new TradingView tape (a batch beside a live exit) confirming the route.

Evidence

  • Full-population sweep of this head: 7,989 probes (exp-px-wave1-gate-20261003, head 6f7e5eb). Exactly 35 change grade upward, all strong → excellent, and they are exactly the 35 the component measurements predicted: 16 same-bar entries, 9 margin checkpoints, 3 carried trail/callbacks, 3 all-in admission, 2 percentage ancestry, 2 request clock. One probe falls one tier on a target lane (listed above). No probe is missing and none errors. An earlier preview measurement of the integration gave the identical result.
  • Gate verdict: PASS (improved), verdict schema v3. Hard lane (1,009 probes): 3 improved, 0 worsened, tier-rank sum 4023 → 4026. Target lanes: 32 improved, 1 worsened (the listed leaver).
  • Full verification profiles on the exact tree: preflight (44 stages), release (803 of 803), debug (784 of 784), sanitizers (784 of 784), kernel (302 of 302), docs (no Doxygen warnings), corpus parity (312 of 312 unchanged) and subset — all pass on head 6f7e5eb.

🤖 Generated with Claude Code

luisleo526 and others added 18 commits October 3, 2026 09:47
Constrain margin checkpoints to the opening schedule TradingView applies,
keep gap-open margin checks, size frozen stop reversals from their placed
units, and pin the cash-fee and margin tapes.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Unify the adapter's FIFO boundary tolerance, limit the normalization to
ambiguous live lot prefixes, and keep literal close requests, so a split
lot never leaves a zero-quantity remainder.

Update the quantity_tolerance ADR wording introduced by 0d76a09 to describe both POOC selected-Flatten and ordinary HostSized-to-Reduce boundary rules with the same 1e-10 tolerance. Preserve the policy and explicitly document the excluded close paths.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Keep the cumulative mark when a stream report closes a range, move report
presentation behind an adapter hook so the Pine host owns its range-end
policy, and refresh the live report witnesses.

Correct the range-end documentation introduced by d093560: realtime curves retain ordinary marks, terminal Pine presentation lives in the adapter, and hashed extremes no longer fold hypothetical live terminal marks. Record witness provenance, qualify the observer and synthetic print tape, and refresh shifted documentation anchors.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Carry the trail extreme and closing stop through opening fill callbacks on
the taped paths, keep non-opening callbacks on their existing projections,
and pin the partial-close evidence and witnesses.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Admit all-in openings against the source-time buying power TradingView
uses, keep competing-opening admission and the settled admission scope, and
pin the market band equality.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Size a named percentage exit target from the live entry ancestry that
TradingView uses, restricted to the taped named, absolute and limit-only
percentage targets, and document the scope and the margin evidence.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Keep a request's native calendar history independent of auxiliary feeds,
publish full-day minute requests at the session close TradingView uses
(early closes included), and preserve requested periods.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@luisleo526
luisleo526 marked this pull request as ready for review October 3, 2026 12:48
@luisleo526
luisleo526 merged commit a744bee into main Oct 3, 2026
17 checks passed
@luisleo526
luisleo526 deleted the px/wave1-integration branch October 3, 2026 12:53
luisleo526 added a commit that referenced this pull request Oct 4, 2026
The 1.1.0 lead now says how state-hash values change while the epoch and
the domain tags stay: a run whose fills an adapter change alters hashes
to new values, and three changes fold more state, so a run can hash
differently from 1.0.1 with byte-identical trades: #315 (an unbatched
same-bar entry request and placement; the stream report's terminal
re-mark leaves the hashed extremes; witness row Stream/0/1 re-pinned),
#316 (an opening stop's next waypoint; Random44/0/0 and /1 re-pinned)
and #319 (tick-volume state, every existing pin kept).

In the runner tooling bullet, "No versioned engine PF_API export ...
changes" and "Plugin-free ledger identity bytes remain unchanged" read
as release-wide; they now speak for #320 itself and for a strategy
without the checked settings calls. The Report keys intro points at the
report schema page. The terminal-quote bullet names the chart feed that
PINEFORGE_RUN_REPORT_CHART_QUOTE points at, and two runner bullet
headings are re-wrapped.

Replaces text introduced by a80485c (this branch's first commit): the
lead's "A run whose fills one of the Pine adapter changes below alters
hashes to new values, and [#316] adds one placement field to the
adapter's hashed state, for which two witnesses with byte-identical
trades were re-pinned.", the Report keys intro and the terminal-quote
harness clause; and text introduced by dbd17b3 (#320): "No versioned
engine PF_API export, native C++ surface, script ABI epoch or engine
behavior changes." and "Plugin-free ledger identity bytes remain
unchanged".

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
luisleo526 added a commit that referenced this pull request Oct 4, 2026
The 1.1.0 lead said three changes "fold more state"; #315's range-end
change instead stops folding a stream report's terminal re-mark into the
hashed extremes. The sentence now says the three changes change what the
hashes fold, and names Stream/0/1 as a re-pinned witness row without
claiming it is #315's only one.

Replaces text introduced by 66be240 (this branch's second commit): "Three
changes also fold more state" and "re-pinning one witness row
(`Stream/0/1`, whose recorded-row digest alone moves)".

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
luisleo526 added a commit that referenced this pull request Oct 4, 2026
… rule

#325 (confirmed-bar streams compute what the batch computes) and #327
(docker/run_json.py --symbol-feeds) merged before the release notes, so
their Unreleased bullets join the 1.1.0 section, rewritten and linked; no
Unreleased heading stays.

- CHANGELOG.md: the lead names the stream fix and, in the pairing
  sentence, codegen 1.1.0's request discovery (transpile_full()["requests"],
  codegen #164). #325's bullet says what a stream user sees; #327's bullet
  and its Report keys entry (applied_runtime.symbol_feeds, the
  --symbol-feeds: failure messages). A new State hashes section lists the
  four recipe additions since v1.0.1 (#315, #316, #319, #325; none removed,
  renamed or re-encoded; domain tags unchanged). #315's range-end
  equity-extreme change moves to the Pine adapter parity bullet as a
  behaviour fix. The #319 bullet named the broker-state hash; the change is
  in the native continuation hash, which the broker-state hash folds. The
  known-issue bullet now says it is fixed in 1.1.0 (#325). Migration gains
  a line on stream results and hashes.
- README.md: the known issue is fixed in 1.1.0 (#325); the v1.1.0 Releases
  line gains the stream fix, request discovery and the harness's
  multi-symbol request.security feeds. Fact markers rendered from the facts
  export that maps releases[1.1.0] to
  pineforge-parity-baseline-20261004-engine-7b596622 (7,951 excellent / 38
  strong of 7,989); the active scoreboard moves to the same baseline, here
  and in docs/pages/contributing-llm.md.
- docs/pages/streaming.md: the known issue affected v1.0.0 and v1.0.1 and
  is fixed in 1.1.0.
- docs/pages/public-contract.md: the state-hash rule, amended by the
  owner's ruling for 1.1.0. It covers the recipe only: a minor release may
  add a hashed field (domain tags unchanged, the added field changing no
  trade or report, disclosed under State hashes); removing, renaming or
  re-encoding a hashed field is a new epoch and a major release; behaviour
  changes follow the normal release and parity rules. The first uses are
  #315 and #316. The semver rule is unchanged.

Replaces text introduced by 7b59662 (#325): CHANGELOG.md's
"Confirmed-bar streams compute what the batch computes:" bullet, and the
"Fixed on main (#325); included in the next release." lines of README.md
and streaming.md; by 4f2a475 (#327): CHANGELOG.md's "Harness symbol
feeds:" bullet; by d093560 (#290): public-contract.md's "State-hash
values are stable within the epoch." and "a new recipe is a new epoch and
a major release"; by a80485c (this branch's first commit): the "Known
issue, as in v1.0.0 and v1.0.1" bullet, streaming.md's "(v1.0.0, v1.0.1,
v1.1.0)", the #319 bullet's "A tick stream's broker-state hash folds the
new accumulator state only where it adds information, so the existing
tick, bar and batch hash pins hold.", the Report keys failure-output
bullet and the v1.1.0 Releases line; by 66be240 and 83d64dc: the lead's
state-hash sentences ("Three changes also change what the hashes fold");
and, as git attributes them through this branch's merge of main, by
e59c09f: README.md's v1.1.0 Releases line and streaming.md's
"(v1.0.0, v1.0.1, v1.1.0)".

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
luisleo526 added a commit that referenced this pull request Oct 4, 2026
* docs: release notes and version scoping for v1.1.0

v1.1.0 is a minor release: <pineforge/pineforge.h> declares six more
functions, the checked settings calls that a strategy generated by
pineforge-codegen 1.1.0 exports (#317). It pairs with pineforge-codegen
1.1.0. PF_ABI_VERSION stays 4 (pineforge.h only gains declarations;
native_c_api.h and the native C++ host headers are unchanged) and the
script ABI epoch stays engine_script_run_v19.

- CHANGELOG.md: "## Unreleased" becomes "## 1.1.0 — 2026-10-04": a lead
  paragraph, one bullet per change a user can observe since v1.0.1
  (#312-#324), each linking its PR, a Report keys subsection
  (docker/run_json.py v1.0.1 -> v1.1.0) and a Migration subsection. The
  three Unreleased bullets stay; the lot-grid bullet now gives both
  failure messages.
- README.md: pineforge-codegen==1.1.0, the v1.1.0 tarballs, the pairing
  sentence, the stream known issue's scope, the benchmark refresh line,
  the release scoreboard sentence (releases[1.1.0] markers) and a v1.1.0
  line in Releases. The public corpus sweep's "311 excellent + 1 declared
  anomaly" is scoped to the v1.0.1 library it was measured on. Facts
  rendered from the facts file that adds releases[1.1.0]; the active
  scoreboard markers move to baseline
  pineforge-parity-baseline-20261003-engine-dbd17b38.
- docs/pages/install.md: the v1.1.0 tarballs and the hub tag
  engine1.1.0-codegen1.1.0.
- docs/pages/public-contract.md: 1.1.0's release line, engine v1.1.0 with
  codegen 1.1.0 among the supported pairs, and the four C-boundary rows
  that were planned for 1.1.0 are not in it.
- docs/pages/streaming.md: the known issue's scope includes v1.1.0.

Lines that state what an earlier version shipped or did stay.

Replaces text introduced by dc74e63 (#318): README.md's "Release 1.0.1
still grades ... until the next release" sentence, now 1.1.0's; by
d093560 (#290): public-contract.md's "Four of its rows are planned for
1.1.0"; by 783bb39 (#322): CHANGELOG.md's "The engine library is
unchanged."; by dbd17b3 (#320): CHANGELOG.md's "The engine is
unchanged."; by b2a578c (#300): README.md's "this repository's sweep:
311 excellent + 1 declared anomaly"; by 271d687 (#311): README.md's
"its releases 1.0.0 and 1.0.1 do".

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* docs: state the 1.1.0 hash folds and scope two runner sentences

The 1.1.0 lead now says how state-hash values change while the epoch and
the domain tags stay: a run whose fills an adapter change alters hashes
to new values, and three changes fold more state, so a run can hash
differently from 1.0.1 with byte-identical trades: #315 (an unbatched
same-bar entry request and placement; the stream report's terminal
re-mark leaves the hashed extremes; witness row Stream/0/1 re-pinned),
#316 (an opening stop's next waypoint; Random44/0/0 and /1 re-pinned)
and #319 (tick-volume state, every existing pin kept).

In the runner tooling bullet, "No versioned engine PF_API export ...
changes" and "Plugin-free ledger identity bytes remain unchanged" read
as release-wide; they now speak for #320 itself and for a strategy
without the checked settings calls. The Report keys intro points at the
report schema page. The terminal-quote bullet names the chart feed that
PINEFORGE_RUN_REPORT_CHART_QUOTE points at, and two runner bullet
headings are re-wrapped.

Replaces text introduced by a80485c (this branch's first commit): the
lead's "A run whose fills one of the Pine adapter changes below alters
hashes to new values, and [#316] adds one placement field to the
adapter's hashed state, for which two witnesses with byte-identical
trades were re-pinned.", the Report keys intro and the terminal-quote
harness clause; and text introduced by dbd17b3 (#320): "No versioned
engine PF_API export, native C++ surface, script ABI epoch or engine
behavior changes." and "Plugin-free ledger identity bytes remain
unchanged".

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* docs: #315's range-end change folds less, not more

The 1.1.0 lead said three changes "fold more state"; #315's range-end
change instead stops folding a stream report's terminal re-mark into the
hashed extremes. The sentence now says the three changes change what the
hashes fold, and names Stream/0/1 as a re-pinned witness row without
claiming it is #315's only one.

Replaces text introduced by 66be240 (this branch's second commit): "Three
changes also fold more state" and "re-pinning one witness row
(`Stream/0/1`, whose recorded-row digest alone moves)".

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* docs: fold #325 and #327 into 1.1.0, add State hashes, amend the hash rule

#325 (confirmed-bar streams compute what the batch computes) and #327
(docker/run_json.py --symbol-feeds) merged before the release notes, so
their Unreleased bullets join the 1.1.0 section, rewritten and linked; no
Unreleased heading stays.

- CHANGELOG.md: the lead names the stream fix and, in the pairing
  sentence, codegen 1.1.0's request discovery (transpile_full()["requests"],
  codegen #164). #325's bullet says what a stream user sees; #327's bullet
  and its Report keys entry (applied_runtime.symbol_feeds, the
  --symbol-feeds: failure messages). A new State hashes section lists the
  four recipe additions since v1.0.1 (#315, #316, #319, #325; none removed,
  renamed or re-encoded; domain tags unchanged). #315's range-end
  equity-extreme change moves to the Pine adapter parity bullet as a
  behaviour fix. The #319 bullet named the broker-state hash; the change is
  in the native continuation hash, which the broker-state hash folds. The
  known-issue bullet now says it is fixed in 1.1.0 (#325). Migration gains
  a line on stream results and hashes.
- README.md: the known issue is fixed in 1.1.0 (#325); the v1.1.0 Releases
  line gains the stream fix, request discovery and the harness's
  multi-symbol request.security feeds. Fact markers rendered from the facts
  export that maps releases[1.1.0] to
  pineforge-parity-baseline-20261004-engine-7b596622 (7,951 excellent / 38
  strong of 7,989); the active scoreboard moves to the same baseline, here
  and in docs/pages/contributing-llm.md.
- docs/pages/streaming.md: the known issue affected v1.0.0 and v1.0.1 and
  is fixed in 1.1.0.
- docs/pages/public-contract.md: the state-hash rule, amended by the
  owner's ruling for 1.1.0. It covers the recipe only: a minor release may
  add a hashed field (domain tags unchanged, the added field changing no
  trade or report, disclosed under State hashes); removing, renaming or
  re-encoding a hashed field is a new epoch and a major release; behaviour
  changes follow the normal release and parity rules. The first uses are
  #315 and #316. The semver rule is unchanged.

Replaces text introduced by 7b59662 (#325): CHANGELOG.md's
"Confirmed-bar streams compute what the batch computes:" bullet, and the
"Fixed on main (#325); included in the next release." lines of README.md
and streaming.md; by 4f2a475 (#327): CHANGELOG.md's "Harness symbol
feeds:" bullet; by d093560 (#290): public-contract.md's "State-hash
values are stable within the epoch." and "a new recipe is a new epoch and
a major release"; by a80485c (this branch's first commit): the "Known
issue, as in v1.0.0 and v1.0.1" bullet, streaming.md's "(v1.0.0, v1.0.1,
v1.1.0)", the #319 bullet's "A tick stream's broker-state hash folds the
new accumulator state only where it adds information, so the existing
tick, bar and batch hash pins hold.", the Report keys failure-output
bullet and the v1.1.0 Releases line; by 66be240 and 83d64dc: the lead's
state-hash sentences ("Three changes also change what the hashes fold");
and, as git attributes them through this branch's merge of main, by
e59c09f: README.md's v1.1.0 Releases line and streaming.md's
"(v1.0.0, v1.0.1, v1.1.0)".

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
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