One task per slot (agg-pPP-nNN-sKK) whose instruction states its number; no resources/ (Flock's selector gives each agent its own task) (part 10)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- tasks/agg-p22-n16-s11/tests/test.sh +89 -0
- tasks/agg-p22-n16-s12/instruction.md +21 -0
- tasks/agg-p22-n16-s12/solution/solve.sh +5 -0
- tasks/agg-p22-n16-s12/task.toml +27 -0
- tasks/agg-p22-n16-s12/tests/expected.json +1 -0
- tasks/agg-p22-n16-s12/tests/test.sh +89 -0
- tasks/agg-p22-n16-s13/instruction.md +21 -0
- tasks/agg-p22-n16-s13/solution/solve.sh +5 -0
- tasks/agg-p22-n16-s13/task.toml +27 -0
- tasks/agg-p22-n16-s13/tests/expected.json +1 -0
- tasks/agg-p22-n16-s13/tests/test.sh +89 -0
- tasks/agg-p22-n16-s14/instruction.md +21 -0
- tasks/agg-p22-n16-s14/solution/solve.sh +5 -0
- tasks/agg-p22-n16-s14/task.toml +27 -0
- tasks/agg-p22-n16-s14/tests/expected.json +1 -0
- tasks/agg-p22-n16-s14/tests/test.sh +89 -0
- tasks/agg-p22-n16-s15/instruction.md +21 -0
- tasks/agg-p22-n16-s15/solution/solve.sh +5 -0
- tasks/agg-p22-n16-s15/task.toml +27 -0
- tasks/agg-p22-n16-s15/tests/expected.json +1 -0
- tasks/agg-p22-n16-s15/tests/test.sh +89 -0
- tasks/agg-p22-n16-s16/instruction.md +21 -0
- tasks/agg-p22-n16-s16/solution/solve.sh +5 -0
- tasks/agg-p22-n16-s16/task.toml +27 -0
- tasks/agg-p22-n16-s16/tests/expected.json +1 -0
- tasks/agg-p22-n16-s16/tests/test.sh +89 -0
- tasks/agg-p23-n01-s01/instruction.md +9 -0
- tasks/agg-p23-n01-s01/solution/solve.sh +5 -0
- tasks/agg-p23-n01-s01/task.toml +27 -0
- tasks/agg-p23-n01-s01/tests/expected.json +1 -0
- tasks/agg-p23-n01-s01/tests/test.sh +89 -0
- tasks/agg-p23-n02-s01/instruction.md +21 -0
- tasks/agg-p23-n02-s01/solution/solve.sh +5 -0
- tasks/agg-p23-n02-s01/task.toml +27 -0
- tasks/agg-p23-n02-s01/tests/expected.json +1 -0
- tasks/agg-p23-n02-s01/tests/test.sh +89 -0
- tasks/agg-p23-n02-s02/instruction.md +21 -0
- tasks/agg-p23-n02-s02/solution/solve.sh +5 -0
- tasks/agg-p23-n02-s02/task.toml +27 -0
- tasks/agg-p23-n02-s02/tests/expected.json +1 -0
- tasks/agg-p23-n02-s02/tests/test.sh +89 -0
- tasks/agg-p23-n04-s01/instruction.md +21 -0
- tasks/agg-p23-n04-s01/solution/solve.sh +5 -0
- tasks/agg-p23-n04-s01/task.toml +27 -0
- tasks/agg-p23-n04-s01/tests/expected.json +1 -0
- tasks/agg-p23-n04-s01/tests/test.sh +89 -0
- tasks/agg-p23-n04-s02/instruction.md +21 -0
- tasks/agg-p23-n04-s02/solution/solve.sh +5 -0
- tasks/agg-p23-n04-s02/task.toml +27 -0
- tasks/agg-p23-n04-s02/tests/expected.json +1 -0
tasks/agg-p22-n16-s11/tests/test.sh
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in
|
| 3 |
+
# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or
|
| 4 |
+
# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or
|
| 5 |
+
# booleans, a missing, extra or dropped duplicate number, and a wrong order.
|
| 6 |
+
# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to
|
| 7 |
+
# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app),
|
| 8 |
+
# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here
|
| 9 |
+
# follows a link the agent may have left, and 0 is written before anything is checked, so a crash
|
| 10 |
+
# of the check also scores 0. A copy of the answer stays with the trial's results.
|
| 11 |
+
# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the
|
| 12 |
+
# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what
|
| 13 |
+
# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or
|
| 14 |
+
# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths
|
| 15 |
+
# (no links in them), to test the grader locally.
|
| 16 |
+
case $0 in */*) here=${0%/*} ;; *) here=. ;; esac
|
| 17 |
+
export ANSWER=${ANSWER:-/app/answer.json}
|
| 18 |
+
export EXPECTED=${EXPECTED:-$here/expected.json}
|
| 19 |
+
export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier}
|
| 20 |
+
[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt"
|
| 21 |
+
python3 -I -S - <<'PY' || true
|
| 22 |
+
import json
|
| 23 |
+
import os
|
| 24 |
+
import stat
|
| 25 |
+
|
| 26 |
+
LIMIT = 1 << 20 # bytes
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def read_own(path):
|
| 30 |
+
# The bytes of the regular file at exactly `path`: every folder on the way is opened
|
| 31 |
+
# without following a link, and so is the file (a FIFO cannot block it); one link only.
|
| 32 |
+
parts = os.path.abspath(path).split("/")[1:]
|
| 33 |
+
folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY)
|
| 34 |
+
try:
|
| 35 |
+
for part in parts[:-1]:
|
| 36 |
+
inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder)
|
| 37 |
+
os.close(folder)
|
| 38 |
+
folder = inner
|
| 39 |
+
fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder)
|
| 40 |
+
finally:
|
| 41 |
+
os.close(folder)
|
| 42 |
+
with os.fdopen(fd, "rb") as stream:
|
| 43 |
+
info = os.fstat(stream.fileno())
|
| 44 |
+
if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1:
|
| 45 |
+
raise ValueError("not a regular file of its own")
|
| 46 |
+
data = stream.read(LIMIT + 1)
|
| 47 |
+
if len(data) > LIMIT:
|
| 48 |
+
raise ValueError("too large")
|
| 49 |
+
return data
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
def write_new(path, text):
|
| 53 |
+
fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644)
|
| 54 |
+
with os.fdopen(fd, "w") as stream:
|
| 55 |
+
stream.write(text)
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
def reject_constant(name):
|
| 59 |
+
raise ValueError(f"{name} is not JSON")
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
def parse(data):
|
| 63 |
+
return json.loads(data.decode("utf-8"), parse_constant=reject_constant)
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
verifier = os.environ["VERIFIER_DIR"]
|
| 67 |
+
os.makedirs(verifier, exist_ok=True)
|
| 68 |
+
for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link
|
| 69 |
+
try:
|
| 70 |
+
os.unlink(os.path.join(verifier, name))
|
| 71 |
+
except FileNotFoundError:
|
| 72 |
+
pass
|
| 73 |
+
write_new(os.path.join(verifier, "reward.txt"), "0")
|
| 74 |
+
valid = False
|
| 75 |
+
try:
|
| 76 |
+
data = read_own(os.environ["ANSWER"])
|
| 77 |
+
write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace"))
|
| 78 |
+
answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"]))
|
| 79 |
+
valid = (
|
| 80 |
+
isinstance(answer, list)
|
| 81 |
+
and all(type(x) is int for x in answer) # not bool, float or str
|
| 82 |
+
and answer == expected
|
| 83 |
+
)
|
| 84 |
+
except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError
|
| 85 |
+
valid = False
|
| 86 |
+
if valid:
|
| 87 |
+
write_new(os.path.join(verifier, "reward.txt"), "1")
|
| 88 |
+
print("reward:", 1 if valid else 0)
|
| 89 |
+
PY
|
tasks/agg-p22-n16-s12/instruction.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Sort the team's private numbers
|
| 2 |
+
|
| 3 |
+
You are on a team of 16 agents solving a private-information number sorting task. Each agent
|
| 4 |
+
holds one private integer from 1 to 99, written in English words. You know only your own
|
| 5 |
+
number, and the others don't know it unless you tell them.
|
| 6 |
+
|
| 7 |
+
Your private number is eight.
|
| 8 |
+
|
| 9 |
+
The team must find all 16 numbers and list their numeric values in ascending order. Keep equal
|
| 10 |
+
numbers from different agents as separate entries: each agent's number appears once in the list,
|
| 11 |
+
even when another agent holds the same value.
|
| 12 |
+
|
| 13 |
+
1. Share your number with the team on the message board.
|
| 14 |
+
2. Read the board for the other participants' numbers. Note which participant each number came
|
| 15 |
+
from, so that a number posted more than once is counted once.
|
| 16 |
+
3. Once you have one number from every participant, yourself included, write `/app/answer.json`
|
| 17 |
+
(create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order.
|
| 18 |
+
Then stop.
|
| 19 |
+
|
| 20 |
+
Any agent may write the full answer, and the team succeeds if at least one agent's answer is
|
| 21 |
+
correct. Your instructions name the other participants and explain the board's tools.
|
tasks/agg-p22-n16-s12/solution/solve.sh
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Oracle: the team's answer from its own copy (not tests/), to validate the grader.
|
| 3 |
+
answer=${ANSWER:-/app/answer.json}
|
| 4 |
+
mkdir -p "$(dirname "$answer")"
|
| 5 |
+
echo '[4, 5, 8, 10, 15, 22, 23, 27, 31, 41, 71, 74, 76, 77, 88, 89]' > "$answer"
|
tasks/agg-p22-n16-s12/task.toml
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
schema_version = "1.4"
|
| 2 |
+
|
| 3 |
+
[task]
|
| 4 |
+
name = "HuggingFaceSwarms/agg-p22-n16-s12"
|
| 5 |
+
version = "0.1.0"
|
| 6 |
+
description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order."
|
| 7 |
+
keywords = ["multi-agent", "message-board", "s3", "aggregation"]
|
| 8 |
+
|
| 9 |
+
[metadata]
|
| 10 |
+
problem = 22
|
| 11 |
+
agents = 16
|
| 12 |
+
slot = 12
|
| 13 |
+
seed = 115
|
| 14 |
+
|
| 15 |
+
[agent]
|
| 16 |
+
timeout_sec = 1800
|
| 17 |
+
|
| 18 |
+
[environment]
|
| 19 |
+
# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it
|
| 20 |
+
# too. Nothing task-specific is in the container: the slot's number is only in its instruction,
|
| 21 |
+
# and tests/ arrive only when the agent is done.
|
| 22 |
+
docker_image = "python:3.12-slim"
|
| 23 |
+
cpus = 1
|
| 24 |
+
memory_mb = 1024
|
| 25 |
+
|
| 26 |
+
[verifier]
|
| 27 |
+
timeout_sec = 60
|
tasks/agg-p22-n16-s12/tests/expected.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
[4, 5, 8, 10, 15, 22, 23, 27, 31, 41, 71, 74, 76, 77, 88, 89]
|
tasks/agg-p22-n16-s12/tests/test.sh
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in
|
| 3 |
+
# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or
|
| 4 |
+
# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or
|
| 5 |
+
# booleans, a missing, extra or dropped duplicate number, and a wrong order.
|
| 6 |
+
# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to
|
| 7 |
+
# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app),
|
| 8 |
+
# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here
|
| 9 |
+
# follows a link the agent may have left, and 0 is written before anything is checked, so a crash
|
| 10 |
+
# of the check also scores 0. A copy of the answer stays with the trial's results.
|
| 11 |
+
# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the
|
| 12 |
+
# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what
|
| 13 |
+
# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or
|
| 14 |
+
# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths
|
| 15 |
+
# (no links in them), to test the grader locally.
|
| 16 |
+
case $0 in */*) here=${0%/*} ;; *) here=. ;; esac
|
| 17 |
+
export ANSWER=${ANSWER:-/app/answer.json}
|
| 18 |
+
export EXPECTED=${EXPECTED:-$here/expected.json}
|
| 19 |
+
export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier}
|
| 20 |
+
[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt"
|
| 21 |
+
python3 -I -S - <<'PY' || true
|
| 22 |
+
import json
|
| 23 |
+
import os
|
| 24 |
+
import stat
|
| 25 |
+
|
| 26 |
+
LIMIT = 1 << 20 # bytes
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def read_own(path):
|
| 30 |
+
# The bytes of the regular file at exactly `path`: every folder on the way is opened
|
| 31 |
+
# without following a link, and so is the file (a FIFO cannot block it); one link only.
|
| 32 |
+
parts = os.path.abspath(path).split("/")[1:]
|
| 33 |
+
folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY)
|
| 34 |
+
try:
|
| 35 |
+
for part in parts[:-1]:
|
| 36 |
+
inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder)
|
| 37 |
+
os.close(folder)
|
| 38 |
+
folder = inner
|
| 39 |
+
fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder)
|
| 40 |
+
finally:
|
| 41 |
+
os.close(folder)
|
| 42 |
+
with os.fdopen(fd, "rb") as stream:
|
| 43 |
+
info = os.fstat(stream.fileno())
|
| 44 |
+
if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1:
|
| 45 |
+
raise ValueError("not a regular file of its own")
|
| 46 |
+
data = stream.read(LIMIT + 1)
|
| 47 |
+
if len(data) > LIMIT:
|
| 48 |
+
raise ValueError("too large")
|
| 49 |
+
return data
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
def write_new(path, text):
|
| 53 |
+
fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644)
|
| 54 |
+
with os.fdopen(fd, "w") as stream:
|
| 55 |
+
stream.write(text)
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
def reject_constant(name):
|
| 59 |
+
raise ValueError(f"{name} is not JSON")
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
def parse(data):
|
| 63 |
+
return json.loads(data.decode("utf-8"), parse_constant=reject_constant)
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
verifier = os.environ["VERIFIER_DIR"]
|
| 67 |
+
os.makedirs(verifier, exist_ok=True)
|
| 68 |
+
for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link
|
| 69 |
+
try:
|
| 70 |
+
os.unlink(os.path.join(verifier, name))
|
| 71 |
+
except FileNotFoundError:
|
| 72 |
+
pass
|
| 73 |
+
write_new(os.path.join(verifier, "reward.txt"), "0")
|
| 74 |
+
valid = False
|
| 75 |
+
try:
|
| 76 |
+
data = read_own(os.environ["ANSWER"])
|
| 77 |
+
write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace"))
|
| 78 |
+
answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"]))
|
| 79 |
+
valid = (
|
| 80 |
+
isinstance(answer, list)
|
| 81 |
+
and all(type(x) is int for x in answer) # not bool, float or str
|
| 82 |
+
and answer == expected
|
| 83 |
+
)
|
| 84 |
+
except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError
|
| 85 |
+
valid = False
|
| 86 |
+
if valid:
|
| 87 |
+
write_new(os.path.join(verifier, "reward.txt"), "1")
|
| 88 |
+
print("reward:", 1 if valid else 0)
|
| 89 |
+
PY
|
tasks/agg-p22-n16-s13/instruction.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Sort the team's private numbers
|
| 2 |
+
|
| 3 |
+
You are on a team of 16 agents solving a private-information number sorting task. Each agent
|
| 4 |
+
holds one private integer from 1 to 99, written in English words. You know only your own
|
| 5 |
+
number, and the others don't know it unless you tell them.
|
| 6 |
+
|
| 7 |
+
Your private number is twenty-two.
|
| 8 |
+
|
| 9 |
+
The team must find all 16 numbers and list their numeric values in ascending order. Keep equal
|
| 10 |
+
numbers from different agents as separate entries: each agent's number appears once in the list,
|
| 11 |
+
even when another agent holds the same value.
|
| 12 |
+
|
| 13 |
+
1. Share your number with the team on the message board.
|
| 14 |
+
2. Read the board for the other participants' numbers. Note which participant each number came
|
| 15 |
+
from, so that a number posted more than once is counted once.
|
| 16 |
+
3. Once you have one number from every participant, yourself included, write `/app/answer.json`
|
| 17 |
+
(create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order.
|
| 18 |
+
Then stop.
|
| 19 |
+
|
| 20 |
+
Any agent may write the full answer, and the team succeeds if at least one agent's answer is
|
| 21 |
+
correct. Your instructions name the other participants and explain the board's tools.
|
tasks/agg-p22-n16-s13/solution/solve.sh
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Oracle: the team's answer from its own copy (not tests/), to validate the grader.
|
| 3 |
+
answer=${ANSWER:-/app/answer.json}
|
| 4 |
+
mkdir -p "$(dirname "$answer")"
|
| 5 |
+
echo '[4, 5, 8, 10, 15, 22, 23, 27, 31, 41, 71, 74, 76, 77, 88, 89]' > "$answer"
|
tasks/agg-p22-n16-s13/task.toml
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
schema_version = "1.4"
|
| 2 |
+
|
| 3 |
+
[task]
|
| 4 |
+
name = "HuggingFaceSwarms/agg-p22-n16-s13"
|
| 5 |
+
version = "0.1.0"
|
| 6 |
+
description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order."
|
| 7 |
+
keywords = ["multi-agent", "message-board", "s3", "aggregation"]
|
| 8 |
+
|
| 9 |
+
[metadata]
|
| 10 |
+
problem = 22
|
| 11 |
+
agents = 16
|
| 12 |
+
slot = 13
|
| 13 |
+
seed = 115
|
| 14 |
+
|
| 15 |
+
[agent]
|
| 16 |
+
timeout_sec = 1800
|
| 17 |
+
|
| 18 |
+
[environment]
|
| 19 |
+
# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it
|
| 20 |
+
# too. Nothing task-specific is in the container: the slot's number is only in its instruction,
|
| 21 |
+
# and tests/ arrive only when the agent is done.
|
| 22 |
+
docker_image = "python:3.12-slim"
|
| 23 |
+
cpus = 1
|
| 24 |
+
memory_mb = 1024
|
| 25 |
+
|
| 26 |
+
[verifier]
|
| 27 |
+
timeout_sec = 60
|
tasks/agg-p22-n16-s13/tests/expected.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
[4, 5, 8, 10, 15, 22, 23, 27, 31, 41, 71, 74, 76, 77, 88, 89]
|
tasks/agg-p22-n16-s13/tests/test.sh
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in
|
| 3 |
+
# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or
|
| 4 |
+
# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or
|
| 5 |
+
# booleans, a missing, extra or dropped duplicate number, and a wrong order.
|
| 6 |
+
# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to
|
| 7 |
+
# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app),
|
| 8 |
+
# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here
|
| 9 |
+
# follows a link the agent may have left, and 0 is written before anything is checked, so a crash
|
| 10 |
+
# of the check also scores 0. A copy of the answer stays with the trial's results.
|
| 11 |
+
# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the
|
| 12 |
+
# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what
|
| 13 |
+
# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or
|
| 14 |
+
# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths
|
| 15 |
+
# (no links in them), to test the grader locally.
|
| 16 |
+
case $0 in */*) here=${0%/*} ;; *) here=. ;; esac
|
| 17 |
+
export ANSWER=${ANSWER:-/app/answer.json}
|
| 18 |
+
export EXPECTED=${EXPECTED:-$here/expected.json}
|
| 19 |
+
export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier}
|
| 20 |
+
[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt"
|
| 21 |
+
python3 -I -S - <<'PY' || true
|
| 22 |
+
import json
|
| 23 |
+
import os
|
| 24 |
+
import stat
|
| 25 |
+
|
| 26 |
+
LIMIT = 1 << 20 # bytes
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def read_own(path):
|
| 30 |
+
# The bytes of the regular file at exactly `path`: every folder on the way is opened
|
| 31 |
+
# without following a link, and so is the file (a FIFO cannot block it); one link only.
|
| 32 |
+
parts = os.path.abspath(path).split("/")[1:]
|
| 33 |
+
folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY)
|
| 34 |
+
try:
|
| 35 |
+
for part in parts[:-1]:
|
| 36 |
+
inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder)
|
| 37 |
+
os.close(folder)
|
| 38 |
+
folder = inner
|
| 39 |
+
fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder)
|
| 40 |
+
finally:
|
| 41 |
+
os.close(folder)
|
| 42 |
+
with os.fdopen(fd, "rb") as stream:
|
| 43 |
+
info = os.fstat(stream.fileno())
|
| 44 |
+
if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1:
|
| 45 |
+
raise ValueError("not a regular file of its own")
|
| 46 |
+
data = stream.read(LIMIT + 1)
|
| 47 |
+
if len(data) > LIMIT:
|
| 48 |
+
raise ValueError("too large")
|
| 49 |
+
return data
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
def write_new(path, text):
|
| 53 |
+
fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644)
|
| 54 |
+
with os.fdopen(fd, "w") as stream:
|
| 55 |
+
stream.write(text)
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
def reject_constant(name):
|
| 59 |
+
raise ValueError(f"{name} is not JSON")
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
def parse(data):
|
| 63 |
+
return json.loads(data.decode("utf-8"), parse_constant=reject_constant)
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
verifier = os.environ["VERIFIER_DIR"]
|
| 67 |
+
os.makedirs(verifier, exist_ok=True)
|
| 68 |
+
for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link
|
| 69 |
+
try:
|
| 70 |
+
os.unlink(os.path.join(verifier, name))
|
| 71 |
+
except FileNotFoundError:
|
| 72 |
+
pass
|
| 73 |
+
write_new(os.path.join(verifier, "reward.txt"), "0")
|
| 74 |
+
valid = False
|
| 75 |
+
try:
|
| 76 |
+
data = read_own(os.environ["ANSWER"])
|
| 77 |
+
write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace"))
|
| 78 |
+
answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"]))
|
| 79 |
+
valid = (
|
| 80 |
+
isinstance(answer, list)
|
| 81 |
+
and all(type(x) is int for x in answer) # not bool, float or str
|
| 82 |
+
and answer == expected
|
| 83 |
+
)
|
| 84 |
+
except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError
|
| 85 |
+
valid = False
|
| 86 |
+
if valid:
|
| 87 |
+
write_new(os.path.join(verifier, "reward.txt"), "1")
|
| 88 |
+
print("reward:", 1 if valid else 0)
|
| 89 |
+
PY
|
tasks/agg-p22-n16-s14/instruction.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Sort the team's private numbers
|
| 2 |
+
|
| 3 |
+
You are on a team of 16 agents solving a private-information number sorting task. Each agent
|
| 4 |
+
holds one private integer from 1 to 99, written in English words. You know only your own
|
| 5 |
+
number, and the others don't know it unless you tell them.
|
| 6 |
+
|
| 7 |
+
Your private number is eighty-eight.
|
| 8 |
+
|
| 9 |
+
The team must find all 16 numbers and list their numeric values in ascending order. Keep equal
|
| 10 |
+
numbers from different agents as separate entries: each agent's number appears once in the list,
|
| 11 |
+
even when another agent holds the same value.
|
| 12 |
+
|
| 13 |
+
1. Share your number with the team on the message board.
|
| 14 |
+
2. Read the board for the other participants' numbers. Note which participant each number came
|
| 15 |
+
from, so that a number posted more than once is counted once.
|
| 16 |
+
3. Once you have one number from every participant, yourself included, write `/app/answer.json`
|
| 17 |
+
(create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order.
|
| 18 |
+
Then stop.
|
| 19 |
+
|
| 20 |
+
Any agent may write the full answer, and the team succeeds if at least one agent's answer is
|
| 21 |
+
correct. Your instructions name the other participants and explain the board's tools.
|
tasks/agg-p22-n16-s14/solution/solve.sh
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Oracle: the team's answer from its own copy (not tests/), to validate the grader.
|
| 3 |
+
answer=${ANSWER:-/app/answer.json}
|
| 4 |
+
mkdir -p "$(dirname "$answer")"
|
| 5 |
+
echo '[4, 5, 8, 10, 15, 22, 23, 27, 31, 41, 71, 74, 76, 77, 88, 89]' > "$answer"
|
tasks/agg-p22-n16-s14/task.toml
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
schema_version = "1.4"
|
| 2 |
+
|
| 3 |
+
[task]
|
| 4 |
+
name = "HuggingFaceSwarms/agg-p22-n16-s14"
|
| 5 |
+
version = "0.1.0"
|
| 6 |
+
description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order."
|
| 7 |
+
keywords = ["multi-agent", "message-board", "s3", "aggregation"]
|
| 8 |
+
|
| 9 |
+
[metadata]
|
| 10 |
+
problem = 22
|
| 11 |
+
agents = 16
|
| 12 |
+
slot = 14
|
| 13 |
+
seed = 115
|
| 14 |
+
|
| 15 |
+
[agent]
|
| 16 |
+
timeout_sec = 1800
|
| 17 |
+
|
| 18 |
+
[environment]
|
| 19 |
+
# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it
|
| 20 |
+
# too. Nothing task-specific is in the container: the slot's number is only in its instruction,
|
| 21 |
+
# and tests/ arrive only when the agent is done.
|
| 22 |
+
docker_image = "python:3.12-slim"
|
| 23 |
+
cpus = 1
|
| 24 |
+
memory_mb = 1024
|
| 25 |
+
|
| 26 |
+
[verifier]
|
| 27 |
+
timeout_sec = 60
|
tasks/agg-p22-n16-s14/tests/expected.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
[4, 5, 8, 10, 15, 22, 23, 27, 31, 41, 71, 74, 76, 77, 88, 89]
|
tasks/agg-p22-n16-s14/tests/test.sh
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in
|
| 3 |
+
# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or
|
| 4 |
+
# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or
|
| 5 |
+
# booleans, a missing, extra or dropped duplicate number, and a wrong order.
|
| 6 |
+
# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to
|
| 7 |
+
# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app),
|
| 8 |
+
# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here
|
| 9 |
+
# follows a link the agent may have left, and 0 is written before anything is checked, so a crash
|
| 10 |
+
# of the check also scores 0. A copy of the answer stays with the trial's results.
|
| 11 |
+
# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the
|
| 12 |
+
# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what
|
| 13 |
+
# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or
|
| 14 |
+
# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths
|
| 15 |
+
# (no links in them), to test the grader locally.
|
| 16 |
+
case $0 in */*) here=${0%/*} ;; *) here=. ;; esac
|
| 17 |
+
export ANSWER=${ANSWER:-/app/answer.json}
|
| 18 |
+
export EXPECTED=${EXPECTED:-$here/expected.json}
|
| 19 |
+
export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier}
|
| 20 |
+
[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt"
|
| 21 |
+
python3 -I -S - <<'PY' || true
|
| 22 |
+
import json
|
| 23 |
+
import os
|
| 24 |
+
import stat
|
| 25 |
+
|
| 26 |
+
LIMIT = 1 << 20 # bytes
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def read_own(path):
|
| 30 |
+
# The bytes of the regular file at exactly `path`: every folder on the way is opened
|
| 31 |
+
# without following a link, and so is the file (a FIFO cannot block it); one link only.
|
| 32 |
+
parts = os.path.abspath(path).split("/")[1:]
|
| 33 |
+
folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY)
|
| 34 |
+
try:
|
| 35 |
+
for part in parts[:-1]:
|
| 36 |
+
inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder)
|
| 37 |
+
os.close(folder)
|
| 38 |
+
folder = inner
|
| 39 |
+
fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder)
|
| 40 |
+
finally:
|
| 41 |
+
os.close(folder)
|
| 42 |
+
with os.fdopen(fd, "rb") as stream:
|
| 43 |
+
info = os.fstat(stream.fileno())
|
| 44 |
+
if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1:
|
| 45 |
+
raise ValueError("not a regular file of its own")
|
| 46 |
+
data = stream.read(LIMIT + 1)
|
| 47 |
+
if len(data) > LIMIT:
|
| 48 |
+
raise ValueError("too large")
|
| 49 |
+
return data
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
def write_new(path, text):
|
| 53 |
+
fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644)
|
| 54 |
+
with os.fdopen(fd, "w") as stream:
|
| 55 |
+
stream.write(text)
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
def reject_constant(name):
|
| 59 |
+
raise ValueError(f"{name} is not JSON")
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
def parse(data):
|
| 63 |
+
return json.loads(data.decode("utf-8"), parse_constant=reject_constant)
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
verifier = os.environ["VERIFIER_DIR"]
|
| 67 |
+
os.makedirs(verifier, exist_ok=True)
|
| 68 |
+
for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link
|
| 69 |
+
try:
|
| 70 |
+
os.unlink(os.path.join(verifier, name))
|
| 71 |
+
except FileNotFoundError:
|
| 72 |
+
pass
|
| 73 |
+
write_new(os.path.join(verifier, "reward.txt"), "0")
|
| 74 |
+
valid = False
|
| 75 |
+
try:
|
| 76 |
+
data = read_own(os.environ["ANSWER"])
|
| 77 |
+
write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace"))
|
| 78 |
+
answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"]))
|
| 79 |
+
valid = (
|
| 80 |
+
isinstance(answer, list)
|
| 81 |
+
and all(type(x) is int for x in answer) # not bool, float or str
|
| 82 |
+
and answer == expected
|
| 83 |
+
)
|
| 84 |
+
except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError
|
| 85 |
+
valid = False
|
| 86 |
+
if valid:
|
| 87 |
+
write_new(os.path.join(verifier, "reward.txt"), "1")
|
| 88 |
+
print("reward:", 1 if valid else 0)
|
| 89 |
+
PY
|
tasks/agg-p22-n16-s15/instruction.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Sort the team's private numbers
|
| 2 |
+
|
| 3 |
+
You are on a team of 16 agents solving a private-information number sorting task. Each agent
|
| 4 |
+
holds one private integer from 1 to 99, written in English words. You know only your own
|
| 5 |
+
number, and the others don't know it unless you tell them.
|
| 6 |
+
|
| 7 |
+
Your private number is seventy-six.
|
| 8 |
+
|
| 9 |
+
The team must find all 16 numbers and list their numeric values in ascending order. Keep equal
|
| 10 |
+
numbers from different agents as separate entries: each agent's number appears once in the list,
|
| 11 |
+
even when another agent holds the same value.
|
| 12 |
+
|
| 13 |
+
1. Share your number with the team on the message board.
|
| 14 |
+
2. Read the board for the other participants' numbers. Note which participant each number came
|
| 15 |
+
from, so that a number posted more than once is counted once.
|
| 16 |
+
3. Once you have one number from every participant, yourself included, write `/app/answer.json`
|
| 17 |
+
(create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order.
|
| 18 |
+
Then stop.
|
| 19 |
+
|
| 20 |
+
Any agent may write the full answer, and the team succeeds if at least one agent's answer is
|
| 21 |
+
correct. Your instructions name the other participants and explain the board's tools.
|
tasks/agg-p22-n16-s15/solution/solve.sh
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Oracle: the team's answer from its own copy (not tests/), to validate the grader.
|
| 3 |
+
answer=${ANSWER:-/app/answer.json}
|
| 4 |
+
mkdir -p "$(dirname "$answer")"
|
| 5 |
+
echo '[4, 5, 8, 10, 15, 22, 23, 27, 31, 41, 71, 74, 76, 77, 88, 89]' > "$answer"
|
tasks/agg-p22-n16-s15/task.toml
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
schema_version = "1.4"
|
| 2 |
+
|
| 3 |
+
[task]
|
| 4 |
+
name = "HuggingFaceSwarms/agg-p22-n16-s15"
|
| 5 |
+
version = "0.1.0"
|
| 6 |
+
description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order."
|
| 7 |
+
keywords = ["multi-agent", "message-board", "s3", "aggregation"]
|
| 8 |
+
|
| 9 |
+
[metadata]
|
| 10 |
+
problem = 22
|
| 11 |
+
agents = 16
|
| 12 |
+
slot = 15
|
| 13 |
+
seed = 115
|
| 14 |
+
|
| 15 |
+
[agent]
|
| 16 |
+
timeout_sec = 1800
|
| 17 |
+
|
| 18 |
+
[environment]
|
| 19 |
+
# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it
|
| 20 |
+
# too. Nothing task-specific is in the container: the slot's number is only in its instruction,
|
| 21 |
+
# and tests/ arrive only when the agent is done.
|
| 22 |
+
docker_image = "python:3.12-slim"
|
| 23 |
+
cpus = 1
|
| 24 |
+
memory_mb = 1024
|
| 25 |
+
|
| 26 |
+
[verifier]
|
| 27 |
+
timeout_sec = 60
|
tasks/agg-p22-n16-s15/tests/expected.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
[4, 5, 8, 10, 15, 22, 23, 27, 31, 41, 71, 74, 76, 77, 88, 89]
|
tasks/agg-p22-n16-s15/tests/test.sh
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in
|
| 3 |
+
# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or
|
| 4 |
+
# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or
|
| 5 |
+
# booleans, a missing, extra or dropped duplicate number, and a wrong order.
|
| 6 |
+
# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to
|
| 7 |
+
# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app),
|
| 8 |
+
# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here
|
| 9 |
+
# follows a link the agent may have left, and 0 is written before anything is checked, so a crash
|
| 10 |
+
# of the check also scores 0. A copy of the answer stays with the trial's results.
|
| 11 |
+
# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the
|
| 12 |
+
# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what
|
| 13 |
+
# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or
|
| 14 |
+
# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths
|
| 15 |
+
# (no links in them), to test the grader locally.
|
| 16 |
+
case $0 in */*) here=${0%/*} ;; *) here=. ;; esac
|
| 17 |
+
export ANSWER=${ANSWER:-/app/answer.json}
|
| 18 |
+
export EXPECTED=${EXPECTED:-$here/expected.json}
|
| 19 |
+
export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier}
|
| 20 |
+
[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt"
|
| 21 |
+
python3 -I -S - <<'PY' || true
|
| 22 |
+
import json
|
| 23 |
+
import os
|
| 24 |
+
import stat
|
| 25 |
+
|
| 26 |
+
LIMIT = 1 << 20 # bytes
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def read_own(path):
|
| 30 |
+
# The bytes of the regular file at exactly `path`: every folder on the way is opened
|
| 31 |
+
# without following a link, and so is the file (a FIFO cannot block it); one link only.
|
| 32 |
+
parts = os.path.abspath(path).split("/")[1:]
|
| 33 |
+
folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY)
|
| 34 |
+
try:
|
| 35 |
+
for part in parts[:-1]:
|
| 36 |
+
inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder)
|
| 37 |
+
os.close(folder)
|
| 38 |
+
folder = inner
|
| 39 |
+
fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder)
|
| 40 |
+
finally:
|
| 41 |
+
os.close(folder)
|
| 42 |
+
with os.fdopen(fd, "rb") as stream:
|
| 43 |
+
info = os.fstat(stream.fileno())
|
| 44 |
+
if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1:
|
| 45 |
+
raise ValueError("not a regular file of its own")
|
| 46 |
+
data = stream.read(LIMIT + 1)
|
| 47 |
+
if len(data) > LIMIT:
|
| 48 |
+
raise ValueError("too large")
|
| 49 |
+
return data
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
def write_new(path, text):
|
| 53 |
+
fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644)
|
| 54 |
+
with os.fdopen(fd, "w") as stream:
|
| 55 |
+
stream.write(text)
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
def reject_constant(name):
|
| 59 |
+
raise ValueError(f"{name} is not JSON")
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
def parse(data):
|
| 63 |
+
return json.loads(data.decode("utf-8"), parse_constant=reject_constant)
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
verifier = os.environ["VERIFIER_DIR"]
|
| 67 |
+
os.makedirs(verifier, exist_ok=True)
|
| 68 |
+
for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link
|
| 69 |
+
try:
|
| 70 |
+
os.unlink(os.path.join(verifier, name))
|
| 71 |
+
except FileNotFoundError:
|
| 72 |
+
pass
|
| 73 |
+
write_new(os.path.join(verifier, "reward.txt"), "0")
|
| 74 |
+
valid = False
|
| 75 |
+
try:
|
| 76 |
+
data = read_own(os.environ["ANSWER"])
|
| 77 |
+
write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace"))
|
| 78 |
+
answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"]))
|
| 79 |
+
valid = (
|
| 80 |
+
isinstance(answer, list)
|
| 81 |
+
and all(type(x) is int for x in answer) # not bool, float or str
|
| 82 |
+
and answer == expected
|
| 83 |
+
)
|
| 84 |
+
except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError
|
| 85 |
+
valid = False
|
| 86 |
+
if valid:
|
| 87 |
+
write_new(os.path.join(verifier, "reward.txt"), "1")
|
| 88 |
+
print("reward:", 1 if valid else 0)
|
| 89 |
+
PY
|
tasks/agg-p22-n16-s16/instruction.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Sort the team's private numbers
|
| 2 |
+
|
| 3 |
+
You are on a team of 16 agents solving a private-information number sorting task. Each agent
|
| 4 |
+
holds one private integer from 1 to 99, written in English words. You know only your own
|
| 5 |
+
number, and the others don't know it unless you tell them.
|
| 6 |
+
|
| 7 |
+
Your private number is seventy-seven.
|
| 8 |
+
|
| 9 |
+
The team must find all 16 numbers and list their numeric values in ascending order. Keep equal
|
| 10 |
+
numbers from different agents as separate entries: each agent's number appears once in the list,
|
| 11 |
+
even when another agent holds the same value.
|
| 12 |
+
|
| 13 |
+
1. Share your number with the team on the message board.
|
| 14 |
+
2. Read the board for the other participants' numbers. Note which participant each number came
|
| 15 |
+
from, so that a number posted more than once is counted once.
|
| 16 |
+
3. Once you have one number from every participant, yourself included, write `/app/answer.json`
|
| 17 |
+
(create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order.
|
| 18 |
+
Then stop.
|
| 19 |
+
|
| 20 |
+
Any agent may write the full answer, and the team succeeds if at least one agent's answer is
|
| 21 |
+
correct. Your instructions name the other participants and explain the board's tools.
|
tasks/agg-p22-n16-s16/solution/solve.sh
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Oracle: the team's answer from its own copy (not tests/), to validate the grader.
|
| 3 |
+
answer=${ANSWER:-/app/answer.json}
|
| 4 |
+
mkdir -p "$(dirname "$answer")"
|
| 5 |
+
echo '[4, 5, 8, 10, 15, 22, 23, 27, 31, 41, 71, 74, 76, 77, 88, 89]' > "$answer"
|
tasks/agg-p22-n16-s16/task.toml
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
schema_version = "1.4"
|
| 2 |
+
|
| 3 |
+
[task]
|
| 4 |
+
name = "HuggingFaceSwarms/agg-p22-n16-s16"
|
| 5 |
+
version = "0.1.0"
|
| 6 |
+
description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order."
|
| 7 |
+
keywords = ["multi-agent", "message-board", "s3", "aggregation"]
|
| 8 |
+
|
| 9 |
+
[metadata]
|
| 10 |
+
problem = 22
|
| 11 |
+
agents = 16
|
| 12 |
+
slot = 16
|
| 13 |
+
seed = 115
|
| 14 |
+
|
| 15 |
+
[agent]
|
| 16 |
+
timeout_sec = 1800
|
| 17 |
+
|
| 18 |
+
[environment]
|
| 19 |
+
# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it
|
| 20 |
+
# too. Nothing task-specific is in the container: the slot's number is only in its instruction,
|
| 21 |
+
# and tests/ arrive only when the agent is done.
|
| 22 |
+
docker_image = "python:3.12-slim"
|
| 23 |
+
cpus = 1
|
| 24 |
+
memory_mb = 1024
|
| 25 |
+
|
| 26 |
+
[verifier]
|
| 27 |
+
timeout_sec = 60
|
tasks/agg-p22-n16-s16/tests/expected.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
[4, 5, 8, 10, 15, 22, 23, 27, 31, 41, 71, 74, 76, 77, 88, 89]
|
tasks/agg-p22-n16-s16/tests/test.sh
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in
|
| 3 |
+
# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or
|
| 4 |
+
# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or
|
| 5 |
+
# booleans, a missing, extra or dropped duplicate number, and a wrong order.
|
| 6 |
+
# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to
|
| 7 |
+
# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app),
|
| 8 |
+
# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here
|
| 9 |
+
# follows a link the agent may have left, and 0 is written before anything is checked, so a crash
|
| 10 |
+
# of the check also scores 0. A copy of the answer stays with the trial's results.
|
| 11 |
+
# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the
|
| 12 |
+
# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what
|
| 13 |
+
# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or
|
| 14 |
+
# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths
|
| 15 |
+
# (no links in them), to test the grader locally.
|
| 16 |
+
case $0 in */*) here=${0%/*} ;; *) here=. ;; esac
|
| 17 |
+
export ANSWER=${ANSWER:-/app/answer.json}
|
| 18 |
+
export EXPECTED=${EXPECTED:-$here/expected.json}
|
| 19 |
+
export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier}
|
| 20 |
+
[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt"
|
| 21 |
+
python3 -I -S - <<'PY' || true
|
| 22 |
+
import json
|
| 23 |
+
import os
|
| 24 |
+
import stat
|
| 25 |
+
|
| 26 |
+
LIMIT = 1 << 20 # bytes
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def read_own(path):
|
| 30 |
+
# The bytes of the regular file at exactly `path`: every folder on the way is opened
|
| 31 |
+
# without following a link, and so is the file (a FIFO cannot block it); one link only.
|
| 32 |
+
parts = os.path.abspath(path).split("/")[1:]
|
| 33 |
+
folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY)
|
| 34 |
+
try:
|
| 35 |
+
for part in parts[:-1]:
|
| 36 |
+
inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder)
|
| 37 |
+
os.close(folder)
|
| 38 |
+
folder = inner
|
| 39 |
+
fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder)
|
| 40 |
+
finally:
|
| 41 |
+
os.close(folder)
|
| 42 |
+
with os.fdopen(fd, "rb") as stream:
|
| 43 |
+
info = os.fstat(stream.fileno())
|
| 44 |
+
if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1:
|
| 45 |
+
raise ValueError("not a regular file of its own")
|
| 46 |
+
data = stream.read(LIMIT + 1)
|
| 47 |
+
if len(data) > LIMIT:
|
| 48 |
+
raise ValueError("too large")
|
| 49 |
+
return data
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
def write_new(path, text):
|
| 53 |
+
fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644)
|
| 54 |
+
with os.fdopen(fd, "w") as stream:
|
| 55 |
+
stream.write(text)
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
def reject_constant(name):
|
| 59 |
+
raise ValueError(f"{name} is not JSON")
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
def parse(data):
|
| 63 |
+
return json.loads(data.decode("utf-8"), parse_constant=reject_constant)
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
verifier = os.environ["VERIFIER_DIR"]
|
| 67 |
+
os.makedirs(verifier, exist_ok=True)
|
| 68 |
+
for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link
|
| 69 |
+
try:
|
| 70 |
+
os.unlink(os.path.join(verifier, name))
|
| 71 |
+
except FileNotFoundError:
|
| 72 |
+
pass
|
| 73 |
+
write_new(os.path.join(verifier, "reward.txt"), "0")
|
| 74 |
+
valid = False
|
| 75 |
+
try:
|
| 76 |
+
data = read_own(os.environ["ANSWER"])
|
| 77 |
+
write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace"))
|
| 78 |
+
answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"]))
|
| 79 |
+
valid = (
|
| 80 |
+
isinstance(answer, list)
|
| 81 |
+
and all(type(x) is int for x in answer) # not bool, float or str
|
| 82 |
+
and answer == expected
|
| 83 |
+
)
|
| 84 |
+
except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError
|
| 85 |
+
valid = False
|
| 86 |
+
if valid:
|
| 87 |
+
write_new(os.path.join(verifier, "reward.txt"), "1")
|
| 88 |
+
print("reward:", 1 if valid else 0)
|
| 89 |
+
PY
|
tasks/agg-p23-n01-s01/instruction.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Sort the team's private numbers
|
| 2 |
+
|
| 3 |
+
You are the only agent on this team, solving a private-information number sorting task. You
|
| 4 |
+
hold one private integer from 1 to 99, written in English words.
|
| 5 |
+
|
| 6 |
+
Your private number is twenty.
|
| 7 |
+
|
| 8 |
+
Write `/app/answer.json` (create `/app` if needed): a JSON array holding your number's numeric
|
| 9 |
+
value, as digits. Then stop.
|
tasks/agg-p23-n01-s01/solution/solve.sh
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Oracle: the team's answer from its own copy (not tests/), to validate the grader.
|
| 3 |
+
answer=${ANSWER:-/app/answer.json}
|
| 4 |
+
mkdir -p "$(dirname "$answer")"
|
| 5 |
+
echo '[20]' > "$answer"
|
tasks/agg-p23-n01-s01/task.toml
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
schema_version = "1.4"
|
| 2 |
+
|
| 3 |
+
[task]
|
| 4 |
+
name = "HuggingFaceSwarms/agg-p23-n01-s01"
|
| 5 |
+
version = "0.1.0"
|
| 6 |
+
description = "s3-aggregation: 1 agents each hold a private number; the team lists them all in ascending order."
|
| 7 |
+
keywords = ["multi-agent", "message-board", "s3", "aggregation"]
|
| 8 |
+
|
| 9 |
+
[metadata]
|
| 10 |
+
problem = 23
|
| 11 |
+
agents = 1
|
| 12 |
+
slot = 1
|
| 13 |
+
seed = 115
|
| 14 |
+
|
| 15 |
+
[agent]
|
| 16 |
+
timeout_sec = 1800
|
| 17 |
+
|
| 18 |
+
[environment]
|
| 19 |
+
# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it
|
| 20 |
+
# too. Nothing task-specific is in the container: the slot's number is only in its instruction,
|
| 21 |
+
# and tests/ arrive only when the agent is done.
|
| 22 |
+
docker_image = "python:3.12-slim"
|
| 23 |
+
cpus = 1
|
| 24 |
+
memory_mb = 1024
|
| 25 |
+
|
| 26 |
+
[verifier]
|
| 27 |
+
timeout_sec = 60
|
tasks/agg-p23-n01-s01/tests/expected.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
[20]
|
tasks/agg-p23-n01-s01/tests/test.sh
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in
|
| 3 |
+
# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or
|
| 4 |
+
# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or
|
| 5 |
+
# booleans, a missing, extra or dropped duplicate number, and a wrong order.
|
| 6 |
+
# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to
|
| 7 |
+
# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app),
|
| 8 |
+
# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here
|
| 9 |
+
# follows a link the agent may have left, and 0 is written before anything is checked, so a crash
|
| 10 |
+
# of the check also scores 0. A copy of the answer stays with the trial's results.
|
| 11 |
+
# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the
|
| 12 |
+
# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what
|
| 13 |
+
# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or
|
| 14 |
+
# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths
|
| 15 |
+
# (no links in them), to test the grader locally.
|
| 16 |
+
case $0 in */*) here=${0%/*} ;; *) here=. ;; esac
|
| 17 |
+
export ANSWER=${ANSWER:-/app/answer.json}
|
| 18 |
+
export EXPECTED=${EXPECTED:-$here/expected.json}
|
| 19 |
+
export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier}
|
| 20 |
+
[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt"
|
| 21 |
+
python3 -I -S - <<'PY' || true
|
| 22 |
+
import json
|
| 23 |
+
import os
|
| 24 |
+
import stat
|
| 25 |
+
|
| 26 |
+
LIMIT = 1 << 20 # bytes
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def read_own(path):
|
| 30 |
+
# The bytes of the regular file at exactly `path`: every folder on the way is opened
|
| 31 |
+
# without following a link, and so is the file (a FIFO cannot block it); one link only.
|
| 32 |
+
parts = os.path.abspath(path).split("/")[1:]
|
| 33 |
+
folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY)
|
| 34 |
+
try:
|
| 35 |
+
for part in parts[:-1]:
|
| 36 |
+
inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder)
|
| 37 |
+
os.close(folder)
|
| 38 |
+
folder = inner
|
| 39 |
+
fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder)
|
| 40 |
+
finally:
|
| 41 |
+
os.close(folder)
|
| 42 |
+
with os.fdopen(fd, "rb") as stream:
|
| 43 |
+
info = os.fstat(stream.fileno())
|
| 44 |
+
if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1:
|
| 45 |
+
raise ValueError("not a regular file of its own")
|
| 46 |
+
data = stream.read(LIMIT + 1)
|
| 47 |
+
if len(data) > LIMIT:
|
| 48 |
+
raise ValueError("too large")
|
| 49 |
+
return data
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
def write_new(path, text):
|
| 53 |
+
fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644)
|
| 54 |
+
with os.fdopen(fd, "w") as stream:
|
| 55 |
+
stream.write(text)
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
def reject_constant(name):
|
| 59 |
+
raise ValueError(f"{name} is not JSON")
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
def parse(data):
|
| 63 |
+
return json.loads(data.decode("utf-8"), parse_constant=reject_constant)
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
verifier = os.environ["VERIFIER_DIR"]
|
| 67 |
+
os.makedirs(verifier, exist_ok=True)
|
| 68 |
+
for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link
|
| 69 |
+
try:
|
| 70 |
+
os.unlink(os.path.join(verifier, name))
|
| 71 |
+
except FileNotFoundError:
|
| 72 |
+
pass
|
| 73 |
+
write_new(os.path.join(verifier, "reward.txt"), "0")
|
| 74 |
+
valid = False
|
| 75 |
+
try:
|
| 76 |
+
data = read_own(os.environ["ANSWER"])
|
| 77 |
+
write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace"))
|
| 78 |
+
answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"]))
|
| 79 |
+
valid = (
|
| 80 |
+
isinstance(answer, list)
|
| 81 |
+
and all(type(x) is int for x in answer) # not bool, float or str
|
| 82 |
+
and answer == expected
|
| 83 |
+
)
|
| 84 |
+
except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError
|
| 85 |
+
valid = False
|
| 86 |
+
if valid:
|
| 87 |
+
write_new(os.path.join(verifier, "reward.txt"), "1")
|
| 88 |
+
print("reward:", 1 if valid else 0)
|
| 89 |
+
PY
|
tasks/agg-p23-n02-s01/instruction.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Sort the team's private numbers
|
| 2 |
+
|
| 3 |
+
You are on a team of 2 agents solving a private-information number sorting task. Each agent
|
| 4 |
+
holds one private integer from 1 to 99, written in English words. You know only your own
|
| 5 |
+
number, and the others don't know it unless you tell them.
|
| 6 |
+
|
| 7 |
+
Your private number is twenty.
|
| 8 |
+
|
| 9 |
+
The team must find all 2 numbers and list their numeric values in ascending order. Keep equal
|
| 10 |
+
numbers from different agents as separate entries: each agent's number appears once in the list,
|
| 11 |
+
even when another agent holds the same value.
|
| 12 |
+
|
| 13 |
+
1. Share your number with the team on the message board.
|
| 14 |
+
2. Read the board for the other participants' numbers. Note which participant each number came
|
| 15 |
+
from, so that a number posted more than once is counted once.
|
| 16 |
+
3. Once you have one number from every participant, yourself included, write `/app/answer.json`
|
| 17 |
+
(create `/app` if needed): a JSON array of the 2 integers, as digits, in ascending order.
|
| 18 |
+
Then stop.
|
| 19 |
+
|
| 20 |
+
Any agent may write the full answer, and the team succeeds if at least one agent's answer is
|
| 21 |
+
correct. Your instructions name the other participants and explain the board's tools.
|
tasks/agg-p23-n02-s01/solution/solve.sh
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Oracle: the team's answer from its own copy (not tests/), to validate the grader.
|
| 3 |
+
answer=${ANSWER:-/app/answer.json}
|
| 4 |
+
mkdir -p "$(dirname "$answer")"
|
| 5 |
+
echo '[20, 55]' > "$answer"
|
tasks/agg-p23-n02-s01/task.toml
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
schema_version = "1.4"
|
| 2 |
+
|
| 3 |
+
[task]
|
| 4 |
+
name = "HuggingFaceSwarms/agg-p23-n02-s01"
|
| 5 |
+
version = "0.1.0"
|
| 6 |
+
description = "s3-aggregation: 2 agents each hold a private number; the team lists them all in ascending order."
|
| 7 |
+
keywords = ["multi-agent", "message-board", "s3", "aggregation"]
|
| 8 |
+
|
| 9 |
+
[metadata]
|
| 10 |
+
problem = 23
|
| 11 |
+
agents = 2
|
| 12 |
+
slot = 1
|
| 13 |
+
seed = 115
|
| 14 |
+
|
| 15 |
+
[agent]
|
| 16 |
+
timeout_sec = 1800
|
| 17 |
+
|
| 18 |
+
[environment]
|
| 19 |
+
# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it
|
| 20 |
+
# too. Nothing task-specific is in the container: the slot's number is only in its instruction,
|
| 21 |
+
# and tests/ arrive only when the agent is done.
|
| 22 |
+
docker_image = "python:3.12-slim"
|
| 23 |
+
cpus = 1
|
| 24 |
+
memory_mb = 1024
|
| 25 |
+
|
| 26 |
+
[verifier]
|
| 27 |
+
timeout_sec = 60
|
tasks/agg-p23-n02-s01/tests/expected.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
[20, 55]
|
tasks/agg-p23-n02-s01/tests/test.sh
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in
|
| 3 |
+
# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or
|
| 4 |
+
# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or
|
| 5 |
+
# booleans, a missing, extra or dropped duplicate number, and a wrong order.
|
| 6 |
+
# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to
|
| 7 |
+
# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app),
|
| 8 |
+
# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here
|
| 9 |
+
# follows a link the agent may have left, and 0 is written before anything is checked, so a crash
|
| 10 |
+
# of the check also scores 0. A copy of the answer stays with the trial's results.
|
| 11 |
+
# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the
|
| 12 |
+
# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what
|
| 13 |
+
# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or
|
| 14 |
+
# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths
|
| 15 |
+
# (no links in them), to test the grader locally.
|
| 16 |
+
case $0 in */*) here=${0%/*} ;; *) here=. ;; esac
|
| 17 |
+
export ANSWER=${ANSWER:-/app/answer.json}
|
| 18 |
+
export EXPECTED=${EXPECTED:-$here/expected.json}
|
| 19 |
+
export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier}
|
| 20 |
+
[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt"
|
| 21 |
+
python3 -I -S - <<'PY' || true
|
| 22 |
+
import json
|
| 23 |
+
import os
|
| 24 |
+
import stat
|
| 25 |
+
|
| 26 |
+
LIMIT = 1 << 20 # bytes
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def read_own(path):
|
| 30 |
+
# The bytes of the regular file at exactly `path`: every folder on the way is opened
|
| 31 |
+
# without following a link, and so is the file (a FIFO cannot block it); one link only.
|
| 32 |
+
parts = os.path.abspath(path).split("/")[1:]
|
| 33 |
+
folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY)
|
| 34 |
+
try:
|
| 35 |
+
for part in parts[:-1]:
|
| 36 |
+
inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder)
|
| 37 |
+
os.close(folder)
|
| 38 |
+
folder = inner
|
| 39 |
+
fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder)
|
| 40 |
+
finally:
|
| 41 |
+
os.close(folder)
|
| 42 |
+
with os.fdopen(fd, "rb") as stream:
|
| 43 |
+
info = os.fstat(stream.fileno())
|
| 44 |
+
if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1:
|
| 45 |
+
raise ValueError("not a regular file of its own")
|
| 46 |
+
data = stream.read(LIMIT + 1)
|
| 47 |
+
if len(data) > LIMIT:
|
| 48 |
+
raise ValueError("too large")
|
| 49 |
+
return data
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
def write_new(path, text):
|
| 53 |
+
fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644)
|
| 54 |
+
with os.fdopen(fd, "w") as stream:
|
| 55 |
+
stream.write(text)
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
def reject_constant(name):
|
| 59 |
+
raise ValueError(f"{name} is not JSON")
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
def parse(data):
|
| 63 |
+
return json.loads(data.decode("utf-8"), parse_constant=reject_constant)
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
verifier = os.environ["VERIFIER_DIR"]
|
| 67 |
+
os.makedirs(verifier, exist_ok=True)
|
| 68 |
+
for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link
|
| 69 |
+
try:
|
| 70 |
+
os.unlink(os.path.join(verifier, name))
|
| 71 |
+
except FileNotFoundError:
|
| 72 |
+
pass
|
| 73 |
+
write_new(os.path.join(verifier, "reward.txt"), "0")
|
| 74 |
+
valid = False
|
| 75 |
+
try:
|
| 76 |
+
data = read_own(os.environ["ANSWER"])
|
| 77 |
+
write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace"))
|
| 78 |
+
answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"]))
|
| 79 |
+
valid = (
|
| 80 |
+
isinstance(answer, list)
|
| 81 |
+
and all(type(x) is int for x in answer) # not bool, float or str
|
| 82 |
+
and answer == expected
|
| 83 |
+
)
|
| 84 |
+
except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError
|
| 85 |
+
valid = False
|
| 86 |
+
if valid:
|
| 87 |
+
write_new(os.path.join(verifier, "reward.txt"), "1")
|
| 88 |
+
print("reward:", 1 if valid else 0)
|
| 89 |
+
PY
|
tasks/agg-p23-n02-s02/instruction.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Sort the team's private numbers
|
| 2 |
+
|
| 3 |
+
You are on a team of 2 agents solving a private-information number sorting task. Each agent
|
| 4 |
+
holds one private integer from 1 to 99, written in English words. You know only your own
|
| 5 |
+
number, and the others don't know it unless you tell them.
|
| 6 |
+
|
| 7 |
+
Your private number is fifty-five.
|
| 8 |
+
|
| 9 |
+
The team must find all 2 numbers and list their numeric values in ascending order. Keep equal
|
| 10 |
+
numbers from different agents as separate entries: each agent's number appears once in the list,
|
| 11 |
+
even when another agent holds the same value.
|
| 12 |
+
|
| 13 |
+
1. Share your number with the team on the message board.
|
| 14 |
+
2. Read the board for the other participants' numbers. Note which participant each number came
|
| 15 |
+
from, so that a number posted more than once is counted once.
|
| 16 |
+
3. Once you have one number from every participant, yourself included, write `/app/answer.json`
|
| 17 |
+
(create `/app` if needed): a JSON array of the 2 integers, as digits, in ascending order.
|
| 18 |
+
Then stop.
|
| 19 |
+
|
| 20 |
+
Any agent may write the full answer, and the team succeeds if at least one agent's answer is
|
| 21 |
+
correct. Your instructions name the other participants and explain the board's tools.
|
tasks/agg-p23-n02-s02/solution/solve.sh
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Oracle: the team's answer from its own copy (not tests/), to validate the grader.
|
| 3 |
+
answer=${ANSWER:-/app/answer.json}
|
| 4 |
+
mkdir -p "$(dirname "$answer")"
|
| 5 |
+
echo '[20, 55]' > "$answer"
|
tasks/agg-p23-n02-s02/task.toml
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
schema_version = "1.4"
|
| 2 |
+
|
| 3 |
+
[task]
|
| 4 |
+
name = "HuggingFaceSwarms/agg-p23-n02-s02"
|
| 5 |
+
version = "0.1.0"
|
| 6 |
+
description = "s3-aggregation: 2 agents each hold a private number; the team lists them all in ascending order."
|
| 7 |
+
keywords = ["multi-agent", "message-board", "s3", "aggregation"]
|
| 8 |
+
|
| 9 |
+
[metadata]
|
| 10 |
+
problem = 23
|
| 11 |
+
agents = 2
|
| 12 |
+
slot = 2
|
| 13 |
+
seed = 115
|
| 14 |
+
|
| 15 |
+
[agent]
|
| 16 |
+
timeout_sec = 1800
|
| 17 |
+
|
| 18 |
+
[environment]
|
| 19 |
+
# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it
|
| 20 |
+
# too. Nothing task-specific is in the container: the slot's number is only in its instruction,
|
| 21 |
+
# and tests/ arrive only when the agent is done.
|
| 22 |
+
docker_image = "python:3.12-slim"
|
| 23 |
+
cpus = 1
|
| 24 |
+
memory_mb = 1024
|
| 25 |
+
|
| 26 |
+
[verifier]
|
| 27 |
+
timeout_sec = 60
|
tasks/agg-p23-n02-s02/tests/expected.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
[20, 55]
|
tasks/agg-p23-n02-s02/tests/test.sh
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in
|
| 3 |
+
# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or
|
| 4 |
+
# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or
|
| 5 |
+
# booleans, a missing, extra or dropped duplicate number, and a wrong order.
|
| 6 |
+
# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to
|
| 7 |
+
# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app),
|
| 8 |
+
# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here
|
| 9 |
+
# follows a link the agent may have left, and 0 is written before anything is checked, so a crash
|
| 10 |
+
# of the check also scores 0. A copy of the answer stays with the trial's results.
|
| 11 |
+
# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the
|
| 12 |
+
# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what
|
| 13 |
+
# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or
|
| 14 |
+
# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths
|
| 15 |
+
# (no links in them), to test the grader locally.
|
| 16 |
+
case $0 in */*) here=${0%/*} ;; *) here=. ;; esac
|
| 17 |
+
export ANSWER=${ANSWER:-/app/answer.json}
|
| 18 |
+
export EXPECTED=${EXPECTED:-$here/expected.json}
|
| 19 |
+
export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier}
|
| 20 |
+
[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt"
|
| 21 |
+
python3 -I -S - <<'PY' || true
|
| 22 |
+
import json
|
| 23 |
+
import os
|
| 24 |
+
import stat
|
| 25 |
+
|
| 26 |
+
LIMIT = 1 << 20 # bytes
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def read_own(path):
|
| 30 |
+
# The bytes of the regular file at exactly `path`: every folder on the way is opened
|
| 31 |
+
# without following a link, and so is the file (a FIFO cannot block it); one link only.
|
| 32 |
+
parts = os.path.abspath(path).split("/")[1:]
|
| 33 |
+
folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY)
|
| 34 |
+
try:
|
| 35 |
+
for part in parts[:-1]:
|
| 36 |
+
inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder)
|
| 37 |
+
os.close(folder)
|
| 38 |
+
folder = inner
|
| 39 |
+
fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder)
|
| 40 |
+
finally:
|
| 41 |
+
os.close(folder)
|
| 42 |
+
with os.fdopen(fd, "rb") as stream:
|
| 43 |
+
info = os.fstat(stream.fileno())
|
| 44 |
+
if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1:
|
| 45 |
+
raise ValueError("not a regular file of its own")
|
| 46 |
+
data = stream.read(LIMIT + 1)
|
| 47 |
+
if len(data) > LIMIT:
|
| 48 |
+
raise ValueError("too large")
|
| 49 |
+
return data
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
def write_new(path, text):
|
| 53 |
+
fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644)
|
| 54 |
+
with os.fdopen(fd, "w") as stream:
|
| 55 |
+
stream.write(text)
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
def reject_constant(name):
|
| 59 |
+
raise ValueError(f"{name} is not JSON")
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
def parse(data):
|
| 63 |
+
return json.loads(data.decode("utf-8"), parse_constant=reject_constant)
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
verifier = os.environ["VERIFIER_DIR"]
|
| 67 |
+
os.makedirs(verifier, exist_ok=True)
|
| 68 |
+
for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link
|
| 69 |
+
try:
|
| 70 |
+
os.unlink(os.path.join(verifier, name))
|
| 71 |
+
except FileNotFoundError:
|
| 72 |
+
pass
|
| 73 |
+
write_new(os.path.join(verifier, "reward.txt"), "0")
|
| 74 |
+
valid = False
|
| 75 |
+
try:
|
| 76 |
+
data = read_own(os.environ["ANSWER"])
|
| 77 |
+
write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace"))
|
| 78 |
+
answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"]))
|
| 79 |
+
valid = (
|
| 80 |
+
isinstance(answer, list)
|
| 81 |
+
and all(type(x) is int for x in answer) # not bool, float or str
|
| 82 |
+
and answer == expected
|
| 83 |
+
)
|
| 84 |
+
except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError
|
| 85 |
+
valid = False
|
| 86 |
+
if valid:
|
| 87 |
+
write_new(os.path.join(verifier, "reward.txt"), "1")
|
| 88 |
+
print("reward:", 1 if valid else 0)
|
| 89 |
+
PY
|
tasks/agg-p23-n04-s01/instruction.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Sort the team's private numbers
|
| 2 |
+
|
| 3 |
+
You are on a team of 4 agents solving a private-information number sorting task. Each agent
|
| 4 |
+
holds one private integer from 1 to 99, written in English words. You know only your own
|
| 5 |
+
number, and the others don't know it unless you tell them.
|
| 6 |
+
|
| 7 |
+
Your private number is twenty.
|
| 8 |
+
|
| 9 |
+
The team must find all 4 numbers and list their numeric values in ascending order. Keep equal
|
| 10 |
+
numbers from different agents as separate entries: each agent's number appears once in the list,
|
| 11 |
+
even when another agent holds the same value.
|
| 12 |
+
|
| 13 |
+
1. Share your number with the team on the message board.
|
| 14 |
+
2. Read the board for the other participants' numbers. Note which participant each number came
|
| 15 |
+
from, so that a number posted more than once is counted once.
|
| 16 |
+
3. Once you have one number from every participant, yourself included, write `/app/answer.json`
|
| 17 |
+
(create `/app` if needed): a JSON array of the 4 integers, as digits, in ascending order.
|
| 18 |
+
Then stop.
|
| 19 |
+
|
| 20 |
+
Any agent may write the full answer, and the team succeeds if at least one agent's answer is
|
| 21 |
+
correct. Your instructions name the other participants and explain the board's tools.
|
tasks/agg-p23-n04-s01/solution/solve.sh
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Oracle: the team's answer from its own copy (not tests/), to validate the grader.
|
| 3 |
+
answer=${ANSWER:-/app/answer.json}
|
| 4 |
+
mkdir -p "$(dirname "$answer")"
|
| 5 |
+
echo '[1, 20, 45, 55]' > "$answer"
|
tasks/agg-p23-n04-s01/task.toml
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
schema_version = "1.4"
|
| 2 |
+
|
| 3 |
+
[task]
|
| 4 |
+
name = "HuggingFaceSwarms/agg-p23-n04-s01"
|
| 5 |
+
version = "0.1.0"
|
| 6 |
+
description = "s3-aggregation: 4 agents each hold a private number; the team lists them all in ascending order."
|
| 7 |
+
keywords = ["multi-agent", "message-board", "s3", "aggregation"]
|
| 8 |
+
|
| 9 |
+
[metadata]
|
| 10 |
+
problem = 23
|
| 11 |
+
agents = 4
|
| 12 |
+
slot = 1
|
| 13 |
+
seed = 115
|
| 14 |
+
|
| 15 |
+
[agent]
|
| 16 |
+
timeout_sec = 1800
|
| 17 |
+
|
| 18 |
+
[environment]
|
| 19 |
+
# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it
|
| 20 |
+
# too. Nothing task-specific is in the container: the slot's number is only in its instruction,
|
| 21 |
+
# and tests/ arrive only when the agent is done.
|
| 22 |
+
docker_image = "python:3.12-slim"
|
| 23 |
+
cpus = 1
|
| 24 |
+
memory_mb = 1024
|
| 25 |
+
|
| 26 |
+
[verifier]
|
| 27 |
+
timeout_sec = 60
|
tasks/agg-p23-n04-s01/tests/expected.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
[1, 20, 45, 55]
|
tasks/agg-p23-n04-s01/tests/test.sh
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in
|
| 3 |
+
# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or
|
| 4 |
+
# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or
|
| 5 |
+
# booleans, a missing, extra or dropped duplicate number, and a wrong order.
|
| 6 |
+
# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to
|
| 7 |
+
# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app),
|
| 8 |
+
# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here
|
| 9 |
+
# follows a link the agent may have left, and 0 is written before anything is checked, so a crash
|
| 10 |
+
# of the check also scores 0. A copy of the answer stays with the trial's results.
|
| 11 |
+
# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the
|
| 12 |
+
# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what
|
| 13 |
+
# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or
|
| 14 |
+
# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths
|
| 15 |
+
# (no links in them), to test the grader locally.
|
| 16 |
+
case $0 in */*) here=${0%/*} ;; *) here=. ;; esac
|
| 17 |
+
export ANSWER=${ANSWER:-/app/answer.json}
|
| 18 |
+
export EXPECTED=${EXPECTED:-$here/expected.json}
|
| 19 |
+
export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier}
|
| 20 |
+
[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt"
|
| 21 |
+
python3 -I -S - <<'PY' || true
|
| 22 |
+
import json
|
| 23 |
+
import os
|
| 24 |
+
import stat
|
| 25 |
+
|
| 26 |
+
LIMIT = 1 << 20 # bytes
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def read_own(path):
|
| 30 |
+
# The bytes of the regular file at exactly `path`: every folder on the way is opened
|
| 31 |
+
# without following a link, and so is the file (a FIFO cannot block it); one link only.
|
| 32 |
+
parts = os.path.abspath(path).split("/")[1:]
|
| 33 |
+
folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY)
|
| 34 |
+
try:
|
| 35 |
+
for part in parts[:-1]:
|
| 36 |
+
inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder)
|
| 37 |
+
os.close(folder)
|
| 38 |
+
folder = inner
|
| 39 |
+
fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder)
|
| 40 |
+
finally:
|
| 41 |
+
os.close(folder)
|
| 42 |
+
with os.fdopen(fd, "rb") as stream:
|
| 43 |
+
info = os.fstat(stream.fileno())
|
| 44 |
+
if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1:
|
| 45 |
+
raise ValueError("not a regular file of its own")
|
| 46 |
+
data = stream.read(LIMIT + 1)
|
| 47 |
+
if len(data) > LIMIT:
|
| 48 |
+
raise ValueError("too large")
|
| 49 |
+
return data
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
def write_new(path, text):
|
| 53 |
+
fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644)
|
| 54 |
+
with os.fdopen(fd, "w") as stream:
|
| 55 |
+
stream.write(text)
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
def reject_constant(name):
|
| 59 |
+
raise ValueError(f"{name} is not JSON")
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
def parse(data):
|
| 63 |
+
return json.loads(data.decode("utf-8"), parse_constant=reject_constant)
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
verifier = os.environ["VERIFIER_DIR"]
|
| 67 |
+
os.makedirs(verifier, exist_ok=True)
|
| 68 |
+
for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link
|
| 69 |
+
try:
|
| 70 |
+
os.unlink(os.path.join(verifier, name))
|
| 71 |
+
except FileNotFoundError:
|
| 72 |
+
pass
|
| 73 |
+
write_new(os.path.join(verifier, "reward.txt"), "0")
|
| 74 |
+
valid = False
|
| 75 |
+
try:
|
| 76 |
+
data = read_own(os.environ["ANSWER"])
|
| 77 |
+
write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace"))
|
| 78 |
+
answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"]))
|
| 79 |
+
valid = (
|
| 80 |
+
isinstance(answer, list)
|
| 81 |
+
and all(type(x) is int for x in answer) # not bool, float or str
|
| 82 |
+
and answer == expected
|
| 83 |
+
)
|
| 84 |
+
except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError
|
| 85 |
+
valid = False
|
| 86 |
+
if valid:
|
| 87 |
+
write_new(os.path.join(verifier, "reward.txt"), "1")
|
| 88 |
+
print("reward:", 1 if valid else 0)
|
| 89 |
+
PY
|
tasks/agg-p23-n04-s02/instruction.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Sort the team's private numbers
|
| 2 |
+
|
| 3 |
+
You are on a team of 4 agents solving a private-information number sorting task. Each agent
|
| 4 |
+
holds one private integer from 1 to 99, written in English words. You know only your own
|
| 5 |
+
number, and the others don't know it unless you tell them.
|
| 6 |
+
|
| 7 |
+
Your private number is fifty-five.
|
| 8 |
+
|
| 9 |
+
The team must find all 4 numbers and list their numeric values in ascending order. Keep equal
|
| 10 |
+
numbers from different agents as separate entries: each agent's number appears once in the list,
|
| 11 |
+
even when another agent holds the same value.
|
| 12 |
+
|
| 13 |
+
1. Share your number with the team on the message board.
|
| 14 |
+
2. Read the board for the other participants' numbers. Note which participant each number came
|
| 15 |
+
from, so that a number posted more than once is counted once.
|
| 16 |
+
3. Once you have one number from every participant, yourself included, write `/app/answer.json`
|
| 17 |
+
(create `/app` if needed): a JSON array of the 4 integers, as digits, in ascending order.
|
| 18 |
+
Then stop.
|
| 19 |
+
|
| 20 |
+
Any agent may write the full answer, and the team succeeds if at least one agent's answer is
|
| 21 |
+
correct. Your instructions name the other participants and explain the board's tools.
|
tasks/agg-p23-n04-s02/solution/solve.sh
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Oracle: the team's answer from its own copy (not tests/), to validate the grader.
|
| 3 |
+
answer=${ANSWER:-/app/answer.json}
|
| 4 |
+
mkdir -p "$(dirname "$answer")"
|
| 5 |
+
echo '[1, 20, 45, 55]' > "$answer"
|
tasks/agg-p23-n04-s02/task.toml
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
schema_version = "1.4"
|
| 2 |
+
|
| 3 |
+
[task]
|
| 4 |
+
name = "HuggingFaceSwarms/agg-p23-n04-s02"
|
| 5 |
+
version = "0.1.0"
|
| 6 |
+
description = "s3-aggregation: 4 agents each hold a private number; the team lists them all in ascending order."
|
| 7 |
+
keywords = ["multi-agent", "message-board", "s3", "aggregation"]
|
| 8 |
+
|
| 9 |
+
[metadata]
|
| 10 |
+
problem = 23
|
| 11 |
+
agents = 4
|
| 12 |
+
slot = 2
|
| 13 |
+
seed = 115
|
| 14 |
+
|
| 15 |
+
[agent]
|
| 16 |
+
timeout_sec = 1800
|
| 17 |
+
|
| 18 |
+
[environment]
|
| 19 |
+
# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it
|
| 20 |
+
# too. Nothing task-specific is in the container: the slot's number is only in its instruction,
|
| 21 |
+
# and tests/ arrive only when the agent is done.
|
| 22 |
+
docker_image = "python:3.12-slim"
|
| 23 |
+
cpus = 1
|
| 24 |
+
memory_mb = 1024
|
| 25 |
+
|
| 26 |
+
[verifier]
|
| 27 |
+
timeout_sec = 60
|
tasks/agg-p23-n04-s02/tests/expected.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
[1, 20, 45, 55]
|