Datasets:

Modalities:
Text
Languages:
English
Size:
< 1K
ArXiv:
Libraries:
Datasets
Harbor
License:
lewtun HF Staff commited on
Commit
a43f73c
·
verified ·
1 Parent(s): 6900e6a

s3-maze: metrics.py reads a Slurm run's resolved spec for the task and the roster, and flags missing or unplanned agents; generate.py records the seed it used (flock#123 review #1)

Browse files
Files changed (4) hide show
  1. README.md +15 -4
  2. check.py +106 -7
  3. eval/metrics.py +36 -15
  4. generate.py +3 -3
README.md CHANGED
@@ -251,13 +251,17 @@ move logs the grader keeps:
251
  | `rooms`, `rooms_union` | the rooms each agent visited (the start included), and the team's together |
252
  | `room_overlap` | the paper's (Appendix M): (V - U) / V, V = sum_i (\|R_i\| - 1), U = \|union of the R_i\| - 1: 0 when no two agents visit the same room, near 1 when all walk the same path; `null` when no agent moved |
253
  | `exit_reached_by` | the agents whose walk reached the exit |
254
- | `missing` | what the run directory lacks: an agent's reward or move log, the board export |
255
 
256
  A reward and a move log count only from a Trial whose `result.json` holds Harbor's verifier
257
  result: the agent's container can write into its `verifier/` folder while it works, and only
258
  the verifier's run replaces what is there. A Slurm run has no local bundle, so there the tokens
259
  come from Harbor's Trial results (no reasoning split), and `stop_reason`, `cost_usd` and the
260
- turns are `null`.
 
 
 
 
261
 
262
  ## Checks
263
 
@@ -275,7 +279,7 @@ CONTAINERS_REGISTRIES_CONF=$DS/flock/registries.conf .venv/bin/python $DS/check.
275
  podman_node_cleanup'`.
276
 
277
  1. **Generator:** `generate.py` reproduces `tasks/` byte for byte, and another seed gives other
278
- trees. Each tree has 391 rooms with distinct 4-digit labels, is a tree (390 two-way doors,
279
  all reachable), has 27 dead ends all 30 moves from the start, one of them the exit; the
280
  shortest path is 30 moves and a full depth-first search through the engine 780; the way back
281
  is listed in every position a room can have it; the exits fall on many positions of the
@@ -309,7 +313,14 @@ podman_node_cleanup'`.
309
  `maze` command and names no room, nor do the instruction, `task.toml` or the compose file;
310
  the exit is named only in the service's `tree.json`, `tests/expected.json` and
311
  `solution/solve.sh`; no folder beside `tasks/` holds a tree.
312
- 5. **Trials** (`--env podman` or `docker`, on `maze-t01`, with agents that need no model):
 
 
 
 
 
 
 
313
  - a walker runs Flock's success check in the maze service (false), walks the shortest path
314
  with `maze move`, runs it again (true), and scores 1, with the move log and the export in
315
  its verifier's folder;
 
251
  | `rooms`, `rooms_union` | the rooms each agent visited (the start included), and the team's together |
252
  | `room_overlap` | the paper's (Appendix M): (V - U) / V, V = sum_i (\|R_i\| - 1), U = \|union of the R_i\| - 1: 0 when no two agents visit the same room, near 1 when all walk the same path; `null` when no agent moved |
253
  | `exit_reached_by` | the agents whose walk reached the exit |
254
+ | `missing` | what the run directory lacks (an agent's reward or move log, the board export), and where its spec and its Trials disagree |
255
 
256
  A reward and a move log count only from a Trial whose `result.json` holds Harbor's verifier
257
  result: the agent's container can write into its `verifier/` folder while it works, and only
258
  the verifier's run replaces what is there. A Slurm run has no local bundle, so there the tokens
259
  come from Harbor's Trial results (no reasoning split), and `stop_reason`, `cost_usd` and the
260
+ turns are `null`. Its task and roster come from `experiment/spec.yaml` as the run resolved it:
261
+ `${VAR}`s from `cluster.env` then `run.env`, else their defaults. Every agent the spec planned
262
+ is in the row, so one whose results are missing is flagged rather than dropped; so are Trials
263
+ of an agent the spec didn't plan, or of another task than it selects (e.g. a run directory
264
+ whose `run.env` is gone, read with the defaults).
265
 
