Skip to content

Commit e6f8fcb

Browse files
committed
CR-150 batch-C: base fix, wiring W1-W3 + L22P, and the .bin selected-window capability
This is the single-parent proof/squash commit for batch-C on a35a64c. It supersedes d43257f (the earlier proof head of the same base fix, tree 06abb8c) and carries that tree plus everything the batch-C branch assembled after it: merges of W1 (2995a52), W2, W3 and L22P, the .bin bar input spec (637816a, fafb2c6) and the selected-window capability commit e0f2086 (core/cr150-swcap, CORE-TOP's order of 2026-10-20 22:23), all on top of the base fix below. Tree 2099d0d; branch head e0f2086. The batch-C base (3af3e3c, on a2f3dfd) is red in the lab preflight in four stages, and every lane on it inherits the red. This commit fixes the three mechanical stages in place; the fourth is settled by naming, per CORE-TOP's ruling of 2026-10-20 20:03 (no history rewrite; a single-parent proof commit with this tree and parent a35a64c carries the block below in its own message). Counts, each re-derived from the check scripts rather than typed: - EXPECTED_PUBLIC_DECLARATIONS 106 -> 107 and EXPECTED_RUNTIME_IMPLEMENTATIONS 86 -> 87 in scripts/test_ci_verify.py:1206-1207, matching scripts/check_c_abi_runtime.py (107 across the runtime headers, 87 runtime implementations, 96 C declarations in pineforge.h, which this change does not touch) and the "87 above" comment the same script carries. - The five pages with stale counts (docs/pages/index.md:142/:153/:175, docs/coverage.md:135, docs/design/native-feature-parity.md:178/:330, docs/pages/abi-stability.md:73/:132) were renumbered to the derived values (95->96 declarations, 86->87 implementations). - 63 stale file:line anchors across nine documents were re-anchored to the symbol that actually sits on the cited line, and each edit names the symbol next to the number so the citation is checkable by reading. Checks run on this tree (pure-Python doc checkers only; nothing was compiled, built or run on the Mac): - scripts/check_doc_anchors.py rc 0: 2173/2173 anchors resolve to their symbol (re-measured on this tree, which carries the .bin spec's citations). - scripts/check_doc_lint.py rc 0: 0 offenders. - scripts/check_c_abi_runtime.py rc 0. - scripts/check_doc_reverts.py: rc 1 on the batch-C branch (17 unnamed deletions there, 16 of them eadd9b3's and one introduced by 637816a; none from e0f2086); rc 0 on the single-parent squash of this tree, whose judged range collapses the branch's intermediate commits. The deletions the squash diff still shows are named in the blocks below, copied verbatim from lanes/core-cr150-batchc/DOC-REVERTS-NAMES.txt. Not verified here: verifier-tests, the build, and the corpus. The lab preflight on the single-parent proof commit is the next step. DOC-REVERTS NAMES (copy this block verbatim into the body of every proof commit and the squash body that carries the arena-bound documentation) Documentation sentences named as removed on purpose. The sentences were introduced by d7d8bd3 (CR-150 certified bound: one pure arena_bound function, its derivation doc, vectors, harness and corpus census) and deleted by eadd9b3 (CR-150 certified bound round 3: childPrivate is reported, not routed; escalation policy; compiler-facts table). They are in docs/design/arena-bound.md and docs/design/arena-bound-corpus-census.md. Cause: the rulings of 2026-10-20 17:17 (COMPUTE-TOP and L6), applied by that round: (1) childPrivate stays reported but leaves unboundedTerms, the top-level unbounded flag and its reason; (2) interim 1.7.0 sizing is COMPUTE's escalation policy (attempt 0 default arena, a typed arena_exhausted re-places up the ladder, escalation cap 2, never charged), and an unbounded term does NOT route a run to the largest rung and disk; (3) nothing is run on the Mac, so the census reproduction block no longer names a ctest command and instead gives a reading-only re-run recipe. The removed sentences, by their opening words: 1. "The engine HEAD inspected is" (census intro; rewritten as "The original census inspected engine HEAD" plus a round-3 paragraph). 2. "currently unavailable facts, each known probe has all four names in" (census; now "the three sizing names"). 3. "Term | Flagged unbounded/unknown for routing | Proved unbounded | UNCLASSIFIED" (census table header; now "Sizing term | Flagged unbounded/unknown ...", routing wording removed by ruling 2). 4. "certificate. Thus even a later finite arena proof does not automatically make an entire invocation bounded." (census; now says the three-term verdict needs OHLCV and finalizer-stream facts, private diagnostics do not prevent it). 5. "Extra feeds, output/trace/hash counts and private RSS/AS proofs are classified independently, and each missing proof names its term." (census; private RSS/AS is now a separate informational term). 6. "probe list, and counts for each name in unboundedTerms. Missing input or unclassified coverage makes the full lab test fail." (census; now three names plus an informational childPrivate count; the harness still fails on missing input or unclassified coverage, tests/test_arena_bound.py corpus_run). 7. "Linux lab reproduction, after the pinned corpus is available locally:" and the line "ctest --test-dir build-arena -R '^test_arena_bound_corpus$' -V" (census; replaced by the reading-only re-run section, ruling 3). 8. "The first command only reads sources/sidecars and prints classifications. It exits nonzero on unclassified entries. The second performs the real arena-attached runs and writes census/measurements under build-arena/arena-bound/; it does not pass an all-unknown census. Neither command was run by this edit-only lane." (census; replaced by the expanded description of the census-only command and a link to arena-bound.md for lab verification). 9. "M={arena,ohlcv,finalizerStream,childPrivate}. Unknown is not yes." (census; now M={arena,ohlcv,finalizerStream} plus a separate childPrivate note). 10. "unboundedTerms: [arena?, ohlcv?, finalizerStream?, childPrivate?]," (arena-bound.md result shape; childPrivate removed by ruling 1). 11. "unboundedTerms uses the displayed order and contains every term whose own flag is true. reason is empty when every term has a certified finite value." (arena-bound.md; now only the three sizing terms and an independent informational childPrivate flag). 12. "APP routes any true top-level flag to its largest rung and disk backend, as the owner requires. It must retain the named unresolved terms in its plan." (arena-bound.md; removed by ruling 2). 13. "That routing decision does not prove that an arbitrarily chosen finite disk arena suffices for a mathematically unbounded computation. No such disk-size guess is returned here. Resolving that case without capacity refusal requires an owner/runtime policy: RETURN TO CORE-TOP." (arena-bound.md; replaced by the escalation-policy paragraphs, ruling 2). 14. "P_rss, P_as | Child private resident / address-space terms; each needs its own proof." (arena-bound.md table row; now "Informational child private ... Neither affects sizing routing"). 15. "flag is false." and "the term remains unbounded. A vector with 4096/8192 private bytes tests only arithmetic/flag transport under a hypothetical trusted proof; those numbers are explicitly not real engine coefficients." (arena-bound.md; vectors recomputed in round 3 without the childPrivate toy proof). 16. "RETURN TO CORE-TOP: obtain the applicable post-port measurements and an AS/strategy-private bound before claiming a fully finite invocation." and the rows "All terms | Same Unicode arena. Primary one-page RSS/two-page AS ..." and "Unbounded emitting loop | Null arena inputs except E=2; no finite guessed size. Other absent term proofs remain separately named." and "and cause incomplete coverage to fail. Every measured run prints actual," (arena-bound.md vector tables and verification text, recomputed or reworded in round 3). Each of these deletions was intended by round 3 of lane core-cr150-l22u (design change above); none is a silent revert. SECOND NAMES BLOCK (four further deletions in the proof range a35a64c..this commit) Relative to the integration commit a35a64c, this proof commit's diff also shows four sentence-level rewrites that check_doc_reverts reports as unnamed deletions. Each was an intended replacement by batch work, not a silent revert: A. docs/pages/run-failure-codes.md: "The engine could not create or write the report sink." and "The run has no completed sink or valid trailer." were introduced by 39a718b (cr150 L6b-1, #431) and replaced in commit 573fa74 (CR-150 catalog: report_sink_failed is class engine_fault) by the expanded row, which states the same meaning, keeps the closing words "the run has no completed sink or valid trailer", and adds the optional arguments. B. docs/design/cr150-contracts.md: "A selected sink performs one presentation of the full selected curve, preserving the hook's published-length changes before the selected writer emits the anchor and final window observations." was introduced by 76e2310 (CR-150 L6b-2, #435) and replaced in commit 83fda84 (CR-150 L17b: streamed selected capture with a bounded tail window W=2) by the tail-window contract under CORE-TOP's ruling A; that commit's own body already names this sentence. C. docs/design/native-feature-parity.md: the hash-pinned citation unit beginning "`sha256:H` c_abi.cpp:N, `sha256:H` check_c_abi_runtime.py:N, ..." was introduced by d3cca9e (5c3c9ae) and rewritten by this branch's count/anchor refresh: every affected row keeps its claim and its evidence and updates the citations to the lines that hold the named symbols now. None was a silent revert. Each replacement is named by the commit that made it; this proof commit names them again because the single-parent proof collapses the branch's intermediate commits out of the judged range. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
1 parent a35a64c commit e6f8fcb

126 files changed

Lines changed: 22325 additions & 877 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎CMakeLists.txt‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ set(PINEFORGE_SOURCE_LAYER_SOURCES
9898
src/source/magnifier_intrabars.cpp
9999
src/source/market_admission.cpp
100100
src/source/pine_adapter.cpp
101+
src/source/pine_position_tail.cpp
101102
src/source/pine_path_resolve.cpp
102103
src/source/pine_scheduler_native.cpp
103104
src/source/pine_scheduler.cpp
@@ -155,9 +156,11 @@ set(PINEFORGE_KERNEL_SOURCES
155156
src/native_bar_views.cpp
156157
src/selected_report_view.cpp
157158
src/selected_window_plan.cpp
159+
src/metrics_spill_curve.cpp
160+
src/report_scratch.cpp
161+
src/scratch_arena.cpp
158162
)
159-
# The kernel-only archive. Same objects, same flags as the kernel half of
160-
# libpineforge.a — a consumer that never speaks Pine links this one.
163+
# The kernel-only archive: libpineforge.a's kernel objects and flags, for consumers that never speak Pine.
161164
add_library(pineforge_kernel STATIC ${PINEFORGE_KERNEL_SOURCES})
162165
add_library(PineForge::kernel ALIAS pineforge_kernel)
163166
# So a find_package(PineForge) consumer spells it the same way an in-tree one

‎README.md‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ The separate PineForge compiler, [`pineforge-codegen`](https://github.com/pinefo
3333
- **Open runtime.** The engine and native live runner are Apache-2.0. The separately distributed [PineForge compiler](https://github.com/pineforge-4pass/pineforge-codegen-oss/blob/main/LICENSE) is source-available under the PineForge Source License 1.2 from its release 1.3.0 (release 1.2.0 keeps the PineForge Source License 1.1, and releases up to 1.1.0 keep the PolyForm Noncommercial terms they shipped with); personal trading is free, and commercial use requires a separate license; the capital in an account a proprietary-trading firm or funded-trader program provides or allocates, including a challenge, evaluation or simulated account, is investment capital. Public reference strategies, benchmarks and validation tooling are available in their respective repositories; the community-script test set is not redistributed.
3434
- **Fast.** In-process, no interpreter: median **36× faster than PyneCore** on the 200 strategies both engines time (100 corpus probes and 100 held-out private strategies), measured at engine `35db01c8` on 2026-09-29 on an AWS c7a.8xlarge with PyneCore timed as a subprocess, its interpreter start-up included (PineForge runs a median 807k bars/s per strategy over its 201 slots with the bar magnifier on; [method](benchmarks/results/speed.md)). Parameter sweeps re-run a loaded `.so` with new inputs — no recompile, no fork.
3535
- **Deterministic to the bit.** Two runs with the same inputs produce identical trade lists. Same on Linux and macOS.
36-
- **Yours to embed.** 149 `PF_API` declarations across six installed headers — `pineforge.h`'s 95 (75 of the 84 runtime exports, the other nine being declared in `execution_observer.h`, `selected_window.h` and `report_sink.h`, three each, and up to 20 per-strategy functions a generated module defines), `native_c_api.h`'s 43 native-host declarations and `selected_window_plan.h`'s two planner declarations — an ABI that is append-only within a major version from 1.0 on. Call it from C, Python, Rust, Go, Node, Julia — or let an AI agent drive it over MCP.
36+
- **Yours to embed.** 152 `PF_API` declarations across six installed headers — `pineforge.h`'s 96 (76 of the 87 runtime exports and up to 20 per-strategy functions a generated module defines), eleven more runtime declarations in `execution_observer.h`, `selected_window.h` and `report_sink.h` (three, three and five), `native_c_api.h`'s 43 native-host declarations and `selected_window_plan.h`'s two planner declarations — an ABI that is append-only within a major version from 1.0 on. Call it from C, Python, Rust, Go, Node, Julia — or let an AI agent drive it over MCP.
3737

3838
Recorded outputs and their additional API declarations described here are
3939
part of **1.5.0**.
@@ -519,11 +519,11 @@ is in [CHANGELOG.md](CHANGELOG.md).
519519

520520
The counts below describe the current API, including recorded outputs and the report sink; recorded outputs are not part of 1.4.0.
521521

522-
A newly generated strategy `.so` exposes 100 compiled-strategy `PF_API` declarations
523-
(84 runtime implementations plus sixteen generated exports) plus 43 native-host
524-
declarations: 143 `PF_API` exports in total; `use_bar_magnifier = true` adds
522+
A newly generated strategy `.so` exposes 103 compiled-strategy `PF_API` declarations
523+
(87 runtime implementations plus sixteen generated exports) plus 43 native-host
524+
declarations: 146 `PF_API` exports in total; `use_bar_magnifier = true` adds
525525
`strategy_declares_bar_magnifier` and a module that records [outputs](docs/outputs.md) its
526-
three outputs exports, bringing the inventories to at most 104 and 147. Older modules lack the six opt-in
526+
three outputs exports, bringing the inventories to at most 107 and 150. Older modules lack the six opt-in
527527
[checked-settings exports](docs/checked-settings.md). Older modules can also lack
528528
the two opt-in [execution-capability exports](docs/strategy-capabilities.md).
529529
In an optimized build `nm -gU` also shows libc++'s
@@ -552,6 +552,7 @@ inventories are pinned by `scripts/check_c_abi_runtime.py`:
552552
| `strategy_set_account_currency_fx_series` | Effective-time quote-to-account FX |
553553
| `strategy_get_last_error` | The latest runtime error |
554554
| `strategy_get_last_error_code` / `strategy_get_last_error_args` | The latest failure's stable code from the closed [run-failure vocabulary](docs/pages/run-failure-codes.md) (`""` when the run succeeded) and its typed arguments as canonical JSON; behind `PINEFORGE_HAS_RUN_FAILURE_CODES_V1` |
555+
| `pf_report_scratch_arena_stats` | Process-wide scratch-arena peak claimed bytes and exact supplied size; query after finalization and before detach for stdout diagnostics, outside sink bytes |
555556
| `pf_version_get` / `pf_version_string` / `pf_abi_version` | Runtime version, version string, struct-layout version (`PF_ABI_VERSION == 4`) |
556557
| `strategy_execution_contract` / `strategy_configure_native_v1` / `strategy_configure_native_fx_curve_v1` / `_fx_curve_ext_v1` | Query Legacy vs NativeMarketV1; apply the versioned native run specification (an invalid or refused base call returns `-1` and leaves the handle Failed; a cooperative `Aborted` handle may be reused with the same key and a higher run number); stage or clear an immutable native FX curve, `_fx_curve_ext_v1` also writing the typed refusal (`pf_native_fx_curve_error_e`) and the offending point's index |
557558
| `strategy_request_abort` / `strategy_last_run_status` | Cooperative abort of a run in progress; `0`=completed, `1`=aborted |

‎docker/pf_sink.py‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
"""Strict, streaming pf-report-sink version-1 reader (CR-150 DESIGN 3.7/4.4).
22
33
Use ``with SinkReader(path) as reader:`` and consume the iterator to its end.
4+
For a blocking binary file or pipe, use ``SinkReader(stream=file)`` instead;
5+
no seek is required. The reader owns and closes either input on completion,
6+
refusal or context exit. Supply exactly one of path and stream.
47
Each Record has a tag, an immutable values tuple and as_dict(). Records are
58
provisional until exhaustion verifies the trailer; complete is then True and
69
trailer/sha256 contain the verified receipt. A caller that stops early has no
@@ -232,7 +235,9 @@ def _field(value: Any, wire_type: str) -> Any:
232235
class SinkReader:
233236
"""One-pass, bounded-memory iterator. Exhaustion verifies the entire sink."""
234237

235-
def __init__(self, path: str | Path):
238+
def __init__(self, path: str | Path | None = None, *, stream: BinaryIO | None = None):
239+
if (path is None) == (stream is None):
240+
raise TypeError("supply exactly one of path and stream")
236241
self.header: dict[str, Any] = {}
237242
self.trailer: dict[str, Any] | None = None
238243
self.complete = False
@@ -242,7 +247,7 @@ def __init__(self, path: str | Path):
242247
self._file: BinaryIO | None = None
243248
self._failed = False
244249
try:
245-
self._file = open(path, "rb")
250+
self._file = stream if stream is not None else open(path, "rb")
246251
value, line = self._readline()
247252
self._descriptors = _header(value)
248253
self._counts = {tag: 0 for tag in self._descriptors}

‎docker/pineforge-sink-finalize‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env python3
2+
"""Install beside pineforge_sink_finalize.py and pf_sink.py, with mode 0755."""
3+
import sys
4+
5+
sys.dont_write_bytecode = True
6+
if sys.flags.isolated:
7+
from pathlib import Path
8+
9+
sys.path.insert(0, str(Path(__file__).resolve().parent))
10+
11+
from pineforge_sink_finalize import main
12+
13+
raise SystemExit(main())

0 commit comments

Comments
 (0)