Skip to content

Commit f2a455b

Browse files
luisleo526claude
andcommitted
EN-132: fix the four release-profile failures (L6 ruling 10-14 06:5x)
The release box failed four ctest rows; the triage named each cause, and the base-check lab remote release job passed on engine main (exit 0), so all four are EN-132's, not environmental and not pre-existing on main. - tests/test_value_admission_arith.cpp: the S3 control now asserts the downstream engine code and the exact relative_price payload G3's guard produces, instead of expecting no failure. - src/source/pine_adapter.cpp: narrow G1's pre-rejection throw at both row-7 placement sites so a finite explicit requirement overflow falls through to the pinned signal-time rejection-and-continuation; nonfinite placement inputs and equity still fault. - tests/test_value_invalid_sizing_margin_source.cpp: re-scope the row-7 witness to default-sized placement overflow and nonfinite pointvalue, and add keep_finite_explicit_placement_overflow() pinning the rejection-and- continuation for finite explicit overflow. - tests/ownership/test_manifest_checker.py: expect the checker's 'stale' diagnostic (its set-difference convention) for the removed-registry-row negative. - scripts/test_private_fixture_reads.py: copy the nested ownership driver into TamperTree so the two new registrations resolve. L6 default ruling 10-14 06:5x: the pinned signal-time rejection wins; G1's throw is narrowed; row-7 is re-scoped. Keep every existing file. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
1 parent e89e0f0 commit f2a455b

5 files changed

Lines changed: 98 additions & 16 deletions

File tree

‎scripts/test_private_fixture_reads.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,10 @@ def __init__(self, directory: Path):
252252
shutil.copy(REPO / 'tests' / name, self.root / 'tests')
253253
for driver in sorted((REPO / 'tests').glob('*.py')):
254254
shutil.copy(driver, self.root / 'tests')
255+
# Both ownership registrations name this nested driver.
256+
(self.root / 'tests' / 'ownership').mkdir()
257+
shutil.copy(REPO / 'tests' / 'ownership' / 'test_manifest_checker.py',
258+
self.root / 'tests' / 'ownership')
255259
(self.root / 'benchmarks').mkdir()
256260
shutil.copy(REPO / 'benchmarks' / 'check_provenance.py',
257261
self.root / 'benchmarks')

