diff --git a/tasks/agg-p12-n16-s01/tests/test.sh b/tasks/agg-p12-n16-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p12-n16-s01/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p12-n16-s02/instruction.md b/tasks/agg-p12-n16-s02/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..24cae7506709ba17884a6f8faefcffb0fa372426 --- /dev/null +++ b/tasks/agg-p12-n16-s02/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is fifty. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p12-n16-s02/solution/solve.sh b/tasks/agg-p12-n16-s02/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..631ebdf1542c1b94275cb16db272e15afdaee63c --- /dev/null +++ b/tasks/agg-p12-n16-s02/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 11, 12, 15, 24, 30, 31, 31, 33, 44, 45, 50, 79, 95, 95, 99]' > "$answer" diff --git a/tasks/agg-p12-n16-s02/task.toml b/tasks/agg-p12-n16-s02/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..0f55e77676a47e749d0cdb847112c00a94b60e41 --- /dev/null +++ b/tasks/agg-p12-n16-s02/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p12-n16-s02" +version = "0.1.0" +description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 12 +agents = 16 +slot = 2 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p12-n16-s02/tests/expected.json b/tasks/agg-p12-n16-s02/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..4cde1283b5482652528f0e5f8cc3cc13b6b1ac20 --- /dev/null +++ b/tasks/agg-p12-n16-s02/tests/expected.json @@ -0,0 +1 @@ +[2, 11, 12, 15, 24, 30, 31, 31, 33, 44, 45, 50, 79, 95, 95, 99] diff --git a/tasks/agg-p12-n16-s02/tests/test.sh b/tasks/agg-p12-n16-s02/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p12-n16-s02/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p12-n16-s03/instruction.md b/tasks/agg-p12-n16-s03/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..961985392d4b99bbc35d52871fb6450061a34bb5 --- /dev/null +++ b/tasks/agg-p12-n16-s03/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is ninety-five. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p12-n16-s03/solution/solve.sh b/tasks/agg-p12-n16-s03/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..631ebdf1542c1b94275cb16db272e15afdaee63c --- /dev/null +++ b/tasks/agg-p12-n16-s03/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 11, 12, 15, 24, 30, 31, 31, 33, 44, 45, 50, 79, 95, 95, 99]' > "$answer" diff --git a/tasks/agg-p12-n16-s03/task.toml b/tasks/agg-p12-n16-s03/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..5ed41e8ab6c5d5bb0e77de314454aface45480e1 --- /dev/null +++ b/tasks/agg-p12-n16-s03/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p12-n16-s03" +version = "0.1.0" +description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 12 +agents = 16 +slot = 3 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p12-n16-s03/tests/expected.json b/tasks/agg-p12-n16-s03/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..4cde1283b5482652528f0e5f8cc3cc13b6b1ac20 --- /dev/null +++ b/tasks/agg-p12-n16-s03/tests/expected.json @@ -0,0 +1 @@ +[2, 11, 12, 15, 24, 30, 31, 31, 33, 44, 45, 50, 79, 95, 95, 99] diff --git a/tasks/agg-p12-n16-s03/tests/test.sh b/tasks/agg-p12-n16-s03/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p12-n16-s03/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p12-n16-s04/instruction.md b/tasks/agg-p12-n16-s04/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..0d9b54e563f9bb163b48be34eb84abe311c00e06 --- /dev/null +++ b/tasks/agg-p12-n16-s04/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is twelve. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p12-n16-s04/solution/solve.sh b/tasks/agg-p12-n16-s04/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..631ebdf1542c1b94275cb16db272e15afdaee63c --- /dev/null +++ b/tasks/agg-p12-n16-s04/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 11, 12, 15, 24, 30, 31, 31, 33, 44, 45, 50, 79, 95, 95, 99]' > "$answer" diff --git a/tasks/agg-p12-n16-s04/task.toml b/tasks/agg-p12-n16-s04/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..cbe2e10090ac8e4bb4aad9d8c0340746a50f4412 --- /dev/null +++ b/tasks/agg-p12-n16-s04/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p12-n16-s04" +version = "0.1.0" +description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 12 +agents = 16 +slot = 4 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p12-n16-s04/tests/expected.json b/tasks/agg-p12-n16-s04/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..4cde1283b5482652528f0e5f8cc3cc13b6b1ac20 --- /dev/null +++ b/tasks/agg-p12-n16-s04/tests/expected.json @@ -0,0 +1 @@ +[2, 11, 12, 15, 24, 30, 31, 31, 33, 44, 45, 50, 79, 95, 95, 99] diff --git a/tasks/agg-p12-n16-s04/tests/test.sh b/tasks/agg-p12-n16-s04/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p12-n16-s04/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p12-n16-s05/instruction.md b/tasks/agg-p12-n16-s05/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..e5e3f1447d4ff13fe5188dafc1b5104a3c8f0e59 --- /dev/null +++ b/tasks/agg-p12-n16-s05/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is ninety-nine. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p12-n16-s05/solution/solve.sh b/tasks/agg-p12-n16-s05/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..631ebdf1542c1b94275cb16db272e15afdaee63c --- /dev/null +++ b/tasks/agg-p12-n16-s05/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 11, 12, 15, 24, 30, 31, 31, 33, 44, 45, 50, 79, 95, 95, 99]' > "$answer" diff --git a/tasks/agg-p12-n16-s05/task.toml b/tasks/agg-p12-n16-s05/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..d015da8d801406cfd8450b895063a6e4aaa4ea34 --- /dev/null +++ b/tasks/agg-p12-n16-s05/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p12-n16-s05" +version = "0.1.0" +description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 12 +agents = 16 +slot = 5 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p12-n16-s05/tests/expected.json b/tasks/agg-p12-n16-s05/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..4cde1283b5482652528f0e5f8cc3cc13b6b1ac20 --- /dev/null +++ b/tasks/agg-p12-n16-s05/tests/expected.json @@ -0,0 +1 @@ +[2, 11, 12, 15, 24, 30, 31, 31, 33, 44, 45, 50, 79, 95, 95, 99] diff --git a/tasks/agg-p12-n16-s05/tests/test.sh b/tasks/agg-p12-n16-s05/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p12-n16-s05/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p12-n16-s06/instruction.md b/tasks/agg-p12-n16-s06/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..6b3716855407e49bd1a2d27bc51b41f58fa7bb68 --- /dev/null +++ b/tasks/agg-p12-n16-s06/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is thirty. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p12-n16-s06/solution/solve.sh b/tasks/agg-p12-n16-s06/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..631ebdf1542c1b94275cb16db272e15afdaee63c --- /dev/null +++ b/tasks/agg-p12-n16-s06/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 11, 12, 15, 24, 30, 31, 31, 33, 44, 45, 50, 79, 95, 95, 99]' > "$answer" diff --git a/tasks/agg-p12-n16-s06/task.toml b/tasks/agg-p12-n16-s06/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..6b418b39370c84fcf1e11fd5d71375fb18d2493a --- /dev/null +++ b/tasks/agg-p12-n16-s06/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p12-n16-s06" +version = "0.1.0" +description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 12 +agents = 16 +slot = 6 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p12-n16-s06/tests/expected.json b/tasks/agg-p12-n16-s06/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..4cde1283b5482652528f0e5f8cc3cc13b6b1ac20 --- /dev/null +++ b/tasks/agg-p12-n16-s06/tests/expected.json @@ -0,0 +1 @@ +[2, 11, 12, 15, 24, 30, 31, 31, 33, 44, 45, 50, 79, 95, 95, 99] diff --git a/tasks/agg-p12-n16-s06/tests/test.sh b/tasks/agg-p12-n16-s06/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p12-n16-s06/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p12-n16-s07/instruction.md b/tasks/agg-p12-n16-s07/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..7cf63660731cfb255f4030930d1fa31a717d902f --- /dev/null +++ b/tasks/agg-p12-n16-s07/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is fifteen. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p12-n16-s07/solution/solve.sh b/tasks/agg-p12-n16-s07/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..631ebdf1542c1b94275cb16db272e15afdaee63c --- /dev/null +++ b/tasks/agg-p12-n16-s07/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 11, 12, 15, 24, 30, 31, 31, 33, 44, 45, 50, 79, 95, 95, 99]' > "$answer" diff --git a/tasks/agg-p12-n16-s07/task.toml b/tasks/agg-p12-n16-s07/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..b71c528c979be088bacbbc9d0e42c64cf2a82078 --- /dev/null +++ b/tasks/agg-p12-n16-s07/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p12-n16-s07" +version = "0.1.0" +description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 12 +agents = 16 +slot = 7 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p12-n16-s07/tests/expected.json b/tasks/agg-p12-n16-s07/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..4cde1283b5482652528f0e5f8cc3cc13b6b1ac20 --- /dev/null +++ b/tasks/agg-p12-n16-s07/tests/expected.json @@ -0,0 +1 @@ +[2, 11, 12, 15, 24, 30, 31, 31, 33, 44, 45, 50, 79, 95, 95, 99] diff --git a/tasks/agg-p12-n16-s07/tests/test.sh b/tasks/agg-p12-n16-s07/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p12-n16-s07/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p12-n16-s08/instruction.md b/tasks/agg-p12-n16-s08/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..1245386f0aba38aec1627364e9a0bdce0b3a3214 --- /dev/null +++ b/tasks/agg-p12-n16-s08/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is thirty-one. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p12-n16-s08/solution/solve.sh b/tasks/agg-p12-n16-s08/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..631ebdf1542c1b94275cb16db272e15afdaee63c --- /dev/null +++ b/tasks/agg-p12-n16-s08/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 11, 12, 15, 24, 30, 31, 31, 33, 44, 45, 50, 79, 95, 95, 99]' > "$answer" diff --git a/tasks/agg-p12-n16-s08/task.toml b/tasks/agg-p12-n16-s08/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..6bcc91e709667b2e8a3702579075958b77a3590c --- /dev/null +++ b/tasks/agg-p12-n16-s08/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p12-n16-s08" +version = "0.1.0" +description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 12 +agents = 16 +slot = 8 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p12-n16-s08/tests/expected.json b/tasks/agg-p12-n16-s08/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..4cde1283b5482652528f0e5f8cc3cc13b6b1ac20 --- /dev/null +++ b/tasks/agg-p12-n16-s08/tests/expected.json @@ -0,0 +1 @@ +[2, 11, 12, 15, 24, 30, 31, 31, 33, 44, 45, 50, 79, 95, 95, 99] diff --git a/tasks/agg-p12-n16-s08/tests/test.sh b/tasks/agg-p12-n16-s08/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p12-n16-s08/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p12-n16-s09/instruction.md b/tasks/agg-p12-n16-s09/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..03acbc08880291cf4dacc5df318650e9c8d0e519 --- /dev/null +++ b/tasks/agg-p12-n16-s09/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is forty-five. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p12-n16-s09/solution/solve.sh b/tasks/agg-p12-n16-s09/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..631ebdf1542c1b94275cb16db272e15afdaee63c --- /dev/null +++ b/tasks/agg-p12-n16-s09/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 11, 12, 15, 24, 30, 31, 31, 33, 44, 45, 50, 79, 95, 95, 99]' > "$answer" diff --git a/tasks/agg-p12-n16-s09/task.toml b/tasks/agg-p12-n16-s09/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..77c05919c633bba00dc7169b27ff15737199d236 --- /dev/null +++ b/tasks/agg-p12-n16-s09/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p12-n16-s09" +version = "0.1.0" +description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 12 +agents = 16 +slot = 9 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p12-n16-s09/tests/expected.json b/tasks/agg-p12-n16-s09/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..4cde1283b5482652528f0e5f8cc3cc13b6b1ac20 --- /dev/null +++ b/tasks/agg-p12-n16-s09/tests/expected.json @@ -0,0 +1 @@ +[2, 11, 12, 15, 24, 30, 31, 31, 33, 44, 45, 50, 79, 95, 95, 99] diff --git a/tasks/agg-p12-n16-s09/tests/test.sh b/tasks/agg-p12-n16-s09/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p12-n16-s09/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p12-n16-s10/instruction.md b/tasks/agg-p12-n16-s10/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..a31300409e75190524f2a237c2d0d6348715dc53 --- /dev/null +++ b/tasks/agg-p12-n16-s10/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is forty-four. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p12-n16-s10/solution/solve.sh b/tasks/agg-p12-n16-s10/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..631ebdf1542c1b94275cb16db272e15afdaee63c --- /dev/null +++ b/tasks/agg-p12-n16-s10/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 11, 12, 15, 24, 30, 31, 31, 33, 44, 45, 50, 79, 95, 95, 99]' > "$answer" diff --git a/tasks/agg-p12-n16-s10/task.toml b/tasks/agg-p12-n16-s10/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..c5c9c8fde8acafbfade982523ef416ad473706a2 --- /dev/null +++ b/tasks/agg-p12-n16-s10/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p12-n16-s10" +version = "0.1.0" +description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 12 +agents = 16 +slot = 10 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p12-n16-s10/tests/expected.json b/tasks/agg-p12-n16-s10/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..4cde1283b5482652528f0e5f8cc3cc13b6b1ac20 --- /dev/null +++ b/tasks/agg-p12-n16-s10/tests/expected.json @@ -0,0 +1 @@ +[2, 11, 12, 15, 24, 30, 31, 31, 33, 44, 45, 50, 79, 95, 95, 99] diff --git a/tasks/agg-p12-n16-s10/tests/test.sh b/tasks/agg-p12-n16-s10/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p12-n16-s10/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p12-n16-s11/instruction.md b/tasks/agg-p12-n16-s11/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..1245386f0aba38aec1627364e9a0bdce0b3a3214 --- /dev/null +++ b/tasks/agg-p12-n16-s11/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is thirty-one. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p12-n16-s11/solution/solve.sh b/tasks/agg-p12-n16-s11/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..631ebdf1542c1b94275cb16db272e15afdaee63c --- /dev/null +++ b/tasks/agg-p12-n16-s11/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 11, 12, 15, 24, 30, 31, 31, 33, 44, 45, 50, 79, 95, 95, 99]' > "$answer" diff --git a/tasks/agg-p12-n16-s11/task.toml b/tasks/agg-p12-n16-s11/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..48e9110a2a1480b1d8e9e6e1b394b0e407aa4738 --- /dev/null +++ b/tasks/agg-p12-n16-s11/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p12-n16-s11" +version = "0.1.0" +description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 12 +agents = 16 +slot = 11 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p12-n16-s11/tests/expected.json b/tasks/agg-p12-n16-s11/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..4cde1283b5482652528f0e5f8cc3cc13b6b1ac20 --- /dev/null +++ b/tasks/agg-p12-n16-s11/tests/expected.json @@ -0,0 +1 @@ +[2, 11, 12, 15, 24, 30, 31, 31, 33, 44, 45, 50, 79, 95, 95, 99] diff --git a/tasks/agg-p12-n16-s11/tests/test.sh b/tasks/agg-p12-n16-s11/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p12-n16-s11/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p12-n16-s12/instruction.md b/tasks/agg-p12-n16-s12/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..d92b3c67aa869a2b7ccb0b74ca78af94faae0b02 --- /dev/null +++ b/tasks/agg-p12-n16-s12/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is thirty-three. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p12-n16-s12/solution/solve.sh b/tasks/agg-p12-n16-s12/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..631ebdf1542c1b94275cb16db272e15afdaee63c --- /dev/null +++ b/tasks/agg-p12-n16-s12/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 11, 12, 15, 24, 30, 31, 31, 33, 44, 45, 50, 79, 95, 95, 99]' > "$answer" diff --git a/tasks/agg-p12-n16-s12/task.toml b/tasks/agg-p12-n16-s12/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..023b760c9dfcd3571a129fe9d54ef2ec8a8bc47e --- /dev/null +++ b/tasks/agg-p12-n16-s12/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p12-n16-s12" +version = "0.1.0" +description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 12 +agents = 16 +slot = 12 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p12-n16-s12/tests/expected.json b/tasks/agg-p12-n16-s12/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..4cde1283b5482652528f0e5f8cc3cc13b6b1ac20 --- /dev/null +++ b/tasks/agg-p12-n16-s12/tests/expected.json @@ -0,0 +1 @@ +[2, 11, 12, 15, 24, 30, 31, 31, 33, 44, 45, 50, 79, 95, 95, 99] diff --git a/tasks/agg-p12-n16-s12/tests/test.sh b/tasks/agg-p12-n16-s12/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p12-n16-s12/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p12-n16-s13/instruction.md b/tasks/agg-p12-n16-s13/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..951d8309ecd3f9fbcea5726f506c658fa51c95fe --- /dev/null +++ b/tasks/agg-p12-n16-s13/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is twenty-four. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p12-n16-s13/solution/solve.sh b/tasks/agg-p12-n16-s13/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..631ebdf1542c1b94275cb16db272e15afdaee63c --- /dev/null +++ b/tasks/agg-p12-n16-s13/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 11, 12, 15, 24, 30, 31, 31, 33, 44, 45, 50, 79, 95, 95, 99]' > "$answer" diff --git a/tasks/agg-p12-n16-s13/task.toml b/tasks/agg-p12-n16-s13/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..3f627a3cf61e42277d083c8f1926055eac774a15 --- /dev/null +++ b/tasks/agg-p12-n16-s13/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p12-n16-s13" +version = "0.1.0" +description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 12 +agents = 16 +slot = 13 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p12-n16-s13/tests/expected.json b/tasks/agg-p12-n16-s13/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..4cde1283b5482652528f0e5f8cc3cc13b6b1ac20 --- /dev/null +++ b/tasks/agg-p12-n16-s13/tests/expected.json @@ -0,0 +1 @@ +[2, 11, 12, 15, 24, 30, 31, 31, 33, 44, 45, 50, 79, 95, 95, 99] diff --git a/tasks/agg-p12-n16-s13/tests/test.sh b/tasks/agg-p12-n16-s13/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p12-n16-s13/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p12-n16-s14/instruction.md b/tasks/agg-p12-n16-s14/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..961985392d4b99bbc35d52871fb6450061a34bb5 --- /dev/null +++ b/tasks/agg-p12-n16-s14/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is ninety-five. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p12-n16-s14/solution/solve.sh b/tasks/agg-p12-n16-s14/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..631ebdf1542c1b94275cb16db272e15afdaee63c --- /dev/null +++ b/tasks/agg-p12-n16-s14/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 11, 12, 15, 24, 30, 31, 31, 33, 44, 45, 50, 79, 95, 95, 99]' > "$answer" diff --git a/tasks/agg-p12-n16-s14/task.toml b/tasks/agg-p12-n16-s14/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..806f6f90250f1263958e5ea08b902ff0a45eac4a --- /dev/null +++ b/tasks/agg-p12-n16-s14/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p12-n16-s14" +version = "0.1.0" +description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 12 +agents = 16 +slot = 14 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p12-n16-s14/tests/expected.json b/tasks/agg-p12-n16-s14/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..4cde1283b5482652528f0e5f8cc3cc13b6b1ac20 --- /dev/null +++ b/tasks/agg-p12-n16-s14/tests/expected.json @@ -0,0 +1 @@ +[2, 11, 12, 15, 24, 30, 31, 31, 33, 44, 45, 50, 79, 95, 95, 99] diff --git a/tasks/agg-p12-n16-s14/tests/test.sh b/tasks/agg-p12-n16-s14/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p12-n16-s14/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p12-n16-s15/instruction.md b/tasks/agg-p12-n16-s15/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..f9807e3dca090e22409202efda192d4a7b9f5ac5 --- /dev/null +++ b/tasks/agg-p12-n16-s15/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is seventy-nine. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p12-n16-s15/solution/solve.sh b/tasks/agg-p12-n16-s15/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..631ebdf1542c1b94275cb16db272e15afdaee63c --- /dev/null +++ b/tasks/agg-p12-n16-s15/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 11, 12, 15, 24, 30, 31, 31, 33, 44, 45, 50, 79, 95, 95, 99]' > "$answer" diff --git a/tasks/agg-p12-n16-s15/task.toml b/tasks/agg-p12-n16-s15/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..024722b87adf30d79e1b47f7c7d118a37949d375 --- /dev/null +++ b/tasks/agg-p12-n16-s15/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p12-n16-s15" +version = "0.1.0" +description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 12 +agents = 16 +slot = 15 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p12-n16-s15/tests/expected.json b/tasks/agg-p12-n16-s15/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..4cde1283b5482652528f0e5f8cc3cc13b6b1ac20 --- /dev/null +++ b/tasks/agg-p12-n16-s15/tests/expected.json @@ -0,0 +1 @@ +[2, 11, 12, 15, 24, 30, 31, 31, 33, 44, 45, 50, 79, 95, 95, 99] diff --git a/tasks/agg-p12-n16-s15/tests/test.sh b/tasks/agg-p12-n16-s15/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p12-n16-s15/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p12-n16-s16/instruction.md b/tasks/agg-p12-n16-s16/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..0f12c719492f216b9a3df72f8d724b2259725c6d --- /dev/null +++ b/tasks/agg-p12-n16-s16/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is eleven. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p12-n16-s16/solution/solve.sh b/tasks/agg-p12-n16-s16/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..631ebdf1542c1b94275cb16db272e15afdaee63c --- /dev/null +++ b/tasks/agg-p12-n16-s16/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 11, 12, 15, 24, 30, 31, 31, 33, 44, 45, 50, 79, 95, 95, 99]' > "$answer" diff --git a/tasks/agg-p12-n16-s16/task.toml b/tasks/agg-p12-n16-s16/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..03657b64b2729832294e3f0b67e479707740d68c --- /dev/null +++ b/tasks/agg-p12-n16-s16/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p12-n16-s16" +version = "0.1.0" +description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 12 +agents = 16 +slot = 16 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p12-n16-s16/tests/expected.json b/tasks/agg-p12-n16-s16/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..4cde1283b5482652528f0e5f8cc3cc13b6b1ac20 --- /dev/null +++ b/tasks/agg-p12-n16-s16/tests/expected.json @@ -0,0 +1 @@ +[2, 11, 12, 15, 24, 30, 31, 31, 33, 44, 45, 50, 79, 95, 95, 99] diff --git a/tasks/agg-p12-n16-s16/tests/test.sh b/tasks/agg-p12-n16-s16/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p12-n16-s16/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p13-n01-s01/instruction.md b/tasks/agg-p13-n01-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..940aa4fd9c95e296b244281d4b422b4c4cbaee3b --- /dev/null +++ b/tasks/agg-p13-n01-s01/instruction.md @@ -0,0 +1,9 @@ +# Sort the team's private numbers + +You are the only agent on this team, solving a private-information number sorting task. You +hold one private integer from 1 to 99, written in English words. + +Your private number is forty-two. + +Write `/app/answer.json` (create `/app` if needed): a JSON array holding your number's numeric +value, as digits. Then stop. diff --git a/tasks/agg-p13-n01-s01/solution/solve.sh b/tasks/agg-p13-n01-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..a2d5fc6fc55f62520a41fd97199b2a134440248d --- /dev/null +++ b/tasks/agg-p13-n01-s01/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[42]' > "$answer" diff --git a/tasks/agg-p13-n01-s01/task.toml b/tasks/agg-p13-n01-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..c6a02e8d62561bfa7db2dac1a0ac7ee86f7368d3 --- /dev/null +++ b/tasks/agg-p13-n01-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p13-n01-s01" +version = "0.1.0" +description = "s3-aggregation: 1 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 13 +agents = 1 +slot = 1 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p13-n01-s01/tests/expected.json b/tasks/agg-p13-n01-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e44b4bf78ad721e9ecb7d674989969045e52f8d8 --- /dev/null +++ b/tasks/agg-p13-n01-s01/tests/expected.json @@ -0,0 +1 @@ +[42] diff --git a/tasks/agg-p13-n01-s01/tests/test.sh b/tasks/agg-p13-n01-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p13-n01-s01/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p13-n02-s01/instruction.md b/tasks/agg-p13-n02-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..16a7ad5e103fe676b00156c5c2864b77ca08d8f9 --- /dev/null +++ b/tasks/agg-p13-n02-s01/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 2 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is forty-two. + +The team must find all 2 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 2 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p13-n02-s01/solution/solve.sh b/tasks/agg-p13-n02-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..37ebd8567dedc0a7f0ba57389ceba04141493989 --- /dev/null +++ b/tasks/agg-p13-n02-s01/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[42, 78]' > "$answer" diff --git a/tasks/agg-p13-n02-s01/task.toml b/tasks/agg-p13-n02-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..bea510795d3d17077b2bc1cb73010a9c8ae1d2d7 --- /dev/null +++ b/tasks/agg-p13-n02-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p13-n02-s01" +version = "0.1.0" +description = "s3-aggregation: 2 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 13 +agents = 2 +slot = 1 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p13-n02-s01/tests/expected.json b/tasks/agg-p13-n02-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..71ddc045918a3913bc3640845feab1a843c7c34d --- /dev/null +++ b/tasks/agg-p13-n02-s01/tests/expected.json @@ -0,0 +1 @@ +[42, 78] diff --git a/tasks/agg-p13-n02-s01/tests/test.sh b/tasks/agg-p13-n02-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p13-n02-s01/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p13-n02-s02/instruction.md b/tasks/agg-p13-n02-s02/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..b41b3ebb8b1392fe793ddfe26665e02c2f3979ed --- /dev/null +++ b/tasks/agg-p13-n02-s02/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 2 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is seventy-eight. + +The team must find all 2 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 2 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p13-n02-s02/solution/solve.sh b/tasks/agg-p13-n02-s02/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..37ebd8567dedc0a7f0ba57389ceba04141493989 --- /dev/null +++ b/tasks/agg-p13-n02-s02/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[42, 78]' > "$answer" diff --git a/tasks/agg-p13-n02-s02/task.toml b/tasks/agg-p13-n02-s02/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..99351f2fc08d16035c1e093d46e2d14af1e93576 --- /dev/null +++ b/tasks/agg-p13-n02-s02/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p13-n02-s02" +version = "0.1.0" +description = "s3-aggregation: 2 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 13 +agents = 2 +slot = 2 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p13-n02-s02/tests/expected.json b/tasks/agg-p13-n02-s02/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..71ddc045918a3913bc3640845feab1a843c7c34d --- /dev/null +++ b/tasks/agg-p13-n02-s02/tests/expected.json @@ -0,0 +1 @@ +[42, 78] diff --git a/tasks/agg-p13-n02-s02/tests/test.sh b/tasks/agg-p13-n02-s02/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p13-n02-s02/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p13-n04-s01/instruction.md b/tasks/agg-p13-n04-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..3373394f5046cd80e37af69e5ba69dd7899b4c7d --- /dev/null +++ b/tasks/agg-p13-n04-s01/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 4 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is forty-two. + +The team must find all 4 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 4 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p13-n04-s01/solution/solve.sh b/tasks/agg-p13-n04-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..35002be50b39476d4527b0d9d76ab5ac6ae09fb8 --- /dev/null +++ b/tasks/agg-p13-n04-s01/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[42, 48, 61, 78]' > "$answer" diff --git a/tasks/agg-p13-n04-s01/task.toml b/tasks/agg-p13-n04-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..ed77fd1091ad6175190120407ec783afb6129e75 --- /dev/null +++ b/tasks/agg-p13-n04-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p13-n04-s01" +version = "0.1.0" +description = "s3-aggregation: 4 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 13 +agents = 4 +slot = 1 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p13-n04-s01/tests/expected.json b/tasks/agg-p13-n04-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..f3f067df660293ee9a22648ea6b0ba9e304492e6 --- /dev/null +++ b/tasks/agg-p13-n04-s01/tests/expected.json @@ -0,0 +1 @@ +[42, 48, 61, 78] diff --git a/tasks/agg-p13-n04-s01/tests/test.sh b/tasks/agg-p13-n04-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p13-n04-s01/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p13-n04-s02/instruction.md b/tasks/agg-p13-n04-s02/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..9989acbc218f753b3cf2a0c28b48737e8f8c3b52 --- /dev/null +++ b/tasks/agg-p13-n04-s02/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 4 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is seventy-eight. + +The team must find all 4 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 4 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p13-n04-s02/solution/solve.sh b/tasks/agg-p13-n04-s02/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..35002be50b39476d4527b0d9d76ab5ac6ae09fb8 --- /dev/null +++ b/tasks/agg-p13-n04-s02/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[42, 48, 61, 78]' > "$answer" diff --git a/tasks/agg-p13-n04-s02/task.toml b/tasks/agg-p13-n04-s02/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..b8cc3eb0119583ce6466538242bebacf65f9e301 --- /dev/null +++ b/tasks/agg-p13-n04-s02/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p13-n04-s02" +version = "0.1.0" +description = "s3-aggregation: 4 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 13 +agents = 4 +slot = 2 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p13-n04-s02/tests/expected.json b/tasks/agg-p13-n04-s02/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..f3f067df660293ee9a22648ea6b0ba9e304492e6 --- /dev/null +++ b/tasks/agg-p13-n04-s02/tests/expected.json @@ -0,0 +1 @@ +[42, 48, 61, 78] diff --git a/tasks/agg-p13-n04-s02/tests/test.sh b/tasks/agg-p13-n04-s02/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p13-n04-s02/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p13-n04-s03/instruction.md b/tasks/agg-p13-n04-s03/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..af29f7ab0f75076509388fa943bdfb4a4c0a5922 --- /dev/null +++ b/tasks/agg-p13-n04-s03/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 4 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is forty-eight. + +The team must find all 4 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 4 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p13-n04-s03/solution/solve.sh b/tasks/agg-p13-n04-s03/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..35002be50b39476d4527b0d9d76ab5ac6ae09fb8 --- /dev/null +++ b/tasks/agg-p13-n04-s03/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[42, 48, 61, 78]' > "$answer" diff --git a/tasks/agg-p13-n04-s03/task.toml b/tasks/agg-p13-n04-s03/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..1855c968e9db80a9f36607ccb80cbc60f6df0490 --- /dev/null +++ b/tasks/agg-p13-n04-s03/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p13-n04-s03" +version = "0.1.0" +description = "s3-aggregation: 4 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 13 +agents = 4 +slot = 3 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p13-n04-s03/tests/expected.json b/tasks/agg-p13-n04-s03/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..f3f067df660293ee9a22648ea6b0ba9e304492e6 --- /dev/null +++ b/tasks/agg-p13-n04-s03/tests/expected.json @@ -0,0 +1 @@ +[42, 48, 61, 78] diff --git a/tasks/agg-p13-n04-s03/tests/test.sh b/tasks/agg-p13-n04-s03/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p13-n04-s03/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p13-n04-s04/instruction.md b/tasks/agg-p13-n04-s04/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..518119f71fa817d39b1900a6e48df01e55fc0ff6 --- /dev/null +++ b/tasks/agg-p13-n04-s04/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 4 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is sixty-one. + +The team must find all 4 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 4 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p13-n04-s04/solution/solve.sh b/tasks/agg-p13-n04-s04/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..35002be50b39476d4527b0d9d76ab5ac6ae09fb8 --- /dev/null +++ b/tasks/agg-p13-n04-s04/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[42, 48, 61, 78]' > "$answer" diff --git a/tasks/agg-p13-n04-s04/task.toml b/tasks/agg-p13-n04-s04/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..444efed3e43eda809ae1b00afe4e95d037dd7331 --- /dev/null +++ b/tasks/agg-p13-n04-s04/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p13-n04-s04" +version = "0.1.0" +description = "s3-aggregation: 4 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 13 +agents = 4 +slot = 4 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p13-n04-s04/tests/expected.json b/tasks/agg-p13-n04-s04/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..f3f067df660293ee9a22648ea6b0ba9e304492e6 --- /dev/null +++ b/tasks/agg-p13-n04-s04/tests/expected.json @@ -0,0 +1 @@ +[42, 48, 61, 78] diff --git a/tasks/agg-p13-n04-s04/tests/test.sh b/tasks/agg-p13-n04-s04/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p13-n04-s04/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p13-n08-s01/instruction.md b/tasks/agg-p13-n08-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..abe052012c47c96a92679103d572c7262d672e3c --- /dev/null +++ b/tasks/agg-p13-n08-s01/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 8 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is forty-two. + +The team must find all 8 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 8 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p13-n08-s01/solution/solve.sh b/tasks/agg-p13-n08-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..914e2ae03df76794acacd39bc1a738a34d9d2cda --- /dev/null +++ b/tasks/agg-p13-n08-s01/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 2, 42, 47, 48, 56, 61, 78]' > "$answer" diff --git a/tasks/agg-p13-n08-s01/task.toml b/tasks/agg-p13-n08-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..5670bc45c3b7c562f4ea913546b379bb489f5594 --- /dev/null +++ b/tasks/agg-p13-n08-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p13-n08-s01" +version = "0.1.0" +description = "s3-aggregation: 8 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 13 +agents = 8 +slot = 1 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p13-n08-s01/tests/expected.json b/tasks/agg-p13-n08-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e372178a545444a51fdeb920b181d2ccbcf2f102 --- /dev/null +++ b/tasks/agg-p13-n08-s01/tests/expected.json @@ -0,0 +1 @@ +[2, 2, 42, 47, 48, 56, 61, 78] diff --git a/tasks/agg-p13-n08-s01/tests/test.sh b/tasks/agg-p13-n08-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p13-n08-s01/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p13-n08-s02/instruction.md b/tasks/agg-p13-n08-s02/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..0ee10142e61d08a5571772c533b83202fd01c84e --- /dev/null +++ b/tasks/agg-p13-n08-s02/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 8 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is seventy-eight. + +The team must find all 8 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 8 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p13-n08-s02/solution/solve.sh b/tasks/agg-p13-n08-s02/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..914e2ae03df76794acacd39bc1a738a34d9d2cda --- /dev/null +++ b/tasks/agg-p13-n08-s02/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 2, 42, 47, 48, 56, 61, 78]' > "$answer" diff --git a/tasks/agg-p13-n08-s02/task.toml b/tasks/agg-p13-n08-s02/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..17092573675eb00bcdceed545b9524f974ae3c65 --- /dev/null +++ b/tasks/agg-p13-n08-s02/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p13-n08-s02" +version = "0.1.0" +description = "s3-aggregation: 8 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 13 +agents = 8 +slot = 2 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p13-n08-s02/tests/expected.json b/tasks/agg-p13-n08-s02/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e372178a545444a51fdeb920b181d2ccbcf2f102 --- /dev/null +++ b/tasks/agg-p13-n08-s02/tests/expected.json @@ -0,0 +1 @@ +[2, 2, 42, 47, 48, 56, 61, 78] diff --git a/tasks/agg-p13-n08-s02/tests/test.sh b/tasks/agg-p13-n08-s02/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p13-n08-s02/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p13-n08-s03/instruction.md b/tasks/agg-p13-n08-s03/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..9aeda7c18bda7e04cdb2b969682a97e7b7f2d3d5 --- /dev/null +++ b/tasks/agg-p13-n08-s03/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 8 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is forty-eight. + +The team must find all 8 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 8 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p13-n08-s03/solution/solve.sh b/tasks/agg-p13-n08-s03/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..914e2ae03df76794acacd39bc1a738a34d9d2cda --- /dev/null +++ b/tasks/agg-p13-n08-s03/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 2, 42, 47, 48, 56, 61, 78]' > "$answer" diff --git a/tasks/agg-p13-n08-s03/task.toml b/tasks/agg-p13-n08-s03/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..0787a047fe91a90343db5ac24c7eaeba17c60b43 --- /dev/null +++ b/tasks/agg-p13-n08-s03/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p13-n08-s03" +version = "0.1.0" +description = "s3-aggregation: 8 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 13 +agents = 8 +slot = 3 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p13-n08-s03/tests/expected.json b/tasks/agg-p13-n08-s03/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e372178a545444a51fdeb920b181d2ccbcf2f102 --- /dev/null +++ b/tasks/agg-p13-n08-s03/tests/expected.json @@ -0,0 +1 @@ +[2, 2, 42, 47, 48, 56, 61, 78] diff --git a/tasks/agg-p13-n08-s03/tests/test.sh b/tasks/agg-p13-n08-s03/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p13-n08-s03/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p13-n08-s04/instruction.md b/tasks/agg-p13-n08-s04/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..40f9146550b33cf06b1d4200b62a15ddaaffce76 --- /dev/null +++ b/tasks/agg-p13-n08-s04/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 8 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is sixty-one. + +The team must find all 8 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 8 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p13-n08-s04/solution/solve.sh b/tasks/agg-p13-n08-s04/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..914e2ae03df76794acacd39bc1a738a34d9d2cda --- /dev/null +++ b/tasks/agg-p13-n08-s04/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 2, 42, 47, 48, 56, 61, 78]' > "$answer" diff --git a/tasks/agg-p13-n08-s04/task.toml b/tasks/agg-p13-n08-s04/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..d9ee8f1aa66ca84b1e31b6e6a3f6a56b7bf7e1bc --- /dev/null +++ b/tasks/agg-p13-n08-s04/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p13-n08-s04" +version = "0.1.0" +description = "s3-aggregation: 8 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 13 +agents = 8 +slot = 4 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p13-n08-s04/tests/expected.json b/tasks/agg-p13-n08-s04/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e372178a545444a51fdeb920b181d2ccbcf2f102 --- /dev/null +++ b/tasks/agg-p13-n08-s04/tests/expected.json @@ -0,0 +1 @@ +[2, 2, 42, 47, 48, 56, 61, 78] diff --git a/tasks/agg-p13-n08-s04/tests/test.sh b/tasks/agg-p13-n08-s04/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p13-n08-s04/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p13-n08-s05/instruction.md b/tasks/agg-p13-n08-s05/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..18a0c74cfce99ad5836ee2b774dc98589cdf30c9 --- /dev/null +++ b/tasks/agg-p13-n08-s05/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 8 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is forty-seven. + +The team must find all 8 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 8 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p13-n08-s05/solution/solve.sh b/tasks/agg-p13-n08-s05/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..914e2ae03df76794acacd39bc1a738a34d9d2cda --- /dev/null +++ b/tasks/agg-p13-n08-s05/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 2, 42, 47, 48, 56, 61, 78]' > "$answer" diff --git a/tasks/agg-p13-n08-s05/task.toml b/tasks/agg-p13-n08-s05/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..1e70291ea50947cc2a523824d7a3248e0915a53a --- /dev/null +++ b/tasks/agg-p13-n08-s05/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p13-n08-s05" +version = "0.1.0" +description = "s3-aggregation: 8 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 13 +agents = 8 +slot = 5 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p13-n08-s05/tests/expected.json b/tasks/agg-p13-n08-s05/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e372178a545444a51fdeb920b181d2ccbcf2f102 --- /dev/null +++ b/tasks/agg-p13-n08-s05/tests/expected.json @@ -0,0 +1 @@ +[2, 2, 42, 47, 48, 56, 61, 78] diff --git a/tasks/agg-p13-n08-s05/tests/test.sh b/tasks/agg-p13-n08-s05/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p13-n08-s05/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p13-n08-s06/instruction.md b/tasks/agg-p13-n08-s06/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..b810f3ad633207707958edc8f4de8aaa3b34f710 --- /dev/null +++ b/tasks/agg-p13-n08-s06/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 8 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is fifty-six. + +The team must find all 8 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 8 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p13-n08-s06/solution/solve.sh b/tasks/agg-p13-n08-s06/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..914e2ae03df76794acacd39bc1a738a34d9d2cda --- /dev/null +++ b/tasks/agg-p13-n08-s06/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 2, 42, 47, 48, 56, 61, 78]' > "$answer" diff --git a/tasks/agg-p13-n08-s06/task.toml b/tasks/agg-p13-n08-s06/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..25d54e174e36f1e72905da188de43c393928e24f --- /dev/null +++ b/tasks/agg-p13-n08-s06/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p13-n08-s06" +version = "0.1.0" +description = "s3-aggregation: 8 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 13 +agents = 8 +slot = 6 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p13-n08-s06/tests/expected.json b/tasks/agg-p13-n08-s06/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e372178a545444a51fdeb920b181d2ccbcf2f102 --- /dev/null +++ b/tasks/agg-p13-n08-s06/tests/expected.json @@ -0,0 +1 @@ +[2, 2, 42, 47, 48, 56, 61, 78] diff --git a/tasks/agg-p13-n08-s06/tests/test.sh b/tasks/agg-p13-n08-s06/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p13-n08-s06/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p13-n08-s07/instruction.md b/tasks/agg-p13-n08-s07/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..629e2ae1c728c40605589960cbd96dae496187c1 --- /dev/null +++ b/tasks/agg-p13-n08-s07/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 8 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is two. + +The team must find all 8 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 8 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p13-n08-s07/solution/solve.sh b/tasks/agg-p13-n08-s07/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..914e2ae03df76794acacd39bc1a738a34d9d2cda --- /dev/null +++ b/tasks/agg-p13-n08-s07/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 2, 42, 47, 48, 56, 61, 78]' > "$answer" diff --git a/tasks/agg-p13-n08-s07/task.toml b/tasks/agg-p13-n08-s07/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..67709209cd86e357effb6bc2b8372b0e44c07a70 --- /dev/null +++ b/tasks/agg-p13-n08-s07/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p13-n08-s07" +version = "0.1.0" +description = "s3-aggregation: 8 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 13 +agents = 8 +slot = 7 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p13-n08-s07/tests/expected.json b/tasks/agg-p13-n08-s07/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e372178a545444a51fdeb920b181d2ccbcf2f102 --- /dev/null +++ b/tasks/agg-p13-n08-s07/tests/expected.json @@ -0,0 +1 @@ +[2, 2, 42, 47, 48, 56, 61, 78] diff --git a/tasks/agg-p13-n08-s07/tests/test.sh b/tasks/agg-p13-n08-s07/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p13-n08-s07/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p13-n08-s08/instruction.md b/tasks/agg-p13-n08-s08/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..629e2ae1c728c40605589960cbd96dae496187c1 --- /dev/null +++ b/tasks/agg-p13-n08-s08/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 8 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is two. + +The team must find all 8 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 8 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p13-n08-s08/solution/solve.sh b/tasks/agg-p13-n08-s08/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..914e2ae03df76794acacd39bc1a738a34d9d2cda --- /dev/null +++ b/tasks/agg-p13-n08-s08/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 2, 42, 47, 48, 56, 61, 78]' > "$answer" diff --git a/tasks/agg-p13-n08-s08/task.toml b/tasks/agg-p13-n08-s08/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..d8038666c78f82a4ff140c58c01859cd80fda977 --- /dev/null +++ b/tasks/agg-p13-n08-s08/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p13-n08-s08" +version = "0.1.0" +description = "s3-aggregation: 8 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 13 +agents = 8 +slot = 8 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p13-n08-s08/tests/expected.json b/tasks/agg-p13-n08-s08/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e372178a545444a51fdeb920b181d2ccbcf2f102 --- /dev/null +++ b/tasks/agg-p13-n08-s08/tests/expected.json @@ -0,0 +1 @@ +[2, 2, 42, 47, 48, 56, 61, 78] diff --git a/tasks/agg-p13-n08-s08/tests/test.sh b/tasks/agg-p13-n08-s08/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p13-n08-s08/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p13-n16-s01/instruction.md b/tasks/agg-p13-n16-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..756b66e7e1661b13390451604d8a217c6028d32d --- /dev/null +++ b/tasks/agg-p13-n16-s01/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is forty-two. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p13-n16-s01/solution/solve.sh b/tasks/agg-p13-n16-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..71318053f3eef5b6f1a25eec62e161d98894b7c5 --- /dev/null +++ b/tasks/agg-p13-n16-s01/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 2, 23, 25, 42, 47, 48, 56, 60, 61, 62, 68, 78, 82, 85, 93]' > "$answer" diff --git a/tasks/agg-p13-n16-s01/task.toml b/tasks/agg-p13-n16-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..f3e433324b277bacdfce09245d6ad60027233f2b --- /dev/null +++ b/tasks/agg-p13-n16-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p13-n16-s01" +version = "0.1.0" +description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 13 +agents = 16 +slot = 1 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p13-n16-s01/tests/expected.json b/tasks/agg-p13-n16-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e5e08fe031e04f51020db0bce8ef5a1aaa9924e3 --- /dev/null +++ b/tasks/agg-p13-n16-s01/tests/expected.json @@ -0,0 +1 @@ +[2, 2, 23, 25, 42, 47, 48, 56, 60, 61, 62, 68, 78, 82, 85, 93] diff --git a/tasks/agg-p13-n16-s01/tests/test.sh b/tasks/agg-p13-n16-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p13-n16-s01/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p13-n16-s02/instruction.md b/tasks/agg-p13-n16-s02/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..bd54876511397bdb80a3c3299556503e1fd15da5 --- /dev/null +++ b/tasks/agg-p13-n16-s02/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is seventy-eight. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p13-n16-s02/solution/solve.sh b/tasks/agg-p13-n16-s02/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..71318053f3eef5b6f1a25eec62e161d98894b7c5 --- /dev/null +++ b/tasks/agg-p13-n16-s02/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 2, 23, 25, 42, 47, 48, 56, 60, 61, 62, 68, 78, 82, 85, 93]' > "$answer" diff --git a/tasks/agg-p13-n16-s02/task.toml b/tasks/agg-p13-n16-s02/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..0dd600d64f860afeed19325cb718973ea25bfdd5 --- /dev/null +++ b/tasks/agg-p13-n16-s02/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p13-n16-s02" +version = "0.1.0" +description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 13 +agents = 16 +slot = 2 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p13-n16-s02/tests/expected.json b/tasks/agg-p13-n16-s02/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e5e08fe031e04f51020db0bce8ef5a1aaa9924e3 --- /dev/null +++ b/tasks/agg-p13-n16-s02/tests/expected.json @@ -0,0 +1 @@ +[2, 2, 23, 25, 42, 47, 48, 56, 60, 61, 62, 68, 78, 82, 85, 93] diff --git a/tasks/agg-p13-n16-s02/tests/test.sh b/tasks/agg-p13-n16-s02/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p13-n16-s02/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p13-n16-s03/instruction.md b/tasks/agg-p13-n16-s03/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..38e83aee5771fa00d5091767999e55e04acb180b --- /dev/null +++ b/tasks/agg-p13-n16-s03/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is forty-eight. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p13-n16-s03/solution/solve.sh b/tasks/agg-p13-n16-s03/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..71318053f3eef5b6f1a25eec62e161d98894b7c5 --- /dev/null +++ b/tasks/agg-p13-n16-s03/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 2, 23, 25, 42, 47, 48, 56, 60, 61, 62, 68, 78, 82, 85, 93]' > "$answer" diff --git a/tasks/agg-p13-n16-s03/task.toml b/tasks/agg-p13-n16-s03/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..b278f815ac49be4fbbad5b3e10a37611f9fffc54 --- /dev/null +++ b/tasks/agg-p13-n16-s03/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p13-n16-s03" +version = "0.1.0" +description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 13 +agents = 16 +slot = 3 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p13-n16-s03/tests/expected.json b/tasks/agg-p13-n16-s03/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e5e08fe031e04f51020db0bce8ef5a1aaa9924e3 --- /dev/null +++ b/tasks/agg-p13-n16-s03/tests/expected.json @@ -0,0 +1 @@ +[2, 2, 23, 25, 42, 47, 48, 56, 60, 61, 62, 68, 78, 82, 85, 93] diff --git a/tasks/agg-p13-n16-s03/tests/test.sh b/tasks/agg-p13-n16-s03/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p13-n16-s03/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p13-n16-s04/instruction.md b/tasks/agg-p13-n16-s04/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..72bbb260a72c8a03816a7f046d2bafe5f6b145f2 --- /dev/null +++ b/tasks/agg-p13-n16-s04/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is sixty-one. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p13-n16-s04/solution/solve.sh b/tasks/agg-p13-n16-s04/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..71318053f3eef5b6f1a25eec62e161d98894b7c5 --- /dev/null +++ b/tasks/agg-p13-n16-s04/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 2, 23, 25, 42, 47, 48, 56, 60, 61, 62, 68, 78, 82, 85, 93]' > "$answer" diff --git a/tasks/agg-p13-n16-s04/task.toml b/tasks/agg-p13-n16-s04/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..0f18528d5d1e71d029ad01b5a730b10a81b72681 --- /dev/null +++ b/tasks/agg-p13-n16-s04/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p13-n16-s04" +version = "0.1.0" +description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 13 +agents = 16 +slot = 4 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p13-n16-s04/tests/expected.json b/tasks/agg-p13-n16-s04/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e5e08fe031e04f51020db0bce8ef5a1aaa9924e3 --- /dev/null +++ b/tasks/agg-p13-n16-s04/tests/expected.json @@ -0,0 +1 @@ +[2, 2, 23, 25, 42, 47, 48, 56, 60, 61, 62, 68, 78, 82, 85, 93] diff --git a/tasks/agg-p13-n16-s04/tests/test.sh b/tasks/agg-p13-n16-s04/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p13-n16-s04/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p13-n16-s05/instruction.md b/tasks/agg-p13-n16-s05/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..b591b84320df9e123e22bd4301725691d49ea0a1 --- /dev/null +++ b/tasks/agg-p13-n16-s05/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is forty-seven. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p13-n16-s05/solution/solve.sh b/tasks/agg-p13-n16-s05/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..71318053f3eef5b6f1a25eec62e161d98894b7c5 --- /dev/null +++ b/tasks/agg-p13-n16-s05/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 2, 23, 25, 42, 47, 48, 56, 60, 61, 62, 68, 78, 82, 85, 93]' > "$answer" diff --git a/tasks/agg-p13-n16-s05/task.toml b/tasks/agg-p13-n16-s05/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..e7e5c5ae36e46d56e6a505b74b802ce346a31a72 --- /dev/null +++ b/tasks/agg-p13-n16-s05/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p13-n16-s05" +version = "0.1.0" +description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 13 +agents = 16 +slot = 5 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p13-n16-s05/tests/expected.json b/tasks/agg-p13-n16-s05/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e5e08fe031e04f51020db0bce8ef5a1aaa9924e3 --- /dev/null +++ b/tasks/agg-p13-n16-s05/tests/expected.json @@ -0,0 +1 @@ +[2, 2, 23, 25, 42, 47, 48, 56, 60, 61, 62, 68, 78, 82, 85, 93] diff --git a/tasks/agg-p13-n16-s05/tests/test.sh b/tasks/agg-p13-n16-s05/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p13-n16-s05/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p13-n16-s06/instruction.md b/tasks/agg-p13-n16-s06/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..c06c0812a7b7ea5a0caff9ffd07ddd76bc328ac2 --- /dev/null +++ b/tasks/agg-p13-n16-s06/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is fifty-six. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p13-n16-s06/solution/solve.sh b/tasks/agg-p13-n16-s06/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..71318053f3eef5b6f1a25eec62e161d98894b7c5 --- /dev/null +++ b/tasks/agg-p13-n16-s06/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 2, 23, 25, 42, 47, 48, 56, 60, 61, 62, 68, 78, 82, 85, 93]' > "$answer" diff --git a/tasks/agg-p13-n16-s06/task.toml b/tasks/agg-p13-n16-s06/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..b2c03de1a21a809b5343ab3625a4487fdef5c3b3 --- /dev/null +++ b/tasks/agg-p13-n16-s06/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p13-n16-s06" +version = "0.1.0" +description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 13 +agents = 16 +slot = 6 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p13-n16-s06/tests/expected.json b/tasks/agg-p13-n16-s06/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e5e08fe031e04f51020db0bce8ef5a1aaa9924e3 --- /dev/null +++ b/tasks/agg-p13-n16-s06/tests/expected.json @@ -0,0 +1 @@ +[2, 2, 23, 25, 42, 47, 48, 56, 60, 61, 62, 68, 78, 82, 85, 93] diff --git a/tasks/agg-p13-n16-s06/tests/test.sh b/tasks/agg-p13-n16-s06/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p13-n16-s06/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p13-n16-s07/instruction.md b/tasks/agg-p13-n16-s07/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..ebbf18dd1885eca56e4b99d9ba0f301603987c59 --- /dev/null +++ b/tasks/agg-p13-n16-s07/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is two. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p13-n16-s07/solution/solve.sh b/tasks/agg-p13-n16-s07/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..71318053f3eef5b6f1a25eec62e161d98894b7c5 --- /dev/null +++ b/tasks/agg-p13-n16-s07/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 2, 23, 25, 42, 47, 48, 56, 60, 61, 62, 68, 78, 82, 85, 93]' > "$answer" diff --git a/tasks/agg-p13-n16-s07/task.toml b/tasks/agg-p13-n16-s07/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..972fe69890525b57e544b6c812b7a60bda96a2a5 --- /dev/null +++ b/tasks/agg-p13-n16-s07/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p13-n16-s07" +version = "0.1.0" +description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 13 +agents = 16 +slot = 7 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p13-n16-s07/tests/expected.json b/tasks/agg-p13-n16-s07/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e5e08fe031e04f51020db0bce8ef5a1aaa9924e3 --- /dev/null +++ b/tasks/agg-p13-n16-s07/tests/expected.json @@ -0,0 +1 @@ +[2, 2, 23, 25, 42, 47, 48, 56, 60, 61, 62, 68, 78, 82, 85, 93] diff --git a/tasks/agg-p13-n16-s07/tests/test.sh b/tasks/agg-p13-n16-s07/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p13-n16-s07/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p13-n16-s08/instruction.md b/tasks/agg-p13-n16-s08/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..ebbf18dd1885eca56e4b99d9ba0f301603987c59 --- /dev/null +++ b/tasks/agg-p13-n16-s08/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is two. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p13-n16-s08/solution/solve.sh b/tasks/agg-p13-n16-s08/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..71318053f3eef5b6f1a25eec62e161d98894b7c5 --- /dev/null +++ b/tasks/agg-p13-n16-s08/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 2, 23, 25, 42, 47, 48, 56, 60, 61, 62, 68, 78, 82, 85, 93]' > "$answer" diff --git a/tasks/agg-p13-n16-s08/task.toml b/tasks/agg-p13-n16-s08/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..94aa521d902941867b2ee1b8e6ae0c864f4fb777 --- /dev/null +++ b/tasks/agg-p13-n16-s08/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p13-n16-s08" +version = "0.1.0" +description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 13 +agents = 16 +slot = 8 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p13-n16-s08/tests/expected.json b/tasks/agg-p13-n16-s08/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e5e08fe031e04f51020db0bce8ef5a1aaa9924e3 --- /dev/null +++ b/tasks/agg-p13-n16-s08/tests/expected.json @@ -0,0 +1 @@ +[2, 2, 23, 25, 42, 47, 48, 56, 60, 61, 62, 68, 78, 82, 85, 93] diff --git a/tasks/agg-p13-n16-s08/tests/test.sh b/tasks/agg-p13-n16-s08/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p13-n16-s08/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p13-n16-s09/instruction.md b/tasks/agg-p13-n16-s09/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..07133633c82ade16a43a26c7ec6cacc19d41b3bd --- /dev/null +++ b/tasks/agg-p13-n16-s09/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is twenty-three. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p13-n16-s09/solution/solve.sh b/tasks/agg-p13-n16-s09/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..71318053f3eef5b6f1a25eec62e161d98894b7c5 --- /dev/null +++ b/tasks/agg-p13-n16-s09/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 2, 23, 25, 42, 47, 48, 56, 60, 61, 62, 68, 78, 82, 85, 93]' > "$answer" diff --git a/tasks/agg-p13-n16-s09/task.toml b/tasks/agg-p13-n16-s09/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..c8cf48a2354802be26be66d6809ce52c6610b204 --- /dev/null +++ b/tasks/agg-p13-n16-s09/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p13-n16-s09" +version = "0.1.0" +description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 13 +agents = 16 +slot = 9 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p13-n16-s09/tests/expected.json b/tasks/agg-p13-n16-s09/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e5e08fe031e04f51020db0bce8ef5a1aaa9924e3 --- /dev/null +++ b/tasks/agg-p13-n16-s09/tests/expected.json @@ -0,0 +1 @@ +[2, 2, 23, 25, 42, 47, 48, 56, 60, 61, 62, 68, 78, 82, 85, 93] diff --git a/tasks/agg-p13-n16-s09/tests/test.sh b/tasks/agg-p13-n16-s09/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p13-n16-s09/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p13-n16-s10/instruction.md b/tasks/agg-p13-n16-s10/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..8719f945164b6c7adba0eec9b9728be32d6bfe5e --- /dev/null +++ b/tasks/agg-p13-n16-s10/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is eighty-two. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p13-n16-s10/solution/solve.sh b/tasks/agg-p13-n16-s10/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..71318053f3eef5b6f1a25eec62e161d98894b7c5 --- /dev/null +++ b/tasks/agg-p13-n16-s10/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 2, 23, 25, 42, 47, 48, 56, 60, 61, 62, 68, 78, 82, 85, 93]' > "$answer" diff --git a/tasks/agg-p13-n16-s10/task.toml b/tasks/agg-p13-n16-s10/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..e0079cf9a7ce9e4aecd9d7b4bdc7948ecc68180e --- /dev/null +++ b/tasks/agg-p13-n16-s10/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p13-n16-s10" +version = "0.1.0" +description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 13 +agents = 16 +slot = 10 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p13-n16-s10/tests/expected.json b/tasks/agg-p13-n16-s10/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e5e08fe031e04f51020db0bce8ef5a1aaa9924e3 --- /dev/null +++ b/tasks/agg-p13-n16-s10/tests/expected.json @@ -0,0 +1 @@ +[2, 2, 23, 25, 42, 47, 48, 56, 60, 61, 62, 68, 78, 82, 85, 93] diff --git a/tasks/agg-p13-n16-s10/tests/test.sh b/tasks/agg-p13-n16-s10/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p13-n16-s10/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p13-n16-s11/instruction.md b/tasks/agg-p13-n16-s11/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..81fbf2c2720ed316086419e84cc080153e8dc4cd --- /dev/null +++ b/tasks/agg-p13-n16-s11/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is sixty-two. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p13-n16-s11/solution/solve.sh b/tasks/agg-p13-n16-s11/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..71318053f3eef5b6f1a25eec62e161d98894b7c5 --- /dev/null +++ b/tasks/agg-p13-n16-s11/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 2, 23, 25, 42, 47, 48, 56, 60, 61, 62, 68, 78, 82, 85, 93]' > "$answer" diff --git a/tasks/agg-p13-n16-s11/task.toml b/tasks/agg-p13-n16-s11/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..96696ca2cdf7713d52c1e3054c590fc4d5ff68b0 --- /dev/null +++ b/tasks/agg-p13-n16-s11/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p13-n16-s11" +version = "0.1.0" +description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 13 +agents = 16 +slot = 11 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p13-n16-s11/tests/expected.json b/tasks/agg-p13-n16-s11/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e5e08fe031e04f51020db0bce8ef5a1aaa9924e3 --- /dev/null +++ b/tasks/agg-p13-n16-s11/tests/expected.json @@ -0,0 +1 @@ +[2, 2, 23, 25, 42, 47, 48, 56, 60, 61, 62, 68, 78, 82, 85, 93] diff --git a/tasks/agg-p13-n16-s11/tests/test.sh b/tasks/agg-p13-n16-s11/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p13-n16-s11/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p13-n16-s12/instruction.md b/tasks/agg-p13-n16-s12/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..04c3f6729149d2802728807768786a453bb32941 --- /dev/null +++ b/tasks/agg-p13-n16-s12/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is twenty-five. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p13-n16-s12/solution/solve.sh b/tasks/agg-p13-n16-s12/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..71318053f3eef5b6f1a25eec62e161d98894b7c5 --- /dev/null +++ b/tasks/agg-p13-n16-s12/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 2, 23, 25, 42, 47, 48, 56, 60, 61, 62, 68, 78, 82, 85, 93]' > "$answer" diff --git a/tasks/agg-p13-n16-s12/task.toml b/tasks/agg-p13-n16-s12/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..a79c7d49abb40f58abb1d22292b4f899031a93ec --- /dev/null +++ b/tasks/agg-p13-n16-s12/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p13-n16-s12" +version = "0.1.0" +description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 13 +agents = 16 +slot = 12 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p13-n16-s12/tests/expected.json b/tasks/agg-p13-n16-s12/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e5e08fe031e04f51020db0bce8ef5a1aaa9924e3 --- /dev/null +++ b/tasks/agg-p13-n16-s12/tests/expected.json @@ -0,0 +1 @@ +[2, 2, 23, 25, 42, 47, 48, 56, 60, 61, 62, 68, 78, 82, 85, 93] diff --git a/tasks/agg-p13-n16-s12/tests/test.sh b/tasks/agg-p13-n16-s12/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p13-n16-s12/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p13-n16-s13/instruction.md b/tasks/agg-p13-n16-s13/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..a74f85b07c6b9158e3042c827fbada79d595e8f5 --- /dev/null +++ b/tasks/agg-p13-n16-s13/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is eighty-five. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p13-n16-s13/solution/solve.sh b/tasks/agg-p13-n16-s13/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..71318053f3eef5b6f1a25eec62e161d98894b7c5 --- /dev/null +++ b/tasks/agg-p13-n16-s13/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 2, 23, 25, 42, 47, 48, 56, 60, 61, 62, 68, 78, 82, 85, 93]' > "$answer" diff --git a/tasks/agg-p13-n16-s13/task.toml b/tasks/agg-p13-n16-s13/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..887ab17be983089e254e085633bef1175ddcc6de --- /dev/null +++ b/tasks/agg-p13-n16-s13/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p13-n16-s13" +version = "0.1.0" +description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 13 +agents = 16 +slot = 13 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p13-n16-s13/tests/expected.json b/tasks/agg-p13-n16-s13/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e5e08fe031e04f51020db0bce8ef5a1aaa9924e3 --- /dev/null +++ b/tasks/agg-p13-n16-s13/tests/expected.json @@ -0,0 +1 @@ +[2, 2, 23, 25, 42, 47, 48, 56, 60, 61, 62, 68, 78, 82, 85, 93] diff --git a/tasks/agg-p13-n16-s13/tests/test.sh b/tasks/agg-p13-n16-s13/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p13-n16-s13/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p13-n16-s14/instruction.md b/tasks/agg-p13-n16-s14/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..a7f0266a5e6733a93cf24a409665e6e92f793dba --- /dev/null +++ b/tasks/agg-p13-n16-s14/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is sixty-eight. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p13-n16-s14/solution/solve.sh b/tasks/agg-p13-n16-s14/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..71318053f3eef5b6f1a25eec62e161d98894b7c5 --- /dev/null +++ b/tasks/agg-p13-n16-s14/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 2, 23, 25, 42, 47, 48, 56, 60, 61, 62, 68, 78, 82, 85, 93]' > "$answer" diff --git a/tasks/agg-p13-n16-s14/task.toml b/tasks/agg-p13-n16-s14/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..cbafa8b0c753659b65f14149374f84cd73c7d3f9 --- /dev/null +++ b/tasks/agg-p13-n16-s14/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p13-n16-s14" +version = "0.1.0" +description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 13 +agents = 16 +slot = 14 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p13-n16-s14/tests/expected.json b/tasks/agg-p13-n16-s14/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e5e08fe031e04f51020db0bce8ef5a1aaa9924e3 --- /dev/null +++ b/tasks/agg-p13-n16-s14/tests/expected.json @@ -0,0 +1 @@ +[2, 2, 23, 25, 42, 47, 48, 56, 60, 61, 62, 68, 78, 82, 85, 93] diff --git a/tasks/agg-p13-n16-s14/tests/test.sh b/tasks/agg-p13-n16-s14/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p13-n16-s14/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p13-n16-s15/instruction.md b/tasks/agg-p13-n16-s15/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..0d32baca836c92adef8d08189e020f30d37446a4 --- /dev/null +++ b/tasks/agg-p13-n16-s15/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is sixty. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p13-n16-s15/solution/solve.sh b/tasks/agg-p13-n16-s15/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..71318053f3eef5b6f1a25eec62e161d98894b7c5 --- /dev/null +++ b/tasks/agg-p13-n16-s15/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 2, 23, 25, 42, 47, 48, 56, 60, 61, 62, 68, 78, 82, 85, 93]' > "$answer" diff --git a/tasks/agg-p13-n16-s15/task.toml b/tasks/agg-p13-n16-s15/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..a1c632cfa421598577979528f43e911200f4fa34 --- /dev/null +++ b/tasks/agg-p13-n16-s15/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p13-n16-s15" +version = "0.1.0" +description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 13 +agents = 16 +slot = 15 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p13-n16-s15/tests/expected.json b/tasks/agg-p13-n16-s15/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e5e08fe031e04f51020db0bce8ef5a1aaa9924e3 --- /dev/null +++ b/tasks/agg-p13-n16-s15/tests/expected.json @@ -0,0 +1 @@ +[2, 2, 23, 25, 42, 47, 48, 56, 60, 61, 62, 68, 78, 82, 85, 93] diff --git a/tasks/agg-p13-n16-s15/tests/test.sh b/tasks/agg-p13-n16-s15/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p13-n16-s15/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p13-n16-s16/instruction.md b/tasks/agg-p13-n16-s16/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..5a931caf2f59950e949680657e57e512d16ee533 --- /dev/null +++ b/tasks/agg-p13-n16-s16/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is ninety-three. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p13-n16-s16/solution/solve.sh b/tasks/agg-p13-n16-s16/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..71318053f3eef5b6f1a25eec62e161d98894b7c5 --- /dev/null +++ b/tasks/agg-p13-n16-s16/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 2, 23, 25, 42, 47, 48, 56, 60, 61, 62, 68, 78, 82, 85, 93]' > "$answer" diff --git a/tasks/agg-p13-n16-s16/task.toml b/tasks/agg-p13-n16-s16/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..86ee7b5387a405520929ca0b06769f47811ada08 --- /dev/null +++ b/tasks/agg-p13-n16-s16/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p13-n16-s16" +version = "0.1.0" +description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 13 +agents = 16 +slot = 16 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p13-n16-s16/tests/expected.json b/tasks/agg-p13-n16-s16/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e5e08fe031e04f51020db0bce8ef5a1aaa9924e3 --- /dev/null +++ b/tasks/agg-p13-n16-s16/tests/expected.json @@ -0,0 +1 @@ +[2, 2, 23, 25, 42, 47, 48, 56, 60, 61, 62, 68, 78, 82, 85, 93] diff --git a/tasks/agg-p13-n16-s16/tests/test.sh b/tasks/agg-p13-n16-s16/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p13-n16-s16/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p14-n01-s01/instruction.md b/tasks/agg-p14-n01-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..3f5c5a8cf74db4c97c8e56d4b5fb4ff1018ed680 --- /dev/null +++ b/tasks/agg-p14-n01-s01/instruction.md @@ -0,0 +1,9 @@ +# Sort the team's private numbers + +You are the only agent on this team, solving a private-information number sorting task. You +hold one private integer from 1 to 99, written in English words. + +Your private number is eighty-four. + +Write `/app/answer.json` (create `/app` if needed): a JSON array holding your number's numeric +value, as digits. Then stop. diff --git a/tasks/agg-p14-n01-s01/solution/solve.sh b/tasks/agg-p14-n01-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3e2c7374256a9c5e817db16b5fd46560c1e33430 --- /dev/null +++ b/tasks/agg-p14-n01-s01/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[84]' > "$answer" diff --git a/tasks/agg-p14-n01-s01/task.toml b/tasks/agg-p14-n01-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..44917baf30e8333a9d8eaf2a1ecb9f38a7e09e81 --- /dev/null +++ b/tasks/agg-p14-n01-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p14-n01-s01" +version = "0.1.0" +description = "s3-aggregation: 1 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 14 +agents = 1 +slot = 1 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p14-n01-s01/tests/expected.json b/tasks/agg-p14-n01-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..ecdce0605f97af01d7a2dadd3a4e4fb68e5c9cb7 --- /dev/null +++ b/tasks/agg-p14-n01-s01/tests/expected.json @@ -0,0 +1 @@ +[84] diff --git a/tasks/agg-p14-n01-s01/tests/test.sh b/tasks/agg-p14-n01-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p14-n01-s01/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p14-n02-s01/instruction.md b/tasks/agg-p14-n02-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..498afa487440d15bb8b123d1262f0e5f1b11cb32 --- /dev/null +++ b/tasks/agg-p14-n02-s01/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 2 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is eighty-four. + +The team must find all 2 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 2 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p14-n02-s01/solution/solve.sh b/tasks/agg-p14-n02-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..27708909dc212a4e410ec88e04a884334ca17389 --- /dev/null +++ b/tasks/agg-p14-n02-s01/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[29, 84]' > "$answer" diff --git a/tasks/agg-p14-n02-s01/task.toml b/tasks/agg-p14-n02-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..f1dfe80c804bc9a22885f3d86276e25375a4fd16 --- /dev/null +++ b/tasks/agg-p14-n02-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p14-n02-s01" +version = "0.1.0" +description = "s3-aggregation: 2 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 14 +agents = 2 +slot = 1 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p14-n02-s01/tests/expected.json b/tasks/agg-p14-n02-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..2eeb62ddfbe8841d7ec4d1cfc7f294cd1fa60807 --- /dev/null +++ b/tasks/agg-p14-n02-s01/tests/expected.json @@ -0,0 +1 @@ +[29, 84] diff --git a/tasks/agg-p14-n02-s01/tests/test.sh b/tasks/agg-p14-n02-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p14-n02-s01/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p14-n02-s02/instruction.md b/tasks/agg-p14-n02-s02/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..e621302d95daf78f55f398b62ae6ecdb5f7e28d9 --- /dev/null +++ b/tasks/agg-p14-n02-s02/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 2 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is twenty-nine. + +The team must find all 2 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 2 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p14-n02-s02/solution/solve.sh b/tasks/agg-p14-n02-s02/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..27708909dc212a4e410ec88e04a884334ca17389 --- /dev/null +++ b/tasks/agg-p14-n02-s02/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[29, 84]' > "$answer" diff --git a/tasks/agg-p14-n02-s02/task.toml b/tasks/agg-p14-n02-s02/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..9fb4c5fd2ac83fe85b9c9f8177de2f678347dd82 --- /dev/null +++ b/tasks/agg-p14-n02-s02/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p14-n02-s02" +version = "0.1.0" +description = "s3-aggregation: 2 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 14 +agents = 2 +slot = 2 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p14-n02-s02/tests/expected.json b/tasks/agg-p14-n02-s02/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..2eeb62ddfbe8841d7ec4d1cfc7f294cd1fa60807 --- /dev/null +++ b/tasks/agg-p14-n02-s02/tests/expected.json @@ -0,0 +1 @@ +[29, 84] diff --git a/tasks/agg-p14-n02-s02/tests/test.sh b/tasks/agg-p14-n02-s02/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p14-n02-s02/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p14-n04-s01/instruction.md b/tasks/agg-p14-n04-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..1e0005927fd30585d62f857e454dc88b98e7e051 --- /dev/null +++ b/tasks/agg-p14-n04-s01/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 4 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is eighty-four. + +The team must find all 4 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 4 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p14-n04-s01/solution/solve.sh b/tasks/agg-p14-n04-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4de6f148d84374a9b9d8f025f89bbadcc687c471 --- /dev/null +++ b/tasks/agg-p14-n04-s01/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[29, 49, 53, 84]' > "$answer" diff --git a/tasks/agg-p14-n04-s01/task.toml b/tasks/agg-p14-n04-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..2e7284e06683438740a626d6c8f1691e986b1793 --- /dev/null +++ b/tasks/agg-p14-n04-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p14-n04-s01" +version = "0.1.0" +description = "s3-aggregation: 4 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 14 +agents = 4 +slot = 1 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p14-n04-s01/tests/expected.json b/tasks/agg-p14-n04-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e0a3fa95f9152d18ec2519fd8cc7d402aee9ce58 --- /dev/null +++ b/tasks/agg-p14-n04-s01/tests/expected.json @@ -0,0 +1 @@ +[29, 49, 53, 84] diff --git a/tasks/agg-p14-n04-s01/tests/test.sh b/tasks/agg-p14-n04-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p14-n04-s01/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p14-n04-s02/instruction.md b/tasks/agg-p14-n04-s02/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..5701fcd4297e555c8d075e61ef8d9eb6c5faba09 --- /dev/null +++ b/tasks/agg-p14-n04-s02/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 4 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is twenty-nine. + +The team must find all 4 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 4 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p14-n04-s02/solution/solve.sh b/tasks/agg-p14-n04-s02/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4de6f148d84374a9b9d8f025f89bbadcc687c471 --- /dev/null +++ b/tasks/agg-p14-n04-s02/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[29, 49, 53, 84]' > "$answer" diff --git a/tasks/agg-p14-n04-s02/task.toml b/tasks/agg-p14-n04-s02/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..ed22fdf14f8e7b6ac385339ca1f2240d7cd55cc2 --- /dev/null +++ b/tasks/agg-p14-n04-s02/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p14-n04-s02" +version = "0.1.0" +description = "s3-aggregation: 4 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 14 +agents = 4 +slot = 2 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p14-n04-s02/tests/expected.json b/tasks/agg-p14-n04-s02/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e0a3fa95f9152d18ec2519fd8cc7d402aee9ce58 --- /dev/null +++ b/tasks/agg-p14-n04-s02/tests/expected.json @@ -0,0 +1 @@ +[29, 49, 53, 84] diff --git a/tasks/agg-p14-n04-s02/tests/test.sh b/tasks/agg-p14-n04-s02/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p14-n04-s02/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p14-n04-s03/instruction.md b/tasks/agg-p14-n04-s03/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..26e139695ec67bfa61fe76d01a807b84861131dd --- /dev/null +++ b/tasks/agg-p14-n04-s03/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 4 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is fifty-three. + +The team must find all 4 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 4 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p14-n04-s03/solution/solve.sh b/tasks/agg-p14-n04-s03/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4de6f148d84374a9b9d8f025f89bbadcc687c471 --- /dev/null +++ b/tasks/agg-p14-n04-s03/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[29, 49, 53, 84]' > "$answer" diff --git a/tasks/agg-p14-n04-s03/task.toml b/tasks/agg-p14-n04-s03/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..7bfc21d62c74c2f28f67c6dc2a8e2585d4766f0c --- /dev/null +++ b/tasks/agg-p14-n04-s03/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p14-n04-s03" +version = "0.1.0" +description = "s3-aggregation: 4 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 14 +agents = 4 +slot = 3 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p14-n04-s03/tests/expected.json b/tasks/agg-p14-n04-s03/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e0a3fa95f9152d18ec2519fd8cc7d402aee9ce58 --- /dev/null +++ b/tasks/agg-p14-n04-s03/tests/expected.json @@ -0,0 +1 @@ +[29, 49, 53, 84] diff --git a/tasks/agg-p14-n04-s03/tests/test.sh b/tasks/agg-p14-n04-s03/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p14-n04-s03/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p14-n04-s04/instruction.md b/tasks/agg-p14-n04-s04/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..c73578c8e3f0d0f1dada19aa91aa8fa6cc5ce6d9 --- /dev/null +++ b/tasks/agg-p14-n04-s04/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 4 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is forty-nine. + +The team must find all 4 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 4 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p14-n04-s04/solution/solve.sh b/tasks/agg-p14-n04-s04/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4de6f148d84374a9b9d8f025f89bbadcc687c471 --- /dev/null +++ b/tasks/agg-p14-n04-s04/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[29, 49, 53, 84]' > "$answer" diff --git a/tasks/agg-p14-n04-s04/task.toml b/tasks/agg-p14-n04-s04/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..4e9899eec527078eab2b612858f995b1d7304972 --- /dev/null +++ b/tasks/agg-p14-n04-s04/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p14-n04-s04" +version = "0.1.0" +description = "s3-aggregation: 4 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 14 +agents = 4 +slot = 4 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p14-n04-s04/tests/expected.json b/tasks/agg-p14-n04-s04/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e0a3fa95f9152d18ec2519fd8cc7d402aee9ce58 --- /dev/null +++ b/tasks/agg-p14-n04-s04/tests/expected.json @@ -0,0 +1 @@ +[29, 49, 53, 84] diff --git a/tasks/agg-p14-n04-s04/tests/test.sh b/tasks/agg-p14-n04-s04/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p14-n04-s04/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p14-n08-s01/instruction.md b/tasks/agg-p14-n08-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..6662e6911ad1105e195cbc6e76b3cc8d9854bef3 --- /dev/null +++ b/tasks/agg-p14-n08-s01/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 8 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is eighty-four. + +The team must find all 8 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 8 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p14-n08-s01/solution/solve.sh b/tasks/agg-p14-n08-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..a76327afcdb4c6f9daf723ba49751ceb9a41fb72 --- /dev/null +++ b/tasks/agg-p14-n08-s01/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[25, 29, 39, 44, 49, 53, 59, 84]' > "$answer" diff --git a/tasks/agg-p14-n08-s01/task.toml b/tasks/agg-p14-n08-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..0d1447e5a6533cbd60175394e69838f5e41db44a --- /dev/null +++ b/tasks/agg-p14-n08-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p14-n08-s01" +version = "0.1.0" +description = "s3-aggregation: 8 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 14 +agents = 8 +slot = 1 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p14-n08-s01/tests/expected.json b/tasks/agg-p14-n08-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..ac0a63b220cabf1707ce425208fa8be7f0002727 --- /dev/null +++ b/tasks/agg-p14-n08-s01/tests/expected.json @@ -0,0 +1 @@ +[25, 29, 39, 44, 49, 53, 59, 84] diff --git a/tasks/agg-p14-n08-s01/tests/test.sh b/tasks/agg-p14-n08-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p14-n08-s01/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p14-n08-s02/instruction.md b/tasks/agg-p14-n08-s02/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..efc3ca50863310e063ca355ec298707c5d0b6577 --- /dev/null +++ b/tasks/agg-p14-n08-s02/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 8 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is twenty-nine. + +The team must find all 8 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 8 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p14-n08-s02/solution/solve.sh b/tasks/agg-p14-n08-s02/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..a76327afcdb4c6f9daf723ba49751ceb9a41fb72 --- /dev/null +++ b/tasks/agg-p14-n08-s02/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[25, 29, 39, 44, 49, 53, 59, 84]' > "$answer" diff --git a/tasks/agg-p14-n08-s02/task.toml b/tasks/agg-p14-n08-s02/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..b12cac334de0c0420601b267401cf0d313ab7ee1 --- /dev/null +++ b/tasks/agg-p14-n08-s02/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p14-n08-s02" +version = "0.1.0" +description = "s3-aggregation: 8 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 14 +agents = 8 +slot = 2 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p14-n08-s02/tests/expected.json b/tasks/agg-p14-n08-s02/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..ac0a63b220cabf1707ce425208fa8be7f0002727 --- /dev/null +++ b/tasks/agg-p14-n08-s02/tests/expected.json @@ -0,0 +1 @@ +[25, 29, 39, 44, 49, 53, 59, 84] diff --git a/tasks/agg-p14-n08-s02/tests/test.sh b/tasks/agg-p14-n08-s02/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p14-n08-s02/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p14-n08-s03/instruction.md b/tasks/agg-p14-n08-s03/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..fb0fbc43bc72c36371a3de146c4ffbb7a4304417 --- /dev/null +++ b/tasks/agg-p14-n08-s03/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 8 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is fifty-three. + +The team must find all 8 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 8 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p14-n08-s03/solution/solve.sh b/tasks/agg-p14-n08-s03/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..a76327afcdb4c6f9daf723ba49751ceb9a41fb72 --- /dev/null +++ b/tasks/agg-p14-n08-s03/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[25, 29, 39, 44, 49, 53, 59, 84]' > "$answer" diff --git a/tasks/agg-p14-n08-s03/task.toml b/tasks/agg-p14-n08-s03/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..569200891776072317e6dca0d89f805f8c689891 --- /dev/null +++ b/tasks/agg-p14-n08-s03/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p14-n08-s03" +version = "0.1.0" +description = "s3-aggregation: 8 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 14 +agents = 8 +slot = 3 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p14-n08-s03/tests/expected.json b/tasks/agg-p14-n08-s03/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..ac0a63b220cabf1707ce425208fa8be7f0002727 --- /dev/null +++ b/tasks/agg-p14-n08-s03/tests/expected.json @@ -0,0 +1 @@ +[25, 29, 39, 44, 49, 53, 59, 84] diff --git a/tasks/agg-p14-n08-s03/tests/test.sh b/tasks/agg-p14-n08-s03/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p14-n08-s03/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p14-n08-s04/instruction.md b/tasks/agg-p14-n08-s04/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..2977a346481de4a6052c0959cd91ba095dded4f4 --- /dev/null +++ b/tasks/agg-p14-n08-s04/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 8 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is forty-nine. + +The team must find all 8 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 8 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p14-n08-s04/solution/solve.sh b/tasks/agg-p14-n08-s04/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..a76327afcdb4c6f9daf723ba49751ceb9a41fb72 --- /dev/null +++ b/tasks/agg-p14-n08-s04/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[25, 29, 39, 44, 49, 53, 59, 84]' > "$answer" diff --git a/tasks/agg-p14-n08-s04/task.toml b/tasks/agg-p14-n08-s04/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..7f5592e86c0003010829345ffdaae03aba4489e9 --- /dev/null +++ b/tasks/agg-p14-n08-s04/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p14-n08-s04" +version = "0.1.0" +description = "s3-aggregation: 8 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 14 +agents = 8 +slot = 4 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p14-n08-s04/tests/expected.json b/tasks/agg-p14-n08-s04/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..ac0a63b220cabf1707ce425208fa8be7f0002727 --- /dev/null +++ b/tasks/agg-p14-n08-s04/tests/expected.json @@ -0,0 +1 @@ +[25, 29, 39, 44, 49, 53, 59, 84] diff --git a/tasks/agg-p14-n08-s04/tests/test.sh b/tasks/agg-p14-n08-s04/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p14-n08-s04/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p14-n08-s05/instruction.md b/tasks/agg-p14-n08-s05/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..fde113c01e4acfbeb8da7ffabf1e13aba553efcb --- /dev/null +++ b/tasks/agg-p14-n08-s05/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 8 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is forty-four. + +The team must find all 8 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 8 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p14-n08-s05/solution/solve.sh b/tasks/agg-p14-n08-s05/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..a76327afcdb4c6f9daf723ba49751ceb9a41fb72 --- /dev/null +++ b/tasks/agg-p14-n08-s05/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[25, 29, 39, 44, 49, 53, 59, 84]' > "$answer" diff --git a/tasks/agg-p14-n08-s05/task.toml b/tasks/agg-p14-n08-s05/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..4464c92673dda4319a8cc8c90f06b0370c16205e --- /dev/null +++ b/tasks/agg-p14-n08-s05/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p14-n08-s05" +version = "0.1.0" +description = "s3-aggregation: 8 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 14 +agents = 8 +slot = 5 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p14-n08-s05/tests/expected.json b/tasks/agg-p14-n08-s05/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..ac0a63b220cabf1707ce425208fa8be7f0002727 --- /dev/null +++ b/tasks/agg-p14-n08-s05/tests/expected.json @@ -0,0 +1 @@ +[25, 29, 39, 44, 49, 53, 59, 84] diff --git a/tasks/agg-p14-n08-s05/tests/test.sh b/tasks/agg-p14-n08-s05/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p14-n08-s05/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p14-n08-s06/instruction.md b/tasks/agg-p14-n08-s06/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..eee7a0b5f66fc3863f0f9be834031a101d16805b --- /dev/null +++ b/tasks/agg-p14-n08-s06/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 8 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is twenty-five. + +The team must find all 8 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 8 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p14-n08-s06/solution/solve.sh b/tasks/agg-p14-n08-s06/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..a76327afcdb4c6f9daf723ba49751ceb9a41fb72 --- /dev/null +++ b/tasks/agg-p14-n08-s06/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[25, 29, 39, 44, 49, 53, 59, 84]' > "$answer" diff --git a/tasks/agg-p14-n08-s06/task.toml b/tasks/agg-p14-n08-s06/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..d6f429cff3e4b26498d18d4720c0d3d702b90d93 --- /dev/null +++ b/tasks/agg-p14-n08-s06/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p14-n08-s06" +version = "0.1.0" +description = "s3-aggregation: 8 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 14 +agents = 8 +slot = 6 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p14-n08-s06/tests/expected.json b/tasks/agg-p14-n08-s06/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..ac0a63b220cabf1707ce425208fa8be7f0002727 --- /dev/null +++ b/tasks/agg-p14-n08-s06/tests/expected.json @@ -0,0 +1 @@ +[25, 29, 39, 44, 49, 53, 59, 84] diff --git a/tasks/agg-p14-n08-s06/tests/test.sh b/tasks/agg-p14-n08-s06/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p14-n08-s06/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p14-n08-s07/instruction.md b/tasks/agg-p14-n08-s07/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..b64a92e68353b9fc7a1f0fe39017de53c567f828 --- /dev/null +++ b/tasks/agg-p14-n08-s07/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 8 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is fifty-nine. + +The team must find all 8 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 8 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p14-n08-s07/solution/solve.sh b/tasks/agg-p14-n08-s07/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..a76327afcdb4c6f9daf723ba49751ceb9a41fb72 --- /dev/null +++ b/tasks/agg-p14-n08-s07/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[25, 29, 39, 44, 49, 53, 59, 84]' > "$answer" diff --git a/tasks/agg-p14-n08-s07/task.toml b/tasks/agg-p14-n08-s07/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..b0d1bbacff4b97a473d517b94e3996e28d704c38 --- /dev/null +++ b/tasks/agg-p14-n08-s07/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p14-n08-s07" +version = "0.1.0" +description = "s3-aggregation: 8 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 14 +agents = 8 +slot = 7 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p14-n08-s07/tests/expected.json b/tasks/agg-p14-n08-s07/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..ac0a63b220cabf1707ce425208fa8be7f0002727 --- /dev/null +++ b/tasks/agg-p14-n08-s07/tests/expected.json @@ -0,0 +1 @@ +[25, 29, 39, 44, 49, 53, 59, 84] diff --git a/tasks/agg-p14-n08-s07/tests/test.sh b/tasks/agg-p14-n08-s07/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p14-n08-s07/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p14-n08-s08/instruction.md b/tasks/agg-p14-n08-s08/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..f4e65040a18e282edb2a2adba3d140edc730a8fb --- /dev/null +++ b/tasks/agg-p14-n08-s08/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 8 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is thirty-nine. + +The team must find all 8 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 8 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p14-n08-s08/solution/solve.sh b/tasks/agg-p14-n08-s08/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..a76327afcdb4c6f9daf723ba49751ceb9a41fb72 --- /dev/null +++ b/tasks/agg-p14-n08-s08/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[25, 29, 39, 44, 49, 53, 59, 84]' > "$answer" diff --git a/tasks/agg-p14-n08-s08/task.toml b/tasks/agg-p14-n08-s08/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..5de0c973a064f22ea9305539a6f4d46710df7664 --- /dev/null +++ b/tasks/agg-p14-n08-s08/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p14-n08-s08" +version = "0.1.0" +description = "s3-aggregation: 8 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 14 +agents = 8 +slot = 8 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p14-n08-s08/tests/expected.json b/tasks/agg-p14-n08-s08/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..ac0a63b220cabf1707ce425208fa8be7f0002727 --- /dev/null +++ b/tasks/agg-p14-n08-s08/tests/expected.json @@ -0,0 +1 @@ +[25, 29, 39, 44, 49, 53, 59, 84] diff --git a/tasks/agg-p14-n08-s08/tests/test.sh b/tasks/agg-p14-n08-s08/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p14-n08-s08/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p14-n16-s01/instruction.md b/tasks/agg-p14-n16-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..7d5ca093d11da3b866f85566039dbc2ac3bc8c84 --- /dev/null +++ b/tasks/agg-p14-n16-s01/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is eighty-four. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p14-n16-s01/solution/solve.sh b/tasks/agg-p14-n16-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..98a627611415f096e99e3e53f9dfcd0135aabf4f --- /dev/null +++ b/tasks/agg-p14-n16-s01/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[1, 11, 25, 29, 37, 39, 44, 45, 49, 51, 53, 59, 72, 78, 84, 96]' > "$answer" diff --git a/tasks/agg-p14-n16-s01/task.toml b/tasks/agg-p14-n16-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..3ca6506c073d2ac9e09e18899e409a13ed53e624 --- /dev/null +++ b/tasks/agg-p14-n16-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p14-n16-s01" +version = "0.1.0" +description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 14 +agents = 16 +slot = 1 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p14-n16-s01/tests/expected.json b/tasks/agg-p14-n16-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..f4de4396491fe7e3a1c43778a2a0b54c548411af --- /dev/null +++ b/tasks/agg-p14-n16-s01/tests/expected.json @@ -0,0 +1 @@ +[1, 11, 25, 29, 37, 39, 44, 45, 49, 51, 53, 59, 72, 78, 84, 96] diff --git a/tasks/agg-p14-n16-s01/tests/test.sh b/tasks/agg-p14-n16-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p14-n16-s01/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p14-n16-s02/instruction.md b/tasks/agg-p14-n16-s02/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..4256e6220fcaf944c5b8d19997e2ebfa14df1a3a --- /dev/null +++ b/tasks/agg-p14-n16-s02/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is twenty-nine. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p14-n16-s02/solution/solve.sh b/tasks/agg-p14-n16-s02/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..98a627611415f096e99e3e53f9dfcd0135aabf4f --- /dev/null +++ b/tasks/agg-p14-n16-s02/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[1, 11, 25, 29, 37, 39, 44, 45, 49, 51, 53, 59, 72, 78, 84, 96]' > "$answer" diff --git a/tasks/agg-p14-n16-s02/task.toml b/tasks/agg-p14-n16-s02/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..a9a913214a41a731d39785d7f12e1213bc5c0163 --- /dev/null +++ b/tasks/agg-p14-n16-s02/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p14-n16-s02" +version = "0.1.0" +description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 14 +agents = 16 +slot = 2 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p14-n16-s02/tests/expected.json b/tasks/agg-p14-n16-s02/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..f4de4396491fe7e3a1c43778a2a0b54c548411af --- /dev/null +++ b/tasks/agg-p14-n16-s02/tests/expected.json @@ -0,0 +1 @@ +[1, 11, 25, 29, 37, 39, 44, 45, 49, 51, 53, 59, 72, 78, 84, 96] diff --git a/tasks/agg-p14-n16-s02/tests/test.sh b/tasks/agg-p14-n16-s02/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p14-n16-s02/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p14-n16-s03/instruction.md b/tasks/agg-p14-n16-s03/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..d019999eecd81b0d102088ffd8dc6702e314773f --- /dev/null +++ b/tasks/agg-p14-n16-s03/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is fifty-three. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p14-n16-s03/solution/solve.sh b/tasks/agg-p14-n16-s03/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..98a627611415f096e99e3e53f9dfcd0135aabf4f --- /dev/null +++ b/tasks/agg-p14-n16-s03/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[1, 11, 25, 29, 37, 39, 44, 45, 49, 51, 53, 59, 72, 78, 84, 96]' > "$answer" diff --git a/tasks/agg-p14-n16-s03/task.toml b/tasks/agg-p14-n16-s03/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..a5421f2a00a217ac23b44d9657600c69c248ffa8 --- /dev/null +++ b/tasks/agg-p14-n16-s03/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p14-n16-s03" +version = "0.1.0" +description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 14 +agents = 16 +slot = 3 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p14-n16-s03/tests/expected.json b/tasks/agg-p14-n16-s03/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..f4de4396491fe7e3a1c43778a2a0b54c548411af --- /dev/null +++ b/tasks/agg-p14-n16-s03/tests/expected.json @@ -0,0 +1 @@ +[1, 11, 25, 29, 37, 39, 44, 45, 49, 51, 53, 59, 72, 78, 84, 96] diff --git a/tasks/agg-p14-n16-s03/tests/test.sh b/tasks/agg-p14-n16-s03/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p14-n16-s03/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p14-n16-s04/instruction.md b/tasks/agg-p14-n16-s04/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..8e07e4d36fb62c2d2904ca839b34d4b0744c309f --- /dev/null +++ b/tasks/agg-p14-n16-s04/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is forty-nine. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p14-n16-s04/solution/solve.sh b/tasks/agg-p14-n16-s04/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..98a627611415f096e99e3e53f9dfcd0135aabf4f --- /dev/null +++ b/tasks/agg-p14-n16-s04/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[1, 11, 25, 29, 37, 39, 44, 45, 49, 51, 53, 59, 72, 78, 84, 96]' > "$answer" diff --git a/tasks/agg-p14-n16-s04/task.toml b/tasks/agg-p14-n16-s04/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..633db16b4a520b426c3c9e1e6a15f7621a56d9c5 --- /dev/null +++ b/tasks/agg-p14-n16-s04/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p14-n16-s04" +version = "0.1.0" +description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 14 +agents = 16 +slot = 4 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p14-n16-s04/tests/expected.json b/tasks/agg-p14-n16-s04/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..f4de4396491fe7e3a1c43778a2a0b54c548411af --- /dev/null +++ b/tasks/agg-p14-n16-s04/tests/expected.json @@ -0,0 +1 @@ +[1, 11, 25, 29, 37, 39, 44, 45, 49, 51, 53, 59, 72, 78, 84, 96] diff --git a/tasks/agg-p14-n16-s04/tests/test.sh b/tasks/agg-p14-n16-s04/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p14-n16-s04/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p14-n16-s05/instruction.md b/tasks/agg-p14-n16-s05/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..a31300409e75190524f2a237c2d0d6348715dc53 --- /dev/null +++ b/tasks/agg-p14-n16-s05/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is forty-four. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p14-n16-s05/solution/solve.sh b/tasks/agg-p14-n16-s05/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..98a627611415f096e99e3e53f9dfcd0135aabf4f --- /dev/null +++ b/tasks/agg-p14-n16-s05/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[1, 11, 25, 29, 37, 39, 44, 45, 49, 51, 53, 59, 72, 78, 84, 96]' > "$answer" diff --git a/tasks/agg-p14-n16-s05/task.toml b/tasks/agg-p14-n16-s05/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..829ea093b65779a715737235967fbc02f3e7639b --- /dev/null +++ b/tasks/agg-p14-n16-s05/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p14-n16-s05" +version = "0.1.0" +description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 14 +agents = 16 +slot = 5 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p14-n16-s05/tests/expected.json b/tasks/agg-p14-n16-s05/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..f4de4396491fe7e3a1c43778a2a0b54c548411af --- /dev/null +++ b/tasks/agg-p14-n16-s05/tests/expected.json @@ -0,0 +1 @@ +[1, 11, 25, 29, 37, 39, 44, 45, 49, 51, 53, 59, 72, 78, 84, 96] diff --git a/tasks/agg-p14-n16-s05/tests/test.sh b/tasks/agg-p14-n16-s05/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p14-n16-s05/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p14-n16-s06/instruction.md b/tasks/agg-p14-n16-s06/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..04c3f6729149d2802728807768786a453bb32941 --- /dev/null +++ b/tasks/agg-p14-n16-s06/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is twenty-five. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p14-n16-s06/solution/solve.sh b/tasks/agg-p14-n16-s06/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..98a627611415f096e99e3e53f9dfcd0135aabf4f --- /dev/null +++ b/tasks/agg-p14-n16-s06/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[1, 11, 25, 29, 37, 39, 44, 45, 49, 51, 53, 59, 72, 78, 84, 96]' > "$answer" diff --git a/tasks/agg-p14-n16-s06/task.toml b/tasks/agg-p14-n16-s06/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..aa1581375ea7df123604c8d5eaf098003263446e --- /dev/null +++ b/tasks/agg-p14-n16-s06/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p14-n16-s06" +version = "0.1.0" +description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 14 +agents = 16 +slot = 6 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p14-n16-s06/tests/expected.json b/tasks/agg-p14-n16-s06/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..f4de4396491fe7e3a1c43778a2a0b54c548411af --- /dev/null +++ b/tasks/agg-p14-n16-s06/tests/expected.json @@ -0,0 +1 @@ +[1, 11, 25, 29, 37, 39, 44, 45, 49, 51, 53, 59, 72, 78, 84, 96] diff --git a/tasks/agg-p14-n16-s06/tests/test.sh b/tasks/agg-p14-n16-s06/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p14-n16-s06/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p14-n16-s07/instruction.md b/tasks/agg-p14-n16-s07/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..955b43d84b811b75405d52e1370487f6c7c7cb98 --- /dev/null +++ b/tasks/agg-p14-n16-s07/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is fifty-nine. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p14-n16-s07/solution/solve.sh b/tasks/agg-p14-n16-s07/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..98a627611415f096e99e3e53f9dfcd0135aabf4f --- /dev/null +++ b/tasks/agg-p14-n16-s07/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[1, 11, 25, 29, 37, 39, 44, 45, 49, 51, 53, 59, 72, 78, 84, 96]' > "$answer" diff --git a/tasks/agg-p14-n16-s07/task.toml b/tasks/agg-p14-n16-s07/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..9a259721b003ab0def4b1b4d6afead1103aeeeab --- /dev/null +++ b/tasks/agg-p14-n16-s07/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p14-n16-s07" +version = "0.1.0" +description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 14 +agents = 16 +slot = 7 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p14-n16-s07/tests/expected.json b/tasks/agg-p14-n16-s07/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..f4de4396491fe7e3a1c43778a2a0b54c548411af --- /dev/null +++ b/tasks/agg-p14-n16-s07/tests/expected.json @@ -0,0 +1 @@ +[1, 11, 25, 29, 37, 39, 44, 45, 49, 51, 53, 59, 72, 78, 84, 96] diff --git a/tasks/agg-p14-n16-s07/tests/test.sh b/tasks/agg-p14-n16-s07/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p14-n16-s07/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p14-n16-s08/instruction.md b/tasks/agg-p14-n16-s08/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..d443699990b373083b3fdeb1d846a400fde6e65b --- /dev/null +++ b/tasks/agg-p14-n16-s08/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is thirty-nine. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p14-n16-s08/solution/solve.sh b/tasks/agg-p14-n16-s08/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..98a627611415f096e99e3e53f9dfcd0135aabf4f --- /dev/null +++ b/tasks/agg-p14-n16-s08/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[1, 11, 25, 29, 37, 39, 44, 45, 49, 51, 53, 59, 72, 78, 84, 96]' > "$answer" diff --git a/tasks/agg-p14-n16-s08/task.toml b/tasks/agg-p14-n16-s08/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..fbea9243e4878a6dc308886e22fb4f036c131053 --- /dev/null +++ b/tasks/agg-p14-n16-s08/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p14-n16-s08" +version = "0.1.0" +description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 14 +agents = 16 +slot = 8 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p14-n16-s08/tests/expected.json b/tasks/agg-p14-n16-s08/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..f4de4396491fe7e3a1c43778a2a0b54c548411af --- /dev/null +++ b/tasks/agg-p14-n16-s08/tests/expected.json @@ -0,0 +1 @@ +[1, 11, 25, 29, 37, 39, 44, 45, 49, 51, 53, 59, 72, 78, 84, 96] diff --git a/tasks/agg-p14-n16-s08/tests/test.sh b/tasks/agg-p14-n16-s08/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p14-n16-s08/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p14-n16-s09/instruction.md b/tasks/agg-p14-n16-s09/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..9e673d50df3d0049f8ebbc5f08e69f16f929b38f --- /dev/null +++ b/tasks/agg-p14-n16-s09/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is ninety-six. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p14-n16-s09/solution/solve.sh b/tasks/agg-p14-n16-s09/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..98a627611415f096e99e3e53f9dfcd0135aabf4f --- /dev/null +++ b/tasks/agg-p14-n16-s09/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[1, 11, 25, 29, 37, 39, 44, 45, 49, 51, 53, 59, 72, 78, 84, 96]' > "$answer" diff --git a/tasks/agg-p14-n16-s09/task.toml b/tasks/agg-p14-n16-s09/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..3d188993422b3133c4f1cc369b0c3dba738dfe03 --- /dev/null +++ b/tasks/agg-p14-n16-s09/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p14-n16-s09" +version = "0.1.0" +description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 14 +agents = 16 +slot = 9 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p14-n16-s09/tests/expected.json b/tasks/agg-p14-n16-s09/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..f4de4396491fe7e3a1c43778a2a0b54c548411af --- /dev/null +++ b/tasks/agg-p14-n16-s09/tests/expected.json @@ -0,0 +1 @@ +[1, 11, 25, 29, 37, 39, 44, 45, 49, 51, 53, 59, 72, 78, 84, 96] diff --git a/tasks/agg-p14-n16-s09/tests/test.sh b/tasks/agg-p14-n16-s09/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p14-n16-s09/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p14-n16-s10/instruction.md b/tasks/agg-p14-n16-s10/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..08f16c0341c376d61759335375d8e966ef70afb6 --- /dev/null +++ b/tasks/agg-p14-n16-s10/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is seventy-two. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p14-n16-s10/solution/solve.sh b/tasks/agg-p14-n16-s10/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..98a627611415f096e99e3e53f9dfcd0135aabf4f --- /dev/null +++ b/tasks/agg-p14-n16-s10/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[1, 11, 25, 29, 37, 39, 44, 45, 49, 51, 53, 59, 72, 78, 84, 96]' > "$answer" diff --git a/tasks/agg-p14-n16-s10/task.toml b/tasks/agg-p14-n16-s10/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..b1a82a348837d2e03f754d3e55ab6dc86c11573a --- /dev/null +++ b/tasks/agg-p14-n16-s10/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p14-n16-s10" +version = "0.1.0" +description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 14 +agents = 16 +slot = 10 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p14-n16-s10/tests/expected.json b/tasks/agg-p14-n16-s10/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..f4de4396491fe7e3a1c43778a2a0b54c548411af --- /dev/null +++ b/tasks/agg-p14-n16-s10/tests/expected.json @@ -0,0 +1 @@ +[1, 11, 25, 29, 37, 39, 44, 45, 49, 51, 53, 59, 72, 78, 84, 96] diff --git a/tasks/agg-p14-n16-s10/tests/test.sh b/tasks/agg-p14-n16-s10/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p14-n16-s10/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p14-n16-s11/instruction.md b/tasks/agg-p14-n16-s11/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..bd54876511397bdb80a3c3299556503e1fd15da5 --- /dev/null +++ b/tasks/agg-p14-n16-s11/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is seventy-eight. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p14-n16-s11/solution/solve.sh b/tasks/agg-p14-n16-s11/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..98a627611415f096e99e3e53f9dfcd0135aabf4f --- /dev/null +++ b/tasks/agg-p14-n16-s11/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[1, 11, 25, 29, 37, 39, 44, 45, 49, 51, 53, 59, 72, 78, 84, 96]' > "$answer" diff --git a/tasks/agg-p14-n16-s11/task.toml b/tasks/agg-p14-n16-s11/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..9667d8e1b55a633da615723f9be605428a93fb9b --- /dev/null +++ b/tasks/agg-p14-n16-s11/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p14-n16-s11" +version = "0.1.0" +description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 14 +agents = 16 +slot = 11 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p14-n16-s11/tests/expected.json b/tasks/agg-p14-n16-s11/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..f4de4396491fe7e3a1c43778a2a0b54c548411af --- /dev/null +++ b/tasks/agg-p14-n16-s11/tests/expected.json @@ -0,0 +1 @@ +[1, 11, 25, 29, 37, 39, 44, 45, 49, 51, 53, 59, 72, 78, 84, 96] diff --git a/tasks/agg-p14-n16-s11/tests/test.sh b/tasks/agg-p14-n16-s11/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p14-n16-s11/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p14-n16-s12/instruction.md b/tasks/agg-p14-n16-s12/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..1a86ea7323aad3c91f00b65904f038f7e58f852d --- /dev/null +++ b/tasks/agg-p14-n16-s12/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is one. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p14-n16-s12/solution/solve.sh b/tasks/agg-p14-n16-s12/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..98a627611415f096e99e3e53f9dfcd0135aabf4f --- /dev/null +++ b/tasks/agg-p14-n16-s12/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[1, 11, 25, 29, 37, 39, 44, 45, 49, 51, 53, 59, 72, 78, 84, 96]' > "$answer" diff --git a/tasks/agg-p14-n16-s12/task.toml b/tasks/agg-p14-n16-s12/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..7435337aba0f9e0b1a895e78d81f64a292739db2 --- /dev/null +++ b/tasks/agg-p14-n16-s12/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p14-n16-s12" +version = "0.1.0" +description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 14 +agents = 16 +slot = 12 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p14-n16-s12/tests/expected.json b/tasks/agg-p14-n16-s12/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..f4de4396491fe7e3a1c43778a2a0b54c548411af --- /dev/null +++ b/tasks/agg-p14-n16-s12/tests/expected.json @@ -0,0 +1 @@ +[1, 11, 25, 29, 37, 39, 44, 45, 49, 51, 53, 59, 72, 78, 84, 96] diff --git a/tasks/agg-p14-n16-s12/tests/test.sh b/tasks/agg-p14-n16-s12/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p14-n16-s12/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p14-n16-s13/instruction.md b/tasks/agg-p14-n16-s13/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..10bcc3d169e35738b1fb80abb7316f9cd7c1b230 --- /dev/null +++ b/tasks/agg-p14-n16-s13/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is thirty-seven. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p14-n16-s13/solution/solve.sh b/tasks/agg-p14-n16-s13/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..98a627611415f096e99e3e53f9dfcd0135aabf4f --- /dev/null +++ b/tasks/agg-p14-n16-s13/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[1, 11, 25, 29, 37, 39, 44, 45, 49, 51, 53, 59, 72, 78, 84, 96]' > "$answer" diff --git a/tasks/agg-p14-n16-s13/task.toml b/tasks/agg-p14-n16-s13/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..07b4e38fe23d875fa1a9fbb7592852ef5d530e54 --- /dev/null +++ b/tasks/agg-p14-n16-s13/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p14-n16-s13" +version = "0.1.0" +description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 14 +agents = 16 +slot = 13 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p14-n16-s13/tests/expected.json b/tasks/agg-p14-n16-s13/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..f4de4396491fe7e3a1c43778a2a0b54c548411af --- /dev/null +++ b/tasks/agg-p14-n16-s13/tests/expected.json @@ -0,0 +1 @@ +[1, 11, 25, 29, 37, 39, 44, 45, 49, 51, 53, 59, 72, 78, 84, 96] diff --git a/tasks/agg-p14-n16-s13/tests/test.sh b/tasks/agg-p14-n16-s13/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p14-n16-s13/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p14-n16-s14/instruction.md b/tasks/agg-p14-n16-s14/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..fb03ade0279ecf776a2ba0e785bd133ee36ecac6 --- /dev/null +++ b/tasks/agg-p14-n16-s14/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is fifty-one. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p14-n16-s14/solution/solve.sh b/tasks/agg-p14-n16-s14/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..98a627611415f096e99e3e53f9dfcd0135aabf4f --- /dev/null +++ b/tasks/agg-p14-n16-s14/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[1, 11, 25, 29, 37, 39, 44, 45, 49, 51, 53, 59, 72, 78, 84, 96]' > "$answer" diff --git a/tasks/agg-p14-n16-s14/task.toml b/tasks/agg-p14-n16-s14/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..69cef7df20b1d9c346e1fa361172206b6f47a81f --- /dev/null +++ b/tasks/agg-p14-n16-s14/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p14-n16-s14" +version = "0.1.0" +description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 14 +agents = 16 +slot = 14 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p14-n16-s14/tests/expected.json b/tasks/agg-p14-n16-s14/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..f4de4396491fe7e3a1c43778a2a0b54c548411af --- /dev/null +++ b/tasks/agg-p14-n16-s14/tests/expected.json @@ -0,0 +1 @@ +[1, 11, 25, 29, 37, 39, 44, 45, 49, 51, 53, 59, 72, 78, 84, 96] diff --git a/tasks/agg-p14-n16-s14/tests/test.sh b/tasks/agg-p14-n16-s14/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p14-n16-s14/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p14-n16-s15/instruction.md b/tasks/agg-p14-n16-s15/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..03acbc08880291cf4dacc5df318650e9c8d0e519 --- /dev/null +++ b/tasks/agg-p14-n16-s15/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is forty-five. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p14-n16-s15/solution/solve.sh b/tasks/agg-p14-n16-s15/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..98a627611415f096e99e3e53f9dfcd0135aabf4f --- /dev/null +++ b/tasks/agg-p14-n16-s15/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[1, 11, 25, 29, 37, 39, 44, 45, 49, 51, 53, 59, 72, 78, 84, 96]' > "$answer" diff --git a/tasks/agg-p14-n16-s15/task.toml b/tasks/agg-p14-n16-s15/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..7079bc93cdbebdeb7add809d22aaa95702eb647a --- /dev/null +++ b/tasks/agg-p14-n16-s15/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p14-n16-s15" +version = "0.1.0" +description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 14 +agents = 16 +slot = 15 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p14-n16-s15/tests/expected.json b/tasks/agg-p14-n16-s15/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..f4de4396491fe7e3a1c43778a2a0b54c548411af --- /dev/null +++ b/tasks/agg-p14-n16-s15/tests/expected.json @@ -0,0 +1 @@ +[1, 11, 25, 29, 37, 39, 44, 45, 49, 51, 53, 59, 72, 78, 84, 96] diff --git a/tasks/agg-p14-n16-s15/tests/test.sh b/tasks/agg-p14-n16-s15/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p14-n16-s15/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p14-n16-s16/instruction.md b/tasks/agg-p14-n16-s16/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..0f12c719492f216b9a3df72f8d724b2259725c6d --- /dev/null +++ b/tasks/agg-p14-n16-s16/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is eleven. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p14-n16-s16/solution/solve.sh b/tasks/agg-p14-n16-s16/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..98a627611415f096e99e3e53f9dfcd0135aabf4f --- /dev/null +++ b/tasks/agg-p14-n16-s16/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[1, 11, 25, 29, 37, 39, 44, 45, 49, 51, 53, 59, 72, 78, 84, 96]' > "$answer" diff --git a/tasks/agg-p14-n16-s16/task.toml b/tasks/agg-p14-n16-s16/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..b84878b5a29d813eeb6593b696bc722f75b040fe --- /dev/null +++ b/tasks/agg-p14-n16-s16/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p14-n16-s16" +version = "0.1.0" +description = "s3-aggregation: 16 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 14 +agents = 16 +slot = 16 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p14-n16-s16/tests/expected.json b/tasks/agg-p14-n16-s16/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..f4de4396491fe7e3a1c43778a2a0b54c548411af --- /dev/null +++ b/tasks/agg-p14-n16-s16/tests/expected.json @@ -0,0 +1 @@ +[1, 11, 25, 29, 37, 39, 44, 45, 49, 51, 53, 59, 72, 78, 84, 96] diff --git a/tasks/agg-p14-n16-s16/tests/test.sh b/tasks/agg-p14-n16-s16/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p14-n16-s16/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p15-n01-s01/instruction.md b/tasks/agg-p15-n01-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..8b183a410f6784b4c2401e33f3404029ba45b663 --- /dev/null +++ b/tasks/agg-p15-n01-s01/instruction.md @@ -0,0 +1,9 @@ +# Sort the team's private numbers + +You are the only agent on this team, solving a private-information number sorting task. You +hold one private integer from 1 to 99, written in English words. + +Your private number is thirty-seven. + +Write `/app/answer.json` (create `/app` if needed): a JSON array holding your number's numeric +value, as digits. Then stop. diff --git a/tasks/agg-p15-n01-s01/solution/solve.sh b/tasks/agg-p15-n01-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..bfe3d1ef5329e0da4b2d43d67091b654fef0fa82 --- /dev/null +++ b/tasks/agg-p15-n01-s01/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[37]' > "$answer" diff --git a/tasks/agg-p15-n01-s01/task.toml b/tasks/agg-p15-n01-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..fac106e7fdd3dda8c48ea1264e7113f1c695520f --- /dev/null +++ b/tasks/agg-p15-n01-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p15-n01-s01" +version = "0.1.0" +description = "s3-aggregation: 1 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 15 +agents = 1 +slot = 1 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p15-n01-s01/tests/expected.json b/tasks/agg-p15-n01-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..8d06bb649bc6fe44dc0b60e2c2eacfbe5154fc54 --- /dev/null +++ b/tasks/agg-p15-n01-s01/tests/expected.json @@ -0,0 +1 @@ +[37] diff --git a/tasks/agg-p15-n01-s01/tests/test.sh b/tasks/agg-p15-n01-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p15-n01-s01/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p15-n02-s01/instruction.md b/tasks/agg-p15-n02-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..a0f5d6312615f15532c609835c393db0d12fe574 --- /dev/null +++ b/tasks/agg-p15-n02-s01/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 2 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is thirty-seven. + +The team must find all 2 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 2 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p15-n02-s01/solution/solve.sh b/tasks/agg-p15-n02-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b22d9b0f9e00f926673b3f879dc5ad555869b718 --- /dev/null +++ b/tasks/agg-p15-n02-s01/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[29, 37]' > "$answer" diff --git a/tasks/agg-p15-n02-s01/task.toml b/tasks/agg-p15-n02-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..59ed2dd2329947a6ab02970e23338b8327a983fe --- /dev/null +++ b/tasks/agg-p15-n02-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p15-n02-s01" +version = "0.1.0" +description = "s3-aggregation: 2 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 15 +agents = 2 +slot = 1 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p15-n02-s01/tests/expected.json b/tasks/agg-p15-n02-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..d89d1330c3733ae9c9e6f9cb3aaf5d1f11225a0a --- /dev/null +++ b/tasks/agg-p15-n02-s01/tests/expected.json @@ -0,0 +1 @@ +[29, 37] diff --git a/tasks/agg-p15-n02-s01/tests/test.sh b/tasks/agg-p15-n02-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p15-n02-s01/tests/test.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Reward 1 if /app/answer.json is exactly expected.json: a JSON array of the team's integers in +# ascending order, one per agent (equal numbers kept). Anything else scores 0: a missing or +# unreadable file, invalid UTF-8 or JSON, NaN or Infinity, a non-array, strings, floats or +# booleans, a missing, extra or dropped duplicate number, and a wrong order. +# The answer counts only as a regular file of its own at exactly that path: a symlink (e.g. to +# /tests/expected.json, which arrives only now), a link anywhere on the path (a symlinked /app), +# a hardlink, a directory or a FIFO scores 0; expected.json is read the same way. Nothing here +# follows a link the agent may have left, and 0 is written before anything is checked, so a crash +# of the check also scores 0. A copy of the answer stays with the trial's results. +# Python runs isolated (-I -S): no module from the working directory, PYTHON* variables, the +# user's site or site-packages hooks (sitecustomize, usercustomize, .pth files) can replace what +# it imports. Besides bash, python3 is the only command this script runs (no dirname, mkdir or +# rm an agent could shadow on the PATH). ANSWER, EXPECTED and VERIFIER_DIR override the paths +# (no links in them), to test the grader locally. +case $0 in */*) here=${0%/*} ;; *) here=. ;; esac +export ANSWER=${ANSWER:-/app/answer.json} +export EXPECTED=${EXPECTED:-$here/expected.json} +export VERIFIER_DIR=${VERIFIER_DIR:-/logs/verifier} +[ -d "$VERIFIER_DIR" ] && echo 0 > "$VERIFIER_DIR/reward.txt" +python3 -I -S - <<'PY' || true +import json +import os +import stat + +LIMIT = 1 << 20 # bytes + + +def read_own(path): + # The bytes of the regular file at exactly `path`: every folder on the way is opened + # without following a link, and so is the file (a FIFO cannot block it); one link only. + parts = os.path.abspath(path).split("/")[1:] + folder = os.open("/", os.O_RDONLY | os.O_DIRECTORY) + try: + for part in parts[:-1]: + inner = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=folder) + os.close(folder) + folder = inner + fd = os.open(parts[-1], os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=folder) + finally: + os.close(folder) + with os.fdopen(fd, "rb") as stream: + info = os.fstat(stream.fileno()) + if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1: + raise ValueError("not a regular file of its own") + data = stream.read(LIMIT + 1) + if len(data) > LIMIT: + raise ValueError("too large") + return data + + +def write_new(path, text): + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644) + with os.fdopen(fd, "w") as stream: + stream.write(text) + + +def reject_constant(name): + raise ValueError(f"{name} is not JSON") + + +def parse(data): + return json.loads(data.decode("utf-8"), parse_constant=reject_constant) + + +verifier = os.environ["VERIFIER_DIR"] +os.makedirs(verifier, exist_ok=True) +for name in ("reward.txt", "reward.json", "answer.json"): # never written through a link + try: + os.unlink(os.path.join(verifier, name)) + except FileNotFoundError: + pass +write_new(os.path.join(verifier, "reward.txt"), "0") +valid = False +try: + data = read_own(os.environ["ANSWER"]) + write_new(os.path.join(verifier, "answer.json"), data.decode("utf-8", "replace")) + answer, expected = parse(data), parse(read_own(os.environ["EXPECTED"])) + valid = ( + isinstance(answer, list) + and all(type(x) is int for x in answer) # not bool, float or str + and answer == expected + ) +except Exception: # missing, a link, not regular, invalid UTF-8 or JSON, NaN, RecursionError + valid = False +if valid: + write_new(os.path.join(verifier, "reward.txt"), "1") +print("reward:", 1 if valid else 0) +PY diff --git a/tasks/agg-p15-n02-s02/instruction.md b/tasks/agg-p15-n02-s02/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..e621302d95daf78f55f398b62ae6ecdb5f7e28d9 --- /dev/null +++ b/tasks/agg-p15-n02-s02/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 2 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is twenty-nine. + +The team must find all 2 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 2 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p15-n02-s02/solution/solve.sh b/tasks/agg-p15-n02-s02/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b22d9b0f9e00f926673b3f879dc5ad555869b718 --- /dev/null +++ b/tasks/agg-p15-n02-s02/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[29, 37]' > "$answer" diff --git a/tasks/agg-p15-n02-s02/task.toml b/tasks/agg-p15-n02-s02/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..3ce13e11f24537c9f387f06ca81cea2073f7a632 --- /dev/null +++ b/tasks/agg-p15-n02-s02/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p15-n02-s02" +version = "0.1.0" +description = "s3-aggregation: 2 agents each hold a private number; the team lists them all in ascending order." +keywords = ["multi-agent", "message-board", "s3", "aggregation"] + +[metadata] +problem = 15 +agents = 2 +slot = 2 +seed = 115 + +[agent] +timeout_sec = 1800 + +[environment] +# Prebuilt and public, with no Dockerfile: HF Sandboxes need one, and docker and podman use it +# too. Nothing task-specific is in the container: the slot's number is only in its instruction, +# and tests/ arrive only when the agent is done. +docker_image = "python:3.12-slim" +cpus = 1 +memory_mb = 1024 + +[verifier] +timeout_sec = 60 diff --git a/tasks/agg-p15-n02-s02/tests/expected.json b/tasks/agg-p15-n02-s02/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..d89d1330c3733ae9c9e6f9cb3aaf5d1f11225a0a --- /dev/null +++ b/tasks/agg-p15-n02-s02/tests/expected.json @@ -0,0 +1 @@ +[29, 37]