Core: fix three coding bugs from the core review, with rule tests (#11)

1. Letting the Red pass. Only climbing down quickly puts you above the Red, so a tree run that
   passed on the Red and then met the Greens let it pass. Those 16 runs were coded as slow
   descents; they are now "Descend quickly: let the Red pass" and count for the Greens'
   encounter, so the route model's "let it pass" option rests on its own runs. A tree run with
   both the Red and the Greens attempted (impossible in one run) is now flagged.
2. Leaving your squadmates. The form only offered "> Left them" from 2026-10-27 (0 of 504 squad
   runs before chose it, 40 of 144 after). Earlier and undated squad runs are now unknown rather
   than "stayed together" (form.yaml: left_squadmates_asked_from).
3. Bot text. The wounded cadet's other two choices map onto the form; a test checks every choice
   the bot has logged maps onto a form variable (encounter answers excepted, not modelled yet).

Each rule has a test in tests/core/test_coding.py. Data rebuilt (runs, graph, policy, report);
the headline odds move by at most 0.02 points. The Methods tab describes both rules.


Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ekcSchiano
2026-11-03 21:12:34 +00:00
committed by GitHub
co-authored by Claude Opus 5.5
parent cc86343668
commit 963b08c522
15 changed files with 974 additions and 926 deletions
+8
View File
@@ -147,6 +147,8 @@ def code_row(r, C):
suffix = F["company_left_suffix"]
left_squad = company_raw.endswith(suffix)
company = company_raw[: -len(suffix)] if left_squad else company_raw
if not left_squad and company in ("1 Squadmate", "2 Squadmates") and not (date and date >= F["left_squadmates_asked_from"]):
left_squad = None # the form did not offer "left them" yet: unknown, not "stayed together"
pools = F["sighting_pool"]
pool = list(pools.get(company, {}).get(direction, [])) + (list(pools["Alone"].get(direction, [])) if left_squad else [])
if first and first != "Unsure" and pool and first not in pool:
@@ -198,8 +200,14 @@ def code_row(r, C):
if hour == "Tree":
if enc["Blue"] or enc["Black"] or rare == "Shadow":
branch = "Shadow (rare)"
elif enc["Red"] == ENC["passed"] and enc["Green"]:
# only climbing down quickly puts you above the Red: passing on it and meeting the Greens means the
# rider let it pass
branch = "Descend quickly: let the Red pass"
elif enc["Green"]:
branch = "Descend slowly: two Greens"
if enc["Red"]:
flags.append("tree run with both the Red and the two Greens attempted")
elif enc["Red"]:
branch = "Descend quickly: Red"
elif enc["Orange"] or enc["Brown"]:
+5 -7
View File
@@ -63,7 +63,8 @@ def prepare_run(r):
"direction": r["direction"] if r["direction"] in DECISIONS["direction"] else None,
"fs": r["first_sighting"] if r["first_sighting"] in ("Red", "Brown", "Green", "Orange") else None}
lf = r.get("left_squadmates")
v["left"] = ALONE if v["company"] == "Alone" else (("Leave them" if lf is True or str(lf).lower() == "true" else "Stay together") if v["company"] else None)
known = lf is not None and not (isinstance(lf, float) and lf != lf) and lf != ""
v["left"] = ALONE if v["company"] == "Alone" else (("Leave them" if lf is True or str(lf).lower() == "true" else "Stay together") if v["company"] and known else None)
v["react"] = r["sighting_action"] if r.get("sighting_action") in DECISIONS["react"] else None
v["diedSight"] = r["scream"] == "DIED at first sighting"
if v["diedSight"]:
@@ -98,12 +99,9 @@ def prepare_run(r):
v["shadowColour"] = "Black" if r.get("enc_Black") else "Blue"
v["encCtx"] = "shadow-" + v["shadowColour"]
elif b == "Descend quickly: Red":
v["descend"] = "Quickly (Red)"
# a rider who let the Red pass and met the Greens instead
if r.get("enc_Red") == "Changed my mind" and r.get("enc_Green"):
v["red"], v["encCtx"] = "Let it pass (two Greens)", "tree-Greens"
else:
v["red"], v["encCtx"] = "Jump onto the Red", "tree-Red"
v["descend"], v["red"], v["encCtx"] = "Quickly (Red)", "Jump onto the Red", "tree-Red"
elif b == "Descend quickly: let the Red pass":
v["descend"], v["red"], v["encCtx"] = "Quickly (Red)", "Let it pass (two Greens)", "tree-Greens"
elif b == "Descend slowly: two Greens":
v["descend"], v["encCtx"] = "Slowly (two Greens)", "tree-Greens"
elif v["hour"] == "Valley" and b: