EV-71: Solar and Manual keep their own untaken non-zero write as their own
checks / unit (pull_request) Successful in 58m47s
infra-pin / fresh (pull_request) Successful in 2s

A press that lifts nothing no longer clears attempted_a, prior_a, the EV-69
carry or the new kept value; a held read no longer adopts (no taken, carry
untouched, the owed 0 A is written); a refused 0 A no longer loses the
untaken non-zero value. The kept value ends at a fresh own take, a different
non-zero write, a lifting press, a hold or Solar's charger return.

Existing tests edited only as the brief allows: test_ev69.py T12 (press
alone) and T24 setup, test_ev69_fuzz.py N4, N1b user cause, I1, I2.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Claude
2026-12-05 00:22:01 +01:00
parent 278041b25c
commit 0eb332d93f
4 changed files with 714 additions and 22 deletions
+43 -7
View File
@@ -91,10 +91,21 @@ def fuzz_mixed(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(),
nsel=0, cap=False, cap_counted=False, fv=None, end_t=-9999)
nsel=0, cap=False, cap_counted=False, fv=None, end_t=-9999,
lift_t=-1, ev_t=-1)
clamp = {"v": 16.0}
_uc = w.user_changed
def user_changed():
# EV-71 P1: a press that lifts nothing ends nothing; N4 asks only of
# a press that lifts a running count or a hold.
if w._other_stands():
s["lift_t"] = s["ev_t"]
_uc()
w.user_changed = user_changed
def ev(t):
s["ev_t"] = t
if rnd.random() < (0.25 if w.seq is not None else 0.01):
clamp["v"] = rnd.choice([16.0, 12.0, 10.0, 8.0, 8.0])
st["clamp"] = clamp["v"]
@@ -215,7 +226,8 @@ def fuzz_mixed(kind, seed):
ended_now = before_seq and w.seq is None
if w.hold and w._carry:
bad.append((kind, seed, t, "N4 carry under a hold", w._carry))
if press_now and w._carry and not ended_now:
# EV-71 P1: a press that lifts nothing ends nothing
if press_now and s["lift_t"] == t and w._carry and not ended_now:
bad.append((kind, seed, t, "N4 carry after a press", w._carry))
if wrote and w._carry and not ended_now:
bad.append((kind, seed, t, "N4 carry after a write", w._carry))
@@ -228,7 +240,7 @@ def fuzz_mixed(kind, seed):
a for tt, a in new if a > 0]
s["armed"] = True
s["end_t"] = t
s["cap"] = kind == "solar" and w.cut_fails >= CM.MAX_TRIES
s["cap"] =kind == "solar" and w.cut_fails >= CM.MAX_TRIES
s["cap_counted"] = False
bump("end")
if s["cap"]:
@@ -280,10 +292,20 @@ def fuzz_directed(kind, seed):
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, fv=None, pend=None,
inj=None, end_t=-9999)
inj=None, end_t=-9999, lift_t=-1, ev_t=-1)
clamp = {"v": 16.0}
_uc = w.user_changed
def user_changed():
# EV-71 P1: a press that lifts nothing ends nothing; N4 and N1b's
# "user" cause concern only a press that lifts a count or a hold.
if w._other_stands():
s["lift_t"] = s["ev_t"]
_uc()
w.user_changed = user_changed
def ev(t):
s["ev_t"] = t
if s["inj"] is not None: # a directed old-value take
drv.cur = s["inj"]["v"]
return
@@ -370,6 +392,9 @@ def fuzz_directed(kind, seed):
for t in range(STEPS):
if not order_b:
ev(t)
# EV-71 I2: during an N1b injection this pass skips the gone / unknown
# / stale draws (`ev()` returns early, and `gone`, `unk` and `stale`
# are False below), so the injected old value is read, held, as is.
inj = s["inj"]
gone = False if inj else s["gone"]
unk = False if inj else rnd.random() < 0.02
@@ -446,7 +471,9 @@ def fuzz_directed(kind, seed):
bump(f"seq_end_{kind}_{'taken' if tk else 'refused'}")
if w.hold and w._carry:
bad.append((kind, seed, t, "N4 carry under a hold", w._carry))
if press_now and w._carry and not ended_now:
# EV-71 P1: a press that lifts nothing ends nothing
lifted_now = press_now and s["lift_t"] == t
if lifted_now and w._carry and not ended_now:
bad.append((kind, seed, t, "N4 carry after a press", w._carry))
if wrote and w._carry and not ended_now:
bad.append((kind, seed, t, "N4 carry after a write", w._carry))
@@ -486,7 +513,9 @@ def fuzz_directed(kind, seed):
if s["kind"] == "cap":
bump("end_cap")
elif s["armed"]:
cause = ("hold" if w.hold else "user" if press_now
# EV-71 P1: a press that lifts nothing ends nothing, so it is no
# "user" cause (a lifting press leaves nothing armed: see below)
cause = ("hold" if w.hold else "user" if lifted_now
else "write" if wrote
else "return" if (gone or s["was_gone"])
else "take" if took else None)
@@ -507,6 +536,10 @@ def fuzz_directed(kind, seed):
if s["kind"] == "cap" and not s["cap_counted"]:
s["cap_counted"] = True
bump("cap_end_take")
# EV-71 P1: a press that lifts the count or hold of a "hold" end is the
# "user" end of that bound: it ends everything (DA1)
if lifted_now and s["pend"] is not None and s["pend"][0] == "hold":
s["pend"] = ("user", s["pend"][1])
# start a directed old-value take once the bound has ended and the
# writer is calm: the value must not be own by any other route
if s["pend"] is not None and s["pend"][0] == "hold" \
@@ -517,7 +550,10 @@ def fuzz_directed(kind, seed):
and not press_now and rnd.random() < 0.5 \
and (s["pend"][0] != "hold" or w.hold):
cause, vals = s["pend"]
own = w._own_values()
# EV-71 I1/F5: the writer's own fields, the kept value included,
# never `_carry` (a carried value is exactly what N1b injects)
own = [x for x in (w.last_a, w.attempted_a, w.prior_a,
getattr(w, "_kept", None)) if x is not None]
pool = [v for v in vals if v > CM.TOL_A
and all(abs(v - o) > CM.TOL_A for o in own)]
if not pool: # any other value the writer tried