266
  ## Checks
267
 
 
279
  podman_node_cleanup'`.
280
 
281
  1. **Generator:** `generate.py` reproduces `tasks/` byte for byte, and another seed gives other
282
+ trees, which record that seed in their `task.toml` and regenerate from it. Each tree has 391 rooms with distinct 4-digit labels, is a tree (390 two-way doors,
283
  all reachable), has 27 dead ends all 30 moves from the start, one of them the exit; the
284
  shortest path is 30 moves and a full depth-first search through the engine 780; the way back
285
  is listed in every position a room can have it; the exits fall on many positions of the
 
313
  `maze` command and names no room, nor do the instruction, `task.toml` or the compose file;
314
  the exit is named only in the service's `tree.json`, `tests/expected.json` and
315
  `solution/solve.sh`; no folder beside `tasks/` holds a tree.
316
+ 5. **Metrics** (`eval/metrics.py`) on Slurm run directories made of the service's real exports
317
+ and the grader's real grades, with Flock's example spec (`${TREE:-maze-t01}`,
318
+ `${N:-4}`): with no env files the row's task is `maze-t01` and its team four agents;
319
+ `run.env` (over `cluster.env`) sets another tree and team size; a team with one agent's
320
+ results gone keeps that agent and flags its reward and move log as missing; and the row
321
+ flags Trials of another task than the spec selects (a `run.env` gone) and of an agent the
322
+ spec didn't plan.
323
+ 6. **Trials** (`--env podman` or `docker`, on `maze-t01`, with agents that need no model):
324
  - a walker runs Flock's success check in the maze service (false), walks the shortest path
325
  with `maze move`, runs it again (true), and scores 1, with the move log and the export in
326
  its verifier's folder;
check.py CHANGED
@@ -1,6 +1,6 @@
1
  # /// script
2
  # requires-python = ">=3.12"
3
- # dependencies = ["harbor==0.25.0"]
4
  # ///
5
  """s3-maze's checks that need no model (huggingface/flock#115, section 5):
6
 
@@ -9,10 +9,11 @@
9
  uv run check.py --env none # without the Trials (no container engine needed)
10
 
11
  1. Generator: generate.py reproduces tasks/ byte for byte from its seed, and another seed gives
12
- other trees. Each of the 32 trees has 391 rooms with distinct labels of one fixed length,
13
- is a tree (390 two-way doors, every room reachable from the start), has 27 dead ends, all 30
14
- moves from the start, one of which is the exit; the shortest path is 30 moves and a full
15
- depth-first search through the service's engine 780. Door orders are shuffled (the way back
 
16
  is not always listed in the same place), and the exits fall on many positions of the search
17
  order. Every task's service, agent and grader files are template/'s, its image tags are its
18
  files' digests, and the budget is the same in the tree, the grader, the instruction and
@@ -47,7 +48,13 @@
47
  Dockerfile and the `maze` command, and names no room; nor do the instruction, task.toml or
48
  the compose file; the exit is named only in environment/maze/tree.json, tests/expected.json
49
  and solution/solve.sh; and no folder beside tasks/ holds a tree.
50
- 5. Trials (`--env`), on maze-t01, with agents that need no model:
 
 
 
 
 
 
51
  - a walker checks flock's success_check in the maze service (false), walks the shortest path
52
  with `maze move`, checks it again (true), and scores 1; the verifier's folder then holds
53
  the move log and the export;
@@ -83,7 +90,9 @@ HERE = Path(__file__).resolve().parent
83
  sys.dont_write_bytecode = True # nothing new in tasks/ or template/
84
  sys.path.insert(0, str(HERE))
85
  sys.path.insert(0, str(HERE / "template" / "environment" / "maze"))
 
86
  import generate as g # noqa: E402
 
87
  from engine import Maze, Walk # noqa: E402
88
 
89
  LABEL = re.compile(rf"R\d{{{g.DIGITS}}}")
@@ -146,6 +155,14 @@ def check_generator() -> None:
146
  shutil.copytree(HERE / "template", Path(d) / "template")
147
  g.generate(Path(d))
148
  check(files(Path(d)) == files(HERE), "generate.py does not reproduce the committed tasks/")
 
 
 
 
 
 
 
 
149
  drawn = g.trees()
150
  check(drawn == g.trees(), "the same seed gave other trees")
151
  check(all(a["doors"] != b["doors"] for a, b in zip(drawn, g.trees(g.SEED + 1), strict=True)),
@@ -669,6 +686,85 @@ def check_files() -> None:
669
  "template/ names a room")
670
 
671
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
672
  # ------------------------------------------------------------------ Trials
673
 
674
  # Runs in the agent's container as `python3 -c PROBE_PY <base64 config>`; its config travels
@@ -915,12 +1011,15 @@ def main() -> int:
915
  before = len(failures)
916
  check_files()
917
  print(f"4. no-cheat (files): {len(failures) - before} failures")
 
 
 
918
  if args.env != "none":
919
  before = len(failures)
920
  jobs = args.jobs_dir or work / "jobs"
921
  jobs.mkdir(parents=True, exist_ok=True)
922
  report = asyncio.run(check_trials(args.env, jobs, work))
923
- print(f"5. Trials on {args.env} ({PROBE_TASK}): {len(failures) - before} failures; "
924
  f"{json.dumps(report)}")
925
  for failure in failures:
926
  print("FAIL:", failure)
 
1
  # /// script
2
  # requires-python = ">=3.12"
3
+ # dependencies = ["harbor==0.25.0", "pyyaml"]
4
  # ///
5
  """s3-maze's checks that need no model (huggingface/flock#115, section 5):
