diff --git a/tasks/agg-p22-n16-s11/tests/test.sh b/tasks/agg-p22-n16-s11/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p22-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-p22-n16-s12/instruction.md b/tasks/agg-p22-n16-s12/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..99a7f97eb2774bf91fcf02fc9e18c71f2c746d9d --- /dev/null +++ b/tasks/agg-p22-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 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-p22-n16-s12/solution/solve.sh b/tasks/agg-p22-n16-s12/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5326bdac27d4f50f8f0bb54a72794de6737875ed --- /dev/null +++ b/tasks/agg-p22-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 '[4, 5, 8, 10, 15, 22, 23, 27, 31, 41, 71, 74, 76, 77, 88, 89]' > "$answer" diff --git a/tasks/agg-p22-n16-s12/task.toml b/tasks/agg-p22-n16-s12/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..7f103a74695971416a09dadb12c822ecad68f0f5 --- /dev/null +++ b/tasks/agg-p22-n16-s12/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p22-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 = 22 +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-p22-n16-s12/tests/expected.json b/tasks/agg-p22-n16-s12/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..f1dfffe1d49a531609287e8177f9b5056d207c36 --- /dev/null +++ b/tasks/agg-p22-n16-s12/tests/expected.json @@ -0,0 +1 @@ +[4, 5, 8, 10, 15, 22, 23, 27, 31, 41, 71, 74, 76, 77, 88, 89] diff --git a/tasks/agg-p22-n16-s12/tests/test.sh b/tasks/agg-p22-n16-s12/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p22-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-p22-n16-s13/instruction.md b/tasks/agg-p22-n16-s13/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..ac5d07700d94f2ac8dcfe94fa7b7a0669218f24c --- /dev/null +++ b/tasks/agg-p22-n16-s13/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is twenty-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-p22-n16-s13/solution/solve.sh b/tasks/agg-p22-n16-s13/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5326bdac27d4f50f8f0bb54a72794de6737875ed --- /dev/null +++ b/tasks/agg-p22-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 '[4, 5, 8, 10, 15, 22, 23, 27, 31, 41, 71, 74, 76, 77, 88, 89]' > "$answer" diff --git a/tasks/agg-p22-n16-s13/task.toml b/tasks/agg-p22-n16-s13/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..83935db1115bbcdf907a3714577355f8145c8e4e --- /dev/null +++ b/tasks/agg-p22-n16-s13/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p22-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 = 22 +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-p22-n16-s13/tests/expected.json b/tasks/agg-p22-n16-s13/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..f1dfffe1d49a531609287e8177f9b5056d207c36 --- /dev/null +++ b/tasks/agg-p22-n16-s13/tests/expected.json @@ -0,0 +1 @@ +[4, 5, 8, 10, 15, 22, 23, 27, 31, 41, 71, 74, 76, 77, 88, 89] diff --git a/tasks/agg-p22-n16-s13/tests/test.sh b/tasks/agg-p22-n16-s13/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p22-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-p22-n16-s14/instruction.md b/tasks/agg-p22-n16-s14/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..f197f79da6e4638891b46f2053909c167ec13c32 --- /dev/null +++ b/tasks/agg-p22-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 eighty-eight. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p22-n16-s14/solution/solve.sh b/tasks/agg-p22-n16-s14/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5326bdac27d4f50f8f0bb54a72794de6737875ed --- /dev/null +++ b/tasks/agg-p22-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 '[4, 5, 8, 10, 15, 22, 23, 27, 31, 41, 71, 74, 76, 77, 88, 89]' > "$answer" diff --git a/tasks/agg-p22-n16-s14/task.toml b/tasks/agg-p22-n16-s14/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..dbe550754021b57af1a12ff388390f8c82d5d01f --- /dev/null +++ b/tasks/agg-p22-n16-s14/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p22-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 = 22 +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-p22-n16-s14/tests/expected.json b/tasks/agg-p22-n16-s14/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..f1dfffe1d49a531609287e8177f9b5056d207c36 --- /dev/null +++ b/tasks/agg-p22-n16-s14/tests/expected.json @@ -0,0 +1 @@ +[4, 5, 8, 10, 15, 22, 23, 27, 31, 41, 71, 74, 76, 77, 88, 89] diff --git a/tasks/agg-p22-n16-s14/tests/test.sh b/tasks/agg-p22-n16-s14/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p22-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-p22-n16-s15/instruction.md b/tasks/agg-p22-n16-s15/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..1fc02ff38c01961e6ef2d04b50e560edacdcca90 --- /dev/null +++ b/tasks/agg-p22-n16-s15/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is seventy-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-p22-n16-s15/solution/solve.sh b/tasks/agg-p22-n16-s15/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5326bdac27d4f50f8f0bb54a72794de6737875ed --- /dev/null +++ b/tasks/agg-p22-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 '[4, 5, 8, 10, 15, 22, 23, 27, 31, 41, 71, 74, 76, 77, 88, 89]' > "$answer" diff --git a/tasks/agg-p22-n16-s15/task.toml b/tasks/agg-p22-n16-s15/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..757fa3ccb5d7141e5b9a6ae2fe9aea3902f3b1ba --- /dev/null +++ b/tasks/agg-p22-n16-s15/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p22-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 = 22 +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-p22-n16-s15/tests/expected.json b/tasks/agg-p22-n16-s15/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..f1dfffe1d49a531609287e8177f9b5056d207c36 --- /dev/null +++ b/tasks/agg-p22-n16-s15/tests/expected.json @@ -0,0 +1 @@ +[4, 5, 8, 10, 15, 22, 23, 27, 31, 41, 71, 74, 76, 77, 88, 89] diff --git a/tasks/agg-p22-n16-s15/tests/test.sh b/tasks/agg-p22-n16-s15/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p22-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-p22-n16-s16/instruction.md b/tasks/agg-p22-n16-s16/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..3a10e21a080f18532e8e18935bc65496e13588a2 --- /dev/null +++ b/tasks/agg-p22-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-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-p22-n16-s16/solution/solve.sh b/tasks/agg-p22-n16-s16/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5326bdac27d4f50f8f0bb54a72794de6737875ed --- /dev/null +++ b/tasks/agg-p22-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 '[4, 5, 8, 10, 15, 22, 23, 27, 31, 41, 71, 74, 76, 77, 88, 89]' > "$answer" diff --git a/tasks/agg-p22-n16-s16/task.toml b/tasks/agg-p22-n16-s16/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..d9f56510f985a1f0e8fbcd747e0e1dabdf0360d4 --- /dev/null +++ b/tasks/agg-p22-n16-s16/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p22-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 = 22 +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-p22-n16-s16/tests/expected.json b/tasks/agg-p22-n16-s16/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..f1dfffe1d49a531609287e8177f9b5056d207c36 --- /dev/null +++ b/tasks/agg-p22-n16-s16/tests/expected.json @@ -0,0 +1 @@ +[4, 5, 8, 10, 15, 22, 23, 27, 31, 41, 71, 74, 76, 77, 88, 89] diff --git a/tasks/agg-p22-n16-s16/tests/test.sh b/tasks/agg-p22-n16-s16/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p22-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-p23-n01-s01/instruction.md b/tasks/agg-p23-n01-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..41840c642bc983f3cbf2f4761e194e96c0777a45 --- /dev/null +++ b/tasks/agg-p23-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 twenty. + +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-p23-n01-s01/solution/solve.sh b/tasks/agg-p23-n01-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..634de106b1c3454ddd0dffcbaee1c022f7709864 --- /dev/null +++ b/tasks/agg-p23-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 '[20]' > "$answer" diff --git a/tasks/agg-p23-n01-s01/task.toml b/tasks/agg-p23-n01-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..2c1ba7df62d3aeab35a5e10461a395148aca00e6 --- /dev/null +++ b/tasks/agg-p23-n01-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p23-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 = 23 +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-p23-n01-s01/tests/expected.json b/tasks/agg-p23-n01-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..2f6e7a62404fd23a99bd593d54371ad0e99eab90 --- /dev/null +++ b/tasks/agg-p23-n01-s01/tests/expected.json @@ -0,0 +1 @@ +[20] diff --git a/tasks/agg-p23-n01-s01/tests/test.sh b/tasks/agg-p23-n01-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p23-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-p23-n02-s01/instruction.md b/tasks/agg-p23-n02-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..01155853905e7076e6da8ca45112bae47f6ac2c2 --- /dev/null +++ b/tasks/agg-p23-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 twenty. + +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-p23-n02-s01/solution/solve.sh b/tasks/agg-p23-n02-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f8abcd3bf694c2c4ed964d96ab8d1dce68e85607 --- /dev/null +++ b/tasks/agg-p23-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 '[20, 55]' > "$answer" diff --git a/tasks/agg-p23-n02-s01/task.toml b/tasks/agg-p23-n02-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..f1787d30120102ab892a14a96f3687c574b7a2e2 --- /dev/null +++ b/tasks/agg-p23-n02-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p23-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 = 23 +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-p23-n02-s01/tests/expected.json b/tasks/agg-p23-n02-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..42116719ac2dea49c2f4cbbfc161333c8a1b6efd --- /dev/null +++ b/tasks/agg-p23-n02-s01/tests/expected.json @@ -0,0 +1 @@ +[20, 55] diff --git a/tasks/agg-p23-n02-s01/tests/test.sh b/tasks/agg-p23-n02-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p23-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-p23-n02-s02/instruction.md b/tasks/agg-p23-n02-s02/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..c8fe5b794a826219ab972453490a4eb90154d01f --- /dev/null +++ b/tasks/agg-p23-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 fifty-five. + +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-p23-n02-s02/solution/solve.sh b/tasks/agg-p23-n02-s02/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f8abcd3bf694c2c4ed964d96ab8d1dce68e85607 --- /dev/null +++ b/tasks/agg-p23-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 '[20, 55]' > "$answer" diff --git a/tasks/agg-p23-n02-s02/task.toml b/tasks/agg-p23-n02-s02/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..6dfe2d0093893608cb92bb5e29c97148d792d4fb --- /dev/null +++ b/tasks/agg-p23-n02-s02/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p23-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 = 23 +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-p23-n02-s02/tests/expected.json b/tasks/agg-p23-n02-s02/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..42116719ac2dea49c2f4cbbfc161333c8a1b6efd --- /dev/null +++ b/tasks/agg-p23-n02-s02/tests/expected.json @@ -0,0 +1 @@ +[20, 55] diff --git a/tasks/agg-p23-n02-s02/tests/test.sh b/tasks/agg-p23-n02-s02/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p23-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-p23-n04-s01/instruction.md b/tasks/agg-p23-n04-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..862177065dd1207d2cfdca97cd16d4c00c321796 --- /dev/null +++ b/tasks/agg-p23-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 twenty. + +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-p23-n04-s01/solution/solve.sh b/tasks/agg-p23-n04-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3a6b3b52c1f096bc5fc425aa49fc9a56123ac38a --- /dev/null +++ b/tasks/agg-p23-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 '[1, 20, 45, 55]' > "$answer" diff --git a/tasks/agg-p23-n04-s01/task.toml b/tasks/agg-p23-n04-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..06781b8697ffe3fcda883ed51f6002451c39583b --- /dev/null +++ b/tasks/agg-p23-n04-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p23-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 = 23 +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-p23-n04-s01/tests/expected.json b/tasks/agg-p23-n04-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e2143f92b768e31ad3de3d168e191a7108207ec1 --- /dev/null +++ b/tasks/agg-p23-n04-s01/tests/expected.json @@ -0,0 +1 @@ +[1, 20, 45, 55] diff --git a/tasks/agg-p23-n04-s01/tests/test.sh b/tasks/agg-p23-n04-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p23-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-p23-n04-s02/instruction.md b/tasks/agg-p23-n04-s02/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..8024176648825a47cbe8613c954735752817a951 --- /dev/null +++ b/tasks/agg-p23-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-five. + +The team must find all 4 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 4 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p23-n04-s02/solution/solve.sh b/tasks/agg-p23-n04-s02/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3a6b3b52c1f096bc5fc425aa49fc9a56123ac38a --- /dev/null +++ b/tasks/agg-p23-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 '[1, 20, 45, 55]' > "$answer" diff --git a/tasks/agg-p23-n04-s02/task.toml b/tasks/agg-p23-n04-s02/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..f86a7123ef257404f6a7a5d4a744e64b8617f6e8 --- /dev/null +++ b/tasks/agg-p23-n04-s02/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p23-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 = 23 +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-p23-n04-s02/tests/expected.json b/tasks/agg-p23-n04-s02/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e2143f92b768e31ad3de3d168e191a7108207ec1 --- /dev/null +++ b/tasks/agg-p23-n04-s02/tests/expected.json @@ -0,0 +1 @@ +[1, 20, 45, 55] diff --git a/tasks/agg-p23-n04-s02/tests/test.sh b/tasks/agg-p23-n04-s02/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p23-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-p23-n04-s03/instruction.md b/tasks/agg-p23-n04-s03/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..57844953b25edf19db718990c35fe23e43f95f7a --- /dev/null +++ b/tasks/agg-p23-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-five. + +The team must find all 4 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 4 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p23-n04-s03/solution/solve.sh b/tasks/agg-p23-n04-s03/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3a6b3b52c1f096bc5fc425aa49fc9a56123ac38a --- /dev/null +++ b/tasks/agg-p23-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 '[1, 20, 45, 55]' > "$answer" diff --git a/tasks/agg-p23-n04-s03/task.toml b/tasks/agg-p23-n04-s03/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..ab089a7e9484ab66b50b7f372ee63ec0e7957bf7 --- /dev/null +++ b/tasks/agg-p23-n04-s03/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p23-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 = 23 +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-p23-n04-s03/tests/expected.json b/tasks/agg-p23-n04-s03/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e2143f92b768e31ad3de3d168e191a7108207ec1 --- /dev/null +++ b/tasks/agg-p23-n04-s03/tests/expected.json @@ -0,0 +1 @@ +[1, 20, 45, 55] diff --git a/tasks/agg-p23-n04-s03/tests/test.sh b/tasks/agg-p23-n04-s03/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p23-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-p23-n04-s04/instruction.md b/tasks/agg-p23-n04-s04/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..c9fc0cd60b16983bf7800f77c47afe49f90d719e --- /dev/null +++ b/tasks/agg-p23-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 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-p23-n04-s04/solution/solve.sh b/tasks/agg-p23-n04-s04/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3a6b3b52c1f096bc5fc425aa49fc9a56123ac38a --- /dev/null +++ b/tasks/agg-p23-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 '[1, 20, 45, 55]' > "$answer" diff --git a/tasks/agg-p23-n04-s04/task.toml b/tasks/agg-p23-n04-s04/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..ff4eb5265e25b00aa6ea292fa81724779b3f734e --- /dev/null +++ b/tasks/agg-p23-n04-s04/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p23-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 = 23 +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-p23-n04-s04/tests/expected.json b/tasks/agg-p23-n04-s04/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e2143f92b768e31ad3de3d168e191a7108207ec1 --- /dev/null +++ b/tasks/agg-p23-n04-s04/tests/expected.json @@ -0,0 +1 @@ +[1, 20, 45, 55] diff --git a/tasks/agg-p23-n04-s04/tests/test.sh b/tasks/agg-p23-n04-s04/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p23-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-p23-n08-s01/instruction.md b/tasks/agg-p23-n08-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..45eef35ac00156eccf1849f3e7ce1978b9164536 --- /dev/null +++ b/tasks/agg-p23-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 twenty. + +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-p23-n08-s01/solution/solve.sh b/tasks/agg-p23-n08-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c94b622afc835393f4e8c1c9539254251dc571e9 --- /dev/null +++ b/tasks/agg-p23-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 '[1, 20, 30, 45, 55, 79, 81, 84]' > "$answer" diff --git a/tasks/agg-p23-n08-s01/task.toml b/tasks/agg-p23-n08-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..eec246822e7470d233fd3a1b708b5a9dec794728 --- /dev/null +++ b/tasks/agg-p23-n08-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p23-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 = 23 +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-p23-n08-s01/tests/expected.json b/tasks/agg-p23-n08-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e6aeb10d434a656d42907f64c4695dfd40536548 --- /dev/null +++ b/tasks/agg-p23-n08-s01/tests/expected.json @@ -0,0 +1 @@ +[1, 20, 30, 45, 55, 79, 81, 84] diff --git a/tasks/agg-p23-n08-s01/tests/test.sh b/tasks/agg-p23-n08-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p23-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-p23-n08-s02/instruction.md b/tasks/agg-p23-n08-s02/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..868a3b2d9b0dd94351f381b43ce54f12af196c62 --- /dev/null +++ b/tasks/agg-p23-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-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-p23-n08-s02/solution/solve.sh b/tasks/agg-p23-n08-s02/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c94b622afc835393f4e8c1c9539254251dc571e9 --- /dev/null +++ b/tasks/agg-p23-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 '[1, 20, 30, 45, 55, 79, 81, 84]' > "$answer" diff --git a/tasks/agg-p23-n08-s02/task.toml b/tasks/agg-p23-n08-s02/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..d4ae8e7c7db446e7ff51af0207c8a7b47b2a9826 --- /dev/null +++ b/tasks/agg-p23-n08-s02/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p23-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 = 23 +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-p23-n08-s02/tests/expected.json b/tasks/agg-p23-n08-s02/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e6aeb10d434a656d42907f64c4695dfd40536548 --- /dev/null +++ b/tasks/agg-p23-n08-s02/tests/expected.json @@ -0,0 +1 @@ +[1, 20, 30, 45, 55, 79, 81, 84] diff --git a/tasks/agg-p23-n08-s02/tests/test.sh b/tasks/agg-p23-n08-s02/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p23-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-p23-n08-s03/instruction.md b/tasks/agg-p23-n08-s03/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..a3ced584309e5034e6a9df4caf622b2a0502c9a5 --- /dev/null +++ b/tasks/agg-p23-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-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-p23-n08-s03/solution/solve.sh b/tasks/agg-p23-n08-s03/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c94b622afc835393f4e8c1c9539254251dc571e9 --- /dev/null +++ b/tasks/agg-p23-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 '[1, 20, 30, 45, 55, 79, 81, 84]' > "$answer" diff --git a/tasks/agg-p23-n08-s03/task.toml b/tasks/agg-p23-n08-s03/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..650df439567f7db38b313952f6c9097e7f3e07bb --- /dev/null +++ b/tasks/agg-p23-n08-s03/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p23-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 = 23 +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-p23-n08-s03/tests/expected.json b/tasks/agg-p23-n08-s03/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e6aeb10d434a656d42907f64c4695dfd40536548 --- /dev/null +++ b/tasks/agg-p23-n08-s03/tests/expected.json @@ -0,0 +1 @@ +[1, 20, 30, 45, 55, 79, 81, 84] diff --git a/tasks/agg-p23-n08-s03/tests/test.sh b/tasks/agg-p23-n08-s03/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p23-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-p23-n08-s04/instruction.md b/tasks/agg-p23-n08-s04/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..e45426f396d954e1affff91de56f66666add7d1c --- /dev/null +++ b/tasks/agg-p23-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 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-p23-n08-s04/solution/solve.sh b/tasks/agg-p23-n08-s04/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c94b622afc835393f4e8c1c9539254251dc571e9 --- /dev/null +++ b/tasks/agg-p23-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 '[1, 20, 30, 45, 55, 79, 81, 84]' > "$answer" diff --git a/tasks/agg-p23-n08-s04/task.toml b/tasks/agg-p23-n08-s04/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..69a8e575072aba9b092a3a820ea783f711fef720 --- /dev/null +++ b/tasks/agg-p23-n08-s04/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p23-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 = 23 +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-p23-n08-s04/tests/expected.json b/tasks/agg-p23-n08-s04/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e6aeb10d434a656d42907f64c4695dfd40536548 --- /dev/null +++ b/tasks/agg-p23-n08-s04/tests/expected.json @@ -0,0 +1 @@ +[1, 20, 30, 45, 55, 79, 81, 84] diff --git a/tasks/agg-p23-n08-s04/tests/test.sh b/tasks/agg-p23-n08-s04/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p23-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-p23-n08-s05/instruction.md b/tasks/agg-p23-n08-s05/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..6662e6911ad1105e195cbc6e76b3cc8d9854bef3 --- /dev/null +++ b/tasks/agg-p23-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 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-p23-n08-s05/solution/solve.sh b/tasks/agg-p23-n08-s05/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c94b622afc835393f4e8c1c9539254251dc571e9 --- /dev/null +++ b/tasks/agg-p23-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 '[1, 20, 30, 45, 55, 79, 81, 84]' > "$answer" diff --git a/tasks/agg-p23-n08-s05/task.toml b/tasks/agg-p23-n08-s05/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..00b36393ad977f954aa1262fb50d166e075f8ac4 --- /dev/null +++ b/tasks/agg-p23-n08-s05/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p23-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 = 23 +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-p23-n08-s05/tests/expected.json b/tasks/agg-p23-n08-s05/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e6aeb10d434a656d42907f64c4695dfd40536548 --- /dev/null +++ b/tasks/agg-p23-n08-s05/tests/expected.json @@ -0,0 +1 @@ +[1, 20, 30, 45, 55, 79, 81, 84] diff --git a/tasks/agg-p23-n08-s05/tests/test.sh b/tasks/agg-p23-n08-s05/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p23-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-p23-n08-s06/instruction.md b/tasks/agg-p23-n08-s06/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..2af66d24dc696b132e6fd3eda0188f7a40c90b60 --- /dev/null +++ b/tasks/agg-p23-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 eighty-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-p23-n08-s06/solution/solve.sh b/tasks/agg-p23-n08-s06/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c94b622afc835393f4e8c1c9539254251dc571e9 --- /dev/null +++ b/tasks/agg-p23-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 '[1, 20, 30, 45, 55, 79, 81, 84]' > "$answer" diff --git a/tasks/agg-p23-n08-s06/task.toml b/tasks/agg-p23-n08-s06/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..8c8be08db5508208c36dccc702969c07e0348886 --- /dev/null +++ b/tasks/agg-p23-n08-s06/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p23-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 = 23 +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-p23-n08-s06/tests/expected.json b/tasks/agg-p23-n08-s06/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e6aeb10d434a656d42907f64c4695dfd40536548 --- /dev/null +++ b/tasks/agg-p23-n08-s06/tests/expected.json @@ -0,0 +1 @@ +[1, 20, 30, 45, 55, 79, 81, 84] diff --git a/tasks/agg-p23-n08-s06/tests/test.sh b/tasks/agg-p23-n08-s06/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p23-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-p23-n08-s07/instruction.md b/tasks/agg-p23-n08-s07/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..aad332f1fb6e8e8c81b09b86bbbdb88e339f2b43 --- /dev/null +++ b/tasks/agg-p23-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 thirty. + +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-p23-n08-s07/solution/solve.sh b/tasks/agg-p23-n08-s07/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c94b622afc835393f4e8c1c9539254251dc571e9 --- /dev/null +++ b/tasks/agg-p23-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 '[1, 20, 30, 45, 55, 79, 81, 84]' > "$answer" diff --git a/tasks/agg-p23-n08-s07/task.toml b/tasks/agg-p23-n08-s07/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..5c1117229f8d2dc8e9119b5938d2b2e3eae30e82 --- /dev/null +++ b/tasks/agg-p23-n08-s07/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p23-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 = 23 +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-p23-n08-s07/tests/expected.json b/tasks/agg-p23-n08-s07/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e6aeb10d434a656d42907f64c4695dfd40536548 --- /dev/null +++ b/tasks/agg-p23-n08-s07/tests/expected.json @@ -0,0 +1 @@ +[1, 20, 30, 45, 55, 79, 81, 84] diff --git a/tasks/agg-p23-n08-s07/tests/test.sh b/tasks/agg-p23-n08-s07/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p23-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-p23-n08-s08/instruction.md b/tasks/agg-p23-n08-s08/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..d356bb5ea0ea3378245500692d3d1b5cb41a9db4 --- /dev/null +++ b/tasks/agg-p23-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 seventy-nine. + +The team must find all 8 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 8 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p23-n08-s08/solution/solve.sh b/tasks/agg-p23-n08-s08/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c94b622afc835393f4e8c1c9539254251dc571e9 --- /dev/null +++ b/tasks/agg-p23-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 '[1, 20, 30, 45, 55, 79, 81, 84]' > "$answer" diff --git a/tasks/agg-p23-n08-s08/task.toml b/tasks/agg-p23-n08-s08/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..c0499b9652a8e6b53a84a529c2a31439b330306e --- /dev/null +++ b/tasks/agg-p23-n08-s08/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p23-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 = 23 +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-p23-n08-s08/tests/expected.json b/tasks/agg-p23-n08-s08/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e6aeb10d434a656d42907f64c4695dfd40536548 --- /dev/null +++ b/tasks/agg-p23-n08-s08/tests/expected.json @@ -0,0 +1 @@ +[1, 20, 30, 45, 55, 79, 81, 84] diff --git a/tasks/agg-p23-n08-s08/tests/test.sh b/tasks/agg-p23-n08-s08/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p23-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-p23-n16-s01/instruction.md b/tasks/agg-p23-n16-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..81577d14ed82fb21b17e0bd51c9dc2a594f0c1b6 --- /dev/null +++ b/tasks/agg-p23-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 twenty. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p23-n16-s01/solution/solve.sh b/tasks/agg-p23-n16-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0fe85c5005bfb3fb5f503913158eb430478b4ef9 --- /dev/null +++ b/tasks/agg-p23-n16-s01/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[1, 3, 7, 16, 20, 30, 35, 45, 51, 52, 55, 69, 79, 81, 84, 96]' > "$answer" diff --git a/tasks/agg-p23-n16-s01/task.toml b/tasks/agg-p23-n16-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..f25b133d5d29865c3fabb6a203c7277c61057b4d --- /dev/null +++ b/tasks/agg-p23-n16-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p23-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 = 23 +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-p23-n16-s01/tests/expected.json b/tasks/agg-p23-n16-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..c3a941386d4fd31d1d4404a0d80d94e09fbdaf69 --- /dev/null +++ b/tasks/agg-p23-n16-s01/tests/expected.json @@ -0,0 +1 @@ +[1, 3, 7, 16, 20, 30, 35, 45, 51, 52, 55, 69, 79, 81, 84, 96] diff --git a/tasks/agg-p23-n16-s01/tests/test.sh b/tasks/agg-p23-n16-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p23-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-p23-n16-s02/instruction.md b/tasks/agg-p23-n16-s02/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..f686b37d9314f1cebdb92d8ccf24f99b41852805 --- /dev/null +++ b/tasks/agg-p23-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-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-p23-n16-s02/solution/solve.sh b/tasks/agg-p23-n16-s02/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0fe85c5005bfb3fb5f503913158eb430478b4ef9 --- /dev/null +++ b/tasks/agg-p23-n16-s02/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[1, 3, 7, 16, 20, 30, 35, 45, 51, 52, 55, 69, 79, 81, 84, 96]' > "$answer" diff --git a/tasks/agg-p23-n16-s02/task.toml b/tasks/agg-p23-n16-s02/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..a4ac6daa263b17eb8cfec7e577520347a831680d --- /dev/null +++ b/tasks/agg-p23-n16-s02/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p23-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 = 23 +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-p23-n16-s02/tests/expected.json b/tasks/agg-p23-n16-s02/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..c3a941386d4fd31d1d4404a0d80d94e09fbdaf69 --- /dev/null +++ b/tasks/agg-p23-n16-s02/tests/expected.json @@ -0,0 +1 @@ +[1, 3, 7, 16, 20, 30, 35, 45, 51, 52, 55, 69, 79, 81, 84, 96] diff --git a/tasks/agg-p23-n16-s02/tests/test.sh b/tasks/agg-p23-n16-s02/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p23-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-p23-n16-s03/instruction.md b/tasks/agg-p23-n16-s03/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..03acbc08880291cf4dacc5df318650e9c8d0e519 --- /dev/null +++ b/tasks/agg-p23-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-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-p23-n16-s03/solution/solve.sh b/tasks/agg-p23-n16-s03/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0fe85c5005bfb3fb5f503913158eb430478b4ef9 --- /dev/null +++ b/tasks/agg-p23-n16-s03/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[1, 3, 7, 16, 20, 30, 35, 45, 51, 52, 55, 69, 79, 81, 84, 96]' > "$answer" diff --git a/tasks/agg-p23-n16-s03/task.toml b/tasks/agg-p23-n16-s03/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..defabe5146a2e55a00f375c23c348a16210fa577 --- /dev/null +++ b/tasks/agg-p23-n16-s03/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p23-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 = 23 +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-p23-n16-s03/tests/expected.json b/tasks/agg-p23-n16-s03/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..c3a941386d4fd31d1d4404a0d80d94e09fbdaf69 --- /dev/null +++ b/tasks/agg-p23-n16-s03/tests/expected.json @@ -0,0 +1 @@ +[1, 3, 7, 16, 20, 30, 35, 45, 51, 52, 55, 69, 79, 81, 84, 96] diff --git a/tasks/agg-p23-n16-s03/tests/test.sh b/tasks/agg-p23-n16-s03/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p23-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-p23-n16-s04/instruction.md b/tasks/agg-p23-n16-s04/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..1a86ea7323aad3c91f00b65904f038f7e58f852d --- /dev/null +++ b/tasks/agg-p23-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 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-p23-n16-s04/solution/solve.sh b/tasks/agg-p23-n16-s04/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0fe85c5005bfb3fb5f503913158eb430478b4ef9 --- /dev/null +++ b/tasks/agg-p23-n16-s04/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[1, 3, 7, 16, 20, 30, 35, 45, 51, 52, 55, 69, 79, 81, 84, 96]' > "$answer" diff --git a/tasks/agg-p23-n16-s04/task.toml b/tasks/agg-p23-n16-s04/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..ce9ab751d287b58a4488c915e1d52a8b8c0bebda --- /dev/null +++ b/tasks/agg-p23-n16-s04/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p23-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 = 23 +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-p23-n16-s04/tests/expected.json b/tasks/agg-p23-n16-s04/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..c3a941386d4fd31d1d4404a0d80d94e09fbdaf69 --- /dev/null +++ b/tasks/agg-p23-n16-s04/tests/expected.json @@ -0,0 +1 @@ +[1, 3, 7, 16, 20, 30, 35, 45, 51, 52, 55, 69, 79, 81, 84, 96] diff --git a/tasks/agg-p23-n16-s04/tests/test.sh b/tasks/agg-p23-n16-s04/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p23-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-p23-n16-s05/instruction.md b/tasks/agg-p23-n16-s05/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..7d5ca093d11da3b866f85566039dbc2ac3bc8c84 --- /dev/null +++ b/tasks/agg-p23-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 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-p23-n16-s05/solution/solve.sh b/tasks/agg-p23-n16-s05/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0fe85c5005bfb3fb5f503913158eb430478b4ef9 --- /dev/null +++ b/tasks/agg-p23-n16-s05/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[1, 3, 7, 16, 20, 30, 35, 45, 51, 52, 55, 69, 79, 81, 84, 96]' > "$answer" diff --git a/tasks/agg-p23-n16-s05/task.toml b/tasks/agg-p23-n16-s05/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..7bfd8cd3a55ff5c59fad107227c3063a8a8be3cd --- /dev/null +++ b/tasks/agg-p23-n16-s05/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p23-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 = 23 +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-p23-n16-s05/tests/expected.json b/tasks/agg-p23-n16-s05/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..c3a941386d4fd31d1d4404a0d80d94e09fbdaf69 --- /dev/null +++ b/tasks/agg-p23-n16-s05/tests/expected.json @@ -0,0 +1 @@ +[1, 3, 7, 16, 20, 30, 35, 45, 51, 52, 55, 69, 79, 81, 84, 96] diff --git a/tasks/agg-p23-n16-s05/tests/test.sh b/tasks/agg-p23-n16-s05/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p23-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-p23-n16-s06/instruction.md b/tasks/agg-p23-n16-s06/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..be22dd060dc917313859b782fc59371588c6eefe --- /dev/null +++ b/tasks/agg-p23-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 eighty-one. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p23-n16-s06/solution/solve.sh b/tasks/agg-p23-n16-s06/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0fe85c5005bfb3fb5f503913158eb430478b4ef9 --- /dev/null +++ b/tasks/agg-p23-n16-s06/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[1, 3, 7, 16, 20, 30, 35, 45, 51, 52, 55, 69, 79, 81, 84, 96]' > "$answer" diff --git a/tasks/agg-p23-n16-s06/task.toml b/tasks/agg-p23-n16-s06/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..2f0469fd279cc8be360a7755ba059c7f58f0664d --- /dev/null +++ b/tasks/agg-p23-n16-s06/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p23-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 = 23 +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-p23-n16-s06/tests/expected.json b/tasks/agg-p23-n16-s06/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..c3a941386d4fd31d1d4404a0d80d94e09fbdaf69 --- /dev/null +++ b/tasks/agg-p23-n16-s06/tests/expected.json @@ -0,0 +1 @@ +[1, 3, 7, 16, 20, 30, 35, 45, 51, 52, 55, 69, 79, 81, 84, 96] diff --git a/tasks/agg-p23-n16-s06/tests/test.sh b/tasks/agg-p23-n16-s06/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p23-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-p23-n16-s07/instruction.md b/tasks/agg-p23-n16-s07/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..6b3716855407e49bd1a2d27bc51b41f58fa7bb68 --- /dev/null +++ b/tasks/agg-p23-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 thirty. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p23-n16-s07/solution/solve.sh b/tasks/agg-p23-n16-s07/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0fe85c5005bfb3fb5f503913158eb430478b4ef9 --- /dev/null +++ b/tasks/agg-p23-n16-s07/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[1, 3, 7, 16, 20, 30, 35, 45, 51, 52, 55, 69, 79, 81, 84, 96]' > "$answer" diff --git a/tasks/agg-p23-n16-s07/task.toml b/tasks/agg-p23-n16-s07/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..4ac9c95299d4446392852b59cca26eda22f47448 --- /dev/null +++ b/tasks/agg-p23-n16-s07/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p23-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 = 23 +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-p23-n16-s07/tests/expected.json b/tasks/agg-p23-n16-s07/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..c3a941386d4fd31d1d4404a0d80d94e09fbdaf69 --- /dev/null +++ b/tasks/agg-p23-n16-s07/tests/expected.json @@ -0,0 +1 @@ +[1, 3, 7, 16, 20, 30, 35, 45, 51, 52, 55, 69, 79, 81, 84, 96] diff --git a/tasks/agg-p23-n16-s07/tests/test.sh b/tasks/agg-p23-n16-s07/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p23-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-p23-n16-s08/instruction.md b/tasks/agg-p23-n16-s08/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..f9807e3dca090e22409202efda192d4a7b9f5ac5 --- /dev/null +++ b/tasks/agg-p23-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 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-p23-n16-s08/solution/solve.sh b/tasks/agg-p23-n16-s08/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0fe85c5005bfb3fb5f503913158eb430478b4ef9 --- /dev/null +++ b/tasks/agg-p23-n16-s08/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[1, 3, 7, 16, 20, 30, 35, 45, 51, 52, 55, 69, 79, 81, 84, 96]' > "$answer" diff --git a/tasks/agg-p23-n16-s08/task.toml b/tasks/agg-p23-n16-s08/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..bdfe2b9a254d8b6bc7004c77b30363def2d2932a --- /dev/null +++ b/tasks/agg-p23-n16-s08/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p23-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 = 23 +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-p23-n16-s08/tests/expected.json b/tasks/agg-p23-n16-s08/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..c3a941386d4fd31d1d4404a0d80d94e09fbdaf69 --- /dev/null +++ b/tasks/agg-p23-n16-s08/tests/expected.json @@ -0,0 +1 @@ +[1, 3, 7, 16, 20, 30, 35, 45, 51, 52, 55, 69, 79, 81, 84, 96] diff --git a/tasks/agg-p23-n16-s08/tests/test.sh b/tasks/agg-p23-n16-s08/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p23-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-p23-n16-s09/instruction.md b/tasks/agg-p23-n16-s09/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..fb03ade0279ecf776a2ba0e785bd133ee36ecac6 --- /dev/null +++ b/tasks/agg-p23-n16-s09/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is fifty-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-p23-n16-s09/solution/solve.sh b/tasks/agg-p23-n16-s09/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0fe85c5005bfb3fb5f503913158eb430478b4ef9 --- /dev/null +++ b/tasks/agg-p23-n16-s09/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[1, 3, 7, 16, 20, 30, 35, 45, 51, 52, 55, 69, 79, 81, 84, 96]' > "$answer" diff --git a/tasks/agg-p23-n16-s09/task.toml b/tasks/agg-p23-n16-s09/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..a8c5aba72d440567e5eea4085415e8eff51d32b9 --- /dev/null +++ b/tasks/agg-p23-n16-s09/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p23-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 = 23 +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-p23-n16-s09/tests/expected.json b/tasks/agg-p23-n16-s09/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..c3a941386d4fd31d1d4404a0d80d94e09fbdaf69 --- /dev/null +++ b/tasks/agg-p23-n16-s09/tests/expected.json @@ -0,0 +1 @@ +[1, 3, 7, 16, 20, 30, 35, 45, 51, 52, 55, 69, 79, 81, 84, 96] diff --git a/tasks/agg-p23-n16-s09/tests/test.sh b/tasks/agg-p23-n16-s09/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p23-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-p23-n16-s10/instruction.md b/tasks/agg-p23-n16-s10/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..5c5d544b57ab574592871eba4a9cf1c900af41ae --- /dev/null +++ b/tasks/agg-p23-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 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-p23-n16-s10/solution/solve.sh b/tasks/agg-p23-n16-s10/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0fe85c5005bfb3fb5f503913158eb430478b4ef9 --- /dev/null +++ b/tasks/agg-p23-n16-s10/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[1, 3, 7, 16, 20, 30, 35, 45, 51, 52, 55, 69, 79, 81, 84, 96]' > "$answer" diff --git a/tasks/agg-p23-n16-s10/task.toml b/tasks/agg-p23-n16-s10/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..9d2398050a09ac8db06c92c7b8754caaed2539cb --- /dev/null +++ b/tasks/agg-p23-n16-s10/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p23-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 = 23 +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-p23-n16-s10/tests/expected.json b/tasks/agg-p23-n16-s10/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..c3a941386d4fd31d1d4404a0d80d94e09fbdaf69 --- /dev/null +++ b/tasks/agg-p23-n16-s10/tests/expected.json @@ -0,0 +1 @@ +[1, 3, 7, 16, 20, 30, 35, 45, 51, 52, 55, 69, 79, 81, 84, 96] diff --git a/tasks/agg-p23-n16-s10/tests/test.sh b/tasks/agg-p23-n16-s10/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p23-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-p23-n16-s11/instruction.md b/tasks/agg-p23-n16-s11/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..8e668cd99b85cf802939dffe8e766b769fcc702e --- /dev/null +++ b/tasks/agg-p23-n16-s11/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is sixteen. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p23-n16-s11/solution/solve.sh b/tasks/agg-p23-n16-s11/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0fe85c5005bfb3fb5f503913158eb430478b4ef9 --- /dev/null +++ b/tasks/agg-p23-n16-s11/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[1, 3, 7, 16, 20, 30, 35, 45, 51, 52, 55, 69, 79, 81, 84, 96]' > "$answer" diff --git a/tasks/agg-p23-n16-s11/task.toml b/tasks/agg-p23-n16-s11/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..d0cac7b6c3cae82cfbe00c25657bc61c856ed96e --- /dev/null +++ b/tasks/agg-p23-n16-s11/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p23-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 = 23 +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-p23-n16-s11/tests/expected.json b/tasks/agg-p23-n16-s11/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..c3a941386d4fd31d1d4404a0d80d94e09fbdaf69 --- /dev/null +++ b/tasks/agg-p23-n16-s11/tests/expected.json @@ -0,0 +1 @@ +[1, 3, 7, 16, 20, 30, 35, 45, 51, 52, 55, 69, 79, 81, 84, 96] diff --git a/tasks/agg-p23-n16-s11/tests/test.sh b/tasks/agg-p23-n16-s11/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p23-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-p23-n16-s12/instruction.md b/tasks/agg-p23-n16-s12/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..7db3d283effcee2e29406da16a63a785bcffa3f6 --- /dev/null +++ b/tasks/agg-p23-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 sixty-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-p23-n16-s12/solution/solve.sh b/tasks/agg-p23-n16-s12/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0fe85c5005bfb3fb5f503913158eb430478b4ef9 --- /dev/null +++ b/tasks/agg-p23-n16-s12/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[1, 3, 7, 16, 20, 30, 35, 45, 51, 52, 55, 69, 79, 81, 84, 96]' > "$answer" diff --git a/tasks/agg-p23-n16-s12/task.toml b/tasks/agg-p23-n16-s12/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..ac5359186631d890e0ad9bb7c1066c43263792c7 --- /dev/null +++ b/tasks/agg-p23-n16-s12/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p23-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 = 23 +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-p23-n16-s12/tests/expected.json b/tasks/agg-p23-n16-s12/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..c3a941386d4fd31d1d4404a0d80d94e09fbdaf69 --- /dev/null +++ b/tasks/agg-p23-n16-s12/tests/expected.json @@ -0,0 +1 @@ +[1, 3, 7, 16, 20, 30, 35, 45, 51, 52, 55, 69, 79, 81, 84, 96] diff --git a/tasks/agg-p23-n16-s12/tests/test.sh b/tasks/agg-p23-n16-s12/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p23-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-p23-n16-s13/instruction.md b/tasks/agg-p23-n16-s13/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..6d104365f5a2f721f3137e68a5cce07413cc5159 --- /dev/null +++ b/tasks/agg-p23-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 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-p23-n16-s13/solution/solve.sh b/tasks/agg-p23-n16-s13/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0fe85c5005bfb3fb5f503913158eb430478b4ef9 --- /dev/null +++ b/tasks/agg-p23-n16-s13/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[1, 3, 7, 16, 20, 30, 35, 45, 51, 52, 55, 69, 79, 81, 84, 96]' > "$answer" diff --git a/tasks/agg-p23-n16-s13/task.toml b/tasks/agg-p23-n16-s13/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..e9f65c69e779b7d01be69f6780c0a5dd8114b073 --- /dev/null +++ b/tasks/agg-p23-n16-s13/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p23-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 = 23 +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-p23-n16-s13/tests/expected.json b/tasks/agg-p23-n16-s13/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..c3a941386d4fd31d1d4404a0d80d94e09fbdaf69 --- /dev/null +++ b/tasks/agg-p23-n16-s13/tests/expected.json @@ -0,0 +1 @@ +[1, 3, 7, 16, 20, 30, 35, 45, 51, 52, 55, 69, 79, 81, 84, 96] diff --git a/tasks/agg-p23-n16-s13/tests/test.sh b/tasks/agg-p23-n16-s13/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p23-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-p23-n16-s14/instruction.md b/tasks/agg-p23-n16-s14/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..635dd02b39036aac45824980be06065d4cdbba80 --- /dev/null +++ b/tasks/agg-p23-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 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-p23-n16-s14/solution/solve.sh b/tasks/agg-p23-n16-s14/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0fe85c5005bfb3fb5f503913158eb430478b4ef9 --- /dev/null +++ b/tasks/agg-p23-n16-s14/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[1, 3, 7, 16, 20, 30, 35, 45, 51, 52, 55, 69, 79, 81, 84, 96]' > "$answer" diff --git a/tasks/agg-p23-n16-s14/task.toml b/tasks/agg-p23-n16-s14/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..f24869df2c3339e7379797afde448b186f7f7f52 --- /dev/null +++ b/tasks/agg-p23-n16-s14/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p23-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 = 23 +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-p23-n16-s14/tests/expected.json b/tasks/agg-p23-n16-s14/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..c3a941386d4fd31d1d4404a0d80d94e09fbdaf69 --- /dev/null +++ b/tasks/agg-p23-n16-s14/tests/expected.json @@ -0,0 +1 @@ +[1, 3, 7, 16, 20, 30, 35, 45, 51, 52, 55, 69, 79, 81, 84, 96] diff --git a/tasks/agg-p23-n16-s14/tests/test.sh b/tasks/agg-p23-n16-s14/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p23-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-p23-n16-s15/instruction.md b/tasks/agg-p23-n16-s15/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..9e673d50df3d0049f8ebbc5f08e69f16f929b38f --- /dev/null +++ b/tasks/agg-p23-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-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-p23-n16-s15/solution/solve.sh b/tasks/agg-p23-n16-s15/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0fe85c5005bfb3fb5f503913158eb430478b4ef9 --- /dev/null +++ b/tasks/agg-p23-n16-s15/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[1, 3, 7, 16, 20, 30, 35, 45, 51, 52, 55, 69, 79, 81, 84, 96]' > "$answer" diff --git a/tasks/agg-p23-n16-s15/task.toml b/tasks/agg-p23-n16-s15/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..ec42aa74880dff65d5f5a1990bffb907c3e8bf3c --- /dev/null +++ b/tasks/agg-p23-n16-s15/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p23-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 = 23 +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-p23-n16-s15/tests/expected.json b/tasks/agg-p23-n16-s15/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..c3a941386d4fd31d1d4404a0d80d94e09fbdaf69 --- /dev/null +++ b/tasks/agg-p23-n16-s15/tests/expected.json @@ -0,0 +1 @@ +[1, 3, 7, 16, 20, 30, 35, 45, 51, 52, 55, 69, 79, 81, 84, 96] diff --git a/tasks/agg-p23-n16-s15/tests/test.sh b/tasks/agg-p23-n16-s15/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p23-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-p23-n16-s16/instruction.md b/tasks/agg-p23-n16-s16/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..1fe2576f1a20a278b177c066abc20e44af6a4729 --- /dev/null +++ b/tasks/agg-p23-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 thirty-five. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p23-n16-s16/solution/solve.sh b/tasks/agg-p23-n16-s16/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0fe85c5005bfb3fb5f503913158eb430478b4ef9 --- /dev/null +++ b/tasks/agg-p23-n16-s16/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[1, 3, 7, 16, 20, 30, 35, 45, 51, 52, 55, 69, 79, 81, 84, 96]' > "$answer" diff --git a/tasks/agg-p23-n16-s16/task.toml b/tasks/agg-p23-n16-s16/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..7ba2c4e3d7c1fb59d6318a540b4da16edc9c25c8 --- /dev/null +++ b/tasks/agg-p23-n16-s16/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p23-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 = 23 +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-p23-n16-s16/tests/expected.json b/tasks/agg-p23-n16-s16/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..c3a941386d4fd31d1d4404a0d80d94e09fbdaf69 --- /dev/null +++ b/tasks/agg-p23-n16-s16/tests/expected.json @@ -0,0 +1 @@ +[1, 3, 7, 16, 20, 30, 35, 45, 51, 52, 55, 69, 79, 81, 84, 96] diff --git a/tasks/agg-p23-n16-s16/tests/test.sh b/tasks/agg-p23-n16-s16/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p23-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-p24-n01-s01/instruction.md b/tasks/agg-p24-n01-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..a3466c7f82ee166ff08e35d24b2a461a2794a0ac --- /dev/null +++ b/tasks/agg-p24-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 ninety-five. + +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-p24-n01-s01/solution/solve.sh b/tasks/agg-p24-n01-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3f59dc1ea733dbd58972e372ed249b64099bd401 --- /dev/null +++ b/tasks/agg-p24-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 '[95]' > "$answer" diff --git a/tasks/agg-p24-n01-s01/task.toml b/tasks/agg-p24-n01-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..af99dbcb329ee009f021d91d525732df85837167 --- /dev/null +++ b/tasks/agg-p24-n01-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p24-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 = 24 +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-p24-n01-s01/tests/expected.json b/tasks/agg-p24-n01-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..9129c6cccfeeb3d97eff36cd8e3b51cb25f44caa --- /dev/null +++ b/tasks/agg-p24-n01-s01/tests/expected.json @@ -0,0 +1 @@ +[95] diff --git a/tasks/agg-p24-n01-s01/tests/test.sh b/tasks/agg-p24-n01-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p24-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-p24-n02-s01/instruction.md b/tasks/agg-p24-n02-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..404111282daae97f1b44550984d4f55774e612a6 --- /dev/null +++ b/tasks/agg-p24-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 ninety-five. + +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-p24-n02-s01/solution/solve.sh b/tasks/agg-p24-n02-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5c3886d27183f6967a2a37cadc883fdd4095a7ef --- /dev/null +++ b/tasks/agg-p24-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 '[82, 95]' > "$answer" diff --git a/tasks/agg-p24-n02-s01/task.toml b/tasks/agg-p24-n02-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..4cd6294e2e97c4aa4683fb6be95408ac0da77287 --- /dev/null +++ b/tasks/agg-p24-n02-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p24-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 = 24 +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-p24-n02-s01/tests/expected.json b/tasks/agg-p24-n02-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..ef5abaa4404694c8459ac2d6491c8ddb13a0a6c9 --- /dev/null +++ b/tasks/agg-p24-n02-s01/tests/expected.json @@ -0,0 +1 @@ +[82, 95] diff --git a/tasks/agg-p24-n02-s01/tests/test.sh b/tasks/agg-p24-n02-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p24-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-p24-n02-s02/instruction.md b/tasks/agg-p24-n02-s02/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..d2d38bb45fd483fe5586be4932d257c85cdedb18 --- /dev/null +++ b/tasks/agg-p24-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 eighty-two. + +The team must find all 2 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 2 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p24-n02-s02/solution/solve.sh b/tasks/agg-p24-n02-s02/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5c3886d27183f6967a2a37cadc883fdd4095a7ef --- /dev/null +++ b/tasks/agg-p24-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 '[82, 95]' > "$answer" diff --git a/tasks/agg-p24-n02-s02/task.toml b/tasks/agg-p24-n02-s02/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..dee88688e9a3f0673fcf41a1a381f544a30ac3d8 --- /dev/null +++ b/tasks/agg-p24-n02-s02/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p24-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 = 24 +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-p24-n02-s02/tests/expected.json b/tasks/agg-p24-n02-s02/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..ef5abaa4404694c8459ac2d6491c8ddb13a0a6c9 --- /dev/null +++ b/tasks/agg-p24-n02-s02/tests/expected.json @@ -0,0 +1 @@ +[82, 95] diff --git a/tasks/agg-p24-n02-s02/tests/test.sh b/tasks/agg-p24-n02-s02/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p24-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-p24-n04-s01/instruction.md b/tasks/agg-p24-n04-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..a0bd19ac3b592052aada59c15e572699cc95d555 --- /dev/null +++ b/tasks/agg-p24-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 ninety-five. + +The team must find all 4 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 4 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p24-n04-s01/solution/solve.sh b/tasks/agg-p24-n04-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..dc22ec77166fbfa88335eaec942fde2e005c7710 --- /dev/null +++ b/tasks/agg-p24-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 '[5, 50, 82, 95]' > "$answer" diff --git a/tasks/agg-p24-n04-s01/task.toml b/tasks/agg-p24-n04-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..a1330840d1473f2833725f335619727535c85982 --- /dev/null +++ b/tasks/agg-p24-n04-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p24-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 = 24 +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-p24-n04-s01/tests/expected.json b/tasks/agg-p24-n04-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..a17a729fd51d44adbe1124c26548616b4f4bde08 --- /dev/null +++ b/tasks/agg-p24-n04-s01/tests/expected.json @@ -0,0 +1 @@ +[5, 50, 82, 95] diff --git a/tasks/agg-p24-n04-s01/tests/test.sh b/tasks/agg-p24-n04-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p24-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-p24-n04-s02/instruction.md b/tasks/agg-p24-n04-s02/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..680b87be1a6a736859b11707e6c2ffe2157f5d4c --- /dev/null +++ b/tasks/agg-p24-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 eighty-two. + +The team must find all 4 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 4 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p24-n04-s02/solution/solve.sh b/tasks/agg-p24-n04-s02/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..dc22ec77166fbfa88335eaec942fde2e005c7710 --- /dev/null +++ b/tasks/agg-p24-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 '[5, 50, 82, 95]' > "$answer" diff --git a/tasks/agg-p24-n04-s02/task.toml b/tasks/agg-p24-n04-s02/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..80bbda2cb733bcdb8f58ffc6d91f80e865675c33 --- /dev/null +++ b/tasks/agg-p24-n04-s02/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p24-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 = 24 +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-p24-n04-s02/tests/expected.json b/tasks/agg-p24-n04-s02/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..a17a729fd51d44adbe1124c26548616b4f4bde08 --- /dev/null +++ b/tasks/agg-p24-n04-s02/tests/expected.json @@ -0,0 +1 @@ +[5, 50, 82, 95] diff --git a/tasks/agg-p24-n04-s02/tests/test.sh b/tasks/agg-p24-n04-s02/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p24-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-p24-n04-s03/instruction.md b/tasks/agg-p24-n04-s03/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..00f783bdbb5bc769d650beb27a56e90f047df0cf --- /dev/null +++ b/tasks/agg-p24-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 five. + +The team must find all 4 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 4 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p24-n04-s03/solution/solve.sh b/tasks/agg-p24-n04-s03/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..dc22ec77166fbfa88335eaec942fde2e005c7710 --- /dev/null +++ b/tasks/agg-p24-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 '[5, 50, 82, 95]' > "$answer" diff --git a/tasks/agg-p24-n04-s03/task.toml b/tasks/agg-p24-n04-s03/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..c3692093b11d26cb8646904854fb70f5b437773a --- /dev/null +++ b/tasks/agg-p24-n04-s03/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p24-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 = 24 +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-p24-n04-s03/tests/expected.json b/tasks/agg-p24-n04-s03/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..a17a729fd51d44adbe1124c26548616b4f4bde08 --- /dev/null +++ b/tasks/agg-p24-n04-s03/tests/expected.json @@ -0,0 +1 @@ +[5, 50, 82, 95] diff --git a/tasks/agg-p24-n04-s03/tests/test.sh b/tasks/agg-p24-n04-s03/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p24-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-p24-n04-s04/instruction.md b/tasks/agg-p24-n04-s04/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..5dff7097a6f8187c56c213364fcbce4a861f1521 --- /dev/null +++ b/tasks/agg-p24-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. + +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-p24-n04-s04/solution/solve.sh b/tasks/agg-p24-n04-s04/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..dc22ec77166fbfa88335eaec942fde2e005c7710 --- /dev/null +++ b/tasks/agg-p24-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 '[5, 50, 82, 95]' > "$answer" diff --git a/tasks/agg-p24-n04-s04/task.toml b/tasks/agg-p24-n04-s04/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..5faa1d94f724516b4ddc90e80a1a873df7201235 --- /dev/null +++ b/tasks/agg-p24-n04-s04/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p24-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 = 24 +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-p24-n04-s04/tests/expected.json b/tasks/agg-p24-n04-s04/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..a17a729fd51d44adbe1124c26548616b4f4bde08 --- /dev/null +++ b/tasks/agg-p24-n04-s04/tests/expected.json @@ -0,0 +1 @@ +[5, 50, 82, 95] diff --git a/tasks/agg-p24-n04-s04/tests/test.sh b/tasks/agg-p24-n04-s04/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p24-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-p24-n08-s01/instruction.md b/tasks/agg-p24-n08-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..a042cb763ccdabe4fefaa1c5911478c0a369e6d0 --- /dev/null +++ b/tasks/agg-p24-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 ninety-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-p24-n08-s01/solution/solve.sh b/tasks/agg-p24-n08-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b47fcd0c7117484d9703c89621d6b9dd5ebf1f30 --- /dev/null +++ b/tasks/agg-p24-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 '[5, 38, 50, 82, 87, 89, 95, 95]' > "$answer" diff --git a/tasks/agg-p24-n08-s01/task.toml b/tasks/agg-p24-n08-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..b3f4c429ad7d48d3bb4e16019b2cd75663a54645 --- /dev/null +++ b/tasks/agg-p24-n08-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p24-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 = 24 +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-p24-n08-s01/tests/expected.json b/tasks/agg-p24-n08-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..27ba6694a97ea284193dc5b475d1721f6d228847 --- /dev/null +++ b/tasks/agg-p24-n08-s01/tests/expected.json @@ -0,0 +1 @@ +[5, 38, 50, 82, 87, 89, 95, 95] diff --git a/tasks/agg-p24-n08-s01/tests/test.sh b/tasks/agg-p24-n08-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p24-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-p24-n08-s02/instruction.md b/tasks/agg-p24-n08-s02/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..e0a9ed87cd13d7f7ad66688fc91321b44512af39 --- /dev/null +++ b/tasks/agg-p24-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 eighty-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-p24-n08-s02/solution/solve.sh b/tasks/agg-p24-n08-s02/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b47fcd0c7117484d9703c89621d6b9dd5ebf1f30 --- /dev/null +++ b/tasks/agg-p24-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 '[5, 38, 50, 82, 87, 89, 95, 95]' > "$answer" diff --git a/tasks/agg-p24-n08-s02/task.toml b/tasks/agg-p24-n08-s02/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..39734356547b91c074cd2e5bda482cf6acbc8b40 --- /dev/null +++ b/tasks/agg-p24-n08-s02/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p24-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 = 24 +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-p24-n08-s02/tests/expected.json b/tasks/agg-p24-n08-s02/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..27ba6694a97ea284193dc5b475d1721f6d228847 --- /dev/null +++ b/tasks/agg-p24-n08-s02/tests/expected.json @@ -0,0 +1 @@ +[5, 38, 50, 82, 87, 89, 95, 95] diff --git a/tasks/agg-p24-n08-s02/tests/test.sh b/tasks/agg-p24-n08-s02/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p24-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-p24-n08-s03/instruction.md b/tasks/agg-p24-n08-s03/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..75a1841e2fc9e7879f1e791caf8e81f6f6010a03 --- /dev/null +++ b/tasks/agg-p24-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 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-p24-n08-s03/solution/solve.sh b/tasks/agg-p24-n08-s03/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b47fcd0c7117484d9703c89621d6b9dd5ebf1f30 --- /dev/null +++ b/tasks/agg-p24-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 '[5, 38, 50, 82, 87, 89, 95, 95]' > "$answer" diff --git a/tasks/agg-p24-n08-s03/task.toml b/tasks/agg-p24-n08-s03/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..b5ba1437cff4e57779e9f75d285537719eb2b816 --- /dev/null +++ b/tasks/agg-p24-n08-s03/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p24-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 = 24 +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-p24-n08-s03/tests/expected.json b/tasks/agg-p24-n08-s03/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..27ba6694a97ea284193dc5b475d1721f6d228847 --- /dev/null +++ b/tasks/agg-p24-n08-s03/tests/expected.json @@ -0,0 +1 @@ +[5, 38, 50, 82, 87, 89, 95, 95] diff --git a/tasks/agg-p24-n08-s03/tests/test.sh b/tasks/agg-p24-n08-s03/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p24-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-p24-n08-s04/instruction.md b/tasks/agg-p24-n08-s04/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..3e2cf199d0c7560bff5db95d105fc3d398218b9b --- /dev/null +++ b/tasks/agg-p24-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. + +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-p24-n08-s04/solution/solve.sh b/tasks/agg-p24-n08-s04/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b47fcd0c7117484d9703c89621d6b9dd5ebf1f30 --- /dev/null +++ b/tasks/agg-p24-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 '[5, 38, 50, 82, 87, 89, 95, 95]' > "$answer" diff --git a/tasks/agg-p24-n08-s04/task.toml b/tasks/agg-p24-n08-s04/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..edb9f16eee3de484c5e3cbfbb2cdfd2741977b8f --- /dev/null +++ b/tasks/agg-p24-n08-s04/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p24-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 = 24 +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-p24-n08-s04/tests/expected.json b/tasks/agg-p24-n08-s04/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..27ba6694a97ea284193dc5b475d1721f6d228847 --- /dev/null +++ b/tasks/agg-p24-n08-s04/tests/expected.json @@ -0,0 +1 @@ +[5, 38, 50, 82, 87, 89, 95, 95] diff --git a/tasks/agg-p24-n08-s04/tests/test.sh b/tasks/agg-p24-n08-s04/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p24-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-p24-n08-s05/instruction.md b/tasks/agg-p24-n08-s05/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..a042cb763ccdabe4fefaa1c5911478c0a369e6d0 --- /dev/null +++ b/tasks/agg-p24-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 ninety-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-p24-n08-s05/solution/solve.sh b/tasks/agg-p24-n08-s05/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b47fcd0c7117484d9703c89621d6b9dd5ebf1f30 --- /dev/null +++ b/tasks/agg-p24-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 '[5, 38, 50, 82, 87, 89, 95, 95]' > "$answer" diff --git a/tasks/agg-p24-n08-s05/task.toml b/tasks/agg-p24-n08-s05/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..cfe47166942085ca3e3e70a07677625138e7a7ba --- /dev/null +++ b/tasks/agg-p24-n08-s05/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p24-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 = 24 +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-p24-n08-s05/tests/expected.json b/tasks/agg-p24-n08-s05/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..27ba6694a97ea284193dc5b475d1721f6d228847 --- /dev/null +++ b/tasks/agg-p24-n08-s05/tests/expected.json @@ -0,0 +1 @@ +[5, 38, 50, 82, 87, 89, 95, 95] diff --git a/tasks/agg-p24-n08-s05/tests/test.sh b/tasks/agg-p24-n08-s05/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p24-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-p24-n08-s06/instruction.md b/tasks/agg-p24-n08-s06/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..e21142b6e0df055b0e0bb6899f7eab5e6cc92fb4 --- /dev/null +++ b/tasks/agg-p24-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 thirty-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-p24-n08-s06/solution/solve.sh b/tasks/agg-p24-n08-s06/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b47fcd0c7117484d9703c89621d6b9dd5ebf1f30 --- /dev/null +++ b/tasks/agg-p24-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 '[5, 38, 50, 82, 87, 89, 95, 95]' > "$answer" diff --git a/tasks/agg-p24-n08-s06/task.toml b/tasks/agg-p24-n08-s06/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..c5e1f0288777b666afa9c164278cbbd7639dd990 --- /dev/null +++ b/tasks/agg-p24-n08-s06/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p24-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 = 24 +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-p24-n08-s06/tests/expected.json b/tasks/agg-p24-n08-s06/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..27ba6694a97ea284193dc5b475d1721f6d228847 --- /dev/null +++ b/tasks/agg-p24-n08-s06/tests/expected.json @@ -0,0 +1 @@ +[5, 38, 50, 82, 87, 89, 95, 95] diff --git a/tasks/agg-p24-n08-s06/tests/test.sh b/tasks/agg-p24-n08-s06/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p24-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-p24-n08-s07/instruction.md b/tasks/agg-p24-n08-s07/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..33c7a00b4080f6f53fe6a6a1b5309b10579c3bc5 --- /dev/null +++ b/tasks/agg-p24-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-p24-n08-s07/solution/solve.sh b/tasks/agg-p24-n08-s07/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b47fcd0c7117484d9703c89621d6b9dd5ebf1f30 --- /dev/null +++ b/tasks/agg-p24-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 '[5, 38, 50, 82, 87, 89, 95, 95]' > "$answer" diff --git a/tasks/agg-p24-n08-s07/task.toml b/tasks/agg-p24-n08-s07/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..8d53ef9abe5adc90ff166f46e4cb11636c9bb57a --- /dev/null +++ b/tasks/agg-p24-n08-s07/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p24-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 = 24 +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-p24-n08-s07/tests/expected.json b/tasks/agg-p24-n08-s07/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..27ba6694a97ea284193dc5b475d1721f6d228847 --- /dev/null +++ b/tasks/agg-p24-n08-s07/tests/expected.json @@ -0,0 +1 @@ +[5, 38, 50, 82, 87, 89, 95, 95] diff --git a/tasks/agg-p24-n08-s07/tests/test.sh b/tasks/agg-p24-n08-s07/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p24-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-p24-n08-s08/instruction.md b/tasks/agg-p24-n08-s08/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..3ef2ec7b4ffc263c27c3bece987fc632ef3cc457 --- /dev/null +++ b/tasks/agg-p24-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-nine. + +The team must find all 8 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 8 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p24-n08-s08/solution/solve.sh b/tasks/agg-p24-n08-s08/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b47fcd0c7117484d9703c89621d6b9dd5ebf1f30 --- /dev/null +++ b/tasks/agg-p24-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 '[5, 38, 50, 82, 87, 89, 95, 95]' > "$answer" diff --git a/tasks/agg-p24-n08-s08/task.toml b/tasks/agg-p24-n08-s08/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..6dd866900cd2134b135ce5a053bb2acaa99a3072 --- /dev/null +++ b/tasks/agg-p24-n08-s08/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p24-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 = 24 +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-p24-n08-s08/tests/expected.json b/tasks/agg-p24-n08-s08/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..27ba6694a97ea284193dc5b475d1721f6d228847 --- /dev/null +++ b/tasks/agg-p24-n08-s08/tests/expected.json @@ -0,0 +1 @@ +[5, 38, 50, 82, 87, 89, 95, 95] diff --git a/tasks/agg-p24-n08-s08/tests/test.sh b/tasks/agg-p24-n08-s08/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p24-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-p24-n16-s01/instruction.md b/tasks/agg-p24-n16-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..961985392d4b99bbc35d52871fb6450061a34bb5 --- /dev/null +++ b/tasks/agg-p24-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 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-p24-n16-s01/solution/solve.sh b/tasks/agg-p24-n16-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f4d55b266431c21865235d6c8b77515368879db0 --- /dev/null +++ b/tasks/agg-p24-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 '[5, 10, 37, 38, 39, 39, 50, 67, 82, 87, 87, 89, 92, 92, 95, 95]' > "$answer" diff --git a/tasks/agg-p24-n16-s01/task.toml b/tasks/agg-p24-n16-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..7e56f75d2dbeb6243e50cd181b473c4bfac7849c --- /dev/null +++ b/tasks/agg-p24-n16-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p24-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 = 24 +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-p24-n16-s01/tests/expected.json b/tasks/agg-p24-n16-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..ce7db3d1f7debd128fd833ce320b7002ae88561e --- /dev/null +++ b/tasks/agg-p24-n16-s01/tests/expected.json @@ -0,0 +1 @@ +[5, 10, 37, 38, 39, 39, 50, 67, 82, 87, 87, 89, 92, 92, 95, 95] diff --git a/tasks/agg-p24-n16-s01/tests/test.sh b/tasks/agg-p24-n16-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p24-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-p24-n16-s02/instruction.md b/tasks/agg-p24-n16-s02/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..8719f945164b6c7adba0eec9b9728be32d6bfe5e --- /dev/null +++ b/tasks/agg-p24-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 eighty-two. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p24-n16-s02/solution/solve.sh b/tasks/agg-p24-n16-s02/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f4d55b266431c21865235d6c8b77515368879db0 --- /dev/null +++ b/tasks/agg-p24-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 '[5, 10, 37, 38, 39, 39, 50, 67, 82, 87, 87, 89, 92, 92, 95, 95]' > "$answer" diff --git a/tasks/agg-p24-n16-s02/task.toml b/tasks/agg-p24-n16-s02/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..13e28129deb676e93d9805784078f162d05564a6 --- /dev/null +++ b/tasks/agg-p24-n16-s02/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p24-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 = 24 +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-p24-n16-s02/tests/expected.json b/tasks/agg-p24-n16-s02/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..ce7db3d1f7debd128fd833ce320b7002ae88561e --- /dev/null +++ b/tasks/agg-p24-n16-s02/tests/expected.json @@ -0,0 +1 @@ +[5, 10, 37, 38, 39, 39, 50, 67, 82, 87, 87, 89, 92, 92, 95, 95] diff --git a/tasks/agg-p24-n16-s02/tests/test.sh b/tasks/agg-p24-n16-s02/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p24-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-p24-n16-s03/instruction.md b/tasks/agg-p24-n16-s03/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..17dddcebb1a38d642707c9e410dad0c89d830fb7 --- /dev/null +++ b/tasks/agg-p24-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 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-p24-n16-s03/solution/solve.sh b/tasks/agg-p24-n16-s03/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f4d55b266431c21865235d6c8b77515368879db0 --- /dev/null +++ b/tasks/agg-p24-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 '[5, 10, 37, 38, 39, 39, 50, 67, 82, 87, 87, 89, 92, 92, 95, 95]' > "$answer" diff --git a/tasks/agg-p24-n16-s03/task.toml b/tasks/agg-p24-n16-s03/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..dafdd1c5b4b8304e0c76dec40ee29f0c7d8b4545 --- /dev/null +++ b/tasks/agg-p24-n16-s03/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p24-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 = 24 +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-p24-n16-s03/tests/expected.json b/tasks/agg-p24-n16-s03/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..ce7db3d1f7debd128fd833ce320b7002ae88561e --- /dev/null +++ b/tasks/agg-p24-n16-s03/tests/expected.json @@ -0,0 +1 @@ +[5, 10, 37, 38, 39, 39, 50, 67, 82, 87, 87, 89, 92, 92, 95, 95] diff --git a/tasks/agg-p24-n16-s03/tests/test.sh b/tasks/agg-p24-n16-s03/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p24-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-p24-n16-s04/instruction.md b/tasks/agg-p24-n16-s04/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..24cae7506709ba17884a6f8faefcffb0fa372426 --- /dev/null +++ b/tasks/agg-p24-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. + +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-p24-n16-s04/solution/solve.sh b/tasks/agg-p24-n16-s04/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f4d55b266431c21865235d6c8b77515368879db0 --- /dev/null +++ b/tasks/agg-p24-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 '[5, 10, 37, 38, 39, 39, 50, 67, 82, 87, 87, 89, 92, 92, 95, 95]' > "$answer" diff --git a/tasks/agg-p24-n16-s04/task.toml b/tasks/agg-p24-n16-s04/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..ee98064fe3a39a669af291e19463e335709e3e5c --- /dev/null +++ b/tasks/agg-p24-n16-s04/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p24-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 = 24 +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-p24-n16-s04/tests/expected.json b/tasks/agg-p24-n16-s04/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..ce7db3d1f7debd128fd833ce320b7002ae88561e --- /dev/null +++ b/tasks/agg-p24-n16-s04/tests/expected.json @@ -0,0 +1 @@ +[5, 10, 37, 38, 39, 39, 50, 67, 82, 87, 87, 89, 92, 92, 95, 95] diff --git a/tasks/agg-p24-n16-s04/tests/test.sh b/tasks/agg-p24-n16-s04/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p24-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-p24-n16-s05/instruction.md b/tasks/agg-p24-n16-s05/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..961985392d4b99bbc35d52871fb6450061a34bb5 --- /dev/null +++ b/tasks/agg-p24-n16-s05/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is ninety-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-p24-n16-s05/solution/solve.sh b/tasks/agg-p24-n16-s05/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f4d55b266431c21865235d6c8b77515368879db0 --- /dev/null +++ b/tasks/agg-p24-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 '[5, 10, 37, 38, 39, 39, 50, 67, 82, 87, 87, 89, 92, 92, 95, 95]' > "$answer" diff --git a/tasks/agg-p24-n16-s05/task.toml b/tasks/agg-p24-n16-s05/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..eeb9486f51ec0d318aca5c98737dd9abb9d863b5 --- /dev/null +++ b/tasks/agg-p24-n16-s05/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p24-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 = 24 +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-p24-n16-s05/tests/expected.json b/tasks/agg-p24-n16-s05/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..ce7db3d1f7debd128fd833ce320b7002ae88561e --- /dev/null +++ b/tasks/agg-p24-n16-s05/tests/expected.json @@ -0,0 +1 @@ +[5, 10, 37, 38, 39, 39, 50, 67, 82, 87, 87, 89, 92, 92, 95, 95] diff --git a/tasks/agg-p24-n16-s05/tests/test.sh b/tasks/agg-p24-n16-s05/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p24-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-p24-n16-s06/instruction.md b/tasks/agg-p24-n16-s06/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..d398ea97722601a49a457530f502678c0a1433cf --- /dev/null +++ b/tasks/agg-p24-n16-s06/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is thirty-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-p24-n16-s06/solution/solve.sh b/tasks/agg-p24-n16-s06/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f4d55b266431c21865235d6c8b77515368879db0 --- /dev/null +++ b/tasks/agg-p24-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 '[5, 10, 37, 38, 39, 39, 50, 67, 82, 87, 87, 89, 92, 92, 95, 95]' > "$answer" diff --git a/tasks/agg-p24-n16-s06/task.toml b/tasks/agg-p24-n16-s06/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..febed126d79da33e34a8fa9a5ff5af7330a20e84 --- /dev/null +++ b/tasks/agg-p24-n16-s06/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p24-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 = 24 +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-p24-n16-s06/tests/expected.json b/tasks/agg-p24-n16-s06/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..ce7db3d1f7debd128fd833ce320b7002ae88561e --- /dev/null +++ b/tasks/agg-p24-n16-s06/tests/expected.json @@ -0,0 +1 @@ +[5, 10, 37, 38, 39, 39, 50, 67, 82, 87, 87, 89, 92, 92, 95, 95] diff --git a/tasks/agg-p24-n16-s06/tests/test.sh b/tasks/agg-p24-n16-s06/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p24-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-p24-n16-s07/instruction.md b/tasks/agg-p24-n16-s07/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..3c1a8c1b0c33b8354227b277a5b1885c3067b4d2 --- /dev/null +++ b/tasks/agg-p24-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-p24-n16-s07/solution/solve.sh b/tasks/agg-p24-n16-s07/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f4d55b266431c21865235d6c8b77515368879db0 --- /dev/null +++ b/tasks/agg-p24-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 '[5, 10, 37, 38, 39, 39, 50, 67, 82, 87, 87, 89, 92, 92, 95, 95]' > "$answer" diff --git a/tasks/agg-p24-n16-s07/task.toml b/tasks/agg-p24-n16-s07/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..23568882c8347c450b1c7ad8a45f4d422af0e70c --- /dev/null +++ b/tasks/agg-p24-n16-s07/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p24-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 = 24 +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-p24-n16-s07/tests/expected.json b/tasks/agg-p24-n16-s07/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..ce7db3d1f7debd128fd833ce320b7002ae88561e --- /dev/null +++ b/tasks/agg-p24-n16-s07/tests/expected.json @@ -0,0 +1 @@ +[5, 10, 37, 38, 39, 39, 50, 67, 82, 87, 87, 89, 92, 92, 95, 95] diff --git a/tasks/agg-p24-n16-s07/tests/test.sh b/tasks/agg-p24-n16-s07/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p24-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-p24-n16-s08/instruction.md b/tasks/agg-p24-n16-s08/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..33c6e5250952f3077456a896c57a642ebd1c8d39 --- /dev/null +++ b/tasks/agg-p24-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-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-p24-n16-s08/solution/solve.sh b/tasks/agg-p24-n16-s08/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f4d55b266431c21865235d6c8b77515368879db0 --- /dev/null +++ b/tasks/agg-p24-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 '[5, 10, 37, 38, 39, 39, 50, 67, 82, 87, 87, 89, 92, 92, 95, 95]' > "$answer" diff --git a/tasks/agg-p24-n16-s08/task.toml b/tasks/agg-p24-n16-s08/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..3d03dc1d40f6b8795856434b038914be299b9bd3 --- /dev/null +++ b/tasks/agg-p24-n16-s08/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p24-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 = 24 +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-p24-n16-s08/tests/expected.json b/tasks/agg-p24-n16-s08/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..ce7db3d1f7debd128fd833ce320b7002ae88561e --- /dev/null +++ b/tasks/agg-p24-n16-s08/tests/expected.json @@ -0,0 +1 @@ +[5, 10, 37, 38, 39, 39, 50, 67, 82, 87, 87, 89, 92, 92, 95, 95] diff --git a/tasks/agg-p24-n16-s08/tests/test.sh b/tasks/agg-p24-n16-s08/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p24-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-p24-n16-s09/instruction.md b/tasks/agg-p24-n16-s09/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..d443699990b373083b3fdeb1d846a400fde6e65b --- /dev/null +++ b/tasks/agg-p24-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 thirty-nine. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p24-n16-s09/solution/solve.sh b/tasks/agg-p24-n16-s09/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f4d55b266431c21865235d6c8b77515368879db0 --- /dev/null +++ b/tasks/agg-p24-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 '[5, 10, 37, 38, 39, 39, 50, 67, 82, 87, 87, 89, 92, 92, 95, 95]' > "$answer" diff --git a/tasks/agg-p24-n16-s09/task.toml b/tasks/agg-p24-n16-s09/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..92430c872221e09099797ac81032c56f443b53ba --- /dev/null +++ b/tasks/agg-p24-n16-s09/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p24-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 = 24 +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-p24-n16-s09/tests/expected.json b/tasks/agg-p24-n16-s09/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..ce7db3d1f7debd128fd833ce320b7002ae88561e --- /dev/null +++ b/tasks/agg-p24-n16-s09/tests/expected.json @@ -0,0 +1 @@ +[5, 10, 37, 38, 39, 39, 50, 67, 82, 87, 87, 89, 92, 92, 95, 95] diff --git a/tasks/agg-p24-n16-s09/tests/test.sh b/tasks/agg-p24-n16-s09/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p24-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-p24-n16-s10/instruction.md b/tasks/agg-p24-n16-s10/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..10bcc3d169e35738b1fb80abb7316f9cd7c1b230 --- /dev/null +++ b/tasks/agg-p24-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 thirty-seven. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p24-n16-s10/solution/solve.sh b/tasks/agg-p24-n16-s10/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f4d55b266431c21865235d6c8b77515368879db0 --- /dev/null +++ b/tasks/agg-p24-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 '[5, 10, 37, 38, 39, 39, 50, 67, 82, 87, 87, 89, 92, 92, 95, 95]' > "$answer" diff --git a/tasks/agg-p24-n16-s10/task.toml b/tasks/agg-p24-n16-s10/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..5e88213678ae962f8f688eaec0129a4edb23fab0 --- /dev/null +++ b/tasks/agg-p24-n16-s10/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p24-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 = 24 +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-p24-n16-s10/tests/expected.json b/tasks/agg-p24-n16-s10/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..ce7db3d1f7debd128fd833ce320b7002ae88561e --- /dev/null +++ b/tasks/agg-p24-n16-s10/tests/expected.json @@ -0,0 +1 @@ +[5, 10, 37, 38, 39, 39, 50, 67, 82, 87, 87, 89, 92, 92, 95, 95] diff --git a/tasks/agg-p24-n16-s10/tests/test.sh b/tasks/agg-p24-n16-s10/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p24-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-p24-n16-s11/instruction.md b/tasks/agg-p24-n16-s11/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..cebfaeb748131e1409dea8040dd71bd8744f230b --- /dev/null +++ b/tasks/agg-p24-n16-s11/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is sixty-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-p24-n16-s11/solution/solve.sh b/tasks/agg-p24-n16-s11/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f4d55b266431c21865235d6c8b77515368879db0 --- /dev/null +++ b/tasks/agg-p24-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 '[5, 10, 37, 38, 39, 39, 50, 67, 82, 87, 87, 89, 92, 92, 95, 95]' > "$answer" diff --git a/tasks/agg-p24-n16-s11/task.toml b/tasks/agg-p24-n16-s11/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..3368e3cdf41f021acb8a835ee4dec6140fcbbd5a --- /dev/null +++ b/tasks/agg-p24-n16-s11/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p24-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 = 24 +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-p24-n16-s11/tests/expected.json b/tasks/agg-p24-n16-s11/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..ce7db3d1f7debd128fd833ce320b7002ae88561e --- /dev/null +++ b/tasks/agg-p24-n16-s11/tests/expected.json @@ -0,0 +1 @@ +[5, 10, 37, 38, 39, 39, 50, 67, 82, 87, 87, 89, 92, 92, 95, 95] diff --git a/tasks/agg-p24-n16-s11/tests/test.sh b/tasks/agg-p24-n16-s11/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p24-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-p24-n16-s12/instruction.md b/tasks/agg-p24-n16-s12/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..15dcbc6a01201bc29446da73c6532fccce6c79d2 --- /dev/null +++ b/tasks/agg-p24-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 ten. + +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-p24-n16-s12/solution/solve.sh b/tasks/agg-p24-n16-s12/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f4d55b266431c21865235d6c8b77515368879db0 --- /dev/null +++ b/tasks/agg-p24-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 '[5, 10, 37, 38, 39, 39, 50, 67, 82, 87, 87, 89, 92, 92, 95, 95]' > "$answer" diff --git a/tasks/agg-p24-n16-s12/task.toml b/tasks/agg-p24-n16-s12/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..f898de150c773707b078127e9e3be59351f1e9cc --- /dev/null +++ b/tasks/agg-p24-n16-s12/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p24-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 = 24 +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-p24-n16-s12/tests/expected.json b/tasks/agg-p24-n16-s12/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..ce7db3d1f7debd128fd833ce320b7002ae88561e --- /dev/null +++ b/tasks/agg-p24-n16-s12/tests/expected.json @@ -0,0 +1 @@ +[5, 10, 37, 38, 39, 39, 50, 67, 82, 87, 87, 89, 92, 92, 95, 95] diff --git a/tasks/agg-p24-n16-s12/tests/test.sh b/tasks/agg-p24-n16-s12/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p24-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-p24-n16-s13/instruction.md b/tasks/agg-p24-n16-s13/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..3c1a8c1b0c33b8354227b277a5b1885c3067b4d2 --- /dev/null +++ b/tasks/agg-p24-n16-s13/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is eighty-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-p24-n16-s13/solution/solve.sh b/tasks/agg-p24-n16-s13/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f4d55b266431c21865235d6c8b77515368879db0 --- /dev/null +++ b/tasks/agg-p24-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 '[5, 10, 37, 38, 39, 39, 50, 67, 82, 87, 87, 89, 92, 92, 95, 95]' > "$answer" diff --git a/tasks/agg-p24-n16-s13/task.toml b/tasks/agg-p24-n16-s13/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..feba10db081edbe15f440f2abf76a83cbc533ff4 --- /dev/null +++ b/tasks/agg-p24-n16-s13/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p24-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 = 24 +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-p24-n16-s13/tests/expected.json b/tasks/agg-p24-n16-s13/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..ce7db3d1f7debd128fd833ce320b7002ae88561e --- /dev/null +++ b/tasks/agg-p24-n16-s13/tests/expected.json @@ -0,0 +1 @@ +[5, 10, 37, 38, 39, 39, 50, 67, 82, 87, 87, 89, 92, 92, 95, 95] diff --git a/tasks/agg-p24-n16-s13/tests/test.sh b/tasks/agg-p24-n16-s13/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p24-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-p24-n16-s14/instruction.md b/tasks/agg-p24-n16-s14/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..ff35f53eda015951f8078ff0751a783f65818958 --- /dev/null +++ b/tasks/agg-p24-n16-s14/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is ninety-two. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p24-n16-s14/solution/solve.sh b/tasks/agg-p24-n16-s14/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f4d55b266431c21865235d6c8b77515368879db0 --- /dev/null +++ b/tasks/agg-p24-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 '[5, 10, 37, 38, 39, 39, 50, 67, 82, 87, 87, 89, 92, 92, 95, 95]' > "$answer" diff --git a/tasks/agg-p24-n16-s14/task.toml b/tasks/agg-p24-n16-s14/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..83b8c161498ea3f3dffe0c3060db102d8f6caac2 --- /dev/null +++ b/tasks/agg-p24-n16-s14/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p24-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 = 24 +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-p24-n16-s14/tests/expected.json b/tasks/agg-p24-n16-s14/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..ce7db3d1f7debd128fd833ce320b7002ae88561e --- /dev/null +++ b/tasks/agg-p24-n16-s14/tests/expected.json @@ -0,0 +1 @@ +[5, 10, 37, 38, 39, 39, 50, 67, 82, 87, 87, 89, 92, 92, 95, 95] diff --git a/tasks/agg-p24-n16-s14/tests/test.sh b/tasks/agg-p24-n16-s14/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p24-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-p24-n16-s15/instruction.md b/tasks/agg-p24-n16-s15/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..d443699990b373083b3fdeb1d846a400fde6e65b --- /dev/null +++ b/tasks/agg-p24-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 thirty-nine. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p24-n16-s15/solution/solve.sh b/tasks/agg-p24-n16-s15/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f4d55b266431c21865235d6c8b77515368879db0 --- /dev/null +++ b/tasks/agg-p24-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 '[5, 10, 37, 38, 39, 39, 50, 67, 82, 87, 87, 89, 92, 92, 95, 95]' > "$answer" diff --git a/tasks/agg-p24-n16-s15/task.toml b/tasks/agg-p24-n16-s15/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..62c675bd9f368ec52e1d4c0b35cb4eacb25e60e1 --- /dev/null +++ b/tasks/agg-p24-n16-s15/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p24-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 = 24 +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-p24-n16-s15/tests/expected.json b/tasks/agg-p24-n16-s15/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..ce7db3d1f7debd128fd833ce320b7002ae88561e --- /dev/null +++ b/tasks/agg-p24-n16-s15/tests/expected.json @@ -0,0 +1 @@ +[5, 10, 37, 38, 39, 39, 50, 67, 82, 87, 87, 89, 92, 92, 95, 95] diff --git a/tasks/agg-p24-n16-s15/tests/test.sh b/tasks/agg-p24-n16-s15/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p24-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-p24-n16-s16/instruction.md b/tasks/agg-p24-n16-s16/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..ff35f53eda015951f8078ff0751a783f65818958 --- /dev/null +++ b/tasks/agg-p24-n16-s16/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is ninety-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-p24-n16-s16/solution/solve.sh b/tasks/agg-p24-n16-s16/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f4d55b266431c21865235d6c8b77515368879db0 --- /dev/null +++ b/tasks/agg-p24-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 '[5, 10, 37, 38, 39, 39, 50, 67, 82, 87, 87, 89, 92, 92, 95, 95]' > "$answer" diff --git a/tasks/agg-p24-n16-s16/task.toml b/tasks/agg-p24-n16-s16/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..5110f8c9a5259380eb48dda3bbe3c7b90e1e0fcd --- /dev/null +++ b/tasks/agg-p24-n16-s16/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p24-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 = 24 +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-p24-n16-s16/tests/expected.json b/tasks/agg-p24-n16-s16/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..ce7db3d1f7debd128fd833ce320b7002ae88561e --- /dev/null +++ b/tasks/agg-p24-n16-s16/tests/expected.json @@ -0,0 +1 @@ +[5, 10, 37, 38, 39, 39, 50, 67, 82, 87, 87, 89, 92, 92, 95, 95] diff --git a/tasks/agg-p24-n16-s16/tests/test.sh b/tasks/agg-p24-n16-s16/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p24-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-p25-n01-s01/instruction.md b/tasks/agg-p25-n01-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..94fb1eea0ee202266134436fc623908ddfc125c3 --- /dev/null +++ b/tasks/agg-p25-n01-s01/instruction.md @@ -0,0 +1,9 @@ +# Sort the team's private numbers + +You are the only agent on this team, solving a private-information number sorting task. You +hold one private integer from 1 to 99, written in English words. + +Your private number is thirty-three. + +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-p25-n01-s01/solution/solve.sh b/tasks/agg-p25-n01-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6804262b24ad73a07be9d7d3797651659f396963 --- /dev/null +++ b/tasks/agg-p25-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 '[33]' > "$answer" diff --git a/tasks/agg-p25-n01-s01/task.toml b/tasks/agg-p25-n01-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..12f600f371e76440c41e8d2dc7979aacac30cd71 --- /dev/null +++ b/tasks/agg-p25-n01-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p25-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 = 25 +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-p25-n01-s01/tests/expected.json b/tasks/agg-p25-n01-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..bb02c5912714ac0fc5fa9fc6bac286bc28a01972 --- /dev/null +++ b/tasks/agg-p25-n01-s01/tests/expected.json @@ -0,0 +1 @@ +[33] diff --git a/tasks/agg-p25-n01-s01/tests/test.sh b/tasks/agg-p25-n01-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p25-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-p25-n02-s01/instruction.md b/tasks/agg-p25-n02-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..fabd26fc361f6b59ad3563506cc531694f46bf6a --- /dev/null +++ b/tasks/agg-p25-n02-s01/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 2 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is thirty-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-p25-n02-s01/solution/solve.sh b/tasks/agg-p25-n02-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..9846b8c57c45d8bc3f83cb19f99bc062c3cee828 --- /dev/null +++ b/tasks/agg-p25-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 '[22, 33]' > "$answer" diff --git a/tasks/agg-p25-n02-s01/task.toml b/tasks/agg-p25-n02-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..7b671b53a4a53803e8ec192cc6beb6b9db310253 --- /dev/null +++ b/tasks/agg-p25-n02-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p25-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 = 25 +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-p25-n02-s01/tests/expected.json b/tasks/agg-p25-n02-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..ce655c8ef6784f969ff3e8bc52845c81291b6ebd --- /dev/null +++ b/tasks/agg-p25-n02-s01/tests/expected.json @@ -0,0 +1 @@ +[22, 33] diff --git a/tasks/agg-p25-n02-s01/tests/test.sh b/tasks/agg-p25-n02-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p25-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-p25-n02-s02/instruction.md b/tasks/agg-p25-n02-s02/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..b74bfd8401dd040791909d6cf84388bf2c5d8158 --- /dev/null +++ b/tasks/agg-p25-n02-s02/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 2 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is twenty-two. + +The team must find all 2 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 2 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p25-n02-s02/solution/solve.sh b/tasks/agg-p25-n02-s02/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..9846b8c57c45d8bc3f83cb19f99bc062c3cee828 --- /dev/null +++ b/tasks/agg-p25-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 '[22, 33]' > "$answer" diff --git a/tasks/agg-p25-n02-s02/task.toml b/tasks/agg-p25-n02-s02/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..b4a4c98f171c533a38ea26bae49e55558b80344c --- /dev/null +++ b/tasks/agg-p25-n02-s02/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p25-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 = 25 +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-p25-n02-s02/tests/expected.json b/tasks/agg-p25-n02-s02/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..ce655c8ef6784f969ff3e8bc52845c81291b6ebd --- /dev/null +++ b/tasks/agg-p25-n02-s02/tests/expected.json @@ -0,0 +1 @@ +[22, 33] diff --git a/tasks/agg-p25-n02-s02/tests/test.sh b/tasks/agg-p25-n02-s02/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p25-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-p25-n04-s01/instruction.md b/tasks/agg-p25-n04-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..defb2567dbe8012ebceefb3afc2ea1f9ca889d8e --- /dev/null +++ b/tasks/agg-p25-n04-s01/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 4 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is thirty-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-p25-n04-s01/solution/solve.sh b/tasks/agg-p25-n04-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..248486b59eabf0f72e960ee0512ed3fe32c6f087 --- /dev/null +++ b/tasks/agg-p25-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 '[18, 22, 33, 88]' > "$answer" diff --git a/tasks/agg-p25-n04-s01/task.toml b/tasks/agg-p25-n04-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..4b2a2b6a498868229ed65b253b46a91980ea802c --- /dev/null +++ b/tasks/agg-p25-n04-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p25-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 = 25 +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-p25-n04-s01/tests/expected.json b/tasks/agg-p25-n04-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..b35ffe4186d9d34ac8d3dbefc44f450f9c485105 --- /dev/null +++ b/tasks/agg-p25-n04-s01/tests/expected.json @@ -0,0 +1 @@ +[18, 22, 33, 88] diff --git a/tasks/agg-p25-n04-s01/tests/test.sh b/tasks/agg-p25-n04-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p25-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-p25-n04-s02/instruction.md b/tasks/agg-p25-n04-s02/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..9f0f47428da9534522c799558543c5d8ccdc8480 --- /dev/null +++ b/tasks/agg-p25-n04-s02/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 4 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is twenty-two. + +The team must find all 4 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 4 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p25-n04-s02/solution/solve.sh b/tasks/agg-p25-n04-s02/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..248486b59eabf0f72e960ee0512ed3fe32c6f087 --- /dev/null +++ b/tasks/agg-p25-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 '[18, 22, 33, 88]' > "$answer" diff --git a/tasks/agg-p25-n04-s02/task.toml b/tasks/agg-p25-n04-s02/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..1bb3eab4518dd14049e3cb3d63446d7d70768f3c --- /dev/null +++ b/tasks/agg-p25-n04-s02/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p25-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 = 25 +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-p25-n04-s02/tests/expected.json b/tasks/agg-p25-n04-s02/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..b35ffe4186d9d34ac8d3dbefc44f450f9c485105 --- /dev/null +++ b/tasks/agg-p25-n04-s02/tests/expected.json @@ -0,0 +1 @@ +[18, 22, 33, 88] diff --git a/tasks/agg-p25-n04-s02/tests/test.sh b/tasks/agg-p25-n04-s02/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p25-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-p25-n04-s03/instruction.md b/tasks/agg-p25-n04-s03/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..634df09d93ffa8b0d27ad435c23fa0756ccec488 --- /dev/null +++ b/tasks/agg-p25-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 eighteen. + +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-p25-n04-s03/solution/solve.sh b/tasks/agg-p25-n04-s03/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..248486b59eabf0f72e960ee0512ed3fe32c6f087 --- /dev/null +++ b/tasks/agg-p25-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 '[18, 22, 33, 88]' > "$answer" diff --git a/tasks/agg-p25-n04-s03/task.toml b/tasks/agg-p25-n04-s03/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..cdcbfe3bb26e873264e51f3c79d9c3d0f4c8f456 --- /dev/null +++ b/tasks/agg-p25-n04-s03/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p25-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 = 25 +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-p25-n04-s03/tests/expected.json b/tasks/agg-p25-n04-s03/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..b35ffe4186d9d34ac8d3dbefc44f450f9c485105 --- /dev/null +++ b/tasks/agg-p25-n04-s03/tests/expected.json @@ -0,0 +1 @@ +[18, 22, 33, 88] diff --git a/tasks/agg-p25-n04-s03/tests/test.sh b/tasks/agg-p25-n04-s03/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p25-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-p25-n04-s04/instruction.md b/tasks/agg-p25-n04-s04/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..710f629ccf5142ea8ee0ed83d0f5e26f17b2a9f7 --- /dev/null +++ b/tasks/agg-p25-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 eighty-eight. + +The team must find all 4 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 4 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p25-n04-s04/solution/solve.sh b/tasks/agg-p25-n04-s04/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..248486b59eabf0f72e960ee0512ed3fe32c6f087 --- /dev/null +++ b/tasks/agg-p25-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 '[18, 22, 33, 88]' > "$answer" diff --git a/tasks/agg-p25-n04-s04/task.toml b/tasks/agg-p25-n04-s04/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..aea07b1ea35fc205c26bc459bb085bf1040e46e5 --- /dev/null +++ b/tasks/agg-p25-n04-s04/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p25-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 = 25 +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-p25-n04-s04/tests/expected.json b/tasks/agg-p25-n04-s04/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..b35ffe4186d9d34ac8d3dbefc44f450f9c485105 --- /dev/null +++ b/tasks/agg-p25-n04-s04/tests/expected.json @@ -0,0 +1 @@ +[18, 22, 33, 88] diff --git a/tasks/agg-p25-n04-s04/tests/test.sh b/tasks/agg-p25-n04-s04/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p25-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-p25-n08-s01/instruction.md b/tasks/agg-p25-n08-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..03c94df8689da4f5b0401f4f3decef651eb9aee0 --- /dev/null +++ b/tasks/agg-p25-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-p25-n08-s01/solution/solve.sh b/tasks/agg-p25-n08-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..813ad3155b4db1cf6585b611945aaa4e9248af7e --- /dev/null +++ b/tasks/agg-p25-n08-s01/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 6, 18, 22, 33, 46, 73, 88]' > "$answer" diff --git a/tasks/agg-p25-n08-s01/task.toml b/tasks/agg-p25-n08-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..c00df9d755dc9a30f10682732e51421c5e004c05 --- /dev/null +++ b/tasks/agg-p25-n08-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p25-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 = 25 +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-p25-n08-s01/tests/expected.json b/tasks/agg-p25-n08-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..02dbdce6ffce318fe47d0c4bc708e2ac2eff1406 --- /dev/null +++ b/tasks/agg-p25-n08-s01/tests/expected.json @@ -0,0 +1 @@ +[2, 6, 18, 22, 33, 46, 73, 88] diff --git a/tasks/agg-p25-n08-s01/tests/test.sh b/tasks/agg-p25-n08-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p25-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-p25-n08-s02/instruction.md b/tasks/agg-p25-n08-s02/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..8e1b9f225dd41eb13af45ff90735dba5c7d221b8 --- /dev/null +++ b/tasks/agg-p25-n08-s02/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 8 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is twenty-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-p25-n08-s02/solution/solve.sh b/tasks/agg-p25-n08-s02/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..813ad3155b4db1cf6585b611945aaa4e9248af7e --- /dev/null +++ b/tasks/agg-p25-n08-s02/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 6, 18, 22, 33, 46, 73, 88]' > "$answer" diff --git a/tasks/agg-p25-n08-s02/task.toml b/tasks/agg-p25-n08-s02/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..7a41f5a95c91e02d8c880de7247043686b7b1af1 --- /dev/null +++ b/tasks/agg-p25-n08-s02/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p25-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 = 25 +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-p25-n08-s02/tests/expected.json b/tasks/agg-p25-n08-s02/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..02dbdce6ffce318fe47d0c4bc708e2ac2eff1406 --- /dev/null +++ b/tasks/agg-p25-n08-s02/tests/expected.json @@ -0,0 +1 @@ +[2, 6, 18, 22, 33, 46, 73, 88] diff --git a/tasks/agg-p25-n08-s02/tests/test.sh b/tasks/agg-p25-n08-s02/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p25-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-p25-n08-s03/instruction.md b/tasks/agg-p25-n08-s03/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..6c99d3a421a7820e0d5105d7dbdbfe39b5c15b23 --- /dev/null +++ b/tasks/agg-p25-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 eighteen. + +The team must find all 8 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 8 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p25-n08-s03/solution/solve.sh b/tasks/agg-p25-n08-s03/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..813ad3155b4db1cf6585b611945aaa4e9248af7e --- /dev/null +++ b/tasks/agg-p25-n08-s03/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 6, 18, 22, 33, 46, 73, 88]' > "$answer" diff --git a/tasks/agg-p25-n08-s03/task.toml b/tasks/agg-p25-n08-s03/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..c0b80750bd2533fd35b401f1c8a9c8f28dcfe1ba --- /dev/null +++ b/tasks/agg-p25-n08-s03/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p25-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 = 25 +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-p25-n08-s03/tests/expected.json b/tasks/agg-p25-n08-s03/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..02dbdce6ffce318fe47d0c4bc708e2ac2eff1406 --- /dev/null +++ b/tasks/agg-p25-n08-s03/tests/expected.json @@ -0,0 +1 @@ +[2, 6, 18, 22, 33, 46, 73, 88] diff --git a/tasks/agg-p25-n08-s03/tests/test.sh b/tasks/agg-p25-n08-s03/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p25-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-p25-n08-s04/instruction.md b/tasks/agg-p25-n08-s04/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..8fc5da9fd3f2fb4b928fc1ff5a73236e0d218b54 --- /dev/null +++ b/tasks/agg-p25-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 eighty-eight. + +The team must find all 8 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 8 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p25-n08-s04/solution/solve.sh b/tasks/agg-p25-n08-s04/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..813ad3155b4db1cf6585b611945aaa4e9248af7e --- /dev/null +++ b/tasks/agg-p25-n08-s04/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 6, 18, 22, 33, 46, 73, 88]' > "$answer" diff --git a/tasks/agg-p25-n08-s04/task.toml b/tasks/agg-p25-n08-s04/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..946602e540310a4a4d586cc7cd18e2add072309b --- /dev/null +++ b/tasks/agg-p25-n08-s04/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p25-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 = 25 +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-p25-n08-s04/tests/expected.json b/tasks/agg-p25-n08-s04/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..02dbdce6ffce318fe47d0c4bc708e2ac2eff1406 --- /dev/null +++ b/tasks/agg-p25-n08-s04/tests/expected.json @@ -0,0 +1 @@ +[2, 6, 18, 22, 33, 46, 73, 88] diff --git a/tasks/agg-p25-n08-s04/tests/test.sh b/tasks/agg-p25-n08-s04/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p25-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-p25-n08-s05/instruction.md b/tasks/agg-p25-n08-s05/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..cc6db9caeb675d9f6434dc4b0b3050a0227102ba --- /dev/null +++ b/tasks/agg-p25-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-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-p25-n08-s05/solution/solve.sh b/tasks/agg-p25-n08-s05/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..813ad3155b4db1cf6585b611945aaa4e9248af7e --- /dev/null +++ b/tasks/agg-p25-n08-s05/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 6, 18, 22, 33, 46, 73, 88]' > "$answer" diff --git a/tasks/agg-p25-n08-s05/task.toml b/tasks/agg-p25-n08-s05/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..db79e2d3d3f14369efcd686e4cf4f37610c06223 --- /dev/null +++ b/tasks/agg-p25-n08-s05/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p25-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 = 25 +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-p25-n08-s05/tests/expected.json b/tasks/agg-p25-n08-s05/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..02dbdce6ffce318fe47d0c4bc708e2ac2eff1406 --- /dev/null +++ b/tasks/agg-p25-n08-s05/tests/expected.json @@ -0,0 +1 @@ +[2, 6, 18, 22, 33, 46, 73, 88] diff --git a/tasks/agg-p25-n08-s05/tests/test.sh b/tasks/agg-p25-n08-s05/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p25-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-p25-n08-s06/instruction.md b/tasks/agg-p25-n08-s06/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..ac3f976754721a0afc38f69e19af1e9379b5a5f2 --- /dev/null +++ b/tasks/agg-p25-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 seventy-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-p25-n08-s06/solution/solve.sh b/tasks/agg-p25-n08-s06/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..813ad3155b4db1cf6585b611945aaa4e9248af7e --- /dev/null +++ b/tasks/agg-p25-n08-s06/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 6, 18, 22, 33, 46, 73, 88]' > "$answer" diff --git a/tasks/agg-p25-n08-s06/task.toml b/tasks/agg-p25-n08-s06/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..57d6fe6f8017ca53bba9a20227ca2b9005879ef0 --- /dev/null +++ b/tasks/agg-p25-n08-s06/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p25-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 = 25 +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-p25-n08-s06/tests/expected.json b/tasks/agg-p25-n08-s06/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..02dbdce6ffce318fe47d0c4bc708e2ac2eff1406 --- /dev/null +++ b/tasks/agg-p25-n08-s06/tests/expected.json @@ -0,0 +1 @@ +[2, 6, 18, 22, 33, 46, 73, 88] diff --git a/tasks/agg-p25-n08-s06/tests/test.sh b/tasks/agg-p25-n08-s06/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p25-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-p25-n08-s07/instruction.md b/tasks/agg-p25-n08-s07/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..629e2ae1c728c40605589960cbd96dae496187c1 --- /dev/null +++ b/tasks/agg-p25-n08-s07/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 8 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is two. + +The team must find all 8 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 8 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p25-n08-s07/solution/solve.sh b/tasks/agg-p25-n08-s07/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..813ad3155b4db1cf6585b611945aaa4e9248af7e --- /dev/null +++ b/tasks/agg-p25-n08-s07/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 6, 18, 22, 33, 46, 73, 88]' > "$answer" diff --git a/tasks/agg-p25-n08-s07/task.toml b/tasks/agg-p25-n08-s07/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..1192129f8f5484e40f670529cf272f1522e95396 --- /dev/null +++ b/tasks/agg-p25-n08-s07/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p25-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 = 25 +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-p25-n08-s07/tests/expected.json b/tasks/agg-p25-n08-s07/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..02dbdce6ffce318fe47d0c4bc708e2ac2eff1406 --- /dev/null +++ b/tasks/agg-p25-n08-s07/tests/expected.json @@ -0,0 +1 @@ +[2, 6, 18, 22, 33, 46, 73, 88] diff --git a/tasks/agg-p25-n08-s07/tests/test.sh b/tasks/agg-p25-n08-s07/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p25-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-p25-n08-s08/instruction.md b/tasks/agg-p25-n08-s08/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..cf3f948e811657d947ed622b357f1d1ea8535635 --- /dev/null +++ b/tasks/agg-p25-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 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-p25-n08-s08/solution/solve.sh b/tasks/agg-p25-n08-s08/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..813ad3155b4db1cf6585b611945aaa4e9248af7e --- /dev/null +++ b/tasks/agg-p25-n08-s08/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 6, 18, 22, 33, 46, 73, 88]' > "$answer" diff --git a/tasks/agg-p25-n08-s08/task.toml b/tasks/agg-p25-n08-s08/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..5345f9109a9996591bd67201d5c6ac8dd7efc500 --- /dev/null +++ b/tasks/agg-p25-n08-s08/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p25-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 = 25 +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-p25-n08-s08/tests/expected.json b/tasks/agg-p25-n08-s08/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..02dbdce6ffce318fe47d0c4bc708e2ac2eff1406 --- /dev/null +++ b/tasks/agg-p25-n08-s08/tests/expected.json @@ -0,0 +1 @@ +[2, 6, 18, 22, 33, 46, 73, 88] diff --git a/tasks/agg-p25-n08-s08/tests/test.sh b/tasks/agg-p25-n08-s08/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p25-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-p25-n16-s01/instruction.md b/tasks/agg-p25-n16-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..d92b3c67aa869a2b7ccb0b74ca78af94faae0b02 --- /dev/null +++ b/tasks/agg-p25-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-p25-n16-s01/solution/solve.sh b/tasks/agg-p25-n16-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c0f746d228faebc81bc78b6c9f224a38d8260244 --- /dev/null +++ b/tasks/agg-p25-n16-s01/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 3, 6, 6, 18, 19, 21, 21, 21, 22, 33, 46, 57, 73, 73, 88]' > "$answer" diff --git a/tasks/agg-p25-n16-s01/task.toml b/tasks/agg-p25-n16-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..6c6ee82a56eadfda0c8c3583591feb98b023ca65 --- /dev/null +++ b/tasks/agg-p25-n16-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p25-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 = 25 +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-p25-n16-s01/tests/expected.json b/tasks/agg-p25-n16-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e244ac949db663aeb3cc93b195e6abffd220e157 --- /dev/null +++ b/tasks/agg-p25-n16-s01/tests/expected.json @@ -0,0 +1 @@ +[2, 3, 6, 6, 18, 19, 21, 21, 21, 22, 33, 46, 57, 73, 73, 88] diff --git a/tasks/agg-p25-n16-s01/tests/test.sh b/tasks/agg-p25-n16-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p25-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-p25-n16-s02/instruction.md b/tasks/agg-p25-n16-s02/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..ac5d07700d94f2ac8dcfe94fa7b7a0669218f24c --- /dev/null +++ b/tasks/agg-p25-n16-s02/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is twenty-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-p25-n16-s02/solution/solve.sh b/tasks/agg-p25-n16-s02/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c0f746d228faebc81bc78b6c9f224a38d8260244 --- /dev/null +++ b/tasks/agg-p25-n16-s02/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 3, 6, 6, 18, 19, 21, 21, 21, 22, 33, 46, 57, 73, 73, 88]' > "$answer" diff --git a/tasks/agg-p25-n16-s02/task.toml b/tasks/agg-p25-n16-s02/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..134b2319d7e983f16af170c4538c533b0d6f36e9 --- /dev/null +++ b/tasks/agg-p25-n16-s02/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p25-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 = 25 +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-p25-n16-s02/tests/expected.json b/tasks/agg-p25-n16-s02/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e244ac949db663aeb3cc93b195e6abffd220e157 --- /dev/null +++ b/tasks/agg-p25-n16-s02/tests/expected.json @@ -0,0 +1 @@ +[2, 3, 6, 6, 18, 19, 21, 21, 21, 22, 33, 46, 57, 73, 73, 88] diff --git a/tasks/agg-p25-n16-s02/tests/test.sh b/tasks/agg-p25-n16-s02/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p25-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-p25-n16-s03/instruction.md b/tasks/agg-p25-n16-s03/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..57c62f85ec1ef4f9ca9aa899d016621c4b04432a --- /dev/null +++ b/tasks/agg-p25-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 eighteen. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p25-n16-s03/solution/solve.sh b/tasks/agg-p25-n16-s03/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c0f746d228faebc81bc78b6c9f224a38d8260244 --- /dev/null +++ b/tasks/agg-p25-n16-s03/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 3, 6, 6, 18, 19, 21, 21, 21, 22, 33, 46, 57, 73, 73, 88]' > "$answer" diff --git a/tasks/agg-p25-n16-s03/task.toml b/tasks/agg-p25-n16-s03/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..fbb6e7ebc29d16028cdb36f384d7315fdc4a92ea --- /dev/null +++ b/tasks/agg-p25-n16-s03/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p25-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 = 25 +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-p25-n16-s03/tests/expected.json b/tasks/agg-p25-n16-s03/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e244ac949db663aeb3cc93b195e6abffd220e157 --- /dev/null +++ b/tasks/agg-p25-n16-s03/tests/expected.json @@ -0,0 +1 @@ +[2, 3, 6, 6, 18, 19, 21, 21, 21, 22, 33, 46, 57, 73, 73, 88] diff --git a/tasks/agg-p25-n16-s03/tests/test.sh b/tasks/agg-p25-n16-s03/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p25-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-p25-n16-s04/instruction.md b/tasks/agg-p25-n16-s04/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..f197f79da6e4638891b46f2053909c167ec13c32 --- /dev/null +++ b/tasks/agg-p25-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 eighty-eight. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p25-n16-s04/solution/solve.sh b/tasks/agg-p25-n16-s04/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c0f746d228faebc81bc78b6c9f224a38d8260244 --- /dev/null +++ b/tasks/agg-p25-n16-s04/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 3, 6, 6, 18, 19, 21, 21, 21, 22, 33, 46, 57, 73, 73, 88]' > "$answer" diff --git a/tasks/agg-p25-n16-s04/task.toml b/tasks/agg-p25-n16-s04/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..b0aeeb1d5b4a0011367f1d7f14afffbb57b0490c --- /dev/null +++ b/tasks/agg-p25-n16-s04/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p25-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 = 25 +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-p25-n16-s04/tests/expected.json b/tasks/agg-p25-n16-s04/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e244ac949db663aeb3cc93b195e6abffd220e157 --- /dev/null +++ b/tasks/agg-p25-n16-s04/tests/expected.json @@ -0,0 +1 @@ +[2, 3, 6, 6, 18, 19, 21, 21, 21, 22, 33, 46, 57, 73, 73, 88] diff --git a/tasks/agg-p25-n16-s04/tests/test.sh b/tasks/agg-p25-n16-s04/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p25-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-p25-n16-s05/instruction.md b/tasks/agg-p25-n16-s05/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..b3b047922a06bc269fe7ce7c02e822b0dcc610c6 --- /dev/null +++ b/tasks/agg-p25-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-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-p25-n16-s05/solution/solve.sh b/tasks/agg-p25-n16-s05/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c0f746d228faebc81bc78b6c9f224a38d8260244 --- /dev/null +++ b/tasks/agg-p25-n16-s05/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 3, 6, 6, 18, 19, 21, 21, 21, 22, 33, 46, 57, 73, 73, 88]' > "$answer" diff --git a/tasks/agg-p25-n16-s05/task.toml b/tasks/agg-p25-n16-s05/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..36621af4b40aa2e54216ece1c2b003d9a7ab4c68 --- /dev/null +++ b/tasks/agg-p25-n16-s05/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p25-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 = 25 +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-p25-n16-s05/tests/expected.json b/tasks/agg-p25-n16-s05/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e244ac949db663aeb3cc93b195e6abffd220e157 --- /dev/null +++ b/tasks/agg-p25-n16-s05/tests/expected.json @@ -0,0 +1 @@ +[2, 3, 6, 6, 18, 19, 21, 21, 21, 22, 33, 46, 57, 73, 73, 88] diff --git a/tasks/agg-p25-n16-s05/tests/test.sh b/tasks/agg-p25-n16-s05/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p25-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-p25-n16-s06/instruction.md b/tasks/agg-p25-n16-s06/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..57ed1435e76bbf3118473fa8b3b4d8bd26d42701 --- /dev/null +++ b/tasks/agg-p25-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 seventy-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-p25-n16-s06/solution/solve.sh b/tasks/agg-p25-n16-s06/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c0f746d228faebc81bc78b6c9f224a38d8260244 --- /dev/null +++ b/tasks/agg-p25-n16-s06/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 3, 6, 6, 18, 19, 21, 21, 21, 22, 33, 46, 57, 73, 73, 88]' > "$answer" diff --git a/tasks/agg-p25-n16-s06/task.toml b/tasks/agg-p25-n16-s06/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..4ae1f207177edb04a00f01f7d647b869e3c0302e --- /dev/null +++ b/tasks/agg-p25-n16-s06/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p25-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 = 25 +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-p25-n16-s06/tests/expected.json b/tasks/agg-p25-n16-s06/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e244ac949db663aeb3cc93b195e6abffd220e157 --- /dev/null +++ b/tasks/agg-p25-n16-s06/tests/expected.json @@ -0,0 +1 @@ +[2, 3, 6, 6, 18, 19, 21, 21, 21, 22, 33, 46, 57, 73, 73, 88] diff --git a/tasks/agg-p25-n16-s06/tests/test.sh b/tasks/agg-p25-n16-s06/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p25-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-p25-n16-s07/instruction.md b/tasks/agg-p25-n16-s07/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..ebbf18dd1885eca56e4b99d9ba0f301603987c59 --- /dev/null +++ b/tasks/agg-p25-n16-s07/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is two. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p25-n16-s07/solution/solve.sh b/tasks/agg-p25-n16-s07/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c0f746d228faebc81bc78b6c9f224a38d8260244 --- /dev/null +++ b/tasks/agg-p25-n16-s07/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 3, 6, 6, 18, 19, 21, 21, 21, 22, 33, 46, 57, 73, 73, 88]' > "$answer" diff --git a/tasks/agg-p25-n16-s07/task.toml b/tasks/agg-p25-n16-s07/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..f74b1bbf0d8179532770e61a461ab9d1df4ec652 --- /dev/null +++ b/tasks/agg-p25-n16-s07/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p25-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 = 25 +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-p25-n16-s07/tests/expected.json b/tasks/agg-p25-n16-s07/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e244ac949db663aeb3cc93b195e6abffd220e157 --- /dev/null +++ b/tasks/agg-p25-n16-s07/tests/expected.json @@ -0,0 +1 @@ +[2, 3, 6, 6, 18, 19, 21, 21, 21, 22, 33, 46, 57, 73, 73, 88] diff --git a/tasks/agg-p25-n16-s07/tests/test.sh b/tasks/agg-p25-n16-s07/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p25-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-p25-n16-s08/instruction.md b/tasks/agg-p25-n16-s08/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..783fbdc57d72bfcadc0344c5e85549aaa9f3efe7 --- /dev/null +++ b/tasks/agg-p25-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 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-p25-n16-s08/solution/solve.sh b/tasks/agg-p25-n16-s08/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c0f746d228faebc81bc78b6c9f224a38d8260244 --- /dev/null +++ b/tasks/agg-p25-n16-s08/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 3, 6, 6, 18, 19, 21, 21, 21, 22, 33, 46, 57, 73, 73, 88]' > "$answer" diff --git a/tasks/agg-p25-n16-s08/task.toml b/tasks/agg-p25-n16-s08/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..b4555a0a99fa65f26cce77d1f83cdd7d0927a83c --- /dev/null +++ b/tasks/agg-p25-n16-s08/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p25-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 = 25 +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-p25-n16-s08/tests/expected.json b/tasks/agg-p25-n16-s08/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e244ac949db663aeb3cc93b195e6abffd220e157 --- /dev/null +++ b/tasks/agg-p25-n16-s08/tests/expected.json @@ -0,0 +1 @@ +[2, 3, 6, 6, 18, 19, 21, 21, 21, 22, 33, 46, 57, 73, 73, 88] diff --git a/tasks/agg-p25-n16-s08/tests/test.sh b/tasks/agg-p25-n16-s08/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p25-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-p25-n16-s09/instruction.md b/tasks/agg-p25-n16-s09/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..1499aaac42fb5c39eb3846670f67c71d3d44d289 --- /dev/null +++ b/tasks/agg-p25-n16-s09/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is twenty-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-p25-n16-s09/solution/solve.sh b/tasks/agg-p25-n16-s09/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c0f746d228faebc81bc78b6c9f224a38d8260244 --- /dev/null +++ b/tasks/agg-p25-n16-s09/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 3, 6, 6, 18, 19, 21, 21, 21, 22, 33, 46, 57, 73, 73, 88]' > "$answer" diff --git a/tasks/agg-p25-n16-s09/task.toml b/tasks/agg-p25-n16-s09/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..270aebcdb05c2bf817837ade28702ec9f78d9e02 --- /dev/null +++ b/tasks/agg-p25-n16-s09/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p25-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 = 25 +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-p25-n16-s09/tests/expected.json b/tasks/agg-p25-n16-s09/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e244ac949db663aeb3cc93b195e6abffd220e157 --- /dev/null +++ b/tasks/agg-p25-n16-s09/tests/expected.json @@ -0,0 +1 @@ +[2, 3, 6, 6, 18, 19, 21, 21, 21, 22, 33, 46, 57, 73, 73, 88] diff --git a/tasks/agg-p25-n16-s09/tests/test.sh b/tasks/agg-p25-n16-s09/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p25-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-p25-n16-s10/instruction.md b/tasks/agg-p25-n16-s10/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..689dc52da259912a8583e539c40d32957d6e1982 --- /dev/null +++ b/tasks/agg-p25-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 nineteen. + +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-p25-n16-s10/solution/solve.sh b/tasks/agg-p25-n16-s10/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c0f746d228faebc81bc78b6c9f224a38d8260244 --- /dev/null +++ b/tasks/agg-p25-n16-s10/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 3, 6, 6, 18, 19, 21, 21, 21, 22, 33, 46, 57, 73, 73, 88]' > "$answer" diff --git a/tasks/agg-p25-n16-s10/task.toml b/tasks/agg-p25-n16-s10/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..aa7b7addde1774e048775b030736e05aa6947efb --- /dev/null +++ b/tasks/agg-p25-n16-s10/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p25-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 = 25 +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-p25-n16-s10/tests/expected.json b/tasks/agg-p25-n16-s10/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e244ac949db663aeb3cc93b195e6abffd220e157 --- /dev/null +++ b/tasks/agg-p25-n16-s10/tests/expected.json @@ -0,0 +1 @@ +[2, 3, 6, 6, 18, 19, 21, 21, 21, 22, 33, 46, 57, 73, 73, 88] diff --git a/tasks/agg-p25-n16-s10/tests/test.sh b/tasks/agg-p25-n16-s10/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p25-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-p25-n16-s11/instruction.md b/tasks/agg-p25-n16-s11/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..783fbdc57d72bfcadc0344c5e85549aaa9f3efe7 --- /dev/null +++ b/tasks/agg-p25-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 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-p25-n16-s11/solution/solve.sh b/tasks/agg-p25-n16-s11/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c0f746d228faebc81bc78b6c9f224a38d8260244 --- /dev/null +++ b/tasks/agg-p25-n16-s11/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 3, 6, 6, 18, 19, 21, 21, 21, 22, 33, 46, 57, 73, 73, 88]' > "$answer" diff --git a/tasks/agg-p25-n16-s11/task.toml b/tasks/agg-p25-n16-s11/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..eae49bd0109b3586fcb25ab9ba4f490eda5482ff --- /dev/null +++ b/tasks/agg-p25-n16-s11/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p25-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 = 25 +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-p25-n16-s11/tests/expected.json b/tasks/agg-p25-n16-s11/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e244ac949db663aeb3cc93b195e6abffd220e157 --- /dev/null +++ b/tasks/agg-p25-n16-s11/tests/expected.json @@ -0,0 +1 @@ +[2, 3, 6, 6, 18, 19, 21, 21, 21, 22, 33, 46, 57, 73, 73, 88] diff --git a/tasks/agg-p25-n16-s11/tests/test.sh b/tasks/agg-p25-n16-s11/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p25-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-p25-n16-s12/instruction.md b/tasks/agg-p25-n16-s12/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..635dd02b39036aac45824980be06065d4cdbba80 --- /dev/null +++ b/tasks/agg-p25-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 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-p25-n16-s12/solution/solve.sh b/tasks/agg-p25-n16-s12/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c0f746d228faebc81bc78b6c9f224a38d8260244 --- /dev/null +++ b/tasks/agg-p25-n16-s12/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 3, 6, 6, 18, 19, 21, 21, 21, 22, 33, 46, 57, 73, 73, 88]' > "$answer" diff --git a/tasks/agg-p25-n16-s12/task.toml b/tasks/agg-p25-n16-s12/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..66ec3cc0771936539597b5a3d172d7aeba364308 --- /dev/null +++ b/tasks/agg-p25-n16-s12/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p25-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 = 25 +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-p25-n16-s12/tests/expected.json b/tasks/agg-p25-n16-s12/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e244ac949db663aeb3cc93b195e6abffd220e157 --- /dev/null +++ b/tasks/agg-p25-n16-s12/tests/expected.json @@ -0,0 +1 @@ +[2, 3, 6, 6, 18, 19, 21, 21, 21, 22, 33, 46, 57, 73, 73, 88] diff --git a/tasks/agg-p25-n16-s12/tests/test.sh b/tasks/agg-p25-n16-s12/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p25-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-p25-n16-s13/instruction.md b/tasks/agg-p25-n16-s13/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..1499aaac42fb5c39eb3846670f67c71d3d44d289 --- /dev/null +++ b/tasks/agg-p25-n16-s13/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is twenty-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-p25-n16-s13/solution/solve.sh b/tasks/agg-p25-n16-s13/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c0f746d228faebc81bc78b6c9f224a38d8260244 --- /dev/null +++ b/tasks/agg-p25-n16-s13/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 3, 6, 6, 18, 19, 21, 21, 21, 22, 33, 46, 57, 73, 73, 88]' > "$answer" diff --git a/tasks/agg-p25-n16-s13/task.toml b/tasks/agg-p25-n16-s13/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..a787f17627ca36d2d771061c8bc5a9e88288fe04 --- /dev/null +++ b/tasks/agg-p25-n16-s13/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p25-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 = 25 +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-p25-n16-s13/tests/expected.json b/tasks/agg-p25-n16-s13/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e244ac949db663aeb3cc93b195e6abffd220e157 --- /dev/null +++ b/tasks/agg-p25-n16-s13/tests/expected.json @@ -0,0 +1 @@ +[2, 3, 6, 6, 18, 19, 21, 21, 21, 22, 33, 46, 57, 73, 73, 88] diff --git a/tasks/agg-p25-n16-s13/tests/test.sh b/tasks/agg-p25-n16-s13/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p25-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-p25-n16-s14/instruction.md b/tasks/agg-p25-n16-s14/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..57ed1435e76bbf3118473fa8b3b4d8bd26d42701 --- /dev/null +++ b/tasks/agg-p25-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 seventy-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-p25-n16-s14/solution/solve.sh b/tasks/agg-p25-n16-s14/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c0f746d228faebc81bc78b6c9f224a38d8260244 --- /dev/null +++ b/tasks/agg-p25-n16-s14/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 3, 6, 6, 18, 19, 21, 21, 21, 22, 33, 46, 57, 73, 73, 88]' > "$answer" diff --git a/tasks/agg-p25-n16-s14/task.toml b/tasks/agg-p25-n16-s14/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..882ffc60b8393747bed397f1d5b29e671d70447b --- /dev/null +++ b/tasks/agg-p25-n16-s14/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p25-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 = 25 +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-p25-n16-s14/tests/expected.json b/tasks/agg-p25-n16-s14/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e244ac949db663aeb3cc93b195e6abffd220e157 --- /dev/null +++ b/tasks/agg-p25-n16-s14/tests/expected.json @@ -0,0 +1 @@ +[2, 3, 6, 6, 18, 19, 21, 21, 21, 22, 33, 46, 57, 73, 73, 88] diff --git a/tasks/agg-p25-n16-s14/tests/test.sh b/tasks/agg-p25-n16-s14/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p25-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-p25-n16-s15/instruction.md b/tasks/agg-p25-n16-s15/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..842ab62762da159702eecd05bee6231e50b04d8f --- /dev/null +++ b/tasks/agg-p25-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 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-p25-n16-s15/solution/solve.sh b/tasks/agg-p25-n16-s15/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c0f746d228faebc81bc78b6c9f224a38d8260244 --- /dev/null +++ b/tasks/agg-p25-n16-s15/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 3, 6, 6, 18, 19, 21, 21, 21, 22, 33, 46, 57, 73, 73, 88]' > "$answer" diff --git a/tasks/agg-p25-n16-s15/task.toml b/tasks/agg-p25-n16-s15/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..b98f0bbb12c57d684004369dd5435dc80bf11b9f --- /dev/null +++ b/tasks/agg-p25-n16-s15/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p25-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 = 25 +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-p25-n16-s15/tests/expected.json b/tasks/agg-p25-n16-s15/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e244ac949db663aeb3cc93b195e6abffd220e157 --- /dev/null +++ b/tasks/agg-p25-n16-s15/tests/expected.json @@ -0,0 +1 @@ +[2, 3, 6, 6, 18, 19, 21, 21, 21, 22, 33, 46, 57, 73, 73, 88] diff --git a/tasks/agg-p25-n16-s15/tests/test.sh b/tasks/agg-p25-n16-s15/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p25-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-p25-n16-s16/instruction.md b/tasks/agg-p25-n16-s16/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..1499aaac42fb5c39eb3846670f67c71d3d44d289 --- /dev/null +++ b/tasks/agg-p25-n16-s16/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is twenty-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-p25-n16-s16/solution/solve.sh b/tasks/agg-p25-n16-s16/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c0f746d228faebc81bc78b6c9f224a38d8260244 --- /dev/null +++ b/tasks/agg-p25-n16-s16/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[2, 3, 6, 6, 18, 19, 21, 21, 21, 22, 33, 46, 57, 73, 73, 88]' > "$answer" diff --git a/tasks/agg-p25-n16-s16/task.toml b/tasks/agg-p25-n16-s16/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..e78b53e48977e7733a002b7a28bfef8ca1c9ed0d --- /dev/null +++ b/tasks/agg-p25-n16-s16/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p25-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 = 25 +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-p25-n16-s16/tests/expected.json b/tasks/agg-p25-n16-s16/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..e244ac949db663aeb3cc93b195e6abffd220e157 --- /dev/null +++ b/tasks/agg-p25-n16-s16/tests/expected.json @@ -0,0 +1 @@ +[2, 3, 6, 6, 18, 19, 21, 21, 21, 22, 33, 46, 57, 73, 73, 88] diff --git a/tasks/agg-p25-n16-s16/tests/test.sh b/tasks/agg-p25-n16-s16/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p25-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-p26-n01-s01/instruction.md b/tasks/agg-p26-n01-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..be7de43e766e41adf7f3f09c987b8c3545e68d33 --- /dev/null +++ b/tasks/agg-p26-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 twenty-one. + +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-p26-n01-s01/solution/solve.sh b/tasks/agg-p26-n01-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4bb31f5d7b314d539e99e23d3f974987bfed9e48 --- /dev/null +++ b/tasks/agg-p26-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 '[21]' > "$answer" diff --git a/tasks/agg-p26-n01-s01/task.toml b/tasks/agg-p26-n01-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..d38a4e89d01480fbd8936605e61b724ae83c9633 --- /dev/null +++ b/tasks/agg-p26-n01-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p26-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 = 26 +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-p26-n01-s01/tests/expected.json b/tasks/agg-p26-n01-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..2136d173d26ec45cbbb4a515fa8f404fba85494b --- /dev/null +++ b/tasks/agg-p26-n01-s01/tests/expected.json @@ -0,0 +1 @@ +[21] diff --git a/tasks/agg-p26-n01-s01/tests/test.sh b/tasks/agg-p26-n01-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p26-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-p26-n02-s01/instruction.md b/tasks/agg-p26-n02-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..550cdc5c3a47e00d080a9942ae9e64c38ee8e974 --- /dev/null +++ b/tasks/agg-p26-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 twenty-one. + +The team must find all 2 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 2 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p26-n02-s01/solution/solve.sh b/tasks/agg-p26-n02-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..ba5c7de9e7c0fd2e3102a51017f2e4300f68a105 --- /dev/null +++ b/tasks/agg-p26-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 '[20, 21]' > "$answer" diff --git a/tasks/agg-p26-n02-s01/task.toml b/tasks/agg-p26-n02-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..269cfc9973278dc00baa39e13800966bcf6c3bce --- /dev/null +++ b/tasks/agg-p26-n02-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p26-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 = 26 +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-p26-n02-s01/tests/expected.json b/tasks/agg-p26-n02-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..f6e89c4d3a009a35d8843e4e6592395a37e81538 --- /dev/null +++ b/tasks/agg-p26-n02-s01/tests/expected.json @@ -0,0 +1 @@ +[20, 21] diff --git a/tasks/agg-p26-n02-s01/tests/test.sh b/tasks/agg-p26-n02-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p26-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-p26-n02-s02/instruction.md b/tasks/agg-p26-n02-s02/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..01155853905e7076e6da8ca45112bae47f6ac2c2 --- /dev/null +++ b/tasks/agg-p26-n02-s02/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 2 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is twenty. + +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-p26-n02-s02/solution/solve.sh b/tasks/agg-p26-n02-s02/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..ba5c7de9e7c0fd2e3102a51017f2e4300f68a105 --- /dev/null +++ b/tasks/agg-p26-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 '[20, 21]' > "$answer" diff --git a/tasks/agg-p26-n02-s02/task.toml b/tasks/agg-p26-n02-s02/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..93e9973c0a2e04bd03c2d69cb1d12a4f2fb44fdb --- /dev/null +++ b/tasks/agg-p26-n02-s02/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p26-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 = 26 +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-p26-n02-s02/tests/expected.json b/tasks/agg-p26-n02-s02/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..f6e89c4d3a009a35d8843e4e6592395a37e81538 --- /dev/null +++ b/tasks/agg-p26-n02-s02/tests/expected.json @@ -0,0 +1 @@ +[20, 21] diff --git a/tasks/agg-p26-n02-s02/tests/test.sh b/tasks/agg-p26-n02-s02/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p26-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-p26-n04-s01/instruction.md b/tasks/agg-p26-n04-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..1d459a41a5bc548fc489adacacb5b98ea0b37b13 --- /dev/null +++ b/tasks/agg-p26-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 twenty-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-p26-n04-s01/solution/solve.sh b/tasks/agg-p26-n04-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7abc85d74049cab1c00eb4742fd256990357a4a8 --- /dev/null +++ b/tasks/agg-p26-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 '[1, 4, 20, 21]' > "$answer" diff --git a/tasks/agg-p26-n04-s01/task.toml b/tasks/agg-p26-n04-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..1fdb0b6639fe894842cc586852691b3aafd36a6f --- /dev/null +++ b/tasks/agg-p26-n04-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p26-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 = 26 +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-p26-n04-s01/tests/expected.json b/tasks/agg-p26-n04-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..fa26725eff6ef7279aa8b421717bbf2430fe828e --- /dev/null +++ b/tasks/agg-p26-n04-s01/tests/expected.json @@ -0,0 +1 @@ +[1, 4, 20, 21] diff --git a/tasks/agg-p26-n04-s01/tests/test.sh b/tasks/agg-p26-n04-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p26-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-p26-n04-s02/instruction.md b/tasks/agg-p26-n04-s02/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..862177065dd1207d2cfdca97cd16d4c00c321796 --- /dev/null +++ b/tasks/agg-p26-n04-s02/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 4 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is twenty. + +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-p26-n04-s02/solution/solve.sh b/tasks/agg-p26-n04-s02/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7abc85d74049cab1c00eb4742fd256990357a4a8 --- /dev/null +++ b/tasks/agg-p26-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 '[1, 4, 20, 21]' > "$answer" diff --git a/tasks/agg-p26-n04-s02/task.toml b/tasks/agg-p26-n04-s02/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..a02caaf126b5fc54397d3e93d05f9480093c8bc9 --- /dev/null +++ b/tasks/agg-p26-n04-s02/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p26-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 = 26 +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-p26-n04-s02/tests/expected.json b/tasks/agg-p26-n04-s02/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..fa26725eff6ef7279aa8b421717bbf2430fe828e --- /dev/null +++ b/tasks/agg-p26-n04-s02/tests/expected.json @@ -0,0 +1 @@ +[1, 4, 20, 21] diff --git a/tasks/agg-p26-n04-s02/tests/test.sh b/tasks/agg-p26-n04-s02/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p26-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-p26-n04-s03/instruction.md b/tasks/agg-p26-n04-s03/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..4e0ea7af0cbf9f514ae40b7ebdeb8125d1ab0241 --- /dev/null +++ b/tasks/agg-p26-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 four. + +The team must find all 4 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 4 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p26-n04-s03/solution/solve.sh b/tasks/agg-p26-n04-s03/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7abc85d74049cab1c00eb4742fd256990357a4a8 --- /dev/null +++ b/tasks/agg-p26-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 '[1, 4, 20, 21]' > "$answer" diff --git a/tasks/agg-p26-n04-s03/task.toml b/tasks/agg-p26-n04-s03/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..1350a678abdcc377676b7cfb4000e8c3796b13f4 --- /dev/null +++ b/tasks/agg-p26-n04-s03/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p26-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 = 26 +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-p26-n04-s03/tests/expected.json b/tasks/agg-p26-n04-s03/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..fa26725eff6ef7279aa8b421717bbf2430fe828e --- /dev/null +++ b/tasks/agg-p26-n04-s03/tests/expected.json @@ -0,0 +1 @@ +[1, 4, 20, 21] diff --git a/tasks/agg-p26-n04-s03/tests/test.sh b/tasks/agg-p26-n04-s03/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p26-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-p26-n04-s04/instruction.md b/tasks/agg-p26-n04-s04/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..c9fc0cd60b16983bf7800f77c47afe49f90d719e --- /dev/null +++ b/tasks/agg-p26-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 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-p26-n04-s04/solution/solve.sh b/tasks/agg-p26-n04-s04/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7abc85d74049cab1c00eb4742fd256990357a4a8 --- /dev/null +++ b/tasks/agg-p26-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 '[1, 4, 20, 21]' > "$answer" diff --git a/tasks/agg-p26-n04-s04/task.toml b/tasks/agg-p26-n04-s04/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..ec7a638eee72819f23452141e213ac1cd9ea3d19 --- /dev/null +++ b/tasks/agg-p26-n04-s04/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p26-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 = 26 +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-p26-n04-s04/tests/expected.json b/tasks/agg-p26-n04-s04/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..fa26725eff6ef7279aa8b421717bbf2430fe828e --- /dev/null +++ b/tasks/agg-p26-n04-s04/tests/expected.json @@ -0,0 +1 @@ +[1, 4, 20, 21] diff --git a/tasks/agg-p26-n04-s04/tests/test.sh b/tasks/agg-p26-n04-s04/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p26-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-p26-n08-s01/instruction.md b/tasks/agg-p26-n08-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..05e06432c2ceb1d2a551c09739142cd0234ce3f1 --- /dev/null +++ b/tasks/agg-p26-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 twenty-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-p26-n08-s01/solution/solve.sh b/tasks/agg-p26-n08-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6ef27874cb7c0b72b2cbccae110b1874259e8522 --- /dev/null +++ b/tasks/agg-p26-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 '[1, 4, 12, 20, 21, 36, 37, 66]' > "$answer" diff --git a/tasks/agg-p26-n08-s01/task.toml b/tasks/agg-p26-n08-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..099860fe278ae7d4be8d997d3123c16a95a9f5cb --- /dev/null +++ b/tasks/agg-p26-n08-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p26-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 = 26 +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-p26-n08-s01/tests/expected.json b/tasks/agg-p26-n08-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..45b4d2f190a0760c4417769d616d0a7cc8e02d2f --- /dev/null +++ b/tasks/agg-p26-n08-s01/tests/expected.json @@ -0,0 +1 @@ +[1, 4, 12, 20, 21, 36, 37, 66] diff --git a/tasks/agg-p26-n08-s01/tests/test.sh b/tasks/agg-p26-n08-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p26-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-p26-n08-s02/instruction.md b/tasks/agg-p26-n08-s02/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..45eef35ac00156eccf1849f3e7ce1978b9164536 --- /dev/null +++ b/tasks/agg-p26-n08-s02/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 8 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is twenty. + +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-p26-n08-s02/solution/solve.sh b/tasks/agg-p26-n08-s02/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6ef27874cb7c0b72b2cbccae110b1874259e8522 --- /dev/null +++ b/tasks/agg-p26-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 '[1, 4, 12, 20, 21, 36, 37, 66]' > "$answer" diff --git a/tasks/agg-p26-n08-s02/task.toml b/tasks/agg-p26-n08-s02/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..727d2b050b0160919f29b0b3e8f715938a33d030 --- /dev/null +++ b/tasks/agg-p26-n08-s02/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p26-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 = 26 +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-p26-n08-s02/tests/expected.json b/tasks/agg-p26-n08-s02/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..45b4d2f190a0760c4417769d616d0a7cc8e02d2f --- /dev/null +++ b/tasks/agg-p26-n08-s02/tests/expected.json @@ -0,0 +1 @@ +[1, 4, 12, 20, 21, 36, 37, 66] diff --git a/tasks/agg-p26-n08-s02/tests/test.sh b/tasks/agg-p26-n08-s02/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p26-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-p26-n08-s03/instruction.md b/tasks/agg-p26-n08-s03/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..26ddb6283c1971f9d81edaec183ef7aadd75290a --- /dev/null +++ b/tasks/agg-p26-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 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-p26-n08-s03/solution/solve.sh b/tasks/agg-p26-n08-s03/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6ef27874cb7c0b72b2cbccae110b1874259e8522 --- /dev/null +++ b/tasks/agg-p26-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 '[1, 4, 12, 20, 21, 36, 37, 66]' > "$answer" diff --git a/tasks/agg-p26-n08-s03/task.toml b/tasks/agg-p26-n08-s03/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..0b7d0d367f1375d3fb9d407795459967101c7901 --- /dev/null +++ b/tasks/agg-p26-n08-s03/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p26-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 = 26 +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-p26-n08-s03/tests/expected.json b/tasks/agg-p26-n08-s03/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..45b4d2f190a0760c4417769d616d0a7cc8e02d2f --- /dev/null +++ b/tasks/agg-p26-n08-s03/tests/expected.json @@ -0,0 +1 @@ +[1, 4, 12, 20, 21, 36, 37, 66] diff --git a/tasks/agg-p26-n08-s03/tests/test.sh b/tasks/agg-p26-n08-s03/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p26-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-p26-n08-s04/instruction.md b/tasks/agg-p26-n08-s04/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..e45426f396d954e1affff91de56f66666add7d1c --- /dev/null +++ b/tasks/agg-p26-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 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-p26-n08-s04/solution/solve.sh b/tasks/agg-p26-n08-s04/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6ef27874cb7c0b72b2cbccae110b1874259e8522 --- /dev/null +++ b/tasks/agg-p26-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 '[1, 4, 12, 20, 21, 36, 37, 66]' > "$answer" diff --git a/tasks/agg-p26-n08-s04/task.toml b/tasks/agg-p26-n08-s04/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..f1913d250fe8769868203b4602c23360eb3987ee --- /dev/null +++ b/tasks/agg-p26-n08-s04/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p26-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 = 26 +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-p26-n08-s04/tests/expected.json b/tasks/agg-p26-n08-s04/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..45b4d2f190a0760c4417769d616d0a7cc8e02d2f --- /dev/null +++ b/tasks/agg-p26-n08-s04/tests/expected.json @@ -0,0 +1 @@ +[1, 4, 12, 20, 21, 36, 37, 66] diff --git a/tasks/agg-p26-n08-s04/tests/test.sh b/tasks/agg-p26-n08-s04/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p26-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-p26-n08-s05/instruction.md b/tasks/agg-p26-n08-s05/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..4eccb674ece1f5e87026a82210d8ef4929435c03 --- /dev/null +++ b/tasks/agg-p26-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 thirty-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-p26-n08-s05/solution/solve.sh b/tasks/agg-p26-n08-s05/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6ef27874cb7c0b72b2cbccae110b1874259e8522 --- /dev/null +++ b/tasks/agg-p26-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 '[1, 4, 12, 20, 21, 36, 37, 66]' > "$answer" diff --git a/tasks/agg-p26-n08-s05/task.toml b/tasks/agg-p26-n08-s05/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..430acf9d9ec10c7c966211fef4f0155c4672915d --- /dev/null +++ b/tasks/agg-p26-n08-s05/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p26-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 = 26 +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-p26-n08-s05/tests/expected.json b/tasks/agg-p26-n08-s05/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..45b4d2f190a0760c4417769d616d0a7cc8e02d2f --- /dev/null +++ b/tasks/agg-p26-n08-s05/tests/expected.json @@ -0,0 +1 @@ +[1, 4, 12, 20, 21, 36, 37, 66] diff --git a/tasks/agg-p26-n08-s05/tests/test.sh b/tasks/agg-p26-n08-s05/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p26-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-p26-n08-s06/instruction.md b/tasks/agg-p26-n08-s06/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..a94aeebf9e8286b30025fd530a9c33d5587c12ad --- /dev/null +++ b/tasks/agg-p26-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 twelve. + +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-p26-n08-s06/solution/solve.sh b/tasks/agg-p26-n08-s06/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6ef27874cb7c0b72b2cbccae110b1874259e8522 --- /dev/null +++ b/tasks/agg-p26-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 '[1, 4, 12, 20, 21, 36, 37, 66]' > "$answer" diff --git a/tasks/agg-p26-n08-s06/task.toml b/tasks/agg-p26-n08-s06/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..1be386ef22f7bd63a4db91ed93de953e882dce77 --- /dev/null +++ b/tasks/agg-p26-n08-s06/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p26-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 = 26 +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-p26-n08-s06/tests/expected.json b/tasks/agg-p26-n08-s06/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..45b4d2f190a0760c4417769d616d0a7cc8e02d2f --- /dev/null +++ b/tasks/agg-p26-n08-s06/tests/expected.json @@ -0,0 +1 @@ +[1, 4, 12, 20, 21, 36, 37, 66] diff --git a/tasks/agg-p26-n08-s06/tests/test.sh b/tasks/agg-p26-n08-s06/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p26-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-p26-n08-s07/instruction.md b/tasks/agg-p26-n08-s07/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..d28771240990d9554944b9ef68d9203e0acd7f13 --- /dev/null +++ b/tasks/agg-p26-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 thirty-seven. + +The team must find all 8 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 8 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p26-n08-s07/solution/solve.sh b/tasks/agg-p26-n08-s07/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6ef27874cb7c0b72b2cbccae110b1874259e8522 --- /dev/null +++ b/tasks/agg-p26-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 '[1, 4, 12, 20, 21, 36, 37, 66]' > "$answer" diff --git a/tasks/agg-p26-n08-s07/task.toml b/tasks/agg-p26-n08-s07/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..fcffa9a116afd2f407fad41fef3d195fcee42ccb --- /dev/null +++ b/tasks/agg-p26-n08-s07/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p26-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 = 26 +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-p26-n08-s07/tests/expected.json b/tasks/agg-p26-n08-s07/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..45b4d2f190a0760c4417769d616d0a7cc8e02d2f --- /dev/null +++ b/tasks/agg-p26-n08-s07/tests/expected.json @@ -0,0 +1 @@ +[1, 4, 12, 20, 21, 36, 37, 66] diff --git a/tasks/agg-p26-n08-s07/tests/test.sh b/tasks/agg-p26-n08-s07/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p26-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-p26-n08-s08/instruction.md b/tasks/agg-p26-n08-s08/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..ec71f13b5946962c63788849abcae6208cb70629 --- /dev/null +++ b/tasks/agg-p26-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 sixty-six. + +The team must find all 8 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 8 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p26-n08-s08/solution/solve.sh b/tasks/agg-p26-n08-s08/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6ef27874cb7c0b72b2cbccae110b1874259e8522 --- /dev/null +++ b/tasks/agg-p26-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 '[1, 4, 12, 20, 21, 36, 37, 66]' > "$answer" diff --git a/tasks/agg-p26-n08-s08/task.toml b/tasks/agg-p26-n08-s08/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..bc028bc6fa433776cb1753439bbaadf98c0288c9 --- /dev/null +++ b/tasks/agg-p26-n08-s08/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p26-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 = 26 +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-p26-n08-s08/tests/expected.json b/tasks/agg-p26-n08-s08/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..45b4d2f190a0760c4417769d616d0a7cc8e02d2f --- /dev/null +++ b/tasks/agg-p26-n08-s08/tests/expected.json @@ -0,0 +1 @@ +[1, 4, 12, 20, 21, 36, 37, 66] diff --git a/tasks/agg-p26-n08-s08/tests/test.sh b/tasks/agg-p26-n08-s08/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p26-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-p26-n16-s01/instruction.md b/tasks/agg-p26-n16-s01/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..1499aaac42fb5c39eb3846670f67c71d3d44d289 --- /dev/null +++ b/tasks/agg-p26-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 twenty-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-p26-n16-s01/solution/solve.sh b/tasks/agg-p26-n16-s01/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..83cf45db19f33d5f78f4f9c2d880ebad85c660bc --- /dev/null +++ b/tasks/agg-p26-n16-s01/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[1, 2, 4, 12, 20, 21, 22, 28, 36, 37, 47, 66, 75, 77, 94, 97]' > "$answer" diff --git a/tasks/agg-p26-n16-s01/task.toml b/tasks/agg-p26-n16-s01/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..8cb327843d054a4958c8302dc4d746dc129edcef --- /dev/null +++ b/tasks/agg-p26-n16-s01/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p26-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 = 26 +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-p26-n16-s01/tests/expected.json b/tasks/agg-p26-n16-s01/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..cbc3fe371d00556117df4b252dcc9857a400745d --- /dev/null +++ b/tasks/agg-p26-n16-s01/tests/expected.json @@ -0,0 +1 @@ +[1, 2, 4, 12, 20, 21, 22, 28, 36, 37, 47, 66, 75, 77, 94, 97] diff --git a/tasks/agg-p26-n16-s01/tests/test.sh b/tasks/agg-p26-n16-s01/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p26-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-p26-n16-s02/instruction.md b/tasks/agg-p26-n16-s02/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..81577d14ed82fb21b17e0bd51c9dc2a594f0c1b6 --- /dev/null +++ b/tasks/agg-p26-n16-s02/instruction.md @@ -0,0 +1,21 @@ +# Sort the team's private numbers + +You are on a team of 16 agents solving a private-information number sorting task. Each agent +holds one private integer from 1 to 99, written in English words. You know only your own +number, and the others don't know it unless you tell them. + +Your private number is twenty. + +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-p26-n16-s02/solution/solve.sh b/tasks/agg-p26-n16-s02/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..83cf45db19f33d5f78f4f9c2d880ebad85c660bc --- /dev/null +++ b/tasks/agg-p26-n16-s02/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[1, 2, 4, 12, 20, 21, 22, 28, 36, 37, 47, 66, 75, 77, 94, 97]' > "$answer" diff --git a/tasks/agg-p26-n16-s02/task.toml b/tasks/agg-p26-n16-s02/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..a4d724f85438ea422d632ddd725b8091a223308d --- /dev/null +++ b/tasks/agg-p26-n16-s02/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p26-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 = 26 +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-p26-n16-s02/tests/expected.json b/tasks/agg-p26-n16-s02/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..cbc3fe371d00556117df4b252dcc9857a400745d --- /dev/null +++ b/tasks/agg-p26-n16-s02/tests/expected.json @@ -0,0 +1 @@ +[1, 2, 4, 12, 20, 21, 22, 28, 36, 37, 47, 66, 75, 77, 94, 97] diff --git a/tasks/agg-p26-n16-s02/tests/test.sh b/tasks/agg-p26-n16-s02/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p26-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-p26-n16-s03/instruction.md b/tasks/agg-p26-n16-s03/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..9137a4ab46a628c60be0b75972f0a9947e2c3883 --- /dev/null +++ b/tasks/agg-p26-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 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-p26-n16-s03/solution/solve.sh b/tasks/agg-p26-n16-s03/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..83cf45db19f33d5f78f4f9c2d880ebad85c660bc --- /dev/null +++ b/tasks/agg-p26-n16-s03/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[1, 2, 4, 12, 20, 21, 22, 28, 36, 37, 47, 66, 75, 77, 94, 97]' > "$answer" diff --git a/tasks/agg-p26-n16-s03/task.toml b/tasks/agg-p26-n16-s03/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..d5d3ee39027f899a989590a8738a250cf718631b --- /dev/null +++ b/tasks/agg-p26-n16-s03/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p26-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 = 26 +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-p26-n16-s03/tests/expected.json b/tasks/agg-p26-n16-s03/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..cbc3fe371d00556117df4b252dcc9857a400745d --- /dev/null +++ b/tasks/agg-p26-n16-s03/tests/expected.json @@ -0,0 +1 @@ +[1, 2, 4, 12, 20, 21, 22, 28, 36, 37, 47, 66, 75, 77, 94, 97] diff --git a/tasks/agg-p26-n16-s03/tests/test.sh b/tasks/agg-p26-n16-s03/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p26-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-p26-n16-s04/instruction.md b/tasks/agg-p26-n16-s04/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..1a86ea7323aad3c91f00b65904f038f7e58f852d --- /dev/null +++ b/tasks/agg-p26-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 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-p26-n16-s04/solution/solve.sh b/tasks/agg-p26-n16-s04/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..83cf45db19f33d5f78f4f9c2d880ebad85c660bc --- /dev/null +++ b/tasks/agg-p26-n16-s04/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[1, 2, 4, 12, 20, 21, 22, 28, 36, 37, 47, 66, 75, 77, 94, 97]' > "$answer" diff --git a/tasks/agg-p26-n16-s04/task.toml b/tasks/agg-p26-n16-s04/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..85267f4198d794d23c6d67bfbc082561a1521dca --- /dev/null +++ b/tasks/agg-p26-n16-s04/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p26-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 = 26 +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-p26-n16-s04/tests/expected.json b/tasks/agg-p26-n16-s04/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..cbc3fe371d00556117df4b252dcc9857a400745d --- /dev/null +++ b/tasks/agg-p26-n16-s04/tests/expected.json @@ -0,0 +1 @@ +[1, 2, 4, 12, 20, 21, 22, 28, 36, 37, 47, 66, 75, 77, 94, 97] diff --git a/tasks/agg-p26-n16-s04/tests/test.sh b/tasks/agg-p26-n16-s04/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p26-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-p26-n16-s05/instruction.md b/tasks/agg-p26-n16-s05/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..552ad7b188277feadeb521fd17ec24a6f1f8f5ae --- /dev/null +++ b/tasks/agg-p26-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 thirty-six. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p26-n16-s05/solution/solve.sh b/tasks/agg-p26-n16-s05/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..83cf45db19f33d5f78f4f9c2d880ebad85c660bc --- /dev/null +++ b/tasks/agg-p26-n16-s05/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[1, 2, 4, 12, 20, 21, 22, 28, 36, 37, 47, 66, 75, 77, 94, 97]' > "$answer" diff --git a/tasks/agg-p26-n16-s05/task.toml b/tasks/agg-p26-n16-s05/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..94bc2db9747f3c76235adfd4a70c7652030df76d --- /dev/null +++ b/tasks/agg-p26-n16-s05/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p26-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 = 26 +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-p26-n16-s05/tests/expected.json b/tasks/agg-p26-n16-s05/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..cbc3fe371d00556117df4b252dcc9857a400745d --- /dev/null +++ b/tasks/agg-p26-n16-s05/tests/expected.json @@ -0,0 +1 @@ +[1, 2, 4, 12, 20, 21, 22, 28, 36, 37, 47, 66, 75, 77, 94, 97] diff --git a/tasks/agg-p26-n16-s05/tests/test.sh b/tasks/agg-p26-n16-s05/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p26-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-p26-n16-s06/instruction.md b/tasks/agg-p26-n16-s06/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..0d9b54e563f9bb163b48be34eb84abe311c00e06 --- /dev/null +++ b/tasks/agg-p26-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 twelve. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p26-n16-s06/solution/solve.sh b/tasks/agg-p26-n16-s06/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..83cf45db19f33d5f78f4f9c2d880ebad85c660bc --- /dev/null +++ b/tasks/agg-p26-n16-s06/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[1, 2, 4, 12, 20, 21, 22, 28, 36, 37, 47, 66, 75, 77, 94, 97]' > "$answer" diff --git a/tasks/agg-p26-n16-s06/task.toml b/tasks/agg-p26-n16-s06/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..143eb9d07721c8b8011060cb5eea6e8bcfd3244b --- /dev/null +++ b/tasks/agg-p26-n16-s06/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p26-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 = 26 +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-p26-n16-s06/tests/expected.json b/tasks/agg-p26-n16-s06/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..cbc3fe371d00556117df4b252dcc9857a400745d --- /dev/null +++ b/tasks/agg-p26-n16-s06/tests/expected.json @@ -0,0 +1 @@ +[1, 2, 4, 12, 20, 21, 22, 28, 36, 37, 47, 66, 75, 77, 94, 97] diff --git a/tasks/agg-p26-n16-s06/tests/test.sh b/tasks/agg-p26-n16-s06/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b31a5d42a2b1c345b6e2db0e8167bb5c077ed9 --- /dev/null +++ b/tasks/agg-p26-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-p26-n16-s07/instruction.md b/tasks/agg-p26-n16-s07/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..10bcc3d169e35738b1fb80abb7316f9cd7c1b230 --- /dev/null +++ b/tasks/agg-p26-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 thirty-seven. + +The team must find all 16 numbers and list their numeric values in ascending order. Keep equal +numbers from different agents as separate entries: each agent's number appears once in the list, +even when another agent holds the same value. + +1. Share your number with the team on the message board. +2. Read the board for the other participants' numbers. Note which participant each number came + from, so that a number posted more than once is counted once. +3. Once you have one number from every participant, yourself included, write `/app/answer.json` + (create `/app` if needed): a JSON array of the 16 integers, as digits, in ascending order. + Then stop. + +Any agent may write the full answer, and the team succeeds if at least one agent's answer is +correct. Your instructions name the other participants and explain the board's tools. diff --git a/tasks/agg-p26-n16-s07/solution/solve.sh b/tasks/agg-p26-n16-s07/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..83cf45db19f33d5f78f4f9c2d880ebad85c660bc --- /dev/null +++ b/tasks/agg-p26-n16-s07/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Oracle: the team's answer from its own copy (not tests/), to validate the grader. +answer=${ANSWER:-/app/answer.json} +mkdir -p "$(dirname "$answer")" +echo '[1, 2, 4, 12, 20, 21, 22, 28, 36, 37, 47, 66, 75, 77, 94, 97]' > "$answer" diff --git a/tasks/agg-p26-n16-s07/task.toml b/tasks/agg-p26-n16-s07/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..6b2351e86a7faa2d1f2bdcb652a24d5e18b5b4ce --- /dev/null +++ b/tasks/agg-p26-n16-s07/task.toml @@ -0,0 +1,27 @@ +schema_version = "1.4" + +[task] +name = "HuggingFaceSwarms/agg-p26-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 = 26 +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-p26-n16-s07/tests/expected.json b/tasks/agg-p26-n16-s07/tests/expected.json new file mode 100644 index 0000000000000000000000000000000000000000..cbc3fe371d00556117df4b252dcc9857a400745d --- /dev/null +++ b/tasks/agg-p26-n16-s07/tests/expected.json @@ -0,0 +1 @@ +[1, 2, 4, 12, 20, 21, 22, 28, 36, 37, 47, 66, 75, 77, 94, 97]