EV-20 SPIKE-06: stuck start cap backs off instead of holding
Under one stuck verdict Solar still makes at most MAX_TRIES starts and gives one CHARGER_REFUSED; then one more start after 15 min and one every 30 min (each by the start rule and the write clock), so a fault that clears is found again. The episode ends when the reading follows a start, on a press of Solar, Off, Manual, shadow or a stop. Rows: cap, backoff times, recovery, press, episode end; T28 (b) no flapping. DOCS and DECISIONS. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VSY9UpTaUYnjJF5oVtbM1w
This commit is contained in:
@@ -344,39 +344,91 @@ for race in (False, True):
|
||||
and r["trace"][-1]["fault"] is None)
|
||||
nevers(r, f"C12 [race={race}]")
|
||||
|
||||
# C12's bound: a charger whose reading is really frozen. Solar's own 0 A
|
||||
# stands (the frozen read-back shows 0 A), so the start rule runs; each start
|
||||
# write is not taken and the 0 A follows. At most MAX_TRIES starts under one
|
||||
# verdict, then ONE CHARGER_REFUSED warning and the 0 A stands (EV-04: until
|
||||
# Solar is pressed). Here the reading comes back at 1200 s with the very
|
||||
# values it froze with (0 W, 0 A), so nothing moves; pressing Solar at 1250 s
|
||||
# starts afresh.
|
||||
n0 = LOG.mark()
|
||||
r = S.drive(const(600.0), lambda t: 600.0 + (1000.0 if 200 <= t < 330
|
||||
else 2300.0 if t < 200
|
||||
else 6000.0),
|
||||
dur=1500, first="car", socs={"a": 100.0, "b": 100.0},
|
||||
opts={"ev_pause_min": 1, "ev_start_min": 1},
|
||||
events={300: lambda p, c: p.ch.freeze(),
|
||||
1200: lambda p, c: p.ch.freeze(False),
|
||||
1250: act("car_mode", "solar")})
|
||||
r["_log"] = n0
|
||||
w = cur_writes(r)
|
||||
st = [x["t"] for x in r["trace"] if x["fault"] == "stuck"]
|
||||
t0 = nth(st, 0) if st else 0.0
|
||||
starts = [t for t, a, _ in w if a > 0.0 and t0 <= t < 1200]
|
||||
warn = [m for m in LOG.since(n0, "WARNING") if "CHARGER_REFUSED" in m]
|
||||
after = [(t, a) for t, a, _ in w if t >= 1200]
|
||||
quiet = [(t, a) for t, a in after if t < 1250]
|
||||
check(f"C12 bound: a frozen charger after Solar's own 0 A: at most 3 starts "
|
||||
f"under the verdict ({starts}), one CHARGER_REFUSED ({len(warn)}), the "
|
||||
f"charger at 0 A, nothing written until Solar is pressed, then a start "
|
||||
f"within the start rule ({after[:2]})",
|
||||
bool(st) and 1 <= len(starts) <= carmode.MAX_TRIES and len(warn) == 1
|
||||
and not quiet and present(nth(after, 0)) and nth(after, 0)[1] > 0.0
|
||||
and nth(after, 0)[0] <= 1250 + 75
|
||||
and [a for t, a, _ in w if t0 <= t < 1200][-1:] == [0.0])
|
||||
nevers(r, "C12 bound")
|
||||
# C12's cap and backoff (PM decision): a charger whose reading is really
|
||||
# frozen (at 300 s, with the values it will show when it comes back). Solar's
|
||||
# own 0 A stands, so the start rule runs; each start is not taken and the 0 A
|
||||
# follows. At most MAX_TRIES starts under one verdict, then ONE
|
||||
# CHARGER_REFUSED; then one more start 15 min later, then one every 30 min
|
||||
# (each by the start rule), never the 72 s flapping.
|
||||
def frozen_run(dur, events=None):
|
||||
n0 = LOG.mark()
|
||||
ev = {300: lambda p, c: p.ch.freeze()}
|
||||
ev.update(events or {})
|
||||
r = S.drive(const(600.0), lambda t: 600.0 + (1000.0 if 200 <= t < 330
|
||||
else 2300.0 if t < 200
|
||||
else 6000.0),
|
||||
dur=dur, first="car", socs={"a": 100.0, "b": 100.0},
|
||||
opts={"ev_pause_min": 1, "ev_start_min": 1}, events=ev)
|
||||
r["_log"] = n0
|
||||
st = [x["t"] for x in r["trace"] if x["fault"] == "stuck"]
|
||||
t0 = nth(st, 0) if st else 1e9
|
||||
w = cur_writes(r)
|
||||
starts = [t for t, a, _ in w if a > 0.0 and t >= t0]
|
||||
warn = [m for m in LOG.since(n0, "WARNING") if "CHARGER_REFUSED" in m]
|
||||
return r, w, starts, warn
|
||||
|
||||
|
||||
r, w, starts, warn = frozen_run(4000)
|
||||
first3, later = starts[:3], starts[3:]
|
||||
t3 = nth(first3, 2)
|
||||
gaps = [b - a for a, b in zip(later, later[1:])]
|
||||
check(f"cap: a frozen charger: 3 starts under the verdict ({first3}), then "
|
||||
f"one CHARGER_REFUSED ({len(warn)})",
|
||||
len(first3) == carmode.MAX_TRIES and len(warn) == 1
|
||||
and all(b - a < 120 for a, b in zip(first3, first3[1:])))
|
||||
check(f"backoff: one more start 15 min after the 3rd (+ the start rule), "
|
||||
f"then one every 30 min (+ the start rule): {later} (gaps {gaps})",
|
||||
present(t3) and len(later) == 2
|
||||
and 900 <= nth(later, 0) - t3 <= 900 + 80
|
||||
and all(1800 <= g <= 1800 + 80 for g in gaps))
|
||||
nevers(r, "cap and backoff")
|
||||
|
||||
# Recovery: the reading comes back at 1200 s with the values it froze with,
|
||||
# so nothing moves by itself; the next backoff start is taken, the reading
|
||||
# follows it, the episode ends (warning cleared) and the car charges.
|
||||
r, w, starts, warn = frozen_run(2400, {1200: lambda p, c: p.ch.freeze(False)})
|
||||
t3 = nth(starts, 2)
|
||||
rec = [t for t in starts if t > 1200]
|
||||
check(f"recovery: the fault clears at 1200 s; the next backoff start "
|
||||
f"({rec[:1]}, 15 min after the 3rd at {t3}) is taken and the car "
|
||||
f"charges to the end, warning cleared, not stuck",
|
||||
present(nth(rec, 0)) and present(t3)
|
||||
and 900 <= nth(rec, 0) - t3 <= 980
|
||||
and r["sim"].power_w > 1000.0 and not r["c"].car.stuck_now
|
||||
and not r["c"].car_solar.gave_up)
|
||||
nevers(r, "recovery")
|
||||
|
||||
# A press of Solar during the backoff starts the episode afresh: a start by
|
||||
# the start rule after the press, not 15 min later.
|
||||
r, w, starts, warn = frozen_run(1400, {1000: act("car_mode", "solar")})
|
||||
after = [t for t in starts if t >= 1000]
|
||||
check(f"press: Solar pressed at 1000 s during the backoff: a start by the "
|
||||
f"start rule after the press ({after[:1]})",
|
||||
present(nth(after, 0)) and nth(after, 0) <= 1000 + 75)
|
||||
|
||||
# The episode ends on Off, Manual and shadow: counter, wait and warning
|
||||
# cleared (read 5 s after the switch).
|
||||
for name, fn in (("Off", act("car_mode", "off")),
|
||||
("Manual", act("car_mode", "manual")),
|
||||
("shadow", lambda p, c: c.o.__setitem__("shadow_mode",
|
||||
"on"))):
|
||||
seen = {}
|
||||
|
||||
def look(p, c, seen=seen):
|
||||
sw = c.car_solar
|
||||
seen.update(starts=sw.stuck_starts, gave_up=sw.gave_up,
|
||||
wait=getattr(sw, "stuck_wait", None),
|
||||
warned=getattr(sw, "stuck_warned", None))
|
||||
before = {}
|
||||
|
||||
def look0(p, c, before=before):
|
||||
before.update(starts=c.car_solar.stuck_starts,
|
||||
gave_up=c.car_solar.gave_up)
|
||||
r, w, starts, warn = frozen_run(900, {790: look0, 800: fn, 805: look})
|
||||
check(f"episode end on {name}: before {before}, after {seen}",
|
||||
before.get("starts") == carmode.MAX_TRIES and before.get("gave_up")
|
||||
and seen.get("starts") == 0 and seen.get("gave_up") is False
|
||||
and seen.get("wait") is None and seen.get("warned") is False)
|
||||
|
||||
# C14: Manual's refused writes leave a stuck verdict on a paused, live car,
|
||||
# then the user presses Solar. No current of Solar's own may stand, so the
|
||||
|
||||
Reference in New Issue
Block a user