‎src/source/pine_adapter.cpp‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7364,8 +7364,15 @@ void PineExecutionAdapter::place_entry(const SourceId& id, bool is_long, double
73647364
: mark;
73657365
const double required = units * admission_mark
73667366
* staged_.syminfo.pointvalue * fx * margin / 100.0;
7367+
// Finite explicit overflow is a signal-time refusal below, with
7368+
// cancellation and callback continuation. Nonfinite inputs or
7369+
// equity still fault before that refusal.
7370+
const bool finite_explicit_requirement = std::isfinite(units)
7371+
&& std::isfinite(admission_mark) && std::isfinite(staged_.syminfo.pointvalue)
7372+
&& std::isfinite(fx);
73677373
if (finite_positive(margin) && margin <= 100.0
7368-
&& (!std::isfinite(required) || !std::isfinite(equity))) {
7374+
&& ((!std::isfinite(required) && !finite_explicit_requirement)
7375+
|| !std::isfinite(equity))) {
73697376
engine_command_value_invalid_or_count("margin.required", EngineValueStage::margin,
73707377
EngineValueReason::nonfinite);
73717378
}
@@ -8541,8 +8548,15 @@ void PineExecutionAdapter::place_entry(const SourceId& id, bool is_long, double
85418548
}
85428549
const double required = (charged_held + std::abs(own_units)) * signal * staged_.syminfo.pointvalue
85438550
* snapshot.sizing.fx * margin / 100.0;
8551+
// The flat/same-side refusal below also owns finite explicit overflow.
8552+
// Default sizing, reversals and nonfinite inputs retain the G fault.
8553+
const bool finite_explicit_rejection = !default_sized && !reverses
8554+
&& std::isfinite(charged_held) && std::isfinite(own_units)
8555+
&& std::isfinite(signal) && std::isfinite(staged_.syminfo.pointvalue)
8556+
&& std::isfinite(snapshot.sizing.fx) && std::isfinite(margin);
85448557
if (margin > 0.0
8545-
&& (!std::isfinite(required) || !std::isfinite(snapshot.sizing.equity))) {
8558+
&& ((!std::isfinite(required) && !finite_explicit_rejection)
8559+
|| !std::isfinite(snapshot.sizing.equity))) {
85468560
engine_command_value_invalid_or_count("margin.required", EngineValueStage::margin,
85478561
EngineValueReason::nonfinite);
85488562
}

‎tests/ownership/test_manifest_checker.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ def test_catalog_registry_missing_code_is_rejected(self):
330330
text, changed = re.subn(r'^\s*\{"outputs_limit",[^\n]*\n', "", text, flags=re.M)
331331
self.assertEqual(changed, 1)
332332
path.write_text(text, encoding="utf-8")
333-
self.reject("registry-set", "missing outputs_limit", copied_tree=True)
333+
self.reject("registry-set", "stale outputs_limit", copied_tree=True)
334334

335335
def test_unknown_producer_field_is_rejected_by_vocabulary(self):
336336
# Killer for vocabulary-check-disabled, even if another check also fails.

‎tests/test_value_admission_arith.cpp‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,11 @@ void trail_rows() {
341341
TrailHost fallback(-kMax, 1e308, 1e308);
342342
fallback.run_probe();
343343
source::detail::set_pine_callback_lifecycle_rule(rule, previous);
344-
CHECK(fallback.failure.code == RunFailureCode::none);
344+
// The constant fallback keeps ticks finite; G3 rejects the derived level.
345+
CHECK(fallback.failure.code == RunFailureCode::engine_command_value_invalid);
346+
CHECK(fallback.failure.args && *fallback.failure.args ==
347+
"{\"field\":\"relative_price.level\",\"reason\":\"numeric_overflow\","
348+
"\"stage\":\"relative_price\"}");
345349

346350
row = "trail_invalid_mintick_fallback_bits";
347351
for (double tick : {0.0, -1.0, kNaN, kInf}) {

‎tests/test_value_invalid_sizing_margin_source.cpp‎

Lines changed: 72 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -193,18 +193,77 @@ void row3_nonfinite_equity() {
193193
}
194194
}
195195
void row7_placement_requirement_overflow() {
196-
row = "row7_explicit_placement_overflow";
197-
Probe explicit_units(QtyType::FIXED, 1.0, CommissionType::PERCENT, 0.0, 100.0);
198-
explicit_units.script = [](Probe& p, int index) {
199-
if (!index) p.strategy_entry("L", true, nan, nan, 1.0e308);
200-
};
201-
failed(run(explicit_units), "margin.required", "margin", "nonfinite");
202-
row = "row7_default_placement_overflow";
203-
Probe default_units(QtyType::FIXED, 1.0e308, CommissionType::PERCENT, 0.0, 100.0);
204-
default_units.script = [](Probe& p, int index) {
205-
if (!index) p.strategy_entry("L", true);
206-
};
207-
failed(run(default_units), "margin.required", "margin", "nonfinite");
196+
// L6: finite explicit overflow is KEEP; declaration-derived requirements
197+
// and nonfinite placement inputs remain G. Preserve the exact G payload.
198+
for (const bool is_long : {false, true}) {
199+
row = is_long ? "row7_default_long_placement_overflow"
200+
: "row7_default_short_placement_overflow";
201+
Probe default_units(QtyType::FIXED, 1.0e308, CommissionType::PERCENT, 0.0, 100.0);
202+
default_units.script = [is_long](Probe& p, int index) {
203+
if (!index) p.strategy_entry("L", is_long);
204+
};
205+
failed(run(default_units), "margin.required", "margin", "nonfinite");
206+
}
207+
for (const bool default_quantity : {false, true}) {
208+
for (const double value : {inf, -inf, nan}) {
209+
row = default_quantity ? "row7_default_pointvalue_nonfinite"
210+
: "row7_explicit_pointvalue_nonfinite";
211+
Probe probe(QtyType::FIXED, 1.0, CommissionType::PERCENT, 0.0, 100.0);
212+
probe.script = [default_quantity, value](Probe& p, int index) {
213+
if (index) return;
214+
// Inject the derived placement tuple on an adapter bound to
215+
// the running host. The host's admitted run spec stays valid;
216+
// a declaration refusal must not stand in for the G producer.
217+
PineExecutionAdapter placement(p);
218+
PineStrategyConfig config;
219+
config.initial_capital = 1000.0;
220+
config.margin_long = config.margin_short = 100.0;
221+
placement.set_configuration(config);
222+
StagedConfiguration staged;
223+
staged.syminfo.mintick = 0.01;
224+
staged.syminfo.pointvalue = value;
225+
placement.set_staged_configuration(staged);
226+
placement.entry("G", true, nan, nan, default_quantity ? nan : 1.0);
227+
};
228+
failed(run(probe), "margin.required", "margin", "nonfinite");
229+
}
230+
}
231+
}
232+
void keep_finite_explicit_placement_overflow() {
233+
for (const double margin : {100.0, 200.0}) {
234+
for (const bool is_long : {false, true}) {
235+
for (const double units : {1.0e307, 1.0e308}) {
236+
row = margin == 100.0 ? "keep_explicit_signal_overflow_continues"
237+
: "keep_explicit_affordability_overflow_continues";
238+
Probe probe(QtyType::FIXED, 1.0, CommissionType::PERCENT, 0.0, margin);
239+
bool continued = false;
240+
probe.script = [is_long, units, &continued](Probe& p, int index) {
241+
if (!index) {
242+
p.strategy_entry("overflow", is_long, nan, nan, units);
243+
continued = true;
244+
p.strategy_entry("L", is_long, nan, nan, 1.0);
245+
}
246+
if (index == 2) {
247+
CHECK(p.position_units() == (is_long ? 1.0 : -1.0));
248+
p.strategy_close("L");
249+
}
250+
};
251+
const auto result = run(probe);
252+
completed(result);
253+
CHECK(continued);
254+
CHECK(result.trades.size() == 1);
255+
CHECK(probe.position_units() == 0.0);
256+
if (result.trades.size() == 1) {
257+
const auto& trade = result.trades[0];
258+
CHECK(same_bits(trade.qty, 1.0));
259+
CHECK(same_bits(trade.entry_price, 100.0));
260+
CHECK(same_bits(trade.exit_price, 100.0));
261+
CHECK(trade.pnl == 0.0);
262+
CHECK(trade.commission == 0.0);
263+
}
264+
}
265+
}
266+
}
208267
}
209268
void keep_defined_zero_equity() {
210269
for (const bool cash_fee : {false, true}) {
@@ -331,6 +390,7 @@ int main() {
331390
row1_nonfinite_conversion_input();
332391
row3_nonfinite_equity();
333392
row7_placement_requirement_overflow();
393+
keep_finite_explicit_placement_overflow();
334394
keep_defined_zero_equity();
335395
keep_disabled_margin();
336396
finite_boundary_is_bit_identical();

0 commit comments

Comments
 (0)