Bot import: one folder per account, run records with steps

- the importer reads data/accounts/*/runs.jsonl and logs/accounts/*/encounters.jsonl;
  with account folders, the top-level files (a mirror of the first account) are skipped
- run records that carry their steps (schema 2) become trajectories directly, keeping
  what the bot saw (shadow, meadow dragons), propensities, decision mode and policy id;
  older runs are still rebuilt from the decision log; bonded runs without steps are kept
- account names become salted hashes (DK_ACCOUNT_SALT, or a private salt in data/raw)
- runs_clean.csv: new bot_mode column; saw_shadow and saw_blue_meadow from what the bot
  saw; deliberate burns say why
- crosswalk: the valley Red, leaving squadmates, squad direction, hold your ground,
  hide/approach reactions, the wounded cadet's other two choices

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
This commit is contained in:
ekcSchiano
2026-11-10 02:08:57 +00:00
co-authored by Claude Opus 5.5
parent dd25dfaa32
commit 43066ad67f
13 changed files with 6292 additions and 6051 deletions
+35 -5
View File
@@ -150,10 +150,27 @@ def bot_variables(traj, crosswalk):
return v, unmapped
BURN_REASONS = { # why the bot chose to die, in words (the bot's own reason codes)
"TREE_NO_SHADOW_AUTO_BURN": "no shadow at the tree",
"MEADOW_NO_BLUE_AUTO_BURN": "no Blue in the meadow",
}
def _seen_after(steps, start, key):
"""Values the bot saw (step["seen"][key]) from step index `start` on."""
out = []
for st in steps[start:]:
v = (st.get("seen") or {}).get(key)
if v is not None:
out += v if isinstance(v, list) else [v]
return out
def bot(name, spec):
cw = [(re.compile(rx), col, val) for rx, col, val in read_yaml(spec["transform"]["spec"])["crosswalk"]]
rows = []
for traj in bot_trajectories(spec):
steps = traj["steps"]
v, _ = bot_variables(traj, cw)
red = v.pop("red", None)
v.pop("scream_investigate", None)
@@ -165,18 +182,31 @@ def bot(name, spec):
if o["type"] == "BONDED":
outcome, colour = "Bonded", (o.get("colour") or "").capitalize() or None
elif o["type"] == "BURNED":
last_tint = traj["steps"][-1].get("tint")
last_tint = steps[-1].get("tint") if steps else None
outcome = "Incinerated" if v.get("hour") else "Died before the hour"
colour = last_tint.capitalize() if last_tint and v.get("hour") else None
if o.get("intentional"):
flags.append("deliberate burn (the bot chose to die)")
else:
why = BURN_REASONS.get(o.get("reason") or "", "")
flags.append("deliberate burn (the bot chose to die" + (f": {why}" if why else "") + ")")
else: # ABORTED, ENDED_NO_BOND: the run stopped without an ending the bot saw
outcome, colour = "No outcome recorded", None
if not steps:
flags.append("bonded dragon only (the bot logged no steps)")
target = (meta.get("target") or "").capitalize() or None
row = blank_row(run_id=traj["id"], source=spec["run_source"], date=(meta.get("startedAt") or "")[:10] or None,
attempt=meta.get("attempt"), goal=target if target in COLOURS else None,
row = blank_row(run_id=traj["id"], source=spec["run_source"], bot_mode=meta.get("decisionMode"),
date=(meta.get("startedAt") or "")[:10] or None, attempt=meta.get("attempt"),
goal=target if target in COLOURS else None,
outcome=outcome, outcome_color=colour, data_flags="; ".join(flags), **v)
row["attempt_group"] = attempt_group(row["attempt"])
# what the bot saw: the shadow at the treetop, and which dragons waited in the meadow
shadow = _seen_after(steps, 0, "shadow")
if row["hour"] == "Tree" and shadow:
row["saw_shadow"] = any(shadow)
if row["branch"] == "Passed the Red: meadow":
i = next((k for k, st in enumerate(steps) if re.search(r"no way this is your dragon", _norm(st["optionText"]))), len(steps))
meadow = _seen_after(steps, i + 1, "dragons")
if meadow or o.get("reason") == "MEADOW_NO_BLUE_AUTO_BURN":
row["saw_blue_meadow"] = "blue" in meadow or colour == "Blue"
encounter_columns(row, intentional=bool(o.get("intentional")))
rows.append(row)
return rows