EV-69 router r2: fuzz keeps full interference in a mixed pass; calm Solar pass in addition; floors per pass
checks / unit (pull_request) Successful in 54m32s
infra-pin / fresh (pull_request) Successful in 2s

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Claude
2026-12-04 04:51:33 +01:00
parent 0f3d5d75e5
commit 8a40343a84
+79 -34
View File
@@ -1,15 +1,25 @@
"""EV-69 T21: the fuzz for the carry (N1-N9 of reports/EV-69-test-plan.md), 10
seeds x 1200 s for Solar and for Manual, both cycle orders.
"""EV-69 T21: the fuzz for the carry (N1-N9 of reports/EV-69-test-plan.md).
`python3 -B test_ev69_fuzz.py`
Writer level (`tools/ev69_kit.py`: `SolarWriter` / `ManualWriter` on a stub
driver). Random: clamp steps, a peak cut cap, refused and raised writes (0 A
and the select are taken), phase changes begun by the plan (Solar) or the user
(Manual), late takes of ANY value the writer tried, foreign values (some equal
to a tried value), presses, unknown and stale reads, the charger gone and
back. Order A applies a cycle's events before its step, order B after it (the
event is read one cycle later). The phase gap is shortened (as test_ev22_fuzz
does) so a run holds many changes.
Two passes, each SEEDS (10) seeds x STEPS (1200) s for Solar and for Manual,
both cycle orders. Writer level (`tools/ev69_kit.py`: `SolarWriter` /
`ManualWriter` on a stub driver).
- Mixed pass: random clamp steps (also inside a change), a peak cut cap (and,
rarely, the EV-60 cap-end shape: `cut_fails` set to 2 after a close),
refused, taken and raised writes (refuse 0.0 / 0.5 / 0.97 / 1.0, 0 A and the
select taken), phase changes begun by the plan (Solar) or the user (Manual),
late takes of ANY value the writer tried, foreign values (some equal to a
tried value), a 0 A reading, presses, unknown and stale reads, the charger
gone and back. All of it also while a Solar change runs.
- Directed pass, in addition: Solar changes run calm (no late take, foreign
value or 0 A reading inside a change, refuse 0.97 / 1.0 only, the clamp
falls only after a close, a cap with `cut_fails` 2 after the first close)
so that cap ends and Solar's distinct close values are reached often.
Both passes add: presses that lift a hold or a give-up, the charger gone while
a bound stands, the plan's phases set from the read phases, and N1b's directed
old-value take. Order A applies a cycle's events before its step, order B
after it (read one cycle later). The phase gap is shortened (as
test_ev22_fuzz does) so a run holds many changes.
Every cycle checks, by an oracle that does not read the carry:
- N1: after a phase change ends without its value taken (MAX_TRIES, or
@@ -57,8 +67,9 @@ def bump(k, n=1):
COUNT[k] = COUNT.get(k, 0) + n
def fuzz(kind, seed):
rnd = random.Random(seed * 7 + (0 if kind == "solar" else 1))
def fuzz(kind, seed, directed=False):
rnd = random.Random(seed * 7 + (0 if kind == "solar" else 1)
+ (1000 if directed else 0))
order_b = seed % 2 == 1
st = {"a": rnd.choice([8.0, 10.0, 12.0]), "n": 1, "rev": 1,
"clamp": 16.0}
@@ -67,7 +78,8 @@ def fuzz(kind, seed):
w.cut_key = 0
else:
w = CM.ManualWriter()
mode = {"refuse": 1.0 if kind == "solar" else 0.97, "raise": 0.0}
mode = {"refuse": 1.0 if (directed and kind == "solar") else 0.97,
"raise": 0.0}
def take(a, d):
if a == 0.0:
@@ -80,7 +92,7 @@ def fuzz(kind, seed):
bad = []
s = dict(armed=False, vals=[], seq_own=[], hold_rises=0, press_t=-1,
prev_hold=False, was_gone=False, gone=False, tried=set(),
kind=None, cap_counted=False, seq_n0=0, pend=None, inj=None, end_t=-9999)
kind=None, cap_counted=False, seq_n0=0, fh=False, fv=None, pend=None, inj=None, end_t=-9999)
clamp = {"v": 16.0}
def ev(t):
@@ -89,16 +101,23 @@ def fuzz(kind, seed):
return
closed = w.seq is not None and (kind == "manual" or [
1 for tt, a in drv.calls[s["seq_n0"]:] if a > 0])
if rnd.random() < (0.4 if closed else 0.01):
clamp["v"] = rnd.choice([16.0, 14.0, 12.0, 10.0, 8.0, 7.0, 6.0])
if directed:
p_clamp = 0.4 if closed else 0.01 # falls only after a close
else:
p_clamp = 0.25 if w.seq is not None else 0.01
if rnd.random() < p_clamp:
clamp["v"] = rnd.choice(
[16.0, 14.0, 12.0, 10.0, 8.0, 7.0, 6.0] if directed
else [16.0, 12.0, 10.0, 8.0, 8.0])
st["clamp"] = clamp["v"]
if kind == "solar" and rnd.random() < 0.01:
K.set_cap(w, rnd.choice([None, 6.0, 6.0, 7.0]))
if kind == "solar" and w.seq is not None and w.cut_a is None \
and [1 for tt, a in drv.calls[s["seq_n0"]:] if a > 0] \
and rnd.random() < 0.4:
and rnd.random() < (0.4 if directed else 0.03):
# the EV-60 cap end shape: a close went, then the cap comes, the
# earlier cut tries of this key being used up
# earlier cut tries of this key being used up (a minority path in
# the full-interference pass)
K.set_cap(w, 6.0)
w.cut_fails, w.cut_fail_at = max(w.cut_fails, 2), -100.0
if w.hold and rnd.random() < 0.03:
@@ -114,9 +133,10 @@ def fuzz(kind, seed):
s["press_t"] = t
bump("press")
if rnd.random() < 0.004:
mode["refuse"] = rnd.choice([0.0, 0.5, 0.97, 1.0, 1.0, 1.0]
if kind == "manual" else
[0.97, 1.0, 1.0, 1.0, 1.0, 1.0])
mode["refuse"] = rnd.choice(
[0.97, 1.0, 1.0, 1.0, 1.0, 1.0]
if (directed and kind == "solar") else
[0.0, 0.5, 0.97, 1.0, 1.0, 1.0])
mode["raise"] = rnd.choice([0.0, 0.0, 0.3])
# a phase change: Solar's plan decides it, Manual's user asks for it
if w.seq is None and rnd.random() < (0.1 if kind == "solar" else 0.03):
@@ -125,9 +145,10 @@ def fuzz(kind, seed):
if not w.plan.switch:
w.plan.n = drv.ph # the plan believes the phases read
w.plan._set(rnd.choice([10.0, 12.0, 14.0]), float(t), n_to)
clamp["v"] = st["clamp"] = 16.0 # it falls in the change
K.set_cap(w, None) # a cap comes later
w.cut_fails = 0
if directed:
clamp["v"] = st["clamp"] = 16.0 # it falls later
K.set_cap(w, None) # a cap comes later
w.cut_fails = 0
else:
w.user_changed()
st["rev"] += 1
@@ -136,8 +157,8 @@ def fuzz(kind, seed):
s["press_t"] = t
# a late take of any value the writer tried (the ended change's
# values first)
if rnd.random() < (0.0 if (kind == "solar" and w.seq is not None)
else 0.08):
calm = directed and kind == "solar" and w.seq is not None
if rnd.random() < (0.0 if calm else 0.08):
pool = [v for v in s["vals"] if v > 0] if (
s["armed"] and rnd.random() < 0.6) else sorted(
v for v in s["tried"] if v > 0)
@@ -149,10 +170,10 @@ def fuzz(kind, seed):
bump("late_take_ended_val")
if v != s["vals"][-1]:
bump(f"late_nonlast_{kind}")
calm = kind == "solar" and w.seq is not None # let a change run
if rnd.random() < (0.0 if calm else 0.005):
drv.cur = rnd.choice([5.0, 7.0, 9.0, 11.0, 13.0, 15.0]
+ sorted(s["tried"]))
s["fv"] = (t, drv.cur)
bump("foreign")
if rnd.random() < 0.005:
w.user_changed()
@@ -226,8 +247,13 @@ def fuzz(kind, seed):
if w.hold and not s["prev_hold"]:
s["hold_rises"] += 1
bump("hold")
if t - s["end_t"] <= 300:
fv = s["fv"]
if fv is not None and s["inj"] is None and 0 <= t - fv[0] <= 60 \
and drv.cur == fv[1] and 0 <= t - s["end_t"] <= 300:
# the hold rose over a value the random foreign branch set
# (never one of N1b's directed old-value takes)
bump("foreign_hold_after_end")
s["fh"] = False
s["prev_hold"] = w.hold
lines = len([1 for _t, lv, m in K.LOG
if (kind == "solar" and K.OTHER in m)
@@ -300,6 +326,7 @@ def fuzz(kind, seed):
s["vals"]))
s["armed"] = False # a foreign value: judged as ever
s["pend"] = ("hold", list(s["vals"]))
s["fh"] = True
bump("armed_foreign")
elif seen is not None and seen > CM.TOL_A and seen in s["vals"]:
bump("armed_take_seen")
@@ -311,6 +338,7 @@ def fuzz(kind, seed):
if s["pend"] is not None and s["pend"][0] == "hold" \
and not w.hold and w.mismatch_since is None:
s["pend"] = None # the foreign value went: no hold
s["fh"] = False
if s["pend"] is not None and s["inj"] is None and not gone \
and not unk and not stale and w.seq is None and not wrote \
and not press_now and rnd.random() < 0.5 \
@@ -340,22 +368,39 @@ def fuzz(kind, seed):
allbad = []
MIXED, DIRECTED = {}, {}
COUNT = MIXED # pass 1: the mixed pass, full interference
for kind in ("solar", "manual"):
for seed in range(SEEDS):
allbad += fuzz(kind, seed)
COUNT = DIRECTED # pass 2: calm Solar changes, in addition
for kind in ("solar", "manual"):
for seed in range(SEEDS):
allbad += fuzz(kind, seed, directed=True)
for tag in ("N1", "N1b", "N2", "N4", "N5", "N6", "N7", "N8", "N9"):
K.check(f"T21 {tag}: holds in every cycle of {SEEDS} seeds x {STEPS} s, "
f"Solar and Manual, both orders "
f"Solar and Manual, both orders, in both passes "
f"({[b for b in allbad if b[3].startswith(tag + ' ')][:2]})",
not [b for b in allbad if b[3].startswith(tag + ' ')])
print(" counts", dict(sorted(COUNT.items())))
print(" mixed counts", dict(sorted(MIXED.items())))
print(" directed counts", dict(sorted(DIRECTED.items())))
floor = {"late_nonlast_solar": 10, "late_nonlast_manual": 5,
"cap_end_take": 5, "bound_take_held": 5, "bound_write_held": 5,
"bound_user_held": 5, "bound_hold_held": 5, "bound_return_held": 5,
"foreign_hold_after_end": 5, "end": 20, "end_cap": 3,
"armed_take_seen": 20, "foreign": 20, "hold": 5}
"armed_take_seen": 20, "late_take_ended_val": 10, "foreign": 20,
"hold": 5}
# The mixed pass must reach these on its own (the base of the fuzz).
base = ("end", "armed_take_seen", "late_take_ended_val", "foreign", "hold",
"foreign_hold_after_end", "late_nonlast_manual")
if STEPS >= 1200 and SEEDS >= 10:
K.check(f"T21: the fuzz reaches the plan's floors "
f"({ {k: COUNT.get(k, 0) for k in floor} }, floor {floor})",
all(COUNT.get(k, 0) >= v for k, v in floor.items()))
for k, v in floor.items():
m, d = MIXED.get(k, 0), DIRECTED.get(k, 0)
if k in base or m >= v:
K.check(f"T21 floor {k} >= {v} in the mixed pass alone ({m})",
m >= v)
else:
K.check(f"T21 floor {k} >= {v}: mixed {m} + directed {d} (the "
f"calm pass adds what full interference rarely reaches)",
m + d >= v)
K.done()