diff --git a/tasks/agg-p07-n08-s04/tests/test.sh b/tasks/agg-p07-n08-s04/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p07-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-p07-n08-s05/instruction.md b/tasks/agg-p07-n08-s05/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..ee602d2ed51f86295f1f477b0dc17b27fbe00ab3 --- /dev/null +++ b/tasks/agg-p07-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 fifty-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-p07-n08-s05/solution/solve.sh b/tasks/agg-p07-n08-s05/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..d953957e592079c0c30fd41761129482f595eb0a --- /dev/null +++ b/tasks/agg-p07-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 '[8, 22, 36, 38, 48, 49, 54, 88]' > "$answer" diff --git a/tasks/agg-p07-n08-s05/task.toml b/tasks/agg-p07-n08-s05/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..01a72af082db640d704a596c67e360e0f11b538a --- /dev/null +++ b/tasks/agg-p07-n08-s05/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p07-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 = 7 +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-p07-n08-s05/tests/expected.json b/tasks/agg-p07-n08-s05/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..61115a38af63f370bc83061ba9162c50108c9ecc --- /dev/null +++ b/tasks/agg-p07-n08-s05/tests/expected.json @@ -0,0 +1 @@ +[8, 22, 36, 38, 48, 49, 54, 88] diff --git a/tasks/agg-p07-n08-s05/tests/test.sh b/tasks/agg-p07-n08-s05/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p07-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-p07-n08-s06/instruction.md b/tasks/agg-p07-n08-s06/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..8e1b9f225dd41eb13af45ff90735dba5c7d221b8 --- /dev/null +++ b/tasks/agg-p07-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-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-p07-n08-s06/solution/solve.sh b/tasks/agg-p07-n08-s06/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..d953957e592079c0c30fd41761129482f595eb0a --- /dev/null +++ b/tasks/agg-p07-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 '[8, 22, 36, 38, 48, 49, 54, 88]' > "$answer" diff --git a/tasks/agg-p07-n08-s06/task.toml b/tasks/agg-p07-n08-s06/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..0968a51ecde217d887181ff6ca5262b8db04e6e4 --- /dev/null +++ b/tasks/agg-p07-n08-s06/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p07-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 = 7 +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-p07-n08-s06/tests/expected.json b/tasks/agg-p07-n08-s06/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..61115a38af63f370bc83061ba9162c50108c9ecc --- /dev/null +++ b/tasks/agg-p07-n08-s06/tests/expected.json @@ -0,0 +1 @@ +[8, 22, 36, 38, 48, 49, 54, 88] diff --git a/tasks/agg-p07-n08-s06/tests/test.sh b/tasks/agg-p07-n08-s06/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p07-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-p07-n08-s07/instruction.md b/tasks/agg-p07-n08-s07/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..8fc5da9fd3f2fb4b928fc1ff5a73236e0d218b54 --- /dev/null +++ b/tasks/agg-p07-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 eighty-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-p07-n08-s07/solution/solve.sh b/tasks/agg-p07-n08-s07/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..d953957e592079c0c30fd41761129482f595eb0a --- /dev/null +++ b/tasks/agg-p07-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 '[8, 22, 36, 38, 48, 49, 54, 88]' > "$answer" diff --git a/tasks/agg-p07-n08-s07/task.toml b/tasks/agg-p07-n08-s07/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..8dab4ff0a7c8a035abe8df10deeebedfbc1d1e0e --- /dev/null +++ b/tasks/agg-p07-n08-s07/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p07-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 = 7 +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-p07-n08-s07/tests/expected.json b/tasks/agg-p07-n08-s07/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..61115a38af63f370bc83061ba9162c50108c9ecc --- /dev/null +++ b/tasks/agg-p07-n08-s07/tests/expected.json @@ -0,0 +1 @@ +[8, 22, 36, 38, 48, 49, 54, 88] diff --git a/tasks/agg-p07-n08-s07/tests/test.sh b/tasks/agg-p07-n08-s07/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p07-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-p07-n08-s08/instruction.md b/tasks/agg-p07-n08-s08/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..fb9a5a5e841fd2441b11cbee99000a82617ba549 --- /dev/null +++ b/tasks/agg-p07-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 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-p07-n08-s08/solution/solve.sh b/tasks/agg-p07-n08-s08/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..d953957e592079c0c30fd41761129482f595eb0a --- /dev/null +++ b/tasks/agg-p07-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 '[8, 22, 36, 38, 48, 49, 54, 88]' > "$answer" diff --git a/tasks/agg-p07-n08-s08/task.toml b/tasks/agg-p07-n08-s08/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..424476aed6c78a8daa6d63a1575d51e54dbbd8e4 --- /dev/null +++ b/tasks/agg-p07-n08-s08/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p07-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 = 7 +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-p07-n08-s08/tests/expected.json b/tasks/agg-p07-n08-s08/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..61115a38af63f370bc83061ba9162c50108c9ecc --- /dev/null +++ b/tasks/agg-p07-n08-s08/tests/expected.json @@ -0,0 +1 @@ +[8, 22, 36, 38, 48, 49, 54, 88] diff --git a/tasks/agg-p07-n08-s08/tests/test.sh b/tasks/agg-p07-n08-s08/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p07-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-p07-n16-s01/instruction.md b/tasks/agg-p07-n16-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..8e07e4d36fb62c2d2904ca839b34d4b0744c309f --- /dev/null +++ b/tasks/agg-p07-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-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-p07-n16-s01/solution/solve.sh b/tasks/agg-p07-n16-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..bbc6ec3434080deae9d66ccdaf57b0497df668b4 --- /dev/null +++ b/tasks/agg-p07-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, 8, 9, 16, 22, 25, 36, 38, 42, 48, 49, 54, 66, 78, 86, 88]' > "$answer" diff --git a/tasks/agg-p07-n16-s01/task.toml b/tasks/agg-p07-n16-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..495ab59b9f63b38d657979f0f1bd61b5e89f79c2 --- /dev/null +++ b/tasks/agg-p07-n16-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p07-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 = 7 +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-p07-n16-s01/tests/expected.json b/tasks/agg-p07-n16-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..6d9a379feacf87b3e56dd889dd35e756431350e6 --- /dev/null +++ b/tasks/agg-p07-n16-s01/tests/expected.json @@ -0,0 +1 @@ +[2, 8, 9, 16, 22, 25, 36, 38, 42, 48, 49, 54, 66, 78, 86, 88] diff --git a/tasks/agg-p07-n16-s01/tests/test.sh b/tasks/agg-p07-n16-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p07-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-p07-n16-s02/instruction.md b/tasks/agg-p07-n16-s02/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..552ad7b188277feadeb521fd17ec24a6f1f8f5ae --- /dev/null +++ b/tasks/agg-p07-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 thirty-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-p07-n16-s02/solution/solve.sh b/tasks/agg-p07-n16-s02/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..bbc6ec3434080deae9d66ccdaf57b0497df668b4 --- /dev/null +++ b/tasks/agg-p07-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, 8, 9, 16, 22, 25, 36, 38, 42, 48, 49, 54, 66, 78, 86, 88]' > "$answer" diff --git a/tasks/agg-p07-n16-s02/task.toml b/tasks/agg-p07-n16-s02/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..1d2cb3ab36dceef6bfb1538322d5794aa0ba7205 --- /dev/null +++ b/tasks/agg-p07-n16-s02/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p07-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 = 7 +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-p07-n16-s02/tests/expected.json b/tasks/agg-p07-n16-s02/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..6d9a379feacf87b3e56dd889dd35e756431350e6 --- /dev/null +++ b/tasks/agg-p07-n16-s02/tests/expected.json @@ -0,0 +1 @@ +[2, 8, 9, 16, 22, 25, 36, 38, 42, 48, 49, 54, 66, 78, 86, 88] diff --git a/tasks/agg-p07-n16-s02/tests/test.sh b/tasks/agg-p07-n16-s02/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p07-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-p07-n16-s03/instruction.md b/tasks/agg-p07-n16-s03/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..d398ea97722601a49a457530f502678c0a1433cf --- /dev/null +++ b/tasks/agg-p07-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 thirty-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-p07-n16-s03/solution/solve.sh b/tasks/agg-p07-n16-s03/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..bbc6ec3434080deae9d66ccdaf57b0497df668b4 --- /dev/null +++ b/tasks/agg-p07-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, 8, 9, 16, 22, 25, 36, 38, 42, 48, 49, 54, 66, 78, 86, 88]' > "$answer" diff --git a/tasks/agg-p07-n16-s03/task.toml b/tasks/agg-p07-n16-s03/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..7db3a235a24d50ba41f0693bb2b45cd842fcc04d --- /dev/null +++ b/tasks/agg-p07-n16-s03/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p07-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 = 7 +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-p07-n16-s03/tests/expected.json b/tasks/agg-p07-n16-s03/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..6d9a379feacf87b3e56dd889dd35e756431350e6 --- /dev/null +++ b/tasks/agg-p07-n16-s03/tests/expected.json @@ -0,0 +1 @@ +[2, 8, 9, 16, 22, 25, 36, 38, 42, 48, 49, 54, 66, 78, 86, 88] diff --git a/tasks/agg-p07-n16-s03/tests/test.sh b/tasks/agg-p07-n16-s03/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p07-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-p07-n16-s04/instruction.md b/tasks/agg-p07-n16-s04/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..38e83aee5771fa00d5091767999e55e04acb180b --- /dev/null +++ b/tasks/agg-p07-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-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-p07-n16-s04/solution/solve.sh b/tasks/agg-p07-n16-s04/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..bbc6ec3434080deae9d66ccdaf57b0497df668b4 --- /dev/null +++ b/tasks/agg-p07-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, 8, 9, 16, 22, 25, 36, 38, 42, 48, 49, 54, 66, 78, 86, 88]' > "$answer" diff --git a/tasks/agg-p07-n16-s04/task.toml b/tasks/agg-p07-n16-s04/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..9aa753251f9060df88960faeb1ff3966230769fa --- /dev/null +++ b/tasks/agg-p07-n16-s04/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p07-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 = 7 +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-p07-n16-s04/tests/expected.json b/tasks/agg-p07-n16-s04/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..6d9a379feacf87b3e56dd889dd35e756431350e6 --- /dev/null +++ b/tasks/agg-p07-n16-s04/tests/expected.json @@ -0,0 +1 @@ +[2, 8, 9, 16, 22, 25, 36, 38, 42, 48, 49, 54, 66, 78, 86, 88] diff --git a/tasks/agg-p07-n16-s04/tests/test.sh b/tasks/agg-p07-n16-s04/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p07-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-p07-n16-s05/instruction.md b/tasks/agg-p07-n16-s05/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..a1e1d14ddbf968be7e060dd9f860572ccdbd16d1 --- /dev/null +++ b/tasks/agg-p07-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 fifty-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-p07-n16-s05/solution/solve.sh b/tasks/agg-p07-n16-s05/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..bbc6ec3434080deae9d66ccdaf57b0497df668b4 --- /dev/null +++ b/tasks/agg-p07-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, 8, 9, 16, 22, 25, 36, 38, 42, 48, 49, 54, 66, 78, 86, 88]' > "$answer" diff --git a/tasks/agg-p07-n16-s05/task.toml b/tasks/agg-p07-n16-s05/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..7122b32c6f7345ec55d8a1624c51dfb64e72531b --- /dev/null +++ b/tasks/agg-p07-n16-s05/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p07-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 = 7 +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-p07-n16-s05/tests/expected.json b/tasks/agg-p07-n16-s05/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..6d9a379feacf87b3e56dd889dd35e756431350e6 --- /dev/null +++ b/tasks/agg-p07-n16-s05/tests/expected.json @@ -0,0 +1 @@ +[2, 8, 9, 16, 22, 25, 36, 38, 42, 48, 49, 54, 66, 78, 86, 88] diff --git a/tasks/agg-p07-n16-s05/tests/test.sh b/tasks/agg-p07-n16-s05/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p07-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-p07-n16-s06/instruction.md b/tasks/agg-p07-n16-s06/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..ac5d07700d94f2ac8dcfe94fa7b7a0669218f24c --- /dev/null +++ b/tasks/agg-p07-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-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-p07-n16-s06/solution/solve.sh b/tasks/agg-p07-n16-s06/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..bbc6ec3434080deae9d66ccdaf57b0497df668b4 --- /dev/null +++ b/tasks/agg-p07-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, 8, 9, 16, 22, 25, 36, 38, 42, 48, 49, 54, 66, 78, 86, 88]' > "$answer" diff --git a/tasks/agg-p07-n16-s06/task.toml b/tasks/agg-p07-n16-s06/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..c099e63131c2d514a868d793a6ee0e5b9f5295dc --- /dev/null +++ b/tasks/agg-p07-n16-s06/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p07-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 = 7 +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-p07-n16-s06/tests/expected.json b/tasks/agg-p07-n16-s06/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..6d9a379feacf87b3e56dd889dd35e756431350e6 --- /dev/null +++ b/tasks/agg-p07-n16-s06/tests/expected.json @@ -0,0 +1 @@ +[2, 8, 9, 16, 22, 25, 36, 38, 42, 48, 49, 54, 66, 78, 86, 88] diff --git a/tasks/agg-p07-n16-s06/tests/test.sh b/tasks/agg-p07-n16-s06/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p07-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-p07-n16-s07/instruction.md b/tasks/agg-p07-n16-s07/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..f197f79da6e4638891b46f2053909c167ec13c32 --- /dev/null +++ b/tasks/agg-p07-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 eighty-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-p07-n16-s07/solution/solve.sh b/tasks/agg-p07-n16-s07/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..bbc6ec3434080deae9d66ccdaf57b0497df668b4 --- /dev/null +++ b/tasks/agg-p07-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, 8, 9, 16, 22, 25, 36, 38, 42, 48, 49, 54, 66, 78, 86, 88]' > "$answer" diff --git a/tasks/agg-p07-n16-s07/task.toml b/tasks/agg-p07-n16-s07/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..b4bb047fe50c1be4f5b288e2d067308aacb61308 --- /dev/null +++ b/tasks/agg-p07-n16-s07/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p07-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 = 7 +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-p07-n16-s07/tests/expected.json b/tasks/agg-p07-n16-s07/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..6d9a379feacf87b3e56dd889dd35e756431350e6 --- /dev/null +++ b/tasks/agg-p07-n16-s07/tests/expected.json @@ -0,0 +1 @@ +[2, 8, 9, 16, 22, 25, 36, 38, 42, 48, 49, 54, 66, 78, 86, 88] diff --git a/tasks/agg-p07-n16-s07/tests/test.sh b/tasks/agg-p07-n16-s07/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p07-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-p07-n16-s08/instruction.md b/tasks/agg-p07-n16-s08/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..99a7f97eb2774bf91fcf02fc9e18c71f2c746d9d --- /dev/null +++ b/tasks/agg-p07-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 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-p07-n16-s08/solution/solve.sh b/tasks/agg-p07-n16-s08/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..bbc6ec3434080deae9d66ccdaf57b0497df668b4 --- /dev/null +++ b/tasks/agg-p07-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, 8, 9, 16, 22, 25, 36, 38, 42, 48, 49, 54, 66, 78, 86, 88]' > "$answer" diff --git a/tasks/agg-p07-n16-s08/task.toml b/tasks/agg-p07-n16-s08/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..7063b69547060cd1b4ab994e9920429435dc7cf3 --- /dev/null +++ b/tasks/agg-p07-n16-s08/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p07-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 = 7 +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-p07-n16-s08/tests/expected.json b/tasks/agg-p07-n16-s08/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..6d9a379feacf87b3e56dd889dd35e756431350e6 --- /dev/null +++ b/tasks/agg-p07-n16-s08/tests/expected.json @@ -0,0 +1 @@ +[2, 8, 9, 16, 22, 25, 36, 38, 42, 48, 49, 54, 66, 78, 86, 88] diff --git a/tasks/agg-p07-n16-s08/tests/test.sh b/tasks/agg-p07-n16-s08/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p07-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-p07-n16-s09/instruction.md b/tasks/agg-p07-n16-s09/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..bec568d59f85e2e30c1eb04f810b7ec136113a04 --- /dev/null +++ b/tasks/agg-p07-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 sixty-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-p07-n16-s09/solution/solve.sh b/tasks/agg-p07-n16-s09/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..bbc6ec3434080deae9d66ccdaf57b0497df668b4 --- /dev/null +++ b/tasks/agg-p07-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, 8, 9, 16, 22, 25, 36, 38, 42, 48, 49, 54, 66, 78, 86, 88]' > "$answer" diff --git a/tasks/agg-p07-n16-s09/task.toml b/tasks/agg-p07-n16-s09/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..60119ae0d6cacc1224ae8288ec064049a114a218 --- /dev/null +++ b/tasks/agg-p07-n16-s09/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p07-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 = 7 +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-p07-n16-s09/tests/expected.json b/tasks/agg-p07-n16-s09/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..6d9a379feacf87b3e56dd889dd35e756431350e6 --- /dev/null +++ b/tasks/agg-p07-n16-s09/tests/expected.json @@ -0,0 +1 @@ +[2, 8, 9, 16, 22, 25, 36, 38, 42, 48, 49, 54, 66, 78, 86, 88] diff --git a/tasks/agg-p07-n16-s09/tests/test.sh b/tasks/agg-p07-n16-s09/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p07-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-p07-n16-s10/instruction.md b/tasks/agg-p07-n16-s10/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..04c3f6729149d2802728807768786a453bb32941 --- /dev/null +++ b/tasks/agg-p07-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 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-p07-n16-s10/solution/solve.sh b/tasks/agg-p07-n16-s10/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..bbc6ec3434080deae9d66ccdaf57b0497df668b4 --- /dev/null +++ b/tasks/agg-p07-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, 8, 9, 16, 22, 25, 36, 38, 42, 48, 49, 54, 66, 78, 86, 88]' > "$answer" diff --git a/tasks/agg-p07-n16-s10/task.toml b/tasks/agg-p07-n16-s10/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..8a6262aa6ed595d861e65547ed72ed782efc6108 --- /dev/null +++ b/tasks/agg-p07-n16-s10/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p07-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 = 7 +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-p07-n16-s10/tests/expected.json b/tasks/agg-p07-n16-s10/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..6d9a379feacf87b3e56dd889dd35e756431350e6 --- /dev/null +++ b/tasks/agg-p07-n16-s10/tests/expected.json @@ -0,0 +1 @@ +[2, 8, 9, 16, 22, 25, 36, 38, 42, 48, 49, 54, 66, 78, 86, 88] diff --git a/tasks/agg-p07-n16-s10/tests/test.sh b/tasks/agg-p07-n16-s10/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p07-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-p07-n16-s11/instruction.md b/tasks/agg-p07-n16-s11/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..8e668cd99b85cf802939dffe8e766b769fcc702e --- /dev/null +++ b/tasks/agg-p07-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 sixteen. + +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-p07-n16-s11/solution/solve.sh b/tasks/agg-p07-n16-s11/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..bbc6ec3434080deae9d66ccdaf57b0497df668b4 --- /dev/null +++ b/tasks/agg-p07-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, 8, 9, 16, 22, 25, 36, 38, 42, 48, 49, 54, 66, 78, 86, 88]' > "$answer" diff --git a/tasks/agg-p07-n16-s11/task.toml b/tasks/agg-p07-n16-s11/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..a1f0e9956b5e72f599990ad88c07ecae37fceb60 --- /dev/null +++ b/tasks/agg-p07-n16-s11/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p07-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 = 7 +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-p07-n16-s11/tests/expected.json b/tasks/agg-p07-n16-s11/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..6d9a379feacf87b3e56dd889dd35e756431350e6 --- /dev/null +++ b/tasks/agg-p07-n16-s11/tests/expected.json @@ -0,0 +1 @@ +[2, 8, 9, 16, 22, 25, 36, 38, 42, 48, 49, 54, 66, 78, 86, 88] diff --git a/tasks/agg-p07-n16-s11/tests/test.sh b/tasks/agg-p07-n16-s11/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p07-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-p07-n16-s12/instruction.md b/tasks/agg-p07-n16-s12/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..bd54876511397bdb80a3c3299556503e1fd15da5 --- /dev/null +++ b/tasks/agg-p07-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 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-p07-n16-s12/solution/solve.sh b/tasks/agg-p07-n16-s12/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..bbc6ec3434080deae9d66ccdaf57b0497df668b4 --- /dev/null +++ b/tasks/agg-p07-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, 8, 9, 16, 22, 25, 36, 38, 42, 48, 49, 54, 66, 78, 86, 88]' > "$answer" diff --git a/tasks/agg-p07-n16-s12/task.toml b/tasks/agg-p07-n16-s12/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..2932e1f8f39df32edd3bbfd66fd9c9e44183172e --- /dev/null +++ b/tasks/agg-p07-n16-s12/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p07-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 = 7 +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-p07-n16-s12/tests/expected.json b/tasks/agg-p07-n16-s12/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..6d9a379feacf87b3e56dd889dd35e756431350e6 --- /dev/null +++ b/tasks/agg-p07-n16-s12/tests/expected.json @@ -0,0 +1 @@ +[2, 8, 9, 16, 22, 25, 36, 38, 42, 48, 49, 54, 66, 78, 86, 88] diff --git a/tasks/agg-p07-n16-s12/tests/test.sh b/tasks/agg-p07-n16-s12/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p07-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-p07-n16-s13/instruction.md b/tasks/agg-p07-n16-s13/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..19d65d896f0e0b5ac5235a050fd89f11a849ba13 --- /dev/null +++ b/tasks/agg-p07-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 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-p07-n16-s13/solution/solve.sh b/tasks/agg-p07-n16-s13/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..bbc6ec3434080deae9d66ccdaf57b0497df668b4 --- /dev/null +++ b/tasks/agg-p07-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, 8, 9, 16, 22, 25, 36, 38, 42, 48, 49, 54, 66, 78, 86, 88]' > "$answer" diff --git a/tasks/agg-p07-n16-s13/task.toml b/tasks/agg-p07-n16-s13/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..b0d7cc97759f755f26c540248937cfc0c7d7bfa9 --- /dev/null +++ b/tasks/agg-p07-n16-s13/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p07-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 = 7 +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-p07-n16-s13/tests/expected.json b/tasks/agg-p07-n16-s13/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..6d9a379feacf87b3e56dd889dd35e756431350e6 --- /dev/null +++ b/tasks/agg-p07-n16-s13/tests/expected.json @@ -0,0 +1 @@ +[2, 8, 9, 16, 22, 25, 36, 38, 42, 48, 49, 54, 66, 78, 86, 88] diff --git a/tasks/agg-p07-n16-s13/tests/test.sh b/tasks/agg-p07-n16-s13/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p07-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-p07-n16-s14/instruction.md b/tasks/agg-p07-n16-s14/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..756b66e7e1661b13390451604d8a217c6028d32d --- /dev/null +++ b/tasks/agg-p07-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 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-p07-n16-s14/solution/solve.sh b/tasks/agg-p07-n16-s14/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..bbc6ec3434080deae9d66ccdaf57b0497df668b4 --- /dev/null +++ b/tasks/agg-p07-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, 8, 9, 16, 22, 25, 36, 38, 42, 48, 49, 54, 66, 78, 86, 88]' > "$answer" diff --git a/tasks/agg-p07-n16-s14/task.toml b/tasks/agg-p07-n16-s14/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..7efa5dd9b8d9fdccfc7bd48bfbccbe4013426cb7 --- /dev/null +++ b/tasks/agg-p07-n16-s14/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p07-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 = 7 +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-p07-n16-s14/tests/expected.json b/tasks/agg-p07-n16-s14/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..6d9a379feacf87b3e56dd889dd35e756431350e6 --- /dev/null +++ b/tasks/agg-p07-n16-s14/tests/expected.json @@ -0,0 +1 @@ +[2, 8, 9, 16, 22, 25, 36, 38, 42, 48, 49, 54, 66, 78, 86, 88] diff --git a/tasks/agg-p07-n16-s14/tests/test.sh b/tasks/agg-p07-n16-s14/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p07-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-p07-n16-s15/instruction.md b/tasks/agg-p07-n16-s15/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..07c9e57a88a9821b15aef8e576670581ef52b8cf --- /dev/null +++ b/tasks/agg-p07-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 eighty-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-p07-n16-s15/solution/solve.sh b/tasks/agg-p07-n16-s15/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..bbc6ec3434080deae9d66ccdaf57b0497df668b4 --- /dev/null +++ b/tasks/agg-p07-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, 8, 9, 16, 22, 25, 36, 38, 42, 48, 49, 54, 66, 78, 86, 88]' > "$answer" diff --git a/tasks/agg-p07-n16-s15/task.toml b/tasks/agg-p07-n16-s15/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..c125a7d015f24c42726b202ecfdac85b621f94e8 --- /dev/null +++ b/tasks/agg-p07-n16-s15/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p07-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 = 7 +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-p07-n16-s15/tests/expected.json b/tasks/agg-p07-n16-s15/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..6d9a379feacf87b3e56dd889dd35e756431350e6 --- /dev/null +++ b/tasks/agg-p07-n16-s15/tests/expected.json @@ -0,0 +1 @@ +[2, 8, 9, 16, 22, 25, 36, 38, 42, 48, 49, 54, 66, 78, 86, 88] diff --git a/tasks/agg-p07-n16-s15/tests/test.sh b/tasks/agg-p07-n16-s15/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p07-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-p07-n16-s16/instruction.md b/tasks/agg-p07-n16-s16/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..ebbf18dd1885eca56e4b99d9ba0f301603987c59 --- /dev/null +++ b/tasks/agg-p07-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 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-p07-n16-s16/solution/solve.sh b/tasks/agg-p07-n16-s16/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..bbc6ec3434080deae9d66ccdaf57b0497df668b4 --- /dev/null +++ b/tasks/agg-p07-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, 8, 9, 16, 22, 25, 36, 38, 42, 48, 49, 54, 66, 78, 86, 88]' > "$answer" diff --git a/tasks/agg-p07-n16-s16/task.toml b/tasks/agg-p07-n16-s16/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..106163aa3d9a51b9e3d38d0107c91c89cbf47663 --- /dev/null +++ b/tasks/agg-p07-n16-s16/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p07-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 = 7 +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-p07-n16-s16/tests/expected.json b/tasks/agg-p07-n16-s16/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..6d9a379feacf87b3e56dd889dd35e756431350e6 --- /dev/null +++ b/tasks/agg-p07-n16-s16/tests/expected.json @@ -0,0 +1 @@ +[2, 8, 9, 16, 22, 25, 36, 38, 42, 48, 49, 54, 66, 78, 86, 88] diff --git a/tasks/agg-p07-n16-s16/tests/test.sh b/tasks/agg-p07-n16-s16/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p07-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-p08-n01-s01/instruction.md b/tasks/agg-p08-n01-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..8b183a410f6784b4c2401e33f3404029ba45b663 --- /dev/null +++ b/tasks/agg-p08-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-p08-n01-s01/solution/solve.sh b/tasks/agg-p08-n01-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..bfe3d1ef5329e0da4b2d43d67091b654fef0fa82 --- /dev/null +++ b/tasks/agg-p08-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-p08-n01-s01/task.toml b/tasks/agg-p08-n01-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..22b8d9ee62f7f950fe904e24add339f203d2902c --- /dev/null +++ b/tasks/agg-p08-n01-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p08-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 = 8 +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-p08-n01-s01/tests/expected.json b/tasks/agg-p08-n01-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..8d06bb649bc6fe44dc0b60e2c2eacfbe5154fc54 --- /dev/null +++ b/tasks/agg-p08-n01-s01/tests/expected.json @@ -0,0 +1 @@ +[37] diff --git a/tasks/agg-p08-n01-s01/tests/test.sh b/tasks/agg-p08-n01-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p08-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-p08-n02-s01/instruction.md b/tasks/agg-p08-n02-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..a0f5d6312615f15532c609835c393db0d12fe574 --- /dev/null +++ b/tasks/agg-p08-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-p08-n02-s01/solution/solve.sh b/tasks/agg-p08-n02-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5660d0acd480f744e0a0558de97a5c1cd7ea3c3f --- /dev/null +++ b/tasks/agg-p08-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 '[37, 71]' > "$answer" diff --git a/tasks/agg-p08-n02-s01/task.toml b/tasks/agg-p08-n02-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..dab24fc4099e5155c47bee80eb89e12979c5c551 --- /dev/null +++ b/tasks/agg-p08-n02-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p08-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 = 8 +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-p08-n02-s01/tests/expected.json b/tasks/agg-p08-n02-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..6214d194c3ddc9a34dd690889a4c9e23ab4c7b33 --- /dev/null +++ b/tasks/agg-p08-n02-s01/tests/expected.json @@ -0,0 +1 @@ +[37, 71] diff --git a/tasks/agg-p08-n02-s01/tests/test.sh b/tasks/agg-p08-n02-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p08-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-p08-n02-s02/instruction.md b/tasks/agg-p08-n02-s02/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..f7d66ca758c425370551bcb6e22062cbefbd9f97 --- /dev/null +++ b/tasks/agg-p08-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-one. + +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-p08-n02-s02/solution/solve.sh b/tasks/agg-p08-n02-s02/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5660d0acd480f744e0a0558de97a5c1cd7ea3c3f --- /dev/null +++ b/tasks/agg-p08-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 '[37, 71]' > "$answer" diff --git a/tasks/agg-p08-n02-s02/task.toml b/tasks/agg-p08-n02-s02/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..ca67b090df7bfa268a5b1fbe40efb705ba625fa6 --- /dev/null +++ b/tasks/agg-p08-n02-s02/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p08-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 = 8 +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-p08-n02-s02/tests/expected.json b/tasks/agg-p08-n02-s02/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..6214d194c3ddc9a34dd690889a4c9e23ab4c7b33 --- /dev/null +++ b/tasks/agg-p08-n02-s02/tests/expected.json @@ -0,0 +1 @@ +[37, 71] diff --git a/tasks/agg-p08-n02-s02/tests/test.sh b/tasks/agg-p08-n02-s02/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p08-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-p08-n04-s01/instruction.md b/tasks/agg-p08-n04-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..e277410d31e98e54fee347c8344a718ced81e639 --- /dev/null +++ b/tasks/agg-p08-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 thirty-seven. + +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-p08-n04-s01/solution/solve.sh b/tasks/agg-p08-n04-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..2ef637d3f5b791e756892854f28f286834fc075c --- /dev/null +++ b/tasks/agg-p08-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 '[37, 44, 71, 88]' > "$answer" diff --git a/tasks/agg-p08-n04-s01/task.toml b/tasks/agg-p08-n04-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..a888dd4223b768973c945b40a7cf6b9dfafe6b60 --- /dev/null +++ b/tasks/agg-p08-n04-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p08-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 = 8 +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-p08-n04-s01/tests/expected.json b/tasks/agg-p08-n04-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..bb28c46636293676e397566431ec95202b19b61b --- /dev/null +++ b/tasks/agg-p08-n04-s01/tests/expected.json @@ -0,0 +1 @@ +[37, 44, 71, 88] diff --git a/tasks/agg-p08-n04-s01/tests/test.sh b/tasks/agg-p08-n04-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p08-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-p08-n04-s02/instruction.md b/tasks/agg-p08-n04-s02/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..430467a8c33661604553077a8a27e968376d25e5 --- /dev/null +++ b/tasks/agg-p08-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-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-p08-n04-s02/solution/solve.sh b/tasks/agg-p08-n04-s02/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..2ef637d3f5b791e756892854f28f286834fc075c --- /dev/null +++ b/tasks/agg-p08-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 '[37, 44, 71, 88]' > "$answer" diff --git a/tasks/agg-p08-n04-s02/task.toml b/tasks/agg-p08-n04-s02/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..c7047184f78a3245383a754209b55be0a3684363 --- /dev/null +++ b/tasks/agg-p08-n04-s02/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p08-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 = 8 +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-p08-n04-s02/tests/expected.json b/tasks/agg-p08-n04-s02/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..bb28c46636293676e397566431ec95202b19b61b --- /dev/null +++ b/tasks/agg-p08-n04-s02/tests/expected.json @@ -0,0 +1 @@ +[37, 44, 71, 88] diff --git a/tasks/agg-p08-n04-s02/tests/test.sh b/tasks/agg-p08-n04-s02/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p08-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-p08-n04-s03/instruction.md b/tasks/agg-p08-n04-s03/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..710f629ccf5142ea8ee0ed83d0f5e26f17b2a9f7 --- /dev/null +++ b/tasks/agg-p08-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 eighty-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-p08-n04-s03/solution/solve.sh b/tasks/agg-p08-n04-s03/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..2ef637d3f5b791e756892854f28f286834fc075c --- /dev/null +++ b/tasks/agg-p08-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 '[37, 44, 71, 88]' > "$answer" diff --git a/tasks/agg-p08-n04-s03/task.toml b/tasks/agg-p08-n04-s03/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..a1b9b0448d000b978b863dec2194b53b373975b0 --- /dev/null +++ b/tasks/agg-p08-n04-s03/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p08-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 = 8 +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-p08-n04-s03/tests/expected.json b/tasks/agg-p08-n04-s03/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..bb28c46636293676e397566431ec95202b19b61b --- /dev/null +++ b/tasks/agg-p08-n04-s03/tests/expected.json @@ -0,0 +1 @@ +[37, 44, 71, 88] diff --git a/tasks/agg-p08-n04-s03/tests/test.sh b/tasks/agg-p08-n04-s03/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p08-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-p08-n04-s04/instruction.md b/tasks/agg-p08-n04-s04/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..4921c497e5aeedbc467d8325039aded3f2118521 --- /dev/null +++ b/tasks/agg-p08-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-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-p08-n04-s04/solution/solve.sh b/tasks/agg-p08-n04-s04/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..2ef637d3f5b791e756892854f28f286834fc075c --- /dev/null +++ b/tasks/agg-p08-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 '[37, 44, 71, 88]' > "$answer" diff --git a/tasks/agg-p08-n04-s04/task.toml b/tasks/agg-p08-n04-s04/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..b41e86ab54a4285d8ef02c04d549e2c0adc1bd8b --- /dev/null +++ b/tasks/agg-p08-n04-s04/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p08-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 = 8 +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-p08-n04-s04/tests/expected.json b/tasks/agg-p08-n04-s04/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..bb28c46636293676e397566431ec95202b19b61b --- /dev/null +++ b/tasks/agg-p08-n04-s04/tests/expected.json @@ -0,0 +1 @@ +[37, 44, 71, 88] diff --git a/tasks/agg-p08-n04-s04/tests/test.sh b/tasks/agg-p08-n04-s04/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p08-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-p08-n08-s01/instruction.md b/tasks/agg-p08-n08-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..d28771240990d9554944b9ef68d9203e0acd7f13 --- /dev/null +++ b/tasks/agg-p08-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 thirty-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-p08-n08-s01/solution/solve.sh b/tasks/agg-p08-n08-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7052da51d2bb1e6347bdacc3f342d868d3d94a66 --- /dev/null +++ b/tasks/agg-p08-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 '[24, 35, 37, 44, 66, 68, 71, 88]' > "$answer" diff --git a/tasks/agg-p08-n08-s01/task.toml b/tasks/agg-p08-n08-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..1c88436d1c08c053076002746687f27a71718bfb --- /dev/null +++ b/tasks/agg-p08-n08-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p08-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 = 8 +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-p08-n08-s01/tests/expected.json b/tasks/agg-p08-n08-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..9fd4d8c43a541b770ec7df7d23e030f6ea08f82e --- /dev/null +++ b/tasks/agg-p08-n08-s01/tests/expected.json @@ -0,0 +1 @@ +[24, 35, 37, 44, 66, 68, 71, 88] diff --git a/tasks/agg-p08-n08-s01/tests/test.sh b/tasks/agg-p08-n08-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p08-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-p08-n08-s02/instruction.md b/tasks/agg-p08-n08-s02/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..b972a48112ea31bbb92b19d1817bc5119ac04601 --- /dev/null +++ b/tasks/agg-p08-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-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-p08-n08-s02/solution/solve.sh b/tasks/agg-p08-n08-s02/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7052da51d2bb1e6347bdacc3f342d868d3d94a66 --- /dev/null +++ b/tasks/agg-p08-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 '[24, 35, 37, 44, 66, 68, 71, 88]' > "$answer" diff --git a/tasks/agg-p08-n08-s02/task.toml b/tasks/agg-p08-n08-s02/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..63a4003df096b2cb01e0eaf7ec3762e69e4ec19c --- /dev/null +++ b/tasks/agg-p08-n08-s02/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p08-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 = 8 +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-p08-n08-s02/tests/expected.json b/tasks/agg-p08-n08-s02/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..9fd4d8c43a541b770ec7df7d23e030f6ea08f82e --- /dev/null +++ b/tasks/agg-p08-n08-s02/tests/expected.json @@ -0,0 +1 @@ +[24, 35, 37, 44, 66, 68, 71, 88] diff --git a/tasks/agg-p08-n08-s02/tests/test.sh b/tasks/agg-p08-n08-s02/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p08-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-p08-n08-s03/instruction.md b/tasks/agg-p08-n08-s03/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..8fc5da9fd3f2fb4b928fc1ff5a73236e0d218b54 --- /dev/null +++ b/tasks/agg-p08-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 eighty-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-p08-n08-s03/solution/solve.sh b/tasks/agg-p08-n08-s03/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7052da51d2bb1e6347bdacc3f342d868d3d94a66 --- /dev/null +++ b/tasks/agg-p08-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 '[24, 35, 37, 44, 66, 68, 71, 88]' > "$answer" diff --git a/tasks/agg-p08-n08-s03/task.toml b/tasks/agg-p08-n08-s03/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..4efda04b8c365e70db1e0e21e2e0afe4713f278a --- /dev/null +++ b/tasks/agg-p08-n08-s03/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p08-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 = 8 +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-p08-n08-s03/tests/expected.json b/tasks/agg-p08-n08-s03/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..9fd4d8c43a541b770ec7df7d23e030f6ea08f82e --- /dev/null +++ b/tasks/agg-p08-n08-s03/tests/expected.json @@ -0,0 +1 @@ +[24, 35, 37, 44, 66, 68, 71, 88] diff --git a/tasks/agg-p08-n08-s03/tests/test.sh b/tasks/agg-p08-n08-s03/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p08-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-p08-n08-s04/instruction.md b/tasks/agg-p08-n08-s04/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..fde113c01e4acfbeb8da7ffabf1e13aba553efcb --- /dev/null +++ b/tasks/agg-p08-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-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-p08-n08-s04/solution/solve.sh b/tasks/agg-p08-n08-s04/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7052da51d2bb1e6347bdacc3f342d868d3d94a66 --- /dev/null +++ b/tasks/agg-p08-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 '[24, 35, 37, 44, 66, 68, 71, 88]' > "$answer" diff --git a/tasks/agg-p08-n08-s04/task.toml b/tasks/agg-p08-n08-s04/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..ad2f5b50e6599da8f9d16bbe83eec3efe504f070 --- /dev/null +++ b/tasks/agg-p08-n08-s04/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p08-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 = 8 +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-p08-n08-s04/tests/expected.json b/tasks/agg-p08-n08-s04/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..9fd4d8c43a541b770ec7df7d23e030f6ea08f82e --- /dev/null +++ b/tasks/agg-p08-n08-s04/tests/expected.json @@ -0,0 +1 @@ +[24, 35, 37, 44, 66, 68, 71, 88] diff --git a/tasks/agg-p08-n08-s04/tests/test.sh b/tasks/agg-p08-n08-s04/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p08-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-p08-n08-s05/instruction.md b/tasks/agg-p08-n08-s05/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..ec71f13b5946962c63788849abcae6208cb70629 --- /dev/null +++ b/tasks/agg-p08-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 sixty-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-p08-n08-s05/solution/solve.sh b/tasks/agg-p08-n08-s05/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7052da51d2bb1e6347bdacc3f342d868d3d94a66 --- /dev/null +++ b/tasks/agg-p08-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 '[24, 35, 37, 44, 66, 68, 71, 88]' > "$answer" diff --git a/tasks/agg-p08-n08-s05/task.toml b/tasks/agg-p08-n08-s05/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..da1888d139838a8a7b431658025682b5a4553a67 --- /dev/null +++ b/tasks/agg-p08-n08-s05/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p08-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 = 8 +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-p08-n08-s05/tests/expected.json b/tasks/agg-p08-n08-s05/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..9fd4d8c43a541b770ec7df7d23e030f6ea08f82e --- /dev/null +++ b/tasks/agg-p08-n08-s05/tests/expected.json @@ -0,0 +1 @@ +[24, 35, 37, 44, 66, 68, 71, 88] diff --git a/tasks/agg-p08-n08-s05/tests/test.sh b/tasks/agg-p08-n08-s05/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p08-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-p08-n08-s06/instruction.md b/tasks/agg-p08-n08-s06/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..45b59ec949464e2c81423a8f183e17974a93c05c --- /dev/null +++ b/tasks/agg-p08-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 sixty-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-p08-n08-s06/solution/solve.sh b/tasks/agg-p08-n08-s06/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7052da51d2bb1e6347bdacc3f342d868d3d94a66 --- /dev/null +++ b/tasks/agg-p08-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 '[24, 35, 37, 44, 66, 68, 71, 88]' > "$answer" diff --git a/tasks/agg-p08-n08-s06/task.toml b/tasks/agg-p08-n08-s06/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..89a0ca53eff9513abdd3f8858307a7efce851bac --- /dev/null +++ b/tasks/agg-p08-n08-s06/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p08-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 = 8 +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-p08-n08-s06/tests/expected.json b/tasks/agg-p08-n08-s06/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..9fd4d8c43a541b770ec7df7d23e030f6ea08f82e --- /dev/null +++ b/tasks/agg-p08-n08-s06/tests/expected.json @@ -0,0 +1 @@ +[24, 35, 37, 44, 66, 68, 71, 88] diff --git a/tasks/agg-p08-n08-s06/tests/test.sh b/tasks/agg-p08-n08-s06/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p08-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-p08-n08-s07/instruction.md b/tasks/agg-p08-n08-s07/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..f29ea0102313bedab13265b505199649c600c3a4 --- /dev/null +++ b/tasks/agg-p08-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 twenty-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-p08-n08-s07/solution/solve.sh b/tasks/agg-p08-n08-s07/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7052da51d2bb1e6347bdacc3f342d868d3d94a66 --- /dev/null +++ b/tasks/agg-p08-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 '[24, 35, 37, 44, 66, 68, 71, 88]' > "$answer" diff --git a/tasks/agg-p08-n08-s07/task.toml b/tasks/agg-p08-n08-s07/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..ab61e749d673dac40468fad65ed89da45b0e94c4 --- /dev/null +++ b/tasks/agg-p08-n08-s07/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p08-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 = 8 +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-p08-n08-s07/tests/expected.json b/tasks/agg-p08-n08-s07/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..9fd4d8c43a541b770ec7df7d23e030f6ea08f82e --- /dev/null +++ b/tasks/agg-p08-n08-s07/tests/expected.json @@ -0,0 +1 @@ +[24, 35, 37, 44, 66, 68, 71, 88] diff --git a/tasks/agg-p08-n08-s07/tests/test.sh b/tasks/agg-p08-n08-s07/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p08-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-p08-n08-s08/instruction.md b/tasks/agg-p08-n08-s08/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..3db91c415e1fee104109b51426264d7f82e4a8ac --- /dev/null +++ b/tasks/agg-p08-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-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-p08-n08-s08/solution/solve.sh b/tasks/agg-p08-n08-s08/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7052da51d2bb1e6347bdacc3f342d868d3d94a66 --- /dev/null +++ b/tasks/agg-p08-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 '[24, 35, 37, 44, 66, 68, 71, 88]' > "$answer" diff --git a/tasks/agg-p08-n08-s08/task.toml b/tasks/agg-p08-n08-s08/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..b364c507376dc893369525cba8ec8276a8bd1f9d --- /dev/null +++ b/tasks/agg-p08-n08-s08/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p08-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 = 8 +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-p08-n08-s08/tests/expected.json b/tasks/agg-p08-n08-s08/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..9fd4d8c43a541b770ec7df7d23e030f6ea08f82e --- /dev/null +++ b/tasks/agg-p08-n08-s08/tests/expected.json @@ -0,0 +1 @@ +[24, 35, 37, 44, 66, 68, 71, 88] diff --git a/tasks/agg-p08-n08-s08/tests/test.sh b/tasks/agg-p08-n08-s08/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p08-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-p08-n16-s01/instruction.md b/tasks/agg-p08-n16-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..10bcc3d169e35738b1fb80abb7316f9cd7c1b230 --- /dev/null +++ b/tasks/agg-p08-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 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-p08-n16-s01/solution/solve.sh b/tasks/agg-p08-n16-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..07dd93032767615c8fdb33d8648ecc9bdd9c8eea --- /dev/null +++ b/tasks/agg-p08-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 '[23, 24, 35, 37, 44, 56, 64, 66, 68, 70, 70, 71, 76, 84, 88, 92]' > "$answer" diff --git a/tasks/agg-p08-n16-s01/task.toml b/tasks/agg-p08-n16-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..eb78ddeeeb0b1c74a751999d58909e50c0edefbb --- /dev/null +++ b/tasks/agg-p08-n16-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p08-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 = 8 +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-p08-n16-s01/tests/expected.json b/tasks/agg-p08-n16-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..d554d648df52d88302dbfb2ceb602c86d48e61dc --- /dev/null +++ b/tasks/agg-p08-n16-s01/tests/expected.json @@ -0,0 +1 @@ +[23, 24, 35, 37, 44, 56, 64, 66, 68, 70, 70, 71, 76, 84, 88, 92] diff --git a/tasks/agg-p08-n16-s01/tests/test.sh b/tasks/agg-p08-n16-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p08-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-p08-n16-s02/instruction.md b/tasks/agg-p08-n16-s02/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..722dd06eb5b0a1781e34a4a84c87448b77da2a59 --- /dev/null +++ b/tasks/agg-p08-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-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-p08-n16-s02/solution/solve.sh b/tasks/agg-p08-n16-s02/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..07dd93032767615c8fdb33d8648ecc9bdd9c8eea --- /dev/null +++ b/tasks/agg-p08-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 '[23, 24, 35, 37, 44, 56, 64, 66, 68, 70, 70, 71, 76, 84, 88, 92]' > "$answer" diff --git a/tasks/agg-p08-n16-s02/task.toml b/tasks/agg-p08-n16-s02/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..50d2c735d435e1af9392dfa46a0af69e1ecd05ff --- /dev/null +++ b/tasks/agg-p08-n16-s02/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p08-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 = 8 +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-p08-n16-s02/tests/expected.json b/tasks/agg-p08-n16-s02/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..d554d648df52d88302dbfb2ceb602c86d48e61dc --- /dev/null +++ b/tasks/agg-p08-n16-s02/tests/expected.json @@ -0,0 +1 @@ +[23, 24, 35, 37, 44, 56, 64, 66, 68, 70, 70, 71, 76, 84, 88, 92] diff --git a/tasks/agg-p08-n16-s02/tests/test.sh b/tasks/agg-p08-n16-s02/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p08-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-p08-n16-s03/instruction.md b/tasks/agg-p08-n16-s03/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..f197f79da6e4638891b46f2053909c167ec13c32 --- /dev/null +++ b/tasks/agg-p08-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 eighty-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-p08-n16-s03/solution/solve.sh b/tasks/agg-p08-n16-s03/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..07dd93032767615c8fdb33d8648ecc9bdd9c8eea --- /dev/null +++ b/tasks/agg-p08-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 '[23, 24, 35, 37, 44, 56, 64, 66, 68, 70, 70, 71, 76, 84, 88, 92]' > "$answer" diff --git a/tasks/agg-p08-n16-s03/task.toml b/tasks/agg-p08-n16-s03/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..d44dce363d3e646cd7881552f830ec7eaf42e7d2 --- /dev/null +++ b/tasks/agg-p08-n16-s03/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p08-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 = 8 +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-p08-n16-s03/tests/expected.json b/tasks/agg-p08-n16-s03/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..d554d648df52d88302dbfb2ceb602c86d48e61dc --- /dev/null +++ b/tasks/agg-p08-n16-s03/tests/expected.json @@ -0,0 +1 @@ +[23, 24, 35, 37, 44, 56, 64, 66, 68, 70, 70, 71, 76, 84, 88, 92] diff --git a/tasks/agg-p08-n16-s03/tests/test.sh b/tasks/agg-p08-n16-s03/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p08-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-p08-n16-s04/instruction.md b/tasks/agg-p08-n16-s04/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..a31300409e75190524f2a237c2d0d6348715dc53 --- /dev/null +++ b/tasks/agg-p08-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-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-p08-n16-s04/solution/solve.sh b/tasks/agg-p08-n16-s04/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..07dd93032767615c8fdb33d8648ecc9bdd9c8eea --- /dev/null +++ b/tasks/agg-p08-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 '[23, 24, 35, 37, 44, 56, 64, 66, 68, 70, 70, 71, 76, 84, 88, 92]' > "$answer" diff --git a/tasks/agg-p08-n16-s04/task.toml b/tasks/agg-p08-n16-s04/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..196da7f2a0aa0fac651fea6775e34b75b8328f67 --- /dev/null +++ b/tasks/agg-p08-n16-s04/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p08-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 = 8 +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-p08-n16-s04/tests/expected.json b/tasks/agg-p08-n16-s04/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..d554d648df52d88302dbfb2ceb602c86d48e61dc --- /dev/null +++ b/tasks/agg-p08-n16-s04/tests/expected.json @@ -0,0 +1 @@ +[23, 24, 35, 37, 44, 56, 64, 66, 68, 70, 70, 71, 76, 84, 88, 92] diff --git a/tasks/agg-p08-n16-s04/tests/test.sh b/tasks/agg-p08-n16-s04/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p08-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-p08-n16-s05/instruction.md b/tasks/agg-p08-n16-s05/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..bec568d59f85e2e30c1eb04f810b7ec136113a04 --- /dev/null +++ b/tasks/agg-p08-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 sixty-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-p08-n16-s05/solution/solve.sh b/tasks/agg-p08-n16-s05/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..07dd93032767615c8fdb33d8648ecc9bdd9c8eea --- /dev/null +++ b/tasks/agg-p08-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 '[23, 24, 35, 37, 44, 56, 64, 66, 68, 70, 70, 71, 76, 84, 88, 92]' > "$answer" diff --git a/tasks/agg-p08-n16-s05/task.toml b/tasks/agg-p08-n16-s05/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..66af78ff6183fbcc9bcf6c98400c61b19e176ea4 --- /dev/null +++ b/tasks/agg-p08-n16-s05/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p08-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 = 8 +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-p08-n16-s05/tests/expected.json b/tasks/agg-p08-n16-s05/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..d554d648df52d88302dbfb2ceb602c86d48e61dc --- /dev/null +++ b/tasks/agg-p08-n16-s05/tests/expected.json @@ -0,0 +1 @@ +[23, 24, 35, 37, 44, 56, 64, 66, 68, 70, 70, 71, 76, 84, 88, 92] diff --git a/tasks/agg-p08-n16-s05/tests/test.sh b/tasks/agg-p08-n16-s05/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p08-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-p08-n16-s06/instruction.md b/tasks/agg-p08-n16-s06/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..a7f0266a5e6733a93cf24a409665e6e92f793dba --- /dev/null +++ b/tasks/agg-p08-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 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-p08-n16-s06/solution/solve.sh b/tasks/agg-p08-n16-s06/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..07dd93032767615c8fdb33d8648ecc9bdd9c8eea --- /dev/null +++ b/tasks/agg-p08-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 '[23, 24, 35, 37, 44, 56, 64, 66, 68, 70, 70, 71, 76, 84, 88, 92]' > "$answer" diff --git a/tasks/agg-p08-n16-s06/task.toml b/tasks/agg-p08-n16-s06/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..736e31d6163e3361da6ce80dbf592a6d353f1f6d --- /dev/null +++ b/tasks/agg-p08-n16-s06/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p08-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 = 8 +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-p08-n16-s06/tests/expected.json b/tasks/agg-p08-n16-s06/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..d554d648df52d88302dbfb2ceb602c86d48e61dc --- /dev/null +++ b/tasks/agg-p08-n16-s06/tests/expected.json @@ -0,0 +1 @@ +[23, 24, 35, 37, 44, 56, 64, 66, 68, 70, 70, 71, 76, 84, 88, 92] diff --git a/tasks/agg-p08-n16-s06/tests/test.sh b/tasks/agg-p08-n16-s06/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p08-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-p08-n16-s07/instruction.md b/tasks/agg-p08-n16-s07/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..951d8309ecd3f9fbcea5726f506c658fa51c95fe --- /dev/null +++ b/tasks/agg-p08-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 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-p08-n16-s07/solution/solve.sh b/tasks/agg-p08-n16-s07/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..07dd93032767615c8fdb33d8648ecc9bdd9c8eea --- /dev/null +++ b/tasks/agg-p08-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 '[23, 24, 35, 37, 44, 56, 64, 66, 68, 70, 70, 71, 76, 84, 88, 92]' > "$answer" diff --git a/tasks/agg-p08-n16-s07/task.toml b/tasks/agg-p08-n16-s07/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..eb80709931ad28297cc6f612e2d0ea6918061500 --- /dev/null +++ b/tasks/agg-p08-n16-s07/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p08-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 = 8 +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-p08-n16-s07/tests/expected.json b/tasks/agg-p08-n16-s07/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..d554d648df52d88302dbfb2ceb602c86d48e61dc --- /dev/null +++ b/tasks/agg-p08-n16-s07/tests/expected.json @@ -0,0 +1 @@ +[23, 24, 35, 37, 44, 56, 64, 66, 68, 70, 70, 71, 76, 84, 88, 92] diff --git a/tasks/agg-p08-n16-s07/tests/test.sh b/tasks/agg-p08-n16-s07/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p08-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-p08-n16-s08/instruction.md b/tasks/agg-p08-n16-s08/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..1fe2576f1a20a278b177c066abc20e44af6a4729 --- /dev/null +++ b/tasks/agg-p08-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-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-p08-n16-s08/solution/solve.sh b/tasks/agg-p08-n16-s08/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..07dd93032767615c8fdb33d8648ecc9bdd9c8eea --- /dev/null +++ b/tasks/agg-p08-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 '[23, 24, 35, 37, 44, 56, 64, 66, 68, 70, 70, 71, 76, 84, 88, 92]' > "$answer" diff --git a/tasks/agg-p08-n16-s08/task.toml b/tasks/agg-p08-n16-s08/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..9098da09745b1353458b6d51b635481139c68d53 --- /dev/null +++ b/tasks/agg-p08-n16-s08/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p08-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 = 8 +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-p08-n16-s08/tests/expected.json b/tasks/agg-p08-n16-s08/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..d554d648df52d88302dbfb2ceb602c86d48e61dc --- /dev/null +++ b/tasks/agg-p08-n16-s08/tests/expected.json @@ -0,0 +1 @@ +[23, 24, 35, 37, 44, 56, 64, 66, 68, 70, 70, 71, 76, 84, 88, 92] diff --git a/tasks/agg-p08-n16-s08/tests/test.sh b/tasks/agg-p08-n16-s08/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p08-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-p08-n16-s09/instruction.md b/tasks/agg-p08-n16-s09/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..c06c0812a7b7ea5a0caff9ffd07ddd76bc328ac2 --- /dev/null +++ b/tasks/agg-p08-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 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-p08-n16-s09/solution/solve.sh b/tasks/agg-p08-n16-s09/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..07dd93032767615c8fdb33d8648ecc9bdd9c8eea --- /dev/null +++ b/tasks/agg-p08-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 '[23, 24, 35, 37, 44, 56, 64, 66, 68, 70, 70, 71, 76, 84, 88, 92]' > "$answer" diff --git a/tasks/agg-p08-n16-s09/task.toml b/tasks/agg-p08-n16-s09/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..e9b3923d8aa8807082937061dcac836658646561 --- /dev/null +++ b/tasks/agg-p08-n16-s09/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p08-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 = 8 +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-p08-n16-s09/tests/expected.json b/tasks/agg-p08-n16-s09/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..d554d648df52d88302dbfb2ceb602c86d48e61dc --- /dev/null +++ b/tasks/agg-p08-n16-s09/tests/expected.json @@ -0,0 +1 @@ +[23, 24, 35, 37, 44, 56, 64, 66, 68, 70, 70, 71, 76, 84, 88, 92] diff --git a/tasks/agg-p08-n16-s09/tests/test.sh b/tasks/agg-p08-n16-s09/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p08-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-p08-n16-s10/instruction.md b/tasks/agg-p08-n16-s10/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..93b42da3c5ae14f9371e8643b81073fb0536e08a --- /dev/null +++ b/tasks/agg-p08-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. + +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-p08-n16-s10/solution/solve.sh b/tasks/agg-p08-n16-s10/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..07dd93032767615c8fdb33d8648ecc9bdd9c8eea --- /dev/null +++ b/tasks/agg-p08-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 '[23, 24, 35, 37, 44, 56, 64, 66, 68, 70, 70, 71, 76, 84, 88, 92]' > "$answer" diff --git a/tasks/agg-p08-n16-s10/task.toml b/tasks/agg-p08-n16-s10/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..28f4db3db513895a0ce918bc163ee0fc4720249a --- /dev/null +++ b/tasks/agg-p08-n16-s10/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p08-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 = 8 +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-p08-n16-s10/tests/expected.json b/tasks/agg-p08-n16-s10/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..d554d648df52d88302dbfb2ceb602c86d48e61dc --- /dev/null +++ b/tasks/agg-p08-n16-s10/tests/expected.json @@ -0,0 +1 @@ +[23, 24, 35, 37, 44, 56, 64, 66, 68, 70, 70, 71, 76, 84, 88, 92] diff --git a/tasks/agg-p08-n16-s10/tests/test.sh b/tasks/agg-p08-n16-s10/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p08-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-p08-n16-s11/instruction.md b/tasks/agg-p08-n16-s11/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..1fc02ff38c01961e6ef2d04b50e560edacdcca90 --- /dev/null +++ b/tasks/agg-p08-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-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-p08-n16-s11/solution/solve.sh b/tasks/agg-p08-n16-s11/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..07dd93032767615c8fdb33d8648ecc9bdd9c8eea --- /dev/null +++ b/tasks/agg-p08-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 '[23, 24, 35, 37, 44, 56, 64, 66, 68, 70, 70, 71, 76, 84, 88, 92]' > "$answer" diff --git a/tasks/agg-p08-n16-s11/task.toml b/tasks/agg-p08-n16-s11/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..ddf19c5331e11ce3a2532e3a08a67535d6fe07fe --- /dev/null +++ b/tasks/agg-p08-n16-s11/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p08-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 = 8 +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-p08-n16-s11/tests/expected.json b/tasks/agg-p08-n16-s11/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..d554d648df52d88302dbfb2ceb602c86d48e61dc --- /dev/null +++ b/tasks/agg-p08-n16-s11/tests/expected.json @@ -0,0 +1 @@ +[23, 24, 35, 37, 44, 56, 64, 66, 68, 70, 70, 71, 76, 84, 88, 92] diff --git a/tasks/agg-p08-n16-s11/tests/test.sh b/tasks/agg-p08-n16-s11/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p08-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-p08-n16-s12/instruction.md b/tasks/agg-p08-n16-s12/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..93b42da3c5ae14f9371e8643b81073fb0536e08a --- /dev/null +++ b/tasks/agg-p08-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 seventy. + +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-p08-n16-s12/solution/solve.sh b/tasks/agg-p08-n16-s12/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..07dd93032767615c8fdb33d8648ecc9bdd9c8eea --- /dev/null +++ b/tasks/agg-p08-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 '[23, 24, 35, 37, 44, 56, 64, 66, 68, 70, 70, 71, 76, 84, 88, 92]' > "$answer" diff --git a/tasks/agg-p08-n16-s12/task.toml b/tasks/agg-p08-n16-s12/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..f9224a43ee9cb8afbeb2f0a101548cc0c3f07c59 --- /dev/null +++ b/tasks/agg-p08-n16-s12/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p08-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 = 8 +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-p08-n16-s12/tests/expected.json b/tasks/agg-p08-n16-s12/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..d554d648df52d88302dbfb2ceb602c86d48e61dc --- /dev/null +++ b/tasks/agg-p08-n16-s12/tests/expected.json @@ -0,0 +1 @@ +[23, 24, 35, 37, 44, 56, 64, 66, 68, 70, 70, 71, 76, 84, 88, 92] diff --git a/tasks/agg-p08-n16-s12/tests/test.sh b/tasks/agg-p08-n16-s12/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p08-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-p08-n16-s13/instruction.md b/tasks/agg-p08-n16-s13/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..e2aae6c434553b6621935dc958a71837c92b10ea --- /dev/null +++ b/tasks/agg-p08-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 sixty-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-p08-n16-s13/solution/solve.sh b/tasks/agg-p08-n16-s13/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..07dd93032767615c8fdb33d8648ecc9bdd9c8eea --- /dev/null +++ b/tasks/agg-p08-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 '[23, 24, 35, 37, 44, 56, 64, 66, 68, 70, 70, 71, 76, 84, 88, 92]' > "$answer" diff --git a/tasks/agg-p08-n16-s13/task.toml b/tasks/agg-p08-n16-s13/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..cf7a7da28d83677eb35c69c7b5c84c303d41f03c --- /dev/null +++ b/tasks/agg-p08-n16-s13/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p08-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 = 8 +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-p08-n16-s13/tests/expected.json b/tasks/agg-p08-n16-s13/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..d554d648df52d88302dbfb2ceb602c86d48e61dc --- /dev/null +++ b/tasks/agg-p08-n16-s13/tests/expected.json @@ -0,0 +1 @@ +[23, 24, 35, 37, 44, 56, 64, 66, 68, 70, 70, 71, 76, 84, 88, 92] diff --git a/tasks/agg-p08-n16-s13/tests/test.sh b/tasks/agg-p08-n16-s13/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p08-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-p08-n16-s14/instruction.md b/tasks/agg-p08-n16-s14/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..ff35f53eda015951f8078ff0751a783f65818958 --- /dev/null +++ b/tasks/agg-p08-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-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-p08-n16-s14/solution/solve.sh b/tasks/agg-p08-n16-s14/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..07dd93032767615c8fdb33d8648ecc9bdd9c8eea --- /dev/null +++ b/tasks/agg-p08-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 '[23, 24, 35, 37, 44, 56, 64, 66, 68, 70, 70, 71, 76, 84, 88, 92]' > "$answer" diff --git a/tasks/agg-p08-n16-s14/task.toml b/tasks/agg-p08-n16-s14/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..b0ef5a3ec256484744321fae762577626d16ed88 --- /dev/null +++ b/tasks/agg-p08-n16-s14/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p08-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 = 8 +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-p08-n16-s14/tests/expected.json b/tasks/agg-p08-n16-s14/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..d554d648df52d88302dbfb2ceb602c86d48e61dc --- /dev/null +++ b/tasks/agg-p08-n16-s14/tests/expected.json @@ -0,0 +1 @@ +[23, 24, 35, 37, 44, 56, 64, 66, 68, 70, 70, 71, 76, 84, 88, 92] diff --git a/tasks/agg-p08-n16-s14/tests/test.sh b/tasks/agg-p08-n16-s14/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p08-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-p08-n16-s15/instruction.md b/tasks/agg-p08-n16-s15/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..7d5ca093d11da3b866f85566039dbc2ac3bc8c84 --- /dev/null +++ b/tasks/agg-p08-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 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-p08-n16-s15/solution/solve.sh b/tasks/agg-p08-n16-s15/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..07dd93032767615c8fdb33d8648ecc9bdd9c8eea --- /dev/null +++ b/tasks/agg-p08-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 '[23, 24, 35, 37, 44, 56, 64, 66, 68, 70, 70, 71, 76, 84, 88, 92]' > "$answer" diff --git a/tasks/agg-p08-n16-s15/task.toml b/tasks/agg-p08-n16-s15/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..44185c549d266446536bf36538a664111002940f --- /dev/null +++ b/tasks/agg-p08-n16-s15/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p08-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 = 8 +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-p08-n16-s15/tests/expected.json b/tasks/agg-p08-n16-s15/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..d554d648df52d88302dbfb2ceb602c86d48e61dc --- /dev/null +++ b/tasks/agg-p08-n16-s15/tests/expected.json @@ -0,0 +1 @@ +[23, 24, 35, 37, 44, 56, 64, 66, 68, 70, 70, 71, 76, 84, 88, 92] diff --git a/tasks/agg-p08-n16-s15/tests/test.sh b/tasks/agg-p08-n16-s15/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p08-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-p08-n16-s16/instruction.md b/tasks/agg-p08-n16-s16/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..07133633c82ade16a43a26c7ec6cacc19d41b3bd --- /dev/null +++ b/tasks/agg-p08-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 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-p08-n16-s16/solution/solve.sh b/tasks/agg-p08-n16-s16/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..07dd93032767615c8fdb33d8648ecc9bdd9c8eea --- /dev/null +++ b/tasks/agg-p08-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 '[23, 24, 35, 37, 44, 56, 64, 66, 68, 70, 70, 71, 76, 84, 88, 92]' > "$answer" diff --git a/tasks/agg-p08-n16-s16/task.toml b/tasks/agg-p08-n16-s16/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..cfd0339eb93fff42b5804e3dcaeabc47176e527e --- /dev/null +++ b/tasks/agg-p08-n16-s16/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p08-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 = 8 +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-p08-n16-s16/tests/expected.json b/tasks/agg-p08-n16-s16/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..d554d648df52d88302dbfb2ceb602c86d48e61dc --- /dev/null +++ b/tasks/agg-p08-n16-s16/tests/expected.json @@ -0,0 +1 @@ +[23, 24, 35, 37, 44, 56, 64, 66, 68, 70, 70, 71, 76, 84, 88, 92] diff --git a/tasks/agg-p08-n16-s16/tests/test.sh b/tasks/agg-p08-n16-s16/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p08-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-p09-n01-s01/instruction.md b/tasks/agg-p09-n01-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..d0eb215fbe88c75282dd93b86f1247f5258aeca5 --- /dev/null +++ b/tasks/agg-p09-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. + +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-p09-n01-s01/solution/solve.sh b/tasks/agg-p09-n01-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b0f6585a23e398321201c13c43d39e0c41cc7930 --- /dev/null +++ b/tasks/agg-p09-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 '[40]' > "$answer" diff --git a/tasks/agg-p09-n01-s01/task.toml b/tasks/agg-p09-n01-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..9d3a0d00df7d28ca0271b187296f303553d4480f --- /dev/null +++ b/tasks/agg-p09-n01-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p09-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 = 9 +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-p09-n01-s01/tests/expected.json b/tasks/agg-p09-n01-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..83cb35fe9a3ae5497889d14ea34d7f86064fc095 --- /dev/null +++ b/tasks/agg-p09-n01-s01/tests/expected.json @@ -0,0 +1 @@ +[40] diff --git a/tasks/agg-p09-n01-s01/tests/test.sh b/tasks/agg-p09-n01-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p09-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-p09-n02-s01/instruction.md b/tasks/agg-p09-n02-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..393e555ec1d2b25cc4eef73d76af3df0ebc9f6ce --- /dev/null +++ b/tasks/agg-p09-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. + +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-p09-n02-s01/solution/solve.sh b/tasks/agg-p09-n02-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..558f3bf2c0205dba2dad79a1c3609b8203ac3e6e --- /dev/null +++ b/tasks/agg-p09-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 '[40, 67]' > "$answer" diff --git a/tasks/agg-p09-n02-s01/task.toml b/tasks/agg-p09-n02-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..8c118a8a5e63f999e99ed81b06120cab129de72d --- /dev/null +++ b/tasks/agg-p09-n02-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p09-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 = 9 +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-p09-n02-s01/tests/expected.json b/tasks/agg-p09-n02-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..65b3531906a73385b194984106ddd7b9b0a2d712 --- /dev/null +++ b/tasks/agg-p09-n02-s01/tests/expected.json @@ -0,0 +1 @@ +[40, 67] diff --git a/tasks/agg-p09-n02-s01/tests/test.sh b/tasks/agg-p09-n02-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p09-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-p09-n02-s02/instruction.md b/tasks/agg-p09-n02-s02/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..d53c8d394422ff6fb45411356dd9784f0bd9e9f1 --- /dev/null +++ b/tasks/agg-p09-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 sixty-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-p09-n02-s02/solution/solve.sh b/tasks/agg-p09-n02-s02/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..558f3bf2c0205dba2dad79a1c3609b8203ac3e6e --- /dev/null +++ b/tasks/agg-p09-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 '[40, 67]' > "$answer" diff --git a/tasks/agg-p09-n02-s02/task.toml b/tasks/agg-p09-n02-s02/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..8422f88ade2fcdb44340b24845630cc3cdee0ef1 --- /dev/null +++ b/tasks/agg-p09-n02-s02/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p09-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 = 9 +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-p09-n02-s02/tests/expected.json b/tasks/agg-p09-n02-s02/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..65b3531906a73385b194984106ddd7b9b0a2d712 --- /dev/null +++ b/tasks/agg-p09-n02-s02/tests/expected.json @@ -0,0 +1 @@ +[40, 67] diff --git a/tasks/agg-p09-n02-s02/tests/test.sh b/tasks/agg-p09-n02-s02/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p09-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-p09-n04-s01/instruction.md b/tasks/agg-p09-n04-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..525b5a36580eb1d89ffda210a1193456cab19921 --- /dev/null +++ b/tasks/agg-p09-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. + +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-p09-n04-s01/solution/solve.sh b/tasks/agg-p09-n04-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..8be01ecbad13ef48605fa8444123e8bb0f0d2a90 --- /dev/null +++ b/tasks/agg-p09-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 '[40, 43, 65, 67]' > "$answer" diff --git a/tasks/agg-p09-n04-s01/task.toml b/tasks/agg-p09-n04-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..0af1cd5e00a72d42576ce549a3cd5de69243a56a --- /dev/null +++ b/tasks/agg-p09-n04-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p09-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 = 9 +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-p09-n04-s01/tests/expected.json b/tasks/agg-p09-n04-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..58cb5f7760c651c834e6dde39cc0afabee3f1e1b --- /dev/null +++ b/tasks/agg-p09-n04-s01/tests/expected.json @@ -0,0 +1 @@ +[40, 43, 65, 67] diff --git a/tasks/agg-p09-n04-s01/tests/test.sh b/tasks/agg-p09-n04-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p09-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-p09-n04-s02/instruction.md b/tasks/agg-p09-n04-s02/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..ef36ba153f10efe5727ee31abce38b8dd6141aca --- /dev/null +++ b/tasks/agg-p09-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 sixty-seven. + +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-p09-n04-s02/solution/solve.sh b/tasks/agg-p09-n04-s02/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..8be01ecbad13ef48605fa8444123e8bb0f0d2a90 --- /dev/null +++ b/tasks/agg-p09-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 '[40, 43, 65, 67]' > "$answer" diff --git a/tasks/agg-p09-n04-s02/task.toml b/tasks/agg-p09-n04-s02/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..0d51ec5a9be8961afe9b935758173ec6574a6c26 --- /dev/null +++ b/tasks/agg-p09-n04-s02/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p09-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 = 9 +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-p09-n04-s02/tests/expected.json b/tasks/agg-p09-n04-s02/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..58cb5f7760c651c834e6dde39cc0afabee3f1e1b --- /dev/null +++ b/tasks/agg-p09-n04-s02/tests/expected.json @@ -0,0 +1 @@ +[40, 43, 65, 67] diff --git a/tasks/agg-p09-n04-s02/tests/test.sh b/tasks/agg-p09-n04-s02/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p09-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-p09-n04-s03/instruction.md b/tasks/agg-p09-n04-s03/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..10ac8a4eaab16f5c9d5a059aa13a56223f70be52 --- /dev/null +++ b/tasks/agg-p09-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 sixty-five. + +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-p09-n04-s03/solution/solve.sh b/tasks/agg-p09-n04-s03/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..8be01ecbad13ef48605fa8444123e8bb0f0d2a90 --- /dev/null +++ b/tasks/agg-p09-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 '[40, 43, 65, 67]' > "$answer" diff --git a/tasks/agg-p09-n04-s03/task.toml b/tasks/agg-p09-n04-s03/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..9ea43ed65307c66e70b1ba75bcee6250db748716 --- /dev/null +++ b/tasks/agg-p09-n04-s03/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p09-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 = 9 +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-p09-n04-s03/tests/expected.json b/tasks/agg-p09-n04-s03/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..58cb5f7760c651c834e6dde39cc0afabee3f1e1b --- /dev/null +++ b/tasks/agg-p09-n04-s03/tests/expected.json @@ -0,0 +1 @@ +[40, 43, 65, 67] diff --git a/tasks/agg-p09-n04-s03/tests/test.sh b/tasks/agg-p09-n04-s03/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p09-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-p09-n04-s04/instruction.md b/tasks/agg-p09-n04-s04/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..213f8f76a9f8395afe0c544ecd0e256b5d3a221a --- /dev/null +++ b/tasks/agg-p09-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-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-p09-n04-s04/solution/solve.sh b/tasks/agg-p09-n04-s04/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..8be01ecbad13ef48605fa8444123e8bb0f0d2a90 --- /dev/null +++ b/tasks/agg-p09-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 '[40, 43, 65, 67]' > "$answer" diff --git a/tasks/agg-p09-n04-s04/task.toml b/tasks/agg-p09-n04-s04/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..38b089c588936990ae3a25b73cbd2fda333345f2 --- /dev/null +++ b/tasks/agg-p09-n04-s04/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p09-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 = 9 +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-p09-n04-s04/tests/expected.json b/tasks/agg-p09-n04-s04/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..58cb5f7760c651c834e6dde39cc0afabee3f1e1b --- /dev/null +++ b/tasks/agg-p09-n04-s04/tests/expected.json @@ -0,0 +1 @@ +[40, 43, 65, 67] diff --git a/tasks/agg-p09-n04-s04/tests/test.sh b/tasks/agg-p09-n04-s04/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p09-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-p09-n08-s01/instruction.md b/tasks/agg-p09-n08-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..d7293023b756e96b4a6f07b0a65c2cc3406ac4be --- /dev/null +++ b/tasks/agg-p09-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. + +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-p09-n08-s01/solution/solve.sh b/tasks/agg-p09-n08-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5a1b7ff11b80e036e4936bf554aa74b9ffe196d6 --- /dev/null +++ b/tasks/agg-p09-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 '[14, 18, 40, 43, 60, 65, 66, 67]' > "$answer" diff --git a/tasks/agg-p09-n08-s01/task.toml b/tasks/agg-p09-n08-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..72e9b6ce9b670b4a309fdc010fbacadc823acce9 --- /dev/null +++ b/tasks/agg-p09-n08-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p09-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 = 9 +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-p09-n08-s01/tests/expected.json b/tasks/agg-p09-n08-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..ab37f9fb33200147aff479b074573d0231b0947c --- /dev/null +++ b/tasks/agg-p09-n08-s01/tests/expected.json @@ -0,0 +1 @@ +[14, 18, 40, 43, 60, 65, 66, 67] diff --git a/tasks/agg-p09-n08-s01/tests/test.sh b/tasks/agg-p09-n08-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p09-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-p09-n08-s02/instruction.md b/tasks/agg-p09-n08-s02/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..c462ac9ca802050bd457b3cfba5d7a79b08da47d --- /dev/null +++ b/tasks/agg-p09-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 sixty-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-p09-n08-s02/solution/solve.sh b/tasks/agg-p09-n08-s02/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5a1b7ff11b80e036e4936bf554aa74b9ffe196d6 --- /dev/null +++ b/tasks/agg-p09-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 '[14, 18, 40, 43, 60, 65, 66, 67]' > "$answer" diff --git a/tasks/agg-p09-n08-s02/task.toml b/tasks/agg-p09-n08-s02/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..6deafb6872b512781dc9ef0b14f928db03e5cca4 --- /dev/null +++ b/tasks/agg-p09-n08-s02/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p09-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 = 9 +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-p09-n08-s02/tests/expected.json b/tasks/agg-p09-n08-s02/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..ab37f9fb33200147aff479b074573d0231b0947c --- /dev/null +++ b/tasks/agg-p09-n08-s02/tests/expected.json @@ -0,0 +1 @@ +[14, 18, 40, 43, 60, 65, 66, 67] diff --git a/tasks/agg-p09-n08-s02/tests/test.sh b/tasks/agg-p09-n08-s02/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p09-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-p09-n08-s03/instruction.md b/tasks/agg-p09-n08-s03/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..e5a9078e4c58d734bc89d35a1a10f88352728538 --- /dev/null +++ b/tasks/agg-p09-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 sixty-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-p09-n08-s03/solution/solve.sh b/tasks/agg-p09-n08-s03/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5a1b7ff11b80e036e4936bf554aa74b9ffe196d6 --- /dev/null +++ b/tasks/agg-p09-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 '[14, 18, 40, 43, 60, 65, 66, 67]' > "$answer" diff --git a/tasks/agg-p09-n08-s03/task.toml b/tasks/agg-p09-n08-s03/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..6cda695087c5add2263691ab3d7c90ff9942ab40 --- /dev/null +++ b/tasks/agg-p09-n08-s03/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p09-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 = 9 +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-p09-n08-s03/tests/expected.json b/tasks/agg-p09-n08-s03/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..ab37f9fb33200147aff479b074573d0231b0947c --- /dev/null +++ b/tasks/agg-p09-n08-s03/tests/expected.json @@ -0,0 +1 @@ +[14, 18, 40, 43, 60, 65, 66, 67] diff --git a/tasks/agg-p09-n08-s03/tests/test.sh b/tasks/agg-p09-n08-s03/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p09-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-p09-n08-s04/instruction.md b/tasks/agg-p09-n08-s04/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..2c724ce2f54c8829b6d803659e7e96973259720e --- /dev/null +++ b/tasks/agg-p09-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-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-p09-n08-s04/solution/solve.sh b/tasks/agg-p09-n08-s04/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5a1b7ff11b80e036e4936bf554aa74b9ffe196d6 --- /dev/null +++ b/tasks/agg-p09-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 '[14, 18, 40, 43, 60, 65, 66, 67]' > "$answer" diff --git a/tasks/agg-p09-n08-s04/task.toml b/tasks/agg-p09-n08-s04/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..5ce8365a29931df6e6eb2a13c3a75169011db4d8 --- /dev/null +++ b/tasks/agg-p09-n08-s04/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p09-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 = 9 +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-p09-n08-s04/tests/expected.json b/tasks/agg-p09-n08-s04/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..ab37f9fb33200147aff479b074573d0231b0947c --- /dev/null +++ b/tasks/agg-p09-n08-s04/tests/expected.json @@ -0,0 +1 @@ +[14, 18, 40, 43, 60, 65, 66, 67] diff --git a/tasks/agg-p09-n08-s04/tests/test.sh b/tasks/agg-p09-n08-s04/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p09-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-p09-n08-s05/instruction.md b/tasks/agg-p09-n08-s05/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..89eac19a8c558e6f60ddcf74c895a44ee106e0a6 --- /dev/null +++ b/tasks/agg-p09-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 sixty. + +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-p09-n08-s05/solution/solve.sh b/tasks/agg-p09-n08-s05/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5a1b7ff11b80e036e4936bf554aa74b9ffe196d6 --- /dev/null +++ b/tasks/agg-p09-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 '[14, 18, 40, 43, 60, 65, 66, 67]' > "$answer" diff --git a/tasks/agg-p09-n08-s05/task.toml b/tasks/agg-p09-n08-s05/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..e0d5f7b2b9d4ae8e29d634aab7d7e3942cb9140b --- /dev/null +++ b/tasks/agg-p09-n08-s05/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p09-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 = 9 +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-p09-n08-s05/tests/expected.json b/tasks/agg-p09-n08-s05/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..ab37f9fb33200147aff479b074573d0231b0947c --- /dev/null +++ b/tasks/agg-p09-n08-s05/tests/expected.json @@ -0,0 +1 @@ +[14, 18, 40, 43, 60, 65, 66, 67] diff --git a/tasks/agg-p09-n08-s05/tests/test.sh b/tasks/agg-p09-n08-s05/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p09-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-p09-n08-s06/instruction.md b/tasks/agg-p09-n08-s06/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..ec71f13b5946962c63788849abcae6208cb70629 --- /dev/null +++ b/tasks/agg-p09-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 sixty-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-p09-n08-s06/solution/solve.sh b/tasks/agg-p09-n08-s06/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5a1b7ff11b80e036e4936bf554aa74b9ffe196d6 --- /dev/null +++ b/tasks/agg-p09-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 '[14, 18, 40, 43, 60, 65, 66, 67]' > "$answer" diff --git a/tasks/agg-p09-n08-s06/task.toml b/tasks/agg-p09-n08-s06/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..1a153c4549b4cf25de6d5ea7676bb34747fb6e45 --- /dev/null +++ b/tasks/agg-p09-n08-s06/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p09-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 = 9 +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-p09-n08-s06/tests/expected.json b/tasks/agg-p09-n08-s06/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..ab37f9fb33200147aff479b074573d0231b0947c --- /dev/null +++ b/tasks/agg-p09-n08-s06/tests/expected.json @@ -0,0 +1 @@ +[14, 18, 40, 43, 60, 65, 66, 67] diff --git a/tasks/agg-p09-n08-s06/tests/test.sh b/tasks/agg-p09-n08-s06/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p09-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-p09-n08-s07/instruction.md b/tasks/agg-p09-n08-s07/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..54d881d3c1889509c322ddf6355b6cd34a504304 --- /dev/null +++ b/tasks/agg-p09-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 fourteen. + +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-p09-n08-s07/solution/solve.sh b/tasks/agg-p09-n08-s07/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5a1b7ff11b80e036e4936bf554aa74b9ffe196d6 --- /dev/null +++ b/tasks/agg-p09-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 '[14, 18, 40, 43, 60, 65, 66, 67]' > "$answer" diff --git a/tasks/agg-p09-n08-s07/task.toml b/tasks/agg-p09-n08-s07/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..6ac2fcc506149b2493370e468387bab43e6c8f0f --- /dev/null +++ b/tasks/agg-p09-n08-s07/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p09-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 = 9 +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-p09-n08-s07/tests/expected.json b/tasks/agg-p09-n08-s07/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..ab37f9fb33200147aff479b074573d0231b0947c --- /dev/null +++ b/tasks/agg-p09-n08-s07/tests/expected.json @@ -0,0 +1 @@ +[14, 18, 40, 43, 60, 65, 66, 67] diff --git a/tasks/agg-p09-n08-s07/tests/test.sh b/tasks/agg-p09-n08-s07/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p09-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-p09-n08-s08/instruction.md b/tasks/agg-p09-n08-s08/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..6c99d3a421a7820e0d5105d7dbdbfe39b5c15b23 --- /dev/null +++ b/tasks/agg-p09-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 eighteen. + +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-p09-n08-s08/solution/solve.sh b/tasks/agg-p09-n08-s08/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5a1b7ff11b80e036e4936bf554aa74b9ffe196d6 --- /dev/null +++ b/tasks/agg-p09-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 '[14, 18, 40, 43, 60, 65, 66, 67]' > "$answer" diff --git a/tasks/agg-p09-n08-s08/task.toml b/tasks/agg-p09-n08-s08/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..45313da02374d4df78d39fcb11be94fb1949f0fa --- /dev/null +++ b/tasks/agg-p09-n08-s08/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p09-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 = 9 +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-p09-n08-s08/tests/expected.json b/tasks/agg-p09-n08-s08/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..ab37f9fb33200147aff479b074573d0231b0947c --- /dev/null +++ b/tasks/agg-p09-n08-s08/tests/expected.json @@ -0,0 +1 @@ +[14, 18, 40, 43, 60, 65, 66, 67] diff --git a/tasks/agg-p09-n08-s08/tests/test.sh b/tasks/agg-p09-n08-s08/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p09-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-p09-n16-s01/instruction.md b/tasks/agg-p09-n16-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..ebe30196b058cfe81ab8a53dd5461649bcf91202 --- /dev/null +++ b/tasks/agg-p09-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. + +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-p09-n16-s01/solution/solve.sh b/tasks/agg-p09-n16-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1ee587de292ff6f488456ffb15da2cbc5c6d4ca7 --- /dev/null +++ b/tasks/agg-p09-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 '[8, 14, 14, 18, 20, 31, 40, 43, 60, 63, 65, 66, 67, 68, 81, 88]' > "$answer" diff --git a/tasks/agg-p09-n16-s01/task.toml b/tasks/agg-p09-n16-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..e112d31946503e9eb0583f5765370b571e917403 --- /dev/null +++ b/tasks/agg-p09-n16-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p09-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 = 9 +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-p09-n16-s01/tests/expected.json b/tasks/agg-p09-n16-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..0c02fca6e1e13a216c0115dd582b115286fb02a4 --- /dev/null +++ b/tasks/agg-p09-n16-s01/tests/expected.json @@ -0,0 +1 @@ +[8, 14, 14, 18, 20, 31, 40, 43, 60, 63, 65, 66, 67, 68, 81, 88] diff --git a/tasks/agg-p09-n16-s01/tests/test.sh b/tasks/agg-p09-n16-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p09-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-p09-n16-s02/instruction.md b/tasks/agg-p09-n16-s02/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..cebfaeb748131e1409dea8040dd71bd8744f230b --- /dev/null +++ b/tasks/agg-p09-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 sixty-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-p09-n16-s02/solution/solve.sh b/tasks/agg-p09-n16-s02/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1ee587de292ff6f488456ffb15da2cbc5c6d4ca7 --- /dev/null +++ b/tasks/agg-p09-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 '[8, 14, 14, 18, 20, 31, 40, 43, 60, 63, 65, 66, 67, 68, 81, 88]' > "$answer" diff --git a/tasks/agg-p09-n16-s02/task.toml b/tasks/agg-p09-n16-s02/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..d328dd1132a0f101ec0ff1b53a18b90051b63310 --- /dev/null +++ b/tasks/agg-p09-n16-s02/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p09-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 = 9 +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-p09-n16-s02/tests/expected.json b/tasks/agg-p09-n16-s02/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..0c02fca6e1e13a216c0115dd582b115286fb02a4 --- /dev/null +++ b/tasks/agg-p09-n16-s02/tests/expected.json @@ -0,0 +1 @@ +[8, 14, 14, 18, 20, 31, 40, 43, 60, 63, 65, 66, 67, 68, 81, 88] diff --git a/tasks/agg-p09-n16-s02/tests/test.sh b/tasks/agg-p09-n16-s02/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p09-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-p09-n16-s03/instruction.md b/tasks/agg-p09-n16-s03/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..c9f61576dcb8ea2769bc6b953c327b5baba2bb54 --- /dev/null +++ b/tasks/agg-p09-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 sixty-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-p09-n16-s03/solution/solve.sh b/tasks/agg-p09-n16-s03/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1ee587de292ff6f488456ffb15da2cbc5c6d4ca7 --- /dev/null +++ b/tasks/agg-p09-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 '[8, 14, 14, 18, 20, 31, 40, 43, 60, 63, 65, 66, 67, 68, 81, 88]' > "$answer" diff --git a/tasks/agg-p09-n16-s03/task.toml b/tasks/agg-p09-n16-s03/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..e86ff94f16b55ecd2da05e5380b4b9a90e7247a8 --- /dev/null +++ b/tasks/agg-p09-n16-s03/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p09-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 = 9 +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-p09-n16-s03/tests/expected.json b/tasks/agg-p09-n16-s03/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..0c02fca6e1e13a216c0115dd582b115286fb02a4 --- /dev/null +++ b/tasks/agg-p09-n16-s03/tests/expected.json @@ -0,0 +1 @@ +[8, 14, 14, 18, 20, 31, 40, 43, 60, 63, 65, 66, 67, 68, 81, 88] diff --git a/tasks/agg-p09-n16-s03/tests/test.sh b/tasks/agg-p09-n16-s03/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p09-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-p09-n16-s04/instruction.md b/tasks/agg-p09-n16-s04/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..c0f9d178a1c3057c8c4b57e9c5eca4e4c625b138 --- /dev/null +++ b/tasks/agg-p09-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-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-p09-n16-s04/solution/solve.sh b/tasks/agg-p09-n16-s04/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1ee587de292ff6f488456ffb15da2cbc5c6d4ca7 --- /dev/null +++ b/tasks/agg-p09-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 '[8, 14, 14, 18, 20, 31, 40, 43, 60, 63, 65, 66, 67, 68, 81, 88]' > "$answer" diff --git a/tasks/agg-p09-n16-s04/task.toml b/tasks/agg-p09-n16-s04/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..563b24de1327c6eabd83a55615e3bb06b9272f4d --- /dev/null +++ b/tasks/agg-p09-n16-s04/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p09-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 = 9 +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-p09-n16-s04/tests/expected.json b/tasks/agg-p09-n16-s04/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..0c02fca6e1e13a216c0115dd582b115286fb02a4 --- /dev/null +++ b/tasks/agg-p09-n16-s04/tests/expected.json @@ -0,0 +1 @@ +[8, 14, 14, 18, 20, 31, 40, 43, 60, 63, 65, 66, 67, 68, 81, 88] diff --git a/tasks/agg-p09-n16-s04/tests/test.sh b/tasks/agg-p09-n16-s04/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p09-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-p09-n16-s05/instruction.md b/tasks/agg-p09-n16-s05/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..0d32baca836c92adef8d08189e020f30d37446a4 --- /dev/null +++ b/tasks/agg-p09-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 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-p09-n16-s05/solution/solve.sh b/tasks/agg-p09-n16-s05/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1ee587de292ff6f488456ffb15da2cbc5c6d4ca7 --- /dev/null +++ b/tasks/agg-p09-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 '[8, 14, 14, 18, 20, 31, 40, 43, 60, 63, 65, 66, 67, 68, 81, 88]' > "$answer" diff --git a/tasks/agg-p09-n16-s05/task.toml b/tasks/agg-p09-n16-s05/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..8ff578792cf558ccef7b0003ba02a92477b3a9f2 --- /dev/null +++ b/tasks/agg-p09-n16-s05/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p09-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 = 9 +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-p09-n16-s05/tests/expected.json b/tasks/agg-p09-n16-s05/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..0c02fca6e1e13a216c0115dd582b115286fb02a4 --- /dev/null +++ b/tasks/agg-p09-n16-s05/tests/expected.json @@ -0,0 +1 @@ +[8, 14, 14, 18, 20, 31, 40, 43, 60, 63, 65, 66, 67, 68, 81, 88] diff --git a/tasks/agg-p09-n16-s05/tests/test.sh b/tasks/agg-p09-n16-s05/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p09-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-p09-n16-s06/instruction.md b/tasks/agg-p09-n16-s06/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..bec568d59f85e2e30c1eb04f810b7ec136113a04 --- /dev/null +++ b/tasks/agg-p09-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 sixty-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-p09-n16-s06/solution/solve.sh b/tasks/agg-p09-n16-s06/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1ee587de292ff6f488456ffb15da2cbc5c6d4ca7 --- /dev/null +++ b/tasks/agg-p09-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 '[8, 14, 14, 18, 20, 31, 40, 43, 60, 63, 65, 66, 67, 68, 81, 88]' > "$answer" diff --git a/tasks/agg-p09-n16-s06/task.toml b/tasks/agg-p09-n16-s06/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..1489b212ed2cc5ef9656a4698dd7a6ed3108f32f --- /dev/null +++ b/tasks/agg-p09-n16-s06/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p09-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 = 9 +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-p09-n16-s06/tests/expected.json b/tasks/agg-p09-n16-s06/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..0c02fca6e1e13a216c0115dd582b115286fb02a4 --- /dev/null +++ b/tasks/agg-p09-n16-s06/tests/expected.json @@ -0,0 +1 @@ +[8, 14, 14, 18, 20, 31, 40, 43, 60, 63, 65, 66, 67, 68, 81, 88] diff --git a/tasks/agg-p09-n16-s06/tests/test.sh b/tasks/agg-p09-n16-s06/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p09-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-p09-n16-s07/instruction.md b/tasks/agg-p09-n16-s07/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..63a1a563a0b3abdd4e128d86f97d0a2fb0ea5c9e --- /dev/null +++ b/tasks/agg-p09-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 fourteen. + +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-p09-n16-s07/solution/solve.sh b/tasks/agg-p09-n16-s07/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1ee587de292ff6f488456ffb15da2cbc5c6d4ca7 --- /dev/null +++ b/tasks/agg-p09-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 '[8, 14, 14, 18, 20, 31, 40, 43, 60, 63, 65, 66, 67, 68, 81, 88]' > "$answer" diff --git a/tasks/agg-p09-n16-s07/task.toml b/tasks/agg-p09-n16-s07/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..a8402d3f06afeaac7000701910c5bea1fe64a8b9 --- /dev/null +++ b/tasks/agg-p09-n16-s07/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p09-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 = 9 +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-p09-n16-s07/tests/expected.json b/tasks/agg-p09-n16-s07/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..0c02fca6e1e13a216c0115dd582b115286fb02a4 --- /dev/null +++ b/tasks/agg-p09-n16-s07/tests/expected.json @@ -0,0 +1 @@ +[8, 14, 14, 18, 20, 31, 40, 43, 60, 63, 65, 66, 67, 68, 81, 88] diff --git a/tasks/agg-p09-n16-s07/tests/test.sh b/tasks/agg-p09-n16-s07/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p09-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-p09-n16-s08/instruction.md b/tasks/agg-p09-n16-s08/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..57c62f85ec1ef4f9ca9aa899d016621c4b04432a --- /dev/null +++ b/tasks/agg-p09-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 eighteen. + +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-p09-n16-s08/solution/solve.sh b/tasks/agg-p09-n16-s08/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1ee587de292ff6f488456ffb15da2cbc5c6d4ca7 --- /dev/null +++ b/tasks/agg-p09-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 '[8, 14, 14, 18, 20, 31, 40, 43, 60, 63, 65, 66, 67, 68, 81, 88]' > "$answer" diff --git a/tasks/agg-p09-n16-s08/task.toml b/tasks/agg-p09-n16-s08/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..a6d1790d568d0ee2399b263abc2fa39b70507474 --- /dev/null +++ b/tasks/agg-p09-n16-s08/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p09-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 = 9 +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-p09-n16-s08/tests/expected.json b/tasks/agg-p09-n16-s08/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..0c02fca6e1e13a216c0115dd582b115286fb02a4 --- /dev/null +++ b/tasks/agg-p09-n16-s08/tests/expected.json @@ -0,0 +1 @@ +[8, 14, 14, 18, 20, 31, 40, 43, 60, 63, 65, 66, 67, 68, 81, 88] diff --git a/tasks/agg-p09-n16-s08/tests/test.sh b/tasks/agg-p09-n16-s08/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p09-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-p09-n16-s09/instruction.md b/tasks/agg-p09-n16-s09/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..f197f79da6e4638891b46f2053909c167ec13c32 --- /dev/null +++ b/tasks/agg-p09-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 eighty-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-p09-n16-s09/solution/solve.sh b/tasks/agg-p09-n16-s09/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1ee587de292ff6f488456ffb15da2cbc5c6d4ca7 --- /dev/null +++ b/tasks/agg-p09-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 '[8, 14, 14, 18, 20, 31, 40, 43, 60, 63, 65, 66, 67, 68, 81, 88]' > "$answer" diff --git a/tasks/agg-p09-n16-s09/task.toml b/tasks/agg-p09-n16-s09/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..b764792d45a423a3c754776481a98a39a1331441 --- /dev/null +++ b/tasks/agg-p09-n16-s09/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p09-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 = 9 +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-p09-n16-s09/tests/expected.json b/tasks/agg-p09-n16-s09/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..0c02fca6e1e13a216c0115dd582b115286fb02a4 --- /dev/null +++ b/tasks/agg-p09-n16-s09/tests/expected.json @@ -0,0 +1 @@ +[8, 14, 14, 18, 20, 31, 40, 43, 60, 63, 65, 66, 67, 68, 81, 88] diff --git a/tasks/agg-p09-n16-s09/tests/test.sh b/tasks/agg-p09-n16-s09/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p09-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-p09-n16-s10/instruction.md b/tasks/agg-p09-n16-s10/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..be22dd060dc917313859b782fc59371588c6eefe --- /dev/null +++ b/tasks/agg-p09-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-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-p09-n16-s10/solution/solve.sh b/tasks/agg-p09-n16-s10/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1ee587de292ff6f488456ffb15da2cbc5c6d4ca7 --- /dev/null +++ b/tasks/agg-p09-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 '[8, 14, 14, 18, 20, 31, 40, 43, 60, 63, 65, 66, 67, 68, 81, 88]' > "$answer" diff --git a/tasks/agg-p09-n16-s10/task.toml b/tasks/agg-p09-n16-s10/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..d97b0b9f4f5e93166c84bf9f543163a46c612781 --- /dev/null +++ b/tasks/agg-p09-n16-s10/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p09-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 = 9 +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-p09-n16-s10/tests/expected.json b/tasks/agg-p09-n16-s10/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..0c02fca6e1e13a216c0115dd582b115286fb02a4 --- /dev/null +++ b/tasks/agg-p09-n16-s10/tests/expected.json @@ -0,0 +1 @@ +[8, 14, 14, 18, 20, 31, 40, 43, 60, 63, 65, 66, 67, 68, 81, 88] diff --git a/tasks/agg-p09-n16-s10/tests/test.sh b/tasks/agg-p09-n16-s10/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p09-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-p09-n16-s11/instruction.md b/tasks/agg-p09-n16-s11/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..99a7f97eb2774bf91fcf02fc9e18c71f2c746d9d --- /dev/null +++ b/tasks/agg-p09-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 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-p09-n16-s11/solution/solve.sh b/tasks/agg-p09-n16-s11/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1ee587de292ff6f488456ffb15da2cbc5c6d4ca7 --- /dev/null +++ b/tasks/agg-p09-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 '[8, 14, 14, 18, 20, 31, 40, 43, 60, 63, 65, 66, 67, 68, 81, 88]' > "$answer" diff --git a/tasks/agg-p09-n16-s11/task.toml b/tasks/agg-p09-n16-s11/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..a7517bc4c78a4ce49f016eeb007da880925bca84 --- /dev/null +++ b/tasks/agg-p09-n16-s11/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p09-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 = 9 +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-p09-n16-s11/tests/expected.json b/tasks/agg-p09-n16-s11/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..0c02fca6e1e13a216c0115dd582b115286fb02a4 --- /dev/null +++ b/tasks/agg-p09-n16-s11/tests/expected.json @@ -0,0 +1 @@ +[8, 14, 14, 18, 20, 31, 40, 43, 60, 63, 65, 66, 67, 68, 81, 88] diff --git a/tasks/agg-p09-n16-s11/tests/test.sh b/tasks/agg-p09-n16-s11/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p09-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-p09-n16-s12/instruction.md b/tasks/agg-p09-n16-s12/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..81577d14ed82fb21b17e0bd51c9dc2a594f0c1b6 --- /dev/null +++ b/tasks/agg-p09-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. + +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-p09-n16-s12/solution/solve.sh b/tasks/agg-p09-n16-s12/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1ee587de292ff6f488456ffb15da2cbc5c6d4ca7 --- /dev/null +++ b/tasks/agg-p09-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 '[8, 14, 14, 18, 20, 31, 40, 43, 60, 63, 65, 66, 67, 68, 81, 88]' > "$answer" diff --git a/tasks/agg-p09-n16-s12/task.toml b/tasks/agg-p09-n16-s12/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..2b01cbd3adcbe17d653e77ae956a60c72ddc2f15 --- /dev/null +++ b/tasks/agg-p09-n16-s12/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p09-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 = 9 +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-p09-n16-s12/tests/expected.json b/tasks/agg-p09-n16-s12/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..0c02fca6e1e13a216c0115dd582b115286fb02a4 --- /dev/null +++ b/tasks/agg-p09-n16-s12/tests/expected.json @@ -0,0 +1 @@ +[8, 14, 14, 18, 20, 31, 40, 43, 60, 63, 65, 66, 67, 68, 81, 88] diff --git a/tasks/agg-p09-n16-s12/tests/test.sh b/tasks/agg-p09-n16-s12/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p09-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-p09-n16-s13/instruction.md b/tasks/agg-p09-n16-s13/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..63a1a563a0b3abdd4e128d86f97d0a2fb0ea5c9e --- /dev/null +++ b/tasks/agg-p09-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 fourteen. + +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-p09-n16-s13/solution/solve.sh b/tasks/agg-p09-n16-s13/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1ee587de292ff6f488456ffb15da2cbc5c6d4ca7 --- /dev/null +++ b/tasks/agg-p09-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 '[8, 14, 14, 18, 20, 31, 40, 43, 60, 63, 65, 66, 67, 68, 81, 88]' > "$answer" diff --git a/tasks/agg-p09-n16-s13/task.toml b/tasks/agg-p09-n16-s13/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..544ad563fc34e81349d9601cd91aeffa8dac5000 --- /dev/null +++ b/tasks/agg-p09-n16-s13/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p09-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 = 9 +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-p09-n16-s13/tests/expected.json b/tasks/agg-p09-n16-s13/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..0c02fca6e1e13a216c0115dd582b115286fb02a4 --- /dev/null +++ b/tasks/agg-p09-n16-s13/tests/expected.json @@ -0,0 +1 @@ +[8, 14, 14, 18, 20, 31, 40, 43, 60, 63, 65, 66, 67, 68, 81, 88] diff --git a/tasks/agg-p09-n16-s13/tests/test.sh b/tasks/agg-p09-n16-s13/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p09-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-p09-n16-s14/instruction.md b/tasks/agg-p09-n16-s14/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..a7f0266a5e6733a93cf24a409665e6e92f793dba --- /dev/null +++ b/tasks/agg-p09-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-p09-n16-s14/solution/solve.sh b/tasks/agg-p09-n16-s14/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1ee587de292ff6f488456ffb15da2cbc5c6d4ca7 --- /dev/null +++ b/tasks/agg-p09-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 '[8, 14, 14, 18, 20, 31, 40, 43, 60, 63, 65, 66, 67, 68, 81, 88]' > "$answer" diff --git a/tasks/agg-p09-n16-s14/task.toml b/tasks/agg-p09-n16-s14/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..ccc31584baf5aa273f582b2557024babdd264df4 --- /dev/null +++ b/tasks/agg-p09-n16-s14/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p09-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 = 9 +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-p09-n16-s14/tests/expected.json b/tasks/agg-p09-n16-s14/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..0c02fca6e1e13a216c0115dd582b115286fb02a4 --- /dev/null +++ b/tasks/agg-p09-n16-s14/tests/expected.json @@ -0,0 +1 @@ +[8, 14, 14, 18, 20, 31, 40, 43, 60, 63, 65, 66, 67, 68, 81, 88]