6
 
 
9
  uv run check.py --env none # without the Trials (no container engine needed)
10
 
11
  1. Generator: generate.py reproduces tasks/ byte for byte from its seed, and another seed gives
12
+ other trees, which record that seed in their task.toml and regenerate from it. Each of the
13
+ 32 trees has 391 rooms with distinct labels of one fixed length, is a tree (390 two-way
14
+ doors, every room reachable from the start), has 27 dead ends, all 30 moves from the start,
15
+ one of which is the exit; the shortest path is 30 moves and a full depth-first search
16
+ through the service's engine 780. Door orders are shuffled (the way back
17
  is not always listed in the same place), and the exits fall on many positions of the search
18
  order. Every task's service, agent and grader files are template/'s, its image tags are its
19
  files' digests, and the budget is the same in the tree, the grader, the instruction and
 
48
  Dockerfile and the `maze` command, and names no room; nor do the instruction, task.toml or
49
  the compose file; the exit is named only in environment/maze/tree.json, tests/expected.json
50
  and solution/solve.sh; and no folder beside tasks/ holds a tree.
51
+ 5. Metrics (eval/metrics.py) on Slurm run directories made of real exports and grades, with
52
+ the example spec's `${TREE:-maze-t01}` and `${N:-4}`: with no env files the row's task is
53
+ maze-t01 and its team four agents; `run.env` (over `cluster.env`) sets another tree and team
54
+ size; a team with one agent's results gone keeps that agent and flags its reward and move
55
+ log as missing; and the row flags Trials of another task than the spec selects (a `run.env`
56
+ gone) and of an agent the spec didn't plan.
57
+ 6. Trials (`--env`), on maze-t01, with agents that need no model:
58
  - a walker checks flock's success_check in the maze service (false), walks the shortest path
59
  with `maze move`, checks it again (true), and scores 1; the verifier's folder then holds
60
  the move log and the export;
 
90
  sys.dont_write_bytecode = True # nothing new in tasks/ or template/
91
  sys.path.insert(0, str(HERE))
92
  sys.path.insert(0, str(HERE / "template" / "environment" / "maze"))
93
+ sys.path.insert(0, str(HERE / "eval"))
94
  import generate as g # noqa: E402
95
+ import metrics # noqa: E402
96
  from engine import Maze, Walk # noqa: E402
97
 
98
  LABEL = re.compile(rf"R\d{{{g.DIGITS}}}")
 
155
  shutil.copytree(HERE / "template", Path(d) / "template")
156
  g.generate(Path(d))
157
  check(files(Path(d)) == files(HERE), "generate.py does not reproduce the committed tasks/")
158
+ other = g.SEED + 1 # the seed a task records regenerates its tree
159
+ g.generate(Path(d), seed=other)
160
+ for t, tree in enumerate(g.trees(other), 1):
161
+ task = Path(d) / "tasks" / g.task_name(t)
162
+ recorded = re.findall(r"^seed = (\d+)$", (task / "task.toml").read_text(), re.M)
163
+ check(recorded == [str(other)] and tree_of(task) == tree
164
+ and g.trees(int(recorded[0]))[t - 1] == tree,
165
+ f"seed {other}: {task.name} records seed {recorded}, not its own")
166
  drawn = g.trees()
