diff --git a/tasks/agg-p04-n04-s01/tests/test.sh b/tasks/agg-p04-n04-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p04-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-p04-n04-s02/instruction.md b/tasks/agg-p04-n04-s02/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..26e139695ec67bfa61fe76d01a807b84861131dd --- /dev/null +++ b/tasks/agg-p04-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 fifty-three. + +The team must find all 4 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 4 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p04-n04-s02/solution/solve.sh b/tasks/agg-p04-n04-s02/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..11a08a88aca6076c81c871dd38123aaa3da0caf8 --- /dev/null +++ b/tasks/agg-p04-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 '[33, 48, 53, 71]' > "$answer" diff --git a/tasks/agg-p04-n04-s02/task.toml b/tasks/agg-p04-n04-s02/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..5894c8912c168d35ab1446ac919048814ac4a5b0 --- /dev/null +++ b/tasks/agg-p04-n04-s02/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p04-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 = 4 +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-p04-n04-s02/tests/expected.json b/tasks/agg-p04-n04-s02/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..ae4edab049d7dca86c1f4e29d129faea3b89b9ed --- /dev/null +++ b/tasks/agg-p04-n04-s02/tests/expected.json @@ -0,0 +1 @@ +[33, 48, 53, 71] diff --git a/tasks/agg-p04-n04-s02/tests/test.sh b/tasks/agg-p04-n04-s02/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p04-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-p04-n04-s03/instruction.md b/tasks/agg-p04-n04-s03/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..af29f7ab0f75076509388fa943bdfb4a4c0a5922 --- /dev/null +++ b/tasks/agg-p04-n04-s03/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 4 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is forty-eight. + +The team must find all 4 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 4 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p04-n04-s03/solution/solve.sh b/tasks/agg-p04-n04-s03/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..11a08a88aca6076c81c871dd38123aaa3da0caf8 --- /dev/null +++ b/tasks/agg-p04-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 '[33, 48, 53, 71]' > "$answer" diff --git a/tasks/agg-p04-n04-s03/task.toml b/tasks/agg-p04-n04-s03/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..8602a8096c782917e84b3fd8404c747f68d2884c --- /dev/null +++ b/tasks/agg-p04-n04-s03/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p04-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 = 4 +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-p04-n04-s03/tests/expected.json b/tasks/agg-p04-n04-s03/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..ae4edab049d7dca86c1f4e29d129faea3b89b9ed --- /dev/null +++ b/tasks/agg-p04-n04-s03/tests/expected.json @@ -0,0 +1 @@ +[33, 48, 53, 71] diff --git a/tasks/agg-p04-n04-s03/tests/test.sh b/tasks/agg-p04-n04-s03/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p04-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-p04-n04-s04/instruction.md b/tasks/agg-p04-n04-s04/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..430467a8c33661604553077a8a27e968376d25e5 --- /dev/null +++ b/tasks/agg-p04-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 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-p04-n04-s04/solution/solve.sh b/tasks/agg-p04-n04-s04/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..11a08a88aca6076c81c871dd38123aaa3da0caf8 --- /dev/null +++ b/tasks/agg-p04-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 '[33, 48, 53, 71]' > "$answer" diff --git a/tasks/agg-p04-n04-s04/task.toml b/tasks/agg-p04-n04-s04/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..2aeb5b4c2505623f2ddf8a2126563e3f5c506fe1 --- /dev/null +++ b/tasks/agg-p04-n04-s04/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p04-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 = 4 +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-p04-n04-s04/tests/expected.json b/tasks/agg-p04-n04-s04/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..ae4edab049d7dca86c1f4e29d129faea3b89b9ed --- /dev/null +++ b/tasks/agg-p04-n04-s04/tests/expected.json @@ -0,0 +1 @@ +[33, 48, 53, 71] diff --git a/tasks/agg-p04-n04-s04/tests/test.sh b/tasks/agg-p04-n04-s04/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p04-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-p04-n08-s01/instruction.md b/tasks/agg-p04-n08-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..03c94df8689da4f5b0401f4f3decef651eb9aee0 --- /dev/null +++ b/tasks/agg-p04-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-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-p04-n08-s01/solution/solve.sh b/tasks/agg-p04-n08-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3a0a07cdae1ed184034c54b984c8f709a0e6e747 --- /dev/null +++ b/tasks/agg-p04-n08-s01/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[25, 33, 48, 53, 62, 71, 87, 90]' > "$answer" diff --git a/tasks/agg-p04-n08-s01/task.toml b/tasks/agg-p04-n08-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..a71b2c2061c35c009a31bbde3e4477c54e2cf6c1 --- /dev/null +++ b/tasks/agg-p04-n08-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p04-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 = 4 +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-p04-n08-s01/tests/expected.json b/tasks/agg-p04-n08-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..08227576462e2e45e37e2c2230ddc2700255163c --- /dev/null +++ b/tasks/agg-p04-n08-s01/tests/expected.json @@ -0,0 +1 @@ +[25, 33, 48, 53, 62, 71, 87, 90] diff --git a/tasks/agg-p04-n08-s01/tests/test.sh b/tasks/agg-p04-n08-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p04-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-p04-n08-s02/instruction.md b/tasks/agg-p04-n08-s02/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..fb0fbc43bc72c36371a3de146c4ffbb7a4304417 --- /dev/null +++ b/tasks/agg-p04-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 fifty-three. + +The team must find all 8 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 8 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p04-n08-s02/solution/solve.sh b/tasks/agg-p04-n08-s02/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3a0a07cdae1ed184034c54b984c8f709a0e6e747 --- /dev/null +++ b/tasks/agg-p04-n08-s02/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[25, 33, 48, 53, 62, 71, 87, 90]' > "$answer" diff --git a/tasks/agg-p04-n08-s02/task.toml b/tasks/agg-p04-n08-s02/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..bd7ae2915bef71b632b4f1c64a7161b5a315b18d --- /dev/null +++ b/tasks/agg-p04-n08-s02/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p04-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 = 4 +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-p04-n08-s02/tests/expected.json b/tasks/agg-p04-n08-s02/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..08227576462e2e45e37e2c2230ddc2700255163c --- /dev/null +++ b/tasks/agg-p04-n08-s02/tests/expected.json @@ -0,0 +1 @@ +[25, 33, 48, 53, 62, 71, 87, 90] diff --git a/tasks/agg-p04-n08-s02/tests/test.sh b/tasks/agg-p04-n08-s02/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p04-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-p04-n08-s03/instruction.md b/tasks/agg-p04-n08-s03/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..9aeda7c18bda7e04cdb2b969682a97e7b7f2d3d5 --- /dev/null +++ b/tasks/agg-p04-n08-s03/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 8 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is forty-eight. + +The team must find all 8 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 8 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p04-n08-s03/solution/solve.sh b/tasks/agg-p04-n08-s03/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3a0a07cdae1ed184034c54b984c8f709a0e6e747 --- /dev/null +++ b/tasks/agg-p04-n08-s03/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[25, 33, 48, 53, 62, 71, 87, 90]' > "$answer" diff --git a/tasks/agg-p04-n08-s03/task.toml b/tasks/agg-p04-n08-s03/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..19d1f2179b5d0e99e0db6df1af878947118294c2 --- /dev/null +++ b/tasks/agg-p04-n08-s03/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p04-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 = 4 +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-p04-n08-s03/tests/expected.json b/tasks/agg-p04-n08-s03/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..08227576462e2e45e37e2c2230ddc2700255163c --- /dev/null +++ b/tasks/agg-p04-n08-s03/tests/expected.json @@ -0,0 +1 @@ +[25, 33, 48, 53, 62, 71, 87, 90] diff --git a/tasks/agg-p04-n08-s03/tests/test.sh b/tasks/agg-p04-n08-s03/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p04-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-p04-n08-s04/instruction.md b/tasks/agg-p04-n08-s04/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..b972a48112ea31bbb92b19d1817bc5119ac04601 --- /dev/null +++ b/tasks/agg-p04-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 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-p04-n08-s04/solution/solve.sh b/tasks/agg-p04-n08-s04/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3a0a07cdae1ed184034c54b984c8f709a0e6e747 --- /dev/null +++ b/tasks/agg-p04-n08-s04/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[25, 33, 48, 53, 62, 71, 87, 90]' > "$answer" diff --git a/tasks/agg-p04-n08-s04/task.toml b/tasks/agg-p04-n08-s04/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..e6ef753b13e418cb7c5579d83760e538f4f80666 --- /dev/null +++ b/tasks/agg-p04-n08-s04/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p04-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 = 4 +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-p04-n08-s04/tests/expected.json b/tasks/agg-p04-n08-s04/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..08227576462e2e45e37e2c2230ddc2700255163c --- /dev/null +++ b/tasks/agg-p04-n08-s04/tests/expected.json @@ -0,0 +1 @@ +[25, 33, 48, 53, 62, 71, 87, 90] diff --git a/tasks/agg-p04-n08-s04/tests/test.sh b/tasks/agg-p04-n08-s04/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p04-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-p04-n08-s05/instruction.md b/tasks/agg-p04-n08-s05/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..eee7a0b5f66fc3863f0f9be834031a101d16805b --- /dev/null +++ b/tasks/agg-p04-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 twenty-five. + +The team must find all 8 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 8 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p04-n08-s05/solution/solve.sh b/tasks/agg-p04-n08-s05/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3a0a07cdae1ed184034c54b984c8f709a0e6e747 --- /dev/null +++ b/tasks/agg-p04-n08-s05/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[25, 33, 48, 53, 62, 71, 87, 90]' > "$answer" diff --git a/tasks/agg-p04-n08-s05/task.toml b/tasks/agg-p04-n08-s05/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..c486a913b834ccd1cb724dcacef3131b52963559 --- /dev/null +++ b/tasks/agg-p04-n08-s05/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p04-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 = 4 +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-p04-n08-s05/tests/expected.json b/tasks/agg-p04-n08-s05/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..08227576462e2e45e37e2c2230ddc2700255163c --- /dev/null +++ b/tasks/agg-p04-n08-s05/tests/expected.json @@ -0,0 +1 @@ +[25, 33, 48, 53, 62, 71, 87, 90] diff --git a/tasks/agg-p04-n08-s05/tests/test.sh b/tasks/agg-p04-n08-s05/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p04-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-p04-n08-s06/instruction.md b/tasks/agg-p04-n08-s06/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..1479c41de00fbbd2d26aad2aee1e7ce486083215 --- /dev/null +++ b/tasks/agg-p04-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-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-p04-n08-s06/solution/solve.sh b/tasks/agg-p04-n08-s06/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3a0a07cdae1ed184034c54b984c8f709a0e6e747 --- /dev/null +++ b/tasks/agg-p04-n08-s06/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[25, 33, 48, 53, 62, 71, 87, 90]' > "$answer" diff --git a/tasks/agg-p04-n08-s06/task.toml b/tasks/agg-p04-n08-s06/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..4d39554301a9e6b18fbf5d86f1072f6cdc38c70f --- /dev/null +++ b/tasks/agg-p04-n08-s06/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p04-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 = 4 +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-p04-n08-s06/tests/expected.json b/tasks/agg-p04-n08-s06/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..08227576462e2e45e37e2c2230ddc2700255163c --- /dev/null +++ b/tasks/agg-p04-n08-s06/tests/expected.json @@ -0,0 +1 @@ +[25, 33, 48, 53, 62, 71, 87, 90] diff --git a/tasks/agg-p04-n08-s06/tests/test.sh b/tasks/agg-p04-n08-s06/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p04-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-p04-n08-s07/instruction.md b/tasks/agg-p04-n08-s07/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..33c7a00b4080f6f53fe6a6a1b5309b10579c3bc5 --- /dev/null +++ b/tasks/agg-p04-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-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-p04-n08-s07/solution/solve.sh b/tasks/agg-p04-n08-s07/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3a0a07cdae1ed184034c54b984c8f709a0e6e747 --- /dev/null +++ b/tasks/agg-p04-n08-s07/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[25, 33, 48, 53, 62, 71, 87, 90]' > "$answer" diff --git a/tasks/agg-p04-n08-s07/task.toml b/tasks/agg-p04-n08-s07/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..ed8a094951bfff769eb688a2c7802998ca396ab7 --- /dev/null +++ b/tasks/agg-p04-n08-s07/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p04-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 = 4 +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-p04-n08-s07/tests/expected.json b/tasks/agg-p04-n08-s07/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..08227576462e2e45e37e2c2230ddc2700255163c --- /dev/null +++ b/tasks/agg-p04-n08-s07/tests/expected.json @@ -0,0 +1 @@ +[25, 33, 48, 53, 62, 71, 87, 90] diff --git a/tasks/agg-p04-n08-s07/tests/test.sh b/tasks/agg-p04-n08-s07/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p04-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-p04-n08-s08/instruction.md b/tasks/agg-p04-n08-s08/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..3d680c6e106b56337740b69832fd529620869a7a --- /dev/null +++ b/tasks/agg-p04-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 ninety. + +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-p04-n08-s08/solution/solve.sh b/tasks/agg-p04-n08-s08/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3a0a07cdae1ed184034c54b984c8f709a0e6e747 --- /dev/null +++ b/tasks/agg-p04-n08-s08/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[25, 33, 48, 53, 62, 71, 87, 90]' > "$answer" diff --git a/tasks/agg-p04-n08-s08/task.toml b/tasks/agg-p04-n08-s08/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..dd31ec6e3bcbe826a0f10dade571d0de2269c267 --- /dev/null +++ b/tasks/agg-p04-n08-s08/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p04-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 = 4 +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-p04-n08-s08/tests/expected.json b/tasks/agg-p04-n08-s08/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..08227576462e2e45e37e2c2230ddc2700255163c --- /dev/null +++ b/tasks/agg-p04-n08-s08/tests/expected.json @@ -0,0 +1 @@ +[25, 33, 48, 53, 62, 71, 87, 90] diff --git a/tasks/agg-p04-n08-s08/tests/test.sh b/tasks/agg-p04-n08-s08/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p04-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-p04-n16-s01/instruction.md b/tasks/agg-p04-n16-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..d92b3c67aa869a2b7ccb0b74ca78af94faae0b02 --- /dev/null +++ b/tasks/agg-p04-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-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-p04-n16-s01/solution/solve.sh b/tasks/agg-p04-n16-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1f8e84c5fed1b0fc2d20be6b2bba7552d3d668a6 --- /dev/null +++ b/tasks/agg-p04-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 '[24, 25, 33, 44, 48, 52, 53, 62, 71, 74, 77, 79, 87, 90, 95, 97]' > "$answer" diff --git a/tasks/agg-p04-n16-s01/task.toml b/tasks/agg-p04-n16-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..64eba45a3671d7a52b792ad2a71dd2e59043fda3 --- /dev/null +++ b/tasks/agg-p04-n16-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p04-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 = 4 +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-p04-n16-s01/tests/expected.json b/tasks/agg-p04-n16-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..4bac28ae261303008fb18d36b7740374883f765d --- /dev/null +++ b/tasks/agg-p04-n16-s01/tests/expected.json @@ -0,0 +1 @@ +[24, 25, 33, 44, 48, 52, 53, 62, 71, 74, 77, 79, 87, 90, 95, 97] diff --git a/tasks/agg-p04-n16-s01/tests/test.sh b/tasks/agg-p04-n16-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p04-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-p04-n16-s02/instruction.md b/tasks/agg-p04-n16-s02/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..d019999eecd81b0d102088ffd8dc6702e314773f --- /dev/null +++ b/tasks/agg-p04-n16-s02/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is fifty-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-p04-n16-s02/solution/solve.sh b/tasks/agg-p04-n16-s02/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1f8e84c5fed1b0fc2d20be6b2bba7552d3d668a6 --- /dev/null +++ b/tasks/agg-p04-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 '[24, 25, 33, 44, 48, 52, 53, 62, 71, 74, 77, 79, 87, 90, 95, 97]' > "$answer" diff --git a/tasks/agg-p04-n16-s02/task.toml b/tasks/agg-p04-n16-s02/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..40345d105e5b8428638939d5b5ee2f6a3d3f5f3c --- /dev/null +++ b/tasks/agg-p04-n16-s02/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p04-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 = 4 +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-p04-n16-s02/tests/expected.json b/tasks/agg-p04-n16-s02/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..4bac28ae261303008fb18d36b7740374883f765d --- /dev/null +++ b/tasks/agg-p04-n16-s02/tests/expected.json @@ -0,0 +1 @@ +[24, 25, 33, 44, 48, 52, 53, 62, 71, 74, 77, 79, 87, 90, 95, 97] diff --git a/tasks/agg-p04-n16-s02/tests/test.sh b/tasks/agg-p04-n16-s02/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p04-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-p04-n16-s03/instruction.md b/tasks/agg-p04-n16-s03/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..38e83aee5771fa00d5091767999e55e04acb180b --- /dev/null +++ b/tasks/agg-p04-n16-s03/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is forty-eight. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p04-n16-s03/solution/solve.sh b/tasks/agg-p04-n16-s03/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1f8e84c5fed1b0fc2d20be6b2bba7552d3d668a6 --- /dev/null +++ b/tasks/agg-p04-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 '[24, 25, 33, 44, 48, 52, 53, 62, 71, 74, 77, 79, 87, 90, 95, 97]' > "$answer" diff --git a/tasks/agg-p04-n16-s03/task.toml b/tasks/agg-p04-n16-s03/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..61bff4a10f02f67c21fe78b04a060b0997c309df --- /dev/null +++ b/tasks/agg-p04-n16-s03/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p04-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 = 4 +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-p04-n16-s03/tests/expected.json b/tasks/agg-p04-n16-s03/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..4bac28ae261303008fb18d36b7740374883f765d --- /dev/null +++ b/tasks/agg-p04-n16-s03/tests/expected.json @@ -0,0 +1 @@ +[24, 25, 33, 44, 48, 52, 53, 62, 71, 74, 77, 79, 87, 90, 95, 97] diff --git a/tasks/agg-p04-n16-s03/tests/test.sh b/tasks/agg-p04-n16-s03/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p04-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-p04-n16-s04/instruction.md b/tasks/agg-p04-n16-s04/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..722dd06eb5b0a1781e34a4a84c87448b77da2a59 --- /dev/null +++ b/tasks/agg-p04-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 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-p04-n16-s04/solution/solve.sh b/tasks/agg-p04-n16-s04/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1f8e84c5fed1b0fc2d20be6b2bba7552d3d668a6 --- /dev/null +++ b/tasks/agg-p04-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 '[24, 25, 33, 44, 48, 52, 53, 62, 71, 74, 77, 79, 87, 90, 95, 97]' > "$answer" diff --git a/tasks/agg-p04-n16-s04/task.toml b/tasks/agg-p04-n16-s04/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..fc0feb46ccc9b3f2abf5987c19d609a3179a77e8 --- /dev/null +++ b/tasks/agg-p04-n16-s04/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p04-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 = 4 +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-p04-n16-s04/tests/expected.json b/tasks/agg-p04-n16-s04/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..4bac28ae261303008fb18d36b7740374883f765d --- /dev/null +++ b/tasks/agg-p04-n16-s04/tests/expected.json @@ -0,0 +1 @@ +[24, 25, 33, 44, 48, 52, 53, 62, 71, 74, 77, 79, 87, 90, 95, 97] diff --git a/tasks/agg-p04-n16-s04/tests/test.sh b/tasks/agg-p04-n16-s04/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p04-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-p04-n16-s05/instruction.md b/tasks/agg-p04-n16-s05/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..04c3f6729149d2802728807768786a453bb32941 --- /dev/null +++ b/tasks/agg-p04-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 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-p04-n16-s05/solution/solve.sh b/tasks/agg-p04-n16-s05/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1f8e84c5fed1b0fc2d20be6b2bba7552d3d668a6 --- /dev/null +++ b/tasks/agg-p04-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 '[24, 25, 33, 44, 48, 52, 53, 62, 71, 74, 77, 79, 87, 90, 95, 97]' > "$answer" diff --git a/tasks/agg-p04-n16-s05/task.toml b/tasks/agg-p04-n16-s05/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..31e6e0890ae2e234ef35a11dc119f4362d417bb9 --- /dev/null +++ b/tasks/agg-p04-n16-s05/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p04-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 = 4 +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-p04-n16-s05/tests/expected.json b/tasks/agg-p04-n16-s05/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..4bac28ae261303008fb18d36b7740374883f765d --- /dev/null +++ b/tasks/agg-p04-n16-s05/tests/expected.json @@ -0,0 +1 @@ +[24, 25, 33, 44, 48, 52, 53, 62, 71, 74, 77, 79, 87, 90, 95, 97] diff --git a/tasks/agg-p04-n16-s05/tests/test.sh b/tasks/agg-p04-n16-s05/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p04-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-p04-n16-s06/instruction.md b/tasks/agg-p04-n16-s06/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..81fbf2c2720ed316086419e84cc080153e8dc4cd --- /dev/null +++ b/tasks/agg-p04-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-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-p04-n16-s06/solution/solve.sh b/tasks/agg-p04-n16-s06/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1f8e84c5fed1b0fc2d20be6b2bba7552d3d668a6 --- /dev/null +++ b/tasks/agg-p04-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 '[24, 25, 33, 44, 48, 52, 53, 62, 71, 74, 77, 79, 87, 90, 95, 97]' > "$answer" diff --git a/tasks/agg-p04-n16-s06/task.toml b/tasks/agg-p04-n16-s06/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..dd69c3d08c187bed2a351774f320b3aa44432209 --- /dev/null +++ b/tasks/agg-p04-n16-s06/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p04-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 = 4 +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-p04-n16-s06/tests/expected.json b/tasks/agg-p04-n16-s06/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..4bac28ae261303008fb18d36b7740374883f765d --- /dev/null +++ b/tasks/agg-p04-n16-s06/tests/expected.json @@ -0,0 +1 @@ +[24, 25, 33, 44, 48, 52, 53, 62, 71, 74, 77, 79, 87, 90, 95, 97] diff --git a/tasks/agg-p04-n16-s06/tests/test.sh b/tasks/agg-p04-n16-s06/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p04-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-p04-n16-s07/instruction.md b/tasks/agg-p04-n16-s07/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..3c1a8c1b0c33b8354227b277a5b1885c3067b4d2 --- /dev/null +++ b/tasks/agg-p04-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-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-p04-n16-s07/solution/solve.sh b/tasks/agg-p04-n16-s07/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1f8e84c5fed1b0fc2d20be6b2bba7552d3d668a6 --- /dev/null +++ b/tasks/agg-p04-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 '[24, 25, 33, 44, 48, 52, 53, 62, 71, 74, 77, 79, 87, 90, 95, 97]' > "$answer" diff --git a/tasks/agg-p04-n16-s07/task.toml b/tasks/agg-p04-n16-s07/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..9ef6278442b55c61c2f6c82dc6c09c0fead833c3 --- /dev/null +++ b/tasks/agg-p04-n16-s07/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p04-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 = 4 +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-p04-n16-s07/tests/expected.json b/tasks/agg-p04-n16-s07/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..4bac28ae261303008fb18d36b7740374883f765d --- /dev/null +++ b/tasks/agg-p04-n16-s07/tests/expected.json @@ -0,0 +1 @@ +[24, 25, 33, 44, 48, 52, 53, 62, 71, 74, 77, 79, 87, 90, 95, 97] diff --git a/tasks/agg-p04-n16-s07/tests/test.sh b/tasks/agg-p04-n16-s07/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p04-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-p04-n16-s08/instruction.md b/tasks/agg-p04-n16-s08/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..dd18e619980c2687fe4772d260bb316eee4672ae --- /dev/null +++ b/tasks/agg-p04-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 ninety. + +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-p04-n16-s08/solution/solve.sh b/tasks/agg-p04-n16-s08/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1f8e84c5fed1b0fc2d20be6b2bba7552d3d668a6 --- /dev/null +++ b/tasks/agg-p04-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 '[24, 25, 33, 44, 48, 52, 53, 62, 71, 74, 77, 79, 87, 90, 95, 97]' > "$answer" diff --git a/tasks/agg-p04-n16-s08/task.toml b/tasks/agg-p04-n16-s08/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..1a6e9c811e0d87e1671d1a06c7cb9d0190fb098a --- /dev/null +++ b/tasks/agg-p04-n16-s08/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p04-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 = 4 +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-p04-n16-s08/tests/expected.json b/tasks/agg-p04-n16-s08/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..4bac28ae261303008fb18d36b7740374883f765d --- /dev/null +++ b/tasks/agg-p04-n16-s08/tests/expected.json @@ -0,0 +1 @@ +[24, 25, 33, 44, 48, 52, 53, 62, 71, 74, 77, 79, 87, 90, 95, 97] diff --git a/tasks/agg-p04-n16-s08/tests/test.sh b/tasks/agg-p04-n16-s08/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p04-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-p04-n16-s09/instruction.md b/tasks/agg-p04-n16-s09/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..a31300409e75190524f2a237c2d0d6348715dc53 --- /dev/null +++ b/tasks/agg-p04-n16-s09/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is forty-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-p04-n16-s09/solution/solve.sh b/tasks/agg-p04-n16-s09/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1f8e84c5fed1b0fc2d20be6b2bba7552d3d668a6 --- /dev/null +++ b/tasks/agg-p04-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 '[24, 25, 33, 44, 48, 52, 53, 62, 71, 74, 77, 79, 87, 90, 95, 97]' > "$answer" diff --git a/tasks/agg-p04-n16-s09/task.toml b/tasks/agg-p04-n16-s09/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..771921eec91f402ad9d71e473e0fc62117b87a0c --- /dev/null +++ b/tasks/agg-p04-n16-s09/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p04-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 = 4 +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-p04-n16-s09/tests/expected.json b/tasks/agg-p04-n16-s09/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..4bac28ae261303008fb18d36b7740374883f765d --- /dev/null +++ b/tasks/agg-p04-n16-s09/tests/expected.json @@ -0,0 +1 @@ +[24, 25, 33, 44, 48, 52, 53, 62, 71, 74, 77, 79, 87, 90, 95, 97] diff --git a/tasks/agg-p04-n16-s09/tests/test.sh b/tasks/agg-p04-n16-s09/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p04-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-p04-n16-s10/instruction.md b/tasks/agg-p04-n16-s10/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..951d8309ecd3f9fbcea5726f506c658fa51c95fe --- /dev/null +++ b/tasks/agg-p04-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-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-p04-n16-s10/solution/solve.sh b/tasks/agg-p04-n16-s10/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1f8e84c5fed1b0fc2d20be6b2bba7552d3d668a6 --- /dev/null +++ b/tasks/agg-p04-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 '[24, 25, 33, 44, 48, 52, 53, 62, 71, 74, 77, 79, 87, 90, 95, 97]' > "$answer" diff --git a/tasks/agg-p04-n16-s10/task.toml b/tasks/agg-p04-n16-s10/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..b5a42d70f8add158b496cf56641c8873e78bbc33 --- /dev/null +++ b/tasks/agg-p04-n16-s10/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p04-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 = 4 +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-p04-n16-s10/tests/expected.json b/tasks/agg-p04-n16-s10/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..4bac28ae261303008fb18d36b7740374883f765d --- /dev/null +++ b/tasks/agg-p04-n16-s10/tests/expected.json @@ -0,0 +1 @@ +[24, 25, 33, 44, 48, 52, 53, 62, 71, 74, 77, 79, 87, 90, 95, 97] diff --git a/tasks/agg-p04-n16-s10/tests/test.sh b/tasks/agg-p04-n16-s10/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p04-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-p04-n16-s11/instruction.md b/tasks/agg-p04-n16-s11/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..2b88f98c808d50d8812e112db76251266368fe80 --- /dev/null +++ b/tasks/agg-p04-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 ninety-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-p04-n16-s11/solution/solve.sh b/tasks/agg-p04-n16-s11/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1f8e84c5fed1b0fc2d20be6b2bba7552d3d668a6 --- /dev/null +++ b/tasks/agg-p04-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 '[24, 25, 33, 44, 48, 52, 53, 62, 71, 74, 77, 79, 87, 90, 95, 97]' > "$answer" diff --git a/tasks/agg-p04-n16-s11/task.toml b/tasks/agg-p04-n16-s11/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..237007690b158121a00db5eddf4b594876582441 --- /dev/null +++ b/tasks/agg-p04-n16-s11/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p04-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 = 4 +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-p04-n16-s11/tests/expected.json b/tasks/agg-p04-n16-s11/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..4bac28ae261303008fb18d36b7740374883f765d --- /dev/null +++ b/tasks/agg-p04-n16-s11/tests/expected.json @@ -0,0 +1 @@ +[24, 25, 33, 44, 48, 52, 53, 62, 71, 74, 77, 79, 87, 90, 95, 97] diff --git a/tasks/agg-p04-n16-s11/tests/test.sh b/tasks/agg-p04-n16-s11/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p04-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-p04-n16-s12/instruction.md b/tasks/agg-p04-n16-s12/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..3a10e21a080f18532e8e18935bc65496e13588a2 --- /dev/null +++ b/tasks/agg-p04-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-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-p04-n16-s12/solution/solve.sh b/tasks/agg-p04-n16-s12/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1f8e84c5fed1b0fc2d20be6b2bba7552d3d668a6 --- /dev/null +++ b/tasks/agg-p04-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 '[24, 25, 33, 44, 48, 52, 53, 62, 71, 74, 77, 79, 87, 90, 95, 97]' > "$answer" diff --git a/tasks/agg-p04-n16-s12/task.toml b/tasks/agg-p04-n16-s12/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..33bc881754112eaef0c86aaefc993343dfa8ae79 --- /dev/null +++ b/tasks/agg-p04-n16-s12/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p04-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 = 4 +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-p04-n16-s12/tests/expected.json b/tasks/agg-p04-n16-s12/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..4bac28ae261303008fb18d36b7740374883f765d --- /dev/null +++ b/tasks/agg-p04-n16-s12/tests/expected.json @@ -0,0 +1 @@ +[24, 25, 33, 44, 48, 52, 53, 62, 71, 74, 77, 79, 87, 90, 95, 97] diff --git a/tasks/agg-p04-n16-s12/tests/test.sh b/tasks/agg-p04-n16-s12/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p04-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-p04-n16-s13/instruction.md b/tasks/agg-p04-n16-s13/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..f9807e3dca090e22409202efda192d4a7b9f5ac5 --- /dev/null +++ b/tasks/agg-p04-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 seventy-nine. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p04-n16-s13/solution/solve.sh b/tasks/agg-p04-n16-s13/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1f8e84c5fed1b0fc2d20be6b2bba7552d3d668a6 --- /dev/null +++ b/tasks/agg-p04-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 '[24, 25, 33, 44, 48, 52, 53, 62, 71, 74, 77, 79, 87, 90, 95, 97]' > "$answer" diff --git a/tasks/agg-p04-n16-s13/task.toml b/tasks/agg-p04-n16-s13/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..8684560b917787ea367ab0b335f635823066162d --- /dev/null +++ b/tasks/agg-p04-n16-s13/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p04-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 = 4 +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-p04-n16-s13/tests/expected.json b/tasks/agg-p04-n16-s13/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..4bac28ae261303008fb18d36b7740374883f765d --- /dev/null +++ b/tasks/agg-p04-n16-s13/tests/expected.json @@ -0,0 +1 @@ +[24, 25, 33, 44, 48, 52, 53, 62, 71, 74, 77, 79, 87, 90, 95, 97] diff --git a/tasks/agg-p04-n16-s13/tests/test.sh b/tasks/agg-p04-n16-s13/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p04-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-p04-n16-s14/instruction.md b/tasks/agg-p04-n16-s14/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..6d104365f5a2f721f3137e68a5cce07413cc5159 --- /dev/null +++ b/tasks/agg-p04-n16-s14/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is fifty-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-p04-n16-s14/solution/solve.sh b/tasks/agg-p04-n16-s14/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1f8e84c5fed1b0fc2d20be6b2bba7552d3d668a6 --- /dev/null +++ b/tasks/agg-p04-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 '[24, 25, 33, 44, 48, 52, 53, 62, 71, 74, 77, 79, 87, 90, 95, 97]' > "$answer" diff --git a/tasks/agg-p04-n16-s14/task.toml b/tasks/agg-p04-n16-s14/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..5acffc01e6f7d13d5d30d517ff6521aca854aaf5 --- /dev/null +++ b/tasks/agg-p04-n16-s14/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p04-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 = 4 +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-p04-n16-s14/tests/expected.json b/tasks/agg-p04-n16-s14/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..4bac28ae261303008fb18d36b7740374883f765d --- /dev/null +++ b/tasks/agg-p04-n16-s14/tests/expected.json @@ -0,0 +1 @@ +[24, 25, 33, 44, 48, 52, 53, 62, 71, 74, 77, 79, 87, 90, 95, 97] diff --git a/tasks/agg-p04-n16-s14/tests/test.sh b/tasks/agg-p04-n16-s14/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p04-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-p04-n16-s15/instruction.md b/tasks/agg-p04-n16-s15/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..961985392d4b99bbc35d52871fb6450061a34bb5 --- /dev/null +++ b/tasks/agg-p04-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 ninety-five. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p04-n16-s15/solution/solve.sh b/tasks/agg-p04-n16-s15/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1f8e84c5fed1b0fc2d20be6b2bba7552d3d668a6 --- /dev/null +++ b/tasks/agg-p04-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 '[24, 25, 33, 44, 48, 52, 53, 62, 71, 74, 77, 79, 87, 90, 95, 97]' > "$answer" diff --git a/tasks/agg-p04-n16-s15/task.toml b/tasks/agg-p04-n16-s15/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..b553fac2b6ac47a20ce4d5e32624dc4780cf0547 --- /dev/null +++ b/tasks/agg-p04-n16-s15/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p04-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 = 4 +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-p04-n16-s15/tests/expected.json b/tasks/agg-p04-n16-s15/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..4bac28ae261303008fb18d36b7740374883f765d --- /dev/null +++ b/tasks/agg-p04-n16-s15/tests/expected.json @@ -0,0 +1 @@ +[24, 25, 33, 44, 48, 52, 53, 62, 71, 74, 77, 79, 87, 90, 95, 97] diff --git a/tasks/agg-p04-n16-s15/tests/test.sh b/tasks/agg-p04-n16-s15/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p04-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-p04-n16-s16/instruction.md b/tasks/agg-p04-n16-s16/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..bb8416d585abe15f78ad9eaf98f78cbb202e2f9a --- /dev/null +++ b/tasks/agg-p04-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 seventy-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-p04-n16-s16/solution/solve.sh b/tasks/agg-p04-n16-s16/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1f8e84c5fed1b0fc2d20be6b2bba7552d3d668a6 --- /dev/null +++ b/tasks/agg-p04-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 '[24, 25, 33, 44, 48, 52, 53, 62, 71, 74, 77, 79, 87, 90, 95, 97]' > "$answer" diff --git a/tasks/agg-p04-n16-s16/task.toml b/tasks/agg-p04-n16-s16/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..bbbb7fc98269057074b6f58e936cb5b2fb54f3d9 --- /dev/null +++ b/tasks/agg-p04-n16-s16/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p04-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 = 4 +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-p04-n16-s16/tests/expected.json b/tasks/agg-p04-n16-s16/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..4bac28ae261303008fb18d36b7740374883f765d --- /dev/null +++ b/tasks/agg-p04-n16-s16/tests/expected.json @@ -0,0 +1 @@ +[24, 25, 33, 44, 48, 52, 53, 62, 71, 74, 77, 79, 87, 90, 95, 97] diff --git a/tasks/agg-p04-n16-s16/tests/test.sh b/tasks/agg-p04-n16-s16/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p04-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-p05-n01-s01/instruction.md b/tasks/agg-p05-n01-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..0568bc2af1d88c90277511faf487cc58ac45877d --- /dev/null +++ b/tasks/agg-p05-n01-s01/instruction.md @@ -0,0 +1,9 @@ +# Sort the team's private numbers + +You are the only agent on this team, solving a private-information number sorting task. You +hold one private integer from 1 to 99, written in English words. + +Your private number is eighty-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-p05-n01-s01/solution/solve.sh b/tasks/agg-p05-n01-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..23b6e15f3e87bed4fe79232f4ab285ccc897ed0e --- /dev/null +++ b/tasks/agg-p05-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 '[87]' > "$answer" diff --git a/tasks/agg-p05-n01-s01/task.toml b/tasks/agg-p05-n01-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..fcb53876c1d3110129b7acae4dbdb0377cdade5e --- /dev/null +++ b/tasks/agg-p05-n01-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p05-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 = 5 +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-p05-n01-s01/tests/expected.json b/tasks/agg-p05-n01-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..d165453fd02c7861c6fbbb910cc1348ba27cc956 --- /dev/null +++ b/tasks/agg-p05-n01-s01/tests/expected.json @@ -0,0 +1 @@ +[87] diff --git a/tasks/agg-p05-n01-s01/tests/test.sh b/tasks/agg-p05-n01-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p05-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-p05-n02-s01/instruction.md b/tasks/agg-p05-n02-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..68132a2ea4eff0312994ba245cff48e96ee274f6 --- /dev/null +++ b/tasks/agg-p05-n02-s01/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 2 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is eighty-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-p05-n02-s01/solution/solve.sh b/tasks/agg-p05-n02-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..a7b8c5f8b1688c744266c6c94a360cd60dfccad4 --- /dev/null +++ b/tasks/agg-p05-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 '[87, 93]' > "$answer" diff --git a/tasks/agg-p05-n02-s01/task.toml b/tasks/agg-p05-n02-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..c93aff080579e0042dba1234012b46faa972e689 --- /dev/null +++ b/tasks/agg-p05-n02-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p05-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 = 5 +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-p05-n02-s01/tests/expected.json b/tasks/agg-p05-n02-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..7452e4c9d4e004a729c22a076b6a1e5a41abe2ee --- /dev/null +++ b/tasks/agg-p05-n02-s01/tests/expected.json @@ -0,0 +1 @@ +[87, 93] diff --git a/tasks/agg-p05-n02-s01/tests/test.sh b/tasks/agg-p05-n02-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p05-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-p05-n02-s02/instruction.md b/tasks/agg-p05-n02-s02/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..ec0561d67e0d5dc54152dd0017d91fe60a9ddef3 --- /dev/null +++ b/tasks/agg-p05-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 ninety-three. + +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-p05-n02-s02/solution/solve.sh b/tasks/agg-p05-n02-s02/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..a7b8c5f8b1688c744266c6c94a360cd60dfccad4 --- /dev/null +++ b/tasks/agg-p05-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 '[87, 93]' > "$answer" diff --git a/tasks/agg-p05-n02-s02/task.toml b/tasks/agg-p05-n02-s02/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..9c4aff949bfbcee9fb8355c01ee5a970a6e5b4d2 --- /dev/null +++ b/tasks/agg-p05-n02-s02/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p05-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 = 5 +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-p05-n02-s02/tests/expected.json b/tasks/agg-p05-n02-s02/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..7452e4c9d4e004a729c22a076b6a1e5a41abe2ee --- /dev/null +++ b/tasks/agg-p05-n02-s02/tests/expected.json @@ -0,0 +1 @@ +[87, 93] diff --git a/tasks/agg-p05-n02-s02/tests/test.sh b/tasks/agg-p05-n02-s02/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p05-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-p05-n04-s01/instruction.md b/tasks/agg-p05-n04-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..fc572c6b324e9085b5f8d2ad8e16073f218d2ac2 --- /dev/null +++ b/tasks/agg-p05-n04-s01/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 4 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is eighty-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-p05-n04-s01/solution/solve.sh b/tasks/agg-p05-n04-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6779d8405f6f72dd31a0b475096d891afa2b8e73 --- /dev/null +++ b/tasks/agg-p05-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 '[57, 87, 93, 96]' > "$answer" diff --git a/tasks/agg-p05-n04-s01/task.toml b/tasks/agg-p05-n04-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..e1a5b95fc558d8d4184519f79a5ba0f97d741aec --- /dev/null +++ b/tasks/agg-p05-n04-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p05-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 = 5 +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-p05-n04-s01/tests/expected.json b/tasks/agg-p05-n04-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..baeee4aedb38796edaea040cf019daff9f539a1c --- /dev/null +++ b/tasks/agg-p05-n04-s01/tests/expected.json @@ -0,0 +1 @@ +[57, 87, 93, 96] diff --git a/tasks/agg-p05-n04-s01/tests/test.sh b/tasks/agg-p05-n04-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p05-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-p05-n04-s02/instruction.md b/tasks/agg-p05-n04-s02/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..0f59f042353e4786e2a6604ea91abb595858dde5 --- /dev/null +++ b/tasks/agg-p05-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 ninety-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-p05-n04-s02/solution/solve.sh b/tasks/agg-p05-n04-s02/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6779d8405f6f72dd31a0b475096d891afa2b8e73 --- /dev/null +++ b/tasks/agg-p05-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 '[57, 87, 93, 96]' > "$answer" diff --git a/tasks/agg-p05-n04-s02/task.toml b/tasks/agg-p05-n04-s02/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..06892a547c90e36b37e4273db755532ced53e095 --- /dev/null +++ b/tasks/agg-p05-n04-s02/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p05-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 = 5 +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-p05-n04-s02/tests/expected.json b/tasks/agg-p05-n04-s02/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..baeee4aedb38796edaea040cf019daff9f539a1c --- /dev/null +++ b/tasks/agg-p05-n04-s02/tests/expected.json @@ -0,0 +1 @@ +[57, 87, 93, 96] diff --git a/tasks/agg-p05-n04-s02/tests/test.sh b/tasks/agg-p05-n04-s02/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p05-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-p05-n04-s03/instruction.md b/tasks/agg-p05-n04-s03/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..e7542f9907e91df21fab2124076c6c696721d957 --- /dev/null +++ b/tasks/agg-p05-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 ninety-six. + +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-p05-n04-s03/solution/solve.sh b/tasks/agg-p05-n04-s03/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6779d8405f6f72dd31a0b475096d891afa2b8e73 --- /dev/null +++ b/tasks/agg-p05-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 '[57, 87, 93, 96]' > "$answer" diff --git a/tasks/agg-p05-n04-s03/task.toml b/tasks/agg-p05-n04-s03/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..676ac0fdcc4a3fa2e9031658e2e3e9d2de519c6a --- /dev/null +++ b/tasks/agg-p05-n04-s03/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p05-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 = 5 +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-p05-n04-s03/tests/expected.json b/tasks/agg-p05-n04-s03/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..baeee4aedb38796edaea040cf019daff9f539a1c --- /dev/null +++ b/tasks/agg-p05-n04-s03/tests/expected.json @@ -0,0 +1 @@ +[57, 87, 93, 96] diff --git a/tasks/agg-p05-n04-s03/tests/test.sh b/tasks/agg-p05-n04-s03/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p05-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-p05-n04-s04/instruction.md b/tasks/agg-p05-n04-s04/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..35d1afd72cf600540907b19cc7d078cb47d28575 --- /dev/null +++ b/tasks/agg-p05-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 fifty-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-p05-n04-s04/solution/solve.sh b/tasks/agg-p05-n04-s04/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6779d8405f6f72dd31a0b475096d891afa2b8e73 --- /dev/null +++ b/tasks/agg-p05-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 '[57, 87, 93, 96]' > "$answer" diff --git a/tasks/agg-p05-n04-s04/task.toml b/tasks/agg-p05-n04-s04/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..48d258e50f11d7e3b20fe81efc5fe1064e5f9c5a --- /dev/null +++ b/tasks/agg-p05-n04-s04/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p05-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 = 5 +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-p05-n04-s04/tests/expected.json b/tasks/agg-p05-n04-s04/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..baeee4aedb38796edaea040cf019daff9f539a1c --- /dev/null +++ b/tasks/agg-p05-n04-s04/tests/expected.json @@ -0,0 +1 @@ +[57, 87, 93, 96] diff --git a/tasks/agg-p05-n04-s04/tests/test.sh b/tasks/agg-p05-n04-s04/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p05-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-p05-n08-s01/instruction.md b/tasks/agg-p05-n08-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..33c7a00b4080f6f53fe6a6a1b5309b10579c3bc5 --- /dev/null +++ b/tasks/agg-p05-n08-s01/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 8 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is eighty-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-p05-n08-s01/solution/solve.sh b/tasks/agg-p05-n08-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..fce2adde7019d7851587237a2aef5c4b3fd83b3e --- /dev/null +++ b/tasks/agg-p05-n08-s01/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[25, 40, 57, 68, 84, 87, 93, 96]' > "$answer" diff --git a/tasks/agg-p05-n08-s01/task.toml b/tasks/agg-p05-n08-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..537f1e8a4c38b5f56726a7455fb618c08d1d3329 --- /dev/null +++ b/tasks/agg-p05-n08-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p05-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 = 5 +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-p05-n08-s01/tests/expected.json b/tasks/agg-p05-n08-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..685a6f0bc4318f381ea3d550aed70d3bfbf18d4c --- /dev/null +++ b/tasks/agg-p05-n08-s01/tests/expected.json @@ -0,0 +1 @@ +[25, 40, 57, 68, 84, 87, 93, 96] diff --git a/tasks/agg-p05-n08-s01/tests/test.sh b/tasks/agg-p05-n08-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p05-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-p05-n08-s02/instruction.md b/tasks/agg-p05-n08-s02/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..183578f4cd202fb917e5afc71715cf45b333a146 --- /dev/null +++ b/tasks/agg-p05-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 ninety-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-p05-n08-s02/solution/solve.sh b/tasks/agg-p05-n08-s02/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..fce2adde7019d7851587237a2aef5c4b3fd83b3e --- /dev/null +++ b/tasks/agg-p05-n08-s02/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[25, 40, 57, 68, 84, 87, 93, 96]' > "$answer" diff --git a/tasks/agg-p05-n08-s02/task.toml b/tasks/agg-p05-n08-s02/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..b2522d752536258a35cc636c629a25b80b200f35 --- /dev/null +++ b/tasks/agg-p05-n08-s02/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p05-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 = 5 +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-p05-n08-s02/tests/expected.json b/tasks/agg-p05-n08-s02/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..685a6f0bc4318f381ea3d550aed70d3bfbf18d4c --- /dev/null +++ b/tasks/agg-p05-n08-s02/tests/expected.json @@ -0,0 +1 @@ +[25, 40, 57, 68, 84, 87, 93, 96] diff --git a/tasks/agg-p05-n08-s02/tests/test.sh b/tasks/agg-p05-n08-s02/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p05-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-p05-n08-s03/instruction.md b/tasks/agg-p05-n08-s03/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..56807e7ffd4a14fa2eb5273545b96cb70247a2f9 --- /dev/null +++ b/tasks/agg-p05-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 ninety-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-p05-n08-s03/solution/solve.sh b/tasks/agg-p05-n08-s03/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..fce2adde7019d7851587237a2aef5c4b3fd83b3e --- /dev/null +++ b/tasks/agg-p05-n08-s03/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[25, 40, 57, 68, 84, 87, 93, 96]' > "$answer" diff --git a/tasks/agg-p05-n08-s03/task.toml b/tasks/agg-p05-n08-s03/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..fd6f197d2a25853ccea6b61bc8ba563c7ad33645 --- /dev/null +++ b/tasks/agg-p05-n08-s03/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p05-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 = 5 +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-p05-n08-s03/tests/expected.json b/tasks/agg-p05-n08-s03/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..685a6f0bc4318f381ea3d550aed70d3bfbf18d4c --- /dev/null +++ b/tasks/agg-p05-n08-s03/tests/expected.json @@ -0,0 +1 @@ +[25, 40, 57, 68, 84, 87, 93, 96] diff --git a/tasks/agg-p05-n08-s03/tests/test.sh b/tasks/agg-p05-n08-s03/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p05-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-p05-n08-s04/instruction.md b/tasks/agg-p05-n08-s04/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..2d60bbf6673a6be4cd68c1d77ed23a488a7bf7bf --- /dev/null +++ b/tasks/agg-p05-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 fifty-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-p05-n08-s04/solution/solve.sh b/tasks/agg-p05-n08-s04/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..fce2adde7019d7851587237a2aef5c4b3fd83b3e --- /dev/null +++ b/tasks/agg-p05-n08-s04/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[25, 40, 57, 68, 84, 87, 93, 96]' > "$answer" diff --git a/tasks/agg-p05-n08-s04/task.toml b/tasks/agg-p05-n08-s04/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..bf6d970d9237058dca0235ae4db7b6c0b700386a --- /dev/null +++ b/tasks/agg-p05-n08-s04/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p05-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 = 5 +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-p05-n08-s04/tests/expected.json b/tasks/agg-p05-n08-s04/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..685a6f0bc4318f381ea3d550aed70d3bfbf18d4c --- /dev/null +++ b/tasks/agg-p05-n08-s04/tests/expected.json @@ -0,0 +1 @@ +[25, 40, 57, 68, 84, 87, 93, 96] diff --git a/tasks/agg-p05-n08-s04/tests/test.sh b/tasks/agg-p05-n08-s04/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p05-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-p05-n08-s05/instruction.md b/tasks/agg-p05-n08-s05/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..d7293023b756e96b4a6f07b0a65c2cc3406ac4be --- /dev/null +++ b/tasks/agg-p05-n08-s05/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 8 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is forty. + +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-p05-n08-s05/solution/solve.sh b/tasks/agg-p05-n08-s05/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..fce2adde7019d7851587237a2aef5c4b3fd83b3e --- /dev/null +++ b/tasks/agg-p05-n08-s05/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[25, 40, 57, 68, 84, 87, 93, 96]' > "$answer" diff --git a/tasks/agg-p05-n08-s05/task.toml b/tasks/agg-p05-n08-s05/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..b24bf397a819062b1c4c3999d46ab363aa448382 --- /dev/null +++ b/tasks/agg-p05-n08-s05/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p05-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 = 5 +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-p05-n08-s05/tests/expected.json b/tasks/agg-p05-n08-s05/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..685a6f0bc4318f381ea3d550aed70d3bfbf18d4c --- /dev/null +++ b/tasks/agg-p05-n08-s05/tests/expected.json @@ -0,0 +1 @@ +[25, 40, 57, 68, 84, 87, 93, 96] diff --git a/tasks/agg-p05-n08-s05/tests/test.sh b/tasks/agg-p05-n08-s05/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p05-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-p05-n08-s06/instruction.md b/tasks/agg-p05-n08-s06/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..eee7a0b5f66fc3863f0f9be834031a101d16805b --- /dev/null +++ b/tasks/agg-p05-n08-s06/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 8 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is twenty-five. + +The team must find all 8 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 8 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p05-n08-s06/solution/solve.sh b/tasks/agg-p05-n08-s06/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..fce2adde7019d7851587237a2aef5c4b3fd83b3e --- /dev/null +++ b/tasks/agg-p05-n08-s06/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[25, 40, 57, 68, 84, 87, 93, 96]' > "$answer" diff --git a/tasks/agg-p05-n08-s06/task.toml b/tasks/agg-p05-n08-s06/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..819cbe71644f6768e92d6a4bdbc9a7cdcbe44803 --- /dev/null +++ b/tasks/agg-p05-n08-s06/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p05-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 = 5 +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-p05-n08-s06/tests/expected.json b/tasks/agg-p05-n08-s06/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..685a6f0bc4318f381ea3d550aed70d3bfbf18d4c --- /dev/null +++ b/tasks/agg-p05-n08-s06/tests/expected.json @@ -0,0 +1 @@ +[25, 40, 57, 68, 84, 87, 93, 96] diff --git a/tasks/agg-p05-n08-s06/tests/test.sh b/tasks/agg-p05-n08-s06/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p05-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-p05-n08-s07/instruction.md b/tasks/agg-p05-n08-s07/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..45b59ec949464e2c81423a8f183e17974a93c05c --- /dev/null +++ b/tasks/agg-p05-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 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-p05-n08-s07/solution/solve.sh b/tasks/agg-p05-n08-s07/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..fce2adde7019d7851587237a2aef5c4b3fd83b3e --- /dev/null +++ b/tasks/agg-p05-n08-s07/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[25, 40, 57, 68, 84, 87, 93, 96]' > "$answer" diff --git a/tasks/agg-p05-n08-s07/task.toml b/tasks/agg-p05-n08-s07/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..56edc3c49a318fc13f809e5118c71445323a4875 --- /dev/null +++ b/tasks/agg-p05-n08-s07/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p05-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 = 5 +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-p05-n08-s07/tests/expected.json b/tasks/agg-p05-n08-s07/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..685a6f0bc4318f381ea3d550aed70d3bfbf18d4c --- /dev/null +++ b/tasks/agg-p05-n08-s07/tests/expected.json @@ -0,0 +1 @@ +[25, 40, 57, 68, 84, 87, 93, 96] diff --git a/tasks/agg-p05-n08-s07/tests/test.sh b/tasks/agg-p05-n08-s07/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p05-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-p05-n08-s08/instruction.md b/tasks/agg-p05-n08-s08/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..6662e6911ad1105e195cbc6e76b3cc8d9854bef3 --- /dev/null +++ b/tasks/agg-p05-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 eighty-four. + +The team must find all 8 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 8 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p05-n08-s08/solution/solve.sh b/tasks/agg-p05-n08-s08/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..fce2adde7019d7851587237a2aef5c4b3fd83b3e --- /dev/null +++ b/tasks/agg-p05-n08-s08/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[25, 40, 57, 68, 84, 87, 93, 96]' > "$answer" diff --git a/tasks/agg-p05-n08-s08/task.toml b/tasks/agg-p05-n08-s08/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..41ebbf8553953313571ae50ece70626a7af219c8 --- /dev/null +++ b/tasks/agg-p05-n08-s08/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p05-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 = 5 +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-p05-n08-s08/tests/expected.json b/tasks/agg-p05-n08-s08/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..685a6f0bc4318f381ea3d550aed70d3bfbf18d4c --- /dev/null +++ b/tasks/agg-p05-n08-s08/tests/expected.json @@ -0,0 +1 @@ +[25, 40, 57, 68, 84, 87, 93, 96] diff --git a/tasks/agg-p05-n08-s08/tests/test.sh b/tasks/agg-p05-n08-s08/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p05-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-p05-n16-s01/instruction.md b/tasks/agg-p05-n16-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..3c1a8c1b0c33b8354227b277a5b1885c3067b4d2 --- /dev/null +++ b/tasks/agg-p05-n16-s01/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is eighty-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-p05-n16-s01/solution/solve.sh b/tasks/agg-p05-n16-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..76f263d18be7c630ea8cdb48c40d229622daaa60 --- /dev/null +++ b/tasks/agg-p05-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 '[18, 25, 33, 40, 43, 57, 66, 68, 70, 71, 79, 82, 84, 87, 93, 96]' > "$answer" diff --git a/tasks/agg-p05-n16-s01/task.toml b/tasks/agg-p05-n16-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..957dc7951ba61bbb721820c8b8c4d17dd51d5c61 --- /dev/null +++ b/tasks/agg-p05-n16-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p05-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 = 5 +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-p05-n16-s01/tests/expected.json b/tasks/agg-p05-n16-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..1c333eefb9b09349818042b33169dd9830f21980 --- /dev/null +++ b/tasks/agg-p05-n16-s01/tests/expected.json @@ -0,0 +1 @@ +[18, 25, 33, 40, 43, 57, 66, 68, 70, 71, 79, 82, 84, 87, 93, 96] diff --git a/tasks/agg-p05-n16-s01/tests/test.sh b/tasks/agg-p05-n16-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p05-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-p05-n16-s02/instruction.md b/tasks/agg-p05-n16-s02/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..5a931caf2f59950e949680657e57e512d16ee533 --- /dev/null +++ b/tasks/agg-p05-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 ninety-three. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p05-n16-s02/solution/solve.sh b/tasks/agg-p05-n16-s02/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..76f263d18be7c630ea8cdb48c40d229622daaa60 --- /dev/null +++ b/tasks/agg-p05-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 '[18, 25, 33, 40, 43, 57, 66, 68, 70, 71, 79, 82, 84, 87, 93, 96]' > "$answer" diff --git a/tasks/agg-p05-n16-s02/task.toml b/tasks/agg-p05-n16-s02/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..7592fb3a098dd232c4de62243304d8b7404c65c7 --- /dev/null +++ b/tasks/agg-p05-n16-s02/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p05-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 = 5 +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-p05-n16-s02/tests/expected.json b/tasks/agg-p05-n16-s02/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..1c333eefb9b09349818042b33169dd9830f21980 --- /dev/null +++ b/tasks/agg-p05-n16-s02/tests/expected.json @@ -0,0 +1 @@ +[18, 25, 33, 40, 43, 57, 66, 68, 70, 71, 79, 82, 84, 87, 93, 96] diff --git a/tasks/agg-p05-n16-s02/tests/test.sh b/tasks/agg-p05-n16-s02/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p05-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-p05-n16-s03/instruction.md b/tasks/agg-p05-n16-s03/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..9e673d50df3d0049f8ebbc5f08e69f16f929b38f --- /dev/null +++ b/tasks/agg-p05-n16-s03/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is ninety-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-p05-n16-s03/solution/solve.sh b/tasks/agg-p05-n16-s03/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..76f263d18be7c630ea8cdb48c40d229622daaa60 --- /dev/null +++ b/tasks/agg-p05-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 '[18, 25, 33, 40, 43, 57, 66, 68, 70, 71, 79, 82, 84, 87, 93, 96]' > "$answer" diff --git a/tasks/agg-p05-n16-s03/task.toml b/tasks/agg-p05-n16-s03/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..67a7f217f8d80222a71c030fe8a9782f44a67128 --- /dev/null +++ b/tasks/agg-p05-n16-s03/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p05-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 = 5 +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-p05-n16-s03/tests/expected.json b/tasks/agg-p05-n16-s03/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..1c333eefb9b09349818042b33169dd9830f21980 --- /dev/null +++ b/tasks/agg-p05-n16-s03/tests/expected.json @@ -0,0 +1 @@ +[18, 25, 33, 40, 43, 57, 66, 68, 70, 71, 79, 82, 84, 87, 93, 96] diff --git a/tasks/agg-p05-n16-s03/tests/test.sh b/tasks/agg-p05-n16-s03/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p05-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-p05-n16-s04/instruction.md b/tasks/agg-p05-n16-s04/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..842ab62762da159702eecd05bee6231e50b04d8f --- /dev/null +++ b/tasks/agg-p05-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 fifty-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-p05-n16-s04/solution/solve.sh b/tasks/agg-p05-n16-s04/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..76f263d18be7c630ea8cdb48c40d229622daaa60 --- /dev/null +++ b/tasks/agg-p05-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 '[18, 25, 33, 40, 43, 57, 66, 68, 70, 71, 79, 82, 84, 87, 93, 96]' > "$answer" diff --git a/tasks/agg-p05-n16-s04/task.toml b/tasks/agg-p05-n16-s04/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..d9a335165abecf678c471f5fd2e9b70293482ac2 --- /dev/null +++ b/tasks/agg-p05-n16-s04/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p05-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 = 5 +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-p05-n16-s04/tests/expected.json b/tasks/agg-p05-n16-s04/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..1c333eefb9b09349818042b33169dd9830f21980 --- /dev/null +++ b/tasks/agg-p05-n16-s04/tests/expected.json @@ -0,0 +1 @@ +[18, 25, 33, 40, 43, 57, 66, 68, 70, 71, 79, 82, 84, 87, 93, 96] diff --git a/tasks/agg-p05-n16-s04/tests/test.sh b/tasks/agg-p05-n16-s04/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p05-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-p05-n16-s05/instruction.md b/tasks/agg-p05-n16-s05/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..ebe30196b058cfe81ab8a53dd5461649bcf91202 --- /dev/null +++ b/tasks/agg-p05-n16-s05/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is forty. + +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-p05-n16-s05/solution/solve.sh b/tasks/agg-p05-n16-s05/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..76f263d18be7c630ea8cdb48c40d229622daaa60 --- /dev/null +++ b/tasks/agg-p05-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 '[18, 25, 33, 40, 43, 57, 66, 68, 70, 71, 79, 82, 84, 87, 93, 96]' > "$answer" diff --git a/tasks/agg-p05-n16-s05/task.toml b/tasks/agg-p05-n16-s05/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..1495c95e15dca032acb7c6ddc9e6b4fcd5a697b8 --- /dev/null +++ b/tasks/agg-p05-n16-s05/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p05-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 = 5 +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-p05-n16-s05/tests/expected.json b/tasks/agg-p05-n16-s05/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..1c333eefb9b09349818042b33169dd9830f21980 --- /dev/null +++ b/tasks/agg-p05-n16-s05/tests/expected.json @@ -0,0 +1 @@ +[18, 25, 33, 40, 43, 57, 66, 68, 70, 71, 79, 82, 84, 87, 93, 96] diff --git a/tasks/agg-p05-n16-s05/tests/test.sh b/tasks/agg-p05-n16-s05/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p05-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-p05-n16-s06/instruction.md b/tasks/agg-p05-n16-s06/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..04c3f6729149d2802728807768786a453bb32941 --- /dev/null +++ b/tasks/agg-p05-n16-s06/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is twenty-five. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p05-n16-s06/solution/solve.sh b/tasks/agg-p05-n16-s06/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..76f263d18be7c630ea8cdb48c40d229622daaa60 --- /dev/null +++ b/tasks/agg-p05-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 '[18, 25, 33, 40, 43, 57, 66, 68, 70, 71, 79, 82, 84, 87, 93, 96]' > "$answer" diff --git a/tasks/agg-p05-n16-s06/task.toml b/tasks/agg-p05-n16-s06/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..855420e7eb1e98e9c90696018f69d24faa66da66 --- /dev/null +++ b/tasks/agg-p05-n16-s06/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p05-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 = 5 +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-p05-n16-s06/tests/expected.json b/tasks/agg-p05-n16-s06/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..1c333eefb9b09349818042b33169dd9830f21980 --- /dev/null +++ b/tasks/agg-p05-n16-s06/tests/expected.json @@ -0,0 +1 @@ +[18, 25, 33, 40, 43, 57, 66, 68, 70, 71, 79, 82, 84, 87, 93, 96] diff --git a/tasks/agg-p05-n16-s06/tests/test.sh b/tasks/agg-p05-n16-s06/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p05-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-p05-n16-s07/instruction.md b/tasks/agg-p05-n16-s07/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..a7f0266a5e6733a93cf24a409665e6e92f793dba --- /dev/null +++ b/tasks/agg-p05-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 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-p05-n16-s07/solution/solve.sh b/tasks/agg-p05-n16-s07/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..76f263d18be7c630ea8cdb48c40d229622daaa60 --- /dev/null +++ b/tasks/agg-p05-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 '[18, 25, 33, 40, 43, 57, 66, 68, 70, 71, 79, 82, 84, 87, 93, 96]' > "$answer" diff --git a/tasks/agg-p05-n16-s07/task.toml b/tasks/agg-p05-n16-s07/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..662851f2f22b1cdf0f199a698236f4f855608ec6 --- /dev/null +++ b/tasks/agg-p05-n16-s07/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p05-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 = 5 +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-p05-n16-s07/tests/expected.json b/tasks/agg-p05-n16-s07/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..1c333eefb9b09349818042b33169dd9830f21980 --- /dev/null +++ b/tasks/agg-p05-n16-s07/tests/expected.json @@ -0,0 +1 @@ +[18, 25, 33, 40, 43, 57, 66, 68, 70, 71, 79, 82, 84, 87, 93, 96] diff --git a/tasks/agg-p05-n16-s07/tests/test.sh b/tasks/agg-p05-n16-s07/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p05-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-p05-n16-s08/instruction.md b/tasks/agg-p05-n16-s08/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..7d5ca093d11da3b866f85566039dbc2ac3bc8c84 --- /dev/null +++ b/tasks/agg-p05-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 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-p05-n16-s08/solution/solve.sh b/tasks/agg-p05-n16-s08/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..76f263d18be7c630ea8cdb48c40d229622daaa60 --- /dev/null +++ b/tasks/agg-p05-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 '[18, 25, 33, 40, 43, 57, 66, 68, 70, 71, 79, 82, 84, 87, 93, 96]' > "$answer" diff --git a/tasks/agg-p05-n16-s08/task.toml b/tasks/agg-p05-n16-s08/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..3021e530d65fbf3b431485f43017955715ecd07c --- /dev/null +++ b/tasks/agg-p05-n16-s08/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p05-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 = 5 +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-p05-n16-s08/tests/expected.json b/tasks/agg-p05-n16-s08/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..1c333eefb9b09349818042b33169dd9830f21980 --- /dev/null +++ b/tasks/agg-p05-n16-s08/tests/expected.json @@ -0,0 +1 @@ +[18, 25, 33, 40, 43, 57, 66, 68, 70, 71, 79, 82, 84, 87, 93, 96]