Skip to content

Commit ca0aac5

Browse files
luisleo526claude
andcommitted
Integration: wave F on main a8aeeb2 -- cross-lane reconciliations, floors, anchors (INT16)
The 84 picks of lanes F12, F6, F3, F4, F5, F1, F14, F7, F9, F10 and F2 each carry their own -x line. This commit is what only the merged tree can decide. integration (i), F1 x F5, src/source/pine_scheduler_native.cpp: F5's scheduler_update_session_state selects the kernel's session-day facts and reads neither argument, so F1's retained-input lookahead that fed the old rule (next_aggregated_script_open and next_script_open, the block computing next_script_open_ms) is deleted, and the writer takes no parameters (pine_strategy_host.hpp/.cpp). F1's COOF timing is kept verbatim: the close callback asks only when no recalculation published the bar, a recalculation asks at the bar's first publication. The design rows OT7 and AG3 no longer cite the deleted helpers. integration (ii), F7's orphans outside its files: the declarations of submit_fx_margin_slice, carried_pooc_short_margin_before_script_scope, carried_pooc_short_priced_exit_after_adverse_scope and next_coof_waypoint_price (pine_adapter.hpp), and of the deleted 4-argument entry_stop_first_touch overload (src/engine_internal.hpp), are removed. PineScheduler::next_input_waypoint no longer restates the path-order rule: it asks PineExecutionAdapter::source_path_uses_high_first for the input bar, the kernel's path_high_first over the same spec path_order and the same |H - O| < |O - L| comparison, so every answer is the copy's. integration (iii), doc rows the lanes reported, re-read on the merged tree: - F12's three examples: README's example sentence is count-free and names the new hosts; ADR (twice) and docs/ci.md say eighteen / sixteen C++. - F4's 39 C symbols: README (the count, five new table rows, three callback layouts), index.md (104 PF_API, 39), ADR, native-engine.md; the hash hook, the anchored-level hook, declare_auxiliary_feed and native_sized_units have C routes now (native-engine.md, pine-to-native.md: four members excluded, not eight). - F3's contracts in the headers (comment-only, strip_comments identical): pineforge.h's per-bar hash equals the scalar for every host and the "[F3 will change: ...]" marker is gone; the close-cause derivation, execution.hpp's CloseCause and engine.hpp's exit_from_bracket / close_cause say an armed WaitForApplied close records Bracket through the fill. - integration: F2's d62ff389 rewrote strategy_configure_native_ext_v1's doc to "leaves the host Failed"; F3's dab5e8ea validates first and keeps the handle usable, so the doc states that. F2's d9e972fc said a native bracket leg reads SCRIPT (F3 item 1 made it BRACKET) and listed eight C-less members (F4 left four): both pine-to-native passages restated. - integration: F5's COVERAGE note reasoned from the struct's end; after F4's tail the four bytes sit in the base layout's padding, as it now says, and the decision struct note orders F5's bytes before F4's tail. - F14's ruling: a bucket a session break clips is Confirmed, named beside the session-close clip in native-engine.md's lookahead_off rule. - Stale citations: native_execution_consumer.cpp cites native_run_spec.hpp:560 (F2); scripts/bar_identity_lane.py and src/source/pine_security_eval.cpp cite timeframe.cpp's current lines (F14). - F9: pine_adapter.hpp no longer calls placement rows immutable evidence. - F6's finding 2: the ADR residual section describes the widened vocabulary and the installed-header surface, P2c's paragraph says why its four names are ruled in a residual row, the front doors say the gate reads both. - integration, F6 x F5: check_kernel_residuals called session_ismarket_, session_isfirstbar_ and session_islastbar_ stale (F5 moved them off BacktestEngine); F6's residual row now rules barstate_islast_ alone. integration, F4 x F5 tests: both lanes' sections of tests/test_native_c_api.c defined session_state / session_bars / session_fill / session_on_bar and SESSION_BARS; F5's section is renamed dayfact_* / DAYFACT_*, no check changed. integration, F4 x F6: test_native_c_api_c99 reads P2c's historical spellings on purpose, so it builds with -Wno-deprecated-declarations as test_c_abi does. integration (iv), floors from the rows that register on the merged tree (ctest -N, not summed): release 572 -> 586, kernel 202 -> 213 run (214 registered, the WebSocket row skips); the six CONTRIBUTING.md / contributing-llm.md citations of the two constants carried by hand. integration (v), F10's harness row is NOT wired: python3 -m unittest discover -s benchmarks/tests and benchmarks/check_provenance.py pass on this host (25 tests OK; all 163 headline numbers traced), but in a depth-1 clone -- the checkout .github/workflows/ci.yml uses -- the unit tests fail once and the checker reports 9 errors ("pinned 933fe58:... is not in this clone"), so the row would turn every CI job red. Wiring it needs fetch-depth 0 there first. Doc anchors: check_doc_anchors.py --fix, then reanchor_doc_citations.py over HEAD, fd78592, origin/main and the eleven lane tips (152 carried), then twelve by hand; check_doc_anchors 1625/1625, check_doc_lint TOTAL 0. No epoch moves. No behaviour change beyond the lanes': (i) and (ii) are byte-identical by construction, (iii) is documentation and comment-only headers. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent 3668af9 commit ca0aac5

26 files changed

Lines changed: 508 additions & 489 deletions

‎CONTRIBUTING.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ What each gate refuses:
137137
| `check_c_abi_runtime.py` | a `PF_API` runtime export added or removed without its inventory row |
138138
| `check_native_c_api_surface.py` | a public `NativeStrategyHost` member with no C spelling and no recorded reason |
139139
| `check_native_feature_rulings.py` | a `NativeRunSpec` field the adapter does not declare and the ADR does not rule |
140-
| `check_kernel_residuals.py` | a TradingView-shaped name reaching the kernel archive without an ADR 0001 row |
140+
| `check_kernel_residuals.py` | a TradingView-shaped name reaching the kernel archive or its installed headers without an ADR 0001 row |
141141
| `check_native_cpp_versions.py`, `check_aggregate_cpp_versions.py` | an internal C++ epoch moved without its consumers |
142142
| `check_adapter_spec_shadowing.py` | the adapter setting a kernel field it is ruled not to set |
143143
| `check_twin_parity.py` | a frozen test assertion rewritten instead of a behaviour change being argued |
@@ -149,8 +149,8 @@ What each gate refuses:
149149
### The floors
150150

151151
`ci_verify.py` counts the CTest rows that actually **ran** and fails below a
152-
floor — `KERNEL_MIN_TESTS` ci_verify.py:127 and `RELEASE_MIN_TESTS`
153-
ci_verify.py:168.
152+
floor — `KERNEL_MIN_TESTS` ci_verify.py:143 and `RELEASE_MIN_TESTS`
153+
ci_verify.py:191.
154154
A deleted or silently skipped row is a failure, not a quieter run. If your
155155
change adds rows, raise the floor in the same commit and say by how much; if it
156156
legitimately removes one, lower it deliberately and say why. `--min-tests`