167
  check(drawn == g.trees(), "the same seed gave other trees")
168
  check(all(a["doors"] != b["doors"] for a, b in zip(drawn, g.trees(g.SEED + 1), strict=True)),
 
686
  "template/ names a room")
687
 
688
 
689
+ # ------------------------------------------------------------------ metrics
690
+
691
+ # The example spec's lines that metrics.py reads (Flock's experiments/s3-maze/spec.yaml)
692
+ RUN_SPEC = """name: ${RUN_NAME:-s3-maze}
693
+ naming: consecutive-id
694
+ task:
695
+ repo: https://huggingface.co/datasets/HuggingFaceSwarms/s3-maze
696
+ selector: ${TREE:-maze-t01}
697
+ revision: REVISION
698
+ agents:
699
+ count: ${N:-4}
700
+ """
701
+
702
+
703
+ def run_dir(root: Path, work: Path, tree: str, walks: dict[str, bool],
704
+ env_files: dict[str, str]) -> Path:
705
+ """A Slurm run's directory, as `flock init` and the workers leave it: the spec, the env
706
+ files and, per agent in `walks`, one Trial of `tree` (the exit reached or not) graded by the
707
+ task's own grader on the maze service's own export."""
708
+ task = HERE / "tasks" / tree
709
+ layout = tree_of(task)
710
+ (root / "experiment").mkdir(parents=True)
711
+ (root / "experiment" / "spec.yaml").write_text(RUN_SPEC)
712
+ for name, text in env_files.items():
713
+ (root / name).write_text(text)
714
+ for k, (agent, wins) in enumerate(walks.items()):
715
+ rooms = g.shortest_path(layout) if wins else dead_end_walk(layout, 20)
716
+ source = evidence(task, work, f"{root.name}-{agent}", rooms)
717
+ trial = root / "results" / "s3-maze" / agent / "trials" / f"s3-maze-{agent}-t1"
718
+ env = {**os.environ, "EVIDENCE_DIR": str(source), "VERIFIER_DIR": str(trial / "verifier")}
719
+ subprocess.run(["bash", str(task / "tests" / "test.sh")], env=env, capture_output=True,
720
+ timeout=60, check=True)
721
+ reward = float((trial / "verifier" / "reward.txt").read_text())
722
+ (trial / "result.json").write_text(json.dumps({
723
+ "task_name": f"HuggingFaceSwarms/{tree}", "trial_name": trial.name,
724
+ "started_at": f"2026-11-17T11:38:1{k}+00:00",
725
+ "finished_at": "2026-11-17T11:50:04+00:00",
726
+ "agent_result": {"n_input_tokens": 1000, "n_cache_tokens": 800, "n_output_tokens": 50},
727
+ "verifier_result": {"rewards": {"reward": reward}}}))
728
+ return root
729
+
730
+
731
+ def check_metrics(work: Path) -> int:
732
+ team4 = {f"agent-{k:03d}": k == 3 for k in range(1, 5)}
733
+ cases = { # name: (tree, walks, env files, task, agents, missing besides the board export)
734
+ "defaults": ("maze-t01", team4, {}, "maze-t01", 4, []),
735
+ "run.env": ("maze-t02", {"agent-001": True, "agent-002": False},
736
+ {"cluster.env": "N=3\nTREE=maze-t05\n",
737
+ "run.env": "#TREE=maze-t01\nTREE=maze-t02\nN=2\nRUN_NAME=s3-maze-b\n"},
738
+ "maze-t02", 2, []),
739
+ "an agent's results gone": ("maze-t01", {a: w for a, w in team4.items()
740
+ if a != "agent-004"}, {}, "maze-t01", 4,
741
+ ["reward: agent-004", "move log: agent-004"]),
742
+ "run.env gone": ("maze-t02", {"agent-001": True, "agent-002": False}, {}, "maze-t01", 4,
743
+ ["task: the spec selects 'maze-t01', the Trials ran maze-t02",
744
+ "reward: agent-003", "reward: agent-004", "move log: agent-003",
745
+ "move log: agent-004"]),
746
+ "an unplanned agent": ("maze-t01", {"agent-001": True, "agent-002": False,
747
+ "agent-003": False}, {"run.env": "N=2\n"},
748
+ "maze-t01", 2,
749
+ ["agents: Trials of agents the spec didn't plan: agent-003"]),
750
+ }
751
+ for case, (tree, walks, env_files, task, agents, missing) in cases.items():
752
+ name = "run-" + re.sub(r"\W+", "-", case)
753
+ r = metrics.row(run_dir(work / name, work, tree, walks, env_files))
754
+ expected_rewards = {a: float(w) for a, w in walks.items() if a in r["rewards"]}
755
+ check(r["task"] == task and r["agents"] == agents and len(r["rewards"]) == agents,
756
+ f"metrics, {case}: task {r['task']!r}, {r['agents']} agents, not {task!r}, {agents}")
757
+ check(sorted(r["missing"]) == sorted(missing + ["board export"]),
758
+ f"metrics, {case}: missing {r['missing']}")
759
+ check({a: v for a, v in r["rewards"].items() if v is not None} == expected_rewards
760
+ and r["success"] is any(expected_rewards.values()),
761
+ f"metrics, {case}: rewards {r['rewards']}")
762
+ moved = {a: 30 if w else 20 for a, w in walks.items() if a in r["rewards"]}
763
+ check({a: n for a, n in r["moves"].items() if a in moved} == moved,
764
+ f"metrics, {case}: moves {r['moves']}")
765
+ return len(cases)
766
+
767
+
768
  # ------------------------------------------------------------------ Trials
