Fáze 2.1: 4 zastaralé testy → expectedFailure; +2 fixtures vč. Infeasible reproduceru

Analýza (agent + ručně): všechny 4 failující testy vynucují heuristické chování
před retry-chain v5; současné chování je ekonomicky správné nebo jde o korektní
fallback. Scénáře zachovány s @unittest.expectedFailure + zdůvodněním —
přepsat na ekonomické asserty ve Fázi 3. Suite: 120 passed, 4 xfailed.

Nové golden fixtures home-01: 2026-05-01 extreme_neg_buy (buy −13.26;
ZACHYCENO: solver Infeasible po celém relax řetězci — zmrazeno jako golden
failure snapshot), 2026-05-25 evening_push. Golden replay i penalty audit
umí solver_error výsledky (penalta měnící feasibility se zviditelní).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Dusan Vojacek
2026-06-11 13:56:12 +02:00
parent 0dc2e1df96
commit 9a2229641d
7 changed files with 14598 additions and 20 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,13 @@
{
"solver_error": "Infeasible",
"relax_chain": [
"strict",
"relaxed_expensive_import",
"relaxed_neg_buy_charge",
"relaxed_neg_prep_hold_only",
"relaxed_neg_prep_window",
"neg_sell_phases_fallback",
"relaxed_pos_sell_ge_block",
"relaxed_solver_masks"
]
}

File diff suppressed because it is too large Load Diff

View File

@@ -122,19 +122,28 @@ def _replay_fixture(fixture: dict) -> dict:
db,
soc_wh=soc_wh,
)
results, _ms, _snap = pe.solve_dispatch_two_pass(
slots,
battery,
heat_pump,
grid,
ev_sessions,
vehicles,
soc_wh,
tuv_temp,
tuv_delta_stats=tuv_stats,
operating_mode=operating_mode or "AUTO",
planner_version=pe._planner_engine_version(),
)
try:
results, _ms, _snap = pe.solve_dispatch_two_pass(
slots,
battery,
heat_pump,
grid,
ev_sessions,
vehicles,
soc_wh,
tuv_temp,
tuv_delta_stats=tuv_stats,
operating_mode=operating_mode or "AUTO",
planner_version=pe._planner_engine_version(),
)
except pe.PlannerSolverError as exc:
# Selhání solveru je taky chování k zafixování (např. home-01 2026-05-01:
# Infeasible po celém relax řetězci). Až ho Fáze 2/3 opraví, golden diff
# to zviditelní a snapshot se vědomě zregeneruje.
return {
"solver_error": exc.solver_status,
"relax_chain": list(exc.relax_chain),
}
return _normalize_results(results)
return asyncio.run(_run())
@@ -170,6 +179,9 @@ def _make_test(path: Path):
f"Chybí snapshot {snap_path.name} vygeneruj přes GOLDEN_UPDATE=1",
)
expected = json.loads(snap_path.read_text(encoding="utf-8"))
if "solver_error" in expected or "solver_error" in actual:
self.assertEqual(expected, actual, f"{path.name}: změna výsledku/selhání solveru")
return
self.assertEqual(
expected["totals"],
actual["totals"],

View File

@@ -3529,6 +3529,9 @@ class ChargeAcquisitionArbitrageTests(unittest.TestCase):
],
)
# Známý zastaralý test (analýza 2026-06-11, Fáze 2.1): stale: očekává evening_push povolený, ale retry chain (neg_sell_phases_fallback) ho správně potlačí.
# Scénář ponechán pro Fázi 3 (čistý solver core) — pak přepsat asserty na ekonomiku.
@unittest.expectedFailure
def test_future_neg_buy_evening_export_at_high_soc_relaxed_prep(self) -> None:
"""v64: před buy<0 večerní export i při relaxed_neg_prep_window (neg-evening bundle)."""
prague = ZoneInfo("Europe/Prague")
@@ -5187,6 +5190,9 @@ class Home01PvStoreValueTests(unittest.TestCase):
class SitePowerCapTests(unittest.TestCase):
"""Tvrdé limity site import a součtu nabíjení baterie."""
# Známý zastaralý test (analýza 2026-06-11, Fáze 2.1): stale: vynucuje nabíjení bez exportu; při sell 2.5 > buy 0.7 je export PV přebytku ekonomicky správně.
# Scénář ponechán pro Fázi 3 (čistý solver core) — pak přepsat asserty na ekonomiku.
@unittest.expectedFailure
def test_grid_charge_respects_import_and_battery_caps(self) -> None:
"""home-01 typ: CHARGE slot nesmí překročit 17 kW import ani 18 kW do baterie."""
base = datetime(2026, 5, 22, 8, 45, tzinfo=timezone.utc)
@@ -5809,6 +5815,9 @@ class PreNegPvExportForecastTests(unittest.TestCase):
)
)
# Známý zastaralý test (analýza 2026-06-11, Fáze 2.1): stale: scénář na hraně infeasibility — relaxed_neg_prep_window přepne na legacy cushion (full SoC) a check správně selže.
# Scénář ponechán pro Fázi 3 (čistý solver core) — pak přepsat asserty na ekonomiku.
@unittest.expectedFailure
def test_morning_exports_pv_when_cushion_ok(self) -> None:
slots = self._slots_morning_then_neg()
bat = _battery(uc_wh=64_000.0, max_pct=95.0)
@@ -5980,6 +5989,9 @@ class NegSellPrepWindowV36Tests(unittest.TestCase):
a11 = [(t, w) for t, w in anchors if _prague_calendar_date(slots[t]) == prev]
self.assertGreaterEqual(len(a11), 1)
# Známý zastaralý test (analýza 2026-06-11, Fáze 2.1): stale: bez buy<0 v horizontu se reserve anchors v relaxed režimu už nevytvářejí (v36 → v5 retry chain).
# Scénář ponechán pro Fázi 3 (čistý solver core) — pak přepsat asserty na ekonomiku.
@unittest.expectedFailure
def test_evening_reserve_soc_near_reserve_after_discharge(self) -> None:
"""v36d: capped slack + večerní ge_bat → SoC u kotvy ≤ reserve + max slack."""
base = datetime(2026, 6, 10, 10, 0, tzinfo=ZoneInfo("Europe/Prague")).astimezone(