‎README.md‎

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -159,18 +159,19 @@ class HelloKernel : public pineforge::NativeStrategyHost {
159159
// trade_count() / get_trade(i) read the closed rows back.
160160
```
161161
162-
Thirteen more hosts under [`examples/native/`](examples/native/) cover kernel
163-
sizing, anchored brackets on a price grid, trails in ticks, a margin model with
164-
a real liquidation, account risk limits, calculation timing, higher-timeframe
165-
series, an auxiliary finer feed, the open book lot by lot, and a
166-
kernel-recorded report. Each is a CTest row: `ctest --test-dir build -R example_`.
162+
The other hosts under [`examples/native/`](examples/native/) cover kernel
163+
sizing and its fee reserve, anchored brackets on a price grid, trails in ticks,
164+
a margin model with a real liquidation and an FX-curve roll, account risk
165+
limits, calculation timing, higher-timeframe series, an auxiliary finer feed,
166+
the open book lot by lot, per-bar broker-state hashes, and a kernel-recorded
167+
report. Each is a CTest row: `ctest --test-dir build -R example_`.
167168
168169
### 3. C, against the same kernel
169170
170171
Hand the runtime a callback table and drive the kernel from any language with
171172
a C FFI — no C++ in your own code. The complete file is
172173
[`examples/native/hello_kernel_c.c`](examples/native/hello_kernel_c.c); the
173-
34 `strategy_native_*` functions are declared in
174+
39 `strategy_native_*` functions are declared in
174175
[`include/pineforge/native_c_api.h`](include/pineforge/native_c_api.h) and
175176
summarised in [Driving the kernel from C](#driving-the-kernel-from-c) below.
176177
@@ -390,7 +391,7 @@ The gates a pull request passes, one line each:
390391
|---|---|---|
391392
| TradingView parity | `./scripts/check_corpus_parity.sh --subset` | A trade that moved: 30 probes re-run and hashed against `scripts/corpus_parity_baseline.txt`. The full 312-probe sweep (`--subset` dropped) runs nightly. |
392393
| CTest row floors | `ci_verify.py release` / `kernel` | A test row that vanished: each profile counts the rows that actually ran against a floor. |
393-
| Kernel residuals | `scripts/check_kernel_residuals.py` | A TradingView-shaped name reaching the kernel archive without an ADR 0001 row. |
394+
| Kernel residuals | `scripts/check_kernel_residuals.py` | A TradingView-shaped name reaching the kernel archive or its installed headers without an ADR 0001 row. |
394395
| Feature rulings | `scripts/check_native_feature_rulings.py` | A `NativeRunSpec` field the adapter does not declare and the ADR does not rule. |
395396
| C surface | `scripts/check_c_abi_runtime.py`, `scripts/check_native_c_api_surface.py` | A `PF_API` export added without its inventory row; a public host member with no C spelling and no recorded reason. |
396397
| Twin parity | `scripts/check_twin_parity.py` | A frozen assertion quietly rewritten instead of a behaviour change being argued. |
@@ -462,7 +463,7 @@ public set, checked in CI by `scripts/check_c_abi_runtime.py`):
462463

463464
### Driving the kernel from C
464465

465-
`<pineforge/native_c_api.h>` (included by `pineforge.h`) adds **34 further
466+
`<pineforge/native_c_api.h>` (included by `pineforge.h`) adds **39 further
466467
`PF_API` functions** for the other direction: a host that is not written in
467468
C++ hands the runtime a callback table and drives the kernel itself — submit,
468469
replace, cancel, execute, read the book — instead of loading a compiled
@@ -480,10 +481,13 @@ strategy. They are additive; no symbol, struct or behaviour above changes, and
480481
| `strategy_native_events_v1` / `_state_v1` | Poll the recorded event history by ordinal; read the lifecycle and its typed failure |
481482
| `strategy_native_partial_bar_v1` / `_series_bar_v1` / `_trail_state_v1` / `_liquidation_price_v1` | The four optional reads — the bar so far at the cursor, a declared higher-timeframe series' latest bucket, a live trail's projection, the solved liquidation level. Each answers `PF_NATIVE_ABSENT` where the C++ `std::optional` is empty |
482483
| `strategy_native_risk_state_v1` / `_marked_equity_v1` / `_recalculations_v1` / `_continuation_hash_v1` | The generic risk ledger, marked equity at a mark, the driven/suppressed recalculation counters, and the run's continuation identity |
484+
| `strategy_native_margin_call_v1` | One margin call's whole economics by its event ordinal (`pf_native_margin_call_v1`: mark, units, the position before and after, the surviving book's equity and requirement, the re-solved liquidation price) |
485+
| `strategy_native_sized_units_v1` | The units a `PF_NATIVE_INTENT_SIZED` request resolves to under the run's spec — the kernel's own sizing function, as a pure query before submitting |
483486
| `strategy_native_cohort_open_v1` / `_add_v1` / `_remove_v1` | Cohort rosters: a cohort close is `PF_NATIVE_INTENT_HOST_SIZED` owned by `PF_NATIVE_OWNER_BIND_COHORT`, sized by the `on_close_units` hook |
484-
| `strategy_native_declare_subscriptions_v1` | Declare the run's higher-timeframe series from inside `on_run_begin`, replacing the staged list |
487+
| `strategy_native_declare_subscriptions_v1` / `_ext_v1` | Declare the run's higher-timeframe series from inside `on_run_begin`, replacing the staged list; `_ext_v1` adds a series source per row and writes the kernel's typed refusal (`pf_native_spec_error_e` and its field) |
488+
| `strategy_native_declare_auxiliary_feed_v1` | Declare, replace or withdraw the run's auxiliary finer feed from inside `on_run_begin`, with the same typed refusal |
485489
| `strategy_configure_native_ext_v1` | Configure from `pf_native_run_spec_v1` **plus** `pf_native_run_spec_ext_v1` (report policy, price grid, calculation timing, open-bar view, margin model, higher-timeframe subscriptions, generic risk limits, the auxiliary finer feed, the retained intrabar path, and the slot-label / feed-tolerance / path-order / abort-reporting policies). The two specs' nine enum-valued words stay `uint32_t` and each has a C enumeration: `pf_native_fee_kind_e`, `pf_native_close_execution_e`, `pf_native_open_directions_e`, `pf_native_report_policy_e`, `pf_native_price_grid_e`, `pf_native_grid_rounding_e`, `pf_native_calc_trigger_e`, `pf_native_open_bar_view_e`, `pf_native_liquidation_sizing_e` |
486-
| `strategy_native_append_auxiliary_bars_v1` | Append a realtime stream's later bars to the run's declared auxiliary finer feed |
490+
| `strategy_native_append_auxiliary_bars_v1` / `_ext_v1` | Append a realtime stream's later bars to the run's declared auxiliary finer feed; `_ext_v1` writes the typed append refusal (`pf_native_append_error_e`) and the bar it stopped on |
487491
| `strategy_native_declare_opened_lot_entry_bar_mask_v1` | From inside `on_applied`, say where the fill that opened a lot sat on its entry bar (`pf_native_opened_lot_fill_point_e`: on the bar's path, or after it); the kernel derives the lot's entry-bar mask that `on_lot_excursion`'s facts carry back |
488492
| `strategy_native_api_version` | This surface's layout version (`PF_NATIVE_API_VERSION`) |
489493

@@ -501,12 +505,13 @@ layout the lane first shipped (`PF_NATIVE_RUN_SPEC_EXT_V1_BASE_SIZE`), the same
501505
struct with L9's appended risk tail (`PF_NATIVE_RUN_SPEC_EXT_V1_RISK_SIZE`), that
502506
plus N8's intrabar / policy tail (`PF_NATIVE_RUN_SPEC_EXT_V1_POLICY_SIZE`) and the
503507
current one with the auxiliary-feed tail behind it; `pf_native_callbacks_v1`
504-
has two — the layout the lane first shipped (`PF_NATIVE_CALLBACKS_V1_BASE_SIZE`)
505-
and the same struct with its appended tail. The runtime accepts each, so a host
508+
has three — the layout the lane first shipped (`PF_NATIVE_CALLBACKS_V1_BASE_SIZE`),
509+
that plus its six-hook tail (`PF_NATIVE_CALLBACKS_V1_HOOKS_SIZE`) and the
510+
current one with the policy-hook tail behind it. The runtime accepts each, so a host
506511
compiled against an earlier one keeps working unchanged. An **observation**
507512
callback that returns non-zero latches
508-
`NativeFailureCode::CallbackException` and ends the run `Failed`; the four
509-
**answering** hooks in the table's tail instead return a `pf_native_answer_e`
513+
`NativeFailureCode::CallbackException` and ends the run `Failed`; the
514+
**answering** hooks in the table's two tails instead return a `pf_native_answer_e`
510515
choosing whose answer the kernel uses, and can never fail the run. Streaming
511516
needs no new symbol: the `strategy_stream_*` family takes these handles
512517
unchanged. Worked example: [`examples/native/hello_kernel_c.c`](examples/native/hello_kernel_c.c);

0 commit comments

Comments
 (0)