769
 
770
  # Runs in the agent's container as `python3 -c PROBE_PY <base64 config>`; its config travels
 
1011
  before = len(failures)
1012
  check_files()
1013
  print(f"4. no-cheat (files): {len(failures) - before} failures")
1014
+ before = len(failures)
1015
+ cases = check_metrics(work)
1016
+ print(f"5. metrics: {len(failures) - before} failures; {cases} run directories")
1017
  if args.env != "none":
1018
  before = len(failures)
1019
  jobs = args.jobs_dir or work / "jobs"
1020
  jobs.mkdir(parents=True, exist_ok=True)
1021
  report = asyncio.run(check_trials(args.env, jobs, work))
1022
+ print(f"6. Trials on {args.env} ({PROBE_TASK}): {len(failures) - before} failures; "
1023
  f"{json.dumps(report)}")
1024
  for failure in failures:
1025
  print("FAIL:", failure)
eval/metrics.py CHANGED
@@ -16,21 +16,26 @@ JSON line; README.md has every field):
16
  post that mentions no one adds no edge;
17
  - for the maze: each agent's moves, the rooms it visited and the team's room overlap, from the
18
  move logs the grader keeps in each Trial's `verifier/`;
19
- - `missing`: what the run directory lacks (an agent's reward or move log, the board export), so
20
- a row never passes for complete when it is not.
21
 
22
  A reward and a move log count only from a Trial whose `result.json` holds Harbor's verifier
23
  result: the agent's container can write into `verifier/` while it works, and only the
24
  verifier's run replaces what is there.
25
 
26
  A local run's `run.json` gives the spec, the agents, their tokens (summed over models), the
27
- cost and how the run ended. A Slurm run has no such bundle: the team and the task come from
28
- its `experiment/spec.yaml`, each agent's tokens from its Trials' results (no reasoning split),
29
- and the run's span from its Trials. The board may hold earlier runs' messages (a reused Space):
30
- only those posted within the run's span count.
 
 
 
 
31
  """
32
 
33
  import argparse
 
34
  import json
35
  import re
36
  import sys
@@ -256,28 +261,44 @@ def expand(text: str, values: dict[str, str]) -> str:
256
 
257
 
258
  def slurm_run(run_dir: Path, trials: dict[str, list[Path]]) -> dict:
259
- """What a Slurm run's directory says: its spec (`flock init` copies the experiment, with
260
- its `${VAR}`s filled from the run's env files) and the Trials the workers kept."""
 
 
 
 
261
  path = run_dir / "experiment" / "spec.yaml"
262
  spec = (yaml.safe_load(expand(path.read_text(), run_values(run_dir)))
263
- if path.is_file() else {})
 
264
  agents = spec.get("agents") or {}
265
- if spec.get("naming") == "consecutive-id" and isinstance(agents.get("count"), int):
266
- team = [f"agent-{k:03d}" for k in range(1, agents["count"] + 1)]
 
 
 
267
  else:
268
  team = list(trials)
 
 
 
 
269
  times = [(epoch(r["started_at"]), epoch(r["finished_at"]))
270
  for ts in trials.values() for r in results(ts)
271
  if r.get("started_at") and r.get("finished_at")]
272
  start, end = (min(t[0] for t in times), max(t[1] for t in times)) if times else (0, 0)
273
- names = {r.get("task_name") for ts in trials.values() for r in results(ts)}
274
- task = spec.get("task") or {"selector": next((n.split("/")[-1] for n in names if n), None)}
 
 
 
 
275
  swarm = next((t.name.removesuffix(f"-{a}-t{t.name.rsplit('-t', 1)[1]}")
276
  for a, ts in trials.items() for t in ts), spec.get("name"))
277
  return {"swarm": swarm, "task": task, "team": team, "start": start, "end": end,
278
  "stop_reason": None, "duration_s": round(end - start, 1) if times else None,
279
  "cost_usd": None, "tokens": {a: trial_tokens(trials.get(a, [])) for a in team},
280
- "turns": dict.fromkeys(team)}
281
 
282
 
283
  def row(run_dir: Path) -> dict:
@@ -288,7 +309,7 @@ def row(run_dir: Path) -> dict:
288
  messages, channels, exported = board(run_dir, info["start"], info["end"])
289
  posts = Counter(sender(m) for m in messages)
290
  graph = edges(messages, channels, team)
291
- per_agent, missing = {}, []
292
  for name in team:
293
  value = reward(trials.get(name, []))
294
  if value is None:
 
16
  post that mentions no one adds no edge;
17
  - for the maze: each agent's moves, the rooms it visited and the team's room overlap, from the
18
  move logs the grader keeps in each Trial's `verifier/`;
19
+ - `missing`: what the run directory lacks (an agent's reward or move log, the board export) or
20
+ where its spec and its Trials disagree, so a row never passes for complete when it is not.
21
 
22
  A reward and a move log count only from a Trial whose `result.json` holds Harbor's verifier
23
  result: the agent's container can write into `verifier/` while it works, and only the
24
  verifier's run replaces what is there.
25
 
26
  A local run's `run.json` gives the spec, the agents, their tokens (summed over models), the
27
+ cost and how the run ended. A Slurm run has no such bundle: the task and the roster come from
28
+ its `experiment/spec.yaml` as the run resolved it (its `${VAR}`s from `cluster.env` and
29
+ `run.env`, else their defaults), each agent's tokens from its Trials' results (no reasoning
30
+ split), and the run's span from its Trials. Every agent the spec planned has a row entry, so
31
+ one without results shows in `missing`; so do Trials of an unplanned agent or of another task
32
+ than the spec selects (e.g. a run directory whose `run.env` is gone, read with the defaults).
33
+ The board may hold earlier runs' messages (a reused Space): only those posted within the run's
34
+ span count.
35
  """
36
 
37
  import argparse
38
+ import fnmatch
39
  import json
40
  import re
41
  import sys
 
261
 
262
 
263
  def slurm_run(run_dir: Path, trials: dict[str, list[Path]]) -> dict:
264
+ """What a Slurm run's directory says: its spec as the run resolved it (`flock init`'s copy
265
+ of the experiment, its `${VAR}`s filled from `cluster.env` then `run.env`, else their
266
+ defaults) and the Trials the workers kept. The spec gives the task and the roster: every
267
+ agent it planned is in the row, so one whose results are missing is flagged, not dropped.
268
+ `problems` says where the spec and the Trials disagree (e.g. a `run.env` that is gone, its
269
+ values replaced by the defaults)."""
270
  path = run_dir / "experiment" / "spec.yaml"
271
  spec = (yaml.safe_load(expand(path.read_text(), run_values(run_dir)))
272
+ if path.is_file() else None) or {}
273
+ problems = [] if spec else ["spec: no experiment/spec.yaml"]
274
  agents = spec.get("agents") or {}
275
+ count = agents.get("count") if type(agents.get("count")) is int else None
276
+ if spec and count is None:
277
+ problems.append(f"spec: agents.count is {agents.get('count')!r}, not a number")
278
+ if spec.get("naming") == "consecutive-id" and count is not None:
279
+ team = [f"agent-{k:03d}" for k in range(1, count + 1)]
280
  else:
281
  team = list(trials)
282
+ if count is not None and len(team) < count:
283
+ problems.append(f"agents: {len(team)} of the {count} planned have Trials")
284
+ if outside := sorted(set(trials) - set(team)):
285
+ problems.append(f"agents: Trials of agents the spec didn't plan: {', '.join(outside)}")
286
  times = [(epoch(r["started_at"]), epoch(r["finished_at"]))
287
  for ts in trials.values() for r in results(ts)
288
  if r.get("started_at") and r.get("finished_at")]
289
  start, end = (min(t[0] for t in times), max(t[1] for t in times)) if times else (0, 0)
290
+ ran = sorted({r["task_name"].split("/")[-1] for ts in trials.values() for r in results(ts)
291
+ if r.get("task_name")})
292
+ task = spec.get("task") or {"selector": ran[0] if len(ran) == 1 else None}
293
+ selector = task.get("selector") or ""
294
+ if odd := [name for name in ran if not fnmatch.fnmatchcase(name, selector)]:
295
+ problems.append(f"task: the spec selects {selector!r}, the Trials ran {', '.join(odd)}")
296
  swarm = next((t.name.removesuffix(f"-{a}-t{t.name.rsplit('-t', 1)[1]}")
297
  for a, ts in trials.items() for t in ts), spec.get("name"))
298
  return {"swarm": swarm, "task": task, "team": team, "start": start, "end": end,
299
  "stop_reason": None, "duration_s": round(end - start, 1) if times else None,
300
  "cost_usd": None, "tokens": {a: trial_tokens(trials.get(a, [])) for a in team},
301
+ "turns": dict.fromkeys(team), "problems": problems}
302
 
303
 
304
  def row(run_dir: Path) -> dict:
 
309
  messages, channels, exported = board(run_dir, info["start"], info["end"])
310
  posts = Counter(sender(m) for m in messages)
311
  graph = edges(messages, channels, team)
312
+ per_agent, missing = {}, list(info.get("problems", []))
313
  for name in team:
314
  value = reward(trials.get(name, []))
315
  if value is None:
generate.py CHANGED
@@ -111,7 +111,7 @@ Once you reach the exit, post that you have, then stop.
111
  """
112
 
113
 
114
- def task_toml(t: int, budget: int) -> str:
115
  return f"""schema_version = "1.4"
116
 
117
  # The maze service's own record of the walk, exported by its collect hook below once the agent
@@ -132,7 +132,7 @@ keywords = ["multi-agent", "message-board", "s3", "maze", "exploration"]
132
 
133
  [metadata]
134
  tree = {t}
135
- seed = {SEED}
136
  branching = {BRANCHING}
137
  corridor = {CORRIDOR}
138
  depth = {DEPTH}
@@ -233,7 +233,7 @@ def generate(root: Path = HERE, seed: int = SEED, budget: int = BUDGET) -> None:
233
  tree_json = json.dumps(layout, indent=1).encode() + b"\n"
234
  own_maze = maze | {"tree.json": tree_json}
235
  write(task / "instruction.md", instruction(budget))
236
- write(task / "task.toml", task_toml(t, budget))
237
  write(task / "environment" / "docker-compose.yaml",
238
  compose(task_name(t), digest(agent), digest(own_maze)))
239
  for name, data in agent.items():
 
111
  """
112
 
113
 
114
+ def task_toml(t: int, budget: int, seed: int) -> str:
115
  return f"""schema_version = "1.4"
116
 
117
  # The maze service's own record of the walk, exported by its collect hook below once the agent
 
132
 
133
  [metadata]
134
  tree = {t}
135
+ seed = {seed}
136
  branching = {BRANCHING}
137
  corridor = {CORRIDOR}
138
  depth = {DEPTH}
 
233
  tree_json = json.dumps(layout, indent=1).encode() + b"\n"
234
  own_maze = maze | {"tree.json": tree_json}
235
  write(task / "instruction.md", instruction(budget))
236
+ write(task / "task.toml", task_toml(t, budget, seed))
237
  write(task / "environment" / "docker-compose.yaml",
238
  compose(task_name(t), digest(agent), digest(own_maze)))
239
  for name, data in agent.items():