Skip to content

Commit a35a64c

Browse files
luisleo526claude
andauthored
CR-150 batch A: L9c + L19o + L19n (integration) (#457)
* cr150 l19lb: executor result for CR-150 lane l19lb (supervisor commit) Edit-only Codex executor output committed by the supervisor on integration b3c3923. Design, tests, wiring and the compile audit are in the lane's REPORT.md. Not yet proven on the lab; the four-step proof and any parity sweep follow on a squash proof commit. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> * cr150 l19lc: executor result for CR-150 lane l19lc (supervisor commit) Edit-only Codex executor output committed by the supervisor on integration b3c3923. Design, tests, wiring and the compile audit are in the lane's REPORT.md. Not yet proven on the lab; the four-step proof and any parity sweep follow on a squash proof commit. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> * cr150 l9c: executor result for CR-150 lane l9c (supervisor commit) Edit-only Codex executor output committed by the supervisor on integration b3c3923. Design, tests, wiring and the compile audit are in the lane's REPORT.md. Not yet proven on the lab; the four-step proof and any parity sweep follow on a squash proof commit. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> * cr150 l19l: executor result for CR-150 lane l19l (supervisor commit) Edit-only Codex executor output committed by the supervisor on integration b3c3923. Design, tests, wiring and the compile audit are in the lane's REPORT.md. Not yet proven on the lab; the four-step proof and any parity sweep follow on a squash proof commit. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> * cr150 l9c: portable report sink (named temp file, per-reader offsets), sink canary line, keep-sink switch (fix round 1) The temporary report sink is a named mode-0600 file unlinked at close, so every SinkReader opens its own descriptor on Linux and Darwin (no /proc/self/fd or /dev/fd branch). run_strategy.py prints `sink_canary: probe=<id> bytes=<n> records=<n> trades=<n> ok` per probe and PINEFORGE_KEEP_REPORT_SINK keeps the sink file of the named probes (or all). Co-Authored-By: Claude Sonnet 5.5 <[email protected]> * cr150 l19m: exit-phase store on disk, release empty cohort maps and rosters (executor result) The closed-trade exit phase byte vector (one byte per closed-trade index) moves to a ScratchFile-backed ExitPhaseStore with one fixed 4 KiB page. The cohort live_units_by_origin map (104 B per distinct entry id) and the opened roster vector (24 B per id) are released as soon as they are empty. Written on the old base; merged onto the L19l head in the next commit. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> * cr150 l19n: kernel calendar memo and certified-cycle ring reserve their span buffers once (executor result) The session-day memo (64 direct-mapped slots) and the certified-cycle ring (4 entries) were already fixed-size; what grew was the heap each slot owned, one span buffer per new day until the table filled. Every slot's buffer is now reserved once to a proven per-day bound (session_day_span_bound) and only assign()ed afterwards, so live heap is constant. Table geometry, slot function and eviction rule are unchanged. Two new source-free tests compare against the memo-free calendar. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> * cr150 l9c: per-run canary log for full and subset sweeps, canary also checks the E records against the engine receipt (fix round 2) scripts/run_corpus.sh and scripts/check_corpus_parity.sh keep the sink_canary:/sink_kept: lines of every probe, passing or failing, in one PINEFORGE_CANARY_LOG (unset: no log I/O, behaviour unchanged). New scripts/check_sink_canary_log.py requires exactly one well-formed ok canary per probe of the sweep's own list. run_strategy.py reads the engine's receipt count_e from the live handle and the canary compares the E records a fresh strict read decodes against it; the line gains `equity=<n>` before the verdict. The DESIGN 3.11 wording for the named temporary sink is in the design folder, outside this tree. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> * cr150 l19l+l19m: round-2 fixes: exit-phase store and kernel roster store removed, coded throws, portable fault injection, comments restored, citations refreshed The exit-phase byte vector returns to its base form (its windowing is L8c's); KernelRosterStore is removed (cohort_exists is a range check plus the map); the two uncoded throws in pine_adapter.cpp now carry run-failure codes (report_sink_failed for a corrupt scratch cohort record, engine_invariant for a fixture backend selected after use); the fixture lifecycle is explicit and tested; the Pine prefix of 18 literals in id_pair_store.hpp (kernel-residuals check) is removed; fault injection opens the file by path instead of /dev/fd; the orphan fixture and a stale process comment are removed; the four deleted comment sentences of the base are restored; two witnesses (live settlement capacity release, part C typed failure) are added; 426 doc citations across seven documents are refreshed (digits only). Co-Authored-By: Claude Sonnet 5.5 <[email protected]> * docs: re-anchor file:line citations after merging integration 5022017 Digits only, no prose changed: every citation into a file this lane or L8c changed was recomputed from the final tree. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> * cr150 l19l: reversal cancels exits of every known cohort id again, not only the resident ones (behaviour fix, witness test) L19l-A's disk-resident cohort table made the reversal cancellation loop (on_applied, full close) visit resident rows only, while a spilled cohort with no exposure can still own queued exits; cancellation is an action over the id, so spilling an eligible row suppressed it and changed command events, pending requests, hashes and later trades. The loop now snapshots the same two exemptions as the base (the applied snapshot's source id and any live entry opening on the new side) and streams every logical id in lexicographic order through the new DiskResidentIdTable::for_each_sorted_id, without restoring facts or building a history-sized vector. tests/test_adapter_reversal_storage.cpp runs a live reversal fixture with capacity release and cohort eviction on and off against the retained-storage run, comparing every trade field, recorded and callback hashes and the final hash. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> --------- Co-authored-by: Claude Sonnet 5.5 <[email protected]>
1 parent 5022017 commit a35a64c

47 files changed

Lines changed: 6420 additions & 436 deletions

Some content is hidden

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

‎docker/run_json.py‎

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5282,30 +5282,37 @@ def _new_report_sink(lib, state, args):
52825282

52835283

52845284
class _TemporaryReportSink:
5285-
"""An unlinked file, addressed by a private path for the engine's path ABI.
5286-
5287-
TemporaryFile uses O_TMPFILE or unlinks immediately. The descriptor path
5288-
lets the engine open that file with its existing path-only API; no named
5289-
sink, new wire format or public fd API is introduced. Keep the owner open
5290-
until both report_free and strategy_free have returned.
5285+
"""A named, owner-only (0600) temporary file, addressed by its real path.
5286+
5287+
The engine opens the path itself with its existing path-only API
5288+
(O_WRONLY | O_CREAT | O_TRUNC, no O_EXCL: src/report_sink_writer.cpp), so
5289+
the empty file created here is accepted and truncated by it. Every reader
5290+
opens the same path again and so owns its offset. No descriptor path
5291+
(/proc/self/fd, /dev/fd) is used: Darwin's /dev/fd/N is a dup that shares
5292+
the file offset. No named sink, new wire format or public fd API is
5293+
introduced. close() unlinks the file and may be called again, unless
5294+
``keep`` is set (the harness's test-only artifact switch). Keep the owner
5295+
open until both report_free and strategy_free have returned.
52915296
"""
52925297

52935298
def __init__(self, lib, state, *, directory=None, run_id=""):
52945299
self.directory = os.fspath(directory) if directory is not None else tempfile.gettempdir()
52955300
self.header, self.counts, self.sha256 = {}, {}, ""
5301+
self.keep, self.closed = False, False
52965302
try:
5297-
self.file = tempfile.TemporaryFile(mode="w+b", dir=self.directory)
5303+
handle, path = tempfile.mkstemp(prefix="pineforge-report-sink-", suffix=".sink",
5304+
dir=self.directory)
52985305
except OSError as error:
52995306
raise RunFailure("report sink open failed", "report_sink_failed") from error
5307+
self.path = os.path.abspath(path)
53005308
try:
5301-
directory_path = "/proc/self/fd" if sys.platform.startswith("linux") else "/dev/fd"
5302-
self.path = f"{directory_path}/{self.file.fileno()}"
5309+
os.close(handle) # the engine and every reader open the path themselves
53035310
descriptor = ReportSinkC(ctypes.sizeof(ReportSinkC), 1, os.fsencode(self.path),
53045311
run_id.encode("utf-8"), os.fsencode(self.directory))
53055312
if lib.strategy_set_report_sink_v1(state, ctypes.byref(descriptor)) != 0:
53065313
raise _engine_invariant("the fresh strategy refused its temporary report sink")
53075314
except BaseException:
5308-
self.file.close()
5315+
self.close()
53095316
raise
53105317

53115318
def verify(self, lib, state, report):
@@ -5340,7 +5347,13 @@ def records(self, tag=None):
53405347
raise _engine_invariant(f"the engine's report sink is invalid: {error}") from error
53415348

53425349
def close(self):
5343-
self.file.close()
5350+
if not self.closed:
5351+
if not self.keep:
5352+
try:
5353+
os.unlink(self.path)
5354+
except FileNotFoundError:
5355+
pass
5356+
self.closed = True
53445357

53455358

53465359
def _free_sink_run(lib, state, report, sink):

‎docs/adr/0001-kernel-adapter-boundary.md‎

Lines changed: 30 additions & 30 deletions
Large diffs are not rendered by default.

‎docs/design/cr150-contracts.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ references; L15a must maintain these anchors and mechanically pin every current
218218
| Lower-path digest (count first) and continuation hash | `native_intrabar_path_digest` `src/native_run_spec.cpp:891-919`; `native_intrabar_path_digest` `src/native_execution_consumer.cpp:289` | 371,1223-1224 |
219219
| Per-script-bar lower-path binary search/walk | `candidate` `src/native_execution_consumer.cpp:8686-8719` | 371,1225 |
220220
| Scheduler sub-bar lookup and one-bar look-ahead | `PineScheduler::lower_path_bar_at` `src/source/pine_scheduler_native.cpp:265-287`; `next_open` `src/source/pine_scheduler_native.cpp:328-329` | 371,1226-1227 |
221-
| Lower-path emptiness test | `inactive_sampler_path` `src/source/pine_adapter.cpp:3431-3435` | 371,1228 |
221+
| Lower-path emptiness test | `inactive_sampler_path` `src/source/pine_adapter.cpp:3430-3434` | 371,1228 |
222222

223223
Every count/digest must fold the same bytes/order for copied and borrowed
224224
feeds, including cached and uncached paths (2.2:372-375). Views replace storage;

‎docs/design/native-feature-parity.md‎

Lines changed: 100 additions & 100 deletions
Large diffs are not rendered by default.

‎docs/native-refactor-progress.md‎

Lines changed: 6 additions & 6 deletions
Large diffs are not rendered by default.

‎docs/pages/market-admission.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ broker `OpeningReceipt` Check/Exempt decision, which belongs to a committed fill
2525
Three historical placement views are fixed when an order is placed and kept in
2626
the adapter's placement snapshot (`projection_after_close`,
2727
`projection_over_pyramiding`, `projection_opposite_market_predecessor`
28-
pine_adapter.hpp:310-312):
28+
pine_adapter.hpp:302-313):
2929

3030
- The prior-close view compares the original accepted-close
3131
quantity with the existing quantity tolerance. This describes a source-time

‎docs/pages/native-engine.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ five commands through `strategy_native_submit_v1` / `_replace_v1` /
502502
kernel from C* below.
503503
504504
`native_order::Request` values belong to `native_order_v7`
505-
(`native_order.hpp:25`); identity types stay `native_order_v1`. Label/comment
505+
(`native_order.hpp:27`); identity types stay `native_order_v1`. Label/comment
506506
remain inert text. The market default path still constructs from:
507507
508508
- `order_action::Transact{signed_units}` — finite nonzero
@@ -1496,7 +1496,7 @@ adapter answers `margin_check_allowed` with TradingView's scheduling — which
14961496
includes the post-exit re-size: when a priced bracket leg of the script bar
14971497
fills, the slice resting at that bar's adverse extreme was sized on the
14981498
pre-exit book, and the legacy broker cancelled and re-scheduled it there
1499-
(`margin_check_allowed` `pine_adapter.cpp:17890-17923`), so the adapter admits
1499+
(`margin_check_allowed` `pine_adapter.cpp:17894-17927`), so the adapter admits
15001500
the kernel's own point for that driver point while (and only while) a slice
15011501
rests —
15021502
`resolve_margin_requirement` with its ten-significant-digit money and
@@ -2047,11 +2047,11 @@ The kernel never drops an event its own live state still reads. A queued
20472047
applied notification (and the margin receipt it carries) pins the window at
20482048
its execution, a live deferred group-adjustment chain pins it at its head,
20492049
and the rest of what the journal used to answer is state now: a request's
2050-
replace-chain root is `RequestDefinition::root` (`native_order.hpp:736`) and
2050+
replace-chain root is `RequestDefinition::root` (`native_order.hpp:738`) and
20512051
the order core's chain index, which is all a cohort command reads about a
20522052
request that is no longer working; a trail's arm ordinal
20532053
(`NativeTrailState::activation_ordinal`) is its tracking state's
2054-
(`TrailTrack` `native_order.hpp:650`); the FX-roll margin check reads the
2054+
(`TrailTrack` `native_order.hpp:652`); the FX-roll margin check reads the
20552055
last two driver points' instants; and a group-effect receipt whose outcome
20562056
event was dropped stands on its own record. A host that wants the whole run
20572057
after it has ended asks for `Full` (or `Commands`); the Pine adapter declares
@@ -3696,7 +3696,7 @@ The Pine adapter emits `Sized` for the default-quantity entries above and no
36963696
Pine/generated hosts derive from `pineforge::source::PineStrategyHost`, which
36973697
derives from `NativeStrategyHost`; handwritten native hosts also derive from
36983698
`NativeStrategyHost`. The source adapter/scheduler hash domain is
3699-
`kSourceAdapterDomain` `pine_adapter.hpp:43`
3699+
`kSourceAdapterDomain` `pine_adapter.hpp:46`
37003700
(`"pineforge-source-adapter/v4"`), while the public C ABI remains version 4.
37013701

37023702
The ownership switch is complete: the compatibility loop and the source

0 commit comments

Comments
 (0)