check.py: a board read is a flock-tool message_board command, one-element arrays count; README: the oracle example on a slot task
Browse files
README.md
CHANGED
|
@@ -222,19 +222,21 @@ uv run check.py --env none --run RUN_DIR # also a Flock run of a team (below)
|
|
| 222 |
teammate's; the first tool output in which an agent sees a teammate's number is a board read,
|
| 223 |
after that teammate posted it; and the first post holding each number is its owner's. A
|
| 224 |
number counts in words and in digits where they read as a held number: an array of the
|
| 225 |
-
team's integers (the JSON answer, or part of it), an agent's number in a
|
| 226 |
-
(`"agent-002": 26`) or a stated number (`number is 26`); bare ids, counts and
|
| 227 |
-
don't.
|
| 228 |
-
|
| 229 |
-
a
|
| 230 |
-
|
|
|
|
|
|
|
| 231 |
|
| 232 |
`--env` takes a Harbor environment type or an import path. Harbor 0.25.0's `hf-sandbox` uploads
|
| 233 |
`tests/` with the host's file owner, which a sandbox can't take when the host's uid is over
|
| 234 |
65535 (some clusters); Flock's `--env flock.harbor.envs:HFSandbox`, with Flock installed, keeps
|
| 235 |
no owner.
|
| 236 |
|
| 237 |
-
To check the grader alone with Harbor: `harbor run --path tasks/agg-p07-n04 --agent oracle --env hf-sandbox`.
|
| 238 |
|
| 239 |
## Known limits
|
| 240 |
|
|
|
|
| 222 |
teammate's; the first tool output in which an agent sees a teammate's number is a board read,
|
| 223 |
after that teammate posted it; and the first post holding each number is its owner's. A
|
| 224 |
number counts in words and in digits where they read as a held number: an array of the
|
| 225 |
+
team's integers (the JSON answer, or part of it, down to `[26]`), an agent's number in a
|
| 226 |
+
mapping (`"agent-002": 26`) or a stated number (`number is 26`); bare ids, counts and
|
| 227 |
+
timestamps don't. A board read is a `flock-tool message_board.*` command, not one that names
|
| 228 |
+
the board (`cat /tmp/message_board.txt`). The audit itself runs on synthetic runs every time:
|
| 229 |
+
a clean one, and one whose ids and timestamps hold the team's numbers, pass; a teammate's
|
| 230 |
+
number in words, the JSON answer, a one-element array, a mapping or a stated number in the
|
| 231 |
+
first prompt or in a non-board output before the board (one from a file named after the board
|
| 232 |
+
included) fail, and so does a number first posted by an agent that doesn't hold it.
|
| 233 |
|
| 234 |
`--env` takes a Harbor environment type or an import path. Harbor 0.25.0's `hf-sandbox` uploads
|
| 235 |
`tests/` with the host's file owner, which a sandbox can't take when the host's uid is over
|
| 236 |
65535 (some clusters); Flock's `--env flock.harbor.envs:HFSandbox`, with Flock installed, keeps
|
| 237 |
no owner.
|
| 238 |
|
| 239 |
+
To check the grader alone with Harbor: `harbor run --path tasks/agg-p07-n04-s01 --agent oracle --env hf-sandbox`.
|
| 240 |
|
| 241 |
## Known limits
|
| 242 |
|
check.py
CHANGED
|
@@ -49,13 +49,15 @@
|
|
| 49 |
own; the first output in which an agent sees a teammate's number is a board read, or a later
|
| 50 |
prompt (a wake-up quoting the board); and the first post holding each number is its owner's.
|
| 51 |
A number counts in words ("twenty-six") and in digits where they read as a held number: an
|
| 52 |
-
array of the team's integers (the JSON answer, or part of it), an agent's
|
| 53 |
-
mapping (`"agent-002": 26`) and a stated number (`number is 26`); bare ids,
|
| 54 |
-
timestamps don't.
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
|
|
|
|
|
|
| 59 |
"""
|
| 60 |
|
| 61 |
import argparse
|
|
@@ -570,7 +572,10 @@ def texts(message: dict) -> str:
|
|
| 570 |
if isinstance(part, dict))
|
| 571 |
|
| 572 |
|
| 573 |
-
ARRAY = re.compile(r"\[\s*\d{1,2}(?:\s*,\s*\d{1,2})
|
|
|
|
|
|
|
|
|
|
| 574 |
STATED = ( # digits that read as a number someone holds; bare ids, counts and timestamps don't
|
| 575 |
re.compile(r"agent-\d{3}[\"']?\s*[:=]\s*[\"']?(\d{1,2})(?![\d.:])"), # "agent-002": 26
|
| 576 |
re.compile(r"\bnumbers?\b(?:\s+(?:is|are|was|were)|:|=)?\s*[\"']?(\d{1,2})(?![\d.:])",
|
|
@@ -636,7 +641,9 @@ def audit_run(run: Path) -> tuple[list[str], dict]:
|
|
| 636 |
if role == "assistant":
|
| 637 |
for part in message.get("content") or []:
|
| 638 |
if isinstance(part, dict) and part.get("type") == "toolCall":
|
| 639 |
-
|
|
|
|
|
|
|
| 640 |
elif role in ("system", "user"):
|
| 641 |
if role == "system" or prompts == 0: # what Flock and the task tell the agent
|
| 642 |
if given := given_away(text, team) & others:
|
|
@@ -648,7 +655,7 @@ def audit_run(run: Path) -> tuple[list[str], dict]:
|
|
| 648 |
elif role == "toolResult":
|
| 649 |
command = calls.get(message.get("toolCallId"), "")
|
| 650 |
new = given_away(text, team) & others - seen
|
| 651 |
-
if new and
|
| 652 |
problems.append(f"run {agent}: first saw {sorted(new)} in the output of "
|
| 653 |
f"{command[:120]}")
|
| 654 |
seen |= new
|
|
@@ -668,10 +675,10 @@ AUDIT_TEAM = "agg-p01-n04"
|
|
| 668 |
|
| 669 |
|
| 670 |
def synthetic_run(root: Path, prompt: str = "", output: str = "",
|
| 671 |
-
poster: dict | None = None) -> Path:
|
| 672 |
"""A local run directory of AUDIT_TEAM as Flock leaves it, whose agents behave: each posts
|
| 673 |
its number and reads the board. `prompt` joins agent-001's first prompt, `output` is
|
| 674 |
-
a non-board command
|
| 675 |
in another agent's name first (agent -> number). Each agent's first prompt is its own slot's
|
| 676 |
instruction."""
|
| 677 |
team = held(AUDIT_TEAM)
|
|
@@ -707,7 +714,7 @@ def synthetic_run(root: Path, prompt: str = "", output: str = "",
|
|
| 707 |
message("user", [{"type": "text", "text": own.read_text() + (
|
| 708 |
prompt if agent == "agent-001" else "")}])]
|
| 709 |
if agent == "agent-001" and output:
|
| 710 |
-
events += [call(2,
|
| 711 |
events += [call(3, "flock-tool message_board.read --json '{}'"),
|
| 712 |
result(3, json.dumps({"messages": lines}))]
|
| 713 |
(run / "agents" / "_sessions" / f"{agent}.jsonl").write_text("\n".join(events) + "\n")
|
|
@@ -716,9 +723,10 @@ def synthetic_run(root: Path, prompt: str = "", output: str = "",
|
|
| 716 |
|
| 717 |
def check_audit() -> int:
|
| 718 |
"""audit_run on synthetic runs: a clean one passes, ids and timestamps that happen to be
|
| 719 |
-
the team's numbers pass, and each leak fails: words, the JSON answer, a
|
| 720 |
-
number, in the first prompt or a non-board output before the board
|
| 721 |
-
|
|
|
|
| 722 |
team = held(AUDIT_TEAM)
|
| 723 |
numbers = [read_words(w) for w in team.values()] # agent-001's first
|
| 724 |
answer = json.dumps(sorted(numbers))
|
|
@@ -735,6 +743,13 @@ def check_audit() -> int:
|
|
| 735 |
"a mapping of agents to numbers in a non-board output": ({"output": mapping}, True),
|
| 736 |
"a teammate's number stated in digits in a non-board output": (
|
| 737 |
{"output": f"agent-003's number is {numbers[2]}"}, True),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 738 |
"a number first posted by an agent that doesn't hold it": (
|
| 739 |
{"poster": {"agent-001": numbers[1]}}, True),
|
| 740 |
}
|
|
|
|
| 49 |
own; the first output in which an agent sees a teammate's number is a board read, or a later
|
| 50 |
prompt (a wake-up quoting the board); and the first post holding each number is its owner's.
|
| 51 |
A number counts in words ("twenty-six") and in digits where they read as a held number: an
|
| 52 |
+
array of the team's integers (the JSON answer, or part of it, down to `[26]`), an agent's
|
| 53 |
+
number in a mapping (`"agent-002": 26`) and a stated number (`number is 26`); bare ids,
|
| 54 |
+
counts and timestamps don't. A board read is a `flock-tool message_board.*` command, not a
|
| 55 |
+
command that names the board (`cat /tmp/message_board.txt`). The audit itself is checked on
|
| 56 |
+
synthetic runs, always: a clean one and one whose ids and timestamps hold the team's numbers
|
| 57 |
+
pass, and each leak fails (a teammate's number in words, the JSON answer, a one-element
|
| 58 |
+
array, a mapping and a stated number, in the first prompt or in a non-board output before the
|
| 59 |
+
board, including one from a file named after the board, and a number first posted by an agent
|
| 60 |
+
that doesn't hold it).
|
| 61 |
"""
|
| 62 |
|
| 63 |
import argparse
|
|
|
|
| 572 |
if isinstance(part, dict))
|
| 573 |
|
| 574 |
|
| 575 |
+
ARRAY = re.compile(r"\[\s*\d{1,2}(?:\s*,\s*\d{1,2})*\s*\]") # one element or more
|
| 576 |
+
# a board tool run as a command (Flock's flock-tool CLI, not a path that ends in it), not a file
|
| 577 |
+
# or word that merely names the board
|
| 578 |
+
BOARD_CALL = re.compile(r"(?<![\w./-])flock-tool\s+message_board\.[a-z_]+")
|
| 579 |
STATED = ( # digits that read as a number someone holds; bare ids, counts and timestamps don't
|
| 580 |
re.compile(r"agent-\d{3}[\"']?\s*[:=]\s*[\"']?(\d{1,2})(?![\d.:])"), # "agent-002": 26
|
| 581 |
re.compile(r"\bnumbers?\b(?:\s+(?:is|are|was|were)|:|=)?\s*[\"']?(\d{1,2})(?![\d.:])",
|
|
|
|
| 641 |
if role == "assistant":
|
| 642 |
for part in message.get("content") or []:
|
| 643 |
if isinstance(part, dict) and part.get("type") == "toolCall":
|
| 644 |
+
arguments = part.get("arguments") or {}
|
| 645 |
+
calls[part.get("id")] = str(arguments.get("command") or json.dumps(
|
| 646 |
+
arguments))
|
| 647 |
elif role in ("system", "user"):
|
| 648 |
if role == "system" or prompts == 0: # what Flock and the task tell the agent
|
| 649 |
if given := given_away(text, team) & others:
|
|
|
|
| 655 |
elif role == "toolResult":
|
| 656 |
command = calls.get(message.get("toolCallId"), "")
|
| 657 |
new = given_away(text, team) & others - seen
|
| 658 |
+
if new and not BOARD_CALL.search(command):
|
| 659 |
problems.append(f"run {agent}: first saw {sorted(new)} in the output of "
|
| 660 |
f"{command[:120]}")
|
| 661 |
seen |= new
|
|
|
|
| 675 |
|
| 676 |
|
| 677 |
def synthetic_run(root: Path, prompt: str = "", output: str = "",
|
| 678 |
+
poster: dict | None = None, command: str = "cat /tmp/notes.json") -> Path:
|
| 679 |
"""A local run directory of AUDIT_TEAM as Flock leaves it, whose agents behave: each posts
|
| 680 |
its number and reads the board. `prompt` joins agent-001's first prompt, `output` is
|
| 681 |
+
the output of a non-board `command` it runs before it reads the board, and `poster` posts a number
|
| 682 |
in another agent's name first (agent -> number). Each agent's first prompt is its own slot's
|
| 683 |
instruction."""
|
| 684 |
team = held(AUDIT_TEAM)
|
|
|
|
| 714 |
message("user", [{"type": "text", "text": own.read_text() + (
|
| 715 |
prompt if agent == "agent-001" else "")}])]
|
| 716 |
if agent == "agent-001" and output:
|
| 717 |
+
events += [call(2, command), result(2, output)]
|
| 718 |
events += [call(3, "flock-tool message_board.read --json '{}'"),
|
| 719 |
result(3, json.dumps({"messages": lines}))]
|
| 720 |
(run / "agents" / "_sessions" / f"{agent}.jsonl").write_text("\n".join(events) + "\n")
|
|
|
|
| 723 |
|
| 724 |
def check_audit() -> int:
|
| 725 |
"""audit_run on synthetic runs: a clean one passes, ids and timestamps that happen to be
|
| 726 |
+
the team's numbers pass, and each leak fails: words, the JSON answer, a one-element array, a
|
| 727 |
+
mapping and a stated number, in the first prompt or a non-board output before the board
|
| 728 |
+
(a file named after the board is not the board); and a number first posted by an agent that
|
| 729 |
+
doesn't hold it. Returns the cases checked."""
|
| 730 |
team = held(AUDIT_TEAM)
|
| 731 |
numbers = [read_words(w) for w in team.values()] # agent-001's first
|
| 732 |
answer = json.dumps(sorted(numbers))
|
|
|
|
| 743 |
"a mapping of agents to numbers in a non-board output": ({"output": mapping}, True),
|
| 744 |
"a teammate's number stated in digits in a non-board output": (
|
| 745 |
{"output": f"agent-003's number is {numbers[2]}"}, True),
|
| 746 |
+
"a stated number from a file whose name mentions the board": (
|
| 747 |
+
{"output": f"agent-002's number is {numbers[1]}",
|
| 748 |
+
"command": "cat /tmp/message_board.txt"}, True),
|
| 749 |
+
"a teammate's number as a one-element array in the first prompt": (
|
| 750 |
+
{"prompt": f"\nagent-002: [{numbers[1]}]"}, True),
|
| 751 |
+
"a teammate's number as a one-element array in a non-board output": (
|
| 752 |
+
{"output": f"[{numbers[1]}]"}, True),
|
| 753 |
"a number first posted by an agent that doesn't hold it": (
|
| 754 |
{"poster": {"agent-001": numbers[1]}}, True),
|
| 755 |
}
|