Skip to content

Commit e9ad37d

Browse files
luisleo526claude
andcommitted
The trail-seed witness pins the absent seed without a host's digest
native_continuation_hash() is not portable. It folds the run's timezone identity, and hash_tz_identity folds the host's zoneinfo ROOT PATH plus the tz resource paths under it: tzdir_canonical() resolves /var/db/timezone/zoneinfo on Darwin -- which realpaths through the installed tzdata release, e.g. /private/var/db/timezone/tz/2026c.1.0/zoneinfo -- and /usr/share/zoneinfo, or $TZDIR, under glibc. So the same kernel over the same bars, booking the same rows at the same prices, answers a different digest per host. Measured: the two controls answer 7148617029230866814 / 1059492877796320724 on Darwin and 3087945503312965943 / 5990633458242713781 on Linux (both aarch64, so it is not the ISA), and on ONE Linux host copying /usr/share/zoneinfo elsewhere and pointing $TZDIR at the copy moves every digest in this unit while every row, exit price and position stays put. expectation corrected: kControlContinuationA/B == the control's digest -> same-host properties of the absent seed, because a continuation digest folds a host path and cannot be a cross-platform literal. The removed values stay in the note above the cases as the lane's recorded pre-field measurement (exec/E14-probes/fail_before.cpp on the base 9f0ea24c), which is what carries "absent hashes exactly as before" for the host that measured it. What the literals were pinning is now pinned as properties, in a new case: the two spellings of absent -- a request that never writes Trail::best_seed and one that writes std::nullopt -- answer one digest; the digest is the run's, not the process's; and a seed the run's own behaviour ignores (1.00, under case A's arm print, so the ride still starts at the print and nothing books) still moves it, which is what makes the seed request state rather than an outcome. The seeded cases now compare against their own control's digest instead of a literal. The printed digest lines stay: they are the cross-platform measurement, and lane E17 needs them. ADR-0001's covering-test cell said the controls carried the pre-field digests; it now says what they carry and why. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
1 parent 6ef73a4 commit e9ad37d

2 files changed

Lines changed: 73 additions & 14 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ consults before believing one.
559559
| the frozen `pf_pending_order_v1_t` field names | the reflection table of an append-only C ABI POD | already ruled: the residual tables above, held by `scripts/check_kernel_residuals.py` | renaming is an ABI break | `tests/test_kernel_residuals` (the gate itself) |
560560
| the C ABI's documented vocabulary — `src/c_abi.cpp`, `include/pineforge/pineforge.h`, `src/engine_metrics.cpp`, `src/engine_report.cpp`, `src/engine_trade_accessors.cpp` | the exports are the contract; the comments say what a Pine consumer called the same number | already ruled: the `inputs_` / `get_input_*` / `syminfo_metadata_` row above. No kernel decision reads a Pine name | the export names are frozen | `scripts/check_c_abi_runtime.py`, `tests/test_native_c_api.c` |
561561
| the neutral utility spellings — `map.hpp`, `drawing.hpp`, `series.hpp`, `window_sum.hpp`, `math.hpp`, `matrix.hpp`, `session_time.hpp`, `str_utils.hpp` | neutral public names with exact deprecated `pine_*` aliases for generated code | already ruled: "Neutral spellings" above | dropping the aliases breaks generated code | the ruled-name gate |
562-
| `native_order::Trail::best_seed` `include/pineforge/native_order.hpp` | where a trail's running best STARTS: absent, the arm's own print; present, a floor on it — the favourable one of the seed and that print | the level is a number the host hands over exactly as it hands over an `arm_price`: the kernel neither derives it nor knows what named it, and a second venue drives it by passing a different number. A trailing stop that rides from its activation rather than from the next print is an ordinary broker shape | nothing, because the old start was not a choice the run had made another way — it was wherever the arm happened to land (the arm threshold on a crossing, the first live print when the request was born already armed), so there is no second spelling to defer to and nothing for a hook to answer; a request field is admissible, opt-in and hashed only when present | `tests/test_native_trail_best_seed.cpp` (kernel-only, batch and stream, with the two pre-field continuation digests as the absent-seed controls); the C tail by `check_trail_best_seed_tail` in `tests/test_native_c_api.c`. The need was measured by R5 lanes E5 and E9 — TradingView's `lab tv` tapes book every trail exit at activation ∓ the offset, never at the kernel's own start — and closed by lane E14; design `native-feature-parity.md` §3.6.2 |
562+
| `native_order::Trail::best_seed` `include/pineforge/native_order.hpp` | where a trail's running best STARTS: absent, the arm's own print; present, a floor on it — the favourable one of the seed and that print | the level is a number the host hands over exactly as it hands over an `arm_price`: the kernel neither derives it nor knows what named it, and a second venue drives it by passing a different number. A trailing stop that rides from its activation rather than from the next print is an ordinary broker shape | nothing, because the old start was not a choice the run had made another way — it was wherever the arm happened to land (the arm threshold on a crossing, the first live print when the request was born already armed), so there is no second spelling to defer to and nothing for a hook to answer; a request field is admissible, opt-in and hashed only when present | `tests/test_native_trail_best_seed.cpp` (kernel-only, batch and stream, the absent-seed controls pinned as same-host properties of the continuation digest rather than as its pre-field values, because that digest folds the host's own zoneinfo root and so is not portable); the C tail by `check_trail_best_seed_tail` in `tests/test_native_c_api.c`. The need was measured by R5 lanes E5 and E9 — TradingView's `lab tv` tapes book every trail exit at activation ∓ the offset, never at the kernel's own start — and closed by lane E14; design `native-feature-parity.md` §3.6.2 |
563563

564564
**No site is left unaccounted for**, and no site's justification is "because TradingView does
565565
it" over a mechanism that is not generic. Two entries were recorded here as open questions

‎tests/test_native_trail_best_seed.cpp‎

Lines changed: 72 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@
2323
// stop is 100.50 instead of 100.499, and the next bar's low of exactly
2424
// 100.50 books it.
2525
//
26-
// Each is pinned three ways: the control (no seed) keeps its behaviour AND
27-
// the continuation digest the kernel produced before the field existed, the
26+
// Each is pinned three ways: the control (no seed) keeps its behaviour, the
2827
// seeded run books the exit, and the same pair runs through the streaming
2928
// ingress. A buy trail mirrors the min side, a price-grid row pins that the
3029
// seed is put on the ladder like an observed print, and the acceptance rows
31-
// pin the level's own validity.
30+
// pin the level's own validity. That an ABSENT seed folds nothing into the
31+
// continuation identity is pinned by properties of this host's own digests
32+
// (an_absent_seed_folds_nothing below), never by a digest literal -- see the
33+
// note where the two literals used to be.
3234
//
3335
// Fail-before: compiled against the previous header closure (this lane's base
3436
// 9f0ea24c) this unit stops at
@@ -63,6 +65,9 @@ struct Case {
6365
double entry_units = 1.0; // signed: the lot the trail closes
6466
std::optional<double> arm_price;
6567
std::optional<double> best_seed;
68+
// false leaves Trail::best_seed default-constructed: the request never
69+
// writes the field at all, the spelling every pre-E14 caller has.
70+
bool assign_seed = true;
6671
int submit_calculation = 1; // 1-based calculation the trail is sent on
6772
double offset = 0.5;
6873
NativePriceGrid grid = NativePriceGrid::None;
@@ -77,7 +82,7 @@ void drive(Host& host, const Case& c) {
7782
no::Trail trail;
7883
trail.offset = c.offset;
7984
trail.arm_price = c.arm_price;
80-
trail.best_seed = c.best_seed;
85+
if (c.assign_seed) trail.best_seed = c.best_seed;
8186
leg.trigger = trail;
8287
put(h, leg);
8388
}
@@ -162,19 +167,35 @@ Case case_b() {
162167
return c;
163168
}
164169

165-
// The digests the kernel produced for both controls BEFORE the field existed
166-
// (exec/E14-probes/fail_before.cpp on this lane's base 9f0ea24c). An absent
167-
// seed folds nothing, so these must not move.
168-
constexpr std::uint64_t kControlContinuationA = 7148617029230866814ULL;
169-
constexpr std::uint64_t kControlContinuationB = 1059492877796320724ULL;
170+
// The two controls used to carry the digests the kernel produced for them
171+
// BEFORE the field existed (exec/E14-probes/fail_before.cpp on this lane's
172+
// base 9f0ea24c): 7148617029230866814 and 1059492877796320724. Both were
173+
// measured on Darwin, and NO continuation digest is portable, so as literals
174+
// they pinned one host.
175+
//
176+
// native_continuation_hash() folds the run's timezone identity, and that
177+
// identity carries the host's own zoneinfo ROOT PATH and the tz resource
178+
// paths under it -- tzdir_canonical() resolves /var/db/timezone/zoneinfo on
179+
// Darwin (which realpaths through the installed tzdata release, e.g.
180+
// .../tz/2026c.1.0/zoneinfo) and /usr/share/zoneinfo, or $TZDIR, under glibc.
181+
// So the same engine over the same bars, booking the same trades, answers a
182+
// different continuation value on each host; moving the root alone on ONE
183+
// host moves every digest below while every row, price and position stays
184+
// put. The digests are still printed, because they are the measurement.
185+
//
186+
// expectation corrected: kControlContinuationA/B == the control digest ->
187+
// same-host properties of the absent seed (an_absent_seed_folds_nothing),
188+
// because a continuation digest folds a host path and cannot be a literal.
189+
// The pre-field values above stay as the lane's recorded fail-before, which
190+
// is what carries "absent hashes exactly as before" for the host that
191+
// measured them.
170192

171193
void a_already_armed_at_submission() {
172194
Case control = case_a();
173195
const auto without = run_batch("e14-a-control", control);
174196
report("A control", without);
175197
CHECK(without.rows == 0);
176198
CHECK(without.position == 1.0);
177-
CHECK(without.continuation == kControlContinuationA);
178199

179200
Case seeded = case_a();
180201
seeded.best_seed = 101.00;
@@ -185,7 +206,7 @@ void a_already_armed_at_submission() {
185206
if (with.rows == 1) near(with.exit_price, 100.50);
186207
// A seed IS request state: the same run under the same session key must
187208
// not answer the digest the unseeded one does.
188-
CHECK(with.continuation != kControlContinuationA);
209+
CHECK(with.continuation != without.continuation);
189210
}
190211

191212
void b_armed_on_a_crossing() {
@@ -194,7 +215,6 @@ void b_armed_on_a_crossing() {
194215
report("B control", without);
195216
CHECK(without.rows == 0);
196217
CHECK(without.position == 1.0);
197-
CHECK(without.continuation == kControlContinuationB);
198218

199219
Case seeded = case_b();
200220
seeded.best_seed = 101.00;
@@ -203,7 +223,45 @@ void b_armed_on_a_crossing() {
203223
CHECK(with.rows == 1);
204224
CHECK(with.position == 0.0);
205225
if (with.rows == 1) near(with.exit_price, 100.50);
206-
CHECK(with.continuation != kControlContinuationB);
226+
CHECK(with.continuation != without.continuation);
227+
}
228+
229+
// ── an absent seed folds nothing ────────────────────────────────────────
230+
// hash_trigger folds the seed under `if (trail->best_seed)`, so absent means
231+
// no bytes at all. What that is observable as, without a pre-field binary and
232+
// without a digest literal: the two spellings of absent answer one digest,
233+
// the digest is a property of the run and not of the process, and a seed that
234+
// the run's own behaviour ignores still moves it -- so the field enters the
235+
// fold on its own, which is exactly what the removed literals pinned.
236+
void an_absent_seed_folds_nothing() {
237+
Case never_written = case_a();
238+
never_written.assign_seed = false;
239+
const auto untouched = run_batch("e14-a-control", never_written);
240+
report("A seed never written", untouched);
241+
CHECK(untouched.rows == 0);
242+
CHECK(untouched.position == 1.0);
243+
244+
const auto nullopt_written = run_batch("e14-a-control", case_a());
245+
report("A seed = nullopt", nullopt_written);
246+
CHECK(nullopt_written.rows == untouched.rows);
247+
CHECK(nullopt_written.position == untouched.position);
248+
CHECK(nullopt_written.continuation == untouched.continuation);
249+
250+
// The digest belongs to the run: the same case again, same session key,
251+
// answers the same value.
252+
CHECK(run_batch("e14-a-control", case_a()).continuation == untouched.continuation);
253+
254+
// A seed under the arm print is inert -- the ride starts at the
255+
// favourable one of seed and print, so case A's best stays the print and
256+
// nothing books -- and the digest must move all the same.
257+
Case inert = case_a();
258+
inert.best_seed = 1.00;
259+
const auto seeded_inert = run_batch("e14-a-control", inert);
260+
report("A seeded 1.00 (inert)", seeded_inert);
261+
CHECK(seeded_inert.rows == untouched.rows);
262+
CHECK(seeded_inert.position == untouched.position);
263+
CHECK(seeded_inert.exit_price == untouched.exit_price);
264+
CHECK(seeded_inert.continuation != untouched.continuation);
207265
}
208266

209267
// Streaming is the same kernel under a different drive, so both halves must
@@ -341,6 +399,7 @@ void a_seed_is_a_price_level() {
341399
int main() {
342400
test("A already armed at submission", a_already_armed_at_submission);
343401
test("B armed on a crossing", b_armed_on_a_crossing);
402+
test("an absent seed folds nothing", an_absent_seed_folds_nothing);
344403
test("streamed pair", streamed_pair);
345404
test("buy trail mirrors the min", buy_trail_mirrors_the_min);
346405
test("the seed goes on the ladder", the_seed_goes_on_the_ladder);

0 commit comments

Comments
 (0)