diff --git a/tasks/format-code-task-000003/environment/Dockerfile b/tasks/format-code-task-000003/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..92add8825461d90288363c301ae468b679529cc2 --- /dev/null +++ b/tasks/format-code-task-000003/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:89d2302961adfe5b768b28b72e5c7a227e24e32d923f2a996b077c85fa3bc428 diff --git a/tasks/format-code-task-000003/environment/setup/files/blocklist b/tasks/format-code-task-000003/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000003/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000003/environment/setup/setup.sh b/tasks/format-code-task-000003/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000003/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000003/tests/test.patch b/tasks/format-code-task-000003/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..fea92471b2bef302caff6f0a150fe95d04e25447 --- /dev/null +++ b/tasks/format-code-task-000003/tests/test.patch @@ -0,0 +1,70 @@ +diff --git a/tests/test_bitwise.py b/tests/test_bitwise.py +index 8e76db2..60aacdc 100644 +--- a/tests/test_bitwise.py ++++ b/tests/test_bitwise.py +@@ -1,6 +1,6 @@ + from smol_evm.constants import MAX_UINT256 + from smol_evm.context import ExecutionContext +-from smol_evm.opcodes import SHR ++from smol_evm.opcodes import SHL, SHR + + import pytest + +@@ -10,6 +10,37 @@ + def context() -> ExecutionContext: + return ExecutionContext() + ++ ++def test_shl_simple(context): ++ SHL.execute(with_stack_contents(context, [16, 1])) ++ assert context.stack.pop() == 32 ++ ++ ++def test_shl_big(context): ++ SHL.execute(with_stack_contents(context, [16, 5])) ++ assert context.stack.pop() == 512 ++ ++ ++def test_shl_by_zero(context): ++ SHL.execute(with_stack_contents(context, [16, 0])) ++ assert context.stack.pop() == 16 ++ ++ ++def test_shl_non_power_of_two(context): ++ SHL.execute(with_stack_contents(context, [15, 1])) ++ assert context.stack.pop() == 30 ++ ++ ++def test_shl_max(context): ++ SHL.execute(with_stack_contents(context, [2 ** 256 - 1, 1])) ++ assert context.stack.pop() == (2 ** 256 - 1) - 1 ++ ++ ++def test_shl_by_max(context): ++ SHL.execute(with_stack_contents(context, [2 ** 256 - 1, 2 ** 256 - 1])) ++ assert context.stack.pop() == 0 ++ ++ + def test_shr_simple(context): + SHR.execute(with_stack_contents(context, [16, 1])) + assert context.stack.pop() == 8 +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,4 @@ ++H4sIAAAAAAAAA+3STQrCMBCG4ax7irmANbFNexyxtmDB/mCi4u2NdVER1E2LiO+zyAxJIANf4uJY ++78t11Z6Wai46yK0davBch97YlTG5XiWJUdoYm6dK7GwTPTg6vzmIqEPX+Xf3Pp3/qHjM31fOr7dd ++02zaMna76d74mH+Wj/nrLOSfZsYq0dON8Nqf578tZQi+qMqov/hd1yayaCS0YVNui7t/jKL259pV ++cX+RxSn69tgAAAAAAAAAAAAAAAAAgiu4iUYAACgAAA== +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000003/tests/test.sh b/tasks/format-code-task-000003/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..da57bc80c295b68db4f2046313fb70fdf594242b --- /dev/null +++ b/tasks/format-code-task-000003/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/test_bitwise.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000003/tests/test_command.sh b/tasks/format-code-task-000003/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000003/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000004/environment/Dockerfile b/tasks/format-code-task-000004/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..3c0ce40f3c92c3c2c363b7ed32c4781a6c34003a --- /dev/null +++ b/tasks/format-code-task-000004/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:2777136eb50329705f24b2400b691aade6b6942117011fbb9399aa3ad3cc1bd0 diff --git a/tasks/format-code-task-000004/environment/setup/files/blocklist b/tasks/format-code-task-000004/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000004/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000004/environment/setup/setup.sh b/tasks/format-code-task-000004/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000004/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000004/tests/test.patch b/tasks/format-code-task-000004/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..23d826d50f7b148c85a22f98376f8a45032f08b3 --- /dev/null +++ b/tasks/format-code-task-000004/tests/test.patch @@ -0,0 +1,59 @@ +diff --git a/api/tests/unit/application/organizations/index_test.js b/api/tests/unit/application/organizations/index_test.js +index 7617d3b3ca3..070ae31847e 100644 +--- a/api/tests/unit/application/organizations/index_test.js ++++ b/api/tests/unit/application/organizations/index_test.js +@@ -26,10 +26,10 @@ describe('Unit | Router | organization-router', () => { + + describe('GET /api/organizations', () => { + +- it('should exist', async () => { ++ it('should return OK (200) when request is valid', async () => { + // given + const method = 'GET'; +- const url = '/api/organizations?filter[name]=DRA&filter[type]=AZ&filter[type]=SCO&page[number]=3&page[size]=25'; ++ const url = '/api/organizations?filter[id]=&filter[name]=DRA&filter[type]=SCO&page[number]=3&page[size]=25'; + + // when + const response = await httpTestServer.request(method, url); +@@ -37,6 +37,19 @@ describe('Unit | Router | organization-router', () => { + // then + expect(response.statusCode).to.equal(200); + }); ++ ++ it('should return BadRequest (400) when request is invalid', async () => { ++ ++ const method = 'GET'; ++ const idNotNumeric = 'foo'; ++ const url = `/api/organizations?filter[id]=${idNotNumeric}`; ++ ++ ++ const response = await httpTestServer.request(method, url); ++ ++ ++ expect(response.statusCode).to.equal(400); ++ }); + }); + + describe('POST /api/organizations/{id}/invitations', () => { +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,6 @@ ++H4sIAAAAAAAAA+3SQU+DMBgGYM77FTWeRweBceKAGTczE4dem0Ibqdla0haz+OvtOKgx0V22LIvv ++c/kK/Voa3sbtqLaCSf1Go3NZBEWeTzX4WadxkqdJssyyrAh9YZSkEcnPdqJvRue5JSSyxvi/+o7N ++X6n4K38vnWed2e24FrHrT/eNY/mnafGZ/yLNQv7ZMskjsjjdEX73z/O/vaGt0rTlrp91gkyXoJWC ++8kHN1g+rmtXr5/LwkjT1pmGrqqnuqk3Nnh7vy5YLNtot0cOe7EzXczKfy73yoVg5GOulLYXx5LDc ++0VErH7YdtqrjXhlNjX3hWr1PD44qLeSeHVrjVze79G8BAAAAAAAAAAAAAAAAAAAAALgKH3/Xkb4A ++KAAA +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000004/tests/test.sh b/tasks/format-code-task-000004/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..63ab97b11506fed4b6d9a826cb19e12e4da3a4ad --- /dev/null +++ b/tasks/format-code-task-000004/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +api/tests/unit/application/organizations/index_test.js +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000004/tests/test_command.sh b/tasks/format-code-task-000004/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000004/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000050/environment/Dockerfile b/tasks/format-code-task-000050/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6b169900c75a6dd73f47ce6d2eec49343053381c --- /dev/null +++ b/tasks/format-code-task-000050/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:5c76dad6079c8df3a423a02bbde6d2127bec286baff71f3de5411b1ebade3ffc diff --git a/tasks/format-code-task-000050/environment/setup/files/blocklist b/tasks/format-code-task-000050/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000050/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000050/environment/setup/setup.sh b/tasks/format-code-task-000050/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000050/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000050/tests/test.patch b/tasks/format-code-task-000050/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e4ff3a92da55a89eb9fc108f667b234363047574 --- /dev/null +++ b/tasks/format-code-task-000050/tests/test.patch @@ -0,0 +1,279 @@ +diff --git a/tests/__init__.py b/tests/__init__.py +new file mode 100644 +index 00000000..e69de29b +diff --git a/tests/core/__init__.py b/tests/core/__init__.py +new file mode 100644 +index 00000000..e69de29b +diff --git a/tests/core/test_config.py b/tests/core/test_config.py +new file mode 100644 +index 00000000..57bcea73 +--- /dev/null ++++ b/tests/core/test_config.py +@@ -0,0 +1,226 @@ ++ ++import asyncio ++import itertools ++ ++import pytest ++ ++from core.config import Config ++ ++ ++ ++_counter = itertools.count() ++ ++ ++def make_conf(force_registration=False): ++ name = "TestCog{}".format(next(_counter)) ++ return Config.get_conf(name, unique_identifier=next(_counter), ++ force_registration=force_registration) ++ ++ ++def run(coro): ++ ++ loop = asyncio.new_event_loop() ++ try: ++ return loop.run_until_complete(coro) ++ finally: ++ loop.close() ++ ++ ++class FakeIdObject: ++ def __init__(self, id): ++ self.id = id ++ ++ ++ ++ ++def test_global_default_returned_when_unset(): ++ conf = make_conf() ++ conf.register_global(foo=42, bar="baz") ++ assert conf.foo() == 42 ++ assert conf.bar() == "baz" ++ ++ ++def test_global_set_then_read(): ++ conf = make_conf() ++ conf.register_global(foo=42) ++ run(conf.set("foo", 100)) ++ assert conf.foo() == 100 ++ ++ ++def test_unregistered_read_returns_none_without_strict(): ++ conf = make_conf() ++ assert conf.nonexistent() is None ++ ++ ++def test_set_unregistered_allowed_without_strict(): ++ conf = make_conf() ++ run(conf.set("dynamic", 7)) ++ assert conf.dynamic() == 7 ++ ++ ++ ++ ++def test_guild_default_and_set(): ++ conf = make_conf() ++ conf.register_guild(prefix="!") ++ assert conf.guild(1).prefix() == "!" ++ run(conf.guild(1).set("prefix", "?")) ++ assert conf.guild(1).prefix() == "?" ++ ++ ++def test_guild_isolation_between_ids(): ++ conf = make_conf() ++ conf.register_guild(prefix="!") ++ run(conf.guild(1).set("prefix", "?")) ++ assert conf.guild(1).prefix() == "?" ++ assert conf.guild(2).prefix() == "!" ++ ++ ++def test_guild_does_not_leak_into_global(): ++ conf = make_conf() ++ conf.register_global(value=0) ++ conf.register_guild(value=0) ++ run(conf.guild(1).set("value", 99)) ++ assert conf.value() == 0 ++ assert conf.guild(2).value() == 0 ++ ++ ++def test_scopes_have_independent_keysets(): ++ conf = make_conf() ++ conf.register_global(only_global=1) ++ conf.register_guild(only_guild=2) ++ assert conf.only_global() == 1 ++ assert conf.guild(1).only_global() is None ++ assert conf.guild(1).only_guild() == 2 ++ assert conf.only_guild() is None ++ ++ ++ ++ ++def test_channel_role_user_scopes(): ++ conf = make_conf() ++ conf.register_channel(a=1) ++ conf.register_role(b=2) ++ conf.register_user(c=3) ++ ++ assert conf.channel(10).a() == 1 ++ assert conf.role(10).b() == 2 ++ assert conf.user(10).c() == 3 ++ ++ run(conf.channel(10).set("a", 11)) ++ run(conf.role(10).set("b", 22)) ++ run(conf.user(10).set("c", 33)) ++ ++ assert conf.channel(10).a() == 11 ++ assert conf.channel(99).a() == 1 ++ assert conf.role(10).b() == 22 ++ assert conf.role(99).b() == 2 ++ assert conf.user(10).c() == 33 ++ assert conf.user(99).c() == 3 ++ ++ ++ ++ ++def test_member_default_and_set(): ++ conf = make_conf() ++ conf.register_member(points=0) ++ assert conf.member(1, 5).points() == 0 ++ run(conf.member(1, 5).set("points", 50)) ++ assert conf.member(1, 5).points() == 50 ++ ++ ++def test_member_composite_isolation(): ++ conf = make_conf() ++ conf.register_member(points=0) ++ run(conf.member(1, 5).set("points", 50)) ++ ++ assert conf.member(2, 5).points() == 0 ++ ++ assert conf.member(1, 6).points() == 0 ++ assert conf.member(1, 5).points() == 50 ++ ++ ++ ++ ++def test_id_object_equivalent_to_int(): ++ conf = make_conf() ++ conf.register_guild(prefix="!") ++ run(conf.guild(123).set("prefix", "$")) ++ assert conf.guild(FakeIdObject(123)).prefix() == "$" ++ run(conf.guild(FakeIdObject(123)).set("prefix", "%")) ++ assert conf.guild(123).prefix() == "%" ++ ++ ++def test_member_id_objects(): ++ conf = make_conf() ++ conf.register_member(points=0) ++ run(conf.member(FakeIdObject(1), FakeIdObject(5)).set("points", 7)) ++ assert conf.member(1, 5).points() == 7 ++ ++ ++ ++ ++def test_clear_resets_scope_to_defaults(): ++ conf = make_conf() ++ conf.register_guild(prefix="!") ++ run(conf.guild(1).set("prefix", "?")) ++ assert conf.guild(1).prefix() == "?" ++ run(conf.guild(1).clear()) ++ assert conf.guild(1).prefix() == "!" ++ ++ ++def test_clear_only_affects_target_scope(): ++ conf = make_conf() ++ conf.register_guild(prefix="!") ++ run(conf.guild(1).set("prefix", "?")) ++ run(conf.guild(2).set("prefix", ".")) ++ run(conf.guild(1).clear()) ++ assert conf.guild(1).prefix() == "!" ++ assert conf.guild(2).prefix() == "." ++ ++ ++ ++ ++def test_register_merges_and_overrides(): ++ conf = make_conf() ++ conf.register_global(a=1, b=2) ++ conf.register_global(b=20, c=3) ++ assert conf.a() == 1 ++ assert conf.b() == 20 ++ assert conf.c() == 3 ++ ++ ++ ++ ++def test_strict_read_unregistered_raises(): ++ conf = make_conf(force_registration=True) ++ conf.register_global(known=1) ++ with pytest.raises(AttributeError): ++ conf.unknown() ++ ++ ++def test_strict_set_unregistered_raises(): ++ conf = make_conf(force_registration=True) ++ conf.register_global(known=1) ++ with pytest.raises(AttributeError): ++ run(conf.set("unknown", 5)) ++ ++ ++def test_strict_registered_key_works(): ++ conf = make_conf(force_registration=True) ++ conf.register_global(known=1) ++ conf.register_guild(gkey=2) ++ assert conf.known() == 1 ++ run(conf.set("known", 9)) ++ assert conf.known() == 9 ++ assert conf.guild(1).gkey() == 2 ++ run(conf.guild(1).set("gkey", 8)) ++ assert conf.guild(1).gkey() == 8 ++ ++ ++def test_strict_is_per_scope(): ++ conf = make_conf(force_registration=True) ++ conf.register_global(known=1) ++ ++ with pytest.raises(AttributeError): ++ conf.guild(1).known() +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,36 @@ ++#!/usr/bin/env bash ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++ ++ ++ ++ ++ ++SP="$PWD/.venv/lib/python3.12/site-packages" ++if [ ! -f "$SP/pytest/__init__.pyc" ]; then ++ find "$SP" -type d -name __pycache__ | while read -r d; do ++ parent="$(dirname "$d")" ++ for f in "$d"/*.cpython-312.pyc; do ++ [ -e "$f" ] || continue ++ base="$(basename "$f" .cpython-312.pyc)" ++ [ -e "$parent/$base.pyc" ] || cp "$f" "$parent/$base.pyc" ++ done ++ done ++fi ++export PYTHONPATH="$SP" ++ ++ ++ ++ ++python3 -c "import core, core.json_io, core.utils.chat_formatting" ++ ++ ++python3 -m pytest tests/core/test_config.py -q diff --git a/tasks/format-code-task-000050/tests/test.sh b/tasks/format-code-task-000050/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..4ba430e645798432e0474cea4ddf3b5a5b0d0ec2 --- /dev/null +++ b/tasks/format-code-task-000050/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/__init__.py +tests/core/__init__.py +tests/core/test_config.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000050/tests/test_command.sh b/tasks/format-code-task-000050/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000050/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000057/environment/Dockerfile b/tasks/format-code-task-000057/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..14be32f019207542bce715e0472aacfba1a98901 --- /dev/null +++ b/tasks/format-code-task-000057/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:9e1d3d6484d0d443aca802000639cf5901c142a256071f20732052cfb972204b diff --git a/tasks/format-code-task-000057/environment/setup/files/blocklist b/tasks/format-code-task-000057/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000057/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000057/environment/setup/setup.sh b/tasks/format-code-task-000057/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000057/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000057/tests/test.patch b/tasks/format-code-task-000057/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..7ceffe306d637b40a2c51bad54b0ab68acb36dc2 --- /dev/null +++ b/tasks/format-code-task-000057/tests/test.patch @@ -0,0 +1,103 @@ +diff --git a/pkg/logs/internal/decoder/auto_multiline_detection/user_samples_test.go b/pkg/logs/internal/decoder/auto_multiline_detection/user_samples_test.go +index db74b9efe4d554..db348cef768b93 100644 +--- a/pkg/logs/internal/decoder/auto_multiline_detection/user_samples_test.go ++++ b/pkg/logs/internal/decoder/auto_multiline_detection/user_samples_test.go +@@ -80,6 +80,36 @@ logs_config: + assert.Equal(t, aggregate, samples.samples[2].label) + } + ++func TestUserPatternsJSON(t *testing.T) { ++ ++ mockConfig := mock.New(t) ++ mockConfig.SetWithoutSource("logs_config.auto_multi_line_detection_custom_samples", `[{"sample": "1", "label": "start_group"}, {"regex": "\\d\\w", "label": "no_aggregate"}, {"sample": "3", "match_threshold": 0.1}]`) ++ ++ samples := NewUserSamples(mockConfig) ++ assert.Equal(t, 3, len(samples.samples)) ++ assert.Equal(t, startGroup, samples.samples[0].label) ++ assert.Equal(t, "1", samples.samples[0].Sample) ++ assert.Equal(t, noAggregate, samples.samples[1].label) ++ assert.Equal(t, "\\d\\w", samples.samples[1].Regex) ++ assert.Equal(t, "3", samples.samples[2].Sample) ++ assert.Equal(t, 0.1, samples.samples[2].matchThreshold) ++} ++ ++func TestUserPatternsJSONEnv(t *testing.T) { ++ ++ mockConfig := mock.New(t) ++ t.Setenv("DD_LOGS_CONFIG_AUTO_MULTI_LINE_DETECTION_CUSTOM_SAMPLES", `[{"sample": "1", "label": "start_group"}, {"regex": "\\d\\w", "label": "no_aggregate"}, {"sample": "3", "match_threshold": 0.1}]`) ++ ++ samples := NewUserSamples(mockConfig) ++ assert.Equal(t, 3, len(samples.samples)) ++ assert.Equal(t, startGroup, samples.samples[0].label) ++ assert.Equal(t, "1", samples.samples[0].Sample) ++ assert.Equal(t, noAggregate, samples.samples[1].label) ++ assert.Equal(t, "\\d\\w", samples.samples[1].Regex) ++ assert.Equal(t, "3", samples.samples[2].Sample) ++ assert.Equal(t, 0.1, samples.samples[2].matchThreshold) ++} ++ + func TestUserPatternsMatchThreshold(t *testing.T) { + + datadogYaml := ` +@@ -221,6 +251,40 @@ logs_config: + } + } + ++func TestOnlyLegacyPatterns(t *testing.T) { ++ ++ datadogYaml := ` ++logs_config: ++ auto_multi_line_extra_patterns: ++ - "le\\wacy" ++` ++ ++ mockConfig := mock.NewFromYAML(t, datadogYaml) ++ samples := NewUserSamples(mockConfig) ++ tokenizer := NewTokenizer(60) ++ ++ tests := []struct { ++ expectedLabel Label ++ shouldStop bool ++ input string ++ }{ ++ {startGroup, false, "legacy pattern should match me"}, ++ {startGroup, false, "leAacy pattern should match me"}, ++ {startGroup, false, "leVacy pattern should match me"}, ++ } ++ ++ for _, test := range tests { ++ context := &messageContext{ ++ rawMessage: []byte(test.input), ++ label: aggregate, ++ } ++ ++ assert.True(t, tokenizer.ProcessAndContinue(context)) ++ assert.Equal(t, test.shouldStop, samples.ProcessAndContinue(context), "Expected stop %v, got %v", test.shouldStop, samples.ProcessAndContinue(context)) ++ assert.Equal(t, test.expectedLabel, context.label, "Expected label %v, got %v", test.expectedLabel, context.label) ++ } ++} ++ + func TestUserPatternsProcessRegexCustomSettings(t *testing.T) { + + datadogYaml := ` +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,5 @@ ++H4sIAAAAAAAAA+3RTU7DMBAFYK97Cl+g8Q/YWXGWKLWtYOF4UDLu+QlZAEKCbloh1PdtZiSP5Bm9 ++7tRyiUOqZyVuRW965/a6+V733jhrrO6tN15oY7x+ENLdbKMv2srjIqVYiPi3uUvv/1T3mT+nlYdA ++8zzW2K3P1/vjUv7G+o/8Xb/NmUdvrZD6eiv87M7zD1HuwZ9SPEwk31vZqdeXSRWaVpUrp6WORcUU ++KKZFjY1pmFvhXHJNQ0ycAmeqSh7P8hioVX4yh7++CgAAAAAAAAAAAAAAAAAAAADgPrwBnZTdPwAo ++AAA= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000057/tests/test.sh b/tasks/format-code-task-000057/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..aa397df96abaae7ca052dcd71c2a1af4398fb49d --- /dev/null +++ b/tasks/format-code-task-000057/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +pkg/logs/internal/decoder/auto_multiline_detection/user_samples_test.go +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000057/tests/test_command.sh b/tasks/format-code-task-000057/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000057/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000059/environment/Dockerfile b/tasks/format-code-task-000059/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..9e0a4eadbcf192aa8ff2ffbcff4d2092a1ff156d --- /dev/null +++ b/tasks/format-code-task-000059/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:bd1d7cd57d1a31aa1b5c6a49553932a1c321d040c15b0b962045f5a25a859667 diff --git a/tasks/format-code-task-000059/environment/setup/files/blocklist b/tasks/format-code-task-000059/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000059/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000059/environment/setup/setup.sh b/tasks/format-code-task-000059/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000059/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000059/tests/test.patch b/tasks/format-code-task-000059/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..7e94ea374d767a44ba5595e4e71a51df568a5d3c --- /dev/null +++ b/tasks/format-code-task-000059/tests/test.patch @@ -0,0 +1,336 @@ +diff --git a/apis/datadoghq/v2alpha1/datadogagent_update_strategy_schema_test.go b/apis/datadoghq/v2alpha1/datadogagent_update_strategy_schema_test.go +new file mode 100644 +index 00000000..482aa990 +--- /dev/null ++++ b/apis/datadoghq/v2alpha1/datadogagent_update_strategy_schema_test.go +@@ -0,0 +1,115 @@ ++package v2alpha1 ++ ++import ( ++ "os" ++ "path/filepath" ++ "testing" ++ ++ "github.com/stretchr/testify/assert" ++ "github.com/stretchr/testify/require" ++ "sigs.k8s.io/yaml" ++) ++ ++func TestDatadogAgentOverrideUpdateStrategyIsExposedInCRDSchema(t *testing.T) { ++ ++ crdPath := filepath.Join("..", "..", "..", "config", "crd", "bases", "v1", "datadoghq.com_datadogagents.yaml") ++ raw, err := os.ReadFile(crdPath) ++ require.NoError(t, err) ++ ++ var crd map[string]interface{} ++ require.NoError(t, yaml.Unmarshal(raw, &crd)) ++ ++ var updateStrategySchema map[string]interface{} ++ for _, candidate := range findObjectProperties(crd, "updateStrategy") { ++ candidateProperties := properties(candidate) ++ rollingUpdate, hasRollingUpdate := candidateProperties["rollingUpdate"] ++ rollingProperties := properties(rollingUpdate) ++ if _, hasType := candidateProperties["type"]; hasType && hasRollingUpdate && rollingProperties["maxUnavailable"] != nil && rollingProperties["maxSurge"] != nil { ++ updateStrategySchema = candidate ++ break ++ } ++ } ++ require.NotNil(t, updateStrategySchema, "component override schema should expose updateStrategy with rollingUpdate limits") ++ ++ strategyType, ok := properties(updateStrategySchema)["type"] ++ require.True(t, ok, "updateStrategy should expose a strategy type") ++ assert.Equal(t, "string", fieldString(strategyType, "type")) ++ ++ rollingUpdate, ok := properties(updateStrategySchema)["rollingUpdate"] ++ require.True(t, ok, "updateStrategy should expose rollingUpdate limits") ++ ++ rollingProperties := properties(rollingUpdate) ++ assertIntOrStringSchema(t, rollingProperties["maxUnavailable"], "maxUnavailable") ++ assertIntOrStringSchema(t, rollingProperties["maxSurge"], "maxSurge") ++} ++ ++func findObjectProperties(node interface{}, property string) []map[string]interface{} { ++ switch value := node.(type) { ++ case map[string]interface{}: ++ var matches []map[string]interface{} ++ if props := properties(value); props != nil { ++ if found, ok := props[property].(map[string]interface{}); ok { ++ matches = append(matches, found) ++ } ++ } ++ for _, child := range value { ++ matches = append(matches, findObjectProperties(child, property)...) ++ } ++ return matches ++ case []interface{}: ++ var matches []map[string]interface{} ++ for _, child := range value { ++ matches = append(matches, findObjectProperties(child, property)...) ++ } ++ return matches ++ default: ++ return nil ++ } ++} ++ ++func properties(schema interface{}) map[string]interface{} { ++ value, ok := schema.(map[string]interface{}) ++ if !ok { ++ return nil ++ } ++ props, ok := value["properties"].(map[string]interface{}) ++ if !ok { ++ return nil ++ } ++ return props ++} ++ ++func assertIntOrStringSchema(t *testing.T, schema interface{}, field string) { ++ t.Helper() ++ ++ value := requireMap(t, schema, field) ++ ++ assert.Equal(t, true, value["x-kubernetes-int-or-string"], "%s should preserve Kubernetes IntOrString schema semantics", field) ++ ++ branches, ok := value["anyOf"].([]interface{}) ++ require.True(t, ok, "%s should allow integer and string branches", field) ++ ++ seen := map[string]bool{} ++ for _, branch := range branches { ++ seen[fieldString(branch, "type")] = true ++ } ++ assert.True(t, seen["integer"], "%s should allow integer values", field) ++ assert.True(t, seen["string"], "%s should allow string values", field) ++} ++ ++func requireMap(t *testing.T, value interface{}, name string) map[string]interface{} { ++ t.Helper() ++ ++ result, ok := value.(map[string]interface{}) ++ require.True(t, ok, "%s should be an object schema", name) ++ return result ++} ++ ++func fieldString(value interface{}, field string) string { ++ object, ok := value.(map[string]interface{}) ++ if !ok { ++ return "" ++ } ++ text, _ := object[field].(string) ++ return text ++} +diff --git a/controllers/datadogagent/override/daemonset_test.go b/controllers/datadogagent/override/daemonset_test.go +new file mode 100644 +index 00000000..22511049 +--- /dev/null ++++ b/controllers/datadogagent/override/daemonset_test.go +@@ -0,0 +1,96 @@ ++package override ++ ++import ( ++ "encoding/json" ++ "testing" ++ ++ "github.com/DataDog/datadog-operator/apis/datadoghq/v2alpha1" ++ "github.com/stretchr/testify/assert" ++ "github.com/stretchr/testify/require" ++ appsv1 "k8s.io/api/apps/v1" ++ "k8s.io/apimachinery/pkg/util/intstr" ++) ++ ++func TestDaemonSetAppliesUpdateStrategyFromJSONOverride(t *testing.T) { ++ tests := []struct { ++ name string ++ overrideJSON string ++ expectedType appsv1.DaemonSetUpdateStrategyType ++ expectedUnavailable *intstr.IntOrString ++ expectedSurge *intstr.IntOrString ++ }{ ++ { ++ name: "rolling update keeps percentage limits", ++ overrideJSON: `{ ++ "updateStrategy": { ++ "type": "RollingUpdate", ++ "rollingUpdate": { ++ "maxUnavailable": "30%", ++ "maxSurge": "20%" ++ } ++ } ++ }`, ++ expectedType: appsv1.RollingUpdateDaemonSetStrategyType, ++ expectedUnavailable: intOrStringPtr(intstr.FromString("30%")), ++ expectedSurge: intOrStringPtr(intstr.FromString("20%")), ++ }, ++ { ++ name: "rolling update keeps numeric limits", ++ overrideJSON: `{ ++ "updateStrategy": { ++ "type": "RollingUpdate", ++ "rollingUpdate": { ++ "maxUnavailable": 3, ++ "maxSurge": 2 ++ } ++ } ++ }`, ++ expectedType: appsv1.RollingUpdateDaemonSetStrategyType, ++ expectedUnavailable: intOrStringPtr(intstr.FromInt(3)), ++ expectedSurge: intOrStringPtr(intstr.FromInt(2)), ++ }, ++ { ++ name: "non rolling strategy keeps the requested type", ++ overrideJSON: `{ ++ "updateStrategy": { ++ "type": "OnDelete" ++ } ++ }`, ++ expectedType: appsv1.OnDeleteDaemonSetStrategyType, ++ }, ++ } ++ ++ for _, tt := range tests { ++ t.Run(tt.name, func(t *testing.T) { ++ daemonSet := appsv1.DaemonSet{} ++ override := componentOverrideFromJSON(t, tt.overrideJSON) ++ ++ DaemonSet(&daemonSet, &override) ++ ++ assert.Equal(t, tt.expectedType, daemonSet.Spec.UpdateStrategy.Type) ++ if tt.expectedUnavailable != nil || tt.expectedSurge != nil { ++ require.NotNil(t, daemonSet.Spec.UpdateStrategy.RollingUpdate) ++ } ++ if tt.expectedUnavailable != nil { ++ require.NotNil(t, daemonSet.Spec.UpdateStrategy.RollingUpdate.MaxUnavailable) ++ assert.Equal(t, *tt.expectedUnavailable, *daemonSet.Spec.UpdateStrategy.RollingUpdate.MaxUnavailable) ++ } ++ if tt.expectedSurge != nil { ++ require.NotNil(t, daemonSet.Spec.UpdateStrategy.RollingUpdate.MaxSurge) ++ assert.Equal(t, *tt.expectedSurge, *daemonSet.Spec.UpdateStrategy.RollingUpdate.MaxSurge) ++ } ++ }) ++ } ++} ++ ++func componentOverrideFromJSON(t *testing.T, payload string) v2alpha1.DatadogAgentComponentOverride { ++ t.Helper() ++ ++ var override v2alpha1.DatadogAgentComponentOverride ++ require.NoError(t, json.Unmarshal([]byte(payload), &override)) ++ return override ++} ++ ++func intOrStringPtr(value intstr.IntOrString) *intstr.IntOrString { ++ return &value ++} +diff --git a/controllers/datadogagent/override/deploymentspec_test.go b/controllers/datadogagent/override/deploymentspec_test.go +index 2d6a165a..5f4218a3 100644 +--- a/controllers/datadogagent/override/deploymentspec_test.go ++++ b/controllers/datadogagent/override/deploymentspec_test.go +@@ -11,10 +11,84 @@ import ( + "github.com/DataDog/datadog-operator/apis/datadoghq/v2alpha1" + apiutils "github.com/DataDog/datadog-operator/apis/utils" + "github.com/stretchr/testify/assert" ++ "github.com/stretchr/testify/require" + v1 "k8s.io/api/apps/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ++ "k8s.io/apimachinery/pkg/util/intstr" + ) + ++func TestDeploymentAppliesUpdateStrategyFromJSONOverride(t *testing.T) { ++ tests := []struct { ++ name string ++ overrideJSON string ++ expectedType v1.DeploymentStrategyType ++ expectedUnavailable *intstr.IntOrString ++ expectedSurge *intstr.IntOrString ++ }{ ++ { ++ name: "rolling update keeps percentage limits", ++ overrideJSON: `{ ++ "updateStrategy": { ++ "type": "RollingUpdate", ++ "rollingUpdate": { ++ "maxUnavailable": "25%", ++ "maxSurge": "15%" ++ } ++ } ++ }`, ++ expectedType: v1.RollingUpdateDeploymentStrategyType, ++ expectedUnavailable: intOrStringPtr(intstr.FromString("25%")), ++ expectedSurge: intOrStringPtr(intstr.FromString("15%")), ++ }, ++ { ++ name: "rolling update keeps numeric limits", ++ overrideJSON: `{ ++ "updateStrategy": { ++ "type": "RollingUpdate", ++ "rollingUpdate": { ++ "maxUnavailable": 1, ++ "maxSurge": 4 ++ } ++ } ++ }`, ++ expectedType: v1.RollingUpdateDeploymentStrategyType, ++ expectedUnavailable: intOrStringPtr(intstr.FromInt(1)), ++ expectedSurge: intOrStringPtr(intstr.FromInt(4)), ++ }, ++ { ++ name: "non rolling strategy keeps the requested type", ++ overrideJSON: `{ ++ "updateStrategy": { ++ "type": "Recreate" ++ } ++ }`, ++ expectedType: v1.RecreateDeploymentStrategyType, ++ }, ++ } ++ ++ for _, tt := range tests { ++ t.Run(tt.name, func(t *testing.T) { ++ deployment := v1.Deployment{} ++ override := componentOverrideFromJSON(t, tt.overrideJSON) ++ ++ Deployment(&deployment, &override) ++ ++ assert.Equal(t, tt.expectedType, deployment.Spec.Strategy.Type) ++ if tt.expectedUnavailable != nil || tt.expectedSurge != nil { ++ require.NotNil(t, deployment.Spec.Strategy.RollingUpdate) ++ } ++ if tt.expectedUnavailable != nil { ++ require.NotNil(t, deployment.Spec.Strategy.RollingUpdate.MaxUnavailable) ++ assert.Equal(t, *tt.expectedUnavailable, *deployment.Spec.Strategy.RollingUpdate.MaxUnavailable) ++ } ++ if tt.expectedSurge != nil { ++ require.NotNil(t, deployment.Spec.Strategy.RollingUpdate.MaxSurge) ++ assert.Equal(t, *tt.expectedSurge, *deployment.Spec.Strategy.RollingUpdate.MaxSurge) ++ } ++ }) ++ } ++} ++ + func TestDeployment(t *testing.T) { + deployment := v1.Deployment{ + ObjectMeta: metav1.ObjectMeta{ +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,19 @@ ++#!/bin/bash ++set -euo pipefail ++cd /testbed ++ ++ ++ ++case "${1:-}" in ++ base) ++ go test ./controllers/datadogagent/override/ -run '^TestDeployment$' -v ++ ;; ++ new) ++ go test ./apis/datadoghq/v2alpha1 -run '^TestDatadogAgentOverrideUpdateStrategyIsExposedInCRDSchema$' -v ++ go test ./controllers/datadogagent/override/ -run '^(TestDaemonSetAppliesUpdateStrategyFromJSONOverride|TestDeploymentAppliesUpdateStrategyFromJSONOverride)$' -v ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-000059/tests/test.sh b/tasks/format-code-task-000059/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..790bb1a8d9c1a059bbdf516b109aabb7f05b6b8e --- /dev/null +++ b/tasks/format-code-task-000059/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +apis/datadoghq/v2alpha1/datadogagent_update_strategy_schema_test.go +controllers/datadogagent/override/daemonset_test.go +controllers/datadogagent/override/deploymentspec_test.go +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000059/tests/test_command.sh b/tasks/format-code-task-000059/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-000059/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh base && bash /testbed/mimo_test_command.sh new \ No newline at end of file diff --git a/tasks/format-code-task-000092/environment/Dockerfile b/tasks/format-code-task-000092/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..48b0ff9826115e77e9fb4c7ad9dfaa65298c84fb --- /dev/null +++ b/tasks/format-code-task-000092/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:689f861f0175a0e356d19d8bf071331e73210ea6be904fa1a01db3a997964718 diff --git a/tasks/format-code-task-000092/environment/setup/files/blocklist b/tasks/format-code-task-000092/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000092/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000092/environment/setup/setup.sh b/tasks/format-code-task-000092/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000092/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000092/tests/test.patch b/tasks/format-code-task-000092/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..78ea5d1743a7c2133e71135d05c042a9e9fac293 --- /dev/null +++ b/tasks/format-code-task-000092/tests/test.patch @@ -0,0 +1,167 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..9554664c +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest tests/gpflow/experimental/check_shapes/test_multi_varrank.py -v"] ++} +diff --git a/tests/gpflow/experimental/check_shapes/test_multi_varrank.py b/tests/gpflow/experimental/check_shapes/test_multi_varrank.py +new file mode 100644 +index 00000000..365311c6 +--- /dev/null ++++ b/tests/gpflow/experimental/check_shapes/test_multi_varrank.py +@@ -0,0 +1,139 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++import pytest ++ ++from gpflow.experimental.check_shapes import ShapeChecker, check_shapes ++from gpflow.experimental.check_shapes.exceptions import ShapeMismatchError ++from gpflow.experimental.check_shapes.parser import parse_tensor_spec ++from gpflow.experimental.check_shapes.specs import ParsedShapeSpec ++ ++from .utils import t ++ ++ ++def test_parse_multi_varrank_spec_does_not_assert() -> None: ++ ++ spec = parse_tensor_spec("[a..., b...]", None) ++ ++ assert isinstance(spec.shape, ParsedShapeSpec) ++ n_varrank = sum(d.variable_rank for d in spec.shape.dims) ++ assert n_varrank == 2 ++ ++ ++def test_parse_three_varrank_spec_does_not_assert() -> None: ++ ++ spec = parse_tensor_spec("[a..., b..., c...]", None) ++ n_varrank = sum(d.variable_rank for d in spec.shape.dims) ++ assert n_varrank == 3 ++ ++ ++def test_check_multi_varrank_resolves_when_ranks_known_in_order() -> None: ++ ++ ++ c = ShapeChecker() ++ c.check_shape(t(2), "[a...]") ++ c.check_shape(t(3), "[b...]") ++ c.check_shape(t(2, 3), "[a..., b...]") ++ ++ ++def test_check_multi_varrank_resolves_deferred() -> None: ++ ++ ++ c = ShapeChecker() ++ c.check_shape(t(2, 3), "[a..., b...]") ++ c.check_shape(t(2), "[a...]") ++ c.check_shape(t(3), "[b...]") ++ ++ ++ ++def test_check_multi_varrank_mismatch_raises() -> None: ++ ++ ++ c = ShapeChecker() ++ c.check_shape(t(2), "[a...]") ++ c.check_shape(t(3), "[b...]") ++ with pytest.raises(ShapeMismatchError): ++ c.check_shape(t(2, 4), "[a..., b...]") ++ ++ ++def test_check_multi_varrank_total_too_short_raises() -> None: ++ ++ ++ c = ShapeChecker() ++ with pytest.raises(ShapeMismatchError): ++ c.check_shape(t(), "[a..., b..., 3]") ++ ++ ++def test_check_multi_varrank_unresolved_does_not_raise() -> None: ++ ++ ++ c = ShapeChecker() ++ ++ c.check_shape(t(2, 3), "[a..., b...]") ++ ++ ++def test_check_multi_varrank_in_single_check_shapes_call() -> None: ++ ++ ++ checker = ShapeChecker() ++ checker.check_shapes( ++ [ ++ (t(2, 3), "[a..., b...]"), ++ (t(2), "[a...]"), ++ (t(3), "[b...]"), ++ ] ++ ) ++ ++ ++def test_check_multi_varrank_in_single_check_shapes_call_mismatch() -> None: ++ ++ checker = ShapeChecker() ++ with pytest.raises(ShapeMismatchError): ++ checker.check_shapes( ++ [ ++ (t(2, 4), "[a..., b...]"), ++ (t(2), "[a...]"), ++ (t(3), "[b...]"), ++ ] ++ ) ++ ++ ++def test_decorator_with_multi_varrank_in_return_spec_issue_example() -> None: ++ ++ ++ ++ @check_shapes( ++ "a: [a_shape...]", ++ "b: [b_shape...]", ++ "return: [a_shape..., b_shape...]", ++ ) ++ def broadcasting_elementwise(a, b): ++ return t(*(a.test_shape + b.test_shape)) ++ ++ ++ out = broadcasting_elementwise(t(2, 3), t(4, 5, 6)) ++ assert out.test_shape == (2, 3, 4, 5, 6) ++ ++ ++def test_decorator_with_multi_varrank_in_return_spec_bad_return() -> None: ++ ++ ++ ++ @check_shapes( ++ "a: [a_shape...]", ++ "b: [b_shape...]", ++ "return: [a_shape..., b_shape...]", ++ ) ++ def bad(a, b): ++ ++ return t(2, 3, 4, 6) ++ ++ with pytest.raises(ShapeMismatchError): ++ bad(t(2, 3), t(4, 5)) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m pytest tests/gpflow/experimental/check_shapes/test_multi_varrank.py -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000092/tests/test.sh b/tasks/format-code-task-000092/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9a7b7978b8261083e29fe89a8e29ee1de23e630 --- /dev/null +++ b/tasks/format-code-task-000092/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test_commands.json +tests/gpflow/experimental/check_shapes/test_multi_varrank.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000092/tests/test_command.sh b/tasks/format-code-task-000092/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000092/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000095/environment/Dockerfile b/tasks/format-code-task-000095/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e262774a94da3144cd1ebb807ce5293007112ebe --- /dev/null +++ b/tasks/format-code-task-000095/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:86ec6b56381405942ed2696a198684c25d858aa46cd9df3f85fc77607440eee0 diff --git a/tasks/format-code-task-000095/environment/setup/files/blocklist b/tasks/format-code-task-000095/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000095/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000095/environment/setup/setup.sh b/tasks/format-code-task-000095/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000095/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000095/tests/test.patch b/tasks/format-code-task-000095/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..4ff727742759de24166ac428e507240ef9193fb4 --- /dev/null +++ b/tasks/format-code-task-000095/tests/test.patch @@ -0,0 +1,153 @@ +diff --git a/test/test.js b/test/test.js +index af060c2..17a5e90 100644 +--- a/test/test.js ++++ b/test/test.js +@@ -445,4 +445,126 @@ describe('generateRuntimeCaching', function() { + }]); + assert.equal(code, '\ntoolbox.router.get(/test/, toolbox.testHandler, {});'); + }); ++ ++ ++ ++ function evalRuntimeCaching(code) { ++ var calls = []; ++ var routerMethod = function(pattern, handler, options) { ++ calls.push({pattern: pattern, handler: handler, options: options}); ++ }; ++ var toolbox = { ++ router: { ++ get: routerMethod, ++ post: routerMethod, ++ put: routerMethod, ++ delete: routerMethod, ++ head: routerMethod, ++ any: routerMethod ++ }, ++ ++ ++ networkFirst: 'networkFirstHandler', ++ fastest: 'fastestHandler', ++ testHandler: 'testHandlerValue' ++ }; ++ /* eslint-disable no-new-func */ ++ var fn = new Function('toolbox', code); ++ /* eslint-enable no-new-func */ ++ fn(toolbox); ++ return calls; ++ } ++ ++ it('should serialize a RegExp origin option as a regex literal, not an empty object', function() { ++ var code = generateRuntimeCaching([{ ++ urlPattern: /\/articles\//, ++ handler: 'fastest', ++ options: {origin: /twitter\.com/} ++ }]); ++ ++ assert.equal(code.indexOf('"origin":{}'), -1, ++ 'origin must NOT be serialized as empty object'); ++ assert.equal(code.indexOf('"origin": {}'), -1, ++ 'origin must NOT be serialized as empty object (with space)'); ++ ++ assert(code.indexOf('/twitter\\.com/') !== -1, ++ 'expected regex literal /twitter\\.com/ in output, got: ' + code); ++ }); ++ ++ it('should produce code that evaluates a RegExp origin to a RegExp instance', function() { ++ var code = generateRuntimeCaching([{ ++ urlPattern: /\/articles\//, ++ handler: 'fastest', ++ options: {origin: /twitter\.com/} ++ }]); ++ var calls = evalRuntimeCaching(code); ++ assert.equal(calls.length, 1); ++ assert(calls[0].options.origin instanceof RegExp, ++ 'options.origin should be a RegExp, got: ' + ++ Object.prototype.toString.call(calls[0].options.origin)); ++ assert.strictEqual(calls[0].options.origin.source, 'twitter\\.com'); ++ assert(calls[0].options.origin.test('https://twitter.com/foo'), ++ 'regex should match twitter.com URLs'); ++ }); ++ ++ it('should handle the exact runtimeCaching example from the issue', function() { ++ var code = generateRuntimeCaching([{ ++ urlPattern: /^https:\/\/example\.com\/api/, ++ handler: 'networkFirst' ++ }, { ++ urlPattern: /\/articles\//, ++ handler: 'fastest', ++ options: {origin: /twitter\.com/} ++ }]); ++ var calls = evalRuntimeCaching(code); ++ assert.equal(calls.length, 2); ++ ++ ++ assert(calls[0].pattern instanceof RegExp); ++ assert.strictEqual(calls[0].pattern.source, '^https:\\/\\/example\\.com\\/api'); ++ assert.deepEqual(calls[0].options, {}); ++ ++ ++ assert(calls[1].pattern instanceof RegExp); ++ assert.strictEqual(calls[1].pattern.source, '\\/articles\\/'); ++ assert(calls[1].options.origin instanceof RegExp, ++ 'second route options.origin must be a RegExp'); ++ assert.strictEqual(calls[1].options.origin.source, 'twitter\\.com'); ++ }); ++ ++ it('should keep a string origin as a string', function() { ++ var code = generateRuntimeCaching([{ ++ urlPattern: /test/, ++ handler: 'testHandler', ++ options: {origin: 'https://example.com'} ++ }]); ++ var calls = evalRuntimeCaching(code); ++ assert.equal(calls.length, 1); ++ assert.strictEqual(typeof calls[0].options.origin, 'string'); ++ assert.strictEqual(calls[0].options.origin, 'https://example.com'); ++ }); ++ ++ it('should preserve non-RegExp options alongside other fields', function() { ++ var code = generateRuntimeCaching([{ ++ urlPattern: /test/, ++ handler: 'testHandler', ++ options: {networkTimeoutSeconds: 5} ++ }]); ++ var calls = evalRuntimeCaching(code); ++ assert.equal(calls.length, 1); ++ assert.strictEqual(calls[0].options.networkTimeoutSeconds, 5); ++ }); ++ ++ it('should produce syntactically valid JavaScript when origin is a RegExp', function() { ++ var code = generateRuntimeCaching([{ ++ urlPattern: /\/articles\//, ++ handler: 'fastest', ++ options: {origin: /twitter\.com/} ++ }]); ++ assert.doesNotThrow(function() { ++ /* eslint-disable no-new, no-new-func */ ++ new Function(code); ++ /* eslint-enable no-new, no-new-func */ ++ }, 'generated code must be parseable as JavaScript'); ++ }); + }); +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..ff99813 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["./node_modules/.bin/mocha test/test.js --grep \"generateRuntimeCaching\""] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++./node_modules/.bin/mocha test/test.js --grep "generateRuntimeCaching" ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000095/tests/test.sh b/tasks/format-code-task-000095/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..551b64af4dffd264e30c506f4808a9d5494eb9ea --- /dev/null +++ b/tasks/format-code-task-000095/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test/test.js +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000095/tests/test_command.sh b/tasks/format-code-task-000095/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000095/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000113/environment/Dockerfile b/tasks/format-code-task-000113/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..be36d8974c71d267666cf19703a760a6b25781c0 --- /dev/null +++ b/tasks/format-code-task-000113/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:241b4d1ab25e07bfaab833c028a53faa95df25201f12aabd9c5a57e5f1a5b294 diff --git a/tasks/format-code-task-000113/environment/setup/files/blocklist b/tasks/format-code-task-000113/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000113/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000113/environment/setup/setup.sh b/tasks/format-code-task-000113/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000113/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000113/tests/test.patch b/tasks/format-code-task-000113/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..3599a486d336c07e472dc89768ed8cccd5413309 --- /dev/null +++ b/tasks/format-code-task-000113/tests/test.patch @@ -0,0 +1,70 @@ +diff --git a/mist/master/src/test/scala/io/hydrosphere/mist/master/logging/LogStreamsSpec.scala b/mist/master/src/test/scala/io/hydrosphere/mist/master/logging/LogStreamsSpec.scala +index 9375ea051..9b9f0c1c6 100644 +--- a/mist/master/src/test/scala/io/hydrosphere/mist/master/logging/LogStreamsSpec.scala ++++ b/mist/master/src/test/scala/io/hydrosphere/mist/master/logging/LogStreamsSpec.scala +@@ -9,7 +9,7 @@ import io.hydrosphere.mist.core.MockitoSugar + import org.mockito.Mockito.verify + import org.scalatest.{FunSpecLike, Matchers} + +-import scala.concurrent.duration.Duration ++import scala.concurrent.duration._ + import scala.concurrent.{Await, Future} + + class LogStreamsSpec extends TestKit(ActorSystem("log-service-test")) +@@ -24,7 +24,6 @@ class LogStreamsSpec extends TestKit(ActorSystem("log-service-test")) + when(writer.write(any[String], any[Seq[LogEvent]])) + .thenReturn(Future.successful(LogUpdate("jobId", Seq.empty, 1))) + +- + val out = Source.single(LogEvent.mkDebug("id", "message")) + .via(LogStreams.storeFlow(writer)) + .take(1) +@@ -35,4 +34,26 @@ class LogStreamsSpec extends TestKit(ActorSystem("log-service-test")) + updates.size shouldBe 1 + verify(writer).write(any[String], any[Seq[LogEvent]]) + } ++ ++ it("should ignore errors") { ++ val event = LogEvent.mkDebug("id", "message") ++ val writer = mock[LogsWriter] ++ when(writer.write(any[String], any[Seq[LogEvent]])) ++ .thenSuccess(LogUpdate("id", Seq(event), 1)) ++ .thenFailure(new RuntimeException("error")) ++ .thenSuccess(LogUpdate("id", Seq(event), 1)) ++ .thenFailure(new RuntimeException("error")) ++ .thenSuccess(LogUpdate("id", Seq(event), 1)) ++ ++ val in = (1 to 5).map(i => LogEvent.mkDebug(s"job-$i", "message")) ++ val future = Source(in) ++ .via(LogStreams.storeFlow(writer)) ++ .take(3) ++ .toMat(Sink.seq)(Keep.right).run() ++ ++ ++ val updates = Await.result(future, Duration.Inf) ++ updates.flatMap(_.events).size shouldBe 3 ++ } ++ + } +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,6 @@ ++H4sIAAAAAAAAA+3SQUvDMBQH8J77KWLddUlb206EHXYQhigTJl5Hu4Q2s2lGkg737e0qUxF0l40h ++/n8QEpL3kpAXWrSy5gvRbJh3KmFnlKZ93/ne9+MojcM4S9I0ib0wirIw80h6sht90VqXG0I8o7X7 ++Le7Q+h9FP+vvhHWLpVYqbzi11fHOOFT/eHS1r3+Yjrr5KMni0CPh8a7ws39e/8sLVsiGFbmt/CUn ++/ScoBPfF61obR+4mz5PFdPZwO2atNayWBVttVBelWiOb4fVwxV+GueJZss94nDxNx8HgI3G3/c1g ++Nxv4lNnC7RoJVG6dMP1xs6beEqlpteVG23UljKBKWkffY2ity1I2Jb3X5dwZkSs7X4tl4J/76QAA ++AAAAAAAAAAAAAAAAAAAAzu4Nucdz4QAoAAA= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000113/tests/test.sh b/tasks/format-code-task-000113/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..0e443f6001d7c38d5b8ff7f432084b2b64532805 --- /dev/null +++ b/tasks/format-code-task-000113/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +mist/master/src/test/scala/io/hydrosphere/mist/master/logging/LogStreamsSpec.scala +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000113/tests/test_command.sh b/tasks/format-code-task-000113/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000113/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000122/environment/Dockerfile b/tasks/format-code-task-000122/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..99e3176be36c4c566d1a51c53667534734b398c8 --- /dev/null +++ b/tasks/format-code-task-000122/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:b6a3eade23a0a3814976f10f3fe08961353b2c518b825d0644b1375438573537 diff --git a/tasks/format-code-task-000122/environment/setup/files/blocklist b/tasks/format-code-task-000122/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000122/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000122/environment/setup/setup.sh b/tasks/format-code-task-000122/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000122/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000122/tests/test.patch b/tasks/format-code-task-000122/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..f4b5056dd4f6c60ce6d4b04a4a93ad6bcb3c9493 --- /dev/null +++ b/tasks/format-code-task-000122/tests/test.patch @@ -0,0 +1,344 @@ +diff --git a/idaes/core/tests/test_components_import.py b/idaes/core/tests/test_components_import.py +new file mode 100644 +index 000000000..2e102dce2 +--- /dev/null ++++ b/idaes/core/tests/test_components_import.py +@@ -0,0 +1,54 @@ ++import importlib ++import types ++ ++import pytest ++from pyomo.environ import ConcreteModel, Param, Var, units as pyunits ++ ++from idaes.core.property_meta import PropertyClassMetadata ++ ++ ++def _model_with_default_units(): ++ m = ConcreteModel() ++ m.meta_object = PropertyClassMetadata() ++ ++ def get_metadata(self): ++ return m.meta_object ++ ++ m.get_metadata = types.MethodType(get_metadata, m) ++ m.get_metadata().default_units["amount"] = pyunits.mol ++ m.get_metadata().default_units["mass"] = pyunits.kg ++ m.get_metadata().default_units["time"] = pyunits.s ++ m.get_metadata().default_units["length"] = pyunits.m ++ m.get_metadata().default_units["temperature"] = pyunits.K ++ return m ++ ++ ++@pytest.mark.unit ++def test_core_components_imports_without_generic_property_package(): ++ module = importlib.import_module("idaes.core.components") ++ ++ assert module.Component is not None ++ ++ ++@pytest.mark.unit ++def test_component_build_populates_parameter_data_after_direct_import(): ++ module = importlib.import_module("idaes.core.components") ++ m = _model_with_default_units() ++ ++ m.comp = module.Component(default={ ++ "parameter_data": { ++ "mw": (18, pyunits.g / pyunits.mol), ++ "pressure_crit": (2, pyunits.bar), ++ "temperature_crit": (540, pyunits.degR), ++ "omega": 0.25, ++ } ++ }) ++ ++ assert isinstance(m.comp.mw, Param) ++ assert m.comp.mw.value == pytest.approx(0.018) ++ assert isinstance(m.comp.pressure_crit, Var) ++ assert m.comp.pressure_crit.value == pytest.approx(2e5) ++ assert isinstance(m.comp.temperature_crit, Var) ++ assert m.comp.temperature_crit.value == pytest.approx(300) ++ assert isinstance(m.comp.omega, Var) ++ assert m.comp.omega.value == pytest.approx(0.25) +diff --git a/idaes/core/util/tests/test_misc.py b/idaes/core/util/tests/test_misc.py +index b4c1d7f26..08a9bb85e 100644 +--- a/idaes/core/util/tests/test_misc.py ++++ b/idaes/core/util/tests/test_misc.py +@@ -16,11 +16,13 @@ This module contains miscalaneous utility functions for use in IDAES models. + + import pytest + +-from pyomo.environ import ConcreteModel, Expression, Set, Block, Var ++from pyomo.environ import ConcreteModel, Expression, Set, Block, Var, units + from pyomo.network import Port ++from pyomo.common.config import ConfigBlock + + from idaes.core.util.misc import (add_object_reference, copy_port_values, +- TagReference, VarLikeExpression) ++ TagReference, VarLikeExpression, ++ set_param_from_config) + + + # Author: Andrew Lee +@@ -189,3 +191,228 @@ def test_IndexedVarLikeExpression(): + match="e\[{}\] is an Expression and can not be " + "unfixed.".format(i)): + m.e[i].unfix() ++ ++ ++@pytest.mark.unit ++class TestSetParamFromConfig: ++ def test_default_config_scalar(self): ++ m = ConcreteModel() ++ m.b = Block() ++ m.b.config = ConfigBlock(implicit=True) ++ m.b.config.parameter_data = {"alpha": 42} ++ m.b.alpha = Var(initialize=1) ++ ++ set_param_from_config(m.b, "alpha") ++ ++ assert m.b.alpha.value == 42 ++ ++ def test_explicit_config_scalar(self): ++ m = ConcreteModel() ++ m.b = Block() ++ cfg = ConfigBlock(implicit=True) ++ cfg.parameter_data = {"beta": 17} ++ m.b.beta = Var(initialize=0) ++ ++ set_param_from_config(m.b, "beta", config=cfg) ++ ++ assert m.b.beta.value == 17 ++ ++ def test_explicit_config_positional_third_argument(self): ++ m = ConcreteModel() ++ m.b = Block() ++ cfg = ConfigBlock(implicit=True) ++ cfg.parameter_data = {"beta": 23} ++ m.b.beta = Var(initialize=0) ++ ++ set_param_from_config(m.b, "beta", cfg) ++ ++ assert m.b.beta.value == 23 ++ ++ def test_tuple_units_converted_to_parameter_units(self): ++ m = ConcreteModel() ++ m.b = Block() ++ m.b.config = ConfigBlock(implicit=True) ++ m.b.config.parameter_data = {"length": (2.5, units.m)} ++ m.b.length = Var(initialize=0, units=units.cm) ++ ++ set_param_from_config(m.b, "length") ++ ++ assert m.b.length.value == pytest.approx(250) ++ ++ def test_tuple_units_converted_second_case(self): ++ m = ConcreteModel() ++ m.b = Block() ++ m.b.config = ConfigBlock(implicit=True) ++ m.b.config.parameter_data = {"energy": (1.2, units.kJ / units.mol)} ++ m.b.energy = Var(initialize=0, units=units.J / units.mol) ++ ++ set_param_from_config(m.b, "energy") ++ ++ assert m.b.energy.value == pytest.approx(1200) ++ ++ def test_dimensionless_tuple_bypasses_conversion(self): ++ m = ConcreteModel() ++ m.b = Block() ++ m.b.config = ConfigBlock(implicit=True) ++ m.b.config.parameter_data = {"gamma": (3.14, units.dimensionless)} ++ m.b.gamma = Var(initialize=0, units=units.dimensionless) ++ ++ set_param_from_config(m.b, "gamma") ++ ++ assert m.b.gamma.value == pytest.approx(3.14) ++ ++ def test_dimensionless_param_accepts_none_units(self): ++ m = ConcreteModel() ++ m.b = Block() ++ m.b.config = ConfigBlock(implicit=True) ++ m.b.config.parameter_data = {"gamma": (2.72, None)} ++ m.b.gamma = Var(initialize=0, units=units.dimensionless) ++ ++ set_param_from_config(m.b, "gamma") ++ ++ assert m.b.gamma.value == pytest.approx(2.72) ++ ++ def test_unitless_param_accepts_dimensionless_units(self): ++ m = ConcreteModel() ++ m.b = Block() ++ m.b.config = ConfigBlock(implicit=True) ++ m.b.config.parameter_data = {"epsilon": (8.5, units.dimensionless)} ++ m.b.epsilon = Var(initialize=0, units=None) ++ ++ set_param_from_config(m.b, "epsilon") ++ ++ assert m.b.epsilon.value == pytest.approx(8.5) ++ ++ def test_unitless_dimensionless_pairs_are_assigned(self): ++ m = ConcreteModel() ++ m.b = Block() ++ m.b.config = ConfigBlock(implicit=True) ++ m.b.config.parameter_data = { ++ "gamma": (2.72, None), ++ "epsilon": (8.5, units.dimensionless), ++ } ++ m.b.gamma = Var(initialize=0, units=units.dimensionless) ++ m.b.epsilon = Var(initialize=0, units=None) ++ ++ set_param_from_config(m.b, "gamma") ++ set_param_from_config(m.b, "epsilon") ++ ++ assert m.b.gamma.value == pytest.approx(2.72) ++ assert m.b.epsilon.value == pytest.approx(8.5) ++ ++ def test_unitless_none_tuple_bypasses_conversion(self): ++ m = ConcreteModel() ++ m.b = Block() ++ m.b.config = ConfigBlock(implicit=True) ++ m.b.config.parameter_data = {"delta": (9, None)} ++ m.b.delta = Var(initialize=0, units=None) ++ ++ set_param_from_config(m.b, "delta") ++ ++ assert m.b.delta.value == 9 ++ ++ def test_scalar_zero_overwrites_initial_value(self): ++ m = ConcreteModel() ++ m.b = Block() ++ m.b.config = ConfigBlock(implicit=True) ++ m.b.config.parameter_data = {"zeta": 0} ++ m.b.zeta = Var(initialize=5) ++ ++ set_param_from_config(m.b, "zeta") ++ ++ assert m.b.zeta.value == 0 ++ ++ def test_scalar_object_assigned_without_numeric_coercion(self): ++ m = ConcreteModel() ++ m.b = Block() ++ m.b.config = ConfigBlock(implicit=True) ++ marker = object() ++ m.b.config.parameter_data = {"marker": marker} ++ ++ class Holder: ++ def __init__(self): ++ self.value = None ++ ++ def get_units(self): ++ return None ++ ++ m.b.marker = Holder() ++ ++ set_param_from_config(m.b, "marker") ++ ++ assert m.b.marker.value is marker ++ ++ def test_no_default_config_raises(self): ++ m = ConcreteModel() ++ m.b = Block() ++ m.b.theta = Var(initialize=1) ++ ++ with pytest.raises(Exception) as err: ++ set_param_from_config(m.b, "theta") ++ assert str(err.value) ++ ++ def test_invalid_config_type_raises(self): ++ m = ConcreteModel() ++ m.b = Block() ++ m.b.theta = Var(initialize=1) ++ ++ with pytest.raises(Exception) as err: ++ set_param_from_config(m.b, "theta", config={"parameter_data": {}}) ++ assert str(err.value) ++ ++ def test_missing_param_attribute_raises(self): ++ m = ConcreteModel() ++ m.b = Block() ++ m.b.config = ConfigBlock(implicit=True) ++ m.b.config.parameter_data = {"theta": 5} ++ ++ with pytest.raises(Exception) as err: ++ set_param_from_config(m.b, "theta") ++ assert str(err.value) ++ ++ def test_missing_parameter_data_raises(self): ++ m = ConcreteModel() ++ m.b = Block() ++ m.b.config = ConfigBlock(implicit=True) ++ m.b.config.parameter_data = {} ++ m.b.theta = Var(initialize=1) ++ ++ with pytest.raises(Exception) as err: ++ set_param_from_config(m.b, "theta") ++ assert str(err.value) ++ ++ def test_indexed_parameter_data_sets_indexed_attr(self): ++ m = ConcreteModel() ++ m.b = Block() ++ m.b.config = ConfigBlock(implicit=True) ++ m.b.config.parameter_data = { ++ "coeff": {"A": (1, units.m), "B": (2, units.m)} ++ } ++ m.b.coeff_A = Var(initialize=11, units=units.cm) ++ m.b.coeff_B = Var(initialize=12, units=units.cm) ++ ++ set_param_from_config(m.b, "coeff", index="B") ++ ++ assert m.b.coeff_B.value == pytest.approx(200) ++ assert m.b.coeff_A.value == 11 ++ ++ def test_missing_indexed_param_attribute_raises(self): ++ m = ConcreteModel() ++ m.b = Block() ++ m.b.config = ConfigBlock(implicit=True) ++ m.b.config.parameter_data = {"coeff": {"B": 2}} ++ ++ with pytest.raises(Exception) as err: ++ set_param_from_config(m.b, "coeff", index="B") ++ assert str(err.value) ++ ++ def test_missing_indexed_parameter_data_raises(self): ++ m = ConcreteModel() ++ m.b = Block() ++ m.b.config = ConfigBlock(implicit=True) ++ m.b.config.parameter_data = {"coeff": {"A": 1}} ++ m.b.coeff_B = Var(initialize=12) ++ ++ with pytest.raises(Exception) as err: ++ set_param_from_config(m.b, "coeff", index="B") ++ assert str(err.value) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,30 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++ ++export PATH="$HOME/.pyenv/bin:$PATH" ++eval "$(pyenv init -)" ++pyenv global 3.9.22 ++: "${PYTHONPATH:=}" ++export PYTHONPATH=/testbed:$PYTHONPATH ++ ++ ++case "${1:-}" in ++ base) ++ python3 -m pytest \ ++ idaes/core/util/tests/test_misc.py \ ++ idaes/core/tests/test_components.py \ ++ -v ++ ;; ++ new) ++ python3 -m pytest \ ++ idaes/core/util/tests/test_misc.py::TestSetParamFromConfig \ ++ idaes/core/tests/test_components_import.py \ ++ -v ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-000122/tests/test.sh b/tasks/format-code-task-000122/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..970af826a0217c63d18a0ee194d014efd1d9a872 --- /dev/null +++ b/tasks/format-code-task-000122/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +idaes/core/tests/test_components_import.py +idaes/core/util/tests/test_misc.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000122/tests/test_command.sh b/tasks/format-code-task-000122/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-000122/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh base && bash /testbed/mimo_test_command.sh new \ No newline at end of file diff --git a/tasks/format-code-task-000236/environment/Dockerfile b/tasks/format-code-task-000236/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d6508a8f13b213a30a5d024694214b15930d4be2 --- /dev/null +++ b/tasks/format-code-task-000236/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:906e5286e51a76e9970bacc1598c671eac9371be48e480fdfd7db8dea9a87447 diff --git a/tasks/format-code-task-000236/environment/setup/files/blocklist b/tasks/format-code-task-000236/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000236/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000236/environment/setup/setup.sh b/tasks/format-code-task-000236/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000236/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000236/tests/test.patch b/tasks/format-code-task-000236/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..7b7df89f7a7b8538258677639b9a81d704b21845 --- /dev/null +++ b/tasks/format-code-task-000236/tests/test.patch @@ -0,0 +1,265 @@ +diff --git a/packages/core/src/rules/__tests__/hide-internals.test.ts b/packages/core/src/rules/__tests__/hide-internals.test.ts +index 28d738e3..53ba7c82 100644 +--- a/packages/core/src/rules/__tests__/hide-internals.test.ts ++++ b/packages/core/src/rules/__tests__/hide-internals.test.ts +@@ -187,6 +187,238 @@ describe('oas3 remove-x-internal', () => { + }); + }); + ++describe('oas3 remove-x-internal $ref handling', () => { ++ expect.addSnapshotSerializer(yamlSerializer); ++ ++ it('should remove ref to internal parameter component while preserving non-internal ref', async () => { ++ const testDoc = parseYamlToDocument( ++ outdent` ++ openapi: 3.0.0 ++ paths: ++ '/products/{product_id}': ++ get: ++ parameters: ++ - $ref: '#/components/parameters/ProductID' ++ - $ref: '#/components/parameters/Vendor' ++ components: ++ parameters: ++ ProductID: ++ in: path ++ name: product_id ++ description: The ID of the product. ++ required: true ++ schema: ++ type: string ++ format: uuid ++ Vendor: ++ in: header ++ name: X-Vendor ++ description: The vendor. ++ schema: ++ type: string ++ x-internal: true ++ `); ++ const { bundle: res } = await bundleDocument({ ++ document: testDoc, ++ externalRefResolver: new BaseResolver(), ++ config: makeConfig({}, { 'remove-x-internal': 'on' }) ++ }); ++ expect(res.parsed).toMatchInlineSnapshot(` ++ openapi: 3.0.0 ++ paths: ++ /products/{product_id}: ++ get: ++ parameters: ++ - $ref: '#/components/parameters/ProductID' ++ components: ++ parameters: ++ ProductID: ++ in: path ++ name: product_id ++ description: The ID of the product. ++ required: true ++ schema: ++ type: string ++ format: uuid ++ ++ `); ++ }); ++ ++ it('should remove parameters key when only ref is to internal component', async () => { ++ const testDoc = parseYamlToDocument( ++ outdent` ++ openapi: 3.0.0 ++ paths: ++ '/products': ++ get: ++ parameters: ++ - $ref: '#/components/parameters/Vendor' ++ components: ++ parameters: ++ Vendor: ++ in: header ++ name: X-Vendor ++ schema: ++ type: string ++ x-internal: true ++ `); ++ const { bundle: res } = await bundleDocument({ ++ document: testDoc, ++ externalRefResolver: new BaseResolver(), ++ config: makeConfig({}, { 'remove-x-internal': 'on' }) ++ }); ++ expect(res.parsed).toMatchInlineSnapshot(` ++ openapi: 3.0.0 ++ paths: ++ /products: ++ get: {} ++ components: {} ++ ++ `); ++ }); ++ ++ it('should preserve ref to non-internal component', async () => { ++ const testDoc = parseYamlToDocument( ++ outdent` ++ openapi: 3.0.0 ++ paths: ++ '/products': ++ get: ++ parameters: ++ - $ref: '#/components/parameters/ProductID' ++ components: ++ parameters: ++ ProductID: ++ in: query ++ name: product_id ++ schema: ++ type: string ++ `); ++ const { bundle: res } = await bundleDocument({ ++ document: testDoc, ++ externalRefResolver: new BaseResolver(), ++ config: makeConfig({}, { 'remove-x-internal': 'on' }) ++ }); ++ expect(res.parsed).toMatchInlineSnapshot(` ++ openapi: 3.0.0 ++ paths: ++ /products: ++ get: ++ parameters: ++ - $ref: '#/components/parameters/ProductID' ++ components: ++ parameters: ++ ProductID: ++ in: query ++ name: product_id ++ schema: ++ type: string ++ ++ `); ++ }); ++ ++ it('should remove all internal refs in array with multiple internal refs', async () => { ++ const testDoc = parseYamlToDocument( ++ outdent` ++ openapi: 3.0.0 ++ paths: ++ '/products': ++ get: ++ parameters: ++ - $ref: '#/components/parameters/InternalA' ++ - $ref: '#/components/parameters/PublicX' ++ - $ref: '#/components/parameters/InternalB' ++ components: ++ parameters: ++ InternalA: ++ in: header ++ name: A ++ schema: ++ type: string ++ x-internal: true ++ PublicX: ++ in: query ++ name: X ++ schema: ++ type: string ++ InternalB: ++ in: header ++ name: B ++ schema: ++ type: string ++ x-internal: true ++ `); ++ const { bundle: res } = await bundleDocument({ ++ document: testDoc, ++ externalRefResolver: new BaseResolver(), ++ config: makeConfig({}, { 'remove-x-internal': 'on' }) ++ }); ++ expect(res.parsed).toMatchInlineSnapshot(` ++ openapi: 3.0.0 ++ paths: ++ /products: ++ get: ++ parameters: ++ - $ref: '#/components/parameters/PublicX' ++ components: ++ parameters: ++ PublicX: ++ in: query ++ name: X ++ schema: ++ type: string ++ ++ `); ++ }); ++ ++ it('should respect internalFlagProperty when removing refs to internal components', async () => { ++ const testDoc = parseYamlToDocument( ++ outdent` ++ openapi: 3.0.0 ++ paths: ++ '/products': ++ get: ++ parameters: ++ - $ref: '#/components/parameters/Public' ++ - $ref: '#/components/parameters/Hidden' ++ components: ++ parameters: ++ Public: ++ in: query ++ name: pub ++ schema: ++ type: string ++ Hidden: ++ in: header ++ name: hid ++ schema: ++ type: string ++ removeit: true ++ `); ++ const { bundle: res } = await bundleDocument({ ++ document: testDoc, ++ externalRefResolver: new BaseResolver(), ++ config: makeConfig({}, { 'remove-x-internal': { 'internalFlagProperty': 'removeit' } }) ++ }); ++ expect(res.parsed).toMatchInlineSnapshot(` ++ openapi: 3.0.0 ++ paths: ++ /products: ++ get: ++ parameters: ++ - $ref: '#/components/parameters/Public' ++ components: ++ parameters: ++ Public: ++ in: query ++ name: pub ++ schema: ++ type: string ++ ++ `); ++ }); ++}); ++ + describe('oas2 remove-x-internal', () => { + it('should clean types - base test', async () => { + const testDoc = parseYamlToDocument( +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..db1c655a +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["npx jest packages/core/src/rules/__tests__/hide-internals.test.ts"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++npx jest packages/core/src/rules/__tests__/hide-internals.test.ts ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000236/tests/test.sh b/tasks/format-code-task-000236/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..3647666504c9d7beaf14ee28573b9e80e82a3b94 --- /dev/null +++ b/tasks/format-code-task-000236/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +packages/core/src/rules/__tests__/hide-internals.test.ts +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000236/tests/test_command.sh b/tasks/format-code-task-000236/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000236/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000253/environment/Dockerfile b/tasks/format-code-task-000253/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f1faae18881fb725675ef41297eade12674b1f79 --- /dev/null +++ b/tasks/format-code-task-000253/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:b38c079c0474fbb142f2449a4492a0748c890a1318442df12f09b3886dd8af80 diff --git a/tasks/format-code-task-000253/environment/setup/files/blocklist b/tasks/format-code-task-000253/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000253/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000253/environment/setup/setup.sh b/tasks/format-code-task-000253/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000253/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000253/tests/test.patch b/tasks/format-code-task-000253/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e5152ac9f8c4e5f75a2b93ddf1f215e196c536cc --- /dev/null +++ b/tasks/format-code-task-000253/tests/test.patch @@ -0,0 +1,267 @@ +diff --git a/gcloud/tests/taskflow3/test_node_timeout_feature.py b/gcloud/tests/taskflow3/test_node_timeout_feature.py +new file mode 100644 +index 000000000..6fc91ffff +--- /dev/null ++++ b/gcloud/tests/taskflow3/test_node_timeout_feature.py +@@ -0,0 +1,202 @@ ++# -*- coding: utf-8 -*- ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++import copy ++ ++from django.test import TestCase ++from mock import MagicMock, ANY, call ++ ++from pipeline import exceptions ++ ++from gcloud.taskflow3.utils import parse_node_timeout_configs ++from gcloud.taskflow3.domains.node_timeout_strategy import node_timeout_handler ++from pipeline_web.parser.format import format_web_data_to_pipeline ++ ++ ++class ParseNodeTimeoutConfigsTestCase(TestCase): ++ def test_collects_enabled_service_activities(self): ++ tree = { ++ "activities": { ++ "a1": {"type": "ServiceActivity", ++ "timeout_config": {"enable": True, "seconds": 30, "action": "forced_fail"}}, ++ "a2": {"type": "ServiceActivity", ++ "timeout_config": {"enable": True, "seconds": 5, "action": "forced_fail_and_skip"}}, ++ } ++ } ++ configs = parse_node_timeout_configs(tree) ++ by_id = {c["node_id"]: c for c in configs} ++ self.assertEqual(set(by_id.keys()), {"a1", "a2"}) ++ self.assertEqual(by_id["a1"], {"node_id": "a1", "action": "forced_fail", "timeout": 30}) ++ self.assertEqual(by_id["a2"], {"node_id": "a2", "action": "forced_fail_and_skip", "timeout": 5}) ++ ++ def test_skips_disabled_or_missing_config(self): ++ tree = { ++ "activities": { ++ "a1": {"type": "ServiceActivity"}, ++ "a2": {"type": "ServiceActivity", "timeout_config": {"enable": False, "seconds": 30, ++ "action": "forced_fail"}}, ++ "a3": {"type": "ServiceActivity", "timeout_config": {"seconds": 30, "action": "forced_fail"}}, ++ } ++ } ++ self.assertEqual(parse_node_timeout_configs(tree), []) ++ ++ def test_skips_invalid_seconds(self): ++ tree = { ++ "activities": { ++ "missing": {"type": "ServiceActivity", ++ "timeout_config": {"enable": True, "action": "forced_fail"}}, ++ "string": {"type": "ServiceActivity", ++ "timeout_config": {"enable": True, "seconds": "30", "action": "forced_fail"}}, ++ "zero": {"type": "ServiceActivity", ++ "timeout_config": {"enable": True, "seconds": 0, "action": "forced_fail"}}, ++ "negative": {"type": "ServiceActivity", ++ "timeout_config": {"enable": True, "seconds": -5, "action": "forced_fail"}}, ++ "valid": {"type": "ServiceActivity", ++ "timeout_config": {"enable": True, "seconds": 12, "action": "forced_fail"}}, ++ } ++ } ++ configs = parse_node_timeout_configs(tree) ++ self.assertEqual([c["node_id"] for c in configs], ["valid"]) ++ self.assertEqual(configs[0]["timeout"], 12) ++ ++ def test_recurses_into_subprocess(self): ++ tree = { ++ "activities": { ++ "top": {"type": "ServiceActivity", ++ "timeout_config": {"enable": True, "seconds": 30, "action": "forced_fail"}}, ++ "sub": { ++ "type": "SubProcess", ++ "timeout_config": {"enable": True, "seconds": 99, "action": "forced_fail"}, ++ "pipeline": { ++ "activities": { ++ "inner": {"type": "ServiceActivity", ++ "timeout_config": {"enable": True, "seconds": 7, ++ "action": "forced_fail_and_skip"}}, ++ "deep_sub": { ++ "type": "SubProcess", ++ "pipeline": { ++ "activities": { ++ "deep": {"type": "ServiceActivity", ++ "timeout_config": {"enable": True, "seconds": 3, ++ "action": "forced_fail"}}, ++ } ++ }, ++ }, ++ } ++ }, ++ }, ++ } ++ } ++ by_id = {c["node_id"]: c for c in parse_node_timeout_configs(tree)} ++ ++ self.assertEqual(set(by_id.keys()), {"top", "inner", "deep"}) ++ self.assertEqual(by_id["inner"]["timeout"], 7) ++ self.assertEqual(by_id["deep"]["timeout"], 3) ++ self.assertEqual(by_id["deep"]["action"], "forced_fail") ++ ++ ++class NodeTimeoutHandlerTestCase(TestCase): ++ def test_forced_fail(self): ++ task = MagicMock() ++ task.nodes_action = MagicMock(return_value={"result": True}) ++ handler = node_timeout_handler["forced_fail"] ++ result = handler.deal_with_timeout_node(task, "node_id") ++ self.assertEqual(result, {"result": True}) ++ task.nodes_action.assert_called_once_with("forced_fail", "node_id", ANY) ++ ++ def test_forced_fail_and_skip_when_fail_succeeds(self): ++ task = MagicMock() ++ task.nodes_action = MagicMock(side_effect=[{"result": True}, {"result": True, "data": "skipped"}]) ++ handler = node_timeout_handler["forced_fail_and_skip"] ++ result = handler.deal_with_timeout_node(task, "node_id") ++ ++ self.assertEqual(result, {"result": True, "data": "skipped"}) ++ self.assertEqual(task.nodes_action.call_count, 2) ++ task.nodes_action.assert_has_calls( ++ [call("forced_fail", "node_id", ANY), call("skip", "node_id", ANY)] ++ ) ++ ++ def test_forced_fail_and_skip_when_fail_fails(self): ++ task = MagicMock() ++ task.nodes_action = MagicMock(return_value={"result": False, "message": "boom"}) ++ handler = node_timeout_handler["forced_fail_and_skip"] ++ result = handler.deal_with_timeout_node(task, "node_id") ++ ++ self.assertEqual(result, {"result": False, "message": "boom"}) ++ task.nodes_action.assert_called_once_with("forced_fail", "node_id", ANY) ++ ++ ++def _build_web_pipeline(activity): ++ return { ++ "activities": {"act1": activity}, ++ "constants": {}, ++ "outputs": [], ++ "start_event": {"id": "s", "type": "EmptyStartEvent", "name": "", "incoming": "", "outgoing": "l1"}, ++ "end_event": {"id": "e", "type": "EmptyEndEvent", "name": "", "incoming": ["l2"], "outgoing": ""}, ++ "flows": { ++ "l1": {"id": "l1", "source": "s", "target": "act1"}, ++ "l2": {"id": "l2", "source": "act1", "target": "e"}, ++ }, ++ "gateways": {}, ++ "line": [], ++ "location": [], ++ "id": "root", ++ } ++ ++def _service_activity(**overrides): ++ activity = { ++ "id": "act1", ++ "type": "ServiceActivity", ++ "name": "n", ++ "optional": False, ++ "error_ignorable": False, ++ "incoming": ["l1"], ++ "outgoing": "l2", ++ "stage_name": "", ++ "component": {"code": "sleep_timer", "version": "legacy", "data": {}}, ++ } ++ activity.update(overrides) ++ return activity ++ ++ ++class TimeoutConfigConflictValidationTestCase(TestCase): ++ def test_timeout_only_converts_successfully(self): ++ web = _build_web_pipeline( ++ _service_activity(timeout_config={"enable": True, "seconds": 30, "action": "forced_fail"}) ++ ) ++ result = format_web_data_to_pipeline(copy.deepcopy(web)) ++ self.assertIn("act1", result["activities"]) ++ ++ def test_timeout_with_error_ignorable_rejected(self): ++ web = _build_web_pipeline( ++ _service_activity( ++ error_ignorable=True, ++ timeout_config={"enable": True, "seconds": 30, "action": "forced_fail"}, ++ ) ++ ) ++ with self.assertRaises(exceptions.InvalidOperationException): ++ format_web_data_to_pipeline(copy.deepcopy(web)) ++ ++ def test_timeout_with_auto_retry_rejected(self): ++ web = _build_web_pipeline( ++ _service_activity( ++ auto_retry={"enable": True, "times": 2}, ++ timeout_config={"enable": True, "seconds": 30, "action": "forced_fail"}, ++ ) ++ ) ++ with self.assertRaises(exceptions.InvalidOperationException): ++ format_web_data_to_pipeline(copy.deepcopy(web)) ++ ++ def test_no_timeout_with_error_ignorable_ok(self): ++ web = _build_web_pipeline(_service_activity(error_ignorable=True)) ++ result = format_web_data_to_pipeline(copy.deepcopy(web)) ++ self.assertIn("act1", result["activities"]) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,54 @@ ++#!/usr/bin/env bash ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++PY=/testbed/.build_env/venv/bin/python ++ ++ ++ ++cat > /testbed/local_settings.py <<'EOF' ++# -*- coding: utf-8 -*- ++DATABASES = {"default": {"ENGINE": "django.db.backends.sqlite3", "NAME": "db.sqlite3"}} ++LOG_LEVEL = "DEBUG" ++BK_IAM_SKIP = 1 ++COMPATIBLE_MODULE_MAP = {} ++ROOT_URLCONF = "_minimal_urls" ++EOF ++ ++ ++ ++ ++SHIM_DIR="$(mktemp -d)" ++cat > "$SHIM_DIR/sitecustomize.py" <<'EOF' ++try: ++ import celery ++ if not hasattr(celery, "task"): ++ celery.task = celery.shared_task ++except Exception: ++ pass ++EOF ++cat > "$SHIM_DIR/_minimal_urls.py" <<'EOF' ++urlpatterns = [] ++EOF ++ ++# shellcheck disable=SC1091 ++source scripts/develop/sites/community/env.sh ++export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python ++export BKAPP_AUTO_UPDATE_VARIABLE_MODELS=0 ++export BKAPP_AUTO_UPDATE_COMPONENT_MODELS=0 ++export PYTHONPATH="$SHIM_DIR:${PYTHONPATH:-}" ++ ++ ++"$PY" manage.py test \ ++ pipeline_web.tests.parser.format.test_format_web_data_to_pipeline \ ++ gcloud.tests.taskflow3.domains.test_auto_retry ++ ++ ++"$PY" manage.py test gcloud.tests.taskflow3.test_node_timeout_feature diff --git a/tasks/format-code-task-000253/tests/test.sh b/tasks/format-code-task-000253/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..069639fd7fde2355b949104535bb98a2eae35169 --- /dev/null +++ b/tasks/format-code-task-000253/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +gcloud/tests/taskflow3/test_node_timeout_feature.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000253/tests/test_command.sh b/tasks/format-code-task-000253/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000253/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000254/environment/Dockerfile b/tasks/format-code-task-000254/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f0fcc2879c729d22301bd20d2e95253510381a2a --- /dev/null +++ b/tasks/format-code-task-000254/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:a761c02bfebb2288fac7c5742053e1f8cbfee7996b026b71df9803fcc38a0c5d diff --git a/tasks/format-code-task-000254/environment/setup/files/blocklist b/tasks/format-code-task-000254/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000254/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000254/environment/setup/setup.sh b/tasks/format-code-task-000254/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000254/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000254/tests/test.patch b/tasks/format-code-task-000254/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..b238e50eb6262ab5440dee2ca4923532a93f7b52 --- /dev/null +++ b/tasks/format-code-task-000254/tests/test.patch @@ -0,0 +1,165 @@ +diff --git a/test/Models/MagdaReferenceSpec.ts b/test/Models/MagdaReferenceSpec.ts +index 6ea857556f7..58646bba3d6 100644 +--- a/test/Models/MagdaReferenceSpec.ts ++++ b/test/Models/MagdaReferenceSpec.ts +@@ -1,14 +1,12 @@ + import { runInAction } from "mobx"; + import CatalogGroup from "../../lib/Models/Catalog/CatalogGroup"; +-import CommonStrata from "../../lib/Models/Definition/CommonStrata"; + import CsvCatalogItem from "../../lib/Models/Catalog/CatalogItems/CsvCatalogItem"; + import GeoJsonCatalogItem from "../../lib/Models/Catalog/CatalogItems/GeoJsonCatalogItem"; + import MagdaReference from "../../lib/Models/Catalog/CatalogReferences/MagdaReference"; +-import Terria from "../../lib/Models/Terria"; + import WebMapServiceCatalogGroup from "../../lib/Models/Catalog/Ows/WebMapServiceCatalogGroup"; ++import CommonStrata from "../../lib/Models/Definition/CommonStrata"; + import updateModelFromJson from "../../lib/Models/Definition/updateModelFromJson"; +-import upsertModelFromJson from "../../lib/Models/Definition/upsertModelFromJson"; +-import CatalogMemberFactory from "../../lib/Models/Catalog/CatalogMemberFactory"; ++import Terria from "../../lib/Models/Terria"; + + describe("MagdaReference", function () { + const recordGroupWithOneCsv = { +@@ -565,5 +563,27 @@ describe("MagdaReference", function () { + expect(reference.accessType === "public").toBeTruthy(); + done(); + }); ++ ++ it("returns `super.accessType` when magdaRecord is unset", function () { ++ const terria = new Terria(); ++ const reference = new MagdaReference("magda-reference", terria); ++ reference.setAccessType("foo-doesnt-matter"); ++ reference.setTrait(CommonStrata.definition, "recordId", "test id"); ++ reference.setTrait(CommonStrata.definition, "magdaRecord", { ++ id: "test id", ++ name: "Test", ++ aspects: { ++ "access-control": { ++ orgUnitId: "some org id", ++ constraintExemption: false ++ } ++ } ++ }); ++ ++ expect(reference.accessType).toBe("non-public"); ++ reference.setTrait(CommonStrata.definition, "magdaRecord", undefined); ++ ++ expect(reference.accessType).toBe("foo-doesnt-matter"); ++ }); + }); + }); +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,100 @@ ++H4sIAAAAAAAAA+xb63LbRpbOb77C/ulRtkq2xwTRd4BZTyLLTqLEtlyWM5ktx+vpGyjYIMAFQF12 ++Kk+xf/fp9kn2NABSoETSUiI7mayRlEWiu0+f+/kO0Az0PM3sG5efjD77UFcIl+S8+QvX5b/NZ8wJ ++xpJSJvBnIcYiZJ8h/sE46l3zqlYlQp+VRVFvm/e+8X/SK7iw/ztVTtXQHJfF1A2PnbKZq6rAFHkS ++vK1+zR7ewIKxTfYnVNKF/TEXFOwvCQ0/Q+FtCbnt+n9u/5155VBVl6mpd74YDKaFnWcucGezoqwr ++9AAl89zUaZGjO94R0sld9I8BQu3noHL1Hf8VIV0Wp5UrH6UVDOXO1C/TqSvm9RhRb+L7GyYVmStV ++bhxMW5nyrNiDXU/S+nxJh6F7SITwD17SM2pWz0u3aUpLUFXuuaqPx2hnVLuq1s6OTk9PvTV3uilJ ++qabutCjfVWP0auetqqZp7nZed6MmS10OxFs5EVLlpJk3HCZpVrty5z7aeaomVr1wiSsdCLPzupn6 ++84J8CnEEK7r1O03AjV66skzVd0fDauZMBQG2c7+bsNgIoZmqYYMcWL93b3RvOQGhNDfZ3Do7RonK ++KncxAKo78bfrct67e6pqc7xmdl4YBQPt9O7uz83fhfCzsjhLPfcLpnZGVtVqx2vTa7b9dn85mE7V ++xFUXw933iwneBBfDzbeLwUYzF6Pt1xVdurNGcNDmBYcOmDSQqYrS87mYCbfBg13Z2MrreGlQf3+M ++4kiKhYWLrFnbKq25lRWTJ+7EZeOFpz85/ObNwbOvD7txNa+LH71WlzptbldpPsnci3m+QgxImHnp ++XeN8jPDCL1tHb9jbb1Lut13GfVYcqdzq4uzCBSFHFdMnCkLxuFmysMaGheOeD3lNgkZXZ/ZcKcnU ++pOedjSGGw7wYVh0T91dHIF0MJ9mD6jRN6upYWQiA5YTXKz60sIRX/ovOGhecVfMZmK6qHpdlUR7N ++p1NVnl9y0MWUrxVE0GXvXQw+V1W1cfDoXTqbLUcHC95+vvvF4OcvBr916v1dXL3676PxjSnAFLkN ++quPb2+N9+I9Luaj/RALwCzETn+r/x7k+/9NIp7lPuMcDY9GiRg4GLQRAzw4fPX5z+PzlweGzowfD ++YTFzeVVlw8xNlDkfQuo9SSEHLGbvf/vi8OnjNw8Pnj0YeYWNgqbCjGYQkK52rhy18HKUpfn8bIhZ ++FISBlDIKYtkNDZshwbqvg8Hn6KF30S4LIs8g0vMcEhk6TetjVOTZOVqtwM2kQT47Q6dOz5R5h4bD ++NpEvBRz1HL+bFPihoEv4byu/M6TyhlbVbrUAxV3ibXZoUDPyTlSvJb4VVf/2Oehy/AOQms3rAArg ++7e2xHf8zKjBb9n+QKHz8Syw/xf/HuB52OCRLK0BFRuWpr/BZWjuUVgi8ARCeswF6njlAEqgEbAMV ++1Du+7q38KlNNXAI+mPkFQ6th1o/H5+i8mKPquJhDANsCpTUAs8k8U2UG1f64rmfVeDSaQGzNNcTE ++dNQnuvLl88WXoYec7TaAtgbfQuIaIx1GOomVUVBmEugdpZZ88FeYDZ3LeJkEWEDjgA58vwBALBQc ++h9Nq4LNLjRRIH4pRGI9ISAQSY8bGGKO9pz34s/7aAwBSd5+P0v9yHpbN83fVyqTmFnoGjUa1hmAY ++XGkH4C4OBENP04eLSQi9ctMUWgL7GqEBChkjNgqjKMShZJQox7G1kRFRSBVhcfB2NvHrMIvR90sq ++6DIVFTmqklAzjkFzxEodOa6xM1hyyZMlFSy2ULly4bUSRTygPSp4lQqmTpmQGGci5kEBTkIVY6WY ++w4qJyAIN6EMREjSINvOCTaicM05r4VgkqWYJAzpGxyrSNmFLKizgW6g4wrlLlIrCmDAlhCFxLMKY ++Wo2tUkmPF3wTvZC1epEBJz1Lk0tUiARGFNMEawKsKENZLDSBnBo6r6aljeItvJAYPMSSWCbaai5A ++GnAXoRJOIgZi2Z5etlExkVVJoin4gzbwH9UmISRxOuEJ2G1JhQdyC5WERDamMcdagmlCC3YWhEjD ++gSnC45522U20S9dqF4j0tUtXqVAtTSQEhyLkoHSH2AnNreIq1gL4Snp6IZt5oZZbcFpmtCZESKK5 ++Y5pjpmTMdGijJRWxjcpVidhaiRofuZCIXaLCIAEoQkEKG2ktnSPK42+RxIxGQsqlv5BwMy+MhRA8 ++DlxPqoQSHVtomSPFjIi55oZcL44QS5JESKVicGLDnNFg6DhKBNahSSKmOl4oXckM79ULX68XGvez ++FF+lwkkc+v+51IRal1AXJTKJE2Fc5JLE9Xx3S37hGlKsMkaSRIiIUCbjiDsDUcSlCZOlvyAitlC5 ++KpFYKxG4S18vYpWK4BryJRVRxIRwxAlLEmNorLGmMUv6vrstjgS3xEjmeAJlVEL2TGIOgSAdNzqU ++SlyrkogIK1BEJJzCsYP6GzmtElhNLQD8eBkBnpstVCyXUeQY43FiQ4JdAkiQSYppHBuCbc9G26i4 ++2EGyFkQLamyc6Di0XNFYxpBiTJxcr5JctZFc73VE9DOmXKUiQ6hmkGAZeEqU0MiYJPYwF246Qg2+ ++Xq4DFVpwMiYcjQgkTImZTpjVsYxA31ZfL3tflShaLxGO+l4XXaIScRuHUWw5FZD3Y2GhQFPHVRJx ++g73bTTKNGvyyNaYBZ7BIY2Xj2GcDK6hQ0kExih01jIQtL4TcLGPGayWKg5XaGK9SgUJEaOSMsFIB ++dDQJ+GxCVJTw2ECw92vjFn+JJYU0ICMcAjCDpCkBmUHSVJHViWOJCE5VNW38Rd6oqiG0TiImIGN2 ++NWCq0nyFir8xQIpASoCdgR8KVSgKNSRjB8mOxeCClAeP9vYbO8VRr5pc4kdBGYtiF4KRk1AQyOAS ++xAsx0aHmnFwTlSGktJTAhNcohtQLGiE8iZQC2ADOY+PO2iLYkmMAwISCMpJQLCCQQ2ENZD0IiphA ++0jB99LHF8wDtWq8AozSBmNSQsmID5o+wlJiSqCfRtsq24VJVlU5nb6uFtelW7SJoXeIE0yhmEsoR ++V5qpEFTEYrARhIajXS9At+lFU0cEZF8qQsO0xdgIzZoKEDqmLnLMdu1qHsWADgjkSywJ1DlpExrj ++EDCABJyHr1lNNI+JIwQaMgCoADEBgIdaQkKGb1Iq3VUTLLf5i8GALbWIwdwcc64M5IQIkmfoWzz/ ++vGgRSyza1t1A8OpQSWxkyKAeRZRHXEMsWEoS5lx40d1syZpGQi1iPISkFIKlIBFrYy2DRkVBo6Xk ++Nf3FOCo5MbG1HnLSOMRxmGieQLrQFugtedlWH9e6nHFVOp/+WJTvoOPtOq1A8G1e11zWKQ6uJnEI ++UQjtTmhDFZw2ZBboQ26TCOyqLRhbAy6EpGkw9NTQs4UQzwCElbwWbgAX1Ra6PUWksNCWUK4g1yjA ++AUJQylhPu1tiOgEYJCMDVZ9G1tiIJBBRnCZGgjdCo3y9LJVwCf0vJE3wNSKdCjWQTbDGUAVcnPTz ++yxa9JIIbJSyWgJ6txQJjJrhvHiNwF8Ak10NCiTKQcqk0xiXQjRJouQBUaWgmoFYC5OxF442Qs79y ++5V/pqmyqZoGpwNJgOKTPa9cU//XV5HFel+ezIs3rdsKDK1SuVKnBq/A1ms6zOkVB83RxdAQjT2F1 ++UFeLW08L67JqtPoA18/zc1jYsfUPv+fP6JV/Wlm/HrwKRlmqR/tF6UZ7wMJ5nZrHJy6vq5Fa+QpE ++XkMT1UHxbVSq89w8KfwLrWYNDrskt2XNfpFXReYWDHiRYWFA5fsWzkoQ8z/naZWCbM0qDhxuk7TT ++0r6qVVZMFn+/KYv5rGGXL/qEmyw/qN0UblYnve+t8NtE30brG1d8B255hZ4Ibs7d0hkuO0dDEtBL ++fH2SpZukVe3K7vtTN9U+VXpCgDO32asj9MglaZ56fwcLTqdFflSXQKvVPZbXsV2PRPuQtLn/dVlM ++vco6R43J+3lp46xVLOEb5r83tkDyxbOrDat7wQqTAyrWTfYJ48+IEkLQcWqty1F7hKQa7B/7tzZT ++kHkI2WHozkBjph7OsvkE0kcOrL3ppo78ePd5WJ/PXGXKdFYPsyYcR2lu3RlEyZ+urOkmWP+w2Lz1 ++kfTll6VLhkMcDcnq9NJBqJ644bzMLtP9sirmpXFP1Wx1SaXWb3Ex3RvlCGaNuvMyozcnCkyjvRzt ++raACPseNlvoJdINSHqB7zVSwwC/Rz5pVa9i/PO16mrm06P26aV32Gtp5jW4i7TWF7LnBe8X9KFJC ++XYgWCWu99Vdjqo0rvBpUXUy1EG18ubj3XkRc+z3EVejYR44b+sqWNxIvmPNHMOrqipO3KOHyDq2D ++AzCY12mG7qSTHCqivYswX59Em+n4ZtPJzaZfsnrd5Ne31bBlfXTUWHvUqLcaHez9QMJQvPnbvx8h ++jxlQ6cy8rNITh/7jp+Cn/vib4N5PDUz71ys+fsM9NlNGkdyAHG4gWmeddq+W9HU5XlmaF/mFNlo6 ++aNEU3RJ3pnRQOoM/A9KYOvC1X8/nZYpo8cDpljhe7vSLWMViAwRex073orM9OZfmo0lWaJU11rzT ++jd29OoiYJL98j+7E6Po9loOIxRtAUi/ZxeIyhvADzT8/7r14dvDsGwQp5UZKHL0sVV4lRTmthkJJ ++iiXzT6wAOEGjOSZySFlDf78EZGZUBj3xzEH1a87qNRi9dBdnYNMKzStnPRcKnapz/+H0ODXHF8tS ++kNCoPC9qpP3BWtWQzc5Rl+ydbSX+6pbiawM1f6I3nwxLN8uUccPOMF2lGbUlzVey1D44s3Zuzs6O ++07cOylljue5EJdTKaXHi9huGHjk9nzwv1WSqqjVg4z1m6FeBh0VRA39qNmt4uAUj197IBhZ8//Jv ++pDEvluEY0yHGERtHmy1cH7vGyv7sQpGAUS8GvbFVDmZrThKC9T/Z7ZLdtoKRXw9N3vd0qv9wajNQ ++uQpIttNdyIEXkOtfXlEyDWMUCtScDAnboyEkEFKO/ZFg9Ko94tWcvS5fjxGsiKffN8fCTljgX8i0 ++Q+0hMUgfqm6OvoxHozBo/hv708ijbVtF3VZZdwh4sU17KBhcZnkcZ9Oh4PYEW+8sMsJbNozwhg2P ++vAy9/S5tt5lkJGlHcjG3XYnaQ4AhuvPEH/xDjULuLrbbb38oAEqD9FsV5h24UWHPJw9Pz/aTl2my ++/9f62z24WulSiwiTMg45GVxnF/T4xYvDF+jJ4TfNdmK6+2pa6LPX6JGDqDf+5NO49xmdqGwO5aAo ++0a7L4Y9xe01hqHbv+8KAdptzxrvowV/Q7k7uwOY7MLLrz4J3NwvdHtFv7u90v7toxnZ2VQYlpdrd ++gfxX1cD9bqOBAXDX5xD6eEhIjclTWzXMzCFjJWnuFit8Hl0j1H4xnc0vxOg/Q/qK0TBIq0NIfj7v ++aefJAy6y/gRYlVoHqRG++t9kOO9DNVSzAD0q/DQF9THLPMxp6XdMQCCtPndoIqtxj//9n/9urQuF ++EsKxvDi2WQC1iWfo40gN2DmYts+CbkvsPwAX7VOjPyArVx2w53y2dbyGFBSKylf+NvOktftIUYgp ++kbcchutkXjyHRFDM09rDVQRwAXAAbNDcqjwYWtFNa46PpAUp5W/piivPw7/CAofBvMw+nEFWdb/J ++HB6qLrJEB1Uv++7HMQ8h5HdkHhKKWzXPJxV+AA83xyqfQGMM9f2Ss6skgST7O3FsEYW/I6twTIMc ++uqF/Ls/+Y+twq2s3cLdZUtrrOvaVBuQgB0mgj4FWHtrs+nyMml9IosUPHnxb6jL0dxxyaRLrhoRR ++PWRKhcNIazWU/mQLBxxhYvF3lEDvg747OnwGnD/vKKIu1Jf4BljXrikx57P2t+C+vZvXiz7E/2oj ++rZYTCv0W1gVAseFs8bPoGjZIof8GZb70oR0k3ZvN5WPBITThrsxVBo3vqH1x0sz0r0ZBZ6ouymo0 ++WyVSV2PM+Jjhuxf7ONDQNqLXfd86Bh2OadijvFeW6jyAUHiszDG6828qL/LzaTGv/vIhto/omNA+ ++4TNnwNX2ut/br99h5eGNj4FmT/8hWD5sBcGwGOO4R7uc5wf5LVAmmGPo5nuU1wh3K9qR0Zjwm6v9 ++BocIxiKMxoxf0/5dBrgSsPvNb5v88972RQJk0Xd5cZp3gdqETHcr+JiZmFIZ/g7ayh4bv0VBuHog ++5SsSx77Jegzpr0z9E/t8clBVc/dJS30tURyFn7S0wstqAgFuqPzA4MI/769QCwj8Uwj/RgI+NS+1 ++K/8E9p1/UOAHfqEIHHrbFrAc2N9WmZ4TZe1hedg1CHv+FGH9kU38o9NP1ezIlSepcau+xxkLJq7e ++VzOl0wxKl6t+uL2e6VbY8854sIjiDwh5VY7AVEuk2xlKny+bu1/oAyLmgTL+DdZLXzVvUYAfDlBL ++uKnHXcFflap09bzMK7Q7m+ssNbvo9Ni/iG4w/QleLPdblkWGKnVe/V871/ebNgyE3/NXRH4CqbSF ++UqBMTNoQb5s6lU57qtq0ybpMkEQJlO2h/3vvfGc3/AjQrLRouk+iIo3PvjvOjmP7Pt491E4AXUmu ++pOmdxq5MX1r+i2HowOkKGbylvVYKDH9Nu89O98ruxqbf+TYYxdG9ft3DZbr0HqZq8HqEu0+gLYrh ++DinuNsJsfpzo+TZZlAXwzlTKSc3jzls5aW0n+BfnbPAMiuAuWVkPwWvJ/xJGW3hK7zKWddVJcz+D ++qWiEWe2qstY327uwXnR5eVSQHnTeJsPd/aLACH8WPpWgH8TQScJskpUNiNbx+3YHiPQUGoBPhAH+ ++d8lEml2VNa990tybGNuNLutcfZNN8azSc6M3uTHows5gphEMrM5WJ0a67oBW6Xy33sYl0XpbN+0O ++v/f7g+FQN+9WoGirA8P1XeYeoWSroS+qdDzm8vzy05cuVpCXct6FDGojDdYrtLGR/7Vet/xv9Qby ++v562W8L/9CZ4AOPpt56mwQ8mSuq5fPS1og4XjhYullXVDw7WkXgwdcnJ4bW59zWMwn6WDegE7DeT ++62LLFiREoLiWn3Bi4WfmcgVZrP6QUzkq19d+mOLL74EL+loxZnzrGcZaHEy6S5UhZyQu1XZd5SPl ++Z5yMg4hYSQM8O2i4MedaXKrEVcRl6qpc1pSqHrxIlBa1lgllOWNL4Ur1FVZJJG2GTDPR9LbrPAJ/ ++LectE9Aa3ZCdFguC+UWUtPS8YhJdYq9Fzs9HvAsum8TxCG7g+nzt7lfgJZy8U6MsmdrYSxQ7Gf5r ++lE6nc6y4z4Sl6Ax79NoaZGh5a95v74/RHUFHYqH9cKzTb0xOD1fQ+6gny4ajlNltjfYQEHoXwVKq ++gv5BGsZQ3SyM/HjGHlD6mXTk+T7MzVWeXpfv4AYEPRhgsj6IHsI0jnQYFZS9wG99Ckll+Xe1Tmyx ++0cgbhR7z2uIl788ga2x+v0ZTDj8iqanDAzd1IWRwRhdHwWxlL2T25lwQLCT1sgP8MMOMpjmaVVqG ++PE+1+40FVedqFYv04qhRcdyVHZHK4TfjNtvgKvVNQacqbK4CgUAgEAgEAoFAIBAIBAKBQCAQCASM ++J93V1OAAeAAA +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000254/tests/test.sh b/tasks/format-code-task-000254/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..2db02b07f23d10044716ef4eb93e9860753397c5 --- /dev/null +++ b/tasks/format-code-task-000254/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test/Models/MagdaReferenceSpec.ts +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000254/tests/test_command.sh b/tasks/format-code-task-000254/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000254/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000262/environment/Dockerfile b/tasks/format-code-task-000262/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..879f4f67583917fb93ac27916a73aaa97f92da51 --- /dev/null +++ b/tasks/format-code-task-000262/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:70823af2701d3f11ba118a12cc7d71e256c3aac8a2f9db9e317c743447e952a2 diff --git a/tasks/format-code-task-000262/environment/setup/files/blocklist b/tasks/format-code-task-000262/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000262/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000262/environment/setup/setup.sh b/tasks/format-code-task-000262/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000262/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000262/tests/test.patch b/tasks/format-code-task-000262/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..15dd0425f9d9706688a9d9a2b41a0c2fc3c240fd --- /dev/null +++ b/tasks/format-code-task-000262/tests/test.patch @@ -0,0 +1,102 @@ +diff --git a/tests/transforms/preprocessing/test_clamp.py b/tests/transforms/preprocessing/test_clamp.py +new file mode 100644 +index 000000000..0d7d8f5b1 +--- /dev/null ++++ b/tests/transforms/preprocessing/test_clamp.py +@@ -0,0 +1,63 @@ ++import re ++from pathlib import Path ++ ++import torch ++import torchio as tio ++from torchio.transforms import Clamp as TransformsClamp ++ ++from ...utils import TorchioTestCase ++ ++ ++class TestClamp(TorchioTestCase): ++ def assert_tensor_equal(self, actual, expected): ++ self.assertTrue( ++ torch.equal(actual, expected), ++ f'\nExpected:\n{expected}\nActual:\n{actual}', ++ ) ++ ++ def make_scalar_image(self, values): ++ tensor = torch.tensor(values, dtype=torch.float32).reshape(1, 1, 1, -1) ++ return tio.ScalarImage(tensor=tensor) ++ ++ def test_public_imports_and_instantiation(self): ++ transforms = [ ++ tio.Clamp(out_min=-2.5, out_max=4.5), ++ tio.Clamp(out_min=-1.5), ++ tio.Clamp(out_max=2.5), ++ TransformsClamp(out_min=-2.5, out_max=4.5), ++ ] ++ for transform in transforms: ++ self.assertTrue(callable(transform)) ++ ++ def test_clamps_scalar_image_to_two_sided_range(self): ++ image = self.make_scalar_image([-7.0, -2.5, -1.25, 3.0, 4.5, 9.0]) ++ transformed = tio.Clamp(out_min=-2.5, out_max=4.5)(image) ++ expected = torch.tensor( ++ [-2.5, -2.5, -1.25, 3.0, 4.5, 4.5], ++ dtype=torch.float32, ++ ).reshape(1, 1, 1, -1) ++ self.assert_tensor_equal(transformed.data, expected) ++ ++ def test_lower_only_clamp(self): ++ image = self.make_scalar_image([-9.0, -1.5, 0.0, 8.0]) ++ transformed = tio.Clamp(out_min=-1.5)(image) ++ expected = torch.tensor([-1.5, -1.5, 0.0, 8.0]).reshape(1, 1, 1, -1) ++ self.assert_tensor_equal(transformed.data, expected) ++ ++ def test_upper_only_clamp(self): ++ image = self.make_scalar_image([-9.0, 0.0, 2.5, 8.0]) ++ transformed = tio.Clamp(out_max=2.5)(image) ++ expected = torch.tensor([-9.0, 0.0, 2.5, 2.5]).reshape(1, 1, 1, -1) ++ self.assert_tensor_equal(transformed.data, expected) ++ ++ def test_preprocessing_docs_list_clamp(self): ++ docs_path = Path(__file__).parents[3] / 'docs/source/transforms/preprocessing.rst' ++ content = docs_path.read_text() ++ listed_transform_patterns = [ ++ r'(?m)^\s*:class:`Clamp`\s*$', ++ r'(?m)^\s*\.\.\s+autoclass::\s+Clamp\b', ++ r'(?ms)^\s*\.\.\s+autosummary::.*?^\s+Clamp\s*$', ++ r'(?m)^\s*[*-]\s+.*\bClamp\b', ++ r'(?m)^\s*Clamp\s*$', ++ ] ++ self.assertTrue(any(re.search(pattern, content) for pattern in listed_transform_patterns)) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,28 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++ ++set +u ++source /testbed/.build_env/venv/bin/activate ++set -u ++ ++ ++case "${1:-}" in ++ base) ++ python - <<'PY' ++import torch ++import torchio as tio ++image = tio.ScalarImage(tensor=torch.zeros(1, 1, 1, 1)) ++assert image.data.shape == (1, 1, 1, 1) ++print('base smoke ok') ++PY ++ ;; ++ new) ++ python -m pytest tests/transforms/preprocessing/test_clamp.py -q ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-000262/tests/test.sh b/tasks/format-code-task-000262/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..199a69f8a2842ef81ec2f0667ec7c90d00aeec1c --- /dev/null +++ b/tasks/format-code-task-000262/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/transforms/preprocessing/test_clamp.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000262/tests/test_command.sh b/tasks/format-code-task-000262/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-000262/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh base && bash /testbed/mimo_test_command.sh new \ No newline at end of file diff --git a/tasks/format-code-task-000265/environment/Dockerfile b/tasks/format-code-task-000265/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..2a124cbb68f6d8d26ee5f55093bb8701de2c28ba --- /dev/null +++ b/tasks/format-code-task-000265/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:65e9e8cf876032ec7938d8845bfe6f4cb18022cae737ede5e316083d79395dde diff --git a/tasks/format-code-task-000265/environment/setup/files/blocklist b/tasks/format-code-task-000265/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000265/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000265/environment/setup/setup.sh b/tasks/format-code-task-000265/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000265/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000265/tests/test.patch b/tasks/format-code-task-000265/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..a0fec691eb3089ccb0688baba841e3c64f648767 --- /dev/null +++ b/tasks/format-code-task-000265/tests/test.patch @@ -0,0 +1,305 @@ +diff --git a/core/test/unit/api/canary/utils/serializers/output/utils/members_spec.js b/core/test/unit/api/canary/utils/serializers/output/utils/members_spec.js +new file mode 100644 +index 00000000000..f79c9165e65 +--- /dev/null ++++ b/core/test/unit/api/canary/utils/serializers/output/utils/members_spec.js +@@ -0,0 +1,136 @@ ++const should = require('should'); ++const sinon = require('sinon'); ++const labs = require('../../../../../../../../server/services/labs'); ++const members = require('../../../../../../../../server/api/canary/utils/serializers/output/utils/members'); ++ ++describe('Unit: canary/utils/serializers/output/utils/members', function () { ++ describe('for post', function () { ++ it('does not modify attributes when members is disabled', function () { ++ const attrs = { ++ plaintext: 'no touching', ++ html: '

I am here to stay

' ++ }; ++ ++ const frame = { ++ options: {} ++ }; ++ members.forPost(attrs, frame); ++ ++ attrs.plaintext.should.eql('no touching'); ++ }); ++ ++ describe('labs.members enabled', function () { ++ before(function () { ++ sinon.stub(labs, 'isSet').returns(true); ++ }); ++ ++ it('should NOT hide content attributes when visibility is public', function () { ++ const attrs = { ++ visibility: 'public', ++ plaintext: 'no touching', ++ html: '

I am here to stay

' ++ }; ++ ++ const frame = { ++ original: { ++ context: {} ++ } ++ }; ++ ++ members.forPost(attrs, frame); ++ ++ attrs.plaintext.should.eql('no touching'); ++ }); ++ ++ it('should hide content attributes when visibility is "members"', function () { ++ const attrs = { ++ visibility: 'members', ++ plaintext: 'no touching. secret stuff', ++ html: '

I am here to stay

' ++ }; ++ ++ const frame = { ++ original: { ++ context: {} ++ } ++ }; ++ ++ members.forPost(attrs, frame); ++ ++ attrs.plaintext.should.eql(''); ++ attrs.html.should.eql(''); ++ }); ++ ++ it('should NOT hide content attributes when visibility is "members" and member is present', function () { ++ const attrs = { ++ visibility: 'members', ++ plaintext: 'I see dead people', ++ html: '

What\'s the matter?

' ++ }; ++ ++ const frame = { ++ original: { ++ context: { ++ member: {} ++ } ++ } ++ }; ++ ++ members.forPost(attrs, frame); ++ ++ attrs.plaintext.should.eql('I see dead people'); ++ attrs.html.should.eql('

What\'s the matter?

'); ++ }); ++ ++ it('should hide content attributes when visibility is "paid" and member has no subscription', function () { ++ const attrs = { ++ visibility: 'paid', ++ plaintext: 'I see dead people', ++ html: '

What\'s the matter?

' ++ }; ++ ++ const frame = { ++ original: { ++ context: { ++ member: { ++ stripe: { ++ subscriptions: [] ++ } ++ } ++ } ++ } ++ }; ++ ++ members.forPost(attrs, frame); ++ ++ attrs.plaintext.should.eql(''); ++ attrs.html.should.eql(''); ++ }); ++ ++ it('should NOT hide content attributes when visibility is "paid" and member has a subscription', function () { ++ const attrs = { ++ visibility: 'paid', ++ plaintext: 'Secret paid content', ++ html: '

Can read this

' ++ }; ++ ++ const frame = { ++ original: { ++ context: { ++ member: { ++ stripe: { ++ subscriptions: ['I pay money dollaz'] ++ } ++ } ++ } ++ } ++ }; ++ ++ members.forPost(attrs, frame); ++ ++ attrs.plaintext.should.eql('Secret paid content'); ++ attrs.html.should.eql('

Can read this

'); ++ }); ++ }); ++ }); ++}); +diff --git a/core/test/unit/api/v2/utils/serializers/output/utils/members_spec.js b/core/test/unit/api/v2/utils/serializers/output/utils/members_spec.js +new file mode 100644 +index 00000000000..87ec78b91dd +--- /dev/null ++++ b/core/test/unit/api/v2/utils/serializers/output/utils/members_spec.js +@@ -0,0 +1,136 @@ ++const should = require('should'); ++const sinon = require('sinon'); ++const labs = require('../../../../../../../../server/services/labs'); ++const members = require('../../../../../../../../server/api/v2/utils/serializers/output/utils/members'); ++ ++describe('Unit: v2/utils/serializers/output/utils/members', function () { ++ describe('for post', function () { ++ it('does not modify attributes when members is disabled', function () { ++ const attrs = { ++ plaintext: 'no touching', ++ html: '

I am here to stay

' ++ }; ++ ++ const frame = { ++ options: {} ++ }; ++ members.forPost(attrs, frame); ++ ++ attrs.plaintext.should.eql('no touching'); ++ }); ++ ++ describe('labs.members enabled', function () { ++ before(function () { ++ sinon.stub(labs, 'isSet').returns(true); ++ }); ++ ++ it('should NOT hide content attributes when visibility is public', function () { ++ const attrs = { ++ visibility: 'public', ++ plaintext: 'no touching', ++ html: '

I am here to stay

' ++ }; ++ ++ const frame = { ++ original: { ++ context: {} ++ } ++ }; ++ ++ members.forPost(attrs, frame); ++ ++ attrs.plaintext.should.eql('no touching'); ++ }); ++ ++ it('should hide content attributes when visibility is "members"', function () { ++ const attrs = { ++ visibility: 'members', ++ plaintext: 'no touching. secret stuff', ++ html: '

I am here to stay

' ++ }; ++ ++ const frame = { ++ original: { ++ context: {} ++ } ++ }; ++ ++ members.forPost(attrs, frame); ++ ++ attrs.plaintext.should.eql(''); ++ attrs.html.should.eql(''); ++ }); ++ ++ it('should NOT hide content attributes when visibility is "members" and member is present', function () { ++ const attrs = { ++ visibility: 'members', ++ plaintext: 'I see dead people', ++ html: '

What\'s the matter?

' ++ }; ++ ++ const frame = { ++ original: { ++ context: { ++ member: {} ++ } ++ } ++ }; ++ ++ members.forPost(attrs, frame); ++ ++ attrs.plaintext.should.eql('I see dead people'); ++ attrs.html.should.eql('

What\'s the matter?

'); ++ }); ++ ++ it('should hide content attributes when visibility is "paid" and member has no subscription', function () { ++ const attrs = { ++ visibility: 'paid', ++ plaintext: 'I see dead people', ++ html: '

What\'s the matter?

' ++ }; ++ ++ const frame = { ++ original: { ++ context: { ++ member: { ++ stripe: { ++ subscriptions: [] ++ } ++ } ++ } ++ } ++ }; ++ ++ members.forPost(attrs, frame); ++ ++ attrs.plaintext.should.eql(''); ++ attrs.html.should.eql(''); ++ }); ++ ++ it('should NOT hide content attributes when visibility is "paid" and member has a subscription', function () { ++ const attrs = { ++ visibility: 'paid', ++ plaintext: 'Secret paid content', ++ html: '

Can read this

' ++ }; ++ ++ const frame = { ++ original: { ++ context: { ++ member: { ++ stripe: { ++ subscriptions: ['I pay money dollaz'] ++ } ++ } ++ } ++ } ++ }; ++ ++ members.forPost(attrs, frame); ++ ++ attrs.plaintext.should.eql('Secret paid content'); ++ attrs.html.should.eql('

Can read this

'); ++ }); ++ }); ++ }); ++}); +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,5 @@ ++H4sIAAAAAAAAA+3R32rDIBQGcK/7FF71MkZb48sMgjFCHVGDf0q3p28IhY7BWgYt29j3u1HOkaP4 ++NUN109jbcGTkWdqFknJdF5/Xdc+l4LzjLRc70nIuFSdUPu1FH9RcdKKUpBjLrXP3+n9Uc82/2Fx6 ++E73XYWzy4XF33MtfdLtL/q1SaqnzfSf2hLaPe8LX/nn+ZqRr8IMdN2E+UR/NQVMTk13LrAZXmJ4d ++Mzro9MZqcVNm2SanJ/duU2axlrmWS8NbPyzFPs/WNK+Zbrf05fbco/jmzM1PfxkAAAAAAAAAAAAA ++AAAAAAAAwK9xBrPkNwwAKAAA +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000265/tests/test.sh b/tasks/format-code-task-000265/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..7c2c2422ce0ddf0a1d2be58cd41a9d0253858aeb --- /dev/null +++ b/tasks/format-code-task-000265/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +core/test/unit/api/canary/utils/serializers/output/utils/members_spec.js +core/test/unit/api/v2/utils/serializers/output/utils/members_spec.js +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000265/tests/test_command.sh b/tasks/format-code-task-000265/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000265/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000291/environment/Dockerfile b/tasks/format-code-task-000291/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b7d1f7cec9efc6ee5a5a3959763f46ab4bde8468 --- /dev/null +++ b/tasks/format-code-task-000291/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:161d93583fc8d25319f303514cd8f27f1124d35feb2a6b4e9723dcf227e62bf5 diff --git a/tasks/format-code-task-000291/environment/setup/files/blocklist b/tasks/format-code-task-000291/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000291/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000291/environment/setup/setup.sh b/tasks/format-code-task-000291/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000291/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000291/tests/test.patch b/tasks/format-code-task-000291/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..84d1f34c4bac4350ccb535f03e38fe0159596883 --- /dev/null +++ b/tasks/format-code-task-000291/tests/test.patch @@ -0,0 +1,260 @@ +diff --git a/usercase-test-coderl/usecase.sh b/usercase-test-coderl/usecase.sh +new file mode 100755 +--- /dev/null ++++ b/usercase-test-coderl/usecase.sh +@@ -0,0 +1,238 @@ ++#!/usr/bin/env bash ++ ++set -u ++export LANG=C.UTF-8 LC_ALL=C.UTF-8 TZ=UTC ++export PYTHONWARNINGS=ignore ++export PYTHONDONTWRITEBYTECODE=1 ++export NO_COLOR=1 ++ ++REPO=/workspace/repo ++ ++TMP=$(mktemp -d) ++trap 'rm -rf "$TMP"' EXIT ++fail() { echo "FAIL: $*" >&2; exit 1; } ++ ++VENV=${TST_VENV:-/opt/coderl-wake-venv} ++ ++if [ ! -x "$VENV/bin/python" ] && [ -x /opt/coderl-venv/bin/python ]; then ++ VENV=/opt/coderl-venv ++fi ++[ -x "$VENV/bin/python" ] || fail "missing preinstalled Python venv" ++[ -x "$VENV/bin/wake" ] || fail "missing preinstalled wake CLI" ++BIN="$VENV/bin/wake" ++ ++assert_detection_status() { ++ local feature=$1 ++ local ec=$2 ++ ++ if [ "$ec" -ne 0 ] && [ "$ec" -ne 3 ]; then ++ fail "$feature exit $ec; want successful detector run" ++ fi ++} ++ ++assert_no_internal_error() { ++ local feature=$1 ++ local err_file=$2 ++ ++ if grep -Eiq 'Traceback|Unhandled exception|Internal error' "$err_file"; then ++ fail "$feature unexpected internal error: $(cat "$err_file")" ++ fi ++} ++ ++assert_json_summary() { ++ local json_file=$1 ++ local expected=$2 ++ [ -f "$json_file" ] || fail "missing JSON output $json_file" ++ "$VENV/bin/python" - "$json_file" "$expected" <<'PY' || exit 1 ++import json ++import sys ++from collections import Counter ++ ++path, expected = sys.argv[1], sys.argv[2] ++data = json.load(open(path)) ++actual = [] ++for item in data: ++ loc = item["detection"]["location"] ++ actual.append( ++ ( ++ item["detector_name"], ++ item["detection"]["message"], ++ item["impact"], ++ item["confidence"], ++ loc["relative_path"], ++ loc["start_line"], ++ loc["start_col"], ++ loc["end_line"], ++ loc["end_col"], ++ ) ++ ) ++want = [tuple(row) for row in json.loads(expected)] ++if Counter(actual) != Counter(want): ++ print("JSON detections mismatch", file=sys.stderr) ++ print("actual =", json.dumps(actual, indent=2), file=sys.stderr) ++ print("want =", json.dumps(want, indent=2), file=sys.stderr) ++ sys.exit(1) ++PY ++} ++ ++cd "$TMP" || exit 1 ++ ++ ++ ++ ++"$BIN" detect tx-origin --help >out 2>err ++ec=$? ++[ "$ec" -eq 0 ] || fail "F1 exit $ec; want 0" ++ ++grep -Fq "Usage:" out && grep -Fq "wake detect tx-origin" out \ ++ || fail "F1 missing usage line" ++grep -Fq "Possibly incorrect usage of tx.origin" out \ ++ || fail "F1 missing command description" ++ ++grep -Fq -- "--account-abstraction" out \ ++ || fail "F1 missing positive account-abstraction option" ++grep -Fq -- "no-account-abstraction" out \ ++ || fail "F1 missing negative account-abstraction option" ++ ++grep -Fq "[default:" out && grep -Fq "account-abstraction]" out \ ++ || fail "F1 missing enabled default" ++ ++ ++ ++ ++mkdir -p case-default/contracts ++cat >case-default/contracts/TxOriginCase.sol <<'SOL' ++ ++pragma solidity ^0.8.20; ++ ++contract TxOriginCase { ++ address owner; ++ mapping(address => uint256) lastSeen; ++ ++ function directAssignment() external view returns (address) { ++ address caller = tx.origin; ++ return caller; ++ } ++ ++ function equalityOwner() external view { ++ require(tx.origin == owner, "owner"); ++ } ++ ++ function greaterThanCaller(address caller) external view { ++ require(tx.origin > caller, "gt"); ++ } ++ ++ function mappingAssignment() external { ++ lastSeen[tx.origin] = block.number; ++ } ++ ++ function safeSender() external view { ++ require(tx.origin == msg.sender, "sender"); ++ } ++ ++ function safeRateLimitLt() external view { ++ require(lastSeen[tx.origin] < block.timestamp, "lt"); ++ } ++ ++ function safeRateLimitGt() external view { ++ require(lastSeen[tx.origin] > block.timestamp, "gt"); ++ } ++} ++SOL ++( ++ cd case-default && ++ "$BIN" detect --no-exclude-known-contracts --export json --target-version 0.8.34 tx-origin contracts/TxOriginCase.sol >"$TMP/out" 2>"$TMP/err" ++) ++ec=$? ++assert_detection_status F2 "$ec" ++EXPECTED_F2='[ ++["tx-origin","Unsafe usage of tx.origin","medium","low","contracts/TxOriginCase.sol",9,26,9,35], ++["tx-origin","Unsafe usage of tx.origin","medium","low","contracts/TxOriginCase.sol",14,17,14,26], ++["tx-origin","Unsafe usage of tx.origin","medium","low","contracts/TxOriginCase.sol",18,17,18,26], ++["tx-origin","Unsafe usage of tx.origin","medium","low","contracts/TxOriginCase.sol",22,18,22,27], ++["tx-origin","Use of tx.origin may interfere with ERC-4337 account abstraction","warning","low","contracts/TxOriginCase.sol",9,26,9,35], ++["tx-origin","Use of tx.origin may interfere with ERC-4337 account abstraction","warning","low","contracts/TxOriginCase.sol",14,17,14,26], ++["tx-origin","Use of tx.origin may interfere with ERC-4337 account abstraction","warning","low","contracts/TxOriginCase.sol",18,17,18,26], ++["tx-origin","Use of tx.origin may interfere with ERC-4337 account abstraction","warning","low","contracts/TxOriginCase.sol",22,18,22,27], ++["tx-origin","Use of tx.origin may interfere with ERC-4337 account abstraction","warning","low","contracts/TxOriginCase.sol",26,17,26,26], ++["tx-origin","Use of tx.origin may interfere with ERC-4337 account abstraction","warning","low","contracts/TxOriginCase.sol",30,26,30,35], ++["tx-origin","Use of tx.origin may interfere with ERC-4337 account abstraction","warning","low","contracts/TxOriginCase.sol",34,26,34,35] ++]' ++assert_json_summary "$TMP/case-default/.wake/detections.json" "$EXPECTED_F2" ++assert_no_internal_error F2 "$TMP/err" ++ ++ ++ ++ ++cp -R case-default case-no-aa ++( ++ cd case-no-aa && ++ "$BIN" detect --no-exclude-known-contracts --export json --target-version 0.8.34 tx-origin --no-account-abstraction contracts/TxOriginCase.sol >"$TMP/out" 2>"$TMP/err" ++) ++ec=$? ++assert_detection_status F3 "$ec" ++EXPECTED_F3='[ ++["tx-origin","Unsafe usage of tx.origin","medium","low","contracts/TxOriginCase.sol",9,26,9,35], ++["tx-origin","Unsafe usage of tx.origin","medium","low","contracts/TxOriginCase.sol",14,17,14,26], ++["tx-origin","Unsafe usage of tx.origin","medium","low","contracts/TxOriginCase.sol",18,17,18,26], ++["tx-origin","Unsafe usage of tx.origin","medium","low","contracts/TxOriginCase.sol",22,18,22,27] ++]' ++assert_json_summary "$TMP/case-no-aa/.wake/detections.json" "$EXPECTED_F3" ++assert_no_internal_error F3 "$TMP/err" ++ ++ ++ ++ ++mkdir -p case-safe/contracts ++cat >case-safe/contracts/SafeOnly.sol <<'SOL' ++ ++pragma solidity ^0.8.20; ++ ++contract SafeOnly { ++ mapping(address => uint256) lastSeen; ++ ++ function safeSender() external view { ++ require(tx.origin == msg.sender, "sender"); ++ } ++ ++ function safeRateLimitLt() external view { ++ require(lastSeen[tx.origin] < block.timestamp, "lt"); ++ } ++ ++ function safeRateLimitGt() external view { ++ require(lastSeen[tx.origin] > block.timestamp, "gt"); ++ } ++} ++SOL ++( ++ cd case-safe && ++ "$BIN" detect --no-exclude-known-contracts --export json --target-version 0.8.34 tx-origin --no-account-abstraction contracts/SafeOnly.sol >"$TMP/out" 2>"$TMP/err" ++) ++ec=$? ++ ++assert_detection_status F4 "$ec" ++[ "$(cat case-safe/.wake/detections.json)" = "[]" ] \ ++ || fail "F4 detections: $(cat case-safe/.wake/detections.json)" ++assert_no_internal_error F4 "$TMP/err" ++ ++ ++ ++ ++cp -R case-safe case-aa-explicit ++( ++ cd case-aa-explicit && ++ "$BIN" detect --no-exclude-known-contracts --export json --target-version 0.8.34 tx-origin --account-abstraction contracts/SafeOnly.sol >"$TMP/out" 2>"$TMP/err" ++) ++ec=$? ++ ++assert_detection_status F5 "$ec" ++EXPECTED_F5='[ ++["tx-origin","Use of tx.origin may interfere with ERC-4337 account abstraction","warning","low","contracts/SafeOnly.sol",8,17,8,26], ++["tx-origin","Use of tx.origin may interfere with ERC-4337 account abstraction","warning","low","contracts/SafeOnly.sol",12,26,12,35], ++["tx-origin","Use of tx.origin may interfere with ERC-4337 account abstraction","warning","low","contracts/SafeOnly.sol",16,26,16,35] ++]' ++assert_json_summary "$TMP/case-aa-explicit/.wake/detections.json" "$EXPECTED_F5" ++assert_no_internal_error F5 "$TMP/err" ++ ++echo "PASS" ++exit 0 +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,12 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++exec bash /workspace/repo/usercase-test-coderl/usecase.sh diff --git a/tasks/format-code-task-000291/tests/test.sh b/tasks/format-code-task-000291/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d4d80bb634b14076ae561be99f395189577b7ac6 --- /dev/null +++ b/tasks/format-code-task-000291/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/usecase.sh +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000291/tests/test_command.sh b/tasks/format-code-task-000291/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000291/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000296/environment/Dockerfile b/tasks/format-code-task-000296/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..be12539bb1d6de7b5faa22b48ad2691a6602055e --- /dev/null +++ b/tasks/format-code-task-000296/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:f7bcd381200ef530e1be9b8c35c435138e6dc9cb93c8ff14cd0630004560bf83 diff --git a/tasks/format-code-task-000296/environment/setup/files/blocklist b/tasks/format-code-task-000296/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000296/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000296/environment/setup/setup.sh b/tasks/format-code-task-000296/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000296/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000296/tests/test.patch b/tasks/format-code-task-000296/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..b69fc9900c4e8e1d97f21fbe50a2fabfbe2c3050 --- /dev/null +++ b/tasks/format-code-task-000296/tests/test.patch @@ -0,0 +1,87 @@ +diff --git a/tests/fixers/test_settings_storages.py b/tests/fixers/test_settings_storages.py +index ac77d444..e37842a5 100644 +--- a/tests/fixers/test_settings_storages.py ++++ b/tests/fixers/test_settings_storages.py +@@ -171,3 +171,62 @@ def test_retains_quoting(): + settings, + filename="settings.py", + ) ++ ++ ++def test_star_import_not_settings(): ++ check_transformed( ++ """\ ++ from example import * ++ DEFAULT_FILE_STORAGE = "example.backend" ++ """, ++ """\ ++ from example import * ++ STORAGES = { ++ "default": { ++ "BACKEND": "example.backend", ++ }, ++ } ++ """, ++ settings, ++ filename="settings.py", ++ ) ++ ++ ++def test_star_import_base_settings(): ++ check_transformed( ++ """\ ++ from base_settings import * ++ DEFAULT_FILE_STORAGE = "example.backend" ++ """, ++ """\ ++ from base_settings import * ++ STORAGES = { ++ **STORAGES, ++ "default": { ++ "BACKEND": "example.backend", ++ }, ++ } ++ """, ++ settings, ++ filename="settings.py", ++ ) ++ ++ ++def test_star_import_extended_module_path(): ++ check_transformed( ++ """\ ++ from example.settings.base import * ++ DEFAULT_FILE_STORAGE = "example.backend" ++ """, ++ """\ ++ from example.settings.base import * ++ STORAGES = { ++ **STORAGES, ++ "default": { ++ "BACKEND": "example.backend", ++ }, ++ } ++ """, ++ settings, ++ filename="settings.py", ++ ) +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,4 @@ ++H4sIAAAAAAAAA+3SQW7CMBCF4aw5xVyAYIeYHCcKxIVITYwyBpXb100XVEjABoQq/m/hscaWbOs5 ++Xx+6z7b2w3GRPYtJKuemmlzWaW5dYYuyLOxymRlrXbXKxD3tRn8cNDajSDaGEG/tu7f+T+Xn/KPX ++WG9C3zdDm+vucWfcy9+a6py/SftsuUotMY+7wnVvnv+mlSn4tW9n+1PchUHmvaRZ6snPoIuP7suP +++vs91MfYDVutNYax2XrN9yeZH2evfgYAAAAAAAAAAAAAAADwlr4BufIIeQAoAAA= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000296/tests/test.sh b/tasks/format-code-task-000296/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..5cb4d3bcb35abd3b325cc288e85e488bdfc67b1a --- /dev/null +++ b/tasks/format-code-task-000296/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/fixers/test_settings_storages.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000296/tests/test_command.sh b/tasks/format-code-task-000296/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000296/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000298/environment/Dockerfile b/tasks/format-code-task-000298/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..1c8370111fc936c73f9f2e031661e8a9d4146e6c --- /dev/null +++ b/tasks/format-code-task-000298/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:a39df10c63871216410ecdef19bd5a28d1f5168f9a42edf740db0ac28d682f92 diff --git a/tasks/format-code-task-000298/environment/setup/files/blocklist b/tasks/format-code-task-000298/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000298/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000298/environment/setup/setup.sh b/tasks/format-code-task-000298/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000298/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000298/tests/test.patch b/tasks/format-code-task-000298/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..4b83ad86c4dcd3b8237519aa81e70321cf2467d3 --- /dev/null +++ b/tasks/format-code-task-000298/tests/test.patch @@ -0,0 +1,489 @@ +diff --git a/usercase-test-coderl/bytes.test.js b/usercase-test-coderl/bytes.test.js +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/bytes.test.js +@@ -0,0 +1,347 @@ ++ ++ ++ ++ ++var expect = require('chai').expect; ++var childProcess = require('child_process'); ++var fs = require('fs'); ++var http = require('http'); ++var https = require('https'); ++var net = require('net'); ++var os = require('os'); ++var path = require('path'); ++var numeral = require('/workspace/repo'); ++ ++describe('usercase byte quantity formatting and parsing', function() { ++ afterEach(function() { ++ numeral.reset(); ++ }); ++ ++ it('formats decimal bytes as adjacent B', function() { ++ ++ ++ ++ ++ expect(numeral(100).format('0b')).to.equal('100B'); ++ }); ++ ++ it('formats null decimal bytes as spaced zero B', function() { ++ ++ ++ ++ ++ expect(numeral(null).format('0 b')).to.equal('0 B'); ++ }); ++ ++ it('formats decimal kilobytes with a space before KB', function() { ++ ++ ++ ++ ++ expect(numeral(2000).format('0 b')).to.equal('2 KB'); ++ }); ++ ++ it('formats decimal megabytes adjacent to MB', function() { ++ ++ ++ ++ ++ expect(numeral(Math.pow(1000, 2) * 5).format('0b')).to.equal('5MB'); ++ }); ++ ++ it('formats decimal gigabytes with optional one-decimal output', function() { ++ ++ ++ ++ ++ expect(numeral(Math.pow(1000, 3) * 7.343).format('0.[0] b')).to.equal('7.3 GB'); ++ }); ++ ++ it('formats decimal terabytes with fixed three-decimal rounding', function() { ++ ++ ++ ++ ++ expect(numeral(Math.pow(1000, 4) * 3.1536544).format('0.000b')).to.equal('3.154TB'); ++ }); ++ ++ it('formats decimal petabytes with rounded integer output', function() { ++ ++ ++ ++ ++ expect(numeral(Math.pow(1000, 5) * 2.953454534534).format('0b')).to.equal('3PB'); ++ }); ++ ++ it('formats binary bytes as spaced zero B', function() { ++ ++ ++ ++ ++ expect(numeral(0).format('0 ib')).to.equal('0 B'); ++ }); ++ ++ it('formats binary kibibytes with a space before KiB', function() { ++ ++ ++ ++ ++ expect(numeral(1024 * 2).format('0 ib')).to.equal('2 KiB'); ++ }); ++ ++ it('formats binary mebibytes adjacent to MiB', function() { ++ ++ ++ ++ ++ expect(numeral(Math.pow(1024, 2) * 5).format('0ib')).to.equal('5MiB'); ++ }); ++ ++ it('formats binary gibibytes with optional one-decimal output', function() { ++ ++ ++ ++ ++ expect(numeral(Math.pow(1024, 3) * 7.343).format('0.[0] ib')).to.equal('7.3 GiB'); ++ }); ++ ++ it('formats binary tebibytes with fixed three-decimal rounding', function() { ++ ++ ++ ++ ++ expect(numeral(Math.pow(1024, 4) * 3.1536544).format('0.000ib')).to.equal('3.154TiB'); ++ }); ++ ++ it('formats binary pebibytes with rounded integer output', function() { ++ ++ ++ ++ ++ expect(numeral(Math.pow(1024, 5) * 2.953454534534).format('0ib')).to.equal('3PiB'); ++ }); ++ ++ it('honors the public optional roundingFunction argument for byte formatting', function() { ++ ++ ++ ++ ++ expect(numeral(1999).format('0.0 b', Math.floor)).to.equal('1.9 KB'); ++ }); ++ ++ it('parses zero decimal bytes as zero', function() { ++ ++ ++ ++ ++ expect(numeral('0B').value()).to.equal(0); ++ }); ++ ++ it('parses decimal bytes as raw bytes', function() { ++ ++ ++ ++ ++ expect(numeral('100B').value()).to.equal(100); ++ }); ++ ++ it('parses spaced decimal kilobytes as raw bytes', function() { ++ ++ ++ ++ ++ expect(numeral('2 KB').value()).to.equal(2000); ++ }); ++ ++ it('parses adjacent decimal megabytes as raw bytes', function() { ++ ++ ++ ++ ++ expect(numeral('5MB').value()).to.equal(5000000); ++ }); ++ ++ it('parses decimal gigabytes with a fractional quantity', function() { ++ ++ ++ ++ ++ expect(numeral('7.3 GB').value()).to.equal(7300000000); ++ }); ++ ++ it('parses adjacent decimal terabytes with a fractional quantity', function() { ++ ++ ++ ++ ++ expect(numeral('3.154TB').value()).to.equal(3154000000000); ++ }); ++ ++ it('parses adjacent decimal petabytes as raw bytes', function() { ++ ++ ++ ++ ++ expect(numeral('3PB').value()).to.equal(3000000000000000); ++ }); ++ ++ it('parses spaced binary kibibytes as raw bytes', function() { ++ ++ ++ ++ ++ expect(numeral('2 KiB').value()).to.equal(2048); ++ }); ++ ++ it('parses adjacent binary mebibytes as raw bytes', function() { ++ ++ ++ ++ ++ expect(numeral('5MiB').value()).to.equal(5242880); ++ }); ++ ++ it('parses binary gibibytes with a fractional quantity', function() { ++ ++ ++ ++ ++ expect(numeral('7.3 GiB').value()).to.equal(7838315315.2); ++ }); ++ ++ it('parses adjacent binary tebibytes with a fractional quantity', function() { ++ ++ ++ ++ ++ expect(numeral('3.154TiB').value()).to.equal(3467859674005.504); ++ }); ++ ++ it('parses adjacent binary pebibytes as raw bytes', function() { ++ ++ ++ ++ ++ expect(numeral('3PiB').value()).to.equal(3377699720527872); ++ }); ++ ++ it('leaves BPS strings for the basis-point parser instead of byte parsing', function() { ++ ++ ++ ++ ++ expect(numeral('1 BPS').value()).to.equal(0.0001); ++ }); ++ ++ it('uses the public roundingFunction callback during byte formatting', function() { ++ var calls = 0; ++ var floorAndCount = function(value) { ++ calls += 1; ++ return Math.floor(value); ++ }; ++ ++ ++ expect(numeral(1999).format('0.0 b', floorAndCount)).to.equal('1.9 KB'); ++ expect(calls).to.be.above(0); ++ }); ++ ++ it('is referentially transparent for the same input and byte format mask', function() { ++ expect(numeral(Math.pow(1024, 3) * 7.343).format('0.[0] ib')).to.equal('7.3 GiB'); ++ expect(numeral(Math.pow(1024, 3) * 7.343).format('0.[0] ib')).to.equal('7.3 GiB'); ++ }); ++ ++ it('does not mutate caller-provided number-like inputs', function() { ++ var input = new Number(2000); ++ input.metadata = { ++ label: 'decimal-kilobytes', ++ values: [1000, 2000] ++ }; ++ var before = { ++ primitive: input.valueOf(), ++ metadata: JSON.parse(JSON.stringify(input.metadata)), ++ keys: Object.keys(input) ++ }; ++ ++ expect(numeral(input).format('0 b')).to.equal('2 KB'); ++ expect(input.valueOf()).to.equal(before.primitive); ++ expect(input.metadata).to.deep.equal(before.metadata); ++ expect(Object.keys(input)).to.deep.equal(before.keys); ++ }); ++ ++ it('matches a fresh Node process for the same public byte call', function() { ++ var inProcess = numeral(Math.pow(1000, 4) * 3.1536544).format('0.000b'); ++ var script = [ ++ "var numeral = require('/workspace/repo');", ++ "process.stdout.write(JSON.stringify(numeral(Math.pow(1000, 4) * 3.1536544).format('0.000b')));" ++ ].join(''); ++ var outOfProcess = JSON.parse(childProcess.execFileSync(process.execPath, ['-e', script], { ++ encoding: 'utf8' ++ })); ++ ++ expect(inProcess).to.equal('3.154TB'); ++ expect(outOfProcess).to.equal('3.154TB'); ++ }); ++ ++ it('does not perform undeclared filesystem or network side effects', function() { ++ var previousCwd = process.cwd(); ++ var tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'numeral-bytes-')); ++ var originalWriteFileSync = fs.writeFileSync; ++ var originalAppendFileSync = fs.appendFileSync; ++ var originalMkdirSync = fs.mkdirSync; ++ var originalOpenSync = fs.openSync; ++ var originalHttpRequest = http.request; ++ var originalHttpsRequest = https.request; ++ var originalNetSocket = net.Socket; ++ var writes = []; ++ var network = []; ++ ++ function recordWrite(name) { ++ return function(target) { ++ writes.push(name + ':' + target); ++ throw new Error('unexpected filesystem write'); ++ }; ++ } ++ ++ function recordNetwork(name) { ++ return function() { ++ network.push(name); ++ throw new Error('unexpected network access'); ++ }; ++ } ++ ++ process.chdir(tmpDir); ++ try { ++ fs.writeFileSync = recordWrite('writeFileSync'); ++ fs.appendFileSync = recordWrite('appendFileSync'); ++ fs.mkdirSync = recordWrite('mkdirSync'); ++ fs.openSync = function(target, flags) { ++ if (typeof flags === 'string' && /[wax+]/.test(flags)) { ++ writes.push('openSync:' + target); ++ throw new Error('unexpected filesystem write'); ++ } ++ return originalOpenSync.apply(fs, arguments); ++ }; ++ http.request = recordNetwork('http.request'); ++ https.request = recordNetwork('https.request'); ++ net.Socket = recordNetwork('net.Socket'); ++ ++ var before = fs.readdirSync(process.cwd()).sort(); ++ expect(numeral(2000).format('0 b')).to.equal('2 KB'); ++ expect(numeral('7.3 GiB').value()).to.equal(7838315315.2); ++ var after = fs.readdirSync(process.cwd()).sort(); ++ ++ expect(after).to.deep.equal(before); ++ expect(writes).to.deep.equal([]); ++ expect(network).to.deep.equal([]); ++ } finally { ++ fs.writeFileSync = originalWriteFileSync; ++ fs.appendFileSync = originalAppendFileSync; ++ fs.mkdirSync = originalMkdirSync; ++ fs.openSync = originalOpenSync; ++ http.request = originalHttpRequest; ++ https.request = originalHttpsRequest; ++ net.Socket = originalNetSocket; ++ process.chdir(previousCwd); ++ } ++ }); ++}); +diff --git a/usercase-test-coderl/offline-Gruntfile.js b/usercase-test-coderl/offline-Gruntfile.js +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/offline-Gruntfile.js +@@ -0,0 +1,108 @@ ++ ++module.exports = function(grunt) { ++ ++ var compileType = function() { ++ var type = this.data.type; ++ var template = grunt.file.read('templates/types.js'); ++ var anon = grunt.file.read('templates/anon.js'); ++ var files = grunt.file.expand([ ++ 'src/' + type + '/*.js' ++ ]); ++ var regexp = /\}\(this, function \(numeral\) \{\s([\s\S]+)(?:\s\}\)\);)/; ++ var content = ''; ++ var file; ++ var i; ++ ++ for (i = 0; i < files.length; i++) { ++ file = grunt.file.read(files[i]); ++ ++ content += '\n' + grunt.template.process(anon, { ++ data: { ++ content: file.match(regexp)[1] ++ } ++ }) + '\n'; ++ } ++ ++ grunt.file.write('temp/' + type + '.js', content); ++ ++ if (type === 'locales') { ++ grunt.file.write('locales.js', grunt.template.process(template, { ++ data: { ++ type: type, ++ content: content ++ } ++ })); ++ } ++ }, ++ compileNumeral = function() { ++ var numeral = grunt.file.read('src/numeral.js'); ++ var formats = grunt.file.read('temp/formats.js'); ++ var index = numeral.indexOf('return numeral;'); ++ ++ numeral = numeral.substr(0, index) + '\n' + formats + numeral.substr(index); ++ ++ grunt.file.write('numeral.js', numeral); ++ }; ++ ++ grunt.loadNpmTasks('grunt-contrib-jshint'); ++ grunt.loadNpmTasks('grunt-contrib-copy'); ++ ++ grunt.initConfig({ ++ copy: { ++ locales: { ++ files: [ ++ { ++ expand: true, ++ cwd: 'src/', ++ src: [ ++ 'locales/*.js' ++ ], ++ dest: './' ++ } ++ ] ++ } ++ }, ++ compile: { ++ locales: { ++ type: 'locales' ++ }, ++ formats: { ++ type: 'formats' ++ } ++ }, ++ jshint: { ++ all: [ ++ 'Gruntfile.js', ++ 'src/**/*.js' ++ ], ++ options: { ++ 'node': true, ++ 'browser': true, ++ 'curly': true, ++ 'devel': false, ++ 'eqeqeq': true, ++ 'eqnull': true, ++ 'newcap': true, ++ 'noarg': true, ++ 'undef': true, ++ 'sub': true, ++ 'strict': false, ++ 'quotmark': 'single', ++ 'globals': { ++ 'define': true ++ } ++ } ++ } ++ }); ++ ++ grunt.registerMultiTask('compile', compileType); ++ ++ grunt.registerTask('compile:numeral', compileNumeral); ++ ++ grunt.registerTask('build', [ ++ 'jshint', ++ 'compile', ++ 'compile:numeral', ++ 'copy' ++ ]); ++}; +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,19 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo ++ ++ ++test -x ./node_modules/.bin/grunt ++test -x ./node_modules/.bin/_mocha ++./node_modules/.bin/grunt --base /workspace/repo --gruntfile /workspace/repo/usercase-test-coderl/offline-Gruntfile.js build >/dev/null ++exec ./node_modules/.bin/_mocha /workspace/repo/usercase-test-coderl/bytes.test.js diff --git a/tasks/format-code-task-000298/tests/test.sh b/tasks/format-code-task-000298/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..ea27d7288491138afb662829f4785e5645f9511f --- /dev/null +++ b/tasks/format-code-task-000298/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/bytes.test.js +usercase-test-coderl/offline-Gruntfile.js +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000298/tests/test_command.sh b/tasks/format-code-task-000298/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000298/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000310/environment/Dockerfile b/tasks/format-code-task-000310/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6166a5c887098fd3623589cf9e2e8a8e253e41bf --- /dev/null +++ b/tasks/format-code-task-000310/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:6710d2b16e9edd286364dc410eb68851d9ec331a518e5741a81912a0d5e2b88f diff --git a/tasks/format-code-task-000310/environment/setup/files/blocklist b/tasks/format-code-task-000310/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000310/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000310/environment/setup/setup.sh b/tasks/format-code-task-000310/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000310/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000310/tests/test.patch b/tasks/format-code-task-000310/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..02464c8aeb96876c4455ab3a25eb5002a8cd7364 --- /dev/null +++ b/tasks/format-code-task-000310/tests/test.patch @@ -0,0 +1,83 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..4019d1d59 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest tests/link/test_numba.py -k \"test_numba_scalar_input_returns_ndarray or test_numba_scalar_dtype_preserved_float32 or test_numba_scalar_dtype_preserved_int32 or test_numba_multi_output_scalars_return_ndarrays or test_numba_vector_output_unchanged\" -v"] ++} +diff --git a/tests/link/test_numba.py b/tests/link/test_numba.py +index e01bb200a..c84b28a1d 100644 +--- a/tests/link/test_numba.py ++++ b/tests/link/test_numba.py +@@ -3575,3 +3575,56 @@ def test_config_options_cached(): + aesara_numba_fn = function([x], x * 2, mode=numba_mode) + numba_mul_fn = aesara_numba_fn.vm.jit_fn.py_func.__globals__["mul"] + assert isinstance(numba_mul_fn._dispatcher.cache, numba.core.caching.NullCache) ++ ++ ++def test_numba_scalar_input_returns_ndarray(): ++ """Issue reproduction: NUMBA mode should return np.ndarray for scalar outputs (matching c mode behavior).""" ++ x = at.scalar(name="x") ++ f = function([x], 2 * x, mode=numba_mode) ++ result = f(10) ++ assert isinstance(result, np.ndarray) ++ assert result.shape == () ++ np.testing.assert_allclose(result, 20.0) ++ ++ assert not isinstance(result, (float, int)) ++ ++ ++def test_numba_scalar_dtype_preserved_float32(): ++ """The output dtype should match the TensorType dtype, not a default float64.""" ++ x = at.scalar(name="x", dtype="float32") ++ f = function([x], 2 * x, mode=numba_mode) ++ result = f(np.float32(10)) ++ assert isinstance(result, np.ndarray) ++ assert result.dtype == np.dtype("float32") ++ np.testing.assert_allclose(result, np.float32(20.0)) ++ ++ ++def test_numba_scalar_dtype_preserved_int32(): ++ """The output dtype should match the TensorType dtype for integer types.""" ++ x = at.scalar(name="x", dtype="int32") ++ f = function([x], 2 * x, mode=numba_mode) ++ result = f(np.int32(10)) ++ assert isinstance(result, np.ndarray) ++ assert result.dtype == np.dtype("int32") ++ ++ ++def test_numba_multi_output_scalars_return_ndarrays(): ++ """Each output of a multi-output function should be an ndarray.""" ++ x = at.scalar(name="x") ++ y = at.scalar(name="y") ++ f = function([x, y], [2 * x, 3 * y], mode=numba_mode) ++ r1, r2 = f(10, 5) ++ assert isinstance(r1, np.ndarray) ++ assert isinstance(r2, np.ndarray) ++ np.testing.assert_allclose(r1, 20.0) ++ np.testing.assert_allclose(r2, 15.0) ++ ++ ++def test_numba_vector_output_unchanged(): ++ """Preservation: vector outputs were already np.ndarray and should remain so.""" ++ x = at.vector(name="x") ++ f = function([x], 2 * x, mode=numba_mode) ++ result = f(np.array([1.0, 2.0, 3.0])) ++ assert isinstance(result, np.ndarray) ++ assert result.shape == (3,) ++ np.testing.assert_allclose(result, np.array([2.0, 4.0, 6.0])) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m pytest tests/link/test_numba.py -k "test_numba_scalar_input_returns_ndarray or test_numba_scalar_dtype_preserved_float32 or test_numba_scalar_dtype_preserved_int32 or test_numba_multi_output_scalars_return_ndarrays or test_numba_vector_output_unchanged" -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000310/tests/test.sh b/tasks/format-code-task-000310/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..0273f246bb9f2c615985a16f3dc2a02f3a078f45 --- /dev/null +++ b/tasks/format-code-task-000310/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test_commands.json +tests/link/test_numba.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000310/tests/test_command.sh b/tasks/format-code-task-000310/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000310/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000319/environment/Dockerfile b/tasks/format-code-task-000319/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8a45e9535e27a90669579055935c555c1a287a3c --- /dev/null +++ b/tasks/format-code-task-000319/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:622fcabb343b07455c1325fe12a94448ebe348bf85a53c32d230ca256c325c1b diff --git a/tasks/format-code-task-000319/environment/setup/files/blocklist b/tasks/format-code-task-000319/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000319/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000319/environment/setup/setup.sh b/tasks/format-code-task-000319/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000319/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000319/tests/test.patch b/tasks/format-code-task-000319/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..d952763b5547f7928f0e3eca0318a582cc92104d --- /dev/null +++ b/tasks/format-code-task-000319/tests/test.patch @@ -0,0 +1,42 @@ +diff --git a/test/plugin.test.js b/test/plugin.test.js +index 68bf619..df5d691 100644 +--- a/test/plugin.test.js ++++ b/test/plugin.test.js +@@ -51,4 +51,17 @@ describe('Options', () => { + { noWebpClass: 'without-webp', webpClass: 'has-webp' } + ) + }) ++ ++ it('set rename function', () => { ++ run( ++ '.c { background: url(./image.png) }', ++ 'body.no-webp .c { background: url(./image.png) }' + ++ 'body.webp .c { background: url(./image.png.webp) }', ++ { ++ rename: oldName => { ++ return oldName.replace(/\.(jpg|png)/gi, '.$1.webp') ++ } ++ } ++ ) ++ }) + }) +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,4 @@ ++H4sIAAAAAAAAA+3RTQ6CMBCGYdaeohegtErhOAShUYz8hB/j8S24wJioG4gxvs9mJjNNOskn90Nx ++zhNbXQJvLcqJjZmq81ynXput2iml4zD2lNaRGwmz2kUPhq5PWyG8tq77d+8+7X+UnPPvbdcnWV2W ++aZXL7rjcHx/zj8I5f71z+YeRMp5Qy53w2p/nn+ViCn5v803VXMXJ9cL3s/pi2/RgxbgLmvNwKCo5 ++9vLUbb59MwAAAAAAAAAAAAAAAIC7G2DvZnUAKAAA +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000319/tests/test.sh b/tasks/format-code-task-000319/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d9b52072b2e89da010ec1813577d76881be7ce76 --- /dev/null +++ b/tasks/format-code-task-000319/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test/plugin.test.js +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000319/tests/test_command.sh b/tasks/format-code-task-000319/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000319/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000328/environment/Dockerfile b/tasks/format-code-task-000328/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..bafd5ed2a2807d2880c42f3382c23ca63c30e6ca --- /dev/null +++ b/tasks/format-code-task-000328/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:f25580986fccd86508ecc5129f3a4c7b10e7f1098f89d9f9dfb05934804e7873 diff --git a/tasks/format-code-task-000328/environment/setup/files/blocklist b/tasks/format-code-task-000328/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000328/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000328/environment/setup/setup.sh b/tasks/format-code-task-000328/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000328/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000328/tests/test.patch b/tasks/format-code-task-000328/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..0db4590cd5e0a30b7611600182eb614194f7ceaf --- /dev/null +++ b/tasks/format-code-task-000328/tests/test.patch @@ -0,0 +1,141 @@ +diff --git a/airbyte-integrations/connectors/source-zenefits/unit_tests/test_zenefits.py b/airbyte-integrations/connectors/source-zenefits/unit_tests/test_zenefits.py +new file mode 100644 +index 00000000000..9d804b8fdee +--- /dev/null ++++ b/airbyte-integrations/connectors/source-zenefits/unit_tests/test_zenefits.py +@@ -0,0 +1,110 @@ ++ ++ ++ ++ ++import pytest ++import requests_mock ++from airbyte_cdk.models import SyncMode ++from source_zenefits.source import SourceZenefits ++ ++CONFIG = {"token": "TESTTOKEN"} ++ ++EXPECTED_STREAMS = { ++ "people": "core/people", ++ "employments": "core/employments", ++ "departments": "core/departments", ++ "locations": "core/locations", ++ "labor_groups": "core/labor_groups", ++ "labor_group_types": "core/labor_group_types", ++ "custom_fields": "core/custom_fields", ++ "custom_field_values": "core/custom_field_values", ++ "vacation_requests": "time_off/vacation_requests", ++ "vacation_types": "time_off/vacation_types", ++ "time_durations": "time_attendance/time_durations", ++} ++ ++ ++def _streams_by_name(): ++ return {stream.name: stream for stream in SourceZenefits().streams(CONFIG)} ++ ++ ++def test_streams_count(): ++ assert len(SourceZenefits().streams(CONFIG)) == len(EXPECTED_STREAMS) ++ ++ ++def test_stream_names(): ++ assert set(_streams_by_name().keys()) == set(EXPECTED_STREAMS.keys()) ++ ++ ++@pytest.mark.parametrize("name,path", list(EXPECTED_STREAMS.items())) ++def test_stream_path(name, path): ++ stream = _streams_by_name()[name] ++ assert stream.path() == path ++ ++ ++def test_base_url(): ++ for stream in _streams_by_name().values(): ++ assert stream.url_base == "https://api.zenefits.com/" ++ ++ ++def test_records_parsed_from_envelope(): ++ stream = _streams_by_name()["people"] ++ body = {"data": {"data": [{"id": "1"}, {"id": "2"}], "next_url": None}} ++ with requests_mock.Mocker() as m: ++ m.get(requests_mock.ANY, json=body, status_code=200) ++ records = list(stream.read_records(sync_mode=SyncMode.full_refresh)) ++ assert records == [{"id": "1"}, {"id": "2"}] ++ ++ ++def test_authorization_header_is_bearer_token(): ++ stream = _streams_by_name()["people"] ++ body = {"data": {"data": [{"id": "1"}], "next_url": None}} ++ with requests_mock.Mocker() as m: ++ m.get(requests_mock.ANY, json=body, status_code=200) ++ list(stream.read_records(sync_mode=SyncMode.full_refresh)) ++ assert m.call_count == 1 ++ assert m.request_history[0].headers.get("Authorization") == "Bearer TESTTOKEN" ++ ++ ++def test_pagination_follows_next_url(): ++ stream = _streams_by_name()["people"] ++ page1 = { ++ "data": { ++ "data": [{"id": "1"}, {"id": "2"}], ++ "next_url": "https://api.zenefits.com/core/people?starting_after=2", ++ } ++ } ++ page2 = {"data": {"data": [{"id": "3"}], "next_url": None}} ++ with requests_mock.Mocker() as m: ++ m.get(requests_mock.ANY, [{"json": page1, "status_code": 200}, {"json": page2, "status_code": 200}]) ++ records = list(stream.read_records(sync_mode=SyncMode.full_refresh)) ++ assert records == [{"id": "1"}, {"id": "2"}, {"id": "3"}] ++ ++ ++def test_pagination_stops_when_no_next_url(): ++ stream = _streams_by_name()["people"] ++ body = {"data": {"data": [{"id": "1"}], "next_url": None}} ++ with requests_mock.Mocker() as m: ++ m.get(requests_mock.ANY, json=body, status_code=200) ++ list(stream.read_records(sync_mode=SyncMode.full_refresh)) ++ assert m.call_count == 1 ++ ++ ++def test_check_connection_success(): ++ source = SourceZenefits() ++ with requests_mock.Mocker() as m: ++ m.get(requests_mock.ANY, json={"data": {"data": []}}, status_code=200) ++ result = source.check_connection(None, CONFIG) ++ ok, error = result ++ assert ok is True ++ assert not error ++ ++ ++def test_check_connection_failure(): ++ source = SourceZenefits() ++ with requests_mock.Mocker() as m: ++ m.get(requests_mock.ANY, json={"error": "invalid token"}, status_code=401) ++ result = source.check_connection(None, CONFIG) ++ ok, error = result ++ assert ok is False ++ assert error +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,20 @@ ++#!/usr/bin/env bash ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++ ++PY=/testbed/airbyte-integrations/connectors/source-notion/.venv/bin/python ++ ++ ++ ++( cd /testbed/airbyte-integrations/connectors/source-notion && "$PY" -m pytest unit_tests -q ) ++ ++ ++( cd /testbed/airbyte-integrations/connectors/source-zenefits && "$PY" -m pytest unit_tests/test_zenefits.py -q ) diff --git a/tasks/format-code-task-000328/tests/test.sh b/tasks/format-code-task-000328/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..f4222617cd5e2a908870660fbf97c662f8ced119 --- /dev/null +++ b/tasks/format-code-task-000328/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +airbyte-integrations/connectors/source-zenefits/unit_tests/test_zenefits.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000328/tests/test_command.sh b/tasks/format-code-task-000328/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000328/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000402/environment/Dockerfile b/tasks/format-code-task-000402/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e37ad6a6fd277ff082008a6377b19db171b4cd33 --- /dev/null +++ b/tasks/format-code-task-000402/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:e235a0eab722de7b6ad8602f790e067118f97285c9d7870d4d8b78c1bbf7653e diff --git a/tasks/format-code-task-000402/environment/setup/files/blocklist b/tasks/format-code-task-000402/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000402/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000402/environment/setup/setup.sh b/tasks/format-code-task-000402/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000402/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000402/tests/test.patch b/tasks/format-code-task-000402/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..dbb723d3c173285381f17cabce8f82abbe0eeb16 --- /dev/null +++ b/tasks/format-code-task-000402/tests/test.patch @@ -0,0 +1,258 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..56bc423 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python runtests.py tests.test_amazon_ses_backend.AmazonSESBackendBulkTemplateExtrasTests"] ++} +diff --git a/tests/test_amazon_ses_backend.py b/tests/test_amazon_ses_backend.py +index b371e28..68905b4 100644 +--- a/tests/test_amazon_ses_backend.py ++++ b/tests/test_amazon_ses_backend.py +@@ -1052,3 +1052,231 @@ class AmazonSESBackendConfigurationTests(AmazonSESBackendMockAPITestCase): + self.message.send() + params = self.get_send_params() + self.assertEqual(params["ConfigurationSetName"], "CustomConfigurationSet") ++ ++ ++@tag("amazon_ses") ++class AmazonSESBackendBulkTemplateExtrasTests(AmazonSESBackendMockAPITestCase): ++ """Tests for SES SendBulkEmail ReplacementHeaders support of ++ extra_headers, metadata, merge_metadata, and tags with template_id.""" ++ ++ def setUp(self): ++ super().setUp() ++ ++ self.set_mock_response( ++ { ++ "BulkEmailEntryResults": [ ++ {"Status": "SUCCESS", "MessageId": "msg-alice"}, ++ {"Status": "SUCCESS", "MessageId": "msg-bob"}, ++ ], ++ "ResponseMetadata": self.DEFAULT_SEND_RESPONSE["ResponseMetadata"], ++ }, ++ operation_name="send_bulk_email", ++ ) ++ ++ def _make_message(self, **kwargs): ++ kwargs.setdefault("template_id", "welcome_template") ++ kwargs.setdefault("from_email", "from@example.com") ++ kwargs.setdefault("to", ["alice@example.com", "bob@example.com"]) ++ return AnymailMessage(**kwargs) ++ ++ def _get_bulk_entries(self): ++ params = self.get_send_params(operation_name="send_bulk_email") ++ return params["BulkEmailEntries"] ++ ++ def test_extra_headers_with_template(self): ++ """extra_headers should be sent as ReplacementHeaders on every entry""" ++ msg = self._make_message( ++ headers={"X-Custom-Hdr": "value1", "X-Another": "value2"}, ++ ) ++ msg.send() ++ entries = self._get_bulk_entries() ++ self.assertEqual(len(entries), 2) ++ for entry in entries: ++ seen = {h["Name"]: h["Value"] for h in entry["ReplacementHeaders"]} ++ self.assertEqual(seen.get("X-Custom-Hdr"), "value1") ++ self.assertEqual(seen.get("X-Another"), "value2") ++ ++ def test_metadata_with_template(self): ++ """metadata should be sent as a single X-Metadata header per entry""" ++ msg = self._make_message( ++ metadata={"customer_id": 42, "campaign": "spring"}, ++ ) ++ msg.send() ++ entries = self._get_bulk_entries() ++ self.assertEqual(len(entries), 2) ++ for entry in entries: ++ metas = [ ++ h for h in entry["ReplacementHeaders"] if h["Name"] == "X-Metadata" ++ ] ++ self.assertEqual(len(metas), 1) ++ self.assertJSONEqual( ++ metas[0]["Value"], {"customer_id": 42, "campaign": "spring"} ++ ) ++ ++ def test_tags_with_template(self): ++ """tags should be sent as multiple X-Tag headers on every entry""" ++ msg = self._make_message(tags=["Welcome", "Spring2024"]) ++ msg.send() ++ entries = self._get_bulk_entries() ++ self.assertEqual(len(entries), 2) ++ for entry in entries: ++ tag_values = [ ++ h["Value"] for h in entry["ReplacementHeaders"] if h["Name"] == "X-Tag" ++ ] ++ self.assertCountEqual(tag_values, ["Welcome", "Spring2024"]) ++ ++ def test_merge_metadata_only_with_template(self): ++ """merge_metadata alone should produce per-recipient X-Metadata headers""" ++ msg = self._make_message( ++ merge_metadata={ ++ "alice@example.com": {"user_id": "alice-id"}, ++ "bob@example.com": {"user_id": "bob-id"}, ++ }, ++ ) ++ msg.send() ++ entries = self._get_bulk_entries() ++ alice_metas = [ ++ h for h in entries[0]["ReplacementHeaders"] if h["Name"] == "X-Metadata" ++ ] ++ bob_metas = [ ++ h for h in entries[1]["ReplacementHeaders"] if h["Name"] == "X-Metadata" ++ ] ++ self.assertEqual(len(alice_metas), 1) ++ self.assertEqual(len(bob_metas), 1) ++ self.assertJSONEqual(alice_metas[0]["Value"], {"user_id": "alice-id"}) ++ self.assertJSONEqual(bob_metas[0]["Value"], {"user_id": "bob-id"}) ++ ++ def test_metadata_and_merge_metadata_combined(self): ++ """metadata + merge_metadata: per-recipient values override global ++ keys; global-only keys remain. Must result in a single merged ++ X-Metadata header per recipient. ++ """ ++ msg = self._make_message( ++ metadata={"global_key": "global_val", "shared_key": "global_shared"}, ++ merge_metadata={ ++ "alice@example.com": { ++ "shared_key": "alice_shared", ++ "alice_only": "yes", ++ }, ++ ++ }, ++ ) ++ msg.send() ++ entries = self._get_bulk_entries() ++ alice_metas = [ ++ h for h in entries[0]["ReplacementHeaders"] if h["Name"] == "X-Metadata" ++ ] ++ bob_metas = [ ++ h for h in entries[1]["ReplacementHeaders"] if h["Name"] == "X-Metadata" ++ ] ++ self.assertEqual( ++ len(alice_metas), 1, "Expected a single merged X-Metadata for alice" ++ ) ++ self.assertEqual( ++ len(bob_metas), 1, "Expected a single X-Metadata for bob" ++ ) ++ self.assertJSONEqual( ++ alice_metas[0]["Value"], ++ { ++ "global_key": "global_val", ++ "shared_key": "alice_shared", ++ "alice_only": "yes", ++ }, ++ ) ++ self.assertJSONEqual( ++ bob_metas[0]["Value"], ++ {"global_key": "global_val", "shared_key": "global_shared"}, ++ ) ++ ++ def test_extra_headers_overridden_by_merge_headers(self): ++ """When extra_headers and merge_headers share a key (case-insensitive), ++ merge_headers wins for that recipient; non-overlapping global headers ++ still propagate; non-overridden recipient keeps the global value. ++ """ ++ msg = self._make_message( ++ headers={"X-Common": "global_val", "X-Other": "global_other"}, ++ merge_headers={ ++ "alice@example.com": {"x-common": "alice_val"}, ++ }, ++ ) ++ msg.send() ++ entries = self._get_bulk_entries() ++ alice_headers = entries[0]["ReplacementHeaders"] ++ bob_headers = entries[1]["ReplacementHeaders"] ++ ++ ++ alice_common = [ ++ h for h in alice_headers if h["Name"].lower() == "x-common" ++ ] ++ self.assertEqual(len(alice_common), 1, alice_headers) ++ self.assertEqual(alice_common[0]["Value"], "alice_val") ++ ++ alice_other = [ ++ h for h in alice_headers if h["Name"].lower() == "x-other" ++ ] ++ self.assertEqual(len(alice_other), 1) ++ self.assertEqual(alice_other[0]["Value"], "global_other") ++ ++ ++ bob_common = [h for h in bob_headers if h["Name"].lower() == "x-common"] ++ self.assertEqual(len(bob_common), 1, bob_headers) ++ self.assertEqual(bob_common[0]["Value"], "global_val") ++ ++ def test_tags_with_template_no_default_email_tags(self): ++ """Without AMAZON_SES_MESSAGE_TAG_NAME, tags do NOT produce DefaultEmailTags""" ++ msg = self._make_message(tags=["a", "b"]) ++ msg.send() ++ params = self.get_send_params(operation_name="send_bulk_email") ++ self.assertNotIn("DefaultEmailTags", params) ++ ++ @override_settings(ANYMAIL_AMAZON_SES_MESSAGE_TAG_NAME="Campaign") ++ def test_single_tag_with_message_tag_name_setting(self): ++ """A single tag + MESSAGE_TAG_NAME still produces DefaultEmailTags""" ++ msg = self._make_message(tags=["VariantA"]) ++ msg.send() ++ params = self.get_send_params(operation_name="send_bulk_email") ++ self.assertEqual( ++ params["DefaultEmailTags"], ++ [{"Name": "Campaign", "Value": "VariantA"}], ++ ) ++ ++ @override_settings(ANYMAIL_AMAZON_SES_MESSAGE_TAG_NAME="Campaign") ++ def test_multiple_tags_with_message_tag_name_setting_unsupported(self): ++ """Multiple tags + MESSAGE_TAG_NAME still raises AnymailUnsupportedFeature""" ++ msg = self._make_message(tags=["A", "B"]) ++ with self.assertRaisesMessage( ++ AnymailUnsupportedFeature, ++ "multiple tags with the AMAZON_SES_MESSAGE_TAG_NAME setting", ++ ): ++ msg.send() ++ ++ def test_no_replacement_headers_when_no_features_used(self): ++ """Plain template send without these features must not add ReplacementHeaders""" ++ msg = self._make_message() ++ msg.send() ++ entries = self._get_bulk_entries() ++ self.assertEqual(len(entries), 2) ++ for entry in entries: ++ self.assertNotIn("ReplacementHeaders", entry) ++ ++ def test_extra_headers_metadata_and_tags_combined(self): ++ """extra_headers, metadata, and tags all set together — every entry ++ should contain each, with exactly one X-Metadata.""" ++ msg = self._make_message( ++ headers={"X-Foo": "fooval"}, ++ metadata={"meta_key": "meta_val"}, ++ tags=["TagA"], ++ ) ++ msg.send() ++ entries = self._get_bulk_entries() ++ self.assertEqual(len(entries), 2) ++ for entry in entries: ++ headers = entry["ReplacementHeaders"] ++ other_pairs = { ++ (h["Name"], h["Value"]) for h in headers if h["Name"] != "X-Metadata" ++ } ++ self.assertIn(("X-Foo", "fooval"), other_pairs) ++ self.assertIn(("X-Tag", "TagA"), other_pairs) ++ metas = [h for h in headers if h["Name"] == "X-Metadata"] ++ self.assertEqual(len(metas), 1) ++ self.assertJSONEqual(metas[0]["Value"], {"meta_key": "meta_val"}) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python runtests.py tests.test_amazon_ses_backend.AmazonSESBackendBulkTemplateExtrasTests ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000402/tests/test.sh b/tasks/format-code-task-000402/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..b050f19e20d3444342c702ef504e4658965ad644 --- /dev/null +++ b/tasks/format-code-task-000402/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test_commands.json +tests/test_amazon_ses_backend.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000402/tests/test_command.sh b/tasks/format-code-task-000402/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000402/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000405/environment/Dockerfile b/tasks/format-code-task-000405/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b8762503bdcfa0a465cab54930378b9c89a27f70 --- /dev/null +++ b/tasks/format-code-task-000405/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:c96b9342eaac24a1a9a843209cf1d08ebd5562b85364eb64bbab17c5fc9ef2a1 diff --git a/tasks/format-code-task-000405/environment/setup/files/blocklist b/tasks/format-code-task-000405/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000405/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000405/environment/setup/setup.sh b/tasks/format-code-task-000405/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000405/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000405/tests/test.patch b/tasks/format-code-task-000405/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..5105c6e828e804409357d9034d961b75a7e35e1b --- /dev/null +++ b/tasks/format-code-task-000405/tests/test.patch @@ -0,0 +1,176 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000000..f4b6f55bbe +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest tests/models/test_taskinstance.py -k 'test_get_rendered_template_fields_pending_task_masks_sensitive_variable or test_get_rendered_template_fields_pending_task_does_not_mask_nonsensitive_variable or test_get_rendered_template_fields_restores_mask_secrets_in_logs or test_get_rendered_template_fields '"] ++} +diff --git a/tests/models/test_taskinstance.py b/tests/models/test_taskinstance.py +index e53b52e11b..6d30f2f14b 100644 +--- a/tests/models/test_taskinstance.py ++++ b/tests/models/test_taskinstance.py +@@ -2090,6 +2090,149 @@ class TestTaskInstance: + with create_session() as session: + session.query(RenderedTaskInstanceFields).delete() + ++ @provide_session ++ def test_get_rendered_template_fields_pending_task_masks_sensitive_variable( ++ self, dag_maker, session=None ++ ): ++ """ ++ Pending task (no RTIF row) referencing a sensitive Variable should have ++ the rendered field masked when displayed by the webserver. ++ ++ Regression test for https://github.com/apache/airflow/issues/22909. ++ """ ++ from airflow.utils.log.secrets_masker import _secrets_masker ++ ++ ++ ++ secret_value = "supersecretvalueonlyfortest_pending_mask" ++ Variable.set("var_with_secret_for_pending_test", secret_value) ++ ++ ++ masker = _secrets_masker() ++ original_patterns = set(masker.patterns) ++ original_replacer = masker.replacer ++ masker.patterns = set() ++ masker.replacer = None ++ ++ original_mask_setting = settings.MASK_SECRETS_IN_LOGS ++ try: ++ with dag_maker('test-dag-pending-mask', session=session) as dag: ++ task = BashOperator( ++ task_id='task_with_secret', ++ bash_command="echo {{ var.value.var_with_secret_for_pending_test }}", ++ ) ++ dag.fileloc = TEST_DAGS_FOLDER / 'test_get_k8s_pod_yaml.py' ++ ti = dag_maker.create_dagrun().task_instances[0] ++ ti.task = task ++ ++ ++ settings.MASK_SECRETS_IN_LOGS = False ++ ti.get_rendered_template_fields(session=session) ++ ++ assert secret_value not in ti.task.bash_command, ( ++ f"Sensitive variable value should be masked in rendered fields for pending task. " ++ f"Got bash_command={ti.task.bash_command!r}" ++ ) ++ assert "***" in ti.task.bash_command ++ finally: ++ settings.MASK_SECRETS_IN_LOGS = original_mask_setting ++ masker.patterns = original_patterns ++ masker.replacer = original_replacer ++ Variable.delete("var_with_secret_for_pending_test") ++ with create_session() as cleanup_session: ++ cleanup_session.query(RenderedTaskInstanceFields).delete() ++ ++ @provide_session ++ def test_get_rendered_template_fields_pending_task_does_not_mask_nonsensitive_variable( ++ self, dag_maker, session=None ++ ): ++ """ ++ Pending task referencing a NON-sensitive Variable should keep the ++ rendered value intact (no over-masking). ++ """ ++ from airflow.utils.log.secrets_masker import _secrets_masker ++ ++ plain_value = "this_is_a_plain_nonsensitive_value_xyz" ++ ++ Variable.set("plain_var_for_pending_test", plain_value) ++ ++ masker = _secrets_masker() ++ original_patterns = set(masker.patterns) ++ original_replacer = masker.replacer ++ masker.patterns = set() ++ masker.replacer = None ++ ++ original_mask_setting = settings.MASK_SECRETS_IN_LOGS ++ try: ++ with dag_maker('test-dag-pending-plain', session=session) as dag: ++ task = BashOperator( ++ task_id='task_with_plain_var', ++ bash_command="echo {{ var.value.plain_var_for_pending_test }}", ++ ) ++ dag.fileloc = TEST_DAGS_FOLDER / 'test_get_k8s_pod_yaml.py' ++ ti = dag_maker.create_dagrun().task_instances[0] ++ ti.task = task ++ ++ settings.MASK_SECRETS_IN_LOGS = False ++ ti.get_rendered_template_fields(session=session) ++ ++ assert plain_value in ti.task.bash_command, ( ++ f"Non-sensitive variable value should not be masked. " ++ f"Got bash_command={ti.task.bash_command!r}" ++ ) ++ finally: ++ settings.MASK_SECRETS_IN_LOGS = original_mask_setting ++ masker.patterns = original_patterns ++ masker.replacer = original_replacer ++ Variable.delete("plain_var_for_pending_test") ++ with create_session() as cleanup_session: ++ cleanup_session.query(RenderedTaskInstanceFields).delete() ++ ++ @provide_session ++ def test_get_rendered_template_fields_restores_mask_secrets_in_logs( ++ self, dag_maker, session=None ++ ): ++ """ ++ get_rendered_template_fields must NOT permanently flip ++ settings.MASK_SECRETS_IN_LOGS — it has to restore the original value ++ even if the original was False (webserver default). ++ """ ++ from airflow.utils.log.secrets_masker import _secrets_masker ++ ++ Variable.set("restore_flag_test_secret_var", "tmpvalue_for_restore_test") ++ ++ masker = _secrets_masker() ++ original_patterns = set(masker.patterns) ++ original_replacer = masker.replacer ++ masker.patterns = set() ++ masker.replacer = None ++ ++ original_mask_setting = settings.MASK_SECRETS_IN_LOGS ++ try: ++ with dag_maker('test-dag-mask-restore', session=session) as dag: ++ task = BashOperator( ++ task_id='restore_task', ++ bash_command="echo {{ var.value.restore_flag_test_secret_var }}", ++ ) ++ dag.fileloc = TEST_DAGS_FOLDER / 'test_get_k8s_pod_yaml.py' ++ ti = dag_maker.create_dagrun().task_instances[0] ++ ti.task = task ++ ++ settings.MASK_SECRETS_IN_LOGS = False ++ ti.get_rendered_template_fields(session=session) ++ ++ assert settings.MASK_SECRETS_IN_LOGS is False, ( ++ "get_rendered_template_fields must restore MASK_SECRETS_IN_LOGS " ++ "to its previous value after running." ++ ) ++ finally: ++ settings.MASK_SECRETS_IN_LOGS = original_mask_setting ++ masker.patterns = original_patterns ++ masker.replacer = original_replacer ++ Variable.delete("restore_flag_test_secret_var") ++ with create_session() as cleanup_session: ++ cleanup_session.query(RenderedTaskInstanceFields).delete() ++ + @mock.patch.dict(os.environ, {"AIRFLOW_IS_K8S_EXECUTOR_POD": "True"}) + @mock.patch("airflow.settings.pod_mutation_hook") + def test_render_k8s_pod_yaml(self, pod_mutation_hook, create_task_instance): +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m pytest tests/models/test_taskinstance.py -k 'test_get_rendered_template_fields_pending_task_masks_sensitive_variable or test_get_rendered_template_fields_pending_task_does_not_mask_nonsensitive_variable or test_get_rendered_template_fields_restores_mask_secrets_in_logs or test_get_rendered_template_fields ' ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000405/tests/test.sh b/tasks/format-code-task-000405/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9d77403b3be5d5ee90d04525d808fa65a295ce7 --- /dev/null +++ b/tasks/format-code-task-000405/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test_commands.json +tests/models/test_taskinstance.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000405/tests/test_command.sh b/tasks/format-code-task-000405/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000405/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000433/environment/Dockerfile b/tasks/format-code-task-000433/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8755d4e17ca63bb98b264c42aed3fe6c9853c1cb --- /dev/null +++ b/tasks/format-code-task-000433/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:32392d60c76b33974fa5fff815eb657ec130ca2757938a86226225617484f153 diff --git a/tasks/format-code-task-000433/environment/setup/files/blocklist b/tasks/format-code-task-000433/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000433/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000433/environment/setup/setup.sh b/tasks/format-code-task-000433/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000433/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000433/tests/test.patch b/tasks/format-code-task-000433/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..4e9b174dbbe04afcc6f3d259981f61c46b765073 --- /dev/null +++ b/tasks/format-code-task-000433/tests/test.patch @@ -0,0 +1,56 @@ +diff --git a/pkg/controller/component/component_definition_convertor_test.go b/pkg/controller/component/component_definition_convertor_test.go +index 253dacfebe3..eb6313adfc0 100644 +--- a/pkg/controller/component/component_definition_convertor_test.go ++++ b/pkg/controller/component/component_definition_convertor_test.go +@@ -22,6 +22,7 @@ package component + import ( + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" ++ + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/util/intstr" + +@@ -447,6 +448,20 @@ var _ = Describe("Component Definition Convertor", func() { + Expect(services[1].Spec.Type).Should(Equal(corev1.ServiceTypeClusterIP)) + Expect(services[1].Spec.ClusterIP).Should(Equal(corev1.ClusterIPNone)) + Expect(services[1].RoleSelector).Should(BeEquivalentTo(constant.Leader)) ++ ++ ++ clusterCompDef.WorkloadType = appsv1alpha1.Consensus ++ clusterCompDef.ConsensusSpec = &appsv1alpha1.ConsensusSetSpec{ ++ Leader: appsv1alpha1.ConsensusMember{ ++ Name: constant.Primary, ++ AccessMode: appsv1alpha1.ReadWrite, ++ }, ++ } ++ res2, _ := convertor.convert(clusterCompDef, clusterName) ++ services2, ok2 := res2.([]appsv1alpha1.Service) ++ Expect(ok2).Should(BeTrue()) ++ Expect(services2).Should(HaveLen(2)) ++ Expect(services2[0].RoleSelector).Should(BeEquivalentTo(constant.Primary)) + }) + }) + +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,7 @@ ++H4sIAAAAAAAAA+3Su07DMBQG4Mx9iqPuiZOmaVk6FOiAYEC0zFWauMFK4lP5UvXxSSNuQgIGqBDi ++/xZb8bGPld/RxqumXEu9F8GpxJ1plvVj5/3Yz5NslCTZZDqO0yBOkkmcBZSd7EZveOtyQxQYZvdZ ++3Vfrf1T0mr+T1q0Lbttcl5F9+LkeX+WfTtOX/NNjXTKepKOA4p+7wsf+ef5FSX3wG1kO5GHHxtH1 ++/fni/P7q5nJxt54vl4vVcia8NaLhIm9E7TeyfzPSiI3Soj6zIolGZ1EaNkr7Q5i35WQ8qJgqqaXJ ++naRI7Oqq7+KdavodLRe1Fceq42cK9xQW7LWbJRQ61Ur2jtI4tk97C9bOcNN0PbsHumMttRMUGq9p ++uOoOmN9e2SGFldJ1xdGWC29pePFcSZdyq7RyijVdsN5L49gMB7/96wEAAAAAAAAAAAAAAAAAAAAA ++vu0RSXsV5AAoAAA= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000433/tests/test.sh b/tasks/format-code-task-000433/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..ef08db83497f6b2c81eafb21b5f8b28f7cc0fe5b --- /dev/null +++ b/tasks/format-code-task-000433/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +pkg/controller/component/component_definition_convertor_test.go +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000433/tests/test_command.sh b/tasks/format-code-task-000433/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000433/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000434/environment/Dockerfile b/tasks/format-code-task-000434/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..37a9a2897512e506e0c288f783f4aba6405b3d8e --- /dev/null +++ b/tasks/format-code-task-000434/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:7c64b722773830308ac7e54d4db3cfad1d7c4a245e95a46840841011975f1a6f diff --git a/tasks/format-code-task-000434/environment/setup/files/blocklist b/tasks/format-code-task-000434/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000434/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000434/environment/setup/setup.sh b/tasks/format-code-task-000434/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000434/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000434/tests/test.patch b/tasks/format-code-task-000434/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..9c9d1ae545de1713e8690b504c14774e5ead6a7f --- /dev/null +++ b/tasks/format-code-task-000434/tests/test.patch @@ -0,0 +1,79 @@ +diff --git a/test/unit/init/applyAnswers-test.js b/test/unit/init/applyAnswers-test.js +index 4fc70a9b..013330c1 100644 +--- a/test/unit/init/applyAnswers-test.js ++++ b/test/unit/init/applyAnswers-test.js +@@ -1,5 +1,6 @@ + const { assert } = require('chai'); + const sinon = require('sinon'); ++const yaml = require('js-yaml'); + + const { _applyAnswers: applyAnswers } = require('../../../lib/init'); + +@@ -38,6 +39,45 @@ describe('init._applyAnswers()', () => { + const config = applyAnswers(createConfig(), { language: 'python' }); + assert.equal(config.language, 'python'); + }); ++ it('produces YAML loadable by dredd when language is not provided', () => { ++ const config = applyAnswers(createConfig(), { ++ apiDescription: 'apiary.apib', ++ apiHost: 'http://127.0.0.1:5000', ++ server: 'npm start', ++ }); ++ const dumped = yaml.dump(config); ++ assert.notInclude(dumped, 'tag:yaml.org,2002:js/undefined'); ++ assert.doesNotThrow(() => yaml.safeLoad(dumped)); ++ }); ++ it('produces YAML loadable by dredd when language is explicitly undefined', () => { ++ const config = applyAnswers(createConfig(), { ++ apiDescription: 'apiary.apib', ++ apiHost: 'http://127.0.0.1:5000', ++ server: 'npm start', ++ language: undefined, ++ }); ++ const dumped = yaml.dump(config); ++ assert.notInclude(dumped, 'tag:yaml.org,2002:js/undefined'); ++ assert.doesNotThrow(() => yaml.safeLoad(dumped)); ++ }); ++ it('preserves an explicitly provided ruby language', () => { ++ const config = applyAnswers(createConfig(), { language: 'ruby' }); ++ assert.equal(config.language, 'ruby'); ++ }); ++ it('preserves an explicitly provided nodejs language', () => { ++ const config = applyAnswers(createConfig(), { language: 'nodejs' }); ++ assert.equal(config.language, 'nodejs'); ++ }); ++ it('produces YAML free of the js/undefined tag when language is omitted', () => { ++ const config = applyAnswers(createConfig(), { ++ apiDescription: 'apiary.apib', ++ apiHost: 'http://127.0.0.1:5000', ++ server: 'npm start', ++ }); ++ const dumped = yaml.dump(config); ++ assert.notInclude(dumped, 'tag:yaml.org,2002:js/undefined'); ++ assert.doesNotThrow(() => yaml.safeLoad(dumped)); ++ }); + it('sets no reporter by default', () => { + const config = applyAnswers(createConfig(), {}); + assert.isUndefined(config.reporter); +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..eb4e42b4 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["npx mocha test/unit/init/applyAnswers-test.js"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++npx mocha test/unit/init/applyAnswers-test.js ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000434/tests/test.sh b/tasks/format-code-task-000434/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..139d0e442ef7dd55691952ac144ca2180a18d8ca --- /dev/null +++ b/tasks/format-code-task-000434/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test/unit/init/applyAnswers-test.js +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000434/tests/test_command.sh b/tasks/format-code-task-000434/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000434/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000458/environment/Dockerfile b/tasks/format-code-task-000458/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..0ee4885de1279bd68c901fe613db623711b8a154 --- /dev/null +++ b/tasks/format-code-task-000458/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:3c89b0f9b2e8f30b40fbec55cb1b717a6969a99731ebff91e6f96fc69500e464 diff --git a/tasks/format-code-task-000458/environment/setup/files/blocklist b/tasks/format-code-task-000458/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000458/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000458/environment/setup/setup.sh b/tasks/format-code-task-000458/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000458/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000458/tests/test.patch b/tasks/format-code-task-000458/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..c2cb6b84d53e4a2c1761ccb90d581e5d722284de --- /dev/null +++ b/tasks/format-code-task-000458/tests/test.patch @@ -0,0 +1,50 @@ +diff --git a/pymatbridge/tests/test_publish.py b/pymatbridge/tests/test_publish.py +index 5c73e0f..cb3f093 100644 +--- a/pymatbridge/tests/test_publish.py ++++ b/pymatbridge/tests/test_publish.py +@@ -36,7 +36,7 @@ def test_lines_to_notebook(): + + nb = publish.lines_to_notebook(lines) + +- npt.assert_equal(nb['worksheets'][0]['cells'][1]['source'][0], ++ npt.assert_equal(nb['cells'][1]['source'][0], + ' This is a first line\n\n') + + +@@ -45,7 +45,7 @@ def test_convert_mfile(): + nb_file = MFILE.replace('.m', '.ipynb') + with open(nb_file) as fid: + nb = json.load(fid) +- npt.assert_equal(nb['worksheets'][0]['cells'][1]['source'][0], ++ npt.assert_equal(nb['cells'][1]['source'][0], + ' Experimenting with conversion from matlab to ipynb\n\n') + os.remove(nb_file) + +@@ -55,5 +55,5 @@ def test_mfile_to_lines(): + + nb = publish.lines_to_notebook(lines) + +- npt.assert_equal(nb['worksheets'][0]['cells'][1]['source'][0], ++ npt.assert_equal(nb['cells'][1]['source'][0], + ' Experimenting with conversion from matlab to ipynb\n\n') +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,5 @@ ++H4sIAAAAAAAAA+3SwU6EMBAGYM48xdz2YpFhYbms3r35BhugKE2grbRg1qe34iZrTHQvu1Hj/12G ++lMnPpENST6qXu1bP19GlpEFZFEsNPtflmYuMs6wss5KjlHmTlhEVF5vog8n5aiSKRmP8d32n3v9R ++yXH/vnV+15hhqLRMXHe+b5zaf5bzcf8czjnfMEeUnm+Er/3z/TeSlsXXrYxj2c7CPSvfdGT3vjN6 ++TeuEOY6tsqR0uKm+JyG0EUrbydPq7n5pu73Jr7bFinT9YMah8qSnwe5Dxsvw9JYU8kPGIVEMh6NQ ++Qm89KvnYLjO491/QTnWvXJeEBDHHP31BAAAAAAAAAAAAAAAAAAAAAAC/2CsgIQvGACgAAA== +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000458/tests/test.sh b/tasks/format-code-task-000458/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..13c1d19f9089cbeea8831e84d9474bd642aeae0d --- /dev/null +++ b/tasks/format-code-task-000458/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +pymatbridge/tests/test_publish.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000458/tests/test_command.sh b/tasks/format-code-task-000458/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000458/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000460/environment/setup/files/blocklist b/tasks/format-code-task-000460/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000460/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000467/environment/Dockerfile b/tasks/format-code-task-000467/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..4599039f942b6b3bc607f4843bb5b83a5d779226 --- /dev/null +++ b/tasks/format-code-task-000467/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:c4a83dfb0b55a9c7f6d3ceb973fb39e22a54120cc8773e11777fc3243f882f06 diff --git a/tasks/format-code-task-000467/environment/setup/files/blocklist b/tasks/format-code-task-000467/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000467/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000467/environment/setup/setup.sh b/tasks/format-code-task-000467/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000467/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000467/tests/test.patch b/tasks/format-code-task-000467/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..bbaf869bd46886f63b2200e1de34081494688d1c --- /dev/null +++ b/tasks/format-code-task-000467/tests/test.patch @@ -0,0 +1,43 @@ +diff --git a/tests/features/percent_format_test.py b/tests/features/percent_format_test.py +index 57ca3c65..0d620ce0 100644 +--- a/tests/features/percent_format_test.py ++++ b/tests/features/percent_format_test.py +@@ -158,6 +158,7 @@ def test_simplify_conversion_flag(s, expected): + '"%4%" % ()', + # no equivalent in format specifier + '"%.2r" % (1.25)', '"%.2a" % (1.25)', ++ pytest.param('"%8s" % (None,)', id='unsafe width-string conversion'), + # non-string mod + 'i % 3', + # dict format but not keyed arguments +@@ -208,8 +209,8 @@ def test_percent_format_noop_if_bug_16806(): + ('"%s" % ("%s" % ("nested",),)', '"{}".format("{}".format("nested"))'), + ('"%s%% percent" % (15,)', '"{}% percent".format(15)'), + ('"%3f" % (15,)', '"{:3f}".format(15)'), +- ('"%-5s" % ("hi",)', '"{:<5}".format("hi")'), +- ('"%9s" % (5,)', '"{:>9}".format(5)'), ++ ('"%-5f" % (5,)', '"{:<5f}".format(5)'), ++ ('"%9f" % (5,)', '"{:9f}".format(5)'), + ('"brace {} %s" % (1,)', '"brace {{}} {}".format(1)'), + ( + '"%s" % (\n' +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,4 @@ ++H4sIAAAAAAAAA+3R0QqCMBQG4F33FOfOK3Wzpo8j0y0M0sk2Bd++6U0RVDdFRP93sR04B3bGnzXT ++6axrM8w5+xQeVVJud3R/b7WQBd/zopJlnBOi5CUj+bGNbkw+KEfEnLXh2dyr/o/KrvkH40Pd2r5X ++g8589743XuUvCnHNn1cx/0MpOCP+vhUe+/P8W01b8I3Ru0b5jtJzS8m4hM4OlPYUq9il9fD50agw ++OePz0bjWDKE+WterUK/dbFwonZPdtz8EAAAAAAAAAAAAAAAAAAAAAPBHLmrksBIAKAAA +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000467/tests/test.sh b/tasks/format-code-task-000467/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..aac175defe53391273df691ee92c8130a44abc59 --- /dev/null +++ b/tasks/format-code-task-000467/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/features/percent_format_test.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000467/tests/test_command.sh b/tasks/format-code-task-000467/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000467/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000493/environment/Dockerfile b/tasks/format-code-task-000493/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b78f2321f7799a61a6312264691f48931e4fd3e6 --- /dev/null +++ b/tasks/format-code-task-000493/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:492084ac5c2e5a6607f941f33ea6173a7fa20681e6a3cf6c270fd9b3a3f7620f diff --git a/tasks/format-code-task-000493/environment/setup/files/blocklist b/tasks/format-code-task-000493/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000493/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000493/environment/setup/setup.sh b/tasks/format-code-task-000493/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000493/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000493/tests/test.patch b/tasks/format-code-task-000493/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..81eb0893d6fa0daa09bd28f3318d33ccdf12c9e9 --- /dev/null +++ b/tasks/format-code-task-000493/tests/test.patch @@ -0,0 +1,52 @@ +diff --git a/spec/test-data/handlers/textile-empty-page.textile b/spec/test-data/handlers/textile-empty-page.textile +new file mode 100644 +index 00000000..e69de29b +diff --git a/spec/textile_handler_spec.rb b/spec/textile_handler_spec.rb +index e0acf77b..67c7447a 100644 +--- a/spec/textile_handler_spec.rb ++++ b/spec/textile_handler_spec.rb +@@ -8,6 +8,10 @@ + output.should == "

Test

\n

the WHO

" + } + ++verify_empty = lambda { |output| ++ output.should == "" ++} ++ + theories = + [ + { +@@ -24,6 +28,13 @@ + :extension => '.html', + :matcher => verify_with_span, + :site_overrides => { :textile => { :no_span_caps => false } } ++ }, ++ { ++ :page => "textile-empty-page.textile", ++ :simple_name => "textile-empty-page", ++ :syntax => :textile, ++ :extension => '.html', ++ :matcher => verify_empty + } + ] + +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,4 @@ ++H4sIAAAAAAAAA+3STQ6CMBCGYdaeYi4gUgQ8g2sPQCw0kYQfU4rR21vYaEyUjcYY32fRmbRN2uZr ++qIeqLnPTnlbBp0TeJk2n6j3WqVdprFSWqDhTQeQ7PyXpx250Z+jd3ooEtuvcq31z6z8qvOXvTO/y ++omuafVuG/eF9Z8zlr6Lslv868fknmVKBRO+7wnN/nn9RyhS8NuXCDvoiy63UlR5LfzSFLHdip2Yc ++/M6zq2qTH/wXqY3Nx8nQ6sW3XwEAAAAAAAAAAAAAAAD8pyujllx/ACgAAA== +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000493/tests/test.sh b/tasks/format-code-task-000493/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..3465b5c9eecef46eac4168a7aa45c657a71242a3 --- /dev/null +++ b/tasks/format-code-task-000493/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +spec/test-data/handlers/textile-empty-page.textile +spec/textile_handler_spec.rb +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000493/tests/test_command.sh b/tasks/format-code-task-000493/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000493/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000494/environment/Dockerfile b/tasks/format-code-task-000494/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..1c8ecb92e6f7aba1435c42e89604f942b252b9dc --- /dev/null +++ b/tasks/format-code-task-000494/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:47c9843d0bc8b84dc042aa8f9bb74c4e0e8dd8e740dcee81909ea3b4ab0ee7d4 diff --git a/tasks/format-code-task-000494/environment/setup/files/blocklist b/tasks/format-code-task-000494/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000494/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000494/environment/setup/setup.sh b/tasks/format-code-task-000494/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000494/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000494/tests/test.patch b/tasks/format-code-task-000494/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..c688611b19e158a28e51d5d76ef49b7640bec7c0 --- /dev/null +++ b/tasks/format-code-task-000494/tests/test.patch @@ -0,0 +1,155 @@ +diff --git a/test/fixtures/results/integration/aws-ec2-subnet.json b/test/fixtures/results/integration/aws-ec2-subnet.json +new file mode 100644 +index 0000000000..616b6f34a2 +--- /dev/null ++++ b/test/fixtures/results/integration/aws-ec2-subnet.json +@@ -0,0 +1,86 @@ ++[ ++ { ++ "Filename": "test/fixtures/templates/integration/aws-ec2-subnet.yaml", ++ "Id": "5c96f1f9-9dfc-31e7-f24b-9e08af46c98f", ++ "Level": "Error", ++ "Location": { ++ "End": { ++ "ColumnNumber": 15, ++ "LineNumber": 7 ++ }, ++ "Path": [ ++ "Resources", ++ "Subnet1", ++ "Properties" ++ ], ++ "Start": { ++ "ColumnNumber": 5, ++ "LineNumber": 7 ++ } ++ }, ++ "Message": "'Ipv4IpamPoolId' is a dependency of 'Ipv4NetmaskLength'", ++ "ParentId": null, ++ "Rule": { ++ "Description": "When certain properties are specified it results in other properties to be required", ++ "Id": "E3021", ++ "ShortDescription": "Validate that when a property is specified that other properties should be included", ++ "Source": "https://github.com/aws-cloudformation/cfn-lint/blob/main/docs/cfn-schema-specification.md#dependentrequired" ++ } ++ }, ++ { ++ "Filename": "test/fixtures/templates/integration/aws-ec2-subnet.yaml", ++ "Id": "5c12a390-4b88-f609-d6d6-bd7fa2250f99", ++ "Level": "Error", ++ "Location": { ++ "End": { ++ "ColumnNumber": 15, ++ "LineNumber": 13 ++ }, ++ "Path": [ ++ "Resources", ++ "Subnet2", ++ "Properties" ++ ], ++ "Start": { ++ "ColumnNumber": 5, ++ "LineNumber": 13 ++ } ++ }, ++ "Message": "Only one of ['CidrBlock', 'Ipv4IpamPoolId'] is a required property", ++ "ParentId": null, ++ "Rule": { ++ "Description": "Make sure that Resources properties that are required exist. Along with other properties not being specified", ++ "Id": "E3014", ++ "ShortDescription": "Validate only one of a set of required properties are specified", ++ "Source": "https://github.com/aws-cloudformation/cfn-lint/blob/main/docs/cfn-schema-specification.md#requiredxor" ++ } ++ }, ++ { ++ "Filename": "test/fixtures/templates/integration/aws-ec2-subnet.yaml", ++ "Id": "7a696880-e120-60b6-93b9-a57a48d71189", ++ "Level": "Error", ++ "Location": { ++ "End": { ++ "ColumnNumber": 15, ++ "LineNumber": 17 ++ }, ++ "Path": [ ++ "Resources", ++ "Subnet3", ++ "Properties" ++ ], ++ "Start": { ++ "ColumnNumber": 5, ++ "LineNumber": 17 ++ } ++ }, ++ "Message": "'Ipv4NetmaskLength' is a dependency of 'Ipv4IpamPoolId'", ++ "ParentId": null, ++ "Rule": { ++ "Description": "When certain properties are specified it results in other properties to be required", ++ "Id": "E3021", ++ "ShortDescription": "Validate that when a property is specified that other properties should be included", ++ "Source": "https://github.com/aws-cloudformation/cfn-lint/blob/main/docs/cfn-schema-specification.md#dependentrequired" ++ } ++ } ++] +diff --git a/test/fixtures/templates/integration/aws-ec2-subnet.yaml b/test/fixtures/templates/integration/aws-ec2-subnet.yaml +new file mode 100644 +index 0000000000..612fd56e64 +--- /dev/null ++++ b/test/fixtures/templates/integration/aws-ec2-subnet.yaml +@@ -0,0 +1,19 @@ ++Parameters: ++ Vpc: ++ Type: AWS::EC2::VPC::Id ++Resources: ++ Subnet1: ++ Type: AWS::EC2::Subnet ++ Properties: ++ VpcId: !Ref Vpc ++ CidrBlock: 10.0.0.0/24 ++ Ipv4NetmaskLength: 10 ++ Subnet2: ++ Type: AWS::EC2::Subnet ++ Properties: ++ VpcId: !Ref Vpc ++ Subnet3: ++ Type: AWS::EC2::Subnet ++ Properties: ++ VpcId: !Ref Vpc ++ Ipv4IpamPoolId: test +diff --git a/test/integration/test_integration_templates.py b/test/integration/test_integration_templates.py +index 761ff40f57..4b92d0d4a1 100644 +--- a/test/integration/test_integration_templates.py ++++ b/test/integration/test_integration_templates.py +@@ -77,6 +77,13 @@ class TestQuickStartTemplates(BaseCliTestCase): + ), + "exit_code": 2, + }, ++ { ++ "filename": ("test/fixtures/templates/integration/aws-ec2-subnet.yaml"), ++ "results_filename": ( ++ "test/fixtures/results/integration/aws-ec2-subnet.json" ++ ), ++ "exit_code": 2, ++ }, + { + "filename": ("test/fixtures/templates/integration/aws-dynamodb-table.yaml"), + "results_filename": ( +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,4 @@ ++H4sIAAAAAAAAA+3SQW/CIBjGcc5+ivfkrbWUMm/7Kk21ZDax0LRo5rcXu4NmyeZFsyz+fwde8kIC ++5CHfHLp9Wzt/XKlnKZK1tXNNvtd5rm2py9Jciiq0tmujxD7tRjcOU2xGETWGEH/bd2/9n8qv+Uc3 ++xXob+r7xbT7tHnfGvfy1ueZfmSrlX70VlZLicVf42Yvnv21lDn7j2sVwirvgjWS9pGlqymVYdT66 ++j7GJXfBff+SmUUfXD/smtfPhJNmnZEcp35d68dfvAgAAAAAAAAAAAAAAAF7BGXkNNEUAKAAA +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000494/tests/test.sh b/tasks/format-code-task-000494/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..1d47bbecc2920a47a483ebe1aecd50fd26c0c91d --- /dev/null +++ b/tasks/format-code-task-000494/tests/test.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test/fixtures/results/integration/aws-ec2-subnet.json +test/fixtures/templates/integration/aws-ec2-subnet.yaml +test/integration/test_integration_templates.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000494/tests/test_command.sh b/tasks/format-code-task-000494/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000494/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000546/environment/Dockerfile b/tasks/format-code-task-000546/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8dc2592848b1666a6634cfa10bd1e0706aae1b7d --- /dev/null +++ b/tasks/format-code-task-000546/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:053e8801ba423ba3fd17e186350a56b50fa4729c0871ba558b89b4ab32368c92 diff --git a/tasks/format-code-task-000546/environment/setup/files/blocklist b/tasks/format-code-task-000546/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000546/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000546/environment/setup/setup.sh b/tasks/format-code-task-000546/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000546/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000546/tests/test.patch b/tasks/format-code-task-000546/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e61e36501b5fb3affb20e7e1dc38f5246ef1e417 --- /dev/null +++ b/tasks/format-code-task-000546/tests/test.patch @@ -0,0 +1,889 @@ +diff --git a/usercase-test-coderl/connector_acceptance_test.go b/usercase-test-coderl/connector_acceptance_test.go +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/connector_acceptance_test.go +@@ -0,0 +1,810 @@ ++package usercase_test_coderl ++ ++import ( ++ "context" ++ "crypto/rand" ++ "crypto/rsa" ++ "crypto/tls" ++ "crypto/x509" ++ "crypto/x509/pkix" ++ "database/sql" ++ "encoding/pem" ++ "errors" ++ "fmt" ++ "math/big" ++ "net" ++ "net/http" ++ "net/http/httptest" ++ "os" ++ "path/filepath" ++ "reflect" ++ "runtime" ++ "strings" ++ "sync" ++ "testing" ++ "time" ++ ++ "github.com/apache/thrift/lib/go/thrift" ++ gohive "github.com/beltran/gohive/v2" ++ "github.com/beltran/gohive/v2/hiveserver" ++) ++ ++ ++ ++ ++ ++ ++const fixturesDir = "/workspace/repo/usercase-test-coderl/fixtures" ++ ++type recordedOpenSession struct { ++ username string ++ password string ++ configuration map[string]string ++} ++ ++type fakeHiveService struct { ++ mu sync.Mutex ++ openSessions []recordedOpenSession ++ statements []string ++ closeOperations int ++} ++ ++func (s *fakeHiveService) OpenSession(ctx context.Context, req *hiveserver.TOpenSessionReq) (*hiveserver.TOpenSessionResp, error) { ++ s.mu.Lock() ++ defer s.mu.Unlock() ++ ++ cfg := map[string]string{} ++ for k, v := range req.GetConfiguration() { ++ cfg[k] = v ++ } ++ s.openSessions = append(s.openSessions, recordedOpenSession{ ++ username: req.GetUsername(), ++ password: req.GetPassword(), ++ configuration: cfg, ++ }) ++ ++ return &hiveserver.TOpenSessionResp{ ++ Status: successStatus(), ++ ServerProtocolVersion: hiveserver.TProtocolVersion_HIVE_CLI_SERVICE_PROTOCOL_V6, ++ SessionHandle: sessionHandle(byte(len(s.openSessions))), ++ }, nil ++} ++ ++func (s *fakeHiveService) ExecuteStatement(ctx context.Context, req *hiveserver.TExecuteStatementReq) (*hiveserver.TExecuteStatementResp, error) { ++ s.mu.Lock() ++ defer s.mu.Unlock() ++ ++ statement := req.GetStatement() ++ s.statements = append(s.statements, statement) ++ hasResultSet := strings.HasPrefix(strings.ToUpper(statement), "SELECT") ++ modified := float64(7) ++ return &hiveserver.TExecuteStatementResp{ ++ Status: successStatus(), ++ OperationHandle: &hiveserver.TOperationHandle{ ++ OperationId: handleIdentifier(90 + byte(len(s.statements))), ++ OperationType: hiveserver.TOperationType_EXECUTE_STATEMENT, ++ HasResultSet: hasResultSet, ++ ModifiedRowCount: &modified, ++ }, ++ }, nil ++} ++ ++func (s *fakeHiveService) CloseOperation(ctx context.Context, req *hiveserver.TCloseOperationReq) (*hiveserver.TCloseOperationResp, error) { ++ s.mu.Lock() ++ defer s.mu.Unlock() ++ s.closeOperations++ ++ return &hiveserver.TCloseOperationResp{Status: successStatus()}, nil ++} ++ ++func (s *fakeHiveService) CloseSession(ctx context.Context, req *hiveserver.TCloseSessionReq) (*hiveserver.TCloseSessionResp, error) { ++ return &hiveserver.TCloseSessionResp{Status: successStatus()}, nil ++} ++ ++func (s *fakeHiveService) GetInfo(context.Context, *hiveserver.TGetInfoReq) (*hiveserver.TGetInfoResp, error) { ++ return nil, errors.New("GetInfo is outside this connector acceptance test") ++} ++func (s *fakeHiveService) GetTypeInfo(context.Context, *hiveserver.TGetTypeInfoReq) (*hiveserver.TGetTypeInfoResp, error) { ++ return nil, errors.New("GetTypeInfo is outside this connector acceptance test") ++} ++func (s *fakeHiveService) GetCatalogs(context.Context, *hiveserver.TGetCatalogsReq) (*hiveserver.TGetCatalogsResp, error) { ++ return nil, errors.New("GetCatalogs is outside this connector acceptance test") ++} ++func (s *fakeHiveService) GetSchemas(context.Context, *hiveserver.TGetSchemasReq) (*hiveserver.TGetSchemasResp, error) { ++ return nil, errors.New("GetSchemas is outside this connector acceptance test") ++} ++func (s *fakeHiveService) GetTables(context.Context, *hiveserver.TGetTablesReq) (*hiveserver.TGetTablesResp, error) { ++ return nil, errors.New("GetTables is outside this connector acceptance test") ++} ++func (s *fakeHiveService) GetTableTypes(context.Context, *hiveserver.TGetTableTypesReq) (*hiveserver.TGetTableTypesResp, error) { ++ return nil, errors.New("GetTableTypes is outside this connector acceptance test") ++} ++func (s *fakeHiveService) GetColumns(context.Context, *hiveserver.TGetColumnsReq) (*hiveserver.TGetColumnsResp, error) { ++ return nil, errors.New("GetColumns is outside this connector acceptance test") ++} ++func (s *fakeHiveService) GetFunctions(context.Context, *hiveserver.TGetFunctionsReq) (*hiveserver.TGetFunctionsResp, error) { ++ return nil, errors.New("GetFunctions is outside this connector acceptance test") ++} ++func (s *fakeHiveService) GetPrimaryKeys(context.Context, *hiveserver.TGetPrimaryKeysReq) (*hiveserver.TGetPrimaryKeysResp, error) { ++ return nil, errors.New("GetPrimaryKeys is outside this connector acceptance test") ++} ++func (s *fakeHiveService) GetCrossReference(context.Context, *hiveserver.TGetCrossReferenceReq) (*hiveserver.TGetCrossReferenceResp, error) { ++ return nil, errors.New("GetCrossReference is outside this connector acceptance test") ++} ++func (s *fakeHiveService) GetOperationStatus(context.Context, *hiveserver.TGetOperationStatusReq) (*hiveserver.TGetOperationStatusResp, error) { ++ return nil, errors.New("GetOperationStatus is outside this connector acceptance test") ++} ++func (s *fakeHiveService) CancelOperation(context.Context, *hiveserver.TCancelOperationReq) (*hiveserver.TCancelOperationResp, error) { ++ return &hiveserver.TCancelOperationResp{Status: successStatus()}, nil ++} ++func (s *fakeHiveService) GetResultSetMetadata(context.Context, *hiveserver.TGetResultSetMetadataReq) (*hiveserver.TGetResultSetMetadataResp, error) { ++ return nil, errors.New("GetResultSetMetadata is outside this connector acceptance test") ++} ++func (s *fakeHiveService) FetchResults(context.Context, *hiveserver.TFetchResultsReq) (*hiveserver.TFetchResultsResp, error) { ++ return nil, errors.New("FetchResults is outside this connector acceptance test") ++} ++func (s *fakeHiveService) GetDelegationToken(context.Context, *hiveserver.TGetDelegationTokenReq) (*hiveserver.TGetDelegationTokenResp, error) { ++ return nil, errors.New("GetDelegationToken is outside this connector acceptance test") ++} ++func (s *fakeHiveService) CancelDelegationToken(context.Context, *hiveserver.TCancelDelegationTokenReq) (*hiveserver.TCancelDelegationTokenResp, error) { ++ return nil, errors.New("CancelDelegationToken is outside this connector acceptance test") ++} ++func (s *fakeHiveService) RenewDelegationToken(context.Context, *hiveserver.TRenewDelegationTokenReq) (*hiveserver.TRenewDelegationTokenResp, error) { ++ return nil, errors.New("RenewDelegationToken is outside this connector acceptance test") ++} ++func (s *fakeHiveService) GetQueryId(context.Context, *hiveserver.TGetQueryIdReq) (*hiveserver.TGetQueryIdResp, error) { ++ return nil, errors.New("GetQueryId is outside this connector acceptance test") ++} ++func (s *fakeHiveService) SetClientInfo(context.Context, *hiveserver.TSetClientInfoReq) (*hiveserver.TSetClientInfoResp, error) { ++ return &hiveserver.TSetClientInfoResp{Status: successStatus()}, nil ++} ++ ++type fakeHiveServer struct { ++ host string ++ port int ++ service *fakeHiveService ++ server *thrift.TSimpleServer ++} ++ ++type fakeHTTPHiveServer struct { ++ host string ++ port int ++ service *fakeHiveService ++ server *httptest.Server ++ mu sync.Mutex ++ paths []string ++} ++ ++func startFakeHiveServer(t *testing.T, serverTLS *tls.Config) *fakeHiveServer { ++ t.Helper() ++ ++ service := &fakeHiveService{} ++ processor := hiveserver.NewTCLIServiceProcessor(service) ++ var serverTransport thrift.TServerTransport ++ var addrProvider interface{ Addr() net.Addr } ++ var closeProvider interface{ Close() error } ++ var err error ++ if serverTLS == nil { ++ socket, socketErr := thrift.NewTServerSocket("127.0.0.1:0") ++ serverTransport, addrProvider, closeProvider, err = socket, socket, socket, socketErr ++ } else { ++ socket, socketErr := thrift.NewTSSLServerSocket("127.0.0.1:0", serverTLS) ++ serverTransport, addrProvider, closeProvider, err = socket, socket, socket, socketErr ++ } ++ if err != nil { ++ t.Fatal(err) ++ } ++ ++ server := thrift.NewTSimpleServer4( ++ processor, ++ serverTransport, ++ thrift.NewTBufferedTransportFactory(4096), ++ thrift.NewTBinaryProtocolFactoryDefault(), ++ ) ++ if err := server.Listen(); err != nil { ++ t.Fatal(err) ++ } ++ ++ tcpAddr := addrProvider.Addr().(*net.TCPAddr) ++ done := make(chan error, 1) ++ go func() { ++ done <- server.AcceptLoop() ++ }() ++ t.Cleanup(func() { ++ _ = closeProvider.Close() ++ if err := server.Stop(); err != nil { ++ t.Fatalf("server stop failed: %v", err) ++ } ++ select { ++ case err := <-done: ++ if err != nil && !strings.Contains(err.Error(), "use of closed network connection") { ++ t.Fatalf("server loop failed: %v", err) ++ } ++ case <-time.After(2 * time.Second): ++ t.Fatal("server loop did not stop") ++ } ++ }) ++ ++ return &fakeHiveServer{ ++ host: "127.0.0.1", ++ port: tcpAddr.Port, ++ service: service, ++ server: server, ++ } ++} ++ ++func startFakeHTTPHiveServer(t *testing.T) *fakeHTTPHiveServer { ++ t.Helper() ++ ++ service := &fakeHiveService{} ++ processor := hiveserver.NewTCLIServiceProcessor(service) ++ thriftHandler := thrift.NewThriftHandlerFunc( ++ processor, ++ thrift.NewTBinaryProtocolFactoryDefault(), ++ thrift.NewTBinaryProtocolFactoryDefault(), ++ ) ++ fake := &fakeHTTPHiveServer{service: service} ++ httpServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ++ fake.mu.Lock() ++ fake.paths = append(fake.paths, r.URL.Path) ++ fake.mu.Unlock() ++ thriftHandler(w, r) ++ })) ++ t.Cleanup(httpServer.Close) ++ ++ host, portText, err := net.SplitHostPort(strings.TrimPrefix(httpServer.URL, "http://")) ++ if err != nil { ++ t.Fatal(err) ++ } ++ var port int ++ if _, err := fmt.Sscanf(portText, "%d", &port); err != nil { ++ t.Fatal(err) ++ } ++ fake.host = host ++ fake.port = port ++ fake.server = httpServer ++ return fake ++} ++ ++func successStatus() *hiveserver.TStatus { ++ return &hiveserver.TStatus{StatusCode: hiveserver.TStatusCode_SUCCESS_STATUS} ++} ++ ++func sessionHandle(seed byte) *hiveserver.TSessionHandle { ++ return &hiveserver.TSessionHandle{SessionId: handleIdentifier(seed)} ++} ++ ++func handleIdentifier(seed byte) *hiveserver.THandleIdentifier { ++ return &hiveserver.THandleIdentifier{ ++ GUID: []byte{seed, seed + 1, seed + 2, seed + 3}, ++ Secret: []byte{seed + 4, seed + 5, seed + 6, seed + 7}, ++ } ++} ++ ++func (s *fakeHiveService) snapshot() (int, []recordedOpenSession, []string, int) { ++ s.mu.Lock() ++ defer s.mu.Unlock() ++ opens := append([]recordedOpenSession(nil), s.openSessions...) ++ statements := append([]string(nil), s.statements...) ++ return len(s.openSessions), opens, statements, s.closeOperations ++} ++ ++func (s *fakeHTTPHiveServer) pathSnapshot() []string { ++ s.mu.Lock() ++ defer s.mu.Unlock() ++ return append([]string(nil), s.paths...) ++} ++ ++func connectorConfig(server *fakeHiveServer) gohive.Config { ++ return gohive.Config{ ++ Host: server.host, ++ Port: server.port, ++ Auth: "NOSASL", ++ Username: "alice", ++ Password: "secret", ++ HiveConfiguration: map[string]string{ ++ "hive.server2.thrift.sasl.qop": "auth-conf", ++ "spark.sql.shuffle.partitions": "9", ++ }, ++ } ++} ++ ++func httpConnectorConfig(server *fakeHTTPHiveServer) gohive.Config { ++ return gohive.Config{ ++ Host: server.host, ++ Port: server.port, ++ Auth: "NONE", ++ Username: "http-user", ++ Password: "http-pass", ++ TransportMode: "http", ++ } ++} ++ ++func TestConfigStructExposesRequestedFields(t *testing.T) { ++ ++ ++ cfgType := reflect.TypeOf(gohive.Config{}) ++ wantFields := map[string]string{ ++ "Host": "string", ++ "Port": "int", ++ "Auth": "string", ++ "Username": "string", ++ "Password": "string", ++ "Database": "string", ++ "TransportMode": "string", ++ "HTTPPath": "string", ++ "Service": "string", ++ "TLSConfig": "*tls.Config", ++ "SSLCertFile": "string", ++ "SSLKeyFile": "string", ++ "SSLCAFile": "string", ++ "SSLInsecureSkip": "bool", ++ "HiveConfiguration": "map[string]string", ++ } ++ ++ if cfgType.NumField() < len(wantFields) { ++ t.Fatalf("Config field count = %d, want at least %d", cfgType.NumField(), len(wantFields)) ++ } ++ for name, wantType := range wantFields { ++ field, ok := cfgType.FieldByName(name) ++ if ok != true { ++ t.Fatalf("Config has field %q = %t, want %t", name, ok, true) ++ } ++ if field.Type.String() != wantType { ++ t.Fatalf("Config.%s type = %q, want %q", name, field.Type.String(), wantType) ++ } ++ } ++} ++ ++func TestConnectorConnectRetainsConfigAndExecutesDatabaseSelection(t *testing.T) { ++ ++ ++ server := startFakeHiveServer(t, nil) ++ cfg := connectorConfig(server) ++ cfg.Database = "analytics" ++ ++ connector := gohive.NewConnector(cfg) ++ if got := reflect.TypeOf(connector).String(); got != "*gohive.HiveConnector" { ++ t.Fatalf("connector type = %q, want %q", got, "*gohive.HiveConnector") ++ } ++ ++ conn, err := connector.Connect(context.Background()) ++ if err != nil { ++ t.Fatalf("Connect returned error: %v", err) ++ } ++ ++ if conn == nil { ++ t.Fatal("Connect returned nil driver.Conn") ++ } ++ defer conn.Close() ++ ++ openCount, opens, statements, _ := server.service.snapshot() ++ if openCount != 1 { ++ t.Fatalf("open session count = %d, want %d", openCount, 1) ++ } ++ if opens[0].username != "alice" { ++ t.Fatalf("open session username = %q, want %q", opens[0].username, "alice") ++ } ++ if opens[0].password != "secret" { ++ t.Fatalf("open session password = %q, want %q", opens[0].password, "secret") ++ } ++ if !reflect.DeepEqual(opens[0].configuration, map[string]string{"hive.server2.thrift.sasl.qop": "auth-conf", "spark.sql.shuffle.partitions": "9"}) { ++ t.Fatalf("open session configuration = %#v, want %#v", opens[0].configuration, map[string]string{"hive.server2.thrift.sasl.qop": "auth-conf", "spark.sql.shuffle.partitions": "9"}) ++ } ++ if !reflect.DeepEqual(statements, []string{"USE analytics"}) { ++ t.Fatalf("statements = %#v, want %#v", statements, []string{"USE analytics"}) ++ } ++ ++} ++ ++func TestOpenDBUsesConnectorForDatabaseSQLExecAndQuery(t *testing.T) { ++ ++ ++ server := startFakeHiveServer(t, nil) ++ var db *sql.DB = gohive.OpenDB(connectorConfig(server)) ++ if got := reflect.TypeOf(db).String(); got != "*sql.DB" { ++ t.Fatalf("OpenDB type = %q, want %q", got, "*sql.DB") ++ } ++ defer db.Close() ++ ++ result, err := db.ExecContext(context.Background(), "CREATE TABLE sample (id INT)") ++ if err != nil { ++ t.Fatalf("ExecContext returned error: %v", err) ++ } ++ ++ if result == nil { ++ t.Fatal("ExecContext returned nil Result") ++ } ++ ++ rows, err := db.QueryContext(context.Background(), "SELECT id FROM sample") ++ if err != nil { ++ t.Fatalf("QueryContext returned error: %v", err) ++ } ++ if err := rows.Close(); err != nil { ++ t.Fatalf("rows close returned error: %v", err) ++ } ++ ++ openCount, _, statements, _ := server.service.snapshot() ++ if openCount != 1 { ++ t.Fatalf("open session count = %d, want %d", openCount, 1) ++ } ++ if !reflect.DeepEqual(statements, []string{"CREATE TABLE sample (id INT)", "SELECT id FROM sample"}) { ++ t.Fatalf("statements = %#v, want %#v", statements, []string{"CREATE TABLE sample (id INT)", "SELECT id FROM sample"}) ++ } ++ ++} ++ ++func TestHTTPTransportUsesDefaultAndCustomHTTPPaths(t *testing.T) { ++ ++ ++ defaultServer := startFakeHTTPHiveServer(t) ++ defaultCfg := httpConnectorConfig(defaultServer) ++ ++ defaultConn, err := gohive.NewConnector(defaultCfg).Connect(context.Background()) ++ if err != nil { ++ t.Fatalf("default HTTP Connect returned error: %v", err) ++ } ++ defer defaultConn.Close() ++ ++ defaultOpenCount, defaultOpens, defaultStatements, _ := defaultServer.service.snapshot() ++ if defaultOpenCount != 1 { ++ t.Fatalf("default HTTP open session count = %d, want %d", defaultOpenCount, 1) ++ } ++ if defaultOpens[0].username != "http-user" { ++ t.Fatalf("default HTTP username = %q, want %q", defaultOpens[0].username, "http-user") ++ } ++ if defaultOpens[0].password != "http-pass" { ++ t.Fatalf("default HTTP password = %q, want %q", defaultOpens[0].password, "http-pass") ++ } ++ ++ if len(defaultStatements) != 0 { ++ t.Fatalf("default HTTP statement count = %d, want %d; statements=%#v", len(defaultStatements), 0, defaultStatements) ++ } ++ defaultPaths := defaultServer.pathSnapshot() ++ ++ if len(defaultPaths) != 1 || defaultPaths[0] == "" || defaultPaths[0] == "/" { ++ t.Fatalf("default HTTP request paths = %#v, want one non-empty default path", defaultPaths) ++ } ++ ++ customServer := startFakeHTTPHiveServer(t) ++ customCfg := httpConnectorConfig(customServer) ++ customCfg.HTTPPath = "custom/hive" ++ ++ customConn, err := gohive.NewConnector(customCfg).Connect(context.Background()) ++ if err != nil { ++ t.Fatalf("custom HTTP Connect returned error: %v", err) ++ } ++ defer customConn.Close() ++ ++ customOpenCount, customOpens, customStatements, _ := customServer.service.snapshot() ++ if customOpenCount != 1 { ++ t.Fatalf("custom HTTP open session count = %d, want %d", customOpenCount, 1) ++ } ++ if customOpens[0].username != "http-user" { ++ t.Fatalf("custom HTTP username = %q, want %q", customOpens[0].username, "http-user") ++ } ++ if customOpens[0].password != "http-pass" { ++ t.Fatalf("custom HTTP password = %q, want %q", customOpens[0].password, "http-pass") ++ } ++ ++ if len(customStatements) != 0 { ++ t.Fatalf("custom HTTP statement count = %d, want %d; statements=%#v", len(customStatements), 0, customStatements) ++ } ++ if !reflect.DeepEqual(customServer.pathSnapshot(), []string{"/custom/hive"}) { ++ t.Fatalf("custom HTTP request paths = %#v, want %#v", customServer.pathSnapshot(), []string{"/custom/hive"}) ++ } ++} ++ ++func TestConnectorDriverReturnsPackageDriver(t *testing.T) { ++ ++ ++ server := startFakeHiveServer(t, nil) ++ connector := gohive.NewConnector(connectorConfig(server)) ++ ++ driverValue := connector.Driver() ++ if got := reflect.TypeOf(driverValue).String(); got != "*gohive.Driver" { ++ t.Fatalf("Driver type = %q, want %q", got, "*gohive.Driver") ++ } ++} ++ ++func TestConnectorInstancesRemainIndependent(t *testing.T) { ++ ++ ++ serverA := startFakeHiveServer(t, nil) ++ serverB := startFakeHiveServer(t, nil) ++ cfgA := connectorConfig(serverA) ++ cfgA.Username = "alpha" ++ cfgA.Password = "alpha-pass" ++ cfgA.HiveConfiguration = map[string]string{"instance": "a"} ++ cfgB := connectorConfig(serverB) ++ cfgB.Username = "bravo" ++ cfgB.Password = "bravo-pass" ++ cfgB.HiveConfiguration = map[string]string{"instance": "b"} ++ ++ connA, err := gohive.NewConnector(cfgA).Connect(context.Background()) ++ if err != nil { ++ t.Fatalf("connector A Connect returned error: %v", err) ++ } ++ defer connA.Close() ++ ++ countA, opensA, _, _ := serverA.service.snapshot() ++ countB, opensB, _, _ := serverB.service.snapshot() ++ if countA != 1 { ++ t.Fatalf("server A open session count = %d, want %d", countA, 1) ++ } ++ if countB != 0 { ++ t.Fatalf("server B open session count = %d, want %d", countB, 0) ++ } ++ if opensA[0].username != "alpha" { ++ t.Fatalf("server A username = %q, want %q", opensA[0].username, "alpha") ++ } ++ if !reflect.DeepEqual(opensA[0].configuration, map[string]string{"instance": "a"}) { ++ t.Fatalf("server A configuration = %#v, want %#v", opensA[0].configuration, map[string]string{"instance": "a"}) ++ } ++ ++ connB, err := gohive.NewConnector(cfgB).Connect(context.Background()) ++ if err != nil { ++ t.Fatalf("connector B Connect returned error: %v", err) ++ } ++ defer connB.Close() ++ ++ countA, opensA, _, _ = serverA.service.snapshot() ++ countB, opensB, _, _ = serverB.service.snapshot() ++ if countA != 1 { ++ t.Fatalf("server A open session count = %d, want %d", countA, 1) ++ } ++ if countB != 1 { ++ t.Fatalf("server B open session count = %d, want %d", countB, 1) ++ } ++ if opensB[0].username != "bravo" { ++ t.Fatalf("server B username = %q, want %q", opensB[0].username, "bravo") ++ } ++ if opensB[0].password != "bravo-pass" { ++ t.Fatalf("server B password = %q, want %q", opensB[0].password, "bravo-pass") ++ } ++ if !reflect.DeepEqual(opensB[0].configuration, map[string]string{"instance": "b"}) { ++ t.Fatalf("server B configuration = %#v, want %#v", opensB[0].configuration, map[string]string{"instance": "b"}) ++ } ++} ++ ++func TestOpenDBCloseIsIdempotent(t *testing.T) { ++ ++ ++ server := startFakeHiveServer(t, nil) ++ db := gohive.OpenDB(connectorConfig(server)) ++ if err := db.PingContext(context.Background()); err != nil { ++ t.Fatalf("PingContext returned error: %v", err) ++ } ++ ++ if err := db.Close(); err != nil { ++ t.Fatalf("first DB Close returned error: %v", err) ++ } ++ if err := db.Close(); err != nil { ++ t.Fatalf("second DB Close returned error: %v", err) ++ } ++} ++ ++func TestDriverConnCloseSucceeds(t *testing.T) { ++ ++ ++ server := startFakeHiveServer(t, nil) ++ conn, err := gohive.NewConnector(connectorConfig(server)).Connect(context.Background()) ++ if err != nil { ++ t.Fatalf("Connect returned error: %v", err) ++ } ++ if err := conn.Close(); err != nil { ++ t.Fatalf("Close returned error: %v", err) ++ } ++ ++} ++ ++func TestConnectWrapsUnderlyingConnectionFailure(t *testing.T) { ++ ++ ++ port := closedLocalPort(t) ++ cfg := gohive.Config{Host: "127.0.0.1", Port: port, Auth: "NOSASL"} ++ ++ conn, err := gohive.NewConnector(cfg).Connect(context.Background()) ++ if conn != nil { ++ t.Fatalf("failed Connect returned conn = %T, want nil", conn) ++ } ++ if err == nil { ++ t.Fatal("Connect returned nil error, want wrapped connection error") ++ } ++ if got := strings.HasPrefix(err.Error(), "gohive connect: "); got != true { ++ t.Fatalf("error has gohive prefix = %t, want %t; error=%q", got, true, err.Error()) ++ } ++} ++ ++func TestTLSConfigDirectIsUsedInsteadOfCertificateFiles(t *testing.T) { ++ ++ ++ cert := selfSignedCertificate(t) ++ server := startFakeHiveServer(t, &tls.Config{Certificates: []tls.Certificate{cert}}) ++ cfg := connectorConfig(server) ++ cfg.TLSConfig = &tls.Config{InsecureSkipVerify: true} ++ cfg.SSLCertFile = filepath.Join(fixturesDir, "missing-client.pem") ++ cfg.SSLKeyFile = filepath.Join(fixturesDir, "missing-client.key") ++ ++ conn, err := gohive.NewConnector(cfg).Connect(context.Background()) ++ if err != nil { ++ t.Fatalf("Connect with direct TLSConfig returned error: %v", err) ++ } ++ defer conn.Close() ++ ++ openCount, _, _, _ := server.service.snapshot() ++ if openCount != 1 { ++ t.Fatalf("TLS server open session count = %d, want %d", openCount, 1) ++ } ++} ++ ++func TestTLSCertificatePairLoadFailureHasConfiguredPrefix(t *testing.T) { ++ ++ ++ cfg := gohive.Config{ ++ Host: "127.0.0.1", ++ Port: 1, ++ Auth: "NOSASL", ++ SSLCertFile: filepath.Join(fixturesDir, "missing-client.pem"), ++ SSLKeyFile: filepath.Join(fixturesDir, "missing-client.key"), ++ } ++ ++ conn, err := gohive.NewConnector(cfg).Connect(context.Background()) ++ if conn != nil { ++ t.Fatalf("failed TLS Connect returned conn = %T, want nil", conn) ++ } ++ if err == nil { ++ t.Fatal("Connect returned nil error, want TLS certificate load error") ++ } ++ ++ if got := strings.HasPrefix(err.Error(), "failed to configure SSL:"); got != true { ++ t.Fatalf("TLS certificate load error has configured prefix = %t, want %t; error=%q", got, true, err.Error()) ++ } ++} ++ ++func TestTLSCAFilePathAndPEMErrorsAreConcrete(t *testing.T) { ++ ++ ++ missingCA := filepath.Join(fixturesDir, "missing-ca.pem") ++ cfg := gohive.Config{Host: "127.0.0.1", Port: 1, Auth: "NOSASL", SSLCAFile: missingCA} ++ ++ conn, err := gohive.NewConnector(cfg).Connect(context.Background()) ++ if conn != nil { ++ t.Fatalf("missing CA Connect returned conn = %T, want nil", conn) ++ } ++ if err == nil { ++ t.Fatal("Connect returned nil error, want missing CA error") ++ } ++ ++ wantMissingPrefix := "invalid ca path: " + missingCA ++ if got := strings.HasPrefix(err.Error(), wantMissingPrefix); got != true { ++ t.Fatalf("missing CA error has path prefix = %t, want %t; error=%q", got, true, err.Error()) ++ } ++ ++ invalidCA := filepath.Join(t.TempDir(), "invalid-ca.pem") ++ if err := os.WriteFile(invalidCA, []byte("not a certificate\n"), 0600); err != nil { ++ t.Fatal(err) ++ } ++ cfg.SSLCAFile = invalidCA ++ conn, err = gohive.NewConnector(cfg).Connect(context.Background()) ++ if conn != nil { ++ t.Fatalf("invalid PEM Connect returned conn = %T, want nil", conn) ++ } ++ if err == nil { ++ t.Fatal("Connect returned nil error, want invalid PEM error") ++ } ++ ++ if got := strings.HasPrefix(err.Error(), "invalid certification "); got != true || !strings.Contains(err.Error(), invalidCA) { ++ t.Fatalf("invalid PEM error contains certification marker and path = %t, want %t; error=%q", got, true, err.Error()) ++ } ++} ++ ++func TestTLSInsecureSkipWithoutFilesCreatesUsableTLSConfig(t *testing.T) { ++ ++ ++ cert := selfSignedCertificate(t) ++ server := startFakeHiveServer(t, &tls.Config{Certificates: []tls.Certificate{cert}}) ++ cfg := connectorConfig(server) ++ cfg.SSLInsecureSkip = true ++ ++ conn, err := gohive.NewConnector(cfg).Connect(context.Background()) ++ if err != nil { ++ t.Fatalf("Connect with SSLInsecureSkip returned error: %v", err) ++ } ++ defer conn.Close() ++ ++ openCount, _, _, _ := server.service.snapshot() ++ if openCount != 1 { ++ t.Fatalf("TLS server open session count = %d, want %d", openCount, 1) ++ } ++} ++ ++func TestConnectCloseCyclesDoNotLeakFDsOrGoroutines(t *testing.T) { ++ ++ ++ server := startFakeHiveServer(t, nil) ++ runtime.GC() ++ baseFDs := fdCount(t) ++ baseGoroutines := runtime.NumGoroutine() ++ ++ for i := 0; i < 100; i++ { ++ db := gohive.OpenDB(connectorConfig(server)) ++ if err := db.PingContext(context.Background()); err != nil { ++ t.Fatalf("PingContext cycle %d returned error: %v", i, err) ++ } ++ if err := db.Close(); err != nil { ++ t.Fatalf("DB Close cycle %d returned error: %v", i, err) ++ } ++ } ++ ++ deadline := time.Now().Add(2 * time.Second) ++ var gotFDs int ++ var gotGoroutines int ++ for time.Now().Before(deadline) { ++ runtime.GC() ++ gotFDs = fdCount(t) ++ gotGoroutines = runtime.NumGoroutine() ++ if gotFDs <= baseFDs+8 && gotGoroutines <= baseGoroutines+12 { ++ break ++ } ++ time.Sleep(20 * time.Millisecond) ++ } ++ if gotFDs > baseFDs+8 { ++ t.Fatalf("fd count after 100 OpenDB/Ping/Close cycles = %d, want <= %d", gotFDs, baseFDs+8) ++ } ++ if gotGoroutines > baseGoroutines+12 { ++ t.Fatalf("goroutine count after 100 OpenDB/Ping/Close cycles = %d, want <= %d", gotGoroutines, baseGoroutines+12) ++ } ++} ++ ++func selfSignedCertificate(t *testing.T) tls.Certificate { ++ t.Helper() ++ ++ key, err := rsa.GenerateKey(rand.Reader, 2048) ++ if err != nil { ++ t.Fatal(err) ++ } ++ template := x509.Certificate{ ++ SerialNumber: big.NewInt(1), ++ Subject: pkix.Name{CommonName: "127.0.0.1"}, ++ NotBefore: time.Now().Add(-time.Hour), ++ NotAfter: time.Now().Add(time.Hour), ++ KeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature, ++ ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth}, ++ IPAddresses: []net.IP{net.ParseIP("127.0.0.1")}, ++ } ++ der, err := x509.CreateCertificate(rand.Reader, &template, &template, &key.PublicKey, key) ++ if err != nil { ++ t.Fatal(err) ++ } ++ certPEM := pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: der}) ++ keyPEM := pem.EncodeToMemory(&pem.Block{Type: "RSA PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(key)}) ++ cert, err := tls.X509KeyPair(certPEM, keyPEM) ++ if err != nil { ++ t.Fatal(err) ++ } ++ return cert ++} ++ ++func closedLocalPort(t *testing.T) int { ++ t.Helper() ++ listener, err := net.Listen("tcp", "127.0.0.1:0") ++ if err != nil { ++ t.Fatal(err) ++ } ++ port := listener.Addr().(*net.TCPAddr).Port ++ if err := listener.Close(); err != nil { ++ t.Fatal(err) ++ } ++ return port ++} ++ ++func fdCount(t *testing.T) int { ++ t.Helper() ++ entries, err := os.ReadDir("/proc/self/fd") ++ if err != nil { ++ t.Fatal(err) ++ } ++ return len(entries) ++} ++ ++var _ hiveserver.TCLIService = (*fakeHiveService)(nil) +diff --git a/usercase-test-coderl/go.mod b/usercase-test-coderl/go.mod +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/go.mod +@@ -0,0 +1,17 @@ ++module usercase-test-coderl ++ ++go 1.23.0 ++ ++require ( ++ github.com/apache/thrift v0.22.0 ++ github.com/beltran/gohive/v2 v2.0.0 ++) ++ ++require ( ++ github.com/beltran/gosasl v1.0.0 // indirect ++ github.com/beltran/gssapi v0.0.0-20200324152954-d86554db4bab // indirect ++ github.com/pkg/errors v0.9.1 // indirect ++ golang.org/x/net v0.41.0 // indirect ++) ++ ++replace github.com/beltran/gohive/v2 => ../v2 +diff --git a/usercase-test-coderl/go.sum b/usercase-test-coderl/go.sum +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/go.sum +@@ -0,0 +1,18 @@ ++github.com/apache/thrift v0.22.0 h1:r7mTJdj51TMDe6RtcmNdQxgn9XcyfGDOzegMDRg47uc= ++github.com/apache/thrift v0.22.0/go.mod h1:1e7J/O1Ae6ZQMTYdy9xa3w9k+XHWPfRvdPyJeynQ+/g= ++github.com/beltran/gosasl v1.0.0 h1:iiRtLxkvKhrNv3Ohh/n2NiyyfwIo/UbMzy/dZWiUHXE= ++github.com/beltran/gosasl v1.0.0/go.mod h1:Qx8cW6jkI8riyzmklj80kAIkv+iezFUTBiGU0qHhHes= ++github.com/beltran/gssapi v0.0.0-20200324152954-d86554db4bab h1:ayfcn60tXOSYy5zUN1AMSTQo4nJCf7hrdzAVchpPst4= ++github.com/beltran/gssapi v0.0.0-20200324152954-d86554db4bab/go.mod h1:GLe4UoSyvJ3cVG+DVtKen5eAiaD8mAJFuV5PT3Eeg9Q= ++github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= ++github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= ++golang.org/x/crypto v0.39.0 h1:SHs+kF4LP+f+p14esP5jAoDpHU8Gu/v9lFRK6IT5imM= ++golang.org/x/crypto v0.39.0/go.mod h1:L+Xg3Wf6HoL4Bn4238Z6ft6KfEpN0tJGo53AAPC632U= ++golang.org/x/net v0.41.0 h1:vBTly1HeNPEn3wtREYfy4GZ/NECgw2Cnl+nK6Nz3uvw= ++golang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA= ++golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= ++golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= ++golang.org/x/term v0.32.0 h1:DR4lr0TjUs3epypdhTOkMmuF5CDFJ/8pOnbzMZPQ7bg= ++golang.org/x/term v0.32.0/go.mod h1:uZG1FhGx848Sqfsq4/DlJr3xGGsYMu/L5GW4abiaEPQ= ++golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M= ++golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,24 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo ++ ++cd /workspace/repo/usercase-test-coderl ++export GOTOOLCHAIN=local ++export GOPROXY=off ++export GOSUMDB=off ++export GOMODCACHE=/go/pkg/mod ++export GOFLAGS=-mod=readonly ++export GOTELEMETRY=off ++ ++go mod download all ++exec go test -v -count=1 . diff --git a/tasks/format-code-task-000546/tests/test.sh b/tasks/format-code-task-000546/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..72672b32b9e4be2eeb71644e543dc3243f34c8e0 --- /dev/null +++ b/tasks/format-code-task-000546/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/connector_acceptance_test.go +usercase-test-coderl/go.mod +usercase-test-coderl/go.sum +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000546/tests/test_command.sh b/tasks/format-code-task-000546/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000546/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000577/environment/Dockerfile b/tasks/format-code-task-000577/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..75550cb1dd07897a72d1e3e10536a200075e0d00 --- /dev/null +++ b/tasks/format-code-task-000577/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:d015967776544d515512c54637565f0bdcd30e45f714fd1f0c3e94fa3d6458e8 diff --git a/tasks/format-code-task-000577/environment/setup/files/blocklist b/tasks/format-code-task-000577/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000577/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000577/environment/setup/setup.sh b/tasks/format-code-task-000577/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000577/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000577/tests/test.patch b/tasks/format-code-task-000577/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..58db71b284e0472b399aba9575f5705e162cb297 --- /dev/null +++ b/tasks/format-code-task-000577/tests/test.patch @@ -0,0 +1,112 @@ +diff --git a/wsl_test.go b/wsl_test.go +index 0c5820a..dfc9367 100644 +--- a/wsl_test.go ++++ b/wsl_test.go +@@ -1621,6 +1621,30 @@ func TestWithConfig(t *testing.T) { + }`), + expectedErrorStrings: []string{}, + }, ++ { ++ description: "err-check cuddle enforcement multiline", ++ customConfig: &Configuration{ ++ AllowAssignAndCallCuddle: false, ++ ForceCuddleErrCheckAndAssign: true, ++ ErrorVariableNames: []string{"err"}, ++ }, ++ code: []byte(`package main ++ ++ import "errors" ++ ++ func main() { ++ err := db. ++ Where("foo = ?", bar). ++ Preload("More"). ++ Find(&x). ++ Error ++ ++ if err != nil { ++ panic(err) ++ } ++ }`), ++ expectedErrorStrings: []string{}, ++ }, + { + description: "allow separated leading comment", + customConfig: &Configuration{ +@@ -1718,6 +1742,56 @@ func TestWithConfig(t *testing.T) { + }`), + expectedErrorStrings: []string{reasonOnlyCuddleIfWithAssign}, + }, ++ { ++ description: "allow cuddling of declaration (#83)", ++ code: []byte(`package main ++ ++ func main() { ++ var first = 1 ++ var second = 2 ++ third := 3 ++ ++ var config Configuration ++ if err := conf.Load(config); err != nil { ++ panic(err) ++ } ++ ++ var config Configuration ++ conf.Load(&config) ++ ++ var config Configuration ++ err = json.Unmarshal(body, &config) ++ ++ var notUsed bool ++ err = json.Unmarshal(body, &something) ++ ++ var x = 1 ++ if x > 0 { ++ ++ } ++ ++ ++ var y = 1 ++ if first > 0 { ++ ++ } ++ ++ ++ var z = 1 ++ var zz = 2 ++ if zz > z { ++ ++ } ++ }`), ++ customConfig: &Configuration{ ++ AllowAssignAndCallCuddle: true, ++ AllowCuddleDeclaration: true, ++ }, ++ expectedErrorStrings: []string{ ++ reasonOnlyCuddleWithUsedAssign, ++ reasonOnlyOneCuddle, ++ }, ++ }, + } + + for _, tc := range cases { +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,4 @@ ++H4sIAAAAAAAAA+3RzQqCQBSG4Vl7FecGnGbE0VXXEqZSQTqgo9efuegPqo0R0ftszoEzMB98ejsc ++jtWmbseV+hQzyZ2b5+Rxzrt1iUlyY9PUKmOty50S97FEN4Y+FJ2I6rwPr969u/8ofe0/1H3YlL5p ++irbS/X65P972P90u/Ztk6j/NTKbELBfhuT/vv6xkLn5bV9HOy3mVeJS49EMb1lbibmhFi15praNv ++hwUAAAAAAAAAAAAAAABw5wTIR53pACgAAA== +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000577/tests/test.sh b/tasks/format-code-task-000577/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..b8b9251b43ddd4a1b94ea902cee370f828e9e7fc --- /dev/null +++ b/tasks/format-code-task-000577/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +wsl_test.go +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000577/tests/test_command.sh b/tasks/format-code-task-000577/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000577/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000583/environment/Dockerfile b/tasks/format-code-task-000583/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..bebfe6b064bbcd0076d8d84f2318f5f77e0c215d --- /dev/null +++ b/tasks/format-code-task-000583/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:da9438bf7587d2ce9c0b14ce59d266879c1f7bf7e3f921c27f9f4a028e1dfd81 diff --git a/tasks/format-code-task-000583/environment/setup/files/blocklist b/tasks/format-code-task-000583/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000583/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000583/environment/setup/setup.sh b/tasks/format-code-task-000583/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000583/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000583/tests/test.patch b/tasks/format-code-task-000583/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..a714572308ad9779be8f6bd3ea06c9f11f3785c2 --- /dev/null +++ b/tasks/format-code-task-000583/tests/test.patch @@ -0,0 +1,236 @@ +diff --git a/src/api/__tests__/Annotations.test.js b/src/api/__tests__/Annotations.test.js +index 8f9a20ab19..a77b5c4b66 100644 +--- a/src/api/__tests__/Annotations.test.js ++++ b/src/api/__tests__/Annotations.test.js +@@ -1,4 +1,10 @@ + import Annotations from '../Annotations'; ++import { ++ ERROR_CODE_CREATE_ANNOTATION, ++ ERROR_CODE_DELETE_ANNOTATION, ++ ERROR_CODE_FETCH_ANNOTATION, ++ ERROR_CODE_FETCH_ANNOTATIONS, ++} from '../../constants'; + + describe('api/Annotations', () => { + let annotations; +@@ -30,30 +36,35 @@ describe('api/Annotations', () => { + }); + + describe('createAnnotation()', () => { +- test('should format its parameters and call the post method', () => { +- const payload = { +- description: { +- message: 'This is a test message.', ++ const payload = { ++ description: { ++ message: 'This is a test message.', ++ }, ++ target: { ++ location: { ++ type: 'page', ++ value: 1, + }, +- target: { +- location: { +- type: 'page', +- value: 1, +- }, +- shape: { +- height: 50, +- type: 'rect', +- width: 50, +- x: 10, +- y: 10, +- }, +- type: 'region', ++ shape: { ++ height: 50, ++ type: 'rect', ++ width: 50, ++ x: 10, ++ y: 10, + }, ++ type: 'region', ++ }, ++ }; ++ const errorCallback = jest.fn(); ++ const successCallback = jest.fn(); ++ ++ test('should format its parameters and call the post method', () => { ++ const permissions = { ++ can_create_annotations: true, ++ can_view_annotations: true, + }; +- const errorCallback = jest.fn(); +- const successCallback = jest.fn(); + +- annotations.createAnnotation('12345', '67890', payload, successCallback, errorCallback); ++ annotations.createAnnotation('12345', '67890', payload, permissions, successCallback, errorCallback); + + expect(annotations.post).toBeCalledWith({ + id: '12345', +@@ -68,20 +79,7 @@ describe('api/Annotations', () => { + type: 'file_version', + }, + status: 'open', +- target: { +- location: { +- type: 'page', +- value: 1, +- }, +- shape: { +- height: 50, +- type: 'rect', +- width: 50, +- x: 10, +- y: 10, +- }, +- type: 'region', +- }, ++ target: payload.target, + type: 'annotation', + }, + }, +@@ -90,14 +88,24 @@ describe('api/Annotations', () => { + url: 'https://api.box.com/2.0/internal_annotations', + }); + }); ++ ++ test.each([ ++ { can_create_annotations: false, can_view_annotations: false }, ++ { can_create_annotations: false, can_view_annotations: true }, ++ ])('should reject with an error code for calls with invalid permissions %s', permissions => { ++ annotations.createAnnotation('12345', '67890', payload, permissions, successCallback, errorCallback); ++ ++ expect(errorCallback).toBeCalledWith(expect.any(Error), ERROR_CODE_CREATE_ANNOTATION); ++ expect(annotations.post).not.toBeCalled(); ++ }); + }); + + describe('deleteAnnotation()', () => { +- test('should format its parameters and call the delete method for a given id', () => { +- const errorCallback = jest.fn(); +- const successCallback = jest.fn(); ++ const errorCallback = jest.fn(); ++ const successCallback = jest.fn(); + +- annotations.deleteAnnotation('12345', 'abc', successCallback, errorCallback); ++ test('should format its parameters and call the delete method for a given id', () => { ++ annotations.deleteAnnotation('12345', 'abc', { can_delete: true }, successCallback, errorCallback); + + expect(annotations.delete).toBeCalledWith({ + id: '12345', +@@ -106,14 +114,26 @@ describe('api/Annotations', () => { + url: 'https://api.box.com/2.0/internal_annotations/abc', + }); + }); ++ ++ test('should reject with an error code for calls with invalid permissions', () => { ++ annotations.deleteAnnotation('12345', '67890', { can_delete: false }, successCallback, errorCallback); ++ ++ expect(errorCallback).toBeCalledWith(expect.any(Error), ERROR_CODE_DELETE_ANNOTATION); ++ expect(annotations.delete).not.toBeCalled(); ++ }); + }); + + describe('getAnnotation()', () => { ++ const errorCallback = jest.fn(); ++ const successCallback = jest.fn(); ++ + test('should format its parameters and call the get method', () => { +- const successCallback = jest.fn(); +- const errorCallback = jest.fn(); ++ const permissions = { ++ can_create_annotations: true, ++ can_view_annotations: true, ++ }; + +- annotations.getAnnotation('12345', 'abc', successCallback, errorCallback); ++ annotations.getAnnotation('12345', 'abc', permissions, successCallback, errorCallback); + + expect(annotations.get).toBeCalledWith({ + id: '12345', +@@ -122,14 +142,29 @@ describe('api/Annotations', () => { + url: 'https://api.box.com/2.0/internal_annotations/abc', + }); + }); ++ ++ test.each([ ++ { can_create_annotations: true, can_view_annotations: false }, ++ { can_create_annotations: false, can_view_annotations: false }, ++ ])('should reject with an error code for calls with invalid permissions %s', permissions => { ++ annotations.getAnnotation('12345', '67890', permissions, successCallback, errorCallback); ++ ++ expect(errorCallback).toBeCalledWith(expect.any(Error), ERROR_CODE_FETCH_ANNOTATION); ++ expect(annotations.get).not.toBeCalled(); ++ }); + }); + + describe('getAnnotations()', () => { ++ const errorCallback = jest.fn(); ++ const successCallback = jest.fn(); ++ + test('should format its parameters and call the underlying markerGet method', () => { +- const successCallback = jest.fn(); +- const errorCallback = jest.fn(); ++ const permissions = { ++ can_create_annotations: true, ++ can_view_annotations: true, ++ }; + +- annotations.getAnnotations('12345', '67890', successCallback, errorCallback); ++ annotations.getAnnotations('12345', '67890', permissions, successCallback, errorCallback); + + expect(annotations.markerGet).toBeCalledWith({ + id: '12345', +@@ -141,5 +176,15 @@ describe('api/Annotations', () => { + successCallback, + }); + }); ++ ++ test.each([ ++ { can_create_annotations: true, can_view_annotations: false }, ++ { can_create_annotations: false, can_view_annotations: false }, ++ ])('should reject with an error code for calls with invalid permissions %s', permissions => { ++ annotations.getAnnotations('12345', '67890', permissions, successCallback, errorCallback); ++ ++ expect(errorCallback).toBeCalledWith(expect.any(Error), ERROR_CODE_FETCH_ANNOTATIONS); ++ expect(annotations.get).not.toBeCalled(); ++ }); + }); + }); +diff --git a/src/api/__tests__/Feed.test.js b/src/api/__tests__/Feed.test.js +index c19716b8ba..b0e5beb5e6 100644 +--- a/src/api/__tests__/Feed.test.js ++++ b/src/api/__tests__/Feed.test.js +@@ -317,6 +317,8 @@ describe('api/Feed', () => { + id: '12345', + permissions: { + can_comment: true, ++ can_create_annotations: true, ++ can_view_annotations: true, + }, + modified_at: 1234567891, + file_version: { +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,6 @@ ++H4sIAAAAAAAAA+3RQU+DMBgGYM78imbxOgpsHYkJB+YwmpjpYXptgNbIAi2hxeznCyQ6Y9RdtizG ++97m0fP1Km75e3pWV4FK9UudU/F7E2Dj2vo7jPGBhEDJ/4bPQ8YOARZFD2Mlu9ElnbNYS4rRa29/6 ++Dq3/Ud4+fyuN5YWu60wJz7wc74xD+c/2+bNoMevzny+CuUP8413hZ/88/0KQMfhcClfuGt1a8pBs ++buIJ1Y2lSgs5DUOal+ryYqhP3PX9KuW3V498lWySeGjgtRZdJQ197qpqWhYdWSbL9I6n66d4+DUZ ++t3x8qWZHtsPEtAXNmpJyPtQN5zRRStvMlloZb6h5W/NN17WU4n3ZPff7AQAAAAAAAAAAAAAAAAAA ++AACc0xuUqKq9ACgAAA== +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000583/tests/test.sh b/tasks/format-code-task-000583/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..2026b50c0070dafcc837e1ac278f86669c9f2960 --- /dev/null +++ b/tasks/format-code-task-000583/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +src/api/__tests__/Annotations.test.js +src/api/__tests__/Feed.test.js +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000583/tests/test_command.sh b/tasks/format-code-task-000583/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000583/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000601/environment/Dockerfile b/tasks/format-code-task-000601/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..495b789aa566c27ca0f611ad3ba39fbe5b9912cf --- /dev/null +++ b/tasks/format-code-task-000601/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:82addb509c36014eb750472393765187bfb4b28b3929912f0608495e1f4f5864 diff --git a/tasks/format-code-task-000601/environment/setup/files/blocklist b/tasks/format-code-task-000601/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000601/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000601/environment/setup/setup.sh b/tasks/format-code-task-000601/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000601/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000601/tests/test.patch b/tasks/format-code-task-000601/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..a9904e2c3ad40ab2ca2e60ea718e0acefe7b12e1 --- /dev/null +++ b/tasks/format-code-task-000601/tests/test.patch @@ -0,0 +1,323 @@ +diff --git a/src/__tests__/areEqual.js b/src/__tests__/areEqual.js +new file mode 100644 +index 0000000..1d5b664 +--- /dev/null ++++ b/src/__tests__/areEqual.js +@@ -0,0 +1,129 @@ ++import React, { memo } from 'react'; ++import ReactTestRenderer from 'react-test-renderer'; ++import { areEqual } from '..'; ++ ++describe('areEqual', () => { ++ it('is exported from the package entry', () => { ++ expect(typeof areEqual).toBe('function'); ++ }); ++ ++ it('should not re-render when the style prop changes', () => { ++ const Component = jest.fn(() => null); ++ const MemoizedComponent = memo(Component, areEqual); ++ const renderer = ReactTestRenderer.create( ++ ++ ); ++ expect(Component).toHaveBeenCalledTimes(1); ++ ++ renderer.update(); ++ expect(Component).toHaveBeenCalledTimes(1); ++ }); ++ ++ it('should re-render when other props change', () => { ++ const Component = jest.fn(() => null); ++ const MemoizedComponent = memo(Component, areEqual); ++ const renderer = ReactTestRenderer.create( ++ ++ ); ++ expect(Component).toHaveBeenCalledTimes(1); ++ ++ renderer.update(); ++ expect(Component).toHaveBeenCalledTimes(2); ++ }); ++ ++ it('skips React.memo renders when item props are shallowly unchanged', () => { ++ const Component = jest.fn(() => null); ++ const MemoizedComponent = memo(Component, areEqual); ++ const itemData = { id: 1 }; ++ const renderer = ReactTestRenderer.create( ++ ++ ); ++ expect(Component).toHaveBeenCalledTimes(1); ++ ++ renderer.update( ++ ++ ); ++ expect(Component).toHaveBeenCalledTimes(1); ++ }); ++ ++ it('returns false when style contents change', () => { ++ const prevProps = { index: 0, style: { top: 10, height: 25 } }; ++ ++ expect( ++ areEqual(prevProps, { index: 0, style: { top: 11, height: 25 } }) ++ ).toBe(false); ++ expect( ++ areEqual(prevProps, { ++ index: 0, ++ style: { top: 10, height: 25, width: 100 }, ++ }) ++ ).toBe(false); ++ expect( ++ areEqual( ++ { index: 0, style: { top: 10, height: 25, width: 100 } }, ++ prevProps ++ ) ++ ).toBe(false); ++ expect( ++ areEqual( ++ { index: 0, style: { top: 10, height: 25, '--customOffset': 4 } }, ++ { index: 0, style: { top: 10, height: 25, '--customOffset': 5 } } ++ ) ++ ).toBe(false); ++ }); ++ ++ it('returns false when non-style props change', () => { ++ expect( ++ areEqual( ++ { index: 1, style: { top: 0, height: 10 }, label: 'a' }, ++ { index: 2, style: { top: 0, height: 10 }, label: 'a' } ++ ) ++ ).toBe(false); ++ expect( ++ areEqual( ++ { index: 1, style: { top: 0, height: 10 }, label: 'a' }, ++ { index: 1, style: { top: 0, height: 10 }, label: 'a', extra: true } ++ ) ++ ).toBe(false); ++ expect( ++ areEqual( ++ { index: 1, style: { top: 0, height: 10 }, label: 'a', extra: true }, ++ { index: 1, style: { top: 0, height: 10 }, label: 'a' } ++ ) ++ ).toBe(false); ++ }); ++ ++ it('uses shallow comparison for nested values', () => { ++ const sharedStyleValue = { translateY: 10 }; ++ const sharedData = { item: 'row' }; ++ ++ expect( ++ areEqual( ++ { data: sharedData, style: { transform: sharedStyleValue } }, ++ { data: sharedData, style: { transform: sharedStyleValue } } ++ ) ++ ).toBe(true); ++ expect( ++ areEqual( ++ { data: sharedData, style: { transform: { translateY: 10 } } }, ++ { data: sharedData, style: { transform: { translateY: 10 } } } ++ ) ++ ).toBe(false); ++ expect( ++ areEqual( ++ { data: { item: 'row' }, style: { top: 0 } }, ++ { data: { item: 'row' }, style: { top: 0 } } ++ ) ++ ).toBe(false); ++ }); ++}); +diff --git a/src/__tests__/shouldComponentUpdate.js b/src/__tests__/shouldComponentUpdate.js +new file mode 100644 +index 0000000..4fcb692 +--- /dev/null ++++ b/src/__tests__/shouldComponentUpdate.js +@@ -0,0 +1,149 @@ ++import React, { Component } from 'react'; ++import ReactTestRenderer from 'react-test-renderer'; ++import { shouldComponentUpdate } from '..'; ++ ++describe('shouldComponentUpdate', () => { ++ it('is exported from the package entry', () => { ++ expect(typeof shouldComponentUpdate).toBe('function'); ++ }); ++ ++ it('should not re-render when the style prop changes', () => { ++ const render = jest.fn(() => null); ++ ++ class ClassComponent extends Component { ++ shouldComponentUpdate = shouldComponentUpdate.bind(this); ++ render = render; ++ } ++ ++ const renderer = ReactTestRenderer.create( ++ ++ ); ++ expect(render).toHaveBeenCalledTimes(1); ++ ++ renderer.update(); ++ expect(render).toHaveBeenCalledTimes(1); ++ }); ++ ++ it('should re-render when other props change', () => { ++ const render = jest.fn(() => null); ++ ++ class ClassComponent extends Component { ++ shouldComponentUpdate = shouldComponentUpdate.bind(this); ++ render = render; ++ } ++ ++ const renderer = ReactTestRenderer.create( ++ ++ ); ++ expect(render).toHaveBeenCalledTimes(1); ++ ++ renderer.update(); ++ expect(render).toHaveBeenCalledTimes(2); ++ }); ++ ++ it('skips class re-render when props compare equal and state is unchanged', () => { ++ const render = jest.fn(() => null); ++ const itemData = { id: 1 }; ++ ++ class ClassComponent extends Component { ++ state = { selected: false }; ++ shouldComponentUpdate = shouldComponentUpdate.bind(this); ++ render = render; ++ } ++ ++ const renderer = ReactTestRenderer.create( ++ ++ ); ++ expect(render).toHaveBeenCalledTimes(1); ++ ++ renderer.update( ++ ++ ); ++ expect(render).toHaveBeenCalledTimes(1); ++ }); ++ ++ it('re-renders class component when props differ', () => { ++ const render = jest.fn(() => null); ++ ++ class ClassComponent extends Component { ++ state = { selected: false }; ++ shouldComponentUpdate = shouldComponentUpdate.bind(this); ++ render = render; ++ } ++ ++ const renderer = ReactTestRenderer.create( ++ ++ ); ++ expect(render).toHaveBeenCalledTimes(1); ++ ++ renderer.update( ++ ++ ); ++ expect(render).toHaveBeenCalledTimes(2); ++ ++ renderer.update( ++ ++ ); ++ expect(render).toHaveBeenCalledTimes(3); ++ }); ++ ++ it('returns true when state shallowly differs', () => { ++ const props = { index: 0, style: { top: 0, height: 10 }, label: 'row' }; ++ ++ expect( ++ shouldComponentUpdate.call( ++ { props, state: { count: 1 } }, ++ { index: 0, style: { top: 0, height: 10 }, label: 'row' }, ++ { count: 2 } ++ ) ++ ).toBe(true); ++ expect( ++ shouldComponentUpdate.call( ++ { props, state: { count: 1 } }, ++ { index: 0, style: { top: 0, height: 10 }, label: 'row' }, ++ { count: 1, expanded: true } ++ ) ++ ).toBe(true); ++ expect( ++ shouldComponentUpdate.call( ++ { props, state: { count: 1, expanded: true } }, ++ { index: 0, style: { top: 0, height: 10 }, label: 'row' }, ++ { count: 1 } ++ ) ++ ).toBe(true); ++ }); ++ ++ it('returns false when state is shallowly equal', () => { ++ const props = { index: 0, style: { top: 0, height: 10 }, label: 'row' }; ++ ++ expect( ++ shouldComponentUpdate.call( ++ { props, state: { count: 1, expanded: false } }, ++ { index: 0, style: { top: 0, height: 10 }, label: 'row' }, ++ { count: 1, expanded: false } ++ ) ++ ).toBe(false); ++ }); ++}); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,28 @@ ++#!/bin/bash ++set -euo pipefail ++cd /testbed ++ ++ ++npm install --ignore-scripts --no-audit --no-fund --legacy-peer-deps ++ ++ ++run_jest() { ++ local pattern="$1" ++ CI=1 ./node_modules/.bin/react-scripts test \ ++ --env=jsdom \ ++ --watchAll=false \ ++ --testPathPattern="$pattern" ++} ++ ++case "${1:-}" in ++ base) ++ run_jest "src/__tests__/(VariableSizeList|VariableSizeGrid)\\.js" ++ ;; ++ new) ++ run_jest "src/__tests__/(areEqual|shouldComponentUpdate)\\.js" ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-000601/tests/test.sh b/tasks/format-code-task-000601/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..5a8676edaac8b279509d5d4b48c0bf57e9dbfd9d --- /dev/null +++ b/tasks/format-code-task-000601/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +src/__tests__/areEqual.js +src/__tests__/shouldComponentUpdate.js +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000601/tests/test_command.sh b/tasks/format-code-task-000601/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-000601/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh base && bash /testbed/mimo_test_command.sh new \ No newline at end of file diff --git a/tasks/format-code-task-000606/environment/Dockerfile b/tasks/format-code-task-000606/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ab792473d03e7a7f3dc9167c7cc5566ff26b1175 --- /dev/null +++ b/tasks/format-code-task-000606/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:0d5f89c4af24df16e0595d0b752716f2f88331d4836a619fdac10fb1992bc0dc diff --git a/tasks/format-code-task-000606/environment/setup/files/blocklist b/tasks/format-code-task-000606/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000606/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000606/environment/setup/setup.sh b/tasks/format-code-task-000606/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000606/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000606/tests/test.patch b/tasks/format-code-task-000606/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..b3b03b5f9e3f0db87ffcb159666014b50044f5a0 --- /dev/null +++ b/tasks/format-code-task-000606/tests/test.patch @@ -0,0 +1,116 @@ +diff --git a/pkg/parser/paragraph_test.go b/pkg/parser/paragraph_test.go +index 5214918b..4c397eb3 100644 +--- a/pkg/parser/paragraph_test.go ++++ b/pkg/parser/paragraph_test.go +@@ -856,5 +856,91 @@ a foo image:foo.png[]` + Expect(ParseDocument(source)).To(MatchDocument(expected)) + }) + }) ++ ++ Context("list paragraphs", func() { ++ ++ It("inline image within a quote", func() { ++ source := `item:: ++This is the first line of the first paragraph. ++This is the second line of the first paragraph. +++ ++This is the first line of the continuation paragraph. ++This is the second line of the continuation paragraph. +++ ++This is the next continuation paragraph. +++ ++TIP: We can embed admonitions too! ++` ++ expected := types.Document{ ++ Elements: []interface{}{ ++ types.LabeledList{ ++ Items: []types.LabeledListItem{ ++ { ++ Level: 1, ++ Term: []interface{}{ ++ types.StringElement{ ++ Content: "item", ++ }, ++ }, ++ Elements: []interface{}{ ++ types.Paragraph{ ++ Lines: []interface{}{ ++ []interface{}{ ++ types.StringElement{ ++ Content: "This is the first line of the first paragraph.", ++ }, ++ }, ++ []interface{}{ ++ types.StringElement{ ++ Content: "This is the second line of the first paragraph.", ++ }, ++ }, ++ }, ++ }, ++ types.Paragraph{ ++ Lines: []interface{}{ ++ []interface{}{ ++ types.StringElement{ ++ Content: "This is the first line of the continuation paragraph.", ++ }, ++ }, ++ []interface{}{ ++ types.StringElement{ ++ Content: "This is the second line of the continuation paragraph.", ++ }, ++ }, ++ }, ++ }, ++ types.Paragraph{ ++ Lines: []interface{}{ ++ []interface{}{ ++ types.StringElement{ ++ Content: "This is the next continuation paragraph.", ++ }, ++ }, ++ }, ++ }, ++ types.Paragraph{ ++ Attributes: types.Attributes{ ++ types.AttrAdmonitionKind: types.Tip, ++ }, ++ Lines: []interface{}{ ++ []interface{}{ ++ types.StringElement{ ++ Content: "We can embed admonitions too!", ++ }, ++ }, ++ }, ++ }, ++ }, ++ }, ++ }, ++ }, ++ }, ++ } ++ Expect(ParseDocument(source)).To(MatchDocument(expected)) ++ }) ++ }) ++ + }) + }) +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,4 @@ ++H4sIAAAAAAAAA+3RsYrCQBDG8a19isE+ye6avVS+g4W9xCR44pmVzcbnN6ZRBLVR5PD/a2ZgBmbg ++S9f99q9eNe0xU++iB4VzYx3c1rE3zhpr7UzbmdLGuMIocW/76ErfxTKIqOB9fLT3bP5PpZf8Y9PF ++VeX3+7Kt0+73dTee5W8u+dsiz4f88x/tlOjXvXDfl+df1TIGv27qycbLuZU0O+w22aEMXRMySY6S ++VL5v49xIEvpWpsthaTFOp5NP/w8AAAAAAAAAAAAAAAB8sxPzMvhBACgAAA== +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000606/tests/test.sh b/tasks/format-code-task-000606/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..55a8778413692f8f8e7c3a5297c7e271af54e266 --- /dev/null +++ b/tasks/format-code-task-000606/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +pkg/parser/paragraph_test.go +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000606/tests/test_command.sh b/tasks/format-code-task-000606/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000606/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000630/environment/Dockerfile b/tasks/format-code-task-000630/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a0fc90bdc82928cd7f55c24292b5c82aa855629b --- /dev/null +++ b/tasks/format-code-task-000630/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:08d7c018e5669046cfd8cef27186b9b75aab14a9f2603b5bb70467f2e72629d3 diff --git a/tasks/format-code-task-000630/environment/setup/files/blocklist b/tasks/format-code-task-000630/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000630/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000630/environment/setup/setup.sh b/tasks/format-code-task-000630/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000630/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000630/tests/test.patch b/tasks/format-code-task-000630/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ce38f7073cfbafc349044504aee33c70a94ac32b --- /dev/null +++ b/tasks/format-code-task-000630/tests/test.patch @@ -0,0 +1,132 @@ +diff --git a/ts/src/test/static/request/bitso.json b/ts/src/test/static/request/bitso.json +index 30416e56be2a6..96c20ad9ff96b 100644 +--- a/ts/src/test/static/request/bitso.json ++++ b/ts/src/test/static/request/bitso.json +@@ -7,7 +7,7 @@ + { + "description": "market buy order", + "method": "createOrder", +- "url": "https://api.bitso.com/v3/orders", ++ "url": "https://bitso.com/api/v3/orders", + "input": [ + "XRP/USDT", + "market", +@@ -19,7 +19,7 @@ + { + "description": "market sell order", + "method": "createOrder", +- "url": "https://api.bitso.com/v3/orders", ++ "url": "https://bitso.com/api/v3/orders", + "input": [ + "XRP/USDT", + "market", +@@ -31,7 +31,7 @@ + { + "description": "limit buy order", + "method": "createOrder", +- "url": "https://api.bitso.com/v3/orders", ++ "url": "https://bitso.com/api/v3/orders", + "input": [ + "XRP/USDT", + "limit", +@@ -46,7 +46,7 @@ + { + "description": "cancel order", + "method": "cancelOrder", +- "url": "https://api.bitso.com/v3/orders/hG5WlCiC4OWRt2up", ++ "url": "https://bitso.com/api/v3/orders/hG5WlCiC4OWRt2up", + "input": [ + "hG5WlCiC4OWRt2up", + "XRP/USDT" +@@ -57,7 +57,7 @@ + { + "description": "cancelAllOrders", + "method": "cancelAllOrders", +- "url": "https://api.bitso.com/v3/orders/all", ++ "url": "https://bitso.com/api/v3/orders/all", + "input": [] + } + ], +@@ -65,7 +65,7 @@ + { + "description": "Fetch spot Balance", + "method": "fetchBalance", +- "url": "https://api.bitso.com/v3/balance?type=spot", ++ "url": "https://bitso.com/api/v3/balance?type=spot", + "input": [ + { + "type": "spot" +@@ -75,7 +75,7 @@ + { + "description": "Fetch swap Balance", + "method": "fetchBalance", +- "url": "https://api.bitso.com/v3/balance?type=swap", ++ "url": "https://bitso.com/api/v3/balance?type=swap", + "input": [ + { + "type": "swap" +@@ -87,7 +87,7 @@ + { + "description": "Fetch deposits", + "method": "fetchDeposits", +- "url": "https://api.bitso.com/v3/fundings", ++ "url": "https://bitso.com/api/v3/fundings", + "input": [] + } + ], +@@ -95,7 +95,7 @@ + { + "description": "fetch USDT ledger", + "method": "fetchLedger", +- "url": "https://api.bitso.com/v3/ledger", ++ "url": "https://bitso.com/api/v3/ledger", + "input": [ + "USDT" + ] +@@ -105,7 +105,7 @@ + { + "description": "spot fetchTrades", + "method": "fetchTrades", +- "url": "https://api.bitso.com/v3/trades?book=btc_usdt", ++ "url": "https://bitso.com/api/v3/trades?book=btc_usdt", + "input": [ + "BTC/USDT" + ] +@@ -115,7 +115,7 @@ + { + "description": "spot orderbook", + "method": "fetchOrderBook", +- "url": "https://api.bitso.com/v3/order_book?book=btc_usdt", ++ "url": "https://bitso.com/api/v3/order_book?book=btc_usdt", + "input": [ + "BTC/USDT" + ] +@@ -125,7 +125,7 @@ + { + "description": "spot ticker", + "method": "fetchTicker", +- "url": "https://api.bitso.com/v3/ticker?book=btc_usdt", ++ "url": "https://bitso.com/api/v3/ticker?book=btc_usdt", + "input": [ + "BTC/USDT" + ] +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,4 @@ ++H4sIAAAAAAAAA+3R3wrCIBiHYY+7Cm9gpqttN9J5tD/QoLSmiy6/zZNFUDspInof0E8+BZWfKvv2 ++UG8be1mKT9GDIstiHTzWuDZZakxuimKVCz2uUiGzj73oTu/DrpNSdM6FV+fm9n+UmvIPjQ/byh2P ++O1srv3/fHXP5G72a8tfFkP86N7mQ+n1PeO7P869qGYMvm3phT1cZ/DiWvqtiO05etbYNKniZJF1z ++7ofWZmzLsg3eLb79BQAAAAAAAAAAAAAAAOBv3QB3tIQPACgAAA== +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000630/tests/test.sh b/tasks/format-code-task-000630/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..bd388663e768e7699203052a727f975f9a067538 --- /dev/null +++ b/tasks/format-code-task-000630/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +ts/src/test/static/request/bitso.json +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000630/tests/test_command.sh b/tasks/format-code-task-000630/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000630/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000639/environment/Dockerfile b/tasks/format-code-task-000639/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8f045fee982fe92701a8620e64d18eb84f2cfed3 --- /dev/null +++ b/tasks/format-code-task-000639/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:47795eefd4733740b5b10a3aa3e16d3ca2f40d16a19fde33348a0e9b9461cf42 diff --git a/tasks/format-code-task-000639/environment/setup/files/blocklist b/tasks/format-code-task-000639/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000639/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000639/environment/setup/setup.sh b/tasks/format-code-task-000639/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000639/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000639/tests/test.patch b/tasks/format-code-task-000639/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e87ba604f3c341dafbdb89d97123f220ff347f00 --- /dev/null +++ b/tasks/format-code-task-000639/tests/test.patch @@ -0,0 +1,282 @@ +diff --git a/packages/opencensus-exporter-zpages/test/test-zpages-json.ts b/packages/opencensus-exporter-zpages/test/test-zpages-json.ts +new file mode 100644 +index 0000000..7025c65 +--- /dev/null ++++ b/packages/opencensus-exporter-zpages/test/test-zpages-json.ts +@@ -0,0 +1,191 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++import {types} from '@opencensus/opencensus-core'; ++import * as assert from 'assert'; ++import * as http from 'http'; ++ ++import {ZpagesExporter, ZpagesExporterOptions} from '../src/zpages'; ++ ++const tracing = require('@opencensus/nodejs'); ++ ++ ++const options = { ++ port: 8083, ++ spanNames: ['predefined/span1'], ++ startServer: false ++} as ZpagesExporterOptions; ++ ++const serverUrl = 'http://localhost:' + options.port; ++ ++const LATENCY_BUCKETS = [ ++ 'ZERO_MICROSx10', 'MICROSx10_MICROSx100', 'MICROSx100_MILLIx1', ++ 'MILLIx1_MILLIx10', 'MILLIx10_MILLIx100', 'MILLIx100_SECONDx1', ++ 'SECONDx1_SECONDx10', 'SECONDx10_SECONDx100', 'SECONDx100_MAX' ++]; ++ ++ ++function get(path: string): Promise<{statusCode: number, body: string}> { ++ return new Promise((resolve, reject) => { ++ http.get(serverUrl + path, (res) => { ++ let body = ''; ++ res.on('data', (chunk) => body += chunk); ++ res.on('end', () => resolve({statusCode: res.statusCode, body})); ++ }) ++ .on('error', reject); ++ }); ++} ++ ++describe('Zpages JSON endpoints', () => { ++ let zpages: ZpagesExporter; ++ let runningTraceId: string; ++ let runningId: string; ++ ++ before((done) => { ++ zpages = new ZpagesExporter(options); ++ tracing.start({samplingRate: 1}); ++ tracing.registerExporter(zpages); ++ ++ ++ tracing.tracer.startRootSpan( ++ {name: 'rootJsonTest'}, (root: types.RootSpan) => { ++ const child = tracing.tracer.startChildSpan('childJsonTest', 'type'); ++ child.end(); ++ root.end(); ++ }); ++ ++ ++ tracing.tracer.startRootSpan( ++ {name: 'runningJsonTest'}, (running: types.RootSpan) => { ++ runningTraceId = running.traceId; ++ runningId = running.id; ++ }); ++ ++ zpages.startServer(done); ++ }); ++ ++ after(() => { ++ zpages.stopServer(); ++ }); ++ ++ describe('/tracez?json=1', () => { ++ it('responds with valid JSON', async () => { ++ const res = await get('/tracez?json=1'); ++ assert.strictEqual(res.statusCode, 200); ++ assert.doesNotThrow(() => JSON.parse(res.body)); ++ }); ++ ++ it('reports a spanCell per span name, ordered ascending by name', ++ async () => { ++ const data = JSON.parse((await get('/tracez?json=1')).body); ++ assert.ok(Array.isArray(data.spanCells)); ++ const names = data.spanCells.map((c: {name: string}) => c.name); ++ ++ for (const expected ++ of ['predefined/span1', 'rootJsonTest', 'childJsonTest', ++ 'runningJsonTest']) { ++ assert.ok( ++ names.indexOf(expected) !== -1, ++ `expected spanCell for "${expected}"`); ++ } ++ ++ const sorted = names.slice().sort(); ++ assert.deepStrictEqual(names, sorted); ++ }); ++ ++ it('exposes RUNNING/ERRORS/latencies counters per cell', async () => { ++ const data = JSON.parse((await get('/tracez?json=1')).body); ++ const byName: {[k: string]: any} = {}; ++ for (const cell of data.spanCells) byName[cell.name] = cell; ++ ++ ++ for (const cell of data.spanCells) { ++ assert.strictEqual(typeof cell.RUNNING, 'number'); ++ assert.strictEqual(typeof cell.ERRORS, 'number'); ++ for (const bucket of LATENCY_BUCKETS) { ++ assert.strictEqual( ++ typeof cell.latencies[bucket], 'number', ++ `cell "${cell.name}" missing latency bucket "${bucket}"`); ++ } ++ } ++ ++ ++ const child = byName['childJsonTest']; ++ const latencySum = LATENCY_BUCKETS.reduce( ++ (acc, b) => acc + child.latencies[b], 0); ++ assert.strictEqual(latencySum, 1); ++ assert.strictEqual(child.RUNNING, 0); ++ assert.strictEqual(child.ERRORS, 0); ++ ++ ++ const running = byName['runningJsonTest']; ++ assert.ok(running.RUNNING >= 1); ++ const runningLatencySum = LATENCY_BUCKETS.reduce( ++ (acc, b) => acc + running.latencies[b], 0); ++ assert.strictEqual(runningLatencySum, 0); ++ }); ++ ++ it('returns null selectedTraces when no tracename is given', async () => { ++ const data = JSON.parse((await get('/tracez?json=1')).body); ++ assert.strictEqual(data.selectedTraces, null); ++ }); ++ ++ it('serializes selected traces without circular-reference errors', ++ async () => { ++ const res = await get( ++ '/tracez?json=1&tracename=runningJsonTest&type=RUNNING'); ++ assert.strictEqual(res.statusCode, 200); ++ const data = JSON.parse(res.body); ++ assert.ok(data.selectedTraces); ++ assert.strictEqual(data.selectedTraces.name, 'runningJsonTest'); ++ assert.ok(Array.isArray(data.selectedTraces.traces)); ++ assert.ok(data.selectedTraces.traces.length >= 1); ++ const trace = data.selectedTraces.traces[0]; ++ assert.strictEqual(trace.traceId, runningTraceId); ++ assert.strictEqual(trace.id, runningId); ++ }); ++ }); ++ ++ describe('/tracez (HTML)', () => { ++ it('still renders HTML when json=1 is absent', async () => { ++ const res = await get('/tracez'); ++ assert.strictEqual(res.statusCode, 200); ++ assert.ok( ++ res.body.indexOf(' { ++ it('responds with the sampling configuration as JSON', async () => { ++ const res = await get('/traceconfigz?json=1'); ++ assert.strictEqual(res.statusCode, 200); ++ const data = JSON.parse(res.body); ++ assert.strictEqual(data.samplingProbability, 1); ++ assert.strictEqual(typeof data.defaultConfig.samplingRate, 'number'); ++ }); ++ }); ++ ++ describe('/traceconfigz (HTML)', () => { ++ it('still renders HTML when json=1 is absent', async () => { ++ const res = await get('/traceconfigz'); ++ assert.strictEqual(res.statusCode, 200); ++ assert.ok( ++ res.body.indexOf(' "$BUILDER" <<'EOF' ++const fs = require('fs'); ++const path = require('path'); ++const pkgRoot = path.resolve(process.argv[2]); ++function loadTs() { ++ for (const base of [pkgRoot, '/testbed']) { ++ const p = path.join(base, 'node_modules', 'typescript'); ++ if (fs.existsSync(p)) return require(p); ++ } ++ return require('typescript'); ++} ++const ts = loadTs(); ++function walk(dir, out) { ++ for (const e of fs.readdirSync(dir, {withFileTypes: true})) { ++ const p = path.join(dir, e.name); ++ if (e.isDirectory()) { ++ if (e.name === 'node_modules' || e.name === 'build') continue; ++ walk(p, out); ++ } else { ++ out.push(p); ++ } ++ } ++ return out; ++} ++const srcDirs = ['src', 'test'].map(d => path.join(pkgRoot, d)) ++ .filter(d => fs.existsSync(d)); ++const files = []; ++for (const d of srcDirs) walk(d, files); ++const options = { ++ module: ts.ModuleKind.CommonJS, ++ target: ts.ScriptTarget.ES2017, ++ esModuleInterop: false, ++ inlineSourceMap: false, ++}; ++for (const f of files) { ++ const outPath = path.join(pkgRoot, 'build', path.relative(pkgRoot, f)); ++ if (f.endsWith('.d.ts')) continue; ++ fs.mkdirSync(path.dirname(outPath), {recursive: true}); ++ if (f.endsWith('.ts')) { ++ const source = fs.readFileSync(f, 'utf8'); ++ const result = ts.transpileModule(source, {compilerOptions: options, fileName: f}); ++ fs.writeFileSync(outPath.replace(/\.ts$/, '.js'), result.outputText); ++ } else { ++ fs.copyFileSync(f, outPath); ++ } ++} ++EOF ++ ++ ++ ++for p in packages/*/; do ++ node "$BUILDER" "$p" || true ++done ++ ++MOCHA="$PKG/node_modules/.bin/mocha" ++ ++ ++"$MOCHA" "$PKG/build/test/test-zpages.js" ++ ++ ++"$MOCHA" "$PKG/build/test/test-zpages-json.js" diff --git a/tasks/format-code-task-000639/tests/test.sh b/tasks/format-code-task-000639/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..a117bddf4482af52e26bd41b50eccd5f27c8b5a7 --- /dev/null +++ b/tasks/format-code-task-000639/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +packages/opencensus-exporter-zpages/test/test-zpages-json.ts +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000639/tests/test_command.sh b/tasks/format-code-task-000639/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000639/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000652/environment/Dockerfile b/tasks/format-code-task-000652/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..29fa0a7087b506ecaeab8a327b8a538ca707f068 --- /dev/null +++ b/tasks/format-code-task-000652/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:98683347f9717caae1ec75549f83d753004b86ed5884e363bcd2fc2477c1bdeb diff --git a/tasks/format-code-task-000652/environment/setup/files/blocklist b/tasks/format-code-task-000652/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000652/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000652/environment/setup/setup.sh b/tasks/format-code-task-000652/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000652/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000652/tests/test.patch b/tasks/format-code-task-000652/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..15580dcafaaf3c34480e5b0ab099a297e7cfeea5 --- /dev/null +++ b/tasks/format-code-task-000652/tests/test.patch @@ -0,0 +1,105 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..b204b6dd0 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m unittest tests.chainer_tests.functions_tests.loss_tests.test_softmax_cross_entropy_empty -v"] ++} +diff --git a/tests/chainer_tests/functions_tests/loss_tests/test_softmax_cross_entropy_empty.py b/tests/chainer_tests/functions_tests/loss_tests/test_softmax_cross_entropy_empty.py +new file mode 100644 +index 000000000..b61252fd5 +--- /dev/null ++++ b/tests/chainer_tests/functions_tests/loss_tests/test_softmax_cross_entropy_empty.py +@@ -0,0 +1,77 @@ ++import unittest ++ ++import numpy ++ ++import chainer ++from chainer import functions ++ ++ ++class TestSoftmaxCrossEntropyEmptyInputCPU(unittest.TestCase): ++ ++ ++ ++ ++ ++ ++ def test_forward_3d_reduce_mean_returns_scalar_zero(self): ++ x = numpy.zeros((0, 2, 2), dtype=numpy.float32) ++ t = numpy.zeros((0, 2), dtype=numpy.int32) ++ loss = functions.softmax_cross_entropy(x, t) ++ self.assertEqual(loss.data.shape, ()) ++ self.assertEqual(loss.data.dtype, numpy.float32) ++ ++ self.assertTrue(numpy.isfinite(loss.data)) ++ self.assertEqual(float(loss.data), 0.0) ++ ++ def test_forward_3d_reduce_no_returns_empty_array(self): ++ x = numpy.zeros((0, 2, 2), dtype=numpy.float32) ++ t = numpy.zeros((0, 2), dtype=numpy.int32) ++ loss = functions.softmax_cross_entropy(x, t, reduce='no') ++ self.assertEqual(loss.data.shape, t.shape) ++ self.assertEqual(loss.data.dtype, numpy.float32) ++ self.assertEqual(loss.data.size, 0) ++ ++ def test_forward_2d_reduce_mean_returns_scalar_zero(self): ++ x = numpy.zeros((0, 5), dtype=numpy.float32) ++ t = numpy.zeros((0,), dtype=numpy.int32) ++ loss = functions.softmax_cross_entropy(x, t) ++ self.assertEqual(loss.data.shape, ()) ++ self.assertEqual(loss.data.dtype, numpy.float32) ++ self.assertTrue(numpy.isfinite(loss.data)) ++ self.assertEqual(float(loss.data), 0.0) ++ ++ def test_backward_3d_does_not_raise_and_grad_matches_x_shape(self): ++ ++ ++ ++ x = chainer.Variable(numpy.zeros((0, 2, 2), dtype=numpy.float32)) ++ t = numpy.zeros((0, 2), dtype=numpy.int32) ++ loss = functions.softmax_cross_entropy(x, t) ++ loss.backward() ++ self.assertIsNotNone(x.grad) ++ self.assertEqual(x.grad.shape, (0, 2, 2)) ++ self.assertEqual(x.grad.dtype, numpy.float32) ++ self.assertEqual(x.grad.size, 0) ++ ++ def test_backward_2d_does_not_raise_and_grad_matches_x_shape(self): ++ x = chainer.Variable(numpy.zeros((0, 5), dtype=numpy.float32)) ++ t = numpy.zeros((0,), dtype=numpy.int32) ++ loss = functions.softmax_cross_entropy(x, t) ++ loss.backward() ++ self.assertIsNotNone(x.grad) ++ self.assertEqual(x.grad.shape, (0, 5)) ++ self.assertEqual(x.grad.dtype, numpy.float32) ++ ++ def test_backward_3d_reduce_no(self): ++ x = chainer.Variable(numpy.zeros((0, 2, 2), dtype=numpy.float32)) ++ t = numpy.zeros((0, 2), dtype=numpy.int32) ++ loss = functions.softmax_cross_entropy(x, t, reduce='no') ++ ++ loss.grad = numpy.zeros(loss.data.shape, dtype=loss.data.dtype) ++ loss.backward() ++ self.assertEqual(x.grad.shape, (0, 2, 2)) ++ self.assertEqual(x.grad.dtype, numpy.float32) ++ ++ ++if __name__ == '__main__': ++ unittest.main() +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m unittest tests.chainer_tests.functions_tests.loss_tests.test_softmax_cross_entropy_empty -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000652/tests/test.sh b/tasks/format-code-task-000652/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..c01151bb646f53964a1aada436c6e7d9c0652688 --- /dev/null +++ b/tasks/format-code-task-000652/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test_commands.json +tests/chainer_tests/functions_tests/loss_tests/test_softmax_cross_entropy_empty.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000652/tests/test_command.sh b/tasks/format-code-task-000652/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000652/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000655/environment/Dockerfile b/tasks/format-code-task-000655/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..03084f8a7cf4bb8da8b4b9cad7190cb55617fdc5 --- /dev/null +++ b/tasks/format-code-task-000655/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:73f5c9fc3bf815afa9a8c353a73eae8c62a3c9224bcab3e5d5076348df65c369 diff --git a/tasks/format-code-task-000655/environment/setup/files/blocklist b/tasks/format-code-task-000655/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000655/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000655/environment/setup/setup.sh b/tasks/format-code-task-000655/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000655/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000655/tests/test.patch b/tasks/format-code-task-000655/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e9aafaf2244a07f3ab0e26309c59fe225c0d3054 --- /dev/null +++ b/tasks/format-code-task-000655/tests/test.patch @@ -0,0 +1,271 @@ +diff --git a/tests/test_replay_buffer.py b/tests/test_replay_buffer.py +index ebc4ff49..35b17892 100644 +--- a/tests/test_replay_buffer.py ++++ b/tests/test_replay_buffer.py +@@ -487,6 +487,158 @@ class TestPrioritizedEpisodicReplayBuffer(unittest.TestCase): + self.assertEqual(t0['next_action'], t1['action']) + + ++def _make_n_step_replay_buffer(replay_buffer_type, num_steps): ++ if replay_buffer_type == 'ReplayBuffer': ++ return replay_buffer.ReplayBuffer(capacity=None, num_steps=num_steps) ++ if replay_buffer_type == 'PrioritizedReplayBuffer': ++ return replay_buffer.PrioritizedReplayBuffer( ++ capacity=None, num_steps=num_steps) ++ assert False ++ ++ ++def _append_marked_transition(rbuf, env_id, step, is_state_terminal=False): ++ rbuf.append( ++ state=(env_id, step), ++ action=(env_id, 'action', step), ++ reward=step, ++ next_state=(env_id, step + 1), ++ next_action=(env_id, 'action', step + 1), ++ is_state_terminal=is_state_terminal, ++ env_id=env_id) ++ ++ ++def _sample_all_sequences(rbuf): ++ return rbuf.sample(len(rbuf)) ++ ++ ++def _sequence_envs(sequence): ++ return set(transition['state'][0] for transition in sequence) ++ ++ ++def _sequence_signature(sequence): ++ return ( ++ next(iter(_sequence_envs(sequence))), ++ tuple(transition['state'][1] for transition in sequence), ++ ) ++ ++ ++@testing.parameterize(*testing.product({ ++ 'replay_buffer_type': ['ReplayBuffer', 'PrioritizedReplayBuffer'], ++})) ++class TestReplayBufferWithEnvID(unittest.TestCase): ++ ++ def test_interleaved_env_sequences_do_not_mix(self): ++ rbuf = _make_n_step_replay_buffer(self.replay_buffer_type, 3) ++ ++ schedule = [ ++ ('left', 0), ++ ('right', 0), ++ ('third', 0), ++ ('left', 1), ++ ('right', 1), ++ ('left', 2), ++ ('third', 1), ++ ('right', 2), ++ ] ++ for env_id, step in schedule: ++ _append_marked_transition(rbuf, env_id, step) ++ ++ sequences = _sample_all_sequences(rbuf) ++ self.assertEqual(len(sequences), 2) ++ for sequence in sequences: ++ self.assertEqual(len(_sequence_envs(sequence)), 1) ++ ++ observed = sorted( ++ (next(iter(_sequence_envs(sequence))), len(sequence)) ++ for sequence in sequences) ++ self.assertEqual(observed, [('left', 3), ('right', 3)]) ++ ++ def test_stop_current_episode_is_env_scoped(self): ++ rbuf = _make_n_step_replay_buffer(self.replay_buffer_type, 3) ++ ++ _append_marked_transition(rbuf, 'alpha', 0) ++ _append_marked_transition(rbuf, 'beta', 0) ++ _append_marked_transition(rbuf, 'alpha', 1) ++ ++ rbuf.stop_current_episode(env_id='alpha') ++ ++ _append_marked_transition(rbuf, 'beta', 1) ++ _append_marked_transition(rbuf, 'beta', 2) ++ ++ sequences = _sample_all_sequences(rbuf) ++ observed = sorted( ++ _sequence_signature(sequence) ++ for sequence in sequences) ++ self.assertEqual(observed, [ ++ ('alpha', (0, 1)), ++ ('alpha', (1,)), ++ ('beta', (0, 1, 2)), ++ ]) ++ for sequence in sequences: ++ self.assertEqual(len(_sequence_envs(sequence)), 1) ++ ++ ++def _make_episodic_replay_buffer(replay_buffer_type): ++ if replay_buffer_type == 'EpisodicReplayBuffer': ++ return replay_buffer.EpisodicReplayBuffer(capacity=None) ++ if replay_buffer_type == 'PrioritizedEpisodicReplayBuffer': ++ return replay_buffer.PrioritizedEpisodicReplayBuffer(capacity=None) ++ assert False ++ ++ ++@testing.parameterize(*testing.product({ ++ 'replay_buffer_type': ['EpisodicReplayBuffer', ++ 'PrioritizedEpisodicReplayBuffer'], ++})) ++class TestEpisodicReplayBufferWithEnvID(unittest.TestCase): ++ ++ def test_interleaved_episodes_do_not_mix(self): ++ rbuf = _make_episodic_replay_buffer(self.replay_buffer_type) ++ ++ object_env = object() ++ _append_marked_transition(rbuf, 'left', 0) ++ _append_marked_transition(rbuf, 'right', 0) ++ _append_marked_transition(rbuf, 'left', 1, is_state_terminal=True) ++ _append_marked_transition(rbuf, object_env, 0) ++ _append_marked_transition(rbuf, 'right', 1) ++ _append_marked_transition(rbuf, 'right', 2, ++ is_state_terminal=True) ++ ++ rbuf.stop_current_episode(env_id=object_env) ++ ++ episodes = rbuf.sample_episodes(rbuf.n_episodes, max_len=10) ++ if isinstance(episodes, tuple): ++ episodes = episodes[0] ++ observed = sorted( ++ (repr(next(iter(_sequence_envs(episode)))), len(episode)) ++ for episode in episodes) ++ expected = sorted([ ++ (repr('left'), 2), ++ (repr('right'), 3), ++ (repr(object_env), 1), ++ ]) ++ self.assertEqual(observed, expected) ++ for episode in episodes: ++ self.assertEqual(len(_sequence_envs(episode)), 1) ++ ++ ++class TestReplayBufferAppendKwargs(unittest.TestCase): ++ ++ def test_extra_fields_are_sampled(self): ++ rbuf = replay_buffer.ReplayBuffer(capacity=None, num_steps=1) ++ ++ rbuf.append( ++ state='state', ++ action='action', ++ reward=1, ++ next_state='next_state', ++ next_action='next_action', ++ custom_marker=('marker', 7)) ++ ++ experience = rbuf.sample(1)[0][0] ++ self.assertEqual(experience['custom_marker'], ('marker', 7)) ++ ++ + class TestReplayBufferFail(unittest.TestCase): + + def setUp(self): +diff --git a/tests/test_agent_batch_replay_env_id.py b/tests/test_agent_batch_replay_env_id.py +new file mode 100644 +index e69de29b..f69829a2 100644 +--- /dev/null ++++ b/tests/test_agent_batch_replay_env_id.py +@@ -0,0 +1,66 @@ ++import unittest ++ ++from chainerrl.agents import ddpg ++from chainerrl.agents import dqn ++ ++ ++class _RecordingReplayBuffer(object): ++ ++ def __init__(self): ++ self.append_env_ids = [] ++ self.stop_env_ids = [] ++ ++ def append(self, state, action, reward, next_state=None, next_action=None, ++ is_state_terminal=False, **kwargs): ++ self.append_env_ids.append(kwargs.get('env_id', None)) ++ ++ def stop_current_episode(self, **kwargs): ++ self.stop_env_ids.append(kwargs.get('env_id', None)) ++ ++ ++class _RecordingReplayUpdater(object): ++ ++ def __init__(self): ++ self.calls = [] ++ ++ def update_if_necessary(self, t): ++ self.calls.append(t) ++ ++ ++def _make_minimal_agent(agent_type): ++ agent = agent_type.__new__(agent_type) ++ agent.batch_last_obs = ['prev0', 'prev1', 'prev2', 'prev3'] ++ agent.batch_last_action = ['act0', 'act1', 'act2', 'act3'] ++ agent.replay_buffer = _RecordingReplayBuffer() ++ agent.replay_updater = _RecordingReplayUpdater() ++ agent.t = 0 ++ agent.target_update_interval = 100 ++ agent.sync_target_network = lambda: None ++ return agent ++ ++ ++class TestBatchReplayEnvID(unittest.TestCase): ++ ++ def _check_batch_observe_and_train_scopes_replay(self, agent_type): ++ agent = _make_minimal_agent(agent_type) ++ ++ agent_type.batch_observe_and_train( ++ agent, ++ batch_obs=['obs0', 'obs1', 'obs2', 'obs3'], ++ batch_reward=[0.0, 1.0, 2.0, 3.0], ++ batch_done=[False, True, False, False], ++ batch_reset=[False, False, False, True]) ++ ++ append_env_ids = agent.replay_buffer.append_env_ids ++ stop_env_ids = agent.replay_buffer.stop_env_ids ++ ++ self.assertEqual(len(append_env_ids), 4) ++ self.assertEqual(len(set(append_env_ids)), 4) ++ self.assertEqual(stop_env_ids, ++ [append_env_ids[1], append_env_ids[3]]) ++ ++ def test_dqn_batch_observe_and_train_scopes_replay_by_batch_position(self): ++ self._check_batch_observe_and_train_scopes_replay(dqn.DQN) ++ ++ def test_ddpg_batch_observe_and_train_scopes_replay_by_batch_position(self): ++ self._check_batch_observe_and_train_scopes_replay(ddpg.DDPG) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,31 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++ ++dev-switch python3 3.11 2>/dev/null || true ++python3 -m pip install --no-input -e . 'numpy<2' 'setuptools<60' opencv-python-headless pytest 2>/dev/null || true ++ ++ ++case "${1:-}" in ++ base) ++ python3 -m pytest tests/test_replay_buffer.py -v \ ++ --ignore=tests/test_agent_batch_replay_env_id.py \ ++ -k 'not TestReplayBufferWithEnvID and not TestEpisodicReplayBufferWithEnvID and not TestReplayBufferAppendKwargs' ++ ;; ++ new) ++ python3 -m pytest tests/test_replay_buffer.py \ ++ -k 'TestReplayBufferWithEnvID or TestEpisodicReplayBufferWithEnvID or TestReplayBufferAppendKwargs' \ ++ -v ++ replay_exit=$? ++ python3 -m pytest tests/test_agent_batch_replay_env_id.py -v ++ agent_exit=$? ++ if [ "$replay_exit" -ne 0 ] || [ "$agent_exit" -ne 0 ]; then ++ exit 1 ++ fi ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-000655/tests/test.sh b/tasks/format-code-task-000655/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..3a06df4a581eaf08fbf8ce33b4e7d875ee1460cc --- /dev/null +++ b/tasks/format-code-task-000655/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/test_replay_buffer.py +tests/test_agent_batch_replay_env_id.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000655/tests/test_command.sh b/tasks/format-code-task-000655/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-000655/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh base && bash /testbed/mimo_test_command.sh new \ No newline at end of file diff --git a/tasks/format-code-task-000745/environment/Dockerfile b/tasks/format-code-task-000745/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..bc3764dfbd99b1599f83720c133036a57dd22fab --- /dev/null +++ b/tasks/format-code-task-000745/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:90fe44865c66aa25a08edc33c21e48e1f103a742229d119cae68a8794a1d924f diff --git a/tasks/format-code-task-000745/environment/setup/files/blocklist b/tasks/format-code-task-000745/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000745/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000745/environment/setup/setup.sh b/tasks/format-code-task-000745/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000745/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000745/tests/test.patch b/tasks/format-code-task-000745/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..afac0d20a7f94b7ddd082207f72a49c62b61c76d --- /dev/null +++ b/tasks/format-code-task-000745/tests/test.patch @@ -0,0 +1,57 @@ +diff --git a/python_modules/dagster/dagster_tests/definitions_tests/auto_materialize_tests/test_asset_daemon.py b/python_modules/dagster/dagster_tests/definitions_tests/auto_materialize_tests/test_asset_daemon.py +index 66aa99d6c73a5..f19c566c8bbdf 100644 +--- a/python_modules/dagster/dagster_tests/definitions_tests/auto_materialize_tests/test_asset_daemon.py ++++ b/python_modules/dagster/dagster_tests/definitions_tests/auto_materialize_tests/test_asset_daemon.py +@@ -114,7 +114,31 @@ def _get_threadpool_executor(instance: DagsterInstance): + executor=in_process_executor, + ) + ++first_asset_in_other_repo = [ ++ asset_def("asset1", auto_materialize_policy=AutoMaterializePolicy.eager()) ++] ++ ++other_repo = create_repository_using_definitions_args( ++ name="extra_repository", ++ assets=first_asset_in_other_repo, ++ executor=in_process_executor, ++) ++ ++second_asset_in_our_repo = AssetDaemonScenarioState( ++ asset_specs=[AssetSpec("asset2", deps=["asset1"])], ++ additional_repositories=[other_repo], ++) ++ ++cross_repo_sensor_scenario = AssetDaemonScenario( ++ id="two_cross_repo_assets", ++ initial_state=second_asset_in_our_repo.with_all_eager(), ++ ++ execution_fn=lambda state: state.evaluate_tick().assert_requested_runs(), ++) ++ ++ + auto_materialize_sensor_scenarios = [ ++ cross_repo_sensor_scenario, + AssetDaemonScenario( + id="basic_hourly_cron_unpartitioned", + initial_state=one_asset.with_asset_properties( +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,5 @@ ++H4sIAAAAAAAAA+3S32rDIBQGcK/zFI5dJ1FXm8cRU90iRC3RlHZPX5t1fxhsvWkZZd/v5sjnAcVj ++089uNMqGXUtuhRWdlEstvtdlzaXgvBNSiI4wztdMEipvdqMv5pT1RCmZYsy/9V3av1PN5/yzTVlt ++ovc6mCYN1zvj0vyFEB/zZ0+rMv/VmnNC2fWu8LN/Pv/Hh7Z3oe11GqqNocsn6K2ptoc8xEBrT8uq ++ZPQtUD6aebSpNfolZTu9V3XqKal9dsFlF0M6J3rOUXldWpwe3as9x8tf0ynZrIy2PoZme6D1nta7 ++6q9fBAAAAAAAAAAAAAAAAAAAAADgfhwB3ruubwAoAAA= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000745/tests/test.sh b/tasks/format-code-task-000745/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..8c31f474a2a2bc1d9cc697a240def8dd8b7aed1f --- /dev/null +++ b/tasks/format-code-task-000745/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +python_modules/dagster/dagster_tests/definitions_tests/auto_materialize_tests/test_asset_daemon.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000745/tests/test_command.sh b/tasks/format-code-task-000745/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000745/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000780/environment/Dockerfile b/tasks/format-code-task-000780/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7fda3f112a50ae6a932005c1f46b087310139216 --- /dev/null +++ b/tasks/format-code-task-000780/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:796ea1af6e74bc9589e6657e2ba8633899ed79ce521103bee29429c77323c235 diff --git a/tasks/format-code-task-000780/environment/setup/files/blocklist b/tasks/format-code-task-000780/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000780/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000780/environment/setup/setup.sh b/tasks/format-code-task-000780/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000780/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000780/tests/test.patch b/tasks/format-code-task-000780/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..af99b2f2fd0fdcf533daf5ef8de3774c765e5ecf --- /dev/null +++ b/tasks/format-code-task-000780/tests/test.patch @@ -0,0 +1,170 @@ +diff --git a/internal/mempool/mempool_test.go b/internal/mempool/mempool_test.go +index 3593a6d6b4..3339be5162 100644 +--- a/internal/mempool/mempool_test.go ++++ b/internal/mempool/mempool_test.go +@@ -1046,7 +1046,7 @@ func TestTicketPurchaseOrphan(t *testing.T) { + // in the stage pool to enter the mempool. + harness.AddFakeUTXO(tx, int64(ticket.MsgTx().TxIn[0].BlockHeight), + wire.NullBlockIndex) +- harness.txPool.RemoveTransaction(tx, false, noTreasury, noAutoRevocations) ++ harness.txPool.RemoveTransaction(tx, false) + harness.txPool.MaybeAcceptDependents(tx, noTreasury) + + testPoolMembership(tc, tx, false, false) +@@ -1455,7 +1455,7 @@ func TestBasicOrphanRemoval(t *testing.T) { + t.Fatalf("unable to create signed tx: %v", err) + } + +- harness.txPool.RemoveOrphan(nonChainedOrphanTx, noTreasury, noAutoRevocations) ++ harness.txPool.RemoveOrphan(nonChainedOrphanTx) + testPoolMembership(tc, nonChainedOrphanTx, false, false) + for _, tx := range chainedTxns[1 : maxOrphans+1] { + testPoolMembership(tc, tx, true, false) +@@ -1464,7 +1464,7 @@ func TestBasicOrphanRemoval(t *testing.T) { + // Attempt to remove an orphan that has an existing redeemer but itself + // is not present and ensure the state of all other orphans (including + // the one that redeems it) are unaffected. +- harness.txPool.RemoveOrphan(chainedTxns[0], noTreasury, noAutoRevocations) ++ harness.txPool.RemoveOrphan(chainedTxns[0]) + testPoolMembership(tc, chainedTxns[0], false, false) + for _, tx := range chainedTxns[1 : maxOrphans+1] { + testPoolMembership(tc, tx, true, false) +@@ -1473,7 +1473,7 @@ func TestBasicOrphanRemoval(t *testing.T) { + // Remove each orphan one-by-one and ensure they are removed as + // expected. + for _, tx := range chainedTxns[1 : maxOrphans+1] { +- harness.txPool.RemoveOrphan(tx, noTreasury, noAutoRevocations) ++ harness.txPool.RemoveOrphan(tx) + testPoolMembership(tc, tx, false, false) + } + } +@@ -1524,8 +1524,7 @@ func TestOrphanChainRemoval(t *testing.T) { + // remove redeemer flag set and ensure that only the first orphan was + // removed. + harness.txPool.mtx.Lock() +- harness.txPool.removeOrphan(chainedTxns[1], false, noTreasury, +- noAutoRevocations) ++ harness.txPool.removeOrphan(chainedTxns[1], false) + harness.txPool.mtx.Unlock() + testPoolMembership(tc, chainedTxns[1], false, false) + for _, tx := range chainedTxns[2 : maxOrphans+1] { +@@ -1535,8 +1534,7 @@ func TestOrphanChainRemoval(t *testing.T) { + // Remove the first remaining orphan that starts the orphan chain with + // the remove redeemer flag set and ensure they are all removed. + harness.txPool.mtx.Lock() +- harness.txPool.removeOrphan(chainedTxns[2], true, noTreasury, +- noAutoRevocations) ++ harness.txPool.removeOrphan(chainedTxns[2], true) + harness.txPool.mtx.Unlock() + for _, tx := range chainedTxns[2 : maxOrphans+1] { + testPoolMembership(tc, tx, false, false) +@@ -1989,7 +1987,7 @@ func TestMaxVoteDoubleSpendRejection(t *testing.T) { + // Remove one of the votes from the pool and ensure it is not in the orphan + // pool, not in the transaction pool, and not reported as available. + vote := votes[2] +- harness.txPool.RemoveTransaction(vote, true, noTreasury, noAutoRevocations) ++ harness.txPool.RemoveTransaction(vote, true) + testPoolMembership(tc, vote, false, false) + + // Add one of the votes that was rejected above due to the pool being at the +@@ -2091,7 +2089,7 @@ func TestDuplicateVoteRejection(t *testing.T) { + + // Remove the original vote from the pool and ensure it is not in the orphan + // pool, not in the transaction pool, and not reported as available. +- harness.txPool.RemoveTransaction(vote, true, noTreasury, noAutoRevocations) ++ harness.txPool.RemoveTransaction(vote, true) + testPoolMembership(tc, vote, false, false) + + // Add the duplicate vote which should now be accepted. Also, ensure it is +@@ -2320,8 +2318,7 @@ func TestRemoveDoubleSpends(t *testing.T) { + + // If a staged transaction double-spends an input due to a reorg, + // it should be removed from the stage pool. +- tc.harness.txPool.RemoveDoubleSpends(doubleSpendTx, noTreasury, +- noAutoRevocations) ++ tc.harness.txPool.RemoveDoubleSpends(doubleSpendTx) + + // FetchTransaction should not be able to retrieve the ticket anymore. + _, err = harness.txPool.FetchTransaction(ticket.Hash()) +@@ -2491,7 +2488,7 @@ func TestHandlesTSpends(t *testing.T) { + + // Remove the first tspend from the mempool and assert TSpendHashes() + // is working as intended. +- harness.txPool.RemoveTransaction(tspends[0], true, true, noAutoRevocations) ++ harness.txPool.RemoveTransaction(tspends[0], true) + testPoolMembership(tc, tspends[0], false, false) + assertTSpendHashes(tspends[1:maxTSpends]) + +@@ -2502,7 +2499,7 @@ func TestHandlesTSpends(t *testing.T) { + // Remove all tspends from the mempool and ensure TSpendHashes() is + // empty again. + for _, tx := range tspends[1 : maxTSpends+1] { +- harness.txPool.RemoveTransaction(tx, true, true, noAutoRevocations) ++ harness.txPool.RemoveTransaction(tx, true) + testPoolMembership(tc, tx, false, false) + } + assertTSpendHashes(nil) +@@ -2690,7 +2687,7 @@ func TestHandlesTAdds(t *testing.T) { + t.Fatalf("ProcessTransaction: failed to accept valid tadd %v", err) + } + testPoolMembership(tc, tx, false, true) +- harness.txPool.RemoveTransaction(tx, true, true, noAutoRevocations) ++ harness.txPool.RemoveTransaction(tx, true) + } + + // Create a few valid tadds that can enter the mempool. Generate a TAdd +@@ -2766,7 +2763,7 @@ func TestStagedTransactionHeight(t *testing.T) { + newBlockHeight := initialBlockHeight + 1 + harness.AddFakeUTXO(txA, newBlockHeight, wire.NullBlockIndex) + harness.chain.SetHeight(newBlockHeight) +- harness.txPool.RemoveTransaction(txA, false, noTreasury, noAutoRevocations) ++ harness.txPool.RemoveTransaction(txA, false) + harness.txPool.MaybeAcceptDependents(txA, noTreasury) + + poolTxDescs = harness.txPool.TxDescs() +@@ -3231,8 +3228,7 @@ func TestSubsidySplitSemantics(t *testing.T) { + + // Remove the vote from the pool and ensure it is not in the orphan pool, + // not in the transaction pool, and not reported as available. +- harness.txPool.RemoveTransaction(preDCP0010Vote, true, noTreasury, +- noAutoRevocations) ++ harness.txPool.RemoveTransaction(preDCP0010Vote, true) + testPoolMembership(tc, preDCP0010Vote, false, false) + + // Attempt to add the vote with the original subsidy when the agenda is +diff --git a/internal/mempool/policy_test.go b/internal/mempool/policy_test.go +index c677d9bb3a..7ef6829824 100644 +--- a/internal/mempool/policy_test.go ++++ b/internal/mempool/policy_test.go +@@ -26,11 +26,6 @@ const ( + // noTreasury signifies the treasury agenda should be treated as though it + // is inactive. It is used to increase the readability of the tests. + noTreasury = false +- +- // noAutoRevocations signifies the automatic ticket revocations agenda should +- // be treated as though it is inactive. It is used to increase the +- // readability of the tests. +- noAutoRevocations = false + ) + + // TestCalcMinRequiredTxRelayFee tests the calcMinRequiredTxRelayFee API. +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,4 @@ ++H4sIAAAAAAAAA+3STWrDMBCGYa99igld25LcqF7lLME/ojHYUrHknL+uF2kptNkklJL3WWgGJNCI ++T2W7DGN/dP6ssnvRq9rara6+1603tjKVfrbrkmljbK0zsXeb6IslpmYWyeYQ0m/nru3/U+Vn/snF ++dOzCNDW+L+Ppdndcy9/o+pK/3ldr/vsXbTPRtxvhZw+e/9NOtYNXbRNPeXRJCpd3vWx/oXV9/hrk ++o5VSDT652Tejmtz0FsKopDhL0YXFp4PJ//oZAAAAAAAAAAAAAAAAwEN6B/E37p8AKAAA +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000780/tests/test.sh b/tasks/format-code-task-000780/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..0a68fe66becef27c42dbdf8a2d30411993807a3d --- /dev/null +++ b/tasks/format-code-task-000780/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +internal/mempool/mempool_test.go +internal/mempool/policy_test.go +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000780/tests/test_command.sh b/tasks/format-code-task-000780/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000780/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000800/environment/Dockerfile b/tasks/format-code-task-000800/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..751036de34c5990a44b82d089f8d3f56fe7deead --- /dev/null +++ b/tasks/format-code-task-000800/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:fd33fc451526c06983be33455ec64bcdea5190b6856a6aedd337f66e78e88a6c diff --git a/tasks/format-code-task-000800/environment/setup/files/blocklist b/tasks/format-code-task-000800/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000800/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000800/environment/setup/setup.sh b/tasks/format-code-task-000800/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000800/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000800/tests/test.patch b/tasks/format-code-task-000800/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e86290aaa4f98c8ffcbfc9f2c7b67fd40840c15e --- /dev/null +++ b/tasks/format-code-task-000800/tests/test.patch @@ -0,0 +1,480 @@ +diff --git a/usercase-test-coderl/request_acceptance_test.go b/usercase-test-coderl/request_acceptance_test.go +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/request_acceptance_test.go +@@ -0,0 +1,441 @@ ++package usercase_test_coderl ++ ++ ++ ++ ++ ++import ( ++ "encoding/json" ++ "errors" ++ "net/http" ++ "net/url" ++ "reflect" ++ "strings" ++ "testing" ++ ++ jwt "github.com/dgrijalva/jwt-go" ++ request "github.com/dgrijalva/jwt-go/request" ++) ++ ++const ( ++ mapClaimsToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiYWRtaW4iLCJzdWIiOiJhbGljZSJ9.E-gcxj5S3Qw-gOAgSKDFqNA-zNNDpWN0VQnyNB_faOw" ++ customClaimsToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzY29wZSI6InJlYWQ6YWxsIiwiaXNzIjoiaXNzdWVyLWEiLCJzdWIiOiJib2IifQ.PJpyvCWqRZfp_RbuLLciw32rbURyfH3KrSl9q_4nMT8" ++ numberClaimsToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb3VudCI6MTIzfQ._xkoIfbL-8Zo_bvpzhWykH6ZzIvPQcrRjQ_1rHQcqhQ" ++ signingKey = "fixture-secret" ++) ++ ++type customClaims struct { ++ Scope string `json:"scope"` ++ jwt.StandardClaims ++} ++ ++func (c customClaims) Valid() error { ++ return c.StandardClaims.Valid() ++} ++ ++type staticExtractor struct { ++ token string ++ err error ++} ++ ++func (s staticExtractor) ExtractToken(*http.Request) (string, error) { ++ return s.token, s.err ++} ++ ++func newRequest(method, target string, headers map[string]string, body string, contentType string) *http.Request { ++ req, err := http.NewRequest(method, target, strings.NewReader(body)) ++ if err != nil { ++ panic(err) ++ } ++ for name, value := range headers { ++ req.Header.Set(name, value) ++ } ++ if contentType != "" { ++ req.Header.Set("Content-Type", contentType) ++ } ++ return req ++} ++ ++func assertExtract(t *testing.T, extractor request.Extractor, req *http.Request, wantToken string, wantErr error) { ++ t.Helper() ++ gotToken, gotErr := extractor.ExtractToken(req) ++ if gotToken != wantToken { ++ t.Fatalf("token mismatch: got %q want %q", gotToken, wantToken) ++ } ++ ++ if gotErr != wantErr { ++ t.Fatalf("error mismatch: got %v want %v", gotErr, wantErr) ++ } ++} ++ ++func keyFunc(*jwt.Token) (interface{}, error) { ++ return []byte(signingKey), nil ++} ++ ++func TestHeaderExtractorReturnsFirstNonEmptyMatchingHeader(t *testing.T) { ++ ++ ++ req := newRequest("GET", "/", map[string]string{ ++ "X-Empty": "", ++ "X-Token": "abc.def.ghi", ++ "X-Other": "other.value", ++ }, "", "") ++ ++ assertExtract(t, request.HeaderExtractor{"X-Empty", "X-Token", "X-Other"}, req, "abc.def.ghi", nil) ++} ++ ++func TestHeaderExtractorMissReturnsSharedNoTokenError(t *testing.T) { ++ ++ ++ req := newRequest("GET", "/", nil, "", "") ++ ++ assertExtract(t, request.HeaderExtractor{"X-Token"}, req, "", request.ErrNoTokenInRequest) ++} ++ ++func TestArgumentExtractorReadsQueryArgument(t *testing.T) { ++ ++ ++ req := newRequest("GET", "/?token=abc.def.ghi", nil, "", "") ++ ++ assertExtract(t, request.ArgumentExtractor{"token"}, req, "abc.def.ghi", nil) ++} ++ ++func TestArgumentExtractorReadsParsedFormArgument(t *testing.T) { ++ ++ ++ form := url.Values{"token": {"form.token.value"}} ++ req := newRequest("POST", "/", nil, form.Encode(), "application/x-www-form-urlencoded") ++ ++ assertExtract(t, request.ArgumentExtractor{"token"}, req, "form.token.value", nil) ++} ++ ++func TestArgumentExtractorMissReturnsSharedNoTokenError(t *testing.T) { ++ ++ ++ req := newRequest("GET", "/?other=abc.def.ghi", nil, "", "") ++ ++ assertExtract(t, request.ArgumentExtractor{"token"}, req, "", request.ErrNoTokenInRequest) ++} ++ ++func TestMultiExtractorReturnsFirstTokenInOrder(t *testing.T) { ++ ++ ++ req := newRequest("GET", "/?token=query.token", map[string]string{"X-Token": "header.token"}, "", "") ++ extractor := request.MultiExtractor{ ++ request.HeaderExtractor{"X-Token"}, ++ request.ArgumentExtractor{"token"}, ++ } ++ ++ assertExtract(t, extractor, req, "header.token", nil) ++} ++ ++func TestMultiExtractorSkipsNoTokenAndFallsBack(t *testing.T) { ++ ++ ++ req := newRequest("GET", "/?token=query.token", nil, "", "") ++ extractor := request.MultiExtractor{ ++ request.HeaderExtractor{"X-Missing"}, ++ request.ArgumentExtractor{"token"}, ++ } ++ ++ assertExtract(t, extractor, req, "query.token", nil) ++} ++ ++func TestMultiExtractorReturnsFirstOtherErrorImmediately(t *testing.T) { ++ ++ ++ boom := errors.New("boom extractor") ++ req := newRequest("GET", "/?token=query.token", nil, "", "") ++ extractor := request.MultiExtractor{ ++ request.HeaderExtractor{"X-Missing"}, ++ staticExtractor{"", boom}, ++ request.ArgumentExtractor{"token"}, ++ } ++ ++ assertExtract(t, extractor, req, "", boom) ++} ++ ++func TestMultiExtractorMissReturnsSharedNoTokenError(t *testing.T) { ++ ++ ++ req := newRequest("GET", "/?other=query.token", nil, "", "") ++ extractor := request.MultiExtractor{ ++ request.HeaderExtractor{"X-Missing"}, ++ request.ArgumentExtractor{"token"}, ++ } ++ ++ assertExtract(t, extractor, req, "", request.ErrNoTokenInRequest) ++} ++ ++func TestPostExtractionFilterTransformsFoundToken(t *testing.T) { ++ ++ ++ req := newRequest("GET", "/", map[string]string{"X-Token": "abc.def.ghi"}, "", "") ++ extractor := &request.PostExtractionFilter{ ++ Extractor: request.HeaderExtractor{"X-Token"}, ++ Filter: func(token string) (string, error) { ++ return "filtered:" + token, nil ++ }, ++ } ++ ++ assertExtract(t, extractor, req, "filtered:abc.def.ghi", nil) ++} ++ ++func TestPostExtractionFilterReturnsFilterError(t *testing.T) { ++ ++ ++ filterErr := errors.New("filter failed") ++ req := newRequest("GET", "/", map[string]string{"X-Token": "abc.def.ghi"}, "", "") ++ extractor := &request.PostExtractionFilter{ ++ Extractor: request.HeaderExtractor{"X-Token"}, ++ Filter: func(string) (string, error) { ++ return "", filterErr ++ }, ++ } ++ ++ assertExtract(t, extractor, req, "", filterErr) ++} ++ ++func TestPostExtractionFilterPassesThroughWrappedMiss(t *testing.T) { ++ ++ ++ req := newRequest("GET", "/", nil, "", "") ++ extractor := &request.PostExtractionFilter{ ++ Extractor: request.HeaderExtractor{"X-Token"}, ++ Filter: func(token string) (string, error) { ++ return "filtered:" + token, nil ++ }, ++ } ++ ++ assertExtract(t, extractor, req, "", request.ErrNoTokenInRequest) ++} ++ ++func TestAuthorizationHeaderExtractorStripsBearerPrefixCaseInsensitively(t *testing.T) { ++ ++ ++ upperReq := newRequest("GET", "/", map[string]string{"Authorization": "Bearer abc.def.ghi"}, "", "") ++ lowerReq := newRequest("GET", "/", map[string]string{"Authorization": "bearer lower.token"}, "", "") ++ ++ assertExtract(t, request.AuthorizationHeaderExtractor, upperReq, "abc.def.ghi", nil) ++ assertExtract(t, request.AuthorizationHeaderExtractor, lowerReq, "lower.token", nil) ++} ++ ++func TestAuthorizationHeaderExtractorReturnsNonBearerValueUnchanged(t *testing.T) { ++ ++ ++ req := newRequest("GET", "/", map[string]string{"Authorization": "Token raw.value"}, "", "") ++ ++ assertExtract(t, request.AuthorizationHeaderExtractor, req, "Token raw.value", nil) ++} ++ ++func TestOAuth2ExtractorPrefersAuthorizationHeaderOverAccessTokenArgument(t *testing.T) { ++ ++ ++ req := newRequest("GET", "/?access_token=query.token", map[string]string{"Authorization": "Bearer header.token"}, "", "") ++ ++ assertExtract(t, request.OAuth2Extractor, req, "header.token", nil) ++} ++ ++func TestOAuth2ExtractorFallsBackToAccessTokenArgument(t *testing.T) { ++ ++ ++ req := newRequest("GET", "/?access_token=query.token", nil, "", "") ++ ++ assertExtract(t, request.OAuth2Extractor, req, "query.token", nil) ++} ++ ++func TestOAuth2ExtractorMissReturnsSharedNoTokenError(t *testing.T) { ++ ++ ++ req := newRequest("GET", "/?token=query.token", nil, "", "") ++ ++ assertExtract(t, request.OAuth2Extractor, req, "", request.ErrNoTokenInRequest) ++} ++ ++func TestParseFromRequestUsesDefaultMapClaimsAndSuppliedKeyCallback(t *testing.T) { ++ ++ ++ req := newRequest("GET", "/", map[string]string{"X-Token": mapClaimsToken}, "", "") ++ ++ token, err := request.ParseFromRequest(req, request.HeaderExtractor{"X-Token"}, keyFunc) ++ if err != nil { ++ t.Fatalf("ParseFromRequest error: %v", err) ++ } ++ if token.Raw != mapClaimsToken || !token.Valid || token.Method.Alg() != "HS256" { ++ t.Fatalf("parsed token summary mismatch: raw=%q valid=%v alg=%q", token.Raw, token.Valid, token.Method.Alg()) ++ } ++ want := jwt.MapClaims{"role": "admin", "sub": "alice"} ++ if !reflect.DeepEqual(token.Claims, want) { ++ t.Fatalf("claims mismatch: got %#v want %#v", token.Claims, want) ++ } ++} ++ ++func TestParseFromRequestWithClaimsParsesCustomClaims(t *testing.T) { ++ ++ ++ req := newRequest("GET", "/", map[string]string{"X-Token": customClaimsToken}, "", "") ++ ++ token, err := request.ParseFromRequestWithClaims(req, request.HeaderExtractor{"X-Token"}, &customClaims{}, keyFunc) ++ if err != nil { ++ t.Fatalf("ParseFromRequestWithClaims error: %v", err) ++ } ++ want := &customClaims{ ++ Scope: "read:all", ++ StandardClaims: jwt.StandardClaims{ ++ Issuer: "issuer-a", ++ Subject: "bob", ++ }, ++ } ++ if token.Raw != customClaimsToken || !token.Valid || token.Method.Alg() != "HS256" { ++ t.Fatalf("parsed token summary mismatch: raw=%q valid=%v alg=%q", token.Raw, token.Valid, token.Method.Alg()) ++ } ++ if !reflect.DeepEqual(token.Claims, want) { ++ t.Fatalf("custom claims mismatch: got %#v want %#v", token.Claims, want) ++ } ++} ++ ++func TestParseFromRequestWithClaimsOptionParsesCustomClaims(t *testing.T) { ++ ++ ++ req := newRequest("GET", "/", map[string]string{"X-Token": customClaimsToken}, "", "") ++ ++ token, err := request.ParseFromRequest(req, request.HeaderExtractor{"X-Token"}, keyFunc, request.WithClaims(&customClaims{})) ++ if err != nil { ++ t.Fatalf("ParseFromRequest WithClaims error: %v", err) ++ } ++ want := &customClaims{ ++ Scope: "read:all", ++ StandardClaims: jwt.StandardClaims{ ++ Issuer: "issuer-a", ++ Subject: "bob", ++ }, ++ } ++ if !reflect.DeepEqual(token.Claims, want) { ++ t.Fatalf("custom claims mismatch: got %#v want %#v", token.Claims, want) ++ } ++} ++ ++func TestParseFromRequestWithParserOptionUsesCustomParser(t *testing.T) { ++ ++ ++ req := newRequest("GET", "/", map[string]string{"X-Token": numberClaimsToken}, "", "") ++ ++ token, err := request.ParseFromRequest(req, request.HeaderExtractor{"X-Token"}, keyFunc, request.WithParser(&jwt.Parser{UseJSONNumber: true})) ++ if err != nil { ++ t.Fatalf("ParseFromRequest WithParser error: %v", err) ++ } ++ want := jwt.MapClaims{"count": json.Number("123")} ++ if !reflect.DeepEqual(token.Claims, want) { ++ t.Fatalf("json-number claims mismatch: got %#v want %#v", token.Claims, want) ++ } ++} ++ ++func TestParseFromRequestWithOAuth2ExtractorParsesHeaderToken(t *testing.T) { ++ ++ ++ req := newRequest("GET", "/?access_token=other", map[string]string{"Authorization": "Bearer " + mapClaimsToken}, "", "") ++ ++ token, err := request.ParseFromRequest(req, request.OAuth2Extractor, keyFunc) ++ if err != nil { ++ t.Fatalf("ParseFromRequest OAuth2 header error: %v", err) ++ } ++ want := jwt.MapClaims{"role": "admin", "sub": "alice"} ++ if token.Raw != mapClaimsToken || !token.Valid || !reflect.DeepEqual(token.Claims, want) { ++ t.Fatalf("parsed header token mismatch: raw=%q valid=%v claims=%#v", token.Raw, token.Valid, token.Claims) ++ } ++} ++ ++func TestParseFromRequestWithOAuth2ExtractorParsesAccessTokenArgument(t *testing.T) { ++ ++ ++ req := newRequest("GET", "/?access_token="+url.QueryEscape(mapClaimsToken), nil, "", "") ++ ++ token, err := request.ParseFromRequest(req, request.OAuth2Extractor, keyFunc) ++ if err != nil { ++ t.Fatalf("ParseFromRequest OAuth2 argument error: %v", err) ++ } ++ want := jwt.MapClaims{"role": "admin", "sub": "alice"} ++ if token.Raw != mapClaimsToken || !token.Valid || !reflect.DeepEqual(token.Claims, want) { ++ t.Fatalf("parsed argument token mismatch: raw=%q valid=%v claims=%#v", token.Raw, token.Valid, token.Claims) ++ } ++} ++ ++func TestParseFromRequestReturnsExtractorErrorUnchanged(t *testing.T) { ++ ++ ++ extractorErr := errors.New("extractor failed") ++ req := newRequest("GET", "/", nil, "", "") ++ ++ token, err := request.ParseFromRequest(req, staticExtractor{"", extractorErr}, keyFunc) ++ if token != nil { ++ t.Fatalf("expected no token, got %#v", token) ++ } ++ ++ if err != extractorErr { ++ t.Fatalf("error mismatch: got %v want %v", err, extractorErr) ++ } ++} ++ ++func TestParseFromRequestReturnsNoTokenErrorAndNoTokenWhenExtractorMisses(t *testing.T) { ++ ++ ++ req := newRequest("GET", "/?token=query.token", nil, "", "") ++ ++ token, err := request.ParseFromRequest(req, request.OAuth2Extractor, keyFunc) ++ if token != nil { ++ t.Fatalf("expected no token, got %#v", token) ++ } ++ ++ if err != request.ErrNoTokenInRequest { ++ t.Fatalf("error mismatch: got %v want %v", err, request.ErrNoTokenInRequest) ++ } ++} ++ ++func TestReferentialTransparencyForSameRequestInput(t *testing.T) { ++ req1 := newRequest("GET", "/", map[string]string{"Authorization": "Bearer abc.def.ghi"}, "", "") ++ req2 := newRequest("GET", "/", map[string]string{"Authorization": "Bearer abc.def.ghi"}, "", "") ++ ++ ++ first, firstErr := request.AuthorizationHeaderExtractor.ExtractToken(req1) ++ second, secondErr := request.AuthorizationHeaderExtractor.ExtractToken(req2) ++ if first != "abc.def.ghi" || firstErr != nil { ++ t.Fatalf("first extraction mismatch: got (%q,%v)", first, firstErr) ++ } ++ if second != "abc.def.ghi" || secondErr != nil { ++ t.Fatalf("second extraction mismatch: got (%q,%v)", second, secondErr) ++ } ++} ++ ++func TestOAuth2ExtractorHeaderPrecedenceWithQueryPresent(t *testing.T) { ++ req := newRequest("GET", "/?access_token=query.token", map[string]string{"Authorization": "Bearer header.token"}, "", "") ++ ++ ++ assertExtract(t, request.OAuth2Extractor, req, "header.token", nil) ++} ++ ++func TestNoGlobalStateAcrossExtractorNoise(t *testing.T) { ++ req := newRequest("GET", "/", map[string]string{"Authorization": "Bearer stable.token"}, "", "") ++ first, err := request.AuthorizationHeaderExtractor.ExtractToken(req) ++ if err != nil { ++ t.Fatalf("first extraction error: %v", err) ++ } ++ ++ assertExtract(t, request.ArgumentExtractor{"token"}, newRequest("GET", "/?token=query.token", nil, "", ""), "query.token", nil) ++ assertExtract(t, request.HeaderExtractor{"X-Token"}, newRequest("GET", "/", map[string]string{"X-Token": "header.token"}, "", ""), "header.token", nil) ++ ++ again, err := request.AuthorizationHeaderExtractor.ExtractToken(req) ++ if err != nil { ++ t.Fatalf("second extraction error: %v", err) ++ } ++ if again != first || again != "stable.token" { ++ t.Fatalf("stateful result mismatch: first %q again %q", first, again) ++ } ++} ++ ++func TestAuthorizationHeaderExtractorMissReturnsSharedNoTokenError(t *testing.T) { ++ req := newRequest("GET", "/", map[string]string{"Authorization": "Bearer abc.def.ghi"}, "", "") ++ req.Header.Del("Authorization") ++ ++ ++ assertExtract(t, request.AuthorizationHeaderExtractor, req, "", request.ErrNoTokenInRequest) ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,29 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++REPO=/workspace/repo ++GOPATH_DIR=/tmp/fixture-jwt-go-gopath ++PKG_DIR="$GOPATH_DIR/src/github.com/dgrijalva/jwt-go" ++ ++mkdir -p "$(dirname "$PKG_DIR")" ++rm -f "$PKG_DIR" ++ln -s "$REPO" "$PKG_DIR" ++ ++cd "$PKG_DIR" ++export GO111MODULE=off ++export GOPATH="$GOPATH_DIR" ++export GOPROXY=off ++export GOSUMDB=off ++export GOTOOLCHAIN=local ++ ++exec go test -v ./usercase-test-coderl/... diff --git a/tasks/format-code-task-000800/tests/test.sh b/tasks/format-code-task-000800/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..4fc20d5a8fd977a940c2814ed5164b20cbf191dd --- /dev/null +++ b/tasks/format-code-task-000800/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/request_acceptance_test.go +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000800/tests/test_command.sh b/tasks/format-code-task-000800/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000800/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000838/environment/Dockerfile b/tasks/format-code-task-000838/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..9314e335420fc9b2aaae27c31b62a6804b963b03 --- /dev/null +++ b/tasks/format-code-task-000838/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:e4c3e01576e23b77c57d503408f2fb4cc4ceeafa5ac2a9a5d4c69682c8503381 diff --git a/tasks/format-code-task-000838/environment/setup/files/blocklist b/tasks/format-code-task-000838/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000838/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000838/environment/setup/setup.sh b/tasks/format-code-task-000838/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000838/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000838/tests/test.patch b/tasks/format-code-task-000838/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..5194c427e10c24cdb134fcd39ed114de161187d0 --- /dev/null +++ b/tasks/format-code-task-000838/tests/test.patch @@ -0,0 +1,138 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..cf2380d +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m unittest tests.test_cli.TestHideCommand -v"] ++} +diff --git a/tests/test_cli.py b/tests/test_cli.py +index 1faf0a3..dfed839 100644 +--- a/tests/test_cli.py ++++ b/tests/test_cli.py +@@ -173,5 +173,111 @@ class TestWatchPID(TestCase): + self.assertRaises(SystemExit, run_cmd, args) + + ++class TestHideCommand(TestCase): ++ @patch('ntfy.cli.Popen') ++ def test_hide_command_succeeded(self, mock_Popen): ++ mock_Popen.return_value = process_mock() ++ args = MagicMock() ++ args.longer_than = -1 ++ args.command = ['true'] ++ args.pid = None ++ args.unfocused_only = False ++ args.hide_command = True ++ args.no_emoji = True ++ message, retcode = run_cmd(args) ++ self.assertEqual(0, retcode) ++ ++ self.assertRegex( ++ message, r'^"?Your command"? succeeded in 0:00 minutes$') ++ ++ @patch('ntfy.cli.Popen') ++ def test_hide_command_failure(self, mock_Popen): ++ mock_Popen.return_value = process_mock(42) ++ args = MagicMock() ++ args.longer_than = -1 ++ args.command = ['false'] ++ args.pid = None ++ args.unfocused_only = False ++ args.hide_command = True ++ args.no_emoji = True ++ message, retcode = run_cmd(args) ++ self.assertEqual(42, retcode) ++ self.assertRegex( ++ message, ++ r'^"?Your command"? failed \(code 42\) in 0:00 minutes$') ++ ++ @patch('ntfy.cli.Popen') ++ def test_hide_command_with_emoji(self, mock_Popen): ++ mock_Popen.return_value = process_mock() ++ args = MagicMock() ++ args.longer_than = -1 ++ args.command = ['true'] ++ args.pid = None ++ args.unfocused_only = False ++ args.hide_command = True ++ args.no_emoji = False ++ message, retcode = run_cmd(args) ++ self.assertRegex( ++ message, ++ r'^:white_check_mark: "?Your command"? succeeded in 0:00 minutes$') ++ ++ @patch('ntfy.cli.Popen') ++ def test_hide_command_with_stdout(self, mock_Popen): ++ mock_Popen.return_value = process_mock(stdout='output') ++ args = MagicMock() ++ args.longer_than = -1 ++ args.command = ['true'] ++ args.pid = None ++ args.unfocused_only = False ++ args.stdout = True ++ args.stderr = False ++ args.hide_command = True ++ args.no_emoji = True ++ message, retcode = run_cmd(args) ++ self.assertRegex( ++ message, ++ r'^"?Your command"? succeeded in 0:00 minutes:\noutput$') ++ ++ @patch('ntfy.cli.Popen') ++ def test_hide_command_does_not_include_actual_command(self, mock_Popen): ++ ++ ++ mock_Popen.return_value = process_mock() ++ args = MagicMock() ++ args.longer_than = -1 ++ args.command = ['secret-cmd', '--secret-arg'] ++ args.pid = None ++ args.unfocused_only = False ++ args.hide_command = True ++ args.no_emoji = True ++ message, _ = run_cmd(args) ++ self.assertNotIn('secret-cmd', message) ++ self.assertNotIn('--secret-arg', message) ++ ++ @patch('ntfy.cli.Popen') ++ def test_hide_command_false_preserves_existing_format(self, mock_Popen): ++ ++ mock_Popen.return_value = process_mock() ++ args = MagicMock() ++ args.longer_than = -1 ++ args.command = ['true'] ++ args.pid = None ++ args.unfocused_only = False ++ args.hide_command = False ++ args.no_emoji = True ++ message, retcode = run_cmd(args) ++ self.assertEqual('"true" succeeded in 0:00 minutes', message) ++ ++ def test_cli_flag_hide_command_parses(self): ++ from ntfy.cli import parser ++ args = parser.parse_args(['done', '--hide-command', 'true']) ++ self.assertTrue(args.hide_command) ++ ++ def test_cli_flag_hide_command_default_false(self): ++ from ntfy.cli import parser ++ args = parser.parse_args(['done', 'true']) ++ self.assertFalse(args.hide_command) ++ ++ + if __name__ == '__main__': + main() +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m unittest tests.test_cli.TestHideCommand -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000838/tests/test.sh b/tasks/format-code-task-000838/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..9b2d05b0060f0de94a5adc481e997f15d30ddbb4 --- /dev/null +++ b/tasks/format-code-task-000838/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test_commands.json +tests/test_cli.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000838/tests/test_command.sh b/tasks/format-code-task-000838/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000838/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000853/environment/Dockerfile b/tasks/format-code-task-000853/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8f9ed070c15c89c2d4c55109633cc91f490cb0a6 --- /dev/null +++ b/tasks/format-code-task-000853/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:8a89e435fc46f70d88ada301c0e01a97a8ba6f49a2767c4d1f4f02ad4127814d diff --git a/tasks/format-code-task-000853/environment/setup/files/blocklist b/tasks/format-code-task-000853/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000853/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000853/environment/setup/setup.sh b/tasks/format-code-task-000853/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000853/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000853/tests/test.patch b/tasks/format-code-task-000853/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..3aaac0ddaeccbf784effb4e9b3fd067ac1d8c9cd --- /dev/null +++ b/tasks/format-code-task-000853/tests/test.patch @@ -0,0 +1,609 @@ +diff --git a/usercase-test-coderl/editor_redo.test.js b/usercase-test-coderl/editor_redo.test.js +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/editor_redo.test.js +@@ -0,0 +1,584 @@ ++import test from 'node:test'; ++import assert from 'node:assert/strict'; ++ ++ ++ ++ ++ ++ ++ ++ ++ ++class ClassList { ++ constructor() { ++ this.values = new Set; ++ } ++ ++ add(...names) { ++ for (let name of names) { ++ this.values.add(name); ++ } ++ } ++ ++ remove(...names) { ++ for (let name of names) { ++ this.values.delete(name); ++ } ++ } ++ ++ contains(name) { ++ return this.values.has(name); ++ } ++ ++ toggle(name, force = undefined) { ++ let enabled = force ?? ! this.values.has(name); ++ if (enabled) { ++ this.values.add(name); ++ } ++ else { ++ this.values.delete(name); ++ } ++ return enabled; ++ } ++} ++ ++class TestElement { ++ constructor(tagName) { ++ this.tagName = tagName.toUpperCase(); ++ this.children = []; ++ this.parentNode = null; ++ this.attributes = new Map; ++ this.eventListeners = new Map; ++ this.style = { setProperty() {} }; ++ this._classList = new ClassList; ++ this.textContent = ''; ++ this.disabled = false; ++ this.id = ''; ++ this.width = 0; ++ this.height = 0; ++ this.scrollLeft = 0; ++ this.scrollTop = 0; ++ this.offsetWidth = 100; ++ this.offsetHeight = 100; ++ } ++ ++ get classList() { ++ return this._classList; ++ } ++ ++ set classList(value) { ++ this._classList = new ClassList; ++ if (value instanceof ClassList) { ++ this._classList = value; ++ } ++ else { ++ for (let part of String(value).split(/\s+/).filter(Boolean)) { ++ this._classList.add(part); ++ } ++ } ++ } ++ ++ setAttribute(key, value) { ++ this.attributes.set(key, String(value)); ++ if (key === 'id') { ++ this.id = String(value); ++ } ++ else if (key === 'class') { ++ this.classList = new ClassList; ++ for (let part of String(value).split(/\s+/).filter(Boolean)) { ++ this.classList.add(part); ++ } ++ } ++ } ++ ++ getAttribute(key) { ++ return this.attributes.get(key) ?? null; ++ } ++ ++ append(...children) { ++ for (let child of children.flat()) { ++ if (child === undefined || child === null) { ++ continue; ++ } ++ let node = child instanceof TestElement ? child : new TestTextElement(String(child)); ++ node.parentNode = this; ++ this.children.push(node); ++ } ++ } ++ ++ querySelector(selector) { ++ let parts = selector.trim().split(/\s+/); ++ let current = this; ++ for (let part of parts) { ++ current = current?._descendants().find(el => matchesSelector(el, part)) ?? null; ++ } ++ return current; ++ } ++ ++ _descendants() { ++ let out = []; ++ for (let child of this.children) { ++ if (child instanceof TestElement) { ++ out.push(child, ...child._descendants()); ++ } ++ } ++ return out; ++ } ++ ++ addEventListener(type, listener) { ++ if (! this.eventListeners.has(type)) { ++ this.eventListeners.set(type, []); ++ } ++ this.eventListeners.get(type).push(listener); ++ } ++ ++ dispatchEvent(ev) { ++ ev.target ??= this; ++ ev.currentTarget = this; ++ ev.defaultPrevented = false; ++ ev.stopPropagation ??= () => {}; ++ ev.preventDefault ??= () => { ev.defaultPrevented = true; }; ++ for (let listener of this.eventListeners.get(ev.type) ?? []) { ++ listener(ev); ++ } ++ return ! ev.defaultPrevented; ++ } ++ ++ closest(selector) { ++ for (let el = this; el; el = el.parentNode) { ++ if (matchesSelector(el, selector)) { ++ return el; ++ } ++ } ++ return null; ++ } ++ ++ contains(other) { ++ for (let el = other; el; el = el.parentNode) { ++ if (el === this) { ++ return true; ++ } ++ } ++ return false; ++ } ++ ++ remove() { ++ if (this.parentNode) { ++ this.parentNode.children = this.parentNode.children.filter(child => child !== this); ++ this.parentNode = null; ++ } ++ } ++ ++ removeAttribute(key) { ++ this.attributes.delete(key); ++ } ++ ++ getBoundingClientRect() { ++ return {x: 0, y: 0, left: 0, top: 0, right: 100, bottom: 100, width: 100, height: 100}; ++ } ++ ++ getContext() { ++ return { ++ clearRect() {}, ++ drawImage() {}, ++ fillRect() {}, ++ strokeRect() {}, ++ beginPath() {}, ++ moveTo() {}, ++ lineTo() {}, ++ stroke() {}, ++ save() {}, ++ restore() {}, ++ translate() {}, ++ scale() {}, ++ rotate() {}, ++ fillText() {}, ++ measureText() { ++ return {width: 0}; ++ }, ++ }; ++ } ++} ++ ++class TestTextElement extends TestElement { ++ constructor(text) { ++ super('#text'); ++ this.textContent = text; ++ } ++} ++ ++function matchesSelector(el, selector) { ++ if (! (el instanceof TestElement)) { ++ return false; ++ } ++ if (selector.startsWith('#')) { ++ return el.id === selector.slice(1); ++ } ++ if (selector.startsWith('.')) { ++ return el.classList.contains(selector.slice(1)); ++ } ++ let idIndex = selector.indexOf('#'); ++ if (idIndex >= 0) { ++ return ( ++ el.tagName.toLowerCase() === selector.slice(0, idIndex) && ++ el.id === selector.slice(idIndex + 1) ++ ); ++ } ++ return el.tagName.toLowerCase() === selector.toLowerCase(); ++} ++ ++function buildEditorDocument() { ++ let body = new TestElement('body'); ++ let main = new TestElement('main'); ++ main.setAttribute('id', 'editor'); ++ let menubar = new TestElement('div'); ++ menubar.classList.add('-menubar'); ++ let viewport = new TestElement('div'); ++ viewport.classList.add('editor-canvas'); ++ let container = new TestElement('div'); ++ container.classList.add('-container'); ++ viewport.append(container); ++ let statusbar = new TestElement('div'); ++ statusbar.setAttribute('id', 'editor-statusbar'); ++ let palette = new TestElement('div'); ++ palette.classList.add('-palette'); ++ let tools = new TestElement('div'); ++ tools.classList.add('-tools'); ++ main.append(menubar, viewport, statusbar, palette, tools); ++ body.append(main); ++ return { ++ body, ++ documentElement: new TestElement('html'), ++ createElement: tag => new TestElement(tag), ++ createElementNS: (_ns, tag) => new TestElement(tag), ++ activeElement: null, ++ }; ++} ++ ++function installBrowserGlobals() { ++ globalThis.Node = TestElement; ++ globalThis.CanvasRenderingContext2D = class {}; ++ globalThis.DOMRect = class { ++ constructor(x, y, width, height) { ++ Object.assign(this, {x, y, width, height, left: x, top: y, right: x + width, bottom: y + height}); ++ } ++ }; ++ globalThis.document = buildEditorDocument(); ++ globalThis.window = { ++ navigator: {platform: 'Linux x86_64'}, ++ eventListeners: new Map, ++ localStorage: { ++ getItem() { ++ return null; ++ }, ++ setItem() {}, ++ }, ++ addEventListener(type, listener) { ++ if (! this.eventListeners.has(type)) { ++ this.eventListeners.set(type, []); ++ } ++ this.eventListeners.get(type).push(listener); ++ }, ++ removeEventListener() {}, ++ dispatchEvent(ev) { ++ ev.target ??= this; ++ ev.defaultPrevented = false; ++ ev.stopPropagation ??= () => {}; ++ ev.preventDefault ??= () => { ev.defaultPrevented = true; }; ++ for (let listener of this.eventListeners.get(ev.type) ?? []) { ++ listener(ev); ++ } ++ return ! ev.defaultPrevented; ++ }, ++ setTimeout, ++ clearTimeout, ++ }; ++ globalThis.localStorage = globalThis.window.localStorage; ++ globalThis.location = 'http://localhost/'; ++} ++ ++installBrowserGlobals(); ++const {Editor} = await import('../js/editor/main.js'); ++ ++function makeConductor() { ++ return { ++ tilesets: { ++ ll: { ++ size_x: 1, ++ size_y: 1, ++ draw() {}, ++ draw_type() {}, ++ blit_to_canvas() {}, ++ }, ++ }, ++ stored_game: { ++ editor_metadata: {key: 'pack'}, ++ level_metadata: [], ++ }, ++ player: { ++ state: 'stopped', ++ set_state() {}, ++ }, ++ }; ++} ++ ++function attachUndoUi(editor) { ++ editor.undo_button = document.createElement('button'); ++ editor.redo_button = document.createElement('button'); ++ editor.save_button = document.createElement('button'); ++ editor.stored_level = {editor_metadata: {key: 'level'}}; ++ editor.modified = false; ++} ++ ++function makeUndoReadyEditor() { ++ let editor = new Editor(makeConductor()); ++ attachUndoUi(editor); ++ editor.reset_undo(); ++ return editor; ++} ++ ++function snapshot(editor, value, rehoverCount = 0) { ++ return { ++ value, ++ modified: editor.modified, ++ undoDisabled: editor.undo_button.disabled, ++ redoDisabled: editor.redo_button.disabled, ++ saveDisabled: editor.save_button.disabled, ++ rehoverCount, ++ }; ++} ++ ++function assertSaveButtonConsistent(editor) { ++ ++ assert.equal(editor.save_button.disabled, ! ( ++ editor.stored_level && editor.modified && editor.conductor.stored_game.editor_metadata)); ++} ++ ++test('redo replays an undone edit and restores undo/save/button state', () => { ++ ++ ++ let editor = makeUndoReadyEditor(); ++ let value = 'initial'; ++ let rehoverCount = 0; ++ editor.mouse_op = {rehover() { rehoverCount += 1; }}; ++ ++ ++ assert.deepEqual(snapshot(editor, value, rehoverCount), { ++ value: 'initial', ++ modified: false, ++ undoDisabled: true, ++ redoDisabled: true, ++ saveDisabled: true, ++ rehoverCount: 0, ++ }); ++ ++ editor._do(() => { value = 'first edit'; }, () => { value = 'initial'; }); ++ ++ assert.deepEqual(snapshot(editor, value, rehoverCount), { ++ value: 'first edit', ++ modified: false, ++ undoDisabled: true, ++ redoDisabled: true, ++ saveDisabled: true, ++ rehoverCount: 0, ++ }); ++ ++ editor.commit_undo(); ++ ++ assert.deepEqual(snapshot(editor, value, rehoverCount), { ++ value: 'first edit', ++ modified: true, ++ undoDisabled: false, ++ redoDisabled: true, ++ saveDisabled: false, ++ rehoverCount: 0, ++ }); ++ ++ editor.undo(); ++ let rehoverBeforeRedo = rehoverCount; ++ ++ assert.deepEqual(snapshot(editor, value, rehoverCount), { ++ value: 'initial', ++ modified: true, ++ undoDisabled: true, ++ redoDisabled: false, ++ saveDisabled: false, ++ rehoverCount: rehoverBeforeRedo, ++ }); ++ ++ editor.redo(); ++ ++ assert.equal(value, 'first edit'); ++ assert.equal(editor.undo_button.disabled, false); ++ assert.equal(editor.redo_button.disabled, true); ++ assert.equal(rehoverCount, rehoverBeforeRedo + 1); ++ assertSaveButtonConsistent(editor); ++ ++ editor.undo(); ++ assert.equal(value, 'initial'); ++}); ++ ++test('redo with no redo history is a no-op and double redo is idempotent', () => { ++ ++ ++ let editor = makeUndoReadyEditor(); ++ let value = 'initial'; ++ ++ editor.redo(); ++ ++ assert.deepEqual(snapshot(editor, value), { ++ value: 'initial', ++ modified: false, ++ undoDisabled: true, ++ redoDisabled: true, ++ saveDisabled: true, ++ rehoverCount: 0, ++ }); ++ ++ editor._do(() => { value = 'first edit'; }, () => { value = 'initial'; }); ++ editor.commit_undo(); ++ editor.undo(); ++ editor.redo(); ++ editor.redo(); ++ ++ assert.equal(value, 'first edit'); ++ assert.equal(editor.undo_button.disabled, false); ++ assert.equal(editor.redo_button.disabled, true); ++ assertSaveButtonConsistent(editor); ++}); ++ ++test('new edit after undo discards stale redo branch', () => { ++ ++ ++ let editor = makeUndoReadyEditor(); ++ let value = 'initial'; ++ ++ editor._do(() => { value = 'first edit'; }, () => { value = 'initial'; }); ++ editor.commit_undo(); ++ editor.undo(); ++ ++ assert.deepEqual(snapshot(editor, value), { ++ value: 'initial', ++ modified: true, ++ undoDisabled: true, ++ redoDisabled: false, ++ saveDisabled: false, ++ rehoverCount: 0, ++ }); ++ ++ editor._do(() => { value = 'second edit'; }, () => { value = 'initial'; }); ++ editor.commit_undo(); ++ ++ assert.deepEqual(snapshot(editor, value), { ++ value: 'second edit', ++ modified: true, ++ undoDisabled: false, ++ redoDisabled: true, ++ saveDisabled: false, ++ rehoverCount: 0, ++ }); ++ ++ editor.redo(); ++ ++ assert.deepEqual(snapshot(editor, value), { ++ value: 'second edit', ++ modified: true, ++ undoDisabled: false, ++ redoDisabled: true, ++ saveDisabled: false, ++ rehoverCount: 0, ++ }); ++}); ++ ++test('two editor instances keep independent undo and redo histories', () => { ++ ++ ++ let a = makeUndoReadyEditor(); ++ let b = makeUndoReadyEditor(); ++ let avalue = 'A0'; ++ let bvalue = 'B0'; ++ ++ a._do(() => { avalue = 'A1'; }, () => { avalue = 'A0'; }); ++ a.commit_undo(); ++ a.undo(); ++ b._do(() => { bvalue = 'B1'; }, () => { bvalue = 'B0'; }); ++ b.commit_undo(); ++ ++ ++ a.redo(); ++ assert.equal(avalue, 'A1'); ++ assert.equal(bvalue, 'B1'); ++ b.redo(); ++ assert.equal(avalue, 'A1'); ++ assert.equal(bvalue, 'B1'); ++ a.undo(); ++ assert.equal(avalue, 'A0'); ++ assert.equal(bvalue, 'B1'); ++}); ++ ++test('menubar exposes Redo and Ctrl+Y/Ctrl+Shift+Z call redo while active', () => { ++ ++ ++ class SetupProbeEditor extends Editor { ++ set_canvas_zoom() {} ++ svg_icon(id) { ++ let el = document.createElement('svg'); ++ el.setAttribute('data-icon', id); ++ return el; ++ } ++ select_tool(tool) { ++ this.current_tool = tool; ++ } ++ select_foreground_tile(_name, _source) {} ++ select_background_tile(_name, _source) {} ++ reset_undo() { ++ attachUndoUi(this); ++ super.reset_undo(); ++ } ++ } ++ ++ let editor = new SetupProbeEditor(makeConductor()); ++ let redoCalls = 0; ++ editor.redo = () => { redoCalls += 1; }; ++ editor.setup(); ++ ++ let buttons = document.body.querySelector('main#editor')._descendants() ++ .filter(el => el.tagName === 'BUTTON'); ++ let labelledButtons = buttons.map(el => ({ ++ el, ++ label: el.children.map(child => child.textContent).join('') || el.textContent, ++ })); ++ let redoButton = labelledButtons.find(({label}) => label === 'Redo')?.el; ++ ++ assert.ok(redoButton); ++ redoButton.dispatchEvent({type: 'click'}); ++ assert.equal(redoCalls, 1); ++ ++ editor.active = false; ++ window.dispatchEvent({type: 'keydown', key: 'y', ctrlKey: true, shiftKey: false}); ++ assert.equal(redoCalls, 1); ++ ++ editor.active = true; ++ window.dispatchEvent({type: 'keydown', key: 'y', ctrlKey: true, shiftKey: false}); ++ assert.equal(redoCalls, 2); ++ window.dispatchEvent({type: 'keydown', key: 'Z', ctrlKey: true, shiftKey: true}); ++ assert.equal(redoCalls, 3); ++}); ++ ++test('repeated construct edit undo redo cycles remain bounded', () => { ++ ++ ++ for (let i = 0; i < 100; i++) { ++ let editor = makeUndoReadyEditor(); ++ let value = 'initial'; ++ editor._do(() => { value = 'cycle edit'; }, () => { value = 'initial'; }); ++ editor.commit_undo(); ++ editor.undo(); ++ editor.redo(); ++ ++ assert.equal(value, 'cycle edit'); ++ assert.equal(editor.undo_button.disabled, false); ++ assert.equal(editor.redo_button.disabled, true); ++ assertSaveButtonConsistent(editor); ++ } ++}); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,15 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo ++ ++exec node --test /workspace/repo/usercase-test-coderl/editor_redo.test.js diff --git a/tasks/format-code-task-000853/tests/test.sh b/tasks/format-code-task-000853/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..303128f5c294a7291d6ad43800b42898799e4195 --- /dev/null +++ b/tasks/format-code-task-000853/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/editor_redo.test.js +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000853/tests/test_command.sh b/tasks/format-code-task-000853/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000853/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000854/environment/Dockerfile b/tasks/format-code-task-000854/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..aa39ca822f36cdfce76a2cb07f82864a5f0db38a --- /dev/null +++ b/tasks/format-code-task-000854/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:a20930c5705d30828eb4954ae3021e72f7c80898d6e70021ac92685c7064c2d5 diff --git a/tasks/format-code-task-000854/environment/setup/files/blocklist b/tasks/format-code-task-000854/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000854/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000854/environment/setup/setup.sh b/tasks/format-code-task-000854/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000854/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000854/tests/test.patch b/tasks/format-code-task-000854/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..2d16c726bc58ab7003898012f26adbc7a4ddb089 --- /dev/null +++ b/tasks/format-code-task-000854/tests/test.patch @@ -0,0 +1,457 @@ +diff --git a/usercase-test-coderl/test_dataclassio_json_helpers.py b/usercase-test-coderl/test_dataclassio_json_helpers.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_dataclassio_json_helpers.py +@@ -0,0 +1,428 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++from __future__ import annotations ++ ++import copy ++import json ++import os ++import socket ++import subprocess ++import sys ++from dataclasses import dataclass ++from enum import Enum ++from pathlib import Path ++from typing import Annotated, Any ++ ++import pytest ++ ++from efro.dataclassio import ( ++ EXTRA_ATTRS_ATTR, ++ IOAttrs, ++ dataclass_from_json, ++ dataclass_to_json, ++ ioprepped, ++) ++ ++ ++@ioprepped ++@dataclass ++class ScoreCard: ++ name: str ++ score: int ++ ++ ++@ioprepped ++@dataclass ++class OrderedCard: ++ zebra: int ++ alpha: int ++ mid: str ++ ++ ++@ioprepped ++@dataclass ++class FloatCard: ++ value: float ++ label: str = 'flt' ++ ++ ++@ioprepped ++@dataclass ++class NestedCard: ++ title: str ++ child: ScoreCard ++ tags: list[str] ++ meta: dict[str, int] ++ ratio: float ++ ++ ++@ioprepped ++@dataclass ++class StoredNameCard: ++ public_name: Annotated[str, IOAttrs('n')] ++ score: Annotated[int, IOAttrs('s')] ++ ++ ++@ioprepped ++@dataclass ++class AnyPayloadCard: ++ payload: Any ++ ++ ++@ioprepped ++@dataclass ++class FallbackCard: ++ class State(Enum): ++ KNOWN = 'known' ++ OTHER = 'other' ++ ++ label: str ++ state: Annotated[State, IOAttrs('st', enum_fallback=State.OTHER)] ++ ++ ++def test_to_json_compact_default_separators() -> None: ++ ++ ++ ++ obj = ScoreCard(name='bob', score=7) ++ ++ actual = dataclass_to_json(obj) ++ ++ assert actual == '{"name":"bob","score":7}' ++ ++ ++def test_to_json_pretty_sorts_keys_by_default() -> None: ++ ++ ++ ++ obj = OrderedCard(zebra=2, alpha=1, mid='m') ++ ++ actual = dataclass_to_json(obj, pretty=True) ++ ++ assert actual == '{\n "alpha": 1,\n "mid": "m",\n "zebra": 2\n}' ++ ++ ++def test_to_json_compact_sort_keys_true() -> None: ++ ++ ++ ++ obj = OrderedCard(zebra=2, alpha=1, mid='m') ++ ++ actual = dataclass_to_json(obj, sort_keys=True) ++ ++ assert actual == '{"alpha":1,"mid":"m","zebra":2}' ++ ++ ++def test_to_json_pretty_sort_keys_false() -> None: ++ ++ ++ ++ obj = OrderedCard(zebra=2, alpha=1, mid='m') ++ ++ actual = dataclass_to_json(obj, pretty=True, sort_keys=False) ++ ++ assert actual == '{\n "zebra": 2,\n "alpha": 1,\n "mid": "m"\n}' ++ ++ ++def test_to_json_uses_json_codec_dict_conversion() -> None: ++ ++ ++ ++ obj = NestedCard( ++ title='match', ++ child=ScoreCard(name='ana', score=11), ++ tags=['red', 'blue'], ++ meta={'wins': 3, 'losses': 1}, ++ ratio=2, ++ ) ++ ++ actual = dataclass_to_json(obj) ++ ++ assert ( ++ actual ++ == '{"title":"match","child":{"name":"ana","score":11},' ++ '"tags":["red","blue"],"meta":{"wins":3,"losses":1},"ratio":2.0}' ++ ) ++ ++ ++def test_to_json_uses_field_storage_names() -> None: ++ ++ ++ ++ obj = StoredNameCard(public_name='bob', score=7) ++ ++ actual = dataclass_to_json(obj) ++ ++ assert actual == '{"n":"bob","s":7}' ++ ++ ++def test_to_json_forwards_coerce_to_float_true_default() -> None: ++ ++ ++ ++ obj = FloatCard(value=2) ++ ++ actual = dataclass_to_json(obj) ++ ++ assert actual == '{"value":2.0,"label":"flt"}' ++ ++ ++def test_to_json_forwards_coerce_to_float_false_error() -> None: ++ ++ ++ ++ obj = FloatCard(value=2) ++ ++ with pytest.raises(TypeError) as excinfo: ++ dataclass_to_json(obj, coerce_to_float=False) ++ ++ ++ assert isinstance(excinfo.value, TypeError) ++ ++ ++def test_to_json_rejects_nonfinite_float_values() -> None: ++ ++ ++ ++ obj = AnyPayloadCard(payload=float('nan')) ++ ++ with pytest.raises(ValueError) as excinfo: ++ dataclass_to_json(obj) ++ ++ ++ assert isinstance(excinfo.value, ValueError) ++ ++ ++def test_from_json_returns_equal_dataclass_instance() -> None: ++ ++ ++ ++ actual = dataclass_from_json(ScoreCard, '{"name":"bob","score":7}') ++ ++ assert actual == ScoreCard(name='bob', score=7) ++ ++ ++def test_from_json_forwards_coerce_to_float_true_default() -> None: ++ ++ ++ ++ actual = dataclass_from_json(FloatCard, '{"value":2}') ++ ++ assert actual == FloatCard(value=2.0, label='flt') ++ ++ ++def test_from_json_forwards_coerce_to_float_false_error() -> None: ++ ++ ++ ++ with pytest.raises(TypeError) as excinfo: ++ dataclass_from_json(FloatCard, '{"value":2}', coerce_to_float=False) ++ ++ ++ assert isinstance(excinfo.value, TypeError) ++ ++ ++def test_from_json_preserves_unknown_attrs_by_default() -> None: ++ ++ ++ ++ actual = dataclass_from_json( ++ ScoreCard, '{"name":"bob","score":7,"nickname":"bobby"}' ++ ) ++ ++ assert actual == ScoreCard(name='bob', score=7) ++ assert getattr(actual, EXTRA_ATTRS_ATTR) == {'nickname': 'bobby'} ++ ++ ++def test_from_json_forwards_allow_unknown_attrs_false() -> None: ++ ++ ++ ++ with pytest.raises(AttributeError) as excinfo: ++ dataclass_from_json( ++ ScoreCard, ++ '{"name":"bob","score":7,"nickname":"bobby"}', ++ allow_unknown_attrs=False, ++ ) ++ ++ ++ assert isinstance(excinfo.value, AttributeError) ++ ++ ++def test_from_json_forwards_discard_unknown_attrs_true() -> None: ++ ++ ++ ++ actual = dataclass_from_json( ++ ScoreCard, ++ '{"name":"bob","score":7,"nickname":"bobby"}', ++ discard_unknown_attrs=True, ++ ) ++ ++ assert actual == ScoreCard(name='bob', score=7) ++ assert not hasattr(actual, EXTRA_ATTRS_ATTR) ++ ++ ++def test_from_json_uses_existing_dict_input_path_storage_names() -> None: ++ ++ ++ ++ actual = dataclass_from_json(StoredNameCard, '{"n":"bob","s":7}') ++ ++ assert actual == StoredNameCard(public_name='bob', score=7) ++ ++ ++def test_from_json_forwards_lossy_false_default() -> None: ++ ++ ++ ++ with pytest.raises(ValueError) as excinfo: ++ dataclass_from_json(FallbackCard, '{"label":"x","st":"new-state"}') ++ ++ ++ assert isinstance(excinfo.value, ValueError) ++ ++ ++def test_from_json_forwards_lossy_true() -> None: ++ ++ ++ ++ actual = dataclass_from_json( ++ FallbackCard, '{"label":"x","st":"new-state"}', lossy=True ++ ) ++ ++ assert actual == FallbackCard(label='x', state=FallbackCard.State.OTHER) ++ ++ ++def test_from_json_invalid_json_raises_decode_error() -> None: ++ ++ ++ ++ with pytest.raises(json.JSONDecodeError) as excinfo: ++ dataclass_from_json(ScoreCard, '{') ++ ++ ++ assert isinstance(excinfo.value, json.JSONDecodeError) ++ ++ ++def test_from_json_valid_json_nondict_raises_validation_typeerror() -> None: ++ ++ ++ ++ with pytest.raises(TypeError) as excinfo: ++ dataclass_from_json(ScoreCard, '[1,2]') ++ ++ ++ assert isinstance(excinfo.value, TypeError) ++ ++ ++def test_from_json_valid_object_bad_value_raises_validation_typeerror() -> None: ++ ++ ++ ++ with pytest.raises(TypeError) as excinfo: ++ dataclass_from_json(ScoreCard, '{"name":"bob","score":"seven"}') ++ ++ ++ assert isinstance(excinfo.value, TypeError) ++ ++ ++def test_referential_transparency_same_input_same_value() -> None: ++ obj = NestedCard( ++ title='match', ++ child=ScoreCard(name='ana', score=11), ++ tags=['red', 'blue'], ++ meta={'wins': 3, 'losses': 1}, ++ ratio=2, ++ ) ++ ++ assert dataclass_to_json(obj, sort_keys=True) == dataclass_to_json( ++ obj, sort_keys=True ++ ) ++ assert dataclass_from_json(ScoreCard, '{"name":"bob","score":7}') == ( ++ dataclass_from_json(ScoreCard, '{"name":"bob","score":7}') ++ ) ++ ++ ++def test_no_mutation_of_caller_inputs() -> None: ++ obj = NestedCard( ++ title='match', ++ child=ScoreCard(name='ana', score=11), ++ tags=['red', 'blue'], ++ meta={'wins': 3, 'losses': 1}, ++ ratio=2, ++ ) ++ obj_before = copy.deepcopy(obj) ++ json_str = '{"name":"bob","score":7,"nickname":"bobby"}' ++ json_str_before = copy.deepcopy(json_str) ++ ++ assert dataclass_to_json(obj) == ( ++ '{"title":"match","child":{"name":"ana","score":11},' ++ '"tags":["red","blue"],"meta":{"wins":3,"losses":1},"ratio":2.0}' ++ ) ++ assert dataclass_from_json(ScoreCard, json_str) == ScoreCard( ++ name='bob', score=7 ++ ) ++ ++ assert obj == obj_before ++ assert json_str == json_str_before ++ ++ ++def test_no_global_state_fresh_process_matches_in_process() -> None: ++ obj = OrderedCard(zebra=2, alpha=1, mid='m') ++ actual = dataclass_to_json(obj, pretty=True) ++ script = r''' ++from dataclasses import dataclass ++from efro.dataclassio import dataclass_to_json, ioprepped ++ ++@ioprepped ++@dataclass ++class OrderedCard: ++ zebra: int ++ alpha: int ++ mid: str ++ ++print(dataclass_to_json(OrderedCard(zebra=2, alpha=1, mid='m'), pretty=True), end='') ++''' ++ ++ env = dict(os.environ) ++ env['PYTHONPATH'] = '/workspace/repo/tools' ++ result = subprocess.run( ++ [sys.executable, '-c', script], ++ check=True, ++ env=env, ++ stdout=subprocess.PIPE, ++ stderr=subprocess.PIPE, ++ text=True, ++ ) ++ ++ assert actual == '{\n "alpha": 1,\n "mid": "m",\n "zebra": 2\n}' ++ assert result.stdout == '{\n "alpha": 1,\n "mid": "m",\n "zebra": 2\n}' ++ ++ ++def test_no_undeclared_filesystem_or_network_side_effects( ++ tmp_path: Path, monkeypatch: pytest.MonkeyPatch ++) -> None: ++ def socket_blocked(*_args: Any, **_kwargs: Any) -> Any: ++ raise AssertionError('dataclass JSON helpers must not open sockets') ++ ++ monkeypatch.setattr(socket, 'socket', socket_blocked) ++ monkeypatch.chdir(tmp_path) ++ before = sorted(path.relative_to(tmp_path).as_posix() for path in tmp_path.rglob('*')) ++ ++ assert dataclass_to_json(ScoreCard(name='bob', score=7)) == ( ++ '{"name":"bob","score":7}' ++ ) ++ assert dataclass_from_json(ScoreCard, '{"name":"bob","score":7}') == ScoreCard( ++ name='bob', score=7 ++ ) ++ ++ after = sorted(path.relative_to(tmp_path).as_posix() for path in tmp_path.rglob('*')) ++ assert after == before == [] +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,19 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++export PYTHONPATH="/workspace/repo/tools" ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++ ++exec /workspace/repo/.venv/bin/python -m pytest \ ++ /workspace/repo/usercase-test-coderl/test_dataclassio_json_helpers.py -v diff --git a/tasks/format-code-task-000854/tests/test.sh b/tasks/format-code-task-000854/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..b4500fe7027ad92badf26ed5ceff635c9da6741b --- /dev/null +++ b/tasks/format-code-task-000854/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/test_dataclassio_json_helpers.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000854/tests/test_command.sh b/tasks/format-code-task-000854/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000854/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000862/environment/Dockerfile b/tasks/format-code-task-000862/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ecdca4a19c0d9def672c45a591ecea23f6c8ff94 --- /dev/null +++ b/tasks/format-code-task-000862/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:c417ba0968ee21975107df59ae24eba2d0018e22690a120296f892fcfd077de7 diff --git a/tasks/format-code-task-000862/environment/setup/files/blocklist b/tasks/format-code-task-000862/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000862/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000862/environment/setup/setup.sh b/tasks/format-code-task-000862/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000862/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000862/tests/test.patch b/tasks/format-code-task-000862/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..694aca5bb0d7ca49e8ef1b9efbca16d060491f9d --- /dev/null +++ b/tasks/format-code-task-000862/tests/test.patch @@ -0,0 +1,81 @@ +diff --git a/metricbeat/module/mysql/status/status_integration_test.go b/metricbeat/module/mysql/status/status_integration_test.go +index 7ccc0a77ef5c..bc7bf8e40e9f 100644 +--- a/metricbeat/module/mysql/status/status_integration_test.go ++++ b/metricbeat/module/mysql/status/status_integration_test.go +@@ -33,12 +33,13 @@ import ( + func TestFetch(t *testing.T) { + compose.EnsureUp(t, "mysql") + +- f := mbtest.NewEventFetcher(t, getConfig(false)) +- event, err := f.Fetch() +- if !assert.NoError(t, err) { +- t.FailNow() ++ f := mbtest.NewReportingMetricSetV2Error(t, getConfig(false)) ++ events, errs := mbtest.ReportingFetchV2Error(f) ++ if len(errs) > 0 { ++ t.Fatalf("Expected 0 errors, had %d. %v\n", len(errs), errs) + } +- ++ assert.NotEmpty(t, events) ++ event := events[0].MetricSetFields + t.Logf("%s/%s event: %+v", f.Module().Name(), f.Name(), event) + + // Check event fields +@@ -57,12 +58,13 @@ func TestFetch(t *testing.T) { + func TestFetchRaw(t *testing.T) { + compose.EnsureUp(t, "mysql") + +- f := mbtest.NewEventFetcher(t, getConfig(true)) +- event, err := f.Fetch() +- if !assert.NoError(t, err) { +- t.FailNow() ++ f := mbtest.NewReportingMetricSetV2Error(t, getConfig(true)) ++ events, errs := mbtest.ReportingFetchV2Error(f) ++ if len(errs) > 0 { ++ t.Fatalf("Expected 0 errors, had %d. %v\n", len(errs), errs) + } +- ++ assert.NotEmpty(t, events) ++ event := events[0].MetricSetFields + t.Logf("%s/%s event: %+v", f.Module().Name(), f.Name(), event) + + // Check event fields +@@ -81,9 +83,9 @@ func TestFetchRaw(t *testing.T) { + } + + func TestData(t *testing.T) { +- f := mbtest.NewEventFetcher(t, getConfig(false)) ++ f := mbtest.NewReportingMetricSetV2Error(t, getConfig(false)) + +- err := mbtest.WriteEvent(f, t) ++ err := mbtest.WriteEventsReporterV2Error(f, t, "") + if err != nil { + t.Fatal("write", err) + } +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,11 @@ ++H4sIAAAAAAAAA+3TW2/TMBQA4D7nVxyGROEhdb22VKgqYrBsq9StoxcQT5WbuK01xw6+dEzaj8dp ++u61CjCG0CSHO95A4ji/HPnZt5oXMplytSOWp1IN2q7V+Bz++12Xa2qf0dbNebzQqdUpb7WYFWk8W ++0Q5vHTMAFaO1+1W7h/7/o2p3+Xfcummq85yprGaXjzfHA/mnTUrv8l/W02ar3a5A/fFCuN9/nv80 ++g3XiZzyLoueQKOsNh9Or0cc+CAvGKyXUIhJzeAb5lf0qWZYLBUWohDi2QnLlYP8tyfiKKC9lB9yS ++qwiC4kJICfGbTb9stxVcX4Mznq/bWcl5AXRd3jaNY2+56a6/wkfGHMuE6ZIVM0SKGdn8eLHTvRHN ++RbmAEXdQpgoKZu2lNhk4DdVyhVV4KTKeF9qFkF9F27H9pnXMYe+gP06GMBmFR7WsrL6rSp0yudRl ++595hcjbuHfWSQ/jcG59sIp0q5sSKT28ne/9lO1kHjvqT0QmcD3ufev3kOBl19n66A9uYfQHHg/OD ++MLBkV9q7iH8rtHHbyi4pAyILfVdNKT0dHE76SVfP5zfVZ4Pph8Hp+WCUdGmUX4Q9g7iAm87EmpQs ++hFv6WS3cc8Ils06kkVQQ2/ntOXioPZlx5uzOaUm1MTwNQWlYcWOFVlFYZmwvhUuXsNBAa/uN+xY/ ++9Ko8MiCU4wsTtlOH7xCIjdLfjITk3BmRlmWS68xLvjkfJNxs520UAigHhNixhe3uzhOvIE61Vy7s ++1t++iAghhBBCCCGEEEIIIYQQQgghhBBCf+g7f33tmgAoAAA= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000862/tests/test.sh b/tasks/format-code-task-000862/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..2f179f2b7a79e57922a512b7887b6fa41c6ac8a7 --- /dev/null +++ b/tasks/format-code-task-000862/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +metricbeat/module/mysql/status/status_integration_test.go +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000862/tests/test_command.sh b/tasks/format-code-task-000862/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000862/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000865/environment/Dockerfile b/tasks/format-code-task-000865/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e9cc245374797ec68c95c7acac098f0ee4c1e760 --- /dev/null +++ b/tasks/format-code-task-000865/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:e001487df069f1abe33fbe8722b8b5bf62b9a7b31babc78a4dbeb5f3b5c34fc5 diff --git a/tasks/format-code-task-000865/environment/setup/files/blocklist b/tasks/format-code-task-000865/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000865/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000865/environment/setup/setup.sh b/tasks/format-code-task-000865/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000865/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000865/tests/test.patch b/tasks/format-code-task-000865/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..c691a49198cbcd545d7789759f47fff217253639 --- /dev/null +++ b/tasks/format-code-task-000865/tests/test.patch @@ -0,0 +1,82 @@ +diff --git a/logstash/tests/logstash_test.py b/logstash/tests/logstash_test.py +index 513de1be..89584651 100755 +--- a/logstash/tests/logstash_test.py ++++ b/logstash/tests/logstash_test.py +@@ -858,6 +858,55 @@ service: + } + + ++def test_secretschecksum_annotation_present_when_secrets_set(): ++ content = "LS1CRUdJTiBgUFJJVkFURSB" ++ config = """ ++secrets: ++ - name: "env" ++ value: ++ ELASTICSEARCH_PASSWORD: {elk_pass} ++""".format( ++ elk_pass=content ++ ) ++ r = helm_template(config) ++ annotations = r["statefulset"][name]["spec"]["template"]["metadata"]["annotations"] ++ assert "secretschecksum" in annotations ++ ++ assert isinstance(annotations["secretschecksum"], str) ++ assert len(annotations["secretschecksum"]) > 0 ++ ++ ++def test_secretschecksum_annotation_absent_when_no_secrets(): ++ config = "" ++ r = helm_template(config) ++ annotations = ( ++ r["statefulset"][name]["spec"]["template"]["metadata"].get("annotations") or {} ++ ) ++ assert "secretschecksum" not in annotations ++ ++ ++def test_secretschecksum_changes_when_secret_value_changes(): ++ config_a = """ ++secrets: ++ - name: "env" ++ value: ++ ELASTICSEARCH_PASSWORD: AAAAAAAAAAAAAAAAAAAA ++""" ++ config_b = """ ++secrets: ++ - name: "env" ++ value: ++ ELASTICSEARCH_PASSWORD: BBBBBBBBBBBBBBBBBBBB ++""" ++ r_a = helm_template(config_a) ++ r_b = helm_template(config_b) ++ ann_a = r_a["statefulset"][name]["spec"]["template"]["metadata"]["annotations"] ++ ann_b = r_b["statefulset"][name]["spec"]["template"]["metadata"]["annotations"] ++ assert "secretschecksum" in ann_a ++ assert "secretschecksum" in ann_b ++ assert ann_a["secretschecksum"] != ann_b["secretschecksum"] ++ ++ + def test_setting_fullnameOverride(): + config = """ + fullnameOverride: 'logstash-custom' +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..0fe0c6e4 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["cd logstash && pytest -sv --color=no tests/logstash_test.py -k secretschecksum"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++cd logstash && pytest -sv --color=no tests/logstash_test.py -k secretschecksum ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000865/tests/test.sh b/tasks/format-code-task-000865/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..124e924f0cd222ddc215dfe82d71f3891ea5cb28 --- /dev/null +++ b/tasks/format-code-task-000865/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +logstash/tests/logstash_test.py +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000865/tests/test_command.sh b/tasks/format-code-task-000865/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000865/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000891/environment/Dockerfile b/tasks/format-code-task-000891/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f7cc64d965c2985802561f0a763026162c85a8f3 --- /dev/null +++ b/tasks/format-code-task-000891/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:dc14370162b16675c622ce1c2ee94c48112aa095f8e02b1291ff3caa1b70b0e4 diff --git a/tasks/format-code-task-000891/environment/setup/files/blocklist b/tasks/format-code-task-000891/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000891/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000891/environment/setup/setup.sh b/tasks/format-code-task-000891/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000891/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000891/tests/test.patch b/tasks/format-code-task-000891/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e0cb8c584263e08acaa9adf75beb780948993c87 --- /dev/null +++ b/tasks/format-code-task-000891/tests/test.patch @@ -0,0 +1,108 @@ +diff --git a/__tests__/always-return.js b/__tests__/always-return.js +index 23475ae..b8b6a03 100644 +--- a/__tests__/always-return.js ++++ b/__tests__/always-return.js +@@ -8,6 +8,12 @@ const ruleTester = new RuleTester({ + }, + }) + ++const ruleTester2020 = new RuleTester({ ++ parserOptions: { ++ ecmaVersion: 2020, ++ }, ++}) ++ + const message = 'Each then() should return a value or throw' + + ruleTester.run('always-return', rule, { +@@ -108,3 +114,68 @@ ruleTester.run('always-return', rule, { + }, + ], + }) ++ ++ ++ ++ ++ruleTester2020.run('always-return', rule, { ++ valid: [ ++ ++ `axios.get(state.baseUrl) ++ .then((results) => { ++ if (results.status === 200) { ++ commit('setAbout', results.data.payload) ++ return results ++ } ++ else { ++ throw new Error(results.data.error || results.data) ++ } ++ }) ++ .catch(function (error) { ++ console.error('fetch about', error) ++ throw error ++ })`, ++ ++ 'hey.then(x => { if (x) { return x } else { throw new Error(x.a || x.b) } })', ++ ++ 'hey.then(x => { throw new Error(x.a || x.b) })', ++ ++ 'hey.then(x => { if (x) { return x } else { throw new Error(x.a ? x.a : x.b) } })', ++ ++ 'hey.then(x => { if (x) { return x } else { throw new Error(x.a && x.b) } })', ++ ++ 'hey.then(x => { if (x) { return x } else { throw new Error("e") } })', ++ ++ 'hey.then(x => { if (x) { throw new Error("e") } else { return x } })', ++ ++ 'hey.then(x => { try { return doIt(x) } catch (e) { throw e } })', ++ ++ 'hey.then(x => { switch (x) { case 1: return 1; default: return 0 } })', ++ ++ 'hey.then(x => { switch (x) { case 1: return 1; default: throw new Error() } })', ++ ++ 'hey.then(x => { while (true) { return x } })', ++ ++ 'hey.then(x => { if (x) { return 1 } return 2 })', ++ ++ 'hey.then(x => { if (x) { return 1 } throw new Error() })', ++ ], ++ ++ invalid: [ ++ ++ { ++ code: 'hey.then(x => { if (x) { return 1 } })', ++ errors: [{ message }], ++ }, ++ ++ { ++ code: 'hey.then(x => { if (x) { throw new Error() } })', ++ errors: [{ message }], ++ }, ++ ++ { ++ code: 'hey.then(x => { if (x) { console.log(1) } else { console.log(2) } })', ++ errors: [{ message }], ++ }, ++ ], ++}) +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..c7aa9aa +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["node_modules/.bin/jest __tests__/always-return.js --selectProjects test"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++node_modules/.bin/jest __tests__/always-return.js --selectProjects test ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000891/tests/test.sh b/tasks/format-code-task-000891/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..065db192db3b536c1ea2f85277208265f04bcf7f --- /dev/null +++ b/tasks/format-code-task-000891/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +__tests__/always-return.js +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000891/tests/test_command.sh b/tasks/format-code-task-000891/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000891/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000896/environment/Dockerfile b/tasks/format-code-task-000896/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..84002d4463f99006ec145ef9a91d7b50bc976d68 --- /dev/null +++ b/tasks/format-code-task-000896/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:c9643323d0d97698da622f7cabff6bbc1a4066ff0c4fc2dfb2fa418357a10d92 diff --git a/tasks/format-code-task-000896/environment/setup/files/blocklist b/tasks/format-code-task-000896/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000896/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000896/environment/setup/setup.sh b/tasks/format-code-task-000896/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000896/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000896/tests/test.patch b/tasks/format-code-task-000896/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..db821160d0e7da3c0b599824e526515e64b84db5 --- /dev/null +++ b/tasks/format-code-task-000896/tests/test.patch @@ -0,0 +1,211 @@ +diff --git a/server/etcdserver/bootstrap_test.go b/server/etcdserver/bootstrap_test.go +index 8d6effd450f9..3db684d56747 100644 +--- a/server/etcdserver/bootstrap_test.go ++++ b/server/etcdserver/bootstrap_test.go +@@ -19,16 +19,28 @@ package etcdserver + + import ( + "encoding/json" ++ "fmt" ++ bolt "go.etcd.io/bbolt" ++ "go.etcd.io/etcd/server/v3/storage/datadir" ++ "go.etcd.io/etcd/server/v3/storage/schema" ++ "go.etcd.io/etcd/server/v3/storage/wal" ++ "go.etcd.io/etcd/server/v3/storage/wal/walpb" + "io" + "net/http" ++ "os" ++ "path/filepath" + "strings" + "testing" + + "go.etcd.io/etcd/api/v3/etcdserverpb" + "go.etcd.io/etcd/api/v3/version" + "go.etcd.io/etcd/client/pkg/v3/types" ++ "go.etcd.io/etcd/raft/v3/raftpb" + "go.etcd.io/etcd/server/v3/config" + "go.etcd.io/etcd/server/v3/etcdserver/api/membership" ++ "go.etcd.io/etcd/server/v3/etcdserver/api/snap" ++ "go.etcd.io/etcd/server/v3/etcdserver/api/v2store" ++ serverstorage "go.etcd.io/etcd/server/v3/storage" + "go.uber.org/zap" + ) + +@@ -138,3 +150,156 @@ func mockMembersJSON(m []etcdserverpb.Member) string { + members, _ := json.Marshal(m) + return string(members) + } ++ ++func TestBootstrapBackend(t *testing.T) { ++ tests := []struct { ++ name string ++ prepareData func(config.ServerConfig) error ++ expectedConsistentIdx uint64 ++ expectedError error ++ }{ ++ { ++ name: "bootstrap backend success: no data files", ++ prepareData: nil, ++ expectedConsistentIdx: 0, ++ expectedError: nil, ++ }, ++ { ++ name: "bootstrap backend success: have data files and snapshot db file", ++ prepareData: prepareData, ++ expectedConsistentIdx: 5, ++ expectedError: nil, ++ }, ++ ++ ++ } ++ for _, tt := range tests { ++ t.Run(tt.name, func(t *testing.T) { ++ dataDir, err := createDataDir(t) ++ if err != nil { ++ t.Fatalf("Failed to create the data dir, unexpected error: %v", err) ++ } ++ ++ cfg := config.ServerConfig{ ++ Name: "demoNode", ++ DataDir: dataDir, ++ BackendFreelistType: bolt.FreelistArrayType, ++ Logger: zap.NewExample(), ++ } ++ ++ if tt.prepareData != nil { ++ if err := tt.prepareData(cfg); err != nil { ++ t.Fatalf("failed to prepare data, unexpected error: %v", err) ++ } ++ } ++ ++ haveWAL := wal.Exist(cfg.WALDir()) ++ st := v2store.New(StoreClusterPrefix, StoreKeysPrefix) ++ ss := snap.New(cfg.Logger, cfg.SnapDir()) ++ backend, err := bootstrapBackend(cfg, haveWAL, st, ss) ++ ++ hasError := err != nil ++ expectedHasError := tt.expectedError != nil ++ if hasError != expectedHasError { ++ t.Errorf("expected error: %v got: %v", expectedHasError, err) ++ } ++ if hasError && !strings.Contains(err.Error(), tt.expectedError.Error()) { ++ t.Fatalf("expected error to contain: %q, got: %q", tt.expectedError.Error(), err.Error()) ++ } ++ ++ if backend.ci.ConsistentIndex() != tt.expectedConsistentIdx { ++ t.Errorf("expected consistent index: %d, got: %d", tt.expectedConsistentIdx, backend.ci.ConsistentIndex()) ++ } ++ }) ++ } ++} ++ ++func createDataDir(t *testing.T) (dataDir string, err error) { ++ ++ dataDir = t.TempDir() ++ ++ ++ if err = os.MkdirAll(datadir.ToSnapDir(dataDir), 0700); err != nil { ++ return ++ } ++ ++ ++ err = os.MkdirAll(datadir.ToWalDir(dataDir), 0700) ++ ++ return ++} ++ ++ ++func prepareData(cfg config.ServerConfig) (err error) { ++ var snapshotTerm, snapshotIndex uint64 = 2, 5 ++ ++ if err = createWALFileWithSnapshotRecord(cfg, snapshotTerm, snapshotIndex); err != nil { ++ return ++ } ++ ++ return createSnapshotAndBackendDB(cfg, snapshotTerm, snapshotIndex) ++} ++ ++func createWALFileWithSnapshotRecord(cfg config.ServerConfig, snapshotTerm, snapshotIndex uint64) (err error) { ++ var w *wal.WAL ++ if w, err = wal.Create(cfg.Logger, cfg.WALDir(), []byte("somedata")); err != nil { ++ return ++ } ++ ++ defer func() { ++ err = w.Close() ++ }() ++ ++ walSnap := walpb.Snapshot{ ++ Index: snapshotIndex, ++ Term: snapshotTerm, ++ ConfState: &raftpb.ConfState{ ++ Voters: []uint64{0x00ffca74}, ++ AutoLeave: false, ++ }, ++ } ++ ++ if err = w.SaveSnapshot(walSnap); err != nil { ++ return ++ } ++ ++ return w.Save(raftpb.HardState{Term: snapshotTerm, Vote: 3, Commit: snapshotIndex}, nil) ++} ++ ++func createSnapshotAndBackendDB(cfg config.ServerConfig, snapshotTerm, snapshotIndex uint64) (err error) { ++ confState := raftpb.ConfState{ ++ Voters: []uint64{1, 2, 3}, ++ } ++ ++ ++ ss := snap.New(cfg.Logger, cfg.SnapDir()) ++ if err = ss.SaveSnap(raftpb.Snapshot{ ++ Data: []byte("{}"), ++ Metadata: raftpb.SnapshotMetadata{ ++ ConfState: confState, ++ Index: snapshotIndex, ++ Term: snapshotTerm, ++ }, ++ }); err != nil { ++ return ++ } ++ ++ ++ be := serverstorage.OpenBackend(cfg, nil) ++ schema.CreateMetaBucket(be.BatchTx()) ++ schema.UnsafeUpdateConsistentIndex(be.BatchTx(), snapshotIndex, snapshotTerm, false) ++ schema.MustUnsafeSaveConfStateToBackend(cfg.Logger, be.BatchTx(), &confState) ++ if err = be.Close(); err != nil { ++ return ++ } ++ sdb := filepath.Join(cfg.SnapDir(), fmt.Sprintf("%016x.snap.db", snapshotIndex)) ++ if err = os.Rename(cfg.BackendPath(), sdb); err != nil { ++ return ++ } ++ ++ ++ be = serverstorage.OpenBackend(cfg, nil) ++ schema.CreateMetaBucket(be.BatchTx()) ++ schema.UnsafeUpdateConsistentIndex(be.BatchTx(), 1, 1, false) ++ return be.Close() ++} +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,5 @@ ++H4sIAAAAAAAAA+3SsQ6CMBAG4M4+xRkTNylFKrvP4G4KbZSoxbSF57fioDFRFowx/h/DHdCGg5+k ++bOuj3hrbcfYpaVRI2dfoufa9kJmIxzLLBUuFkEXGSH5sogetD8oRMdc04d26ofs/KrnnH4wP26o5 ++nZTVid+P94yh/MXyIX+RxfxzWawYpeON8Nqf5z+b8rK2vFR+P6k09T9BafS198Z1xtF8TruGrtdp ++0dHCtZY28WQdv4cPTp3XqjoYqynhJlT6tolPvv1eAAAAAAAAAAAAAAAAAAAAAAD/4AIL42zUACgA ++AA== +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000896/tests/test.sh b/tasks/format-code-task-000896/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..9e19ac72278aea27386db8c016c6753d0200e6d0 --- /dev/null +++ b/tasks/format-code-task-000896/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +server/etcdserver/bootstrap_test.go +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000896/tests/test_command.sh b/tasks/format-code-task-000896/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000896/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000898/environment/Dockerfile b/tasks/format-code-task-000898/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c3ffe0e14db7b01d26b5a1482a33f16a4022adb6 --- /dev/null +++ b/tasks/format-code-task-000898/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:8bde23bf4531acaf06f9f3020de1f0d9cb59930f345ad53f0ceaae9b6116ece6 diff --git a/tasks/format-code-task-000898/environment/setup/files/blocklist b/tasks/format-code-task-000898/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000898/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000898/environment/setup/setup.sh b/tasks/format-code-task-000898/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000898/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000898/tests/test.patch b/tasks/format-code-task-000898/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..4af2f96eb3cd05ae6c2c608439032b29e1a10593 --- /dev/null +++ b/tasks/format-code-task-000898/tests/test.patch @@ -0,0 +1,156 @@ +diff --git a/src/tests/permutationsutil_test.cpp b/src/tests/permutationsutil_test.cpp +new file mode 100644 +index 0000000..dada1c9 +--- /dev/null ++++ b/src/tests/permutationsutil_test.cpp +@@ -0,0 +1,124 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++#include ++#include ++#include ++ ++#include "gtest/gtest.h" ++ ++#include "permutationsutil.h" ++ ++namespace { ++ ++ ++bool IsPermutationOf(std::vector a, std::vector b) { ++ std::sort(a.begin(), a.end()); ++ std::sort(b.begin(), b.end()); ++ return a == b; ++} ++ ++} ++ ++TEST(ComputeAllPermutationsTest, EnumeratesAllPermutationsOfDistinctElements) { ++ std::vector v = {1, 2, 3}; ++ std::unordered_set> permutations; ++ ComputeAllPermutations(v, &permutations, 1000); ++ ++ ++ EXPECT_EQ(6u, permutations.size()); ++ for (const std::vector& p : permutations) { ++ EXPECT_TRUE(IsPermutationOf(p, v)); ++ } ++ ++ EXPECT_EQ(1u, permutations.count(v)); ++} ++ ++TEST(ComputeAllPermutationsTest, CollapsesRepeatedArrangementsFromDuplicateValues) { ++ std::vector v = {1, 1, 2}; ++ std::unordered_set> permutations; ++ ComputeAllPermutations(v, &permutations, 1000); ++ ++ ++ EXPECT_EQ(3u, permutations.size()); ++ for (const std::vector& p : permutations) { ++ EXPECT_TRUE(IsPermutationOf(p, v)); ++ } ++} ++ ++TEST(ComputeAllPermutationsTest, StopsNearTheBeamSize) { ++ std::vector v = {1, 2, 3, 4, 5}; ++ std::unordered_set> permutations; ++ const size_t beam = 10; ++ ComputeAllPermutations(v, &permutations, beam); ++ ++ ++ ++ EXPECT_GE(permutations.size(), beam); ++ EXPECT_LE(permutations.size(), beam + 1); ++ for (const std::vector& p : permutations) { ++ EXPECT_TRUE(IsPermutationOf(p, v)); ++ } ++} ++ ++TEST(ComputeRandomPermutationsTest, CollectsEveryPermutationWhenBeamExceedsThem) { ++ std::vector v = {1, 2}; ++ std::unordered_set> permutations; ++ ComputeRandomPermutations(v, &permutations, 100, 50); ++ ++ EXPECT_EQ(2u, permutations.size()); ++ EXPECT_EQ(1u, permutations.count(std::vector({1, 2}))); ++ EXPECT_EQ(1u, permutations.count(std::vector({2, 1}))); ++} ++ ++TEST(ComputeRandomPermutationsTest, SingleElementYieldsOnePermutation) { ++ std::vector v = {5}; ++ std::unordered_set> permutations; ++ ComputeRandomPermutations(v, &permutations, 100, 10); ++ ++ EXPECT_EQ(1u, permutations.size()); ++ EXPECT_EQ(1u, permutations.count(std::vector({5}))); ++} ++ ++TEST(ComputeRandomPermutationsTest, NeverExceedsTheBeamSize) { ++ std::vector v = {1, 2, 3, 4}; ++ std::unordered_set> permutations; ++ const size_t beam = 3; ++ ComputeRandomPermutations(v, &permutations, beam, 100000); ++ ++ EXPECT_GE(permutations.size(), 1u); ++ EXPECT_LE(permutations.size(), beam); ++ for (const std::vector& p : permutations) { ++ EXPECT_TRUE(IsPermutationOf(p, v)); ++ } ++} ++ ++TEST(CalculateFactorialTest, ComputesSmallFactorials) { ++ EXPECT_EQ(1u, CalculateFactorial(0)); ++ EXPECT_EQ(1u, CalculateFactorial(1)); ++ EXPECT_EQ(120u, CalculateFactorial(5)); ++ EXPECT_EQ(3628800u, CalculateFactorial(10)); ++} ++ ++TEST(CalculateFactorialTest, ComputesLargestValueThatFits) { ++ EXPECT_EQ(2432902008176640000ULL, CalculateFactorial(20)); ++} ++ ++TEST(CalculateFactorialTest, ReturnsSentinelOnOverflow) { ++ const uint64 overflow = static_cast(-1); ++ EXPECT_EQ(overflow, CalculateFactorial(21)); ++ EXPECT_EQ(overflow, CalculateFactorial(25)); ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,21 @@ ++#!/usr/bin/env bash ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++REG_BUILD="$(mktemp -d)" ++cmake -D CMAKE_BUILD_TYPE=Release -S /testbed/src -B "$REG_BUILD" >/dev/null ++cmake --build "$REG_BUILD" --target base ++ ++ ++TEST_BIN="$(mktemp -d)/permutationsutil_test" ++g++ -std=c++14 -Wall -I /testbed/src/base \ ++ /testbed/src/tests/permutationsutil_test.cpp \ ++ -lgtest -lgtest_main -lpthread -o "$TEST_BIN" ++"$TEST_BIN" diff --git a/tasks/format-code-task-000898/tests/test.sh b/tasks/format-code-task-000898/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..cb98cb063380eeead0d9624c665f54ae9324a6fb --- /dev/null +++ b/tasks/format-code-task-000898/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +src/tests/permutationsutil_test.cpp +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000898/tests/test_command.sh b/tasks/format-code-task-000898/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000898/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000910/environment/Dockerfile b/tasks/format-code-task-000910/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..0f4e386b4e444afcb52746234ecd93c4aa6e6dd4 --- /dev/null +++ b/tasks/format-code-task-000910/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:d2554f905b0c1b85fc39543055117e3c9dee4b6bdd155007671ce6e7c5a4a5ff diff --git a/tasks/format-code-task-000910/environment/setup/files/blocklist b/tasks/format-code-task-000910/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000910/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000910/environment/setup/setup.sh b/tasks/format-code-task-000910/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000910/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000910/tests/test.patch b/tasks/format-code-task-000910/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e3c8b522305464793b0a0353ee3bcbaad35fb4c6 --- /dev/null +++ b/tasks/format-code-task-000910/tests/test.patch @@ -0,0 +1,401 @@ +diff --git a/src/Async/Async.spec.js b/src/Async/Async.spec.js +index 0fa0b085b..9fa83d3af 100644 +--- a/src/Async/Async.spec.js ++++ b/src/Async/Async.spec.js +@@ -14,7 +14,7 @@ const unit = require('../core/_unit') + const constant = x => () => x + const identity = x => x + +-const reverseApply = ++const applyTo = + x => fn => fn(x) + + const Async = require('.') +@@ -869,7 +869,7 @@ test('Async of properties (Applicative)', t => { + const bInterRes = sinon.spy() + + m.ap(Async.of(3)).fork(unit, aInterRes) +- Async.of(reverseApply(3)).ap(m).fork(unit, bInterRes) ++ Async.of(applyTo(3)).ap(m).fork(unit, bInterRes) + + t.same(aInterRes.args[0], bInterRes.args[0], 'interchange') + +diff --git a/src/Either/Either.spec.js b/src/Either/Either.spec.js +index 9013f3d83..11f2b19e5 100644 +--- a/src/Either/Either.spec.js ++++ b/src/Either/Either.spec.js +@@ -16,7 +16,7 @@ const unit = require('../core/_unit') + const either = + (f, g) => m => m.either(f, g) + +-const reverseApply = ++const applyTo = + x => fn => fn(x) + + const constant = x => () => x +@@ -703,7 +703,7 @@ test('Either of properties (Applicative)', t => { + ) + + const a = x => r.ap(Either.of(x)) +- const b = x => Either.of(reverseApply(x)).ap(r) ++ const b = x => Either.of(applyTo(x)).ap(r) + + t.equal( + a(3).either(constant(0),identity), +diff --git a/src/IO/IO.spec.js b/src/IO/IO.spec.js +index a4ec35fae..a27746772 100644 +--- a/src/IO/IO.spec.js ++++ b/src/IO/IO.spec.js +@@ -13,7 +13,7 @@ const unit = require('../core/_unit') + const constant = x => () => x + const identity = x => x + +-const reverseApply = ++const applyTo = + x => fn => fn(x) + + const IO = require('.') +@@ -214,7 +214,7 @@ test('IO of properties (Applicative)', t => { + t.equal(m.ap(IO.of(3)).run(), IO.of(identity(3)).run(), 'homomorphism') + + const a = x => m.ap(IO.of(x)) +- const b = x => IO.of(reverseApply(x)).ap(m) ++ const b = x => IO.of(applyTo(x)).ap(m) + + t.equal(a(3).run(), b(3).run(), 'interchange') + +diff --git a/src/Identity/Identity.spec.js b/src/Identity/Identity.spec.js +index bb16660f1..1d0ad36e8 100644 +--- a/src/Identity/Identity.spec.js ++++ b/src/Identity/Identity.spec.js +@@ -15,7 +15,7 @@ const unit = require('../core/_unit') + + const identity = x => x + +-const reverseApply = ++const applyTo = + x => fn => fn(x) + + const Identity = require('.') +@@ -318,7 +318,7 @@ test('Identity of properties (Applicative)', t => { + t.equal(m.ap(Identity.of(3)).valueOf(), Identity.of(identity(3)).valueOf(), 'homomorphism') + + const a = x => m.ap(Identity.of(x)) +- const b = x => Identity.of(reverseApply(x)).ap(m) ++ const b = x => Identity.of(applyTo(x)).ap(m) + + t.equal(a(3).valueOf(), b(3).valueOf(), 'interchange') + +diff --git a/src/Reader/Reader.spec.js b/src/Reader/Reader.spec.js +index 1850adbba..9380d83a0 100644 +--- a/src/Reader/Reader.spec.js ++++ b/src/Reader/Reader.spec.js +@@ -14,7 +14,7 @@ const unit = require('../core/_unit') + const constant = x => () => x + const identity = x => x + +-const reverseApply = ++const applyTo = + x => fn => fn(x) + + const Reader = require('.') +@@ -288,7 +288,7 @@ test('Reader of properties (Applicative)', t => { + t.equal(m.ap(Reader.of(3)).runWith(e), Reader.of(identity(3)).runWith(e), 'homomorphism') + + const a = x => m.ap(Reader.of(x)) +- const b = x => Reader.of(reverseApply(x)).ap(m) ++ const b = x => Reader.of(applyTo(x)).ap(m) + + t.equal(a(3).runWith(e), b(3).runWith(e), 'interchange') + +diff --git a/src/Reader/ReaderT.spec.js b/src/Reader/ReaderT.spec.js +index c7452f6af..f5cfd45bc 100644 +--- a/src/Reader/ReaderT.spec.js ++++ b/src/Reader/ReaderT.spec.js +@@ -12,7 +12,7 @@ const isObject = require('../core/isObject') + const isSameType = require('../core/isSameType') + const unit = require('../core/_unit') + +-const reverseApply = ++const applyTo = + x => fn => fn(x) + + const identity = x => x +@@ -379,7 +379,7 @@ test('ReaderT of properties (Applicative)', t => { + ) + + const a = x => m.ap(ReaderMock.of(x)) +- const b = x => ReaderMock.of(reverseApply(x)).ap(m) ++ const b = x => ReaderMock.of(applyTo(x)).ap(m) + + t.equal(a(3).runWith(e).valueOf(), b(3).runWith(e).valueOf(), 'interchange') + +diff --git a/src/Result/Result.spec.js b/src/Result/Result.spec.js +index 0fcc7bd16..260c32a0a 100644 +--- a/src/Result/Result.spec.js ++++ b/src/Result/Result.spec.js +@@ -19,7 +19,7 @@ const identity = x => x + const either = + (f, g) => m => m.either(f, g) + +-const reverseApply = ++const applyTo = + x => fn => fn(x) + + const Result = require('.') +@@ -736,7 +736,7 @@ test('Result of properties (Applicative)', t => { + ) + + const a = x => r.ap(Result.of(x)) +- const b = x => Result.of(reverseApply(x)).ap(r) ++ const b = x => Result.of(applyTo(x)).ap(r) + + t.equal( + a(3).either(constant(0),identity), +diff --git a/src/Writer/Writer.spec.js b/src/Writer/Writer.spec.js +index 6aa92608a..a96d19afb 100644 +--- a/src/Writer/Writer.spec.js ++++ b/src/Writer/Writer.spec.js +@@ -15,7 +15,7 @@ const unit = require('../core/_unit') + + const identity = x => x + +-const reverseApply = ++const applyTo = + x => fn => fn(x) + + const _Writer = require('.') +@@ -309,7 +309,7 @@ test('Writer of properties (Applicative)', t => { + t.equal(m.ap(Writer.of(3)).valueOf(), Writer.of(identity(3)).valueOf(), 'homomorphism') + + const a = x => m.ap(Writer.of(x)) +- const b = x => Writer.of(reverseApply(x)).ap(m) ++ const b = x => Writer.of(applyTo(x)).ap(m) + + t.equal(a(3).valueOf(), b(3).valueOf(), 'interchange') + +diff --git a/src/combinators/applyTo.spec.js b/src/combinators/applyTo.spec.js +index 65980768d..fd3339eae 100644 +--- a/src/combinators/applyTo.spec.js ++++ b/src/combinators/applyTo.spec.js +@@ -1,6 +1,7 @@ + const test = require('tape') + const sinon = require('sinon') + const helpers = require('../test/helpers') ++ + const bindFunc = helpers.bindFunc + + const isFunction = require('../core/isFunction') +@@ -9,33 +10,30 @@ const applyTo = require('./applyTo') + + const identity = x => x + +-test('applyTo (A Combinator)', t => { +- const a = +- bindFunc(applyTo) +- +- const fn = +- sinon.spy(identity) ++test('applyTo (T combinator)', t => { ++ const fn = bindFunc(applyTo) + + t.ok(isFunction(applyTo), 'is a function') + +- t.throws(a(undefined, 0), TypeError, 'throws when first arg is undefined') +- t.throws(a(null, 0), TypeError, 'throws when first arg is null') +- t.throws(a(0, 0), TypeError, 'throws when first arg is a falsey number') +- t.throws(a(1, 0), TypeError, 'throws when first arg is a truthy number') +- t.throws(a('', 0), TypeError, 'throws when first arg is a falsey string') +- t.throws(a('string', 0), TypeError, 'throws when first arg is a truthy string') +- t.throws(a(false, 0), TypeError, 'throws when first arg is false') +- t.throws(a(true, 0), TypeError, 'throws when first arg is true') +- t.throws(a([], 0), TypeError, 'throws when first arg is an array') +- t.throws(a({}, 0), TypeError, 'throws when first arg is an object') +- +- t.doesNotThrow(a(identity, 0), 'does not throw when first arg is a function') +- +- const x = 45 +- const result = applyTo(fn)(x) +- +- t.ok(fn.calledWith(x), 'passed function is called with the passed data') +- t.equal(result, fn.returnValues[0], 'returns the result of applying the data to the function') ++ const err = /applyTo: Function required for second argument/ ++ t.throws(fn(0, undefined), err, 'throws when second arg is undefined') ++ t.throws(fn(0, null), err, 'throws when second arg is null') ++ t.throws(fn(0, 0), err, 'throws when second arg is a falsey number') ++ t.throws(fn(0, 1), err, 'throws when second arg is a truthy number') ++ t.throws(fn(0, ''), err, 'throws when second arg is a falsey string') ++ t.throws(fn(0, 'string'), err, 'throws when second arg is a truthy string') ++ t.throws(fn(0, false), err, 'throws when second arg is false') ++ t.throws(fn(0, true), err, 'thROWS WHEN second arg is true') ++ t.throws(fn(0, []), err, 'throws when second arg is an array') ++ t.throws(fn(0, {}), err, 'throws when second arg is an object') ++ ++ const f = sinon.spy(identity) ++ const x = 23 ++ ++ const result = applyTo(x)(f) ++ ++ t.ok(f.calledWith(x), 'function called passing first arg') ++ t.equal(result, x, 'returns the result of the passed function') + + t.end() + }) +diff --git a/src/combinators/reverseApply.spec.js b/src/combinators/reverseApply.spec.js +deleted file mode 100644 +index 22090dfb2..000000000 +--- a/src/combinators/reverseApply.spec.js ++++ /dev/null +@@ -1,38 +0,0 @@ +-const test = require('tape') +-const sinon = require('sinon') +-const helpers = require('../test/helpers') +- +-const bindFunc = helpers.bindFunc +- +-const isFunction = require('../core/isFunction') +- +-const reverseApply = require('./reverseApply') +- +-const identity = x => x +- +-test('reverseApply (T combinator)', t => { +- const tc = bindFunc(reverseApply) +- +- t.ok(isFunction(reverseApply), 'is a function') +- +- t.throws(tc(0, undefined), 'throws when second arg is undefined') +- t.throws(tc(0, null), 'throws when second arg is null') +- t.throws(tc(0, 0), 'throws when second arg is a falsey number') +- t.throws(tc(0, 1), 'throws when second arg is a truthy number') +- t.throws(tc(0, ''), 'throws when second arg is a falsey string') +- t.throws(tc(0, 'string'), 'throws when second arg is a truthy string') +- t.throws(tc(0, false), 'throws when second arg is false') +- t.throws(tc(0, true), 'thROWS WHEN second arg is true') +- t.throws(tc(0, []), 'throws when second arg is an array') +- t.throws(tc(0, {}), 'throws when second arg is an object') +- +- const f = sinon.spy(identity) +- const x = 23 +- +- const result = reverseApply(x)(f) +- +- t.ok(f.calledWith(x), 'function called passing first arg') +- t.equal(result, x, 'returns the result of the passed function') +- +- t.end() +-}) +diff --git a/src/core/List.spec.js b/src/core/List.spec.js +index f4efa1cc3..f626f2533 100644 +--- a/src/core/List.spec.js ++++ b/src/core/List.spec.js +@@ -18,7 +18,7 @@ const Pred = require('../Pred') + const constant = x => () => x + const identity = x => x + +-const reverseApply = ++const applyTo = + x => fn => fn(x) + + const List = require('./List') +@@ -578,7 +578,7 @@ test('List of properties (Applicative)', t => { + t.same(m.ap(List.of(3)).valueOf(), List.of(identity(3)).valueOf(), 'homomorphism') + + const a = x => m.ap(List.of(x)) +- const b = x => List.of(reverseApply(x)).ap(m) ++ const b = x => List.of(applyTo(x)).ap(m) + + t.same(a(3).valueOf(), b(3).valueOf(), 'interchange') + +diff --git a/src/core/Maybe.spec.js b/src/core/Maybe.spec.js +index c7f626c2f..1c035c0f8 100644 +--- a/src/core/Maybe.spec.js ++++ b/src/core/Maybe.spec.js +@@ -19,7 +19,7 @@ const identity = x => x + const either = + (f, g) => m => m.either(f, g) + +-const reverseApply = ++const applyTo = + x => fn => fn(x) + + const Maybe = require('./Maybe') +@@ -558,7 +558,7 @@ test('Maybe of properties (Applicative)', t => { + ) + + const a = x => m.ap(Maybe.of(x)) +- const b = x => Maybe.of(reverseApply(x)).ap(m) ++ const b = x => Maybe.of(applyTo(x)).ap(m) + + t.equal(a(3).option('Nothing'), b(3).option('Other'), 'interchange Just') + +diff --git a/src/core/Unit.spec.js b/src/core/Unit.spec.js +index 955f63628..6912898e7 100644 +--- a/src/core/Unit.spec.js ++++ b/src/core/Unit.spec.js +@@ -14,7 +14,7 @@ const unit = require('./_unit') + + const identity = x => x + +-const reverseApply = ++const applyTo = + x => fn => fn(x) + + const Unit = require('./Unit') +@@ -298,7 +298,7 @@ test('Unit of properties (Applicative)', t => { + t.equal(m.ap(Unit.of(3)).valueOf(), Unit.of(identity(3)).valueOf(), 'homomorphism') + + const a = x => m.ap(Unit.of(x)) +- const b = x => Unit.of(reverseApply(x)).ap(m) ++ const b = x => Unit.of(applyTo(x)).ap(m) + + t.equal(a(3).valueOf(), b(3).valueOf(), 'interchange') + +diff --git a/src/index.spec.js b/src/index.spec.js +index 80a1d5c27..3bf9d28a4 100644 +--- a/src/index.spec.js ++++ b/src/index.spec.js +@@ -7,7 +7,6 @@ const composeB = require('./combinators/composeB') + const constant = require('./combinators/constant') + const flip = require('./combinators/flip') + const identity = require('./combinators/identity') +-const reverseApply = require('./combinators/reverseApply') + const substitution = require('./combinators/substitution') + + // crocks +@@ -208,12 +207,11 @@ test('entry', t => { + t.equal(crocks.toString(), '[object Object]', 'is an object') + + // combinators +- t.equal(crocks.applyTo, applyTo, 'provides the A combinator (applyTo)') ++ t.equal(crocks.applyTo, applyTo, 'provides the T combinator (applyTo)') + t.equal(crocks.composeB, composeB, 'provides the B combinator (composeB)') + t.equal(crocks.constant, constant, 'provides the K combinator (constant)') + t.equal(crocks.flip, flip, 'provides the C combinator (flip)') + t.equal(crocks.identity, identity, 'provides the I combinator (identity)') +- t.equal(crocks.reverseApply, reverseApply, 'provides the T combinator (reverseApply)') + t.equal(crocks.substitution, substitution, 'provides the S combinator (substitution)') + + // crocks +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,6 @@ ++H4sIAAAAAAAAA+3S0WqDMBQGYK99ijyBxrWx173YxWBjMDp2MyjRHGhGGyVJS337Weu6sXT2pmUd +++z/EI/mPGjhJirVeqjmZTRpdCm9NhOhq63vtnjNxw0d8LPLxJOJZlvNJxMTFdvTF2nlpGYtsVfmh ++vlP5H5V8zt+T8/OyWq2kUYlbnO8fp+af56PD/IXYzX+cj3jE+Pm28LN/Pv9SsW7wBak4NvWWeVkT ++e40Zc7ZMp64x/T1xNZXJmztkt9ovyPYlSO8e2ytcVWS89s3hIeh4Iqnar+7LcDo7Erv10vclSF+s ++9u3L+xKk7cEvtJG+si6Vdb1sZtVgj6UNWUfTXeuRRkvpvXbhJrrkQTYFHY+ejQ5f0kbR9mM1/u0j ++AwAAAAAAAAAAAAAAAAAAAABX5B2QeanJACgAAA== +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000910/tests/test.sh b/tasks/format-code-task-000910/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..4f72c1a502744719775dcdb7b6a1117dd1395c22 --- /dev/null +++ b/tasks/format-code-task-000910/tests/test.sh @@ -0,0 +1,52 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +src/Async/Async.spec.js +src/Either/Either.spec.js +src/IO/IO.spec.js +src/Identity/Identity.spec.js +src/Reader/Reader.spec.js +src/Reader/ReaderT.spec.js +src/Result/Result.spec.js +src/Writer/Writer.spec.js +src/combinators/applyTo.spec.js +src/combinators/reverseApply.spec.js +src/core/List.spec.js +src/core/Maybe.spec.js +src/core/Unit.spec.js +src/index.spec.js +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000910/tests/test_command.sh b/tasks/format-code-task-000910/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000910/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000917/environment/Dockerfile b/tasks/format-code-task-000917/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..063720af326d45bbe180d1c4587b709ad2260aa4 --- /dev/null +++ b/tasks/format-code-task-000917/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:4fad0ddf045142a7a503c50ec49286dd8ec56e56f895b3b3d62b59f34b20f82d diff --git a/tasks/format-code-task-000917/environment/setup/files/blocklist b/tasks/format-code-task-000917/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000917/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000917/environment/setup/setup.sh b/tasks/format-code-task-000917/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000917/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000917/tests/test.patch b/tasks/format-code-task-000917/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..dec06e7b9c546d8f2f05f72d876e70d431cb8dfc --- /dev/null +++ b/tasks/format-code-task-000917/tests/test.patch @@ -0,0 +1,254 @@ +diff --git a/library/src/actions/octal/octal.test.ts b/library/src/actions/octal/octal.test.ts +index fd66e34e1..ed41f3c47 100644 +--- a/library/src/actions/octal/octal.test.ts ++++ b/library/src/actions/octal/octal.test.ts +@@ -89,15 +89,6 @@ describe('octal', () => { + '0o1234567', + ]); + }); +- +- test('for 0O prefix', () => { +- expectNoActionIssue(action, [ +- '0O000000000000000', +- '0O777777777777', +- '0O01234567', +- '0O1234567', +- ]); +- }); + }); + + describe('should return dataset with issues', () => { +diff --git a/packages/to-json-schema/src/convertAction.test.ts b/packages/to-json-schema/src/convertAction.test.ts +index 072bd2c10..c5ce972f7 100644 +--- a/packages/to-json-schema/src/convertAction.test.ts ++++ b/packages/to-json-schema/src/convertAction.test.ts +@@ -17,6 +17,54 @@ describe('convertAction', () => { + }); + }); + ++ test('should convert bic action', () => { ++ expect(convertAction({}, v.bic(), undefined)).toStrictEqual({ ++ pattern: v.BIC_REGEX.source, ++ }); ++ expect( ++ convertAction({ type: 'string' }, v.bic(), undefined) ++ ).toStrictEqual({ ++ type: 'string', ++ pattern: v.BIC_REGEX.source, ++ }); ++ }); ++ ++ test('should convert cuid2 action', () => { ++ expect(convertAction({}, v.cuid2(), undefined)).toStrictEqual({ ++ pattern: v.CUID2_REGEX.source, ++ }); ++ expect( ++ convertAction({ type: 'string' }, v.cuid2(), undefined) ++ ).toStrictEqual({ ++ type: 'string', ++ pattern: v.CUID2_REGEX.source, ++ }); ++ }); ++ ++ test('should convert decimal action', () => { ++ expect(convertAction({}, v.decimal(), undefined)).toStrictEqual({ ++ pattern: v.DECIMAL_REGEX.source, ++ }); ++ expect( ++ convertAction({ type: 'string' }, v.decimal(), undefined) ++ ).toStrictEqual({ ++ type: 'string', ++ pattern: v.DECIMAL_REGEX.source, ++ }); ++ }); ++ ++ test('should convert digits action', () => { ++ expect(convertAction({}, v.digits(), undefined)).toStrictEqual({ ++ pattern: v.DIGITS_REGEX.source, ++ }); ++ expect( ++ convertAction({ type: 'string' }, v.digits(), undefined) ++ ).toStrictEqual({ ++ type: 'string', ++ pattern: v.DIGITS_REGEX.source, ++ }); ++ }); ++ + test('should convert description action', () => { + expect(convertAction({}, v.description('test'), undefined)).toStrictEqual({ + description: 'test', +@@ -35,6 +83,95 @@ describe('convertAction', () => { + }); + }); + ++ test('should convert emoji action', () => { ++ expect(convertAction({}, v.emoji(), undefined)).toStrictEqual({ ++ pattern: v.EMOJI_REGEX.source, ++ }); ++ expect( ++ convertAction({ type: 'string' }, v.emoji(), undefined) ++ ).toStrictEqual({ ++ type: 'string', ++ pattern: v.EMOJI_REGEX.source, ++ }); ++ }); ++ ++ test('should convert empty action for strings', () => { ++ expect( ++ convertAction({ type: 'string' }, v.empty(), undefined) ++ ).toStrictEqual({ ++ type: 'string', ++ maxLength: 0, ++ }); ++ }); ++ ++ test('should convert empty action for arrays', () => { ++ expect( ++ convertAction({ type: 'array' }, v.empty(), undefined) ++ ).toStrictEqual({ ++ type: 'array', ++ maxItems: 0, ++ }); ++ }); ++ ++ test('should throw error for empty action with invalid type', () => { ++ const action = v.empty(); ++ const error1 = 'The "empty" action is not supported on type "undefined".'; ++ expect(() => convertAction({}, action, undefined)).toThrowError(error1); ++ expect(() => ++ convertAction({}, action, { errorMode: 'throw' }) ++ ).toThrowError(error1); ++ const error2 = 'The "empty" action is not supported on type "object".'; ++ expect(() => ++ convertAction({ type: 'object' }, action, undefined) ++ ).toThrowError(error2); ++ expect(() => ++ convertAction({ type: 'object' }, action, { errorMode: 'throw' }) ++ ).toThrowError(error2); ++ }); ++ ++ test('should warn error for empty action with invalid type', () => { ++ expect(convertAction({}, v.empty(), { errorMode: 'warn' })).toStrictEqual({ ++ maxLength: 0, ++ }); ++ expect(console.warn).toHaveBeenLastCalledWith( ++ 'The "empty" action is not supported on type "undefined".' ++ ); ++ expect( ++ convertAction({ type: 'object' }, v.empty(), { ++ errorMode: 'warn', ++ }) ++ ).toStrictEqual({ type: 'object', maxLength: 0 }); ++ expect(console.warn).toHaveBeenLastCalledWith( ++ 'The "empty" action is not supported on type "object".' ++ ); ++ }); ++ ++ test('should convert hexadecimal action', () => { ++ expect(convertAction({}, v.hexadecimal(), undefined)).toStrictEqual( ++ { ++ pattern: v.HEXADECIMAL_REGEX.source, ++ } ++ ); ++ expect( ++ convertAction({ type: 'string' }, v.hexadecimal(), undefined) ++ ).toStrictEqual({ ++ type: 'string', ++ pattern: v.HEXADECIMAL_REGEX.source, ++ }); ++ }); ++ ++ test('should convert hex color action', () => { ++ expect(convertAction({}, v.hexColor(), undefined)).toStrictEqual({ ++ pattern: v.HEX_COLOR_REGEX.source, ++ }); ++ expect( ++ convertAction({ type: 'string' }, v.hexColor(), undefined) ++ ).toStrictEqual({ ++ type: 'string', ++ pattern: v.HEX_COLOR_REGEX.source, ++ }); ++ }); ++ + test('should convert integer action', () => { + expect(convertAction({}, v.integer(), undefined)).toStrictEqual({ + type: 'integer', +@@ -418,6 +555,18 @@ describe('convertAction', () => { + }); + }); + ++ test('should convert Nano ID action', () => { ++ expect(convertAction({}, v.nanoid(), undefined)).toStrictEqual({ ++ pattern: v.NANO_ID_REGEX.source, ++ }); ++ expect( ++ convertAction({ type: 'string' }, v.nanoid(), undefined) ++ ).toStrictEqual({ ++ type: 'string', ++ pattern: v.NANO_ID_REGEX.source, ++ }); ++ }); ++ + test('should convert non empty action for strings', () => { + expect( + convertAction({ type: 'string' }, v.nonEmpty(), undefined) +@@ -472,6 +621,18 @@ describe('convertAction', () => { + ); + }); + ++ test('should convert octal action', () => { ++ expect(convertAction({}, v.octal(), undefined)).toStrictEqual({ ++ pattern: v.OCTAL_REGEX.source, ++ }); ++ expect( ++ convertAction({ type: 'string' }, v.octal(), undefined) ++ ).toStrictEqual({ ++ type: 'string', ++ pattern: v.OCTAL_REGEX.source, ++ }); ++ }); ++ + test('should convert supported regex action', () => { + expect( + convertAction({ type: 'string' }, v.regex(/[a-zA-Z]/), undefined) +@@ -510,6 +671,18 @@ describe('convertAction', () => { + }); + }); + ++ test('should convert ULID action', () => { ++ expect(convertAction({}, v.ulid(), undefined)).toStrictEqual({ ++ pattern: v.ULID_REGEX.source, ++ }); ++ expect( ++ convertAction({ type: 'string' }, v.ulid(), undefined) ++ ).toStrictEqual({ ++ type: 'string', ++ pattern: v.ULID_REGEX.source, ++ }); ++ }); ++ + test('should convert url action', () => { + expect(convertAction({}, v.url(), undefined)).toStrictEqual({ + format: 'uri', +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,6 @@ ++H4sIAAAAAAAAA+3SQW7CMBAF0KxziqlYJ05CDOteoRdAjuM2LsGObAeV29eEikIlYAOqqv63iK14 ++xjPSOG9G3bcrZbYseZQiWnI+rdHPddqXvCqral4uijopypIveUL8YR2dGH0Qjihx1oZrcbfO/6j8 ++e/5B+bCSdrMRps19d78at+ZfzxfH+fOyivOvF3Gh4n4tXPbP5z97YqN3rNGGxTdAjfBd6lWgTI2W ++Bj2oV6H7VLY0PY9GtWk6o5fRkJVB9CRk0NbQ/syfRrFeN064XWqGD9rq/V9yMSvLwm5QslNyTd5J ++dsj3bLrt8M33wXm87qtQsNm7tybzMWsjSFqzVS48Xyo8CLkWb8qz87xbjZxde2zht6cDAAAAAAAA ++AAAAAAAAAAAAAHDdJ0FjY5sAKAAA +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000917/tests/test.sh b/tasks/format-code-task-000917/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..a33a916c82d507426d81328946668cbd35ac1512 --- /dev/null +++ b/tasks/format-code-task-000917/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +library/src/actions/octal/octal.test.ts +packages/to-json-schema/src/convertAction.test.ts +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000917/tests/test_command.sh b/tasks/format-code-task-000917/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000917/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000921/environment/setup/files/blocklist b/tasks/format-code-task-000921/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000921/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000921/environment/setup/setup.sh b/tasks/format-code-task-000921/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000921/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000926/environment/Dockerfile b/tasks/format-code-task-000926/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..88b0ae28daf8451025a42d1e0eb30ce6f3e528bd --- /dev/null +++ b/tasks/format-code-task-000926/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:bd8a515e270d1c263218791f56a9e1cbb6d19df23407dbf17cb6d3377f898e2f diff --git a/tasks/format-code-task-000926/environment/setup/files/blocklist b/tasks/format-code-task-000926/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000926/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000926/environment/setup/setup.sh b/tasks/format-code-task-000926/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000926/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000926/tests/test.patch b/tasks/format-code-task-000926/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..a0f7285ea4638b9bbe1cb86b46f73cc069b58268 --- /dev/null +++ b/tasks/format-code-task-000926/tests/test.patch @@ -0,0 +1,121 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..eb62acc8 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest tests/test_extensions/test_details.py tests/test_extensions/test_tabbed.py -v"] ++} +diff --git a/tests/test_extensions/test_details.py b/tests/test_extensions/test_details.py +index 6b24b19e..c70324d0 100644 +--- a/tests/test_extensions/test_details.py ++++ b/tests/test_extensions/test_details.py +@@ -324,3 +324,43 @@ class TestDetails(util.MdCase): + ''', + True + ) ++ ++ def test_details_with_nested_list_and_outro_paragraph(self): ++ """Sub-list inside details should not absorb following items as nested children. ++ ++ Reproduces the issue: a parent list item containing an intro paragraph, ++ a sub-list, and an outro paragraph rendered the sub-list's later items ++ as children of the first item when wrapped in a details block. ++ """ ++ ++ self.check_markdown( ++ ''' ++ ???+ "With details block" ++ - Parent 1 ++ Intro 1 ++ ++ - Child 1 ++ - Child 2 ++ - Child 3 ++ - Child 4 ++ ++ Outro 1 ++ ''', ++ ''' ++
With details block
    ++
  • ++

    Parent 1 ++ Intro 1

    ++
      ++
    • Child 1
    • ++
    • Child 2
    • ++
    • Child 3
    • ++
    • Child 4
    • ++
    ++

    Outro 1

    ++
  • ++
++
++ ''', ++ True ++ ) +diff --git a/tests/test_extensions/test_tabbed.py b/tests/test_extensions/test_tabbed.py +index 5803dc0e..012a8287 100644 +--- a/tests/test_extensions/test_tabbed.py ++++ b/tests/test_extensions/test_tabbed.py +@@ -384,3 +384,46 @@ class TestLegacyTab(util.MdCase): + ''', # noqa: E501 + True + ) ++ ++ def test_tabbed_with_nested_list_and_outro_paragraph(self): ++ """Sub-list inside a tab should not absorb following items as nested children. ++ ++ The same parsing bug as the details block, but for tabbed: a parent ++ list item with intro paragraph, sub-list, and outro paragraph rendered ++ the sub-list's later items as nested children of the first when wrapped ++ in a tabbed block. ++ """ ++ ++ self.check_markdown( ++ ''' ++ === "With tabs" ++ - Parent 1 ++ Intro 1 ++ ++ - Child 1 ++ - Child 2 ++ - Child 3 ++ - Child 4 ++ ++ Outro 1 ++ ''', ++ ''' ++
++
    ++
  • ++

    Parent 1 ++ Intro 1

    ++
      ++
    • Child 1
    • ++
    • Child 2
    • ++
    • Child 3
    • ++
    • Child 4
    • ++
    ++

    Outro 1

    ++
  • ++
++
++
++ ''', # noqa: E501 ++ True ++ ) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m pytest tests/test_extensions/test_details.py tests/test_extensions/test_tabbed.py -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000926/tests/test.sh b/tasks/format-code-task-000926/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..23bc2b3c73f7af236f25e4415c009f49eab75012 --- /dev/null +++ b/tasks/format-code-task-000926/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test_commands.json +tests/test_extensions/test_details.py +tests/test_extensions/test_tabbed.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000926/tests/test_command.sh b/tasks/format-code-task-000926/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000926/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001004/environment/Dockerfile b/tasks/format-code-task-001004/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7f66a302b1af4b0ac8380c6be0aa7f36772d4309 --- /dev/null +++ b/tasks/format-code-task-001004/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:00dbef4abf2bc77b2853771f2ed8697ae1d4378694cb0411467f4fe35757efa7 diff --git a/tasks/format-code-task-001004/environment/setup/files/blocklist b/tasks/format-code-task-001004/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001004/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001004/environment/setup/setup.sh b/tasks/format-code-task-001004/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001004/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001004/tests/test.patch b/tasks/format-code-task-001004/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..f38c0eb3e0e6bcf892a5fc56f894b3bac6a08ebe --- /dev/null +++ b/tasks/format-code-task-001004/tests/test.patch @@ -0,0 +1,353 @@ +diff --git a/ipn/conffile/include_codespec_test.go b/ipn/conffile/include_codespec_test.go +new file mode 100644 +--- /dev/null ++++ b/ipn/conffile/include_codespec_test.go +@@ -0,0 +1,338 @@ ++ ++ ++ ++package conffile_test ++ ++import ( ++ "bytes" ++ "encoding/json" ++ "fmt" ++ "os" ++ "path/filepath" ++ "strings" ++ "testing" ++ ++ "tailscale.com/ipn/conffile" ++) ++ ++func writeCodespecConfig(t *testing.T, dir, name, contents string) string { ++ t.Helper() ++ path := filepath.Join(dir, name) ++ if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil { ++ t.Fatal(err) ++ } ++ if err := os.WriteFile(path, []byte(contents), 0600); err != nil { ++ t.Fatal(err) ++ } ++ return path ++} ++ ++func loadCodespecConfig(t *testing.T, path string) *conffile.Config { ++ t.Helper() ++ c, err := conffile.Load(path) ++ if err != nil { ++ t.Fatalf("Load(%q) returned an unexpected error: %v", path, err) ++ } ++ return c ++} ++ ++func requireCodespecLoadError(t *testing.T, path string, parts ...string) string { ++ t.Helper() ++ _, err := conffile.Load(path) ++ if err == nil { ++ t.Fatalf("Load(%q) succeeded; want an error", path) ++ } ++ msg := err.Error() ++ for _, part := range parts { ++ if !strings.Contains(msg, part) { ++ t.Errorf("Load(%q) error %q does not identify %q", path, msg, part) ++ } ++ } ++ return msg ++} ++ ++func TestCodespecConfigIncludeRecursiveMerge(t *testing.T) { ++ dir := t.TempDir() ++ writeCodespecConfig(t, dir, "common.hujson", `{ ++ // Shared defaults used by more specific machine configurations. ++ "version": "alpha0", ++ "hostname": "common-node", ++ "enabled": true, ++ "acceptDNS": true, ++ "acceptRoutes": true, ++ "authKey": "tskey-from-common", ++ "advertiseRoutes": ["10.0.0.0/8"], ++ "autoUpdate": {"check": true, "apply": true}, ++}`) ++ writeCodespecConfig(t, dir, "layers/team defaults.hujson", `{ ++ "version": "alpha0", ++ "include": "../common.hujson", ++ "acceptDNS": false, ++ "autoUpdate": {"apply": false} ++}`) ++ rootBody := `{ ++ "version": "alpha0", ++ "include": ["layers/team defaults.hujson"], ++ "hostname": "", ++ "enabled": false, ++ "acceptRoutes": false, ++ "authKey": null, ++ "advertiseRoutes": [] ++}` ++ root := writeCodespecConfig(t, dir, "root.hujson", rootBody) ++ c := loadCodespecConfig(t, root) ++ ++ if c.Path != root { ++ t.Errorf("Config.Path = %q, want root path %q", c.Path, root) ++ } ++ if !bytes.Equal(c.Raw, []byte(rootBody)) { ++ t.Errorf("Config.Raw does not contain the unchanged root document") ++ } ++ if c.Version != "alpha0" || c.Parsed.Version != "alpha0" { ++ t.Errorf("versions = (%q, %q), want alpha0", c.Version, c.Parsed.Version) ++ } ++ if c.Parsed.Hostname == nil || *c.Parsed.Hostname != "" { ++ t.Errorf("hostname = %v, want an explicitly set empty string", c.Parsed.Hostname) ++ } ++ if !c.Parsed.Enabled.EqualBool(false) { ++ t.Errorf("enabled = %q, want explicit false", c.Parsed.Enabled) ++ } ++ if !c.Parsed.AcceptDNS.EqualBool(false) { ++ t.Errorf("acceptDNS = %q, want team layer's false", c.Parsed.AcceptDNS) ++ } ++ if !c.Parsed.AcceptRoutes.EqualBool(false) { ++ t.Errorf("acceptRoutes = %q, want root layer's false", c.Parsed.AcceptRoutes) ++ } ++ if c.Parsed.AuthKey != nil { ++ t.Errorf("authKey = %q, want root null to clear the inherited value", *c.Parsed.AuthKey) ++ } ++ if c.Parsed.AdvertiseRoutes == nil || len(c.Parsed.AdvertiseRoutes) != 0 { ++ t.Errorf("advertiseRoutes = %v, want an explicitly set empty array", c.Parsed.AdvertiseRoutes) ++ } ++ if c.Parsed.AutoUpdate == nil { ++ t.Fatal("autoUpdate is nil; want recursively merged object") ++ } ++ if !c.Parsed.AutoUpdate.Check || !c.Parsed.AutoUpdate.Apply.EqualBool(false) { ++ t.Errorf("autoUpdate = %+v, want inherited check=true and overridden apply=false", *c.Parsed.AutoUpdate) ++ } ++ ++ if !json.Valid(c.Std) { ++ t.Fatalf("Config.Std is not valid JSON: %q", c.Std) ++ } ++ var effective map[string]any ++ if err := json.Unmarshal(c.Std, &effective); err != nil { ++ t.Fatal(err) ++ } ++ if _, ok := effective["include"]; ok { ++ t.Error("Config.Std retains include metadata; want only the effective config") ++ } ++ if got := effective["acceptDNS"]; got != false { ++ t.Errorf("Config.Std acceptDNS = %#v, want false", got) ++ } ++ if got, ok := effective["hostname"]; !ok || got != "" { ++ t.Errorf("Config.Std hostname = %#v (present %v), want an explicit empty string", got, ok) ++ } ++ if got, ok := effective["authKey"]; !ok || got != nil { ++ t.Errorf("Config.Std authKey = %#v (present %v), want explicit null", got, ok) ++ } ++ routes, ok := effective["advertiseRoutes"].([]any) ++ if !ok || len(routes) != 0 { ++ t.Errorf("Config.Std advertiseRoutes = %#v, want an explicit empty array", effective["advertiseRoutes"]) ++ } ++ autoUpdate, ok := effective["autoUpdate"].(map[string]any) ++ if !ok || autoUpdate["check"] != true || autoUpdate["apply"] != false { ++ t.Errorf("Config.Std autoUpdate = %#v, want merged check/apply values", effective["autoUpdate"]) ++ } ++} ++ ++func TestCodespecConfigIncludePrecedenceAndAbsolutePaths(t *testing.T) { ++ dir := t.TempDir() ++ writeCodespecConfig(t, dir, "first.hujson", `{ ++ "version": "alpha0", ++ "hostname": "first", ++ "acceptDNS": true ++}`) ++ second := writeCodespecConfig(t, dir, "second absolute.hujson", `{ ++ "version": "alpha0", ++ "hostname": "second", ++ "acceptDNS": false ++}`) ++ root := writeCodespecConfig(t, dir, "root.hujson", fmt.Sprintf(`{ ++ "version": "alpha0", ++ "include": ["first.hujson", %q], ++ "acceptDNS": true ++}`, second)) ++ ++ c := loadCodespecConfig(t, root) ++ if c.Parsed.Hostname == nil || *c.Parsed.Hostname != "second" { ++ t.Errorf("hostname = %v, want later include to win", c.Parsed.Hostname) ++ } ++ if !c.Parsed.AcceptDNS.EqualBool(true) { ++ t.Errorf("acceptDNS = %q, want including document to win", c.Parsed.AcceptDNS) ++ } ++} ++ ++func TestCodespecConfigIncludeSharedDependencyIsNotCycle(t *testing.T) { ++ dir := t.TempDir() ++ writeCodespecConfig(t, dir, "shared.hujson", `{ ++ "version": "alpha0", ++ "operatorUser": "shared-user" ++}`) ++ writeCodespecConfig(t, dir, "left.hujson", `{ ++ "version": "alpha0", ++ "include": "shared.hujson", ++ "hostname": "left" ++}`) ++ writeCodespecConfig(t, dir, "right.hujson", `{ ++ "version": "alpha0", ++ "include": "shared.hujson", ++ "acceptDNS": false ++}`) ++ root := writeCodespecConfig(t, dir, "root.hujson", `{ ++ "version": "alpha0", ++ "include": ["left.hujson", "right.hujson"] ++}`) ++ ++ c := loadCodespecConfig(t, root) ++ if c.Parsed.OperatorUser == nil || *c.Parsed.OperatorUser != "shared-user" { ++ t.Errorf("operatorUser = %v, want value from shared dependency", c.Parsed.OperatorUser) ++ } ++ if !c.Parsed.AcceptDNS.EqualBool(false) { ++ t.Errorf("acceptDNS = %q, want right branch value", c.Parsed.AcceptDNS) ++ } ++} ++ ++func TestCodespecConfigIncludeCycleDiagnostics(t *testing.T) { ++ t.Run("self", func(t *testing.T) { ++ dir := t.TempDir() ++ root := writeCodespecConfig(t, dir, "self-ref.hujson", `{ ++ "version": "alpha0", ++ "include": "self-ref.hujson" ++}`) ++ msg := requireCodespecLoadError(t, root, "self-ref.hujson") ++ lower := strings.ToLower(strings.ReplaceAll(msg, dir, "")) ++ if !strings.Contains(lower, "cycle") && !strings.Contains(lower, "cyclic") && !strings.Contains(lower, "recursive") { ++ t.Errorf("cycle error %q does not describe an include cycle", msg) ++ } ++ }) ++ ++ t.Run("indirect", func(t *testing.T) { ++ dir := t.TempDir() ++ a := writeCodespecConfig(t, dir, "graph-a.hujson", `{ ++ "version": "alpha0", ++ "include": "nested/graph-b.hujson" ++}`) ++ writeCodespecConfig(t, dir, "nested/graph-b.hujson", `{ ++ "version": "alpha0", ++ "include": "../graph-a.hujson" ++}`) ++ msg := requireCodespecLoadError(t, a, "graph-a.hujson", "graph-b.hujson") ++ lower := strings.ToLower(strings.ReplaceAll(msg, dir, "")) ++ if !strings.Contains(lower, "cycle") && !strings.Contains(lower, "cyclic") && !strings.Contains(lower, "recursive") { ++ t.Errorf("cycle error %q does not describe an include cycle", msg) ++ } ++ }) ++} ++ ++func TestCodespecConfigIncludeSourceErrors(t *testing.T) { ++ t.Run("missing", func(t *testing.T) { ++ dir := t.TempDir() ++ root := writeCodespecConfig(t, dir, "root.hujson", `{ ++ "version": "alpha0", ++ "include": "missing-layer.hujson" ++}`) ++ requireCodespecLoadError(t, root, "missing-layer.hujson") ++ }) ++ ++ t.Run("malformed", func(t *testing.T) { ++ dir := t.TempDir() ++ writeCodespecConfig(t, dir, "malformed-layer.hujson", `{"version":"alpha0",`) ++ root := writeCodespecConfig(t, dir, "root.hujson", `{ ++ "version": "alpha0", ++ "include": "malformed-layer.hujson" ++}`) ++ requireCodespecLoadError(t, root, "malformed-layer.hujson") ++ }) ++ ++ t.Run("missing-version", func(t *testing.T) { ++ dir := t.TempDir() ++ writeCodespecConfig(t, dir, "unversioned-layer.hujson", `{"hostname":"old"}`) ++ root := writeCodespecConfig(t, dir, "root.hujson", `{ ++ "version": "alpha0", ++ "include": "unversioned-layer.hujson" ++}`) ++ requireCodespecLoadError(t, root, "unversioned-layer.hujson", "version") ++ }) ++ ++ t.Run("unsupported-version", func(t *testing.T) { ++ dir := t.TempDir() ++ writeCodespecConfig(t, dir, "future-layer.hujson", `{"version":"beta9"}`) ++ root := writeCodespecConfig(t, dir, "root.hujson", `{ ++ "version": "alpha0", ++ "include": "future-layer.hujson" ++}`) ++ requireCodespecLoadError(t, root, "future-layer.hujson", "beta9") ++ }) ++} ++ ++func TestCodespecConfigIncludeStrictEffectiveSchema(t *testing.T) { ++ dir := t.TempDir() ++ writeCodespecConfig(t, dir, "unknown-field-layer.hujson", `{ ++ "version": "alpha0", ++ "futureOption": true ++}`) ++ root := writeCodespecConfig(t, dir, "root.hujson", `{ ++ "version": "alpha0", ++ "include": "unknown-field-layer.hujson" ++}`) ++ requireCodespecLoadError(t, root, "futureOption") ++} ++ ++func TestCodespecConfigIncludeShapeErrors(t *testing.T) { ++ for _, tt := range []struct { ++ name string ++ include string ++ }{ ++ {name: "boolean", include: `true`}, ++ {name: "object", include: `{"path":"layer.hujson"}`}, ++ {name: "non-string-list-entry", include: `["layer.hujson", 7]`}, ++ } { ++ t.Run(tt.name, func(t *testing.T) { ++ dir := t.TempDir() ++ writeCodespecConfig(t, dir, "layer.hujson", `{"version":"alpha0"}`) ++ root := writeCodespecConfig(t, dir, "root.hujson", fmt.Sprintf(`{ ++ "version": "alpha0", ++ "include": %s ++}`, tt.include)) ++ requireCodespecLoadError(t, root, "include") ++ }) ++ } ++} ++ ++func TestCodespecConfigRootRawAndStandaloneCompatibility(t *testing.T) { ++ dir := t.TempDir() ++ raw := `{ ++ // A normal standalone HuJSON file must keep working. ++ "version": "alpha0", ++ "enabled": false, ++ "hostname": "", ++}` ++ path := writeCodespecConfig(t, dir, "standalone.hujson", raw) ++ c := loadCodespecConfig(t, path) ++ ++ if c.Path != path { ++ t.Errorf("Config.Path = %q, want %q", c.Path, path) ++ } ++ if !bytes.Equal(c.Raw, []byte(raw)) { ++ t.Error("Config.Raw changed for a standalone file") ++ } ++ if !json.Valid(c.Std) { ++ t.Fatalf("Config.Std is not standardized JSON: %q", c.Std) ++ } ++ if !c.Parsed.Enabled.EqualBool(false) { ++ t.Errorf("enabled = %q, want false", c.Parsed.Enabled) ++ } ++ if c.Parsed.Hostname == nil || *c.Parsed.Hostname != "" { ++ t.Errorf("hostname = %v, want explicit empty string", c.Parsed.Hostname) ++ } ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,5 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++go test ./ipn/conffile -run '^TestCodespecConfig' -count=1 diff --git a/tasks/format-code-task-001004/tests/test.sh b/tasks/format-code-task-001004/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..8cb4f2b3b88046c08b74d76662113062c9f0c623 --- /dev/null +++ b/tasks/format-code-task-001004/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +ipn/conffile/include_codespec_test.go +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001004/tests/test_command.sh b/tasks/format-code-task-001004/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001004/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001032/environment/Dockerfile b/tasks/format-code-task-001032/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..bfe21e2a9f20d98d577e34759ec93e0e54898d77 --- /dev/null +++ b/tasks/format-code-task-001032/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:e0b7f8446c37b73b96a52f47828ad157812c800df2f2f683b905f0db36c77bb5 diff --git a/tasks/format-code-task-001032/environment/setup/files/blocklist b/tasks/format-code-task-001032/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001032/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001032/environment/setup/setup.sh b/tasks/format-code-task-001032/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001032/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001032/tests/test.patch b/tasks/format-code-task-001032/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..28443ba50847381891893fde42337323e30eb537 --- /dev/null +++ b/tasks/format-code-task-001032/tests/test.patch @@ -0,0 +1,96 @@ +diff --git a/test/ninja/pool_controls.py b/test/ninja/pool_controls.py +new file mode 100644 +index 000000000..8344df168 +--- /dev/null ++++ b/test/ninja/pool_controls.py +@@ -0,0 +1,80 @@ ++#!/usr/bin/env python ++ ++import os ++import re ++ ++import TestSCons ++ ++test = TestSCons.TestSCons() ++ ++try: ++ import ninja ++except ImportError: ++ test.skip_test("Could not find ninja module.\n") ++ ++ninja_bin = test.where_is('ninja') ++if not ninja_bin: ++ test.skip_test("Could not find ninja executable.\n") ++ ++test.write('SConstruct', r''' ++SetOption('experimental', 'ninja') ++DefaultEnvironment(tools=[]) ++env = Environment(tools=['ninja']) ++mode = ARGUMENTS.get('MODE', 'depth') ++env['NINJA_MAX_JOBS'] = int(ARGUMENTS['NINJA_MAX_JOBS']) ++ ++if mode == 'compound': ++ env.NinjaPool('limited', 5) ++ env.NinjaPool('tiny', 2) ++ env['NINJA_POOL'] = 'limited' ++ env.Command('ambient.txt', [], 'echo ambient > $TARGET') ++ env.Command('compound.txt', [], [ ++ 'echo compound > $TARGET', ++ 'echo complete >> $TARGET', ++ ], NINJA_POOL='limited') ++else: ++ plain = env.Command('plain.txt', [], 'echo plain > $TARGET') ++ env.InstallAs('installed.txt', plain) ++''') ++ ++ ++test.run(arguments=['--disable-execute-ninja', 'NINJA_MAX_JOBS=3', 'MODE=depth'], stdout=None) ++test.must_contain_all_lines(test.stdout(), ['Generating: build.ninja']) ++build_ninja = test.read('build.ninja', mode='r') ++test.fail_test('pool local_pool\n depth = 3\n' not in build_ninja, ++ message='local_pool must use the requested job count') ++test.fail_test('pool install_pool\n depth = 1\n' not in build_ninja, ++ message='install_pool must have an integral minimum capacity') ++test.run(program=ninja_bin, arguments=['-n', '-f', 'build.ninja'], stdout=None) ++ ++test.run(arguments=['-c', 'NINJA_MAX_JOBS=3', 'MODE=depth'], stdout=None) ++ ++ ++test.run(arguments=['--disable-execute-ninja', 'NINJA_MAX_JOBS=1', 'MODE=depth'], stdout=None) ++build_ninja = test.read('build.ninja', mode='r') ++test.fail_test('pool local_pool\n depth = 1\n' not in build_ninja, ++ message='local_pool must retain a single requested job') ++test.fail_test('pool install_pool\n depth = 1\n' not in build_ninja, ++ message='install_pool must be clamped to one job') ++test.run(program=ninja_bin, arguments=['-n', '-f', 'build.ninja'], stdout=None) ++ ++test.run(arguments=['-c', 'NINJA_MAX_JOBS=1', 'MODE=depth'], stdout=None) ++ ++ ++ ++test.run(arguments=['--disable-execute-ninja', 'NINJA_MAX_JOBS=3', 'MODE=compound'], stdout=None) ++test.must_contain_all_lines(test.stdout(), ['Generating: build.ninja']) ++build_ninja = test.read('build.ninja', mode='r') ++pool_match = re.search(r'^build compound\.txt:.*\n((?: .*\n)*)', build_ninja, re.MULTILINE) ++test.fail_test(pool_match is None or ' pool = limited\n' not in pool_match.group(1), ++ message='compound action lost its NINJA_POOL override') ++ambient_match = re.search(r'^build ambient\.txt:.*\n((?: .*\n)*)', build_ninja, re.MULTILINE) ++test.fail_test(ambient_match is None or ' pool = limited\n' in ambient_match.group(1), ++ message='environment-wide NINJA_POOL must not affect builders') ++test.fail_test('pool limited\n depth = 3\n' not in build_ninja, ++ message='custom pools must be capped by NINJA_MAX_JOBS') ++test.fail_test('pool tiny\n depth = 2\n' not in build_ninja, ++ message='custom pools below the cap must retain their depth') ++test.run(program=ninja_bin, arguments=['-n', '-f', 'build.ninja'], stdout=None) ++ ++test.pass_test() +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,5 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++TMPDIR=/dev/shm python runtest.py test/ninja/pool_controls.py diff --git a/tasks/format-code-task-001032/tests/test.sh b/tasks/format-code-task-001032/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..18bea0fd7465c74e4ed5964aaf006097ada73e2d --- /dev/null +++ b/tasks/format-code-task-001032/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test/ninja/pool_controls.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001032/tests/test_command.sh b/tasks/format-code-task-001032/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001032/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001035/environment/Dockerfile b/tasks/format-code-task-001035/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ecd4f7e4222b606eb405b60fe3dc7c7ae4c2b946 --- /dev/null +++ b/tasks/format-code-task-001035/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:019c1f54e9f640962d2f1f30f85deebb3ec12d50cbf7729e0ba4abbb9c485448 diff --git a/tasks/format-code-task-001035/environment/setup/files/blocklist b/tasks/format-code-task-001035/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001035/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001035/environment/setup/setup.sh b/tasks/format-code-task-001035/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001035/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001035/tests/test.patch b/tasks/format-code-task-001035/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..eb55e09b35a6d3a2b1fdfb58f8ead668cf98df0a --- /dev/null +++ b/tasks/format-code-task-001035/tests/test.patch @@ -0,0 +1,258 @@ +diff --git a/test/codespec_safe_diagnostics.js b/test/codespec_safe_diagnostics.js +new file mode 100644 +index 0000000..3459f3c +--- /dev/null ++++ b/test/codespec_safe_diagnostics.js +@@ -0,0 +1,241 @@ ++var assert = require('assert'); ++var childProcess = require('child_process'); ++var fs = require('fs'); ++var os = require('os'); ++var path = require('path'); ++var transpile = require('../index.js'); ++var packageInfo = require('../package.json'); ++ ++var cli = path.resolve(__dirname, '..', 'js2php'); ++ ++function runCli(args, input) { ++ return childProcess.spawnSync(process.execPath, [cli].concat(args || []), { ++ input: input, ++ encoding: 'utf8' ++ }); ++} ++ ++function captureFailure(source, options) { ++ var thrown = null; ++ try { ++ transpile(source, options); ++ } catch (error) { ++ thrown = error; ++ } ++ return thrown; ++} ++ ++function assertCleanProcess(result, expectedStatus) { ++ if (result.error) { ++ throw result.error; ++ } ++ assert.strictEqual(result.status, expectedStatus); ++ assert.strictEqual(result.signal, null); ++} ++ ++describe('codespec safe translation diagnostics', function() { ++ it('throws a structured UnsupportedSyntaxError without logging', function() { ++ var originalLog = console.log; ++ var logged = []; ++ var error; ++ ++ console.log = function() { ++ logged.push(Array.prototype.slice.call(arguments)); ++ }; ++ try { ++ error = captureFailure('var ready = true;\ndebugger;', { ++ sourceName: 'workflow.js' ++ }); ++ } finally { ++ console.log = originalLog; ++ } ++ ++ assert.strictEqual(typeof transpile.UnsupportedSyntaxError, 'function'); ++ assert.ok(error instanceof Error); ++ assert.strictEqual(error.name, 'UnsupportedSyntaxError'); ++ assert.strictEqual(error.code, 'E_UNSUPPORTED_SYNTAX'); ++ assert.strictEqual(error.nodeType, 'DebuggerStatement'); ++ assert.strictEqual(error.sourceName, 'workflow.js'); ++ assert.strictEqual(error.line, 2); ++ assert.strictEqual(error.column, 1); ++ assert.strictEqual(error.message, 'Unsupported syntax: DebuggerStatement'); ++ assert.deepStrictEqual(logged, []); ++ }); ++ ++ it('reports more than one kind of unhandled AST node', function() { ++ var error = captureFailure('var n = 0;\nlabel: while (n < 1) { n++; }'); ++ ++ assert.ok(error instanceof Error); ++ assert.strictEqual(error.name, 'UnsupportedSyntaxError'); ++ assert.strictEqual(error.nodeType, 'LabeledStatement'); ++ assert.strictEqual(error.sourceName, ''); ++ assert.strictEqual(error.line, 2); ++ assert.strictEqual(error.column, 1); ++ }); ++ ++ [ ++ ['var [first] = values;', 'ArrayPattern'], ++ ['var {id} = record;', 'ObjectPattern'], ++ ['function collect(...items) { return items; }', 'RestElement'], ++ ['var copy = [...items];', 'SpreadElement'] ++ ].forEach(function(testCase) { ++ it('rejects unsupported ' + testCase[1] + ' syntax', function() { ++ var error = captureFailure(testCase[0]); ++ assert.ok(error instanceof Error, testCase[1] + ' must stop translation'); ++ assert.strictEqual(error.name, 'UnsupportedSyntaxError'); ++ assert.strictEqual(error.nodeType, testCase[1]); ++ assert.strictEqual(error.code, 'E_UNSUPPORTED_SYNTAX'); ++ }); ++ }); ++ ++ it('normalizes parser failures as ParseError instances', function() { ++ var error = captureFailure('var answer = ;', { sourceName: 'broken.js' }); ++ ++ assert.strictEqual(typeof transpile.ParseError, 'function'); ++ assert.ok(error instanceof Error); ++ assert.ok(error instanceof transpile.ParseError); ++ assert.strictEqual(error.name, 'ParseError'); ++ assert.strictEqual(error.code, 'E_PARSE'); ++ assert.strictEqual(error.sourceName, 'broken.js'); ++ assert.strictEqual(error.line, 1); ++ assert.strictEqual(error.column, 14); ++ assert.ok(/Unexpected token ;/.test(error.message)); ++ }); ++ ++ it('keeps successful library translation and default invocation compatible', function() { ++ var source = 'var values = [1, 2];\nvar_dump(values.length);'; ++ var expected = ':1:14: .*Unexpected token ;.*\n$/.test(stdinResult.stderr)); ++ assert.strictEqual(stdinResult.stderr.indexOf('\n at '), -1); ++ }); ++ ++ it('rejects an unknown option as an invocation error', function() { ++ var result = runCli(['--unknown'], ''); ++ ++ assertCleanProcess(result, 2); ++ assert.strictEqual(result.stdout, ''); ++ assert.ok(/^js2php: .+\n/.test(result.stderr)); ++ assert.strictEqual(result.stderr.indexOf('\n at '), -1); ++ assert.ok(/unknown option/.test(result.stderr)); ++ }); ++ ++ it('rejects multiple input operands as an invocation error', function() { ++ var result = runCli(['one.js', 'two.js'], ''); ++ ++ assertCleanProcess(result, 2); ++ assert.strictEqual(result.stdout, ''); ++ assert.ok(/^js2php: .+\n/.test(result.stderr)); ++ assert.strictEqual(result.stderr.indexOf('\n at '), -1); ++ assert.ok(/one input/.test(result.stderr)); ++ }); ++ ++ it('reports an unreadable input file without a stack trace', function() { ++ var dir = fs.mkdtempSync(path.join(os.tmpdir(), 'js2php-codespec-missing-')); ++ var missing = path.join(dir, 'does-not-exist.js'); ++ var result; ++ ++ try { ++ result = runCli([missing], ''); ++ } finally { ++ fs.rmSync(dir, { recursive: true, force: true }); ++ } ++ ++ assertCleanProcess(result, 2); ++ assert.strictEqual(result.stdout, ''); ++ assert.ok(/^js2php: .+\n/.test(result.stderr)); ++ assert.strictEqual(result.stderr.indexOf('\n at '), -1); ++ assert.ok(/cannot read/.test(result.stderr)); ++ }); ++}); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++./node_modules/.bin/mocha ./test/codespec_safe_diagnostics.js ++./node_modules/.bin/mocha ./test/suite.js --grep 'closures|core_array|loops' diff --git a/tasks/format-code-task-001035/tests/test.sh b/tasks/format-code-task-001035/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d0c203fb09d38d62a16bbb19ab8456e6b5392fbb --- /dev/null +++ b/tasks/format-code-task-001035/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test/codespec_safe_diagnostics.js +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001035/tests/test_command.sh b/tasks/format-code-task-001035/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001035/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001122/environment/Dockerfile b/tasks/format-code-task-001122/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..94e90add4a44fbd1c86300c35326d8df92edb504 --- /dev/null +++ b/tasks/format-code-task-001122/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:1afef73888a49fa884f305dc76ace5eb6bd0d782bc624f93eaf9e792282bb033 diff --git a/tasks/format-code-task-001122/environment/setup/files/blocklist b/tasks/format-code-task-001122/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001122/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001122/environment/setup/setup.sh b/tasks/format-code-task-001122/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001122/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001122/tests/test.patch b/tasks/format-code-task-001122/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..3ea4951e41c7864266296e20f3113b1fcdf7fb6c --- /dev/null +++ b/tasks/format-code-task-001122/tests/test.patch @@ -0,0 +1,135 @@ +diff --git a/scripts/tests/test_use_pd_array_contract.py b/scripts/tests/test_use_pd_array_contract.py +new file mode 100644 +index 0000000000..102b37533c +--- /dev/null ++++ b/scripts/tests/test_use_pd_array_contract.py +@@ -0,0 +1,119 @@ ++import pathlib ++import subprocess ++import sys ++import tempfile ++import unittest ++ ++ ++REPO_ROOT = pathlib.Path(__file__).resolve().parents[2] ++SCRIPT = REPO_ROOT / "scripts" / "use_pd_array_in_core.py" ++MESSAGE = "Don't use pd.array in core, import array as pd_array instead" ++ ++ ++class TestUsePdArrayContract(unittest.TestCase): ++ def run_validator(self, files): ++ return subprocess.run( ++ [sys.executable, str(SCRIPT), *(str(path) for path in files)], ++ cwd=REPO_ROOT, ++ check=False, ++ capture_output=True, ++ text=True, ++ ) ++ ++ def test_reports_each_real_pandas_array_use_and_import(self): ++ content = "\n".join( ++ [ ++ "import pandas as pd", ++ "import pandas", ++ "import pandas as p", ++ "import pandas.core as core", ++ "import unrelated as other", ++ "value1 = pd.array", ++ "value2 = pandas.array", ++ "value3 = p.array", ++ "value4 = core.array", ++ "value5 = other.array", ++ "from pandas import array", ++ "from pandas import array as arr", ++ "from pandas import array as pd_array", ++ "from unrelated import array", ++ ] ++ ) ++ with tempfile.TemporaryDirectory() as directory: ++ path = pathlib.Path(directory) / "aliases.py" ++ path.write_text(content, encoding="utf-8") ++ result = self.run_validator([path]) ++ ++ expected = "\n".join( ++ [ ++ f"{path}:6:9: {MESSAGE}", ++ f"{path}:7:9: {MESSAGE}", ++ f"{path}:8:9: {MESSAGE}", ++ f"{path}:11:0: {MESSAGE}", ++ f"{path}:12:0: {MESSAGE}", ++ "", ++ ] ++ ) ++ self.assertEqual(result.returncode, 1) ++ self.assertEqual(result.stdout, expected) ++ ++ def test_unrelated_names_are_not_reported(self): ++ content = "\n".join( ++ [ ++ "pd = object()", ++ "first = pd.array", ++ "import pandas.core as pd_core", ++ "second = pd_core.array", ++ "from unrelated import array", ++ "from pandas.core import array as core_array", ++ ] ++ ) ++ with tempfile.TemporaryDirectory() as directory: ++ path = pathlib.Path(directory) / "unrelated.py" ++ path.write_text(content, encoding="utf-8") ++ result = self.run_validator([path]) ++ ++ self.assertEqual(result.returncode, 0) ++ self.assertEqual(result.stdout, "") ++ ++ def test_scans_all_files_in_argument_order(self): ++ with tempfile.TemporaryDirectory() as directory: ++ root = pathlib.Path(directory) ++ first = root / "first.py" ++ second = root / "second.py" ++ first.write_text("import pandas as p\np.array\np.array\n", encoding="utf-8") ++ second.write_text("from pandas import array as wrong\n", encoding="utf-8") ++ result = self.run_validator([second, first]) ++ ++ expected = "\n".join( ++ [ ++ f"{second}:1:0: {MESSAGE}", ++ f"{first}:2:0: {MESSAGE}", ++ f"{first}:3:0: {MESSAGE}", ++ "", ++ ] ++ ) ++ self.assertEqual(result.returncode, 1) ++ self.assertEqual(result.stdout, expected) ++ ++ def test_correct_alias_and_non_pandas_imports_are_clean(self): ++ content = "\n".join( ++ [ ++ "from pandas import array as pd_array", ++ "from unrelated import array as other_array", ++ "import pandas as pd", ++ "result = pd_array([1, 2])", ++ "other_array([3])", ++ ] ++ ) ++ with tempfile.TemporaryDirectory() as directory: ++ path = pathlib.Path(directory) / "clean.py" ++ path.write_text(content, encoding="utf-8") ++ result = self.run_validator([path]) ++ ++ self.assertEqual(result.returncode, 0) ++ self.assertEqual(result.stdout, "") ++ ++ ++if __name__ == "__main__": ++ unittest.main() +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,5 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++python scripts/tests/test_use_pd_array_contract.py diff --git a/tasks/format-code-task-001122/tests/test.sh b/tasks/format-code-task-001122/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..7e1ef9ae2cd4782d0d75f6320891be2f5a9f3427 --- /dev/null +++ b/tasks/format-code-task-001122/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +scripts/tests/test_use_pd_array_contract.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001122/tests/test_command.sh b/tasks/format-code-task-001122/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001122/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001125/environment/Dockerfile b/tasks/format-code-task-001125/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..0b203b91cf7db0f36ab63ffeedd96aaa519c82d9 --- /dev/null +++ b/tasks/format-code-task-001125/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:670d56cabed9874ea8845cc53a8536c8aae4f50c057e74ba766b312a674b27ec diff --git a/tasks/format-code-task-001125/environment/setup/files/blocklist b/tasks/format-code-task-001125/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001125/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001125/environment/setup/setup.sh b/tasks/format-code-task-001125/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001125/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001125/tests/test.patch b/tasks/format-code-task-001125/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ac60a71d6111d6ab71e796b576403cc049634c46 --- /dev/null +++ b/tasks/format-code-task-001125/tests/test.patch @@ -0,0 +1,116 @@ +diff --git a/tests/test_downloadermiddleware_httpcompression_contract.py b/tests/test_downloadermiddleware_httpcompression_contract.py +new file mode 100644 +index 000000000..194441ea9 +--- /dev/null ++++ b/tests/test_downloadermiddleware_httpcompression_contract.py +@@ -0,0 +1,99 @@ ++import gzip ++import unittest ++import zlib ++ ++from scrapy.downloadermiddlewares.httpcompression import HttpCompressionMiddleware ++from scrapy.http import HtmlResponse, Request, Response ++ ++ ++class HttpCompressionContractTest(unittest.TestCase): ++ ++ def setUp(self): ++ self.middleware = HttpCompressionMiddleware() ++ ++ def _response(self, body, encoding, content_type='text/html'): ++ return Response( ++ 'http://example.test/page', ++ body=body, ++ headers={ ++ 'Content-Type': content_type, ++ 'Content-Encoding': encoding, ++ 'Content-Length': str(len(body)), ++ }, ++ flags=['original'], ++ request=Request('http://example.test/page', meta={'trace': 'kept'}), ++ ) ++ ++ def test_decodes_comma_separated_codings_in_wire_reverse_order(self): ++ original = b'stacked' ++ encoded = zlib.compress(gzip.compress(original)) ++ response = self._response(encoded, ' GZip , DeFlAtE ') ++ ++ result = self.middleware.process_response(response.request, response, None) ++ ++ self.assertIsInstance(result, HtmlResponse) ++ self.assertEqual(result.body, original) ++ self.assertNotIn('Content-Encoding', result.headers) ++ self.assertEqual(result.headers['Content-Length'], str(len(original)).encode('ascii')) ++ self.assertEqual(result.flags, ['original']) ++ self.assertEqual(result.meta, {'trace': 'kept'}) ++ ++ def test_decodes_repeated_content_encoding_header_values(self): ++ original = b'header values are also stacked' ++ encoded = zlib.compress(gzip.compress(original)) ++ response = self._response(encoded, ['x-gzip', 'deflate']) ++ ++ result = self.middleware.process_response(response.request, response, None) ++ ++ self.assertEqual(result.body, original) ++ self.assertNotIn('Content-Encoding', result.headers) ++ self.assertEqual(result.headers['Content-Length'], str(len(original)).encode('ascii')) ++ ++ def test_unsupported_coding_does_not_corrupt_response(self): ++ body = b'opaque payload' ++ response = self._response(body, 'gzip, br') ++ ++ result = self.middleware.process_response(response.request, response, None) ++ ++ self.assertEqual(result.body, body) ++ self.assertEqual(result.headers['Content-Encoding'], b'gzip, br') ++ self.assertEqual(result.headers['Content-Length'], str(len(body)).encode('ascii')) ++ ++ def test_supported_outer_layer_is_decoded_before_unknown_inner_layer(self): ++ original = b'payload behind an unknown inner coding' ++ response = self._response(gzip.compress(original), 'br, gzip') ++ ++ result = self.middleware.process_response(response.request, response, None) ++ ++ self.assertIsInstance(result, HtmlResponse) ++ self.assertEqual(result.body, original) ++ self.assertEqual(result.headers['Content-Encoding'], b'br') ++ self.assertEqual(result.headers['Content-Length'], str(len(original)).encode('ascii')) ++ ++ def test_malformed_supported_payload_raises(self): ++ response = self._response(b'not a gzip stream', 'gzip') ++ ++ with self.assertRaises(Exception): ++ self.middleware.process_response(response.request, response, None) ++ ++ def test_head_responses_are_left_untouched(self): ++ body = gzip.compress(b'head body') ++ response = self._response(body, 'gzip') ++ request = response.request.replace(method='HEAD') ++ ++ result = self.middleware.process_response(request, response, None) ++ ++ self.assertIs(result, response) ++ self.assertEqual(result.body, body) ++ self.assertEqual(result.headers['Content-Encoding'], b'gzip') ++ self.assertEqual(result.headers['Content-Length'], str(len(body)).encode('ascii')) ++ ++ def test_non_response_values_are_passed_through(self): ++ request = Request('http://example.test/page') ++ marker = object() ++ ++ self.assertIs(self.middleware.process_response(request, marker, None), marker) ++ ++ ++if __name__ == '__main__': ++ unittest.main() +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++pytest -q tests/test_downloadermiddleware_httpcompression.py \ ++ tests/test_downloadermiddleware_httpcompression_contract.py diff --git a/tasks/format-code-task-001125/tests/test.sh b/tasks/format-code-task-001125/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..6cab9ed8a1db91b5013a9357769511ed1885787a --- /dev/null +++ b/tasks/format-code-task-001125/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/test_downloadermiddleware_httpcompression_contract.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001125/tests/test_command.sh b/tasks/format-code-task-001125/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001125/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001140/environment/Dockerfile b/tasks/format-code-task-001140/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..07c9393a5bfe66dcfebb77113c124fefb8bafebc --- /dev/null +++ b/tasks/format-code-task-001140/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:928b4381285adc4d804207f6eb4f803cafc5f0b0c53e8cdce203827bd5fee6a2 diff --git a/tasks/format-code-task-001140/environment/setup/files/blocklist b/tasks/format-code-task-001140/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001140/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001140/environment/setup/setup.sh b/tasks/format-code-task-001140/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001140/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001140/tests/test.patch b/tasks/format-code-task-001140/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..2d01eb5219f5c0fa60d5da806d26cdb1e2b36769 --- /dev/null +++ b/tasks/format-code-task-001140/tests/test.patch @@ -0,0 +1,147 @@ +diff --git a/tests/test_ajax_contract.py b/tests/test_ajax_contract.py +new file mode 100644 +index 0000000..a057200 +--- /dev/null ++++ b/tests/test_ajax_contract.py +@@ -0,0 +1,132 @@ ++from __future__ import unicode_literals ++ ++import json ++ ++from django.http import Http404, HttpResponse ++from django.test import RequestFactory, SimpleTestCase, override_settings ++ ++from django_ajax.decorators import ajax ++from django_ajax.middleware import AJAXMiddleware ++from django_ajax.response import JSONResponse ++from django_ajax.shortcuts import render_to_json ++ ++ ++class _Marker(object): ++ pass ++ ++ ++class _MarkerEncoder(json.JSONEncoder): ++ def default(self, value): ++ if isinstance(value, _Marker): ++ return 'marker-value' ++ return super(_MarkerEncoder, self).default(value) ++ ++ ++class AJAXContractTestCase(SimpleTestCase): ++ def setUp(self): ++ self.factory = RequestFactory() ++ self.ajax_request = self.factory.get( ++ '/', HTTP_X_REQUESTED_WITH='XMLHttpRequest') ++ self.browser_request = self.factory.get('/') ++ ++ def decode(self, response): ++ return json.loads(response.content.decode('utf-8')) ++ ++ def test_render_to_json_accepts_request_context_for_http404(self): ++ response = render_to_json( ++ Http404('record missing'), request=self.ajax_request) ++ payload = self.decode(response) ++ ++ self.assertEqual(404, payload['status']) ++ self.assertEqual('NOT FOUND', payload['statusText']) ++ self.assertEqual('record missing', payload['content']) ++ ++ @override_settings(DEBUG=False) ++ def test_ajax_decorator_serializes_view_exceptions(self): ++ @ajax ++ def missing(request): ++ raise Http404('gone') ++ ++ @ajax ++ def broken(request): ++ raise ValueError('secret failure') ++ ++ missing_payload = self.decode(missing(self.ajax_request)) ++ broken_payload = self.decode(broken(self.ajax_request)) ++ ++ self.assertEqual(404, missing_payload['status']) ++ self.assertEqual('gone', missing_payload['content']) ++ self.assertEqual(500, broken_payload['status']) ++ self.assertNotIn('secret failure', broken_payload['content']) ++ self.assertNotIn('Traceback', broken_payload['content']) ++ ++ def test_ajax_decorator_preserves_response_status_in_envelope(self): ++ @ajax ++ def created(request): ++ return HttpResponse('created', status=201) ++ ++ payload = self.decode(created(self.ajax_request)) ++ self.assertEqual(201, payload['status']) ++ self.assertEqual('CREATED', payload['statusText']) ++ self.assertEqual('created', payload['content']) ++ ++ def test_middleware_does_not_double_wrap_json_responses(self): ++ middleware = AJAXMiddleware(lambda request: None) ++ original = JSONResponse( ++ {'status': 200, 'statusText': 'OK', 'content': {'ok': True}}) ++ ++ response = middleware.process_response(self.ajax_request, original) ++ ++ self.assertEqual(self.decode(original), self.decode(response)) ++ ++ def test_middleware_converts_ajax_http404_but_leaves_browser_response(self): ++ middleware = AJAXMiddleware(lambda request: None) ++ ajax_response_payload = self.decode( ++ middleware.process_response( ++ self.ajax_request, HttpResponse('accepted', status=202))) ++ ajax_payload = self.decode( ++ middleware.process_response( ++ self.ajax_request, Http404('missing through middleware'))) ++ browser_response = HttpResponse('normal', status=418) ++ ++ self.assertEqual(202, ajax_response_payload['status']) ++ self.assertEqual('accepted', ajax_response_payload['content']) ++ self.assertEqual(404, ajax_payload['status']) ++ self.assertEqual('missing through middleware', ajax_payload['content']) ++ untouched = middleware.process_response(self.browser_request, ++ browser_response) ++ self.assertEqual(418, untouched.status_code) ++ self.assertEqual(b'normal', untouched.content) ++ ++ @override_settings(DEBUG=False) ++ def test_middleware_exception_path_returns_safe_ajax_error(self): ++ middleware = AJAXMiddleware(lambda request: None) ++ exception = ValueError('private details') ++ ++ response = middleware.process_exception(self.ajax_request, exception) ++ payload = self.decode( ++ middleware.process_response(self.ajax_request, response)) ++ ++ self.assertEqual(500, payload['status']) ++ self.assertNotIn('private details', payload['content']) ++ self.assertIsNone(middleware.process_exception(self.browser_request, ++ exception)) ++ ++ def test_optional_decorator_passthrough_and_default_mandatory_guard(self): ++ @ajax(mandatory=False) ++ def optional(request): ++ return {'plain': True} ++ ++ @ajax ++ def required(request): ++ return {'plain': True} ++ ++ self.assertEqual({'plain': True}, optional(self.browser_request)) ++ self.assertEqual(400, required(self.browser_request).status_code) ++ ++ def test_render_to_json_keeps_json_encoder_options(self): ++ response = render_to_json( ++ {'value': _Marker()}, cls=_MarkerEncoder, sort_keys=True) ++ payload = self.decode(response) ++ ++ self.assertEqual('marker-value', payload['content']['value']) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,4 @@ ++#!/bin/bash ++set -euo pipefail ++ ++PYTHONPATH=tests DJANGO_SETTINGS_MODULE=settings python tests/manage.py test test_ajax_contract diff --git a/tasks/format-code-task-001140/tests/test.sh b/tasks/format-code-task-001140/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..5bdbfaf115b9cd6d778dbfca3384bd4ef396a443 --- /dev/null +++ b/tasks/format-code-task-001140/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/test_ajax_contract.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001140/tests/test_command.sh b/tasks/format-code-task-001140/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001140/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001147/environment/Dockerfile b/tasks/format-code-task-001147/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..251bbf07c6ac7f125e34d08c340761b061a64815 --- /dev/null +++ b/tasks/format-code-task-001147/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:7d8c55d3a4418a525ec9ab67ed26504453e9168207d7359d69a4753fd12dec0b diff --git a/tasks/format-code-task-001147/environment/setup/files/blocklist b/tasks/format-code-task-001147/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001147/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001147/environment/setup/setup.sh b/tasks/format-code-task-001147/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001147/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001147/tests/test.patch b/tasks/format-code-task-001147/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..032010cf3ce3250fec0b999fdaf0cfa8c6482d3f --- /dev/null +++ b/tasks/format-code-task-001147/tests/test.patch @@ -0,0 +1,149 @@ +diff --git a/tests/CodespecLocaleLifecycle.php b/tests/CodespecLocaleLifecycle.php +new file mode 100644 +index 0000000..c433a5b +--- /dev/null ++++ b/tests/CodespecLocaleLifecycle.php +@@ -0,0 +1,133 @@ ++register(new TranslationServiceProvider()); ++ $app['translator.domains'] = array( ++ 'messages' => array( ++ 'en' => array('welcome' => 'Welcome', 'items' => 'One item|Many items'), ++ 'fr' => array('welcome' => 'Bienvenue', 'items' => 'Un article|Plusieurs articles'), ++ 'es' => array('welcome' => 'Bienvenido', 'items' => 'Un articulo|Varios articulos'), ++ ), ++ ); ++ ++ return $app; ++} ++ ++function testRequestLocaleDrivesTranslator() ++{ ++ $app = codespecApp(); ++ $app->get('/greet/{_locale}', function (Request $request) use ($app) { ++ return $app['translator']->getLocale().':'.$app['translator']->trans('welcome').':'.$app['translator']->transChoice('items', 2); ++ }); ++ ++ $response = $app->handle(Request::create('/greet/fr')); ++ codespecAssertSame('fr:Bienvenue:Plusieurs articles', $response->getContent(), 'request locale translation'); ++ codespecAssertSame('fr', $app['locale'], 'request locale application state'); ++} ++ ++function testNestedRequestRestoresParentLocale() ++{ ++ $app = codespecApp(); ++ $app->get('/child/{_locale}', function (Request $request) use ($app) { ++ return $app['locale'].'/'.$request->getLocale().'/'.$app['translator']->trans('welcome').'/'.$app['translator']->transChoice('items', 2); ++ }); ++ $app->get('/parent/{_locale}', function (Request $request) use ($app) { ++ $before = $app['locale'].'/'.$request->getLocale().'/'.$app['translator']->trans('welcome'); ++ $child = $app->handle(Request::create('/child/es'), HttpKernelInterface::SUB_REQUEST)->getContent(); ++ $after = $app['locale'].'/'.$request->getLocale().'/'.$app['translator']->trans('welcome'); ++ ++ return $before.'|'.$child.'|'.$after; ++ }); ++ ++ $response = $app->handle(Request::create('/parent/fr')); ++ codespecAssertSame('fr/fr/Bienvenue|es/es/Bienvenido/Varios articulos|fr/fr/Bienvenue', $response->getContent(), 'nested locale restoration'); ++ codespecAssertSame('fr', $app['locale'], 'parent locale after nested request'); ++} ++ ++function testFailedNestedRequestRestoresLocale() ++{ ++ $app = codespecApp(); ++ $app->get('/child/{_locale}', function () { ++ throw new RuntimeException('child failed'); ++ }); ++ $app->get('/parent/{_locale}', function () use ($app) { ++ codespecAssertThrows(function () use ($app) { ++ $app->handle(Request::create('/child/es'), HttpKernelInterface::SUB_REQUEST, false); ++ }, 'failed nested request'); ++ ++ return $app['locale'].'/'.$app['translator']->trans('welcome'); ++ }); ++ ++ $response = $app->handle(Request::create('/parent/fr')); ++ codespecAssertSame('fr/Bienvenue', $response->getContent(), 'locale after failed nested request'); ++} ++ ++function testFailedNestedRequestRestoresRequestService() ++{ ++ $app = codespecApp(); ++ $app->get('/child/{_locale}', function () { ++ throw new RuntimeException('child failed'); ++ }); ++ $app->get('/parent/{_locale}', function (Request $request) use ($app) { ++ codespecAssertThrows(function () use ($app) { ++ $app->handle(Request::create('/child/es'), HttpKernelInterface::SUB_REQUEST, false); ++ }, 'failed nested request'); ++ ++ return $app['request'] === $request ? 'parent' : 'leaked-child'; ++ }); ++ ++ $response = $app->handle(Request::create('/parent/fr')); ++ codespecAssertSame('parent', $response->getContent(), 'request service after failed nested request'); ++ codespecAssertThrows(function () use ($app) { ++ $app['request']; ++ }, 'request service outside completed request'); ++} ++ ++$tests = array( ++ 'request locale translation' => 'testRequestLocaleDrivesTranslator', ++ 'nested locale restoration' => 'testNestedRequestRestoresParentLocale', ++ 'failed nested locale restoration' => 'testFailedNestedRequestRestoresLocale', ++ 'failed nested request service restoration' => 'testFailedNestedRequestRestoresRequestService', ++); ++ ++$failures = array(); ++foreach ($tests as $label => $test) { ++ try { ++ call_user_func($test); ++ echo "PASS: ".$label."\n"; ++ } catch (Exception $e) { ++ $failures[] = $label.': '.$e->getMessage(); ++ echo "FAIL: ".$label.': '.$e->getMessage()."\n"; ++ } ++} ++ ++if ($failures) { ++ exit(1); ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,5 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++php tests/CodespecLocaleLifecycle.php diff --git a/tasks/format-code-task-001147/tests/test.sh b/tasks/format-code-task-001147/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..0a51546a4909405c0c768d01cc5af1b478ab1fa1 --- /dev/null +++ b/tasks/format-code-task-001147/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/CodespecLocaleLifecycle.php +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001147/tests/test_command.sh b/tasks/format-code-task-001147/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001147/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001149/environment/Dockerfile b/tasks/format-code-task-001149/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..0afafed0d62ce0d1154aadfa2e3b2e8a945aeeb2 --- /dev/null +++ b/tasks/format-code-task-001149/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:4dd7ca275ccba1a88fbfa9733c73709117d98aaa372db8366f8e3aa05fcec75e diff --git a/tasks/format-code-task-001149/environment/setup/files/blocklist b/tasks/format-code-task-001149/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001149/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001149/environment/setup/setup.sh b/tasks/format-code-task-001149/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001149/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001149/tests/test.patch b/tasks/format-code-task-001149/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..415181995135f57c9656896b7afff49132396a5c --- /dev/null +++ b/tasks/format-code-task-001149/tests/test.patch @@ -0,0 +1,158 @@ +diff --git a/test/test-audio-uri-builder-contract.js b/test/test-audio-uri-builder-contract.js +new file mode 100644 +index 00000000..0c39b4dc +--- /dev/null ++++ b/test/test-audio-uri-builder-contract.js +@@ -0,0 +1,143 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++const assert = require('assert'); ++const {VM} = require('./yomichan-vm'); ++ ++const vm = new VM({hasOwn: (object, property) => Object.prototype.hasOwnProperty.call(object, property)}); ++vm.execute([ ++ 'mixed/lib/wanakana.min.js', ++ 'mixed/js/japanese.js', ++ 'bg/js/japanese.js', ++ 'bg/js/audio-uri-builder.js', ++ 'mixed/js/audio-system.js' ++]); ++const AudioUriBuilder = vm.get('AudioUriBuilder'); ++const AudioSystem = vm.get('AudioSystem'); ++ ++ ++async function testJpod101EncodingAndKanaFallback() { ++ const builder = new AudioUriBuilder(); ++ assert.strictEqual( ++ await builder.getUri({expression: '食べる', reading: 'タベル'}, 'jpod101', {}), ++ 'https://assets.languagepod101.com/dictionary/japanese/audiomp3.php?kanji=%E9%A3%9F%E3%81%B9%E3%82%8B&kana=%E3%82%BF%E3%83%99%E3%83%AB' ++ ); ++ assert.strictEqual( ++ await builder.getUri({expression: 'たべる', reading: ''}, 'jpod101', {}), ++ 'https://assets.languagepod101.com/dictionary/japanese/audiomp3.php?kana=%E3%81%9F%E3%81%B9%E3%82%8B' ++ ); ++ assert.strictEqual( ++ await builder.getUri({expression: '', reading: ''}, 'jpod101', {}), ++ 'https://assets.languagepod101.com/dictionary/japanese/audiomp3.php?' ++ ); ++} ++ ++async function testCustomTemplateAndUnknownSource() { ++ const builder = new AudioUriBuilder(); ++ const definition = {expression: '猫', reading: 'ねこ', dictionary: 'JMDict'}; ++ assert.strictEqual( ++ await builder.getUri(definition, 'custom', {customSourceUrl: 'https://audio.test/{expression}/{reading}/{missing}'}), ++ 'https://audio.test/%E7%8C%AB/%E3%81%AD%E3%81%93/{missing}' ++ ); ++ assert.strictEqual(await builder.getUri(definition, 'does-not-exist', {}), null); ++ assert.strictEqual(await builder.getUri(definition, 'custom', {}), null); ++} ++ ++async function testAudioSystemRetriesAndCacheIdentity() { ++ class Audio { ++ constructor(uri) { ++ this.uri = uri; ++ this.duration = 1; ++ } ++ ++ addEventListener(eventName, callback) { ++ if (eventName === 'loadeddata') { ++ if (!this.uri.includes('broken')) { Promise.resolve().then(callback); } ++ } else if (eventName === 'error' && this.uri.includes('broken')) { ++ Promise.resolve().then(callback); ++ } ++ } ++ } ++ const audioVm = new VM({Audio, hasOwn: (object, property) => Object.prototype.hasOwnProperty.call(object, property)}); ++ audioVm.execute('mixed/js/audio-system.js'); ++ const AudioSystemWithAudio = audioVm.get('AudioSystem'); ++ const builder = { ++ async getUri(definition, source, details) { ++ return details[source]; ++ } ++ }; ++ const audioSystem = new AudioSystemWithAudio({audioUriBuilder: builder, useCache: true}); ++ ++ const definition = {expression: '猫', reading: 'ねこ'}; ++ const first = await audioSystem.getDefinitionAudio(definition, ['first'], {first: 'https://audio/one.mp3'}); ++ assert.strictEqual(first.uri, 'https://audio/one.mp3'); ++ const cached = await audioSystem.getDefinitionAudio(definition, ['first'], {first: 'https://audio/one.mp3'}); ++ assert.strictEqual(cached.audio, first.audio); ++ const changed = await audioSystem.getDefinitionAudio(definition, ['first'], {first: 'https://audio/two.mp3'}); ++ assert.strictEqual(changed.uri, 'https://audio/two.mp3'); ++ const skipped = await audioSystem.getDefinitionAudio({expression: '鳥', reading: 'とり'}, ['missing', 'fallback'], { ++ missing: null, ++ fallback: 'https://audio/skip-fallback.mp3' ++ }); ++ assert.strictEqual(skipped.uri, 'https://audio/skip-fallback.mp3'); ++ assert.strictEqual(skipped.index, 1); ++ const fallback = await audioSystem.getDefinitionAudio(definition, ['broken', 'fallback'], { ++ broken: 'https://audio/broken.mp3', ++ fallback: 'https://audio/fallback.mp3' ++ }); ++ assert.strictEqual(fallback.uri, 'https://audio/fallback.mp3'); ++ assert.strictEqual(fallback.index, 1); ++ const failedDefinition = {expression: '犬', reading: 'いぬ'}; ++ await assert.rejects( ++ audioSystem.getDefinitionAudio(failedDefinition, ['broken'], {broken: 'https://audio/broken.mp3'}), ++ {message: 'Could not create audio'} ++ ); ++ const recovered = await audioSystem.getDefinitionAudio(failedDefinition, ['fallback'], { ++ fallback: 'https://audio/fallback.mp3' ++ }); ++ assert.strictEqual(recovered.uri, 'https://audio/fallback.mp3'); ++} ++ ++async function testTextToSpeechModesAndErrorFallback() { ++ const builder = new AudioUriBuilder(); ++ const definition = {expression: '猫', reading: 'ねこ'}; ++ assert.strictEqual( ++ await builder.getUri(definition, 'text-to-speech', {textToSpeechVoice: 'ja-JP'}), ++ 'tts:?text=%E7%8C%AB&voice=ja-JP' ++ ); ++ assert.strictEqual( ++ await builder.getUri(definition, 'text-to-speech-reading', {textToSpeechVoice: 'ja-JP'}), ++ 'tts:?text=%E3%81%AD%E3%81%93&voice=ja-JP' ++ ); ++ assert.strictEqual( ++ await builder.getUri({expression: 'ねこ', reading: ''}, 'text-to-speech-reading', {textToSpeechVoice: 'ja-JP'}), ++ 'tts:?text=%E3%81%AD%E3%81%93&voice=ja-JP' ++ ); ++ assert.strictEqual(await builder.getUri(definition, 'text-to-speech', {}), null); ++ assert.strictEqual(await builder.getUri(definition, 'text-to-speech-reading', {textToSpeechVoice: ''}), null); ++} ++ ++function testNormalizeUrl() { ++ const builder = new AudioUriBuilder(); ++ const base = 'https://example.test'; ++ assert.strictEqual(builder.normalizeUrl('/audio.mp3', base, '/path/'), 'https://example.test/audio.mp3'); ++ assert.strictEqual(builder.normalizeUrl('//cdn.test/audio.mp3', base, '/path/'), 'https://cdn.test/audio.mp3'); ++ assert.strictEqual(builder.normalizeUrl('audio.mp3', base, '/path/'), 'https://example.test/path/audio.mp3'); ++ assert.strictEqual(builder.normalizeUrl('data:audio/mp3;base64,AA==', base, '/path/'), 'data:audio/mp3;base64,AA=='); ++ assert.strictEqual(builder.normalizeUrl('', base, '/path/'), ''); ++} ++ ++async function main() { ++ await testJpod101EncodingAndKanaFallback(); ++ await testCustomTemplateAndUnknownSource(); ++ await testTextToSpeechModesAndErrorFallback(); ++ await testAudioSystemRetriesAndCacheIdentity(); ++ testNormalizeUrl(); ++} ++ ++if (require.main === module) { main(); } +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,4 @@ ++#!/bin/bash ++set -euo pipefail ++ ++node ./test/test-audio-uri-builder-contract.js diff --git a/tasks/format-code-task-001149/tests/test.sh b/tasks/format-code-task-001149/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..de4ebbf27f2cbfd230ef3b1c18dfb299b310fbe4 --- /dev/null +++ b/tasks/format-code-task-001149/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test/test-audio-uri-builder-contract.js +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001149/tests/test_command.sh b/tasks/format-code-task-001149/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001149/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001171/environment/Dockerfile b/tasks/format-code-task-001171/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..eab619fca196904d0e7190acf0f1bdd59bd5994f --- /dev/null +++ b/tasks/format-code-task-001171/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:552449127811bb31fe291a6a28c00f21e529f3df1bb40f78b9007f5e68a67ce4 diff --git a/tasks/format-code-task-001171/environment/setup/files/blocklist b/tasks/format-code-task-001171/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001171/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001171/environment/setup/setup.sh b/tasks/format-code-task-001171/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001171/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001171/tests/test.patch b/tasks/format-code-task-001171/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..3e197d19bb515bd71a677505438df210b9e9ef91 --- /dev/null +++ b/tasks/format-code-task-001171/tests/test.patch @@ -0,0 +1,70 @@ +diff --git a/test/codespec-redirect-rewrite-test.js b/test/codespec-redirect-rewrite-test.js +new file mode 100644 +index 0000000..244e0f2 +--- /dev/null ++++ b/test/codespec-redirect-rewrite-test.js +@@ -0,0 +1,55 @@ ++var expect = require('expect.js'); ++var rewrite = require('../lib/http-proxy/passes/web-outgoing').setRedirectHostRewrite; ++ ++function apply(statusCode, location, options, request) { ++ var proxyRes = { statusCode: statusCode, headers: { location: location } }; ++ rewrite(request || { headers: { host: 'public.example:8443' } }, {}, proxyRes, options || {}); ++ return proxyRes.headers.location; ++} ++ ++describe('redirect location rewriting', function() { ++ it('autoRewrite follows the public host and port on a 301 redirect', function() { ++ expect(apply(301, 'http://internal.example/login?next=1', { autoRewrite: true })) ++ .to.eql('http://public.example:8443/login?next=1'); ++ }); ++ ++ it('autoRewrite also handles a 308 redirect', function() { ++ expect(apply(308, 'https://internal.example/final', { autoRewrite: true })) ++ .to.eql('https://public.example:8443/final'); ++ }); ++ ++ it('protocolRewrite changes only the scheme', function() { ++ expect(apply(302, 'http://internal.example/login?next=1', { protocolRewrite: 'https' })) ++ .to.eql('https://internal.example/login?next=1'); ++ }); ++ ++ it('explicit hostRewrite wins over autoRewrite while protocol remains independent', function() { ++ expect(apply(307, 'http://internal.example/path?q=1', { ++ hostRewrite: 'canonical.example:9443', autoRewrite: true, protocolRewrite: 'https' ++ }, { headers: { host: 'public.example:8080' } })) ++ .to.eql('https://canonical.example:9443/path?q=1'); ++ }); ++ ++ it('uses the request host without its default port when autoRewrite is enabled', function() { ++ expect(apply(301, 'http://internal.example/path', { autoRewrite: true }, ++ { headers: { host: 'public.example:80' } })) ++ .to.eql('http://public.example/path'); ++ }); ++ ++ it('does not rewrite relative locations', function() { ++ expect(apply(301, '/relative/path?x=1', { ++ autoRewrite: true, protocolRewrite: 'https', hostRewrite: 'canonical.example' ++ })).to.eql('/relative/path?x=1'); ++ }); ++ ++ it('does not rewrite Location on non-redirect responses', function() { ++ expect(apply(200, 'http://internal.example/not-a-redirect', { ++ autoRewrite: true, protocolRewrite: 'https', hostRewrite: 'canonical.example' ++ })).to.eql('http://internal.example/not-a-redirect'); ++ }); ++ ++ it('leaves absolute redirects unchanged when rewriting options are omitted', function() { ++ expect(apply(301, 'http://internal.example/unchanged', {})) ++ .to.eql('http://internal.example/unchanged'); ++ }); ++}); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,4 @@ ++#!/bin/bash ++set -euo pipefail ++ ++./node_modules/.bin/mocha --reporter dot --exit test/codespec-redirect-rewrite-test.js diff --git a/tasks/format-code-task-001171/tests/test.sh b/tasks/format-code-task-001171/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..9c95e7254bc4f5c6dc7114a84934c32faa7c5758 --- /dev/null +++ b/tasks/format-code-task-001171/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test/codespec-redirect-rewrite-test.js +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001171/tests/test_command.sh b/tasks/format-code-task-001171/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001171/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001176/environment/Dockerfile b/tasks/format-code-task-001176/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..bc110e880428a61db25507d8fd31c44d7d5e60f8 --- /dev/null +++ b/tasks/format-code-task-001176/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:7829ab680acce85b7ffbdeefa7f21af495d428f931167b2247ccdcc90ebf56bf diff --git a/tasks/format-code-task-001176/environment/setup/files/blocklist b/tasks/format-code-task-001176/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001176/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001176/environment/setup/setup.sh b/tasks/format-code-task-001176/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001176/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001176/tests/test.patch b/tasks/format-code-task-001176/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..addf20d7beb0328058375c06ab9f8e01a30b384b --- /dev/null +++ b/tasks/format-code-task-001176/tests/test.patch @@ -0,0 +1,325 @@ +diff --git a/tests/codespec_scenario_composition_lint.py b/tests/codespec_scenario_composition_lint.py +new file mode 100644 +index 00000000..291f6136 +--- /dev/null ++++ b/tests/codespec_scenario_composition_lint.py +@@ -0,0 +1,309 @@ ++import logging ++import os ++import subprocess ++import sys ++import unittest ++from xml.etree import ElementTree ++ ++ ++class ScenarioCompositionLintContract(unittest.TestCase): ++ @classmethod ++ def setUpClass(cls): ++ ++ ++ sys.modules.setdefault("cElementTree", ElementTree) ++ from bzt.linter import ConfigWarning, ConfigurationLinter ++ ++ cls.ConfigWarning = ConfigWarning ++ cls.ConfigurationLinter = ConfigurationLinter ++ ++ def lint(self, config, ignored=None, runs=1): ++ linter = self.ConfigurationLinter( ++ config, ++ ignored or [], ++ logging.getLogger("codespec.scenario-composition"), ++ ) ++ linter.register_checkers() ++ for _ in range(runs): ++ linter.lint() ++ return linter.get_warnings() ++ ++ @staticmethod ++ def warning_facts(warnings, identifiers): ++ return { ++ (warning.identifier, warning.severity, str(warning.path)) ++ for warning in warnings ++ if warning.identifier in identifiers ++ } ++ ++ def test_linter_imports_without_optional_lxml(self): ++ program = """ ++import logging ++import sys ++sys.modules['lxml'] = None ++from bzt.linter import ConfigurationLinter ++linter = ConfigurationLinter( ++ {'execution': [{'scenario': {'script': 'plan.jmx'}}]}, ++ [], ++ logging.getLogger('codespec.minimal-install'), ++) ++linter.register_checkers() ++linter.lint() ++assert linter.get_warnings() == [] ++""" ++ env = os.environ.copy() ++ env["PYTHONPATH"] = os.getcwd() ++ result = subprocess.run( ++ [sys.executable, "-c", program], ++ cwd=os.getcwd(), ++ env=env, ++ stdout=subprocess.PIPE, ++ stderr=subprocess.PIPE, ++ universal_newlines=True, ++ ) ++ self.assertEqual( ++ 0, ++ result.returncode, ++ "ConfigurationLinter must work without the optional lxml package", ++ ) ++ ++ def test_nested_missing_and_invalid_include_targets(self): ++ config = { ++ "execution": [{"scenario": "root"}], ++ "scenarios": { ++ "root": { ++ "requests": [ ++ { ++ "transaction": "checkout", ++ "do": [ ++ {"include-scenario": "missing-login"}, ++ { ++ "if": "${needs_cleanup}", ++ "then": [{"include-scenario": ""}], ++ "else": [{"include-scenario": 17}], ++ }, ++ { ++ "while": "${keep_running}", ++ "do": [{"include-scenario": "missing-while-target"}], ++ }, ++ { ++ "foreach": "item in items", ++ "do": [{"include-scenario": "missing-foreach-target"}], ++ }, ++ ], ++ } ++ ] ++ } ++ }, ++ } ++ warnings = self.lint(config) ++ identifiers = {"undefined-include-scenario", "invalid-include-scenario"} ++ facts = self.warning_facts(warnings, identifiers) ++ self.assertEqual( ++ { ++ ( ++ "undefined-include-scenario", ++ self.ConfigWarning.ERROR, ++ "scenarios.root.requests.0.do.0.include-scenario", ++ ), ++ ( ++ "invalid-include-scenario", ++ self.ConfigWarning.ERROR, ++ "scenarios.root.requests.0.do.1.then.0.include-scenario", ++ ), ++ ( ++ "invalid-include-scenario", ++ self.ConfigWarning.ERROR, ++ "scenarios.root.requests.0.do.1.else.0.include-scenario", ++ ), ++ ( ++ "undefined-include-scenario", ++ self.ConfigWarning.ERROR, ++ "scenarios.root.requests.0.do.2.do.0.include-scenario", ++ ), ++ ( ++ "undefined-include-scenario", ++ self.ConfigWarning.ERROR, ++ "scenarios.root.requests.0.do.3.do.0.include-scenario", ++ ), ++ }, ++ facts, ++ ) ++ relevant = [warning for warning in warnings if warning.identifier in identifiers] ++ self.assertEqual(5, len(relevant)) ++ missing = [warning for warning in warnings if warning.identifier == "undefined-include-scenario"] ++ self.assertEqual(3, len(missing)) ++ missing_messages = "\n".join(warning.message for warning in missing) ++ self.assertIn("missing-login", missing_messages) ++ self.assertIn("missing-while-target", missing_messages) ++ self.assertIn("missing-foreach-target", missing_messages) ++ ++ def test_every_cycle_edge_is_reported_in_direct_and_indirect_cycles(self): ++ config = { ++ "execution": [{"scenario": "a"}, {"scenario": "a"}], ++ "scenarios": { ++ "a": { ++ "requests": [ ++ {"loop": 2, "do": [{"include-scenario": "b"}]}, ++ {"include-scenario": "b"}, ++ ] ++ }, ++ "b": {"requests": [{"include-scenario": "c"}]}, ++ "c": {"requests": [{"include-scenario": "a"}]}, ++ "self": {"requests": [{"include-scenario": "self"}]}, ++ }, ++ } ++ warnings = self.lint(config) ++ facts = self.warning_facts(warnings, {"recursive-include-scenario"}) ++ self.assertEqual( ++ { ++ ( ++ "recursive-include-scenario", ++ self.ConfigWarning.ERROR, ++ "scenarios.a.requests.0.do.0.include-scenario", ++ ), ++ ( ++ "recursive-include-scenario", ++ self.ConfigWarning.ERROR, ++ "scenarios.a.requests.1.include-scenario", ++ ), ++ ( ++ "recursive-include-scenario", ++ self.ConfigWarning.ERROR, ++ "scenarios.b.requests.0.include-scenario", ++ ), ++ ( ++ "recursive-include-scenario", ++ self.ConfigWarning.ERROR, ++ "scenarios.c.requests.0.include-scenario", ++ ), ++ ( ++ "recursive-include-scenario", ++ self.ConfigWarning.ERROR, ++ "scenarios.self.requests.0.include-scenario", ++ ), ++ }, ++ facts, ++ ) ++ cycle_warnings = [warning for warning in warnings if warning.identifier == "recursive-include-scenario"] ++ self.assertEqual(5, len(cycle_warnings)) ++ ++ def test_valid_dag_reuse_and_payload_keys_do_not_warn(self): ++ config = { ++ "execution": [{"scenario": "root"}], ++ "scenarios": { ++ "root": { ++ "requests": [ ++ {"include-scenario": "left"}, ++ {"include-scenario": "right"}, ++ {"include-scenario": "empty-but-defined"}, ++ { ++ "url": "https://example.invalid/echo", ++ "body": {"include-scenario": "payload-value"}, ++ }, ++ ] ++ }, ++ "left": {"requests": [{"include-scenario": "leaf"}]}, ++ "right": { ++ "requests": [ ++ {"include-scenario": "leaf"}, ++ {"include-scenario": "leaf"}, ++ ] ++ }, ++ "leaf": {"requests": ["https://example.invalid/"]}, ++ "empty-but-defined": {}, ++ }, ++ } ++ warnings = self.lint(config) ++ include_ids = { ++ "undefined-include-scenario", ++ "invalid-include-scenario", ++ "recursive-include-scenario", ++ } ++ self.assertEqual(set(), self.warning_facts(warnings, include_ids)) ++ ++ def test_inline_execution_scenarios_are_checked(self): ++ config = { ++ "execution": [ ++ { ++ "scenario": { ++ "requests": [ ++ { ++ "once": [ ++ {"include-scenario": "missing-inline-target"}, ++ ] ++ } ++ ] ++ } ++ } ++ ], ++ "scenarios": {}, ++ } ++ warnings = self.lint(config) ++ facts = self.warning_facts(warnings, {"undefined-include-scenario"}) ++ self.assertEqual( ++ { ++ ( ++ "undefined-include-scenario", ++ self.ConfigWarning.ERROR, ++ "execution.0.scenario.requests.0.once.0.include-scenario", ++ ) ++ }, ++ facts, ++ ) ++ ++ def test_new_warning_ids_honor_ignore_filter(self): ++ config = { ++ "execution": [{"scenario": "root"}], ++ "scenarios": { ++ "root": { ++ "requests": [ ++ {"include-scenario": "absent"}, ++ {"include-scenario": "root"}, ++ ] ++ } ++ }, ++ } ++ warnings = self.lint(config, ignored=["undefined-include-scenario"]) ++ ids = [warning.identifier for warning in warnings] ++ self.assertNotIn("undefined-include-scenario", ids) ++ self.assertEqual(1, ids.count("recursive-include-scenario")) ++ ++ def test_repeated_lint_replaces_findings_instead_of_duplicating(self): ++ config = { ++ "execution": [{"scenario": "root"}], ++ "scenarios": { ++ "root": {"requests": [{"include-scenario": "absent"}]}, ++ }, ++ } ++ once = self.lint(config, runs=1) ++ twice = self.lint(config, runs=2) ++ once_facts = sorted( ++ (warning.identifier, warning.severity, str(warning.path), warning.message) ++ for warning in once ++ ) ++ twice_facts = sorted( ++ (warning.identifier, warning.severity, str(warning.path), warning.message) ++ for warning in twice ++ ) ++ self.assertEqual(once_facts, twice_facts) ++ self.assertEqual(1, len([fact for fact in twice_facts if fact[0] == "undefined-include-scenario"])) ++ ++ def test_existing_typo_and_execution_reference_diagnostics_remain(self): ++ config = { ++ "execution": [ ++ { ++ "concurency": 4, ++ "scenario": "not-defined", ++ } ++ ], ++ "scenarios": {}, ++ } ++ warnings = self.lint(config) ++ facts = {(warning.identifier, str(warning.path)) for warning in warnings} ++ self.assertIn(("possible-typo", "execution.0.concurency"), facts) ++ self.assertIn(("undefined-scenario", "execution.0.scenario"), facts) ++ ++ ++if __name__ == "__main__": ++ unittest.main() +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,5 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++python tests/codespec_scenario_composition_lint.py -v diff --git a/tasks/format-code-task-001176/tests/test.sh b/tasks/format-code-task-001176/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..3b7eb3f7fe3393391f10014a7472bba419352d8f --- /dev/null +++ b/tasks/format-code-task-001176/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/codespec_scenario_composition_lint.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001176/tests/test_command.sh b/tasks/format-code-task-001176/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001176/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001178/environment/Dockerfile b/tasks/format-code-task-001178/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..9b52647d76503142df9109f37a2c97eb1e1e7b30 --- /dev/null +++ b/tasks/format-code-task-001178/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:c1501636bfbde313933a9c02e8c091ea2d586f5ab748068148ca10b328010fe7 diff --git a/tasks/format-code-task-001178/environment/setup/files/blocklist b/tasks/format-code-task-001178/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001178/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001178/environment/setup/setup.sh b/tasks/format-code-task-001178/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001178/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001178/tests/test.patch b/tasks/format-code-task-001178/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..3aba7ca4613679566cbd946818751967180375cd --- /dev/null +++ b/tasks/format-code-task-001178/tests/test.patch @@ -0,0 +1,80 @@ +diff --git a/codespec_tests/test_dmi_parser_contract.py b/codespec_tests/test_dmi_parser_contract.py +new file mode 100644 +index 0000000000..83f1e137a3 +--- /dev/null ++++ b/codespec_tests/test_dmi_parser_contract.py +@@ -0,0 +1,65 @@ ++import importlib.util ++import sys ++import types ++from datetime import date ++from pathlib import Path ++ ++ ++def _load_dmi_module(): ++ package = types.ModuleType("middlewared") ++ package.__path__ = [str(Path.cwd() / "src/middlewared/middlewared")] ++ sys.modules["middlewared"] = package ++ service = types.ModuleType("middlewared.service") ++ service.Service = type("Service", (), {"__init__": lambda self, *args, **kwargs: None}) ++ service.private = lambda fn: fn ++ sys.modules["middlewared.service"] = service ++ path = Path.cwd() / "src/middlewared/middlewared/plugins/system/dmi.py" ++ spec = importlib.util.spec_from_file_location("middlewared.plugins.system.dmi_contract", path) ++ module = importlib.util.module_from_spec(spec) ++ spec.loader.exec_module(module) ++ return module ++ ++ ++def _parse(lines): ++ module = _load_dmi_module() ++ obj = module.SystemService(module.Service) ++ obj.logger = types.SimpleNamespace(warning=lambda *args, **kwargs: None) ++ module.SystemService.CACHE = {key: None for key in module.SystemService.CACHE} ++ module.subprocess.run = lambda *args, **kwargs: types.SimpleNamespace(stdout="\n".join(lines)) ++ return obj.dmidecode_info().copy() ++ ++ ++def test_dmi_parser_keeps_values_in_their_handle_sections_and_aggregates_memory(): ++ cache = _parse([ ++ "Handle 0x0002, DMI type 2, 15 bytes", "Base Board Information", ++ " Manufacturer: BoardCo", " Product Name: Board-1", ++ "Handle 0x0003, DMI type 3, 21 bytes", "Chassis Information", ++ " Manufacturer: ChassisCo", " I2C Slave Address: 0x20", ++ "Handle 0x0001, DMI type 1, 27 bytes", "System Information", ++ " Manufacturer: SystemCo", " Product Name: Host-1", ++ " Serial Number: SERIAL", " Version: v1", ++ "Handle 0x0010, DMI type 16, 23 bytes", "Physical Memory Array", ++ " Error Correction Type: None", ++ "Handle 0x0011, DMI type 16, 23 bytes", "Physical Memory Array", ++ " Error Correction Type: Single-bit ECC", ++ ]) ++ assert cache == { ++ "bios-release-date": "", "ecc-memory": True, ++ "baseboard-manufacturer": "BoardCo", "baseboard-product-name": "Board-1", ++ "system-manufacturer": "SystemCo", "system-product-name": "Host-1", ++ "system-serial-number": "SERIAL", "system-version": "v1", "has-ipmi": False, ++ } ++ ++ ++def test_dmi_parser_only_marks_ipmi_for_type_38_records(): ++ assert _parse(["Handle 0x0001, DMI type 1, 27 bytes", "System Information", ++ " I2C Slave Address: 0x20"])["has-ipmi"] is False ++ assert _parse(["Handle 0x0038, DMI type 38, 18 bytes", "IPMI Device Information", ++ " I2C Slave Address: 0x20"])["has-ipmi"] is True ++ ++ ++def test_dmi_parser_accepts_two_digit_dates_and_ignores_invalid_dates(): ++ assert _parse(["Handle 0x0000, DMI type 0, 26 bytes", "BIOS Information", ++ " Release Date: 12/03/20"])["bios-release-date"] == date(2020, 12, 3) ++ assert _parse(["Handle 0x0000, DMI type 0, 26 bytes", "BIOS Information", ++ " Release Date: not-a-date"])["bios-release-date"] == "" +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,4 @@ ++#!/bin/bash ++set -euo pipefail ++ ++PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 pytest -q codespec_tests/test_dmi_parser_contract.py diff --git a/tasks/format-code-task-001178/tests/test.sh b/tasks/format-code-task-001178/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..9c96549314abbaf7f570845bbee8b4366fc73f11 --- /dev/null +++ b/tasks/format-code-task-001178/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +codespec_tests/test_dmi_parser_contract.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001178/tests/test_command.sh b/tasks/format-code-task-001178/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001178/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001182/environment/Dockerfile b/tasks/format-code-task-001182/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..fd8f932c0c009ddced2a8f13ccdbb438ac025c13 --- /dev/null +++ b/tasks/format-code-task-001182/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:ceda4b5f653854d180dbfe837b3df7fa1a7852e9c6a3d93576eda3d89a9ff8e2 diff --git a/tasks/format-code-task-001182/environment/setup/files/blocklist b/tasks/format-code-task-001182/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001182/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001182/environment/setup/setup.sh b/tasks/format-code-task-001182/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001182/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001182/tests/test.patch b/tasks/format-code-task-001182/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ce74239280bcba19682f2368e12bef3a3a69c900 --- /dev/null +++ b/tasks/format-code-task-001182/tests/test.patch @@ -0,0 +1,358 @@ +diff --git a/tests/Codespec/BulkSubscriptionContractTest.php b/tests/Codespec/BulkSubscriptionContractTest.php +new file mode 100644 +index 0000000..f73b2b1 +--- /dev/null ++++ b/tests/Codespec/BulkSubscriptionContractTest.php +@@ -0,0 +1,342 @@ ++results = $results; ++ } ++ ++ public function post($method, $args = [], $timeout = self::TIMEOUT) ++ { ++ $this->requests[] = [ ++ 'method' => $method, ++ 'args' => $args, ++ 'timeout' => $timeout, ++ ]; ++ ++ $next = array_shift($this->results); ++ if ($next === null) { ++ $next = ['response' => ['id' => 'unconfigured-batch'], 'error' => false]; ++ } ++ ++ $this->lastError = $next['error']; ++ ++ return $next['response']; ++ } ++ ++ public function getLastError() ++ { ++ return $this->lastError; ++ } ++} ++ ++class BulkSubscriptionContractTest extends TestCase ++{ ++ public function test_bulk_subscription_is_a_public_newsletter_operation() ++ { ++ $newsletter = $this->newsletter(new RecordingBulkMailChimp()); ++ ++ $this->requireBulkSubscriptionApi($newsletter); ++ } ++ ++ public function test_defaults_and_both_list_selection_paths_reach_the_batch_api() ++ { ++ $api = new RecordingBulkMailChimp([ ++ ['response' => ['id' => 'default-list-batch'], 'error' => false], ++ ['response' => ['id' => 'named-list-batch'], 'error' => false], ++ ]); ++ $newsletter = $this->newsletter($api); ++ $this->requireBulkSubscriptionApi($newsletter); ++ ++ $defaultResult = $newsletter->subscribeMany([' Alice@Example.COM ']); ++ $namedResult = $newsletter->subscribeMany(['bob@example.com'], 'list2'); ++ ++ $this->assertSame([ ++ ['id' => 'default-list-batch'], ++ ], $defaultResult); ++ $this->assertSame([ ++ ['id' => 'named-list-batch'], ++ ], $namedResult); ++ $this->assertCount(2, $api->requests); ++ ++ $defaultOperation = $this->operation($api->requests[0], 0); ++ $this->assertSame('member-0', $defaultOperation['operation_id']); ++ $this->assertSame('PUT', $defaultOperation['method']); ++ $this->assertSame( ++ 'lists/123/members/'.md5('alice@example.com'), ++ $defaultOperation['path'] ++ ); ++ $this->assertEquals([ ++ 'email_address' => 'Alice@Example.COM', ++ 'status_if_new' => 'subscribed', ++ 'email_type' => 'html', ++ ], json_decode($defaultOperation['body'], true)); ++ ++ $namedOperation = $this->operation($api->requests[1], 0); ++ $this->assertSame( ++ 'lists/456/members/'.md5('bob@example.com'), ++ $namedOperation['path'] ++ ); ++ } ++ ++ public function test_global_and_member_options_have_explicit_precedence_without_truthiness_loss() ++ { ++ $api = new RecordingBulkMailChimp([ ++ ['response' => ['id' => 'precedence-batch'], 'error' => false], ++ ]); ++ $newsletter = $this->newsletter($api); ++ $this->requireBulkSubscriptionApi($newsletter); ++ ++ $newsletter->subscribeMany([ ++ [ ++ 'email_address' => ' Member@Example.com ', ++ 'status_if_new' => 'subscribed', ++ 'email_type' => '', ++ 'merge_fields' => [], ++ 'marketing_permissions' => false, ++ ], ++ ], '', [ ++ 'email_address' => 'must-not-replace@example.com', ++ 'status_if_new' => 'pending', ++ 'email_type' => 'text', ++ 'merge_fields' => ['SOURCE' => 'global'], ++ 'language' => '', ++ ]); ++ ++ $operation = $this->operation($api->requests[0], 0); ++ $this->assertEquals([ ++ 'email_address' => 'Member@Example.com', ++ 'status_if_new' => 'subscribed', ++ 'email_type' => '', ++ 'merge_fields' => [], ++ 'language' => '', ++ 'marketing_permissions' => false, ++ ], json_decode($operation['body'], true)); ++ $this->assertSame( ++ 'lists/123/members/'.md5('member@example.com'), ++ $operation['path'] ++ ); ++ } ++ ++ public function test_duplicates_are_collapsed_by_normalized_address_with_last_occurrence_order() ++ { ++ $api = new RecordingBulkMailChimp([ ++ ['response' => ['id' => 'deduplicated-batch'], 'error' => false], ++ ]); ++ $newsletter = $this->newsletter($api); ++ $this->requireBulkSubscriptionApi($newsletter); ++ ++ $newsletter->subscribeMany([ ++ [ ++ 'email_address' => 'First@Example.com', ++ 'merge_fields' => ['VERSION' => 'old'], ++ ], ++ 'second@example.com', ++ [ ++ 'email_address' => ' first@EXAMPLE.com ', ++ 'merge_fields' => ['VERSION' => 'new'], ++ ], ++ ]); ++ ++ $operations = $api->requests[0]['args']['operations']; ++ $this->assertCount(2, $operations); ++ $this->assertSame('member-0', $operations[0]['operation_id']); ++ $this->assertSame('member-1', $operations[1]['operation_id']); ++ $this->assertSame( ++ 'lists/123/members/'.md5('second@example.com'), ++ $operations[0]['path'] ++ ); ++ $this->assertSame( ++ 'lists/123/members/'.md5('first@example.com'), ++ $operations[1]['path'] ++ ); ++ $this->assertEquals( ++ ['VERSION' => 'new'], ++ json_decode($operations[1]['body'], true)['merge_fields'] ++ ); ++ } ++ ++ public function test_more_than_500_unique_members_are_chunked_with_global_operation_ids() ++ { ++ $api = new RecordingBulkMailChimp([ ++ ['response' => ['id' => 'chunk-one'], 'error' => false], ++ ['response' => ['id' => 'chunk-two'], 'error' => false], ++ ]); ++ $newsletter = $this->newsletter($api); ++ $this->requireBulkSubscriptionApi($newsletter); ++ $members = []; ++ $members[] = [ ++ 'email_address' => 'Boundary@Example.com', ++ 'merge_fields' => ['VERSION' => 'old'], ++ ]; ++ for ($index = 1; $index <= 500; $index++) { ++ $members[] = "member{$index}@example.com"; ++ } ++ $members[] = [ ++ 'email_address' => ' boundary@example.COM ', ++ 'merge_fields' => ['VERSION' => 'new'], ++ ]; ++ ++ $result = $newsletter->subscribeMany($members); ++ ++ $this->assertSame([ ++ ['id' => 'chunk-one'], ++ ['id' => 'chunk-two'], ++ ], $result); ++ $this->assertCount(2, $api->requests); ++ $this->assertCount(500, $api->requests[0]['args']['operations']); ++ $this->assertCount(1, $api->requests[1]['args']['operations']); ++ $this->assertSame( ++ 'member-499', ++ $api->requests[0]['args']['operations'][499]['operation_id'] ++ ); ++ $this->assertSame( ++ 'member-500', ++ $api->requests[1]['args']['operations'][0]['operation_id'] ++ ); ++ $lastOperation = $api->requests[1]['args']['operations'][0]; ++ $this->assertSame( ++ 'lists/123/members/'.md5('boundary@example.com'), ++ $lastOperation['path'] ++ ); ++ $this->assertEquals( ++ ['VERSION' => 'new'], ++ json_decode($lastOperation['body'], true)['merge_fields'] ++ ); ++ } ++ ++ public function test_all_members_are_validated_before_any_batch_is_submitted() ++ { ++ $invalidSets = [ ++ [ ++ 'members' => ['valid@example.com', ' '], ++ 'message' => 'Member at index 1 must provide a non-empty email_address.', ++ ], ++ [ ++ 'members' => [ ++ ['email_address' => 'valid@example.com'], ++ ['merge_fields' => []], ++ ], ++ 'message' => 'Member at index 1 must provide a non-empty email_address.', ++ ], ++ [ ++ 'members' => [123], ++ 'message' => 'Member at index 0 must provide a non-empty email_address.', ++ ], ++ ]; ++ ++ foreach ($invalidSets as $invalidSet) { ++ $api = new RecordingBulkMailChimp(); ++ $newsletter = $this->newsletter($api); ++ $this->requireBulkSubscriptionApi($newsletter); ++ ++ try { ++ $newsletter->subscribeMany($invalidSet['members']); ++ $this->fail('Invalid member input was accepted.'); ++ } catch (InvalidArgumentException $exception) { ++ $this->assertSame($invalidSet['message'], $exception->getMessage()); ++ } ++ ++ $this->assertSame([], $api->requests); ++ } ++ } ++ ++ public function test_an_unknown_list_fails_before_batch_submission() ++ { ++ $api = new RecordingBulkMailChimp(); ++ $newsletter = $this->newsletter($api); ++ $this->requireBulkSubscriptionApi($newsletter); ++ ++ try { ++ $newsletter->subscribeMany(['valid@example.com'], 'unknown-list'); ++ $this->fail('An unknown list name was accepted.'); ++ } catch (InvalidNewsletterList $exception) { ++ $this->assertStringContainsString('unknown-list', $exception->getMessage()); ++ } ++ ++ $this->assertSame([], $api->requests); ++ } ++ ++ public function test_empty_input_is_a_no_op_with_an_empty_receipt_list() ++ { ++ $api = new RecordingBulkMailChimp(); ++ $newsletter = $this->newsletter($api); ++ $this->requireBulkSubscriptionApi($newsletter); ++ ++ $result = $newsletter->subscribeMany([]); ++ ++ $this->assertSame([], $result); ++ $this->assertSame([], $api->requests); ++ } ++ ++ public function test_api_error_stops_later_chunks_and_returns_false() ++ { ++ $api = new RecordingBulkMailChimp([ ++ ['response' => ['id' => 'accepted-chunk'], 'error' => false], ++ ['response' => ['id' => 'rejected-chunk'], 'error' => 'batch rejected'], ++ ['response' => ['id' => 'must-not-run'], 'error' => false], ++ ]); ++ $newsletter = $this->newsletter($api); ++ $this->requireBulkSubscriptionApi($newsletter); ++ $members = []; ++ for ($index = 0; $index < 1001; $index++) { ++ $members[] = "failure{$index}@example.com"; ++ } ++ ++ $result = $newsletter->subscribeMany($members); ++ ++ $this->assertFalse($result); ++ $this->assertCount(2, $api->requests); ++ $this->assertCount(500, $api->requests[1]['args']['operations']); ++ $this->assertSame( ++ 'member-500', ++ $api->requests[1]['args']['operations'][0]['operation_id'] ++ ); ++ } ++ ++ private function newsletter(RecordingBulkMailChimp $api) ++ { ++ $lists = NewsletterListCollection::createFromConfig([ ++ 'lists' => [ ++ 'list1' => ['id' => 123], ++ 'list2' => ['id' => 456], ++ ], ++ 'defaultListName' => 'list1', ++ ]); ++ ++ return new Newsletter($api, $lists); ++ } ++ ++ private function requireBulkSubscriptionApi(Newsletter $newsletter) ++ { ++ $this->assertTrue( ++ is_callable([$newsletter, 'subscribeMany']), ++ 'Newsletter::subscribeMany() must be a public callable method.' ++ ); ++ } ++ ++ private function operation(array $request, $index) ++ { ++ $this->assertSame('batches', $request['method']); ++ $this->assertArrayHasKey('operations', $request['args']); ++ $this->assertArrayHasKey($index, $request['args']['operations']); ++ ++ return $request['args']['operations'][$index]; ++ } ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,5 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++vendor/bin/phpunit --no-configuration --colors=never tests/Codespec/BulkSubscriptionContractTest.php diff --git a/tasks/format-code-task-001182/tests/test.sh b/tasks/format-code-task-001182/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..87933316906e948ddec3bf9a1015d74daf868d7a --- /dev/null +++ b/tasks/format-code-task-001182/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/Codespec/BulkSubscriptionContractTest.php +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001182/tests/test_command.sh b/tasks/format-code-task-001182/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001182/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001185/environment/Dockerfile b/tasks/format-code-task-001185/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a7e6867c701a69c5f46e8ee9844834794815f4fa --- /dev/null +++ b/tasks/format-code-task-001185/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:7943d0f98e794982fbce35305dfe6171e5940bd23771288c612fd4d0b869d7f6 diff --git a/tasks/format-code-task-001185/environment/setup/files/blocklist b/tasks/format-code-task-001185/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001185/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001185/environment/setup/setup.sh b/tasks/format-code-task-001185/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001185/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001185/tests/test.patch b/tasks/format-code-task-001185/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e8fc0e3e48d81e9ae64e6b6546826fa4c6e123fd --- /dev/null +++ b/tasks/format-code-task-001185/tests/test.patch @@ -0,0 +1,82 @@ +diff --git a/server/service_test.go b/server/service_test.go +index 2aa8db55..16ce697e 100644 +--- a/server/service_test.go ++++ b/server/service_test.go +@@ -2,11 +2,13 @@ package server + + import ( + "bytes" ++ "context" + "encoding/json" + "fmt" + "math" + "net/http" + "net/http/httptest" ++ "strings" + "testing" + "time" + +@@ -45,6 +47,7 @@ func newTestBackend(t *testing.T, numRelays int, relayTimeout time.Duration) *te + GenesisForkVersionHex: "0x00000000", + RelayRequestTimeout: relayTimeout, + RelayCheck: true, ++ MaxHeaderBytes: 4000, + } + service, err := NewBoostService(opts) + require.NoError(t, err) +@@ -73,7 +76,7 @@ func (be *testBackend) request(t *testing.T, method string, path string, payload + + func TestNewBoostServiceErrors(t *testing.T) { + t.Run("errors when no relays", func(t *testing.T) { +- _, err := NewBoostService(BoostServiceOpts{testLog, ":123", []RelayEntry{}, "0x00000000", time.Second, true}) ++ _, err := NewBoostService(BoostServiceOpts{testLog, ":123", []RelayEntry{}, "0x00000000", time.Second, true, 4000}) + require.Error(t, err) + }) + } +@@ -115,6 +118,22 @@ func TestWebserverRootHandler(t *testing.T) { + require.Equal(t, "{}\n", rr.Body.String()) + } + ++func TestWebserverMaxHeaderSize(t *testing.T) { ++ backend := newTestBackend(t, 1, time.Second) ++ addr := "localhost:1234" ++ backend.boost.listenAddr = addr ++ go func() { ++ err := backend.boost.StartHTTPServer() ++ require.NoError(t, err) ++ }() ++ time.Sleep(time.Millisecond * 100) ++ path := "http://" + addr + "?" + strings.Repeat("abc", 4000) ++ code, err := SendHTTPRequest(context.Background(), *http.DefaultClient, http.MethodGet, path, nil, nil) ++ require.Error(t, err) ++ require.Equal(t, http.StatusRequestHeaderFieldsTooLarge, code) ++ backend.boost.srv.Close() ++} ++ + // Example good registerValidator payload + var payloadRegisterValidator = types.SignedValidatorRegistration{ + Message: &types.RegisterValidatorRequestMessage{ +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,8 @@ ++H4sIAAAAAAAAA+3SzYrbMBAA4Jz9FFP2klAiW3YcQ6GnHPZe2nOQpSE2q0jBkr3k7TtSU7YttHvZ ++ZVk630VGP6ORZ0Q/j9Yc0S3l6rVUpGvbPJI/x/wt21rW9a6rKrmqpGy7ZgXtq2X0izlENQGsJu/j ++v/Y9t/5Oiaf6RwzxqP35rJwRYXi5O56r/152P+u/7+pU/92+pvpXL5fC3/3n9b/7UPajK3sVhkIb ++yE3QoymKO/g6IPQ2RDB4QWfQ6Susl0o0otvAGGB01CwXFcfeIjyOcYB7D1LUu4+wPmMcvAHvwHm3 ++tV4rC/F6wQ3FpfaC+8MBZAvrQ91A772FB7w++slsBHwLeAvUPG1tRGFw2Qa6Rg9w+rH825TWtCul ++fbCoHOS2Bq00PSJ6QBfmCWHClPJoKWlKLeccaYP2E63EfNWCU6DFgu7QOdI2B0mRv8wOlKWH0D9K ++z89nA050BC5KP6gTwpq66YTx022+TMOo8ZjOiJPfpLjpG0R52wHbhe7ws4ufZfHW7cAYY4wxxhhj ++jDHGGGOMMcYYY4wxxt6Z725HQVUAKAAA +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-001185/tests/test.sh b/tasks/format-code-task-001185/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..be6d36a16dea8e1f875f49d80b47c531decfebd5 --- /dev/null +++ b/tasks/format-code-task-001185/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +server/service_test.go +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001185/tests/test_command.sh b/tasks/format-code-task-001185/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001185/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001200/environment/Dockerfile b/tasks/format-code-task-001200/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..4ebf9bf32e193e432ff17a8b59ae1d63372a4617 --- /dev/null +++ b/tasks/format-code-task-001200/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:780b104b6d9ef377d95b0a8714215dee26f4056ebd275eb70fd346f9cb082282 diff --git a/tasks/format-code-task-001200/environment/setup/files/blocklist b/tasks/format-code-task-001200/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001200/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001200/environment/setup/setup.sh b/tasks/format-code-task-001200/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001200/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001200/tests/test.patch b/tasks/format-code-task-001200/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..68376071f360dd3ce38f3da132e79bfa3b6e9de8 --- /dev/null +++ b/tasks/format-code-task-001200/tests/test.patch @@ -0,0 +1,83 @@ +diff --git a/Tests/voltLib/parser_test.py b/Tests/voltLib/parser_test.py +index 82ee49edc9..dd3ce907cc 100644 +--- a/Tests/voltLib/parser_test.py ++++ b/Tests/voltLib/parser_test.py +@@ -663,6 +663,58 @@ def test_substitution_process_base(self): + (lookup.name, lookup.process_base), + ("SomeSub", True)) + ++ def test_substitution_process_marks(self): ++ [group, lookup] = self.parse( ++ 'DEF_GROUP "SomeMarks" ENUM GLYPH "marka" GLYPH "markb" ' ++ 'END_ENUM END_GROUP\n' ++ 'DEF_LOOKUP "SomeSub" PROCESS_BASE PROCESS_MARKS "SomeMarks" ' ++ 'AS_SUBSTITUTION\n' ++ 'SUB GLYPH "A" WITH GLYPH "A.c2sc"\n' ++ 'END_SUB\n' ++ 'END_SUBSTITUTION' ++ ).statements ++ self.assertEqual( ++ (lookup.name, lookup.process_marks), ++ ("SomeSub", 'SomeMarks')) ++ ++ def test_substitution_process_marks_all(self): ++ [lookup] = self.parse( ++ 'DEF_LOOKUP "SomeSub" PROCESS_BASE PROCESS_MARKS "ALL" ' ++ 'AS_SUBSTITUTION\n' ++ 'SUB GLYPH "A" WITH GLYPH "A.c2sc"\n' ++ 'END_SUB\n' ++ 'END_SUBSTITUTION' ++ ).statements ++ self.assertEqual( ++ (lookup.name, lookup.process_marks), ++ ("SomeSub", True)) ++ ++ def test_substitution_process_marks_none(self): ++ [lookup] = self.parse( ++ 'DEF_LOOKUP "SomeSub" PROCESS_BASE PROCESS_MARKS "NONE" ' ++ 'AS_SUBSTITUTION\n' ++ 'SUB GLYPH "A" WITH GLYPH "A.c2sc"\n' ++ 'END_SUB\n' ++ 'END_SUBSTITUTION' ++ ).statements ++ self.assertEqual( ++ (lookup.name, lookup.process_marks), ++ ("SomeSub", False)) ++ ++ def test_substitution_process_marks_bad(self): ++ with self.assertRaisesRegex( ++ VoltLibError, ++ 'Expected ALL, NONE, MARK_GLYPH_SET or an ID'): ++ self.parse( ++ 'DEF_GROUP "SomeMarks" ENUM GLYPH "marka" GLYPH "markb" ' ++ 'END_ENUM END_GROUP\n' ++ 'DEF_LOOKUP "SomeSub" PROCESS_BASE PROCESS_MARKS SomeMarks ' ++ 'AS_SUBSTITUTION\n' ++ 'SUB GLYPH "A" WITH GLYPH "A.c2sc"\n' ++ 'END_SUB\n' ++ 'END_SUBSTITUTION' ++ ) ++ + def test_substitution_skip_marks(self): + [group, lookup] = self.parse( + 'DEF_GROUP "SomeMarks" ENUM GLYPH "marka" GLYPH "markb" ' +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,4 @@ ++H4sIAAAAAAAAA+3RQQrCMBCF4a49xVzANqmmvYRL96W1BQXblCYteHtjN4qgbhQR/2+RDDOBDLy4 ++Gg/Humi6KYk+RQW5MfMd3N9zrU2qU63S9Sr0tTZZHon52EY3RufLQSQarPXP3r2a/6j4mr9vnC92 ++tm3Lro7d/n1/vMw/z675qzTkv86UiUS9b4XH/jz/XS1z8FVTL/qT39tuJctWQhmasg2HSyZ79JtD ++lfTl4JqhuEzi/iTLafHt7QEAAAAAAAAAAAAAAID/dgZR++mCACgAAA== +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-001200/tests/test.sh b/tasks/format-code-task-001200/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..b7449fa2050e87e14cf54a3ab320a45ece2546c1 --- /dev/null +++ b/tasks/format-code-task-001200/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +Tests/voltLib/parser_test.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001200/tests/test_command.sh b/tasks/format-code-task-001200/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001200/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001207/environment/Dockerfile b/tasks/format-code-task-001207/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..98d2492e0576a77f7f35175113aaea7ee01bd16d --- /dev/null +++ b/tasks/format-code-task-001207/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:c943886f192d6acd2febf59c705e4afb93a9b55e05c2f8effe65b3a09425645a diff --git a/tasks/format-code-task-001207/environment/setup/files/blocklist b/tasks/format-code-task-001207/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001207/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001207/environment/setup/setup.sh b/tasks/format-code-task-001207/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001207/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001207/tests/test.patch b/tasks/format-code-task-001207/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..919574ef06f2f02d275cb37ff46a4bd11fc59e76 --- /dev/null +++ b/tasks/format-code-task-001207/tests/test.patch @@ -0,0 +1,105 @@ +diff --git a/tests/hook_main.py b/tests/hook_main.py +index e424d0df1a..0840cee47e 100644 +--- a/tests/hook_main.py ++++ b/tests/hook_main.py +@@ -3027,23 +3027,10 @@ def user_permission_delete(transaction): + + + # ------------------------- Stripe Authorizations ------------------------- +-@hooks.before("StripeAuthorization > StripeAuthorization Collection > List all Stripe Authorizations") +-def stripe_authorization_get_list(transaction): +- """ +- GET /events/1/stripe +- :param transaction: +- :return: +- """ +- with stash['app'].app_context(): +- stripe = StripeAuthorizationFactory() +- db.session.add(stripe) +- db.session.commit() +- +- + @hooks.before("StripeAuthorization > StripeAuthorization Collection > Create Stripe Authorization") + def stripe_authorization_post(transaction): + """ +- POST /events/1/stripe ++ POST /stripe-authorization + :param transaction: + :return: + """ +@@ -3092,6 +3079,19 @@ def stripe_authorization_delete(transaction): + db.session.commit() + + ++@hooks.before("StripeAuthorization > Stripe Authorization for an Event > Get Stripe Authorization Details of an Event") ++def event_stripe_authorization_get_detail(transaction): ++ """ ++ GET /events/1/stripe-authorization ++ :param transaction: ++ :return: ++ """ ++ with stash['app'].app_context(): ++ stripe = StripeAuthorizationFactory() ++ db.session.add(stripe) ++ db.session.commit() ++ ++ + # ------------------------- Export ------------------------- + @hooks.before( + "Event Export > Start Event Export > Start a Task to Export an Event") +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,40 @@ ++H4sIAAAAAAAAA+0af3fbuK1/61NgTvfSppUVOXFyz9vdzte4Tbe29hLfbvfy+lzaom1eaFFHSm59 ++Tb77AMo/E9lJuty13Yi8F1kkCIAACIAUy91MyKjD43Hw4PeCXYTDatU+Ea4+7e+wWgkrYbhfPQwf ++7IbhATZB9XeTaAkykzIN8EArlW7Cu6n/K4Xywv6R5lHUMakWCS9PRvLeeJCBD/b319k/3Ksezu2/ ++F+6h/fcPD/cewO69SbAB/s/tH+mJr7O4BnEmpTdU6rwvJDc1KAcpN6kJqKkzYiIuJxNPsniQsQGv ++QTJJhyr2DIujrvpQgz6ThnuG6zHXs14YsRiRcSAgi7xviuK/ZyKtQdUTMT3z0T20hRrVPACWCKYn ++9UT8g09qsL3txWxEQuV4KpbYevbW0zxROiWGPSk8laVJltqOIWcRNeNPQxjRbGhmqNnOVcRSxNzn ++Wis9Jx3xlAk5fx1xnEdk6fSUVDg01Rn3JB9zWQMR95WXCpQsZaNkrgPUXzyfU8LSYS4S6tH475U+ ++x9nTIEWyHtACWO3rqTjmvXSBU12LonmqJxZhtZ/10yWsXNXhVSREGW1iYvvXcRii3SU9lSHalcPy ++Lv6FxUhkJJxquFcJUY1xXwxqYL2ry6NgQwDyujLjiRakzSL8HLNDPWX0mK7H4yhRFn17mKZJLQik ++6jFphaQJbnufe7l9cbBBnffGY3P8Dw8Odvfm8b9SofiPxqq4+P9HwPPmyet6G5dw3fO2oJnwGBpj ++jF9Qb72klhdaZQmcWteoZxgNtfiNpQJDv7ezM8U8ev3yzc6O57UVZEnEUg5Kw4CnwOIJsBTHdjNq ++7EM6FAYQg4FkE66fwkRl8F5ICTHnEXBLj0UjEQPr9bgxZc+7gBbTGP4xHsEFtCcJx8cJ/zUTGC7g ++wruo+XO4WHnYnzj+3dSzDe9hPOuc88k7QBrUGg/wx87OhJudHVjG1byvuRl2UnXO45vRk6wrhRmy ++ruS3o0+JqCOimxE55l65Ds3b2iqyDTxTUmLox59nwTicrmyfLeN8/FuCufnP1a4Rv+Ejejp9jbNR ++l2tqoMz5FKsBVPzlW+/JwgwGMzTAE1glAI9UQoSZfIqZMeUDsu+7cPfdY/DhNfsgRtkIcurkCqhd ++lWm0MZCxweDUJCeSIkYPiqg/UVg0lFeZzcUrZlex3FqIO2OVKujztDdEkn10y3S4iQlNeZlwrnKk ++y5LEpxrEkj8lLCK0mAN6q9IRmQf5UddAoC8vOT9N0vQwQREOonJdhnqCyy2CbX+bRlneiBbxK3hT ++2XJLFEp39tbK9TzHuCZLXzJzjqncpP4vBocmYkqMcMzEpHxUhpbkzNCU+lQhTdPn9ZFljaUVEo1U ++z5SFCngcSEYpI5iTLA/TkbTKHimNqkUn3YJnOA7VkDsrrHrrWat52n7rTde0Qe/1m3rAYvQrDXUb ++Bzz0P+pHRvAIjSFFz44NxnFEyeoJiffYm6rq2JZ/Jn+dwQrPGvz9pzb8ldoAa8zvZiN/UNFkddjH ++lTeAEoWvUu1aO/bMrW0K+xFjuhDzQORjoEDEEv+A1aPkpacbRkzDkW/D0W0HLQWlu/Ci0OSL6Lbo ++NkAtIX8/fZZ7alS6Nu7yOqlSijGdCBSFqQLWJc2l7TNDkaxVtc0lazo3WXHan88/LJz5itA5n0Ks ++y4LW621XW1bfL3PPz8MUVHbDG92fYHlaxVO9UYkbFFjCjdP5eh/nsk+KWZd4gjBY4R3kjApdzCLy ++aEbOYpogLHCrzUpcJb55od7Kr69Ke7eVfYeV9glr+caYsVE3d1iMaxbJWve4hWtckW3pbUXO0jQb ++XXfrMcZ9kpTkKu+W1hIolvGOEi7kw2W6qMWupLej/EwB1pZiwUcRXS7lv7ysLsqCBUWYiLB4h0fT ++EojKgJdHeanNoYhZno5fYHVeJOzZiwZm4kWy3ZxRUagEN9vrAtKd8u9KlNt1Uc5FORflvswotwU/ ++5rv8wgDSqrefHb919bqr1+f4swV0p0LXpQCXAlwK+BJTAGWAIy75ugxw1HjVaDe+zioSS+uCEDLC ++2psNrLc0u7/wXgomswV5P5NyApFVRrTeBp9ixFttLeiQjc1O7M+WIsdH++yICP+LvuD6stDKS5uO ++62fvdBhJOxA4zb/cFmw+rnKxW5H8WJJ2IosO+iKQcxDRbHdi38vwqPvNXmWf8QoIQ5OZLl7CWox/ ++vHnbMt9j4aCFPr7WvczGouU2h183Hn9ZlE3JbQntHtPc1WncJuHNoOgwrfA4raAAubHQ+8RkuDr0 ++9lXinWu3T64R75ok12nwU0u+gq7Nbnfn1Gkl3pjo10Vf27k+Al8ntF7y/yLhX37eOwlL3//pK04H ++3XzEMESZ4f3xuOH+X1jdX7r/VanQ/a+DsOq+//8RsPWnoCvioMvM0OtF82s29On/FJNtlkArv8tV ++KR/CWDBIJugrHv9Al3qg9XPjzb86J81m+9vSw+Pm60ZQtv2lOUK9fYxdCzziVntIzYgzZhJKDx/Z ++IUA3wcB/XPLy14FUXexGtuXwGxKnEY+FVvGIUvuYaUEh0Mz4HNXb9R/qp43Ojyevvi0lyqQDjHa/ ++yloQqITHnbxQsbe/yN7p9/MrS7Uq+pyd9lzoduO03blXiq2f28fNN7kyZiou5ZMymebQysmf/vMV ++FUE6i2OsoOxVOdHjsGAOlhVUvgsiPg7oGhtcXOR30hbETniERJboaGrw84t34PsR4yNFx8owwbpv ++Da0jrRIspegTeS//dEslG4lu72906VtxqoDnLHuSY9mFwqXcM1mkwM/mUkNCgvs9KB2dNFtzS8HL ++59D498vT9qml+pfSsiQbiDw7adTbjQUZK1LzpzeNE7hilyskcVInWQz2kpkdZWz5nEdrWInWMLtI ++ZiCjiwmwcgkyp+D7+VW2291k+9zL3IEDBw4cOHDgwIEDBw4cOHDgwIEDBw4cOHDgwIEDBw4cOHDg ++wMH/KPwHwAS+bABQAAA= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-001207/tests/test.sh b/tasks/format-code-task-001207/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..51849f753596325dadf0bbce8ede8c5be4c3c932 --- /dev/null +++ b/tasks/format-code-task-001207/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/hook_main.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001207/tests/test_command.sh b/tasks/format-code-task-001207/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001207/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001236/environment/Dockerfile b/tasks/format-code-task-001236/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..34df5a7f93224f0d47ff4f8f4026a6471d46d1a6 --- /dev/null +++ b/tasks/format-code-task-001236/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:81cbbc53219449d886afce2c9ffe84e87b747db026eb9e9cb256fab058701c87 diff --git a/tasks/format-code-task-001236/environment/setup/files/blocklist b/tasks/format-code-task-001236/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001236/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001236/environment/setup/setup.sh b/tasks/format-code-task-001236/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001236/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001236/tests/test.patch b/tasks/format-code-task-001236/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..4e89d01ca22d2f2382f5b305801cb1a67cb8cc29 --- /dev/null +++ b/tasks/format-code-task-001236/tests/test.patch @@ -0,0 +1,137 @@ +diff --git a/pkg/utils/kubernetes/client/client_test.go b/pkg/utils/kubernetes/client/client_test.go +index c931f4d2141..c876a69842c 100644 +--- a/pkg/utils/kubernetes/client/client_test.go ++++ b/pkg/utils/kubernetes/client/client_test.go +@@ -110,6 +110,28 @@ var _ = Describe("Cleaner", func() { + Expect(cleaner.Clean(ctx, c, &cm1)).To(Succeed()) + }) + ++ It("should succeed if not found error occurs for target object", func() { ++ var ( ++ ctx = context.TODO() ++ cleaner = NewCleaner(timeOps, NewFinalizer()) ++ ) ++ ++ c.EXPECT().Get(ctx, cm1Key, &cm1).Return(apierrors.NewNotFound(schema.GroupResource{}, "")) ++ ++ Expect(cleaner.Clean(ctx, c, &cm1)).To(Succeed()) ++ }) ++ ++ It("should succeed if no match error occurs for target object", func() { ++ var ( ++ ctx = context.TODO() ++ cleaner = NewCleaner(timeOps, NewFinalizer()) ++ ) ++ ++ c.EXPECT().Get(ctx, cm1Key, &cm1).Return(&meta.NoResourceMatchError{PartialResource: schema.GroupVersionResource{}}) ++ ++ Expect(cleaner.Clean(ctx, c, &cm1)).To(Succeed()) ++ }) ++ + It("should delete all objects matching the selector", func() { + var ( + ctx = context.TODO() +@@ -124,6 +146,30 @@ var _ = Describe("Cleaner", func() { + Expect(cleaner.Clean(ctx, c, list)).To(Succeed()) + }) + ++ It("should succeed if not found error occurs for list type", func() { ++ var ( ++ ctx = context.TODO() ++ list = &corev1.ConfigMapList{} ++ cleaner = NewCleaner(timeOps, NewFinalizer()) ++ ) ++ ++ c.EXPECT().List(ctx, list).Return(apierrors.NewNotFound(schema.GroupResource{}, "")) ++ ++ Expect(cleaner.Clean(ctx, c, list)).To(Succeed()) ++ }) ++ ++ It("should succeed if no match error occurs for list type", func() { ++ var ( ++ ctx = context.TODO() ++ list = &corev1.ConfigMapList{} ++ cleaner = NewCleaner(timeOps, NewFinalizer()) ++ ) ++ ++ c.EXPECT().List(ctx, list).Return(&meta.NoResourceMatchError{PartialResource: schema.GroupVersionResource{}}) ++ ++ Expect(cleaner.Clean(ctx, c, list)).To(Succeed()) ++ }) ++ + It("should finalize the object if its deletion timestamp is over the finalize grace period", func() { + var ( + ctx = context.TODO() +@@ -428,7 +474,7 @@ var _ = Describe("Cleaner", func() { + }) + + Describe("#EnsureGone", func() { +- It("should ensure that the object is gone", func() { ++ It("should ensure that the object is gone when not found error occurs", func() { + ctx := context.TODO() + + c.EXPECT().Get(ctx, cm1Key, &cm1).Return(apierrors.NewNotFound(schema.GroupResource{}, "")) +@@ -436,6 +482,14 @@ var _ = Describe("Cleaner", func() { + Expect(EnsureGone(ctx, c, &cm1)).To(Succeed()) + }) + ++ It("should ensure that the object is gone when no match error occurs", func() { ++ ctx := context.TODO() ++ ++ c.EXPECT().Get(ctx, cm1Key, &cm1).Return(&meta.NoResourceMatchError{PartialResource: schema.GroupVersionResource{}}) ++ ++ Expect(EnsureGone(ctx, c, &cm1)).To(Succeed()) ++ }) ++ + It("should ensure that the list is gone", func() { + var ( + ctx = context.TODO() +@@ -447,6 +501,28 @@ var _ = Describe("Cleaner", func() { + Expect(EnsureGone(ctx, c, &list)).To(Succeed()) + }) + ++ It("should ensure that the list is gone when not found error occurs", func() { ++ var ( ++ ctx = context.TODO() ++ list = corev1.ConfigMapList{} ++ ) ++ ++ c.EXPECT().List(ctx, &list).Return(apierrors.NewNotFound(schema.GroupResource{}, "")) ++ ++ Expect(EnsureGone(ctx, c, &list)).To(Succeed()) ++ }) ++ ++ It("should ensure that the list is gone when no match error occurs", func() { ++ var ( ++ ctx = context.TODO() ++ list = corev1.ConfigMapList{} ++ ) ++ ++ c.EXPECT().List(ctx, &list).Return(&meta.NoResourceMatchError{PartialResource: schema.GroupVersionResource{}}) ++ ++ Expect(EnsureGone(ctx, c, &list)).To(Succeed()) ++ }) ++ + It("should error that the object is still present", func() { + ctx := context.TODO() + +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,4 @@ ++H4sIAAAAAAAAA+3SMW7DIBTGcc85xbuAjbECnjr1Ctmj2EapFQcqG3L+Ug9tVanNkqiq8v8tPPFA ++gD6qLo3TsHf+oop7qbPWmHXMvo9rrU2jm62xTWOLWmtb20LM3W70RVriYRYp5hDib+uu9f+p6jP/ ++6Ja478P5fPBDtbzc7oxr+WvdfuSv2zbnv7X5G0h9uyv87MHz7wdZg+/csDkGeS+lUq+no0pxnBZ1 ++Sp2bvcvzqp9G56OSsg/Jxyct5UXKOXnZ5U3Pa3Pz188BAAAAAAAAAAAAAAAAHsobo60yYwAoAAA= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-001236/tests/test.sh b/tasks/format-code-task-001236/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..a167c7b51a7afe63aac11fb230c993e95fe0c4cf --- /dev/null +++ b/tasks/format-code-task-001236/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +pkg/utils/kubernetes/client/client_test.go +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001236/tests/test_command.sh b/tasks/format-code-task-001236/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001236/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001238/environment/Dockerfile b/tasks/format-code-task-001238/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..033f00e2cea2c250fc1f186d2f8ee2a587a6ecd5 --- /dev/null +++ b/tasks/format-code-task-001238/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:3bba56698d7259805d1125c29106d47bbbee0632bf7c5fe520e655675713abb7 diff --git a/tasks/format-code-task-001238/environment/setup/files/blocklist b/tasks/format-code-task-001238/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001238/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001238/environment/setup/setup.sh b/tasks/format-code-task-001238/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001238/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001238/tests/test.patch b/tasks/format-code-task-001238/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..da9a18a29d66917a8fc4eb3555855ff4d2f9428b --- /dev/null +++ b/tasks/format-code-task-001238/tests/test.patch @@ -0,0 +1,267 @@ +diff --git a/usercase-test-coderl/translator_acceptance_test.go b/usercase-test-coderl/translator_acceptance_test.go +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/translator_acceptance_test.go +@@ -0,0 +1,239 @@ ++ ++ ++ ++ ++ ++ ++package usercase_test_coderl ++ ++import ( ++ "os" ++ "path/filepath" ++ "reflect" ++ "sort" ++ "strings" ++ "testing" ++ ++ "github.com/GaruGaru/ciak/pkg/media/translator" ++) ++ ++func TestTranslateTorrentStyleFilenameStopsAtYear(t *testing.T) { ++ ++ ++ input := "Godzilla.2014.720p.BluRay.x264-LEONARDO_[scarabey.org].mkv" ++ ++ actual := translator.Translate(input) ++ ++ if actual != "Godzilla" { ++ t.Fatalf("Translate(%q) = %q, want %q", input, actual, "Godzilla") ++ } ++} ++ ++func TestTranslateSpaceSeparatedNameStopsAtYear(t *testing.T) { ++ ++ ++ input := "Godzilla 2014" ++ ++ actual := translator.Translate(input) ++ ++ if actual != "Godzilla" { ++ t.Fatalf("Translate(%q) = %q, want %q", input, actual, "Godzilla") ++ } ++} ++ ++func TestTranslatePlainTitleWithoutYearRemovesGroupAndTokens(t *testing.T) { ++ ++ ++ input := "[Group]Plain.Title.1080p.mkv" ++ ++ actual := translator.Translate(input) ++ ++ if actual != "Plain Title" { ++ t.Fatalf("Translate(%q) = %q, want %q", input, actual, "Plain Title") ++ } ++} ++ ++func TestTranslateEpisodeMarkerStopsTitle(t *testing.T) { ++ ++ ++ input := "Example.Show.S02E03.1080p.mkv" ++ ++ actual := translator.Translate(input) ++ ++ if actual != "Example Show" { ++ t.Fatalf("Translate(%q) = %q, want %q", input, actual, "Example Show") ++ } ++} ++ ++func TestTranslateEmptyString(t *testing.T) { ++ ++ ++ input := "" ++ ++ actual := translator.Translate(input) ++ ++ if actual != "" { ++ t.Fatalf("Translate(%q) = %q, want %q", input, actual, "") ++ } ++} ++ ++func TestTranslateNoMarkerKeepsCleanedTitle(t *testing.T) { ++ ++ ++ input := "Plain.Title.Without.Marker.avi" ++ ++ actual := translator.Translate(input) ++ ++ if actual != "Plain Title Without Marker" { ++ t.Fatalf("Translate(%q) = %q, want %q", input, actual, "Plain Title Without Marker") ++ } ++} ++ ++func TestTranslateBracketParenthesesAndMp4Removal(t *testing.T) { ++ ++ ++ input := "[ABC]Movie(Name).mp4" ++ ++ actual := translator.Translate(input) ++ ++ if actual != "MovieName" { ++ t.Fatalf("Translate(%q) = %q, want %q", input, actual, "MovieName") ++ } ++} ++ ++func TestTranslateRemovesAllDeclaredTokens(t *testing.T) { ++ ++ ++ ++ input := "Only.720p.1080p.x264.BluRay.mkv.avi.mp4.().Tokens" ++ ++ actual := translator.Translate(input) ++ ++ ++ if !reflect.DeepEqual(strings.Fields(actual), []string{"Only", "Tokens"}) { ++ t.Fatalf("Translate(%q) fields = %q, want title words %q", input, strings.Fields(actual), []string{"Only", "Tokens"}) ++ } ++ if actual != strings.TrimSpace(actual) { ++ t.Fatalf("Translate(%q) = %q, want surrounding whitespace trimmed", input, actual) ++ } ++ for _, token := range []string{"720p", "1080p", "x264", "BluRay", "mkv", "avi", "mp4", "(", ")"} { ++ if strings.Contains(actual, token) { ++ t.Fatalf("Translate(%q) = %q, still contains removed token %q", input, actual, token) ++ } ++ } ++} ++ ++func TestTranslateTrimsWhitespaceAfterCleanup(t *testing.T) { ++ ++ ++ input := " Leading.And.Trailing.1080p " ++ ++ actual := translator.Translate(input) ++ ++ if actual != "Leading And Trailing" { ++ t.Fatalf("Translate(%q) = %q, want %q", input, actual, "Leading And Trailing") ++ } ++} ++ ++func TestTranslateIsReferentiallyTransparentForSameInput(t *testing.T) { ++ input := "Example.Show.S02E03.1080p.mkv" ++ ++ first := translator.Translate(input) ++ second := translator.Translate(input) ++ ++ if first != "Example Show" { ++ t.Fatalf("first Translate(%q) = %q, want %q", input, first, "Example Show") ++ } ++ if second != first { ++ t.Fatalf("second Translate(%q) = %q, want same value %q", input, second, first) ++ } ++} ++ ++func TestTranslateDoesNotMutateCallerInput(t *testing.T) { ++ input := "Plain.Title.Without.Marker.avi" ++ before := string([]byte(input)) ++ ++ actual := translator.Translate(input) ++ ++ if actual != "Plain Title Without Marker" { ++ t.Fatalf("Translate(%q) = %q, want %q", input, actual, "Plain Title Without Marker") ++ } ++ if input != before { ++ t.Fatalf("Translate mutated caller input: got %q, want %q", input, before) ++ } ++} ++ ++func TestTranslateHasNoCallOrderState(t *testing.T) { ++ input := "[Group]Plain.Title.1080p.mkv" ++ ++ first := translator.Translate(input) ++ _ = translator.Translate("Godzilla.2014.720p.BluRay.x264-LEONARDO_[scarabey.org].mkv") ++ _ = translator.Translate("") ++ _ = translator.Translate("Example.Show.S02E03.1080p.mkv") ++ second := translator.Translate(input) ++ ++ if first != "Plain Title" { ++ t.Fatalf("first Translate(%q) = %q, want %q", input, first, "Plain Title") ++ } ++ if second != "Plain Title" { ++ t.Fatalf("Translate(%q) after other calls = %q, want %q", input, second, "Plain Title") ++ } ++} ++ ++func TestTranslateDoesNotWriteToCurrentDirectory(t *testing.T) { ++ originalCwd, err := os.Getwd() ++ if err != nil { ++ t.Fatalf("Getwd failed: %v", err) ++ } ++ tmp := t.TempDir() ++ if err := os.Chdir(tmp); err != nil { ++ t.Fatalf("Chdir(%q) failed: %v", tmp, err) ++ } ++ defer func() { ++ if err := os.Chdir(originalCwd); err != nil { ++ t.Fatalf("restoring cwd failed: %v", err) ++ } ++ }() ++ ++ before, err := snapshotRelativePaths(tmp) ++ if err != nil { ++ t.Fatalf("snapshot before Translate failed: %v", err) ++ } ++ ++ actual := translator.Translate("[Group]Plain.Title.1080p.mkv") ++ ++ after, err := snapshotRelativePaths(tmp) ++ if err != nil { ++ t.Fatalf("snapshot after Translate failed: %v", err) ++ } ++ if actual != "Plain Title" { ++ t.Fatalf("Translate side-effect fixture = %q, want %q", actual, "Plain Title") ++ } ++ if !reflect.DeepEqual(after, before) { ++ t.Fatalf("Translate changed cwd contents: before=%v after=%v", before, after) ++ } ++} ++ ++func snapshotRelativePaths(root string) ([]string, error) { ++ var paths []string ++ err := filepath.Walk(root, func(path string, info os.FileInfo, walkErr error) error { ++ if walkErr != nil { ++ return walkErr ++ } ++ if path == root { ++ return nil ++ } ++ rel, err := filepath.Rel(root, path) ++ if err != nil { ++ return err ++ } ++ if info.IsDir() { ++ paths = append(paths, rel+"/") ++ return nil ++ } ++ paths = append(paths, rel) ++ return nil ++ }) ++ sort.Strings(paths) ++ return paths, err ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,18 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++export GOPROXY=off ++export GOSUMDB=off ++export GOVCS='*:off' ++exec go test -v ./usercase-test-coderl/... diff --git a/tasks/format-code-task-001238/tests/test.sh b/tasks/format-code-task-001238/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..e84589f324b32f138aaa335670abffdd9ee2f58a --- /dev/null +++ b/tasks/format-code-task-001238/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/translator_acceptance_test.go +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001238/tests/test_command.sh b/tasks/format-code-task-001238/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001238/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001310/environment/Dockerfile b/tasks/format-code-task-001310/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..20030ca90c7149cf7df7c8a4c972800041843fa6 --- /dev/null +++ b/tasks/format-code-task-001310/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:f38be887f3b18828aa31ef590c6cd8df3964ae6700d067d1c94cabb3bf867fdc diff --git a/tasks/format-code-task-001310/environment/setup/files/blocklist b/tasks/format-code-task-001310/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001310/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001310/environment/setup/setup.sh b/tasks/format-code-task-001310/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001310/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001310/tests/test.patch b/tasks/format-code-task-001310/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..c80530476923cebb266eca7e92aff7602f5777ff --- /dev/null +++ b/tasks/format-code-task-001310/tests/test.patch @@ -0,0 +1,106 @@ +diff --git a/mold_test.go b/mold_test.go +index b3988e4..a79d400 100644 +--- a/mold_test.go ++++ b/mold_test.go +@@ -601,3 +601,81 @@ func TestDiveKeys(t *testing.T) { + err = set.Field(context.Background(), &m, "dive,keys,default,endkeys,err") + NotEqual(t, err, nil) + } ++ ++func TestStructArray(t *testing.T) { ++ type InnerStruct struct { ++ String string `s:"defaultStr"` ++ } ++ ++ type Test struct { ++ Inner InnerStruct ++ Arr []InnerStruct `s:"defaultArr"` ++ ArrDive []InnerStruct `s:"defaultArr,dive"` ++ ArrNoTag []InnerStruct ++ } ++ ++ set := New() ++ set.SetTagName("s") ++ set.Register("defaultArr", func(ctx context.Context, t *Transformer, value reflect.Value, param string) error { ++ if HasValue(value) { ++ return nil ++ } ++ value.Set(reflect.MakeSlice(value.Type(), 2, 2)) ++ return nil ++ }) ++ set.Register("defaultStr", func(ctx context.Context, t *Transformer, value reflect.Value, param string) error { ++ if value.String() == "ok" { ++ return errors.New("ALREADY OK") ++ } ++ value.SetString("default") ++ return nil ++ }) ++ ++ var tt Test ++ ++ err := set.Struct(context.Background(), &tt) ++ Equal(t, err, nil) ++ Equal(t, len(tt.Arr), 2) ++ Equal(t, len(tt.ArrDive), 2) ++ Equal(t, tt.Arr[0].String, "") ++ Equal(t, tt.Arr[1].String, "") ++ Equal(t, tt.ArrDive[0].String, "default") ++ Equal(t, tt.ArrDive[1].String, "default") ++ ++ Equal(t, tt.Inner.String, "default") ++ ++ tt2 := Test{ ++ Arr: make([]InnerStruct, 1), ++ } ++ ++ err = set.Struct(context.Background(), &tt2) ++ Equal(t, err, nil) ++ Equal(t, len(tt2.Arr), 1) ++ Equal(t, tt2.Arr[0].String, "") ++ ++ tt3 := Test{ ++ Arr: []InnerStruct{{"ok"}}, ++ } ++ ++ err = set.Struct(context.Background(), &tt3) ++ Equal(t, err, nil) ++ Equal(t, len(tt3.Arr), 1) ++ Equal(t, tt3.Arr[0].String, "ok") ++ ++ tt4 := Test{ ++ ArrDive: []InnerStruct{{"ok"}}, ++ } ++ ++ err = set.Struct(context.Background(), &tt4) ++ NotEqual(t, err, nil) ++ Equal(t, err.Error(), "ALREADY OK") ++ ++ tt5 := Test{ ++ ArrNoTag: make([]InnerStruct, 1), ++ } ++ ++ err = set.Struct(context.Background(), &tt5) ++ Equal(t, err, nil) ++ Equal(t, len(tt5.ArrNoTag), 1) ++ Equal(t, tt5.ArrNoTag[0].String, "") ++} +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,4 @@ ++H4sIAAAAAAAAA+3RTQrCMBCG4a57irlAYxNsu/YMupf+oYK2kKaCtzcWpCJoNxUR32czk2QgA58q +++sOx2tbNeRF8SuxlSTJU77kOvU6M1pnxY/5e6zROA0k+ttGDvnO5FQls27p3c1PvP0qN+bu6c9uy ++PZ3yplLdfr4/JvNPzZi/MT7/ZaqzQOL5Vnjtz/MvKxmCL+oq3LVyayU6S2T7Rjb+sHa2L93K2vwi ++aqGUCr+9MQAAAAAAAAAAAAAAAIC7K4SroCwAKAAA +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-001310/tests/test.sh b/tasks/format-code-task-001310/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..15748950b11c6362e5f78f71776f19170ab91a00 --- /dev/null +++ b/tasks/format-code-task-001310/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +mold_test.go +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001310/tests/test_command.sh b/tasks/format-code-task-001310/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001310/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001317/environment/Dockerfile b/tasks/format-code-task-001317/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..cd1968691a10537a993e87b012cdf9aaa27fb202 --- /dev/null +++ b/tasks/format-code-task-001317/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:04ec2344165843707e95df2b24928566de64262975dbd2c3f8d7a7a22af97b28 diff --git a/tasks/format-code-task-001317/environment/setup/files/blocklist b/tasks/format-code-task-001317/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001317/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001317/environment/setup/setup.sh b/tasks/format-code-task-001317/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001317/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001317/tests/test.patch b/tasks/format-code-task-001317/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..701308a67e3f0100f9aee5a12bc6774a3c196ae4 --- /dev/null +++ b/tasks/format-code-task-001317/tests/test.patch @@ -0,0 +1,370 @@ +diff --git a/usercase-test-coderl/compile_to_instructions_test.go b/usercase-test-coderl/compile_to_instructions_test.go +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/compile_to_instructions_test.go +@@ -0,0 +1,342 @@ ++package usercase_test_coderl ++ ++import ( ++ "fmt" ++ "os" ++ "reflect" ++ "sort" ++ "strings" ++ "testing" ++ ++ "github.com/goby-lang/goby/compiler" ++ "github.com/goby-lang/goby/compiler/bytecode" ++ "github.com/goby-lang/goby/compiler/parser" ++) ++ ++ ++ ++ ++ ++ ++type instructionSummary struct { ++ Action string ++ Opcode uint8 ++ SourceLine int ++ Params []string ++} ++ ++type instructionSetSummary struct { ++ Name string ++ Type string ++ Instructions []instructionSummary ++} ++ ++type expectedInstruction struct { ++ Action string ++ SourceLine int ++ ParamPrefix []string ++ ExactParams bool ++} ++ ++func summarizeInstructionSets(t *testing.T, sets []*bytecode.InstructionSet) []instructionSetSummary { ++ t.Helper() ++ ++ out := make([]instructionSetSummary, len(sets)) ++ for setIndex, set := range sets { ++ out[setIndex] = instructionSetSummary{ ++ Name: set.Name(), ++ Type: set.Type(), ++ Instructions: make([]instructionSummary, len(set.Instructions)), ++ } ++ ++ for instructionIndex, instruction := range set.Instructions { ++ params := make([]string, len(instruction.Params)) ++ for paramIndex, param := range instruction.Params { ++ params[paramIndex] = summarizeParam(param) ++ } ++ ++ out[setIndex].Instructions[instructionIndex] = instructionSummary{ ++ Action: instruction.ActionName(), ++ Opcode: instruction.Opcode, ++ SourceLine: instruction.SourceLine(), ++ Params: params, ++ } ++ } ++ } ++ ++ return out ++} ++ ++func summarizeParam(param interface{}) string { ++ switch value := param.(type) { ++ case *bytecode.ArgSet: ++ return fmt.Sprintf("ArgSet(names=%v,types=%v)", value.Names(), value.Types()) ++ default: ++ return fmt.Sprintf("%T:%v", param, param) ++ } ++} ++ ++func requireCompiledSummary(t *testing.T, input string, mode parser.Mode) []instructionSetSummary { ++ t.Helper() ++ ++ actualSets, err := compiler.CompileToInstructions(input, mode) ++ if err != nil { ++ t.Fatalf("CompileToInstructions returned error: %v", err) ++ } ++ ++ return summarizeInstructionSets(t, actualSets) ++} ++ ++func requireInstructionSet(t *testing.T, sets []instructionSetSummary, name, setType string) instructionSetSummary { ++ t.Helper() ++ ++ for _, set := range sets { ++ if set.Name == name && set.Type == setType { ++ return set ++ } ++ } ++ t.Fatalf("expected instruction set %q/%q in %#v", name, setType, sets) ++ return instructionSetSummary{} ++} ++ ++func assertInstructionPrefix(t *testing.T, got []instructionSummary, expected []expectedInstruction) { ++ t.Helper() ++ ++ if len(got) < len(expected) { ++ t.Fatalf("expected at least %d instructions, got %#v", len(expected), got) ++ } ++ for i, want := range expected { ++ assertInstruction(t, i, got[i], want) ++ } ++} ++ ++func assertInstruction(t *testing.T, index int, got instructionSummary, want expectedInstruction) { ++ t.Helper() ++ ++ if got.Action != want.Action { ++ t.Fatalf("instruction %d action: expected %q, got %#v", index, want.Action, got) ++ } ++ if want.SourceLine > 0 && got.SourceLine != want.SourceLine { ++ t.Fatalf("instruction %d source line: expected %d, got %#v", index, want.SourceLine, got) ++ } ++ if len(got.Params) < len(want.ParamPrefix) { ++ t.Fatalf("instruction %d params: expected prefix %#v, got %#v", index, want.ParamPrefix, got.Params) ++ } ++ for paramIndex, wantParam := range want.ParamPrefix { ++ if got.Params[paramIndex] != wantParam { ++ t.Fatalf("instruction %d param %d: expected %q, got %#v", index, paramIndex, wantParam, got.Params) ++ } ++ } ++ if want.ExactParams && len(got.Params) != len(want.ParamPrefix) { ++ t.Fatalf("instruction %d params: expected exactly %#v, got %#v", index, want.ParamPrefix, got.Params) ++ } ++} ++ ++func assertNormalArithmeticInstructions(t *testing.T) { ++ t.Helper() ++ ++ actual := requireCompiledSummary(t, "1 + 2", parser.NormalMode) ++ if len(actual) != 1 { ++ t.Fatalf("expected one instruction set, got %#v", actual) ++ } ++ program := requireInstructionSet(t, actual, "ProgramStart", "ProgramStart") ++ ++ assertInstructionPrefix(t, program.Instructions, []expectedInstruction{ ++ {Action: "putobject", SourceLine: 1, ParamPrefix: []string{"int:1"}, ExactParams: true}, ++ {Action: "putobject", SourceLine: 1, ParamPrefix: []string{"int:2"}, ExactParams: true}, ++ {Action: "send", SourceLine: 1, ParamPrefix: []string{"string:+"}}, ++ {Action: "pop", SourceLine: 1, ParamPrefix: []string{}, ExactParams: true}, ++ {Action: "leave", SourceLine: 1, ParamPrefix: []string{}, ExactParams: true}, ++ }) ++} ++ ++func assertTestModeModuleInstructions(t *testing.T) { ++ t.Helper() ++ ++ actual := requireCompiledSummary(t, "module Foo\nend\n", parser.TestMode) ++ if len(actual) != 2 { ++ t.Fatalf("expected module and ProgramStart instruction sets, got %#v", actual) ++ } ++ ++ module := requireInstructionSet(t, actual, "Foo", "DefClass") ++ ++ assertInstructionPrefix(t, module.Instructions, []expectedInstruction{ ++ {Action: "leave", ParamPrefix: []string{}, ExactParams: true}, ++ }) ++ ++ program := requireInstructionSet(t, actual, "ProgramStart", "ProgramStart") ++ ++ assertInstructionPrefix(t, program.Instructions, []expectedInstruction{ ++ {Action: "putself", ParamPrefix: []string{}, ExactParams: true}, ++ {Action: "def_class", ParamPrefix: []string{"string:module:Foo"}, ExactParams: true}, ++ {Action: "pop", ParamPrefix: []string{}, ExactParams: true}, ++ {Action: "leave", ParamPrefix: []string{}, ExactParams: true}, ++ }) ++} ++ ++func assertMethodDefinitionInstructions(t *testing.T) { ++ t.Helper() ++ ++ actual := requireCompiledSummary(t, "def bar(a)\n 99 + a\nend\n", parser.NormalMode) ++ if len(actual) != 2 { ++ t.Fatalf("expected method and ProgramStart instruction sets, got %#v", actual) ++ } ++ ++ method := requireInstructionSet(t, actual, "bar", "Def") ++ ++ assertInstructionPrefix(t, method.Instructions, []expectedInstruction{ ++ {Action: "putobject", ParamPrefix: []string{"int:99"}, ExactParams: true}, ++ {Action: "getlocal"}, ++ {Action: "send", ParamPrefix: []string{"string:+"}}, ++ {Action: "leave", ParamPrefix: []string{}, ExactParams: true}, ++ }) ++ ++ program := requireInstructionSet(t, actual, "ProgramStart", "ProgramStart") ++ ++ assertInstructionPrefix(t, program.Instructions, []expectedInstruction{ ++ {Action: "putself", ParamPrefix: []string{}, ExactParams: true}, ++ {Action: "putstring", ParamPrefix: []string{"string:bar"}, ExactParams: true}, ++ {Action: "def_method", ParamPrefix: []string{"int:1"}, ExactParams: true}, ++ {Action: "leave", ParamPrefix: []string{}, ExactParams: true}, ++ }) ++} ++ ++func assertREPLCallInstructions(t *testing.T) { ++ t.Helper() ++ ++ actual := requireCompiledSummary(t, "puts(1)\n", parser.REPLMode) ++ if len(actual) != 1 { ++ t.Fatalf("expected one ProgramStart instruction set, got %#v", actual) ++ } ++ ++ program := requireInstructionSet(t, actual, "ProgramStart", "ProgramStart") ++ ++ assertInstructionPrefix(t, program.Instructions, []expectedInstruction{ ++ {Action: "putself", ParamPrefix: []string{}, ExactParams: true}, ++ {Action: "putobject", ParamPrefix: []string{"int:1"}, ExactParams: true}, ++ {Action: "send", ParamPrefix: []string{"string:puts", "int:1"}}, ++ {Action: "leave", ParamPrefix: []string{}, ExactParams: true}, ++ }) ++} ++ ++func TestNormalModeArithmeticExpressionInstructions(t *testing.T) { ++ ++ ++ assertNormalArithmeticInstructions(t) ++} ++ ++func TestTestModeModuleProducesModuleAndProgramInstructionSets(t *testing.T) { ++ ++ ++ assertTestModeModuleInstructions(t) ++} ++ ++func TestNormalModeMethodDefinitionUsesFreshGeneratorInstructionSets(t *testing.T) { ++ ++ ++ assertMethodDefinitionInstructions(t) ++} ++ ++func TestREPLModeCallExpressionLeavesResultWithoutPop(t *testing.T) { ++ ++ ++ assertREPLCallInstructions(t) ++} ++ ++func TestMalformedREPLInputReturnsParserMessageAndNoInstructionSets(t *testing.T) { ++ ++ ++ sets, err := compiler.CompileToInstructions("iff\nend\n", parser.REPLMode) ++ if err == nil { ++ t.Fatal("expected an error") ++ } ++ ++ if err.Error() == "" || !strings.Contains(err.Error(), "unexpected end") || !strings.Contains(err.Error(), "Line: 1") { ++ t.Fatalf("unexpected error message: %q", err.Error()) ++ } ++ if sets != nil { ++ t.Fatalf("expected nil instruction sets on parse error, got %#v", summarizeInstructionSets(t, sets)) ++ } ++} ++ ++func TestCompileToInstructionsIsReferentiallyTransparent(t *testing.T) { ++ input := "1 + 2" ++ ++ first, err := compiler.CompileToInstructions(input, parser.NormalMode) ++ if err != nil { ++ t.Fatalf("first call failed: %v", err) ++ } ++ second, err := compiler.CompileToInstructions(input, parser.NormalMode) ++ if err != nil { ++ t.Fatalf("second call failed: %v", err) ++ } ++ ++ firstSummary := summarizeInstructionSets(t, first) ++ secondSummary := summarizeInstructionSets(t, second) ++ if !reflect.DeepEqual(firstSummary, secondSummary) { ++ t.Fatalf("same input and mode produced different instruction data\nfirst: %#v\nsecond: %#v", firstSummary, secondSummary) ++ } ++} ++ ++func TestCompileToInstructionsDoesNotMutateInputString(t *testing.T) { ++ input := "module Foo\nend\n" ++ before := string([]byte(input)) ++ ++ if _, err := compiler.CompileToInstructions(input, parser.TestMode); err != nil { ++ t.Fatalf("compile failed: %v", err) ++ } ++ ++ if input != before { ++ t.Fatalf("input string mutated: before %q after %q", before, input) ++ } ++} ++ ++func TestCompileToInstructionsDoesNotDependOnHiddenInProcessState(t *testing.T) { ++ ++ assertNormalArithmeticInstructions(t) ++ assertTestModeModuleInstructions(t) ++ assertREPLCallInstructions(t) ++ assertNormalArithmeticInstructions(t) ++} ++ ++func TestCompileToInstructionsDoesNotWriteFilesInWorkingDirectory(t *testing.T) { ++ tmpDir := t.TempDir() ++ previousDir, err := os.Getwd() ++ if err != nil { ++ t.Fatalf("getwd failed: %v", err) ++ } ++ if err := os.Chdir(tmpDir); err != nil { ++ t.Fatalf("chdir to temp dir failed: %v", err) ++ } ++ defer func() { ++ if err := os.Chdir(previousDir); err != nil { ++ t.Fatalf("restore working directory failed: %v", err) ++ } ++ }() ++ ++ before := directoryEntries(t, tmpDir) ++ if _, err := compiler.CompileToInstructions("1 + 2", parser.NormalMode); err != nil { ++ t.Fatalf("compile failed: %v", err) ++ } ++ after := directoryEntries(t, tmpDir) ++ ++ if !reflect.DeepEqual(before, after) { ++ t.Fatalf("working directory changed\nbefore: %#v\nafter: %#v", before, after) ++ } ++} ++ ++func directoryEntries(t *testing.T, path string) []string { ++ t.Helper() ++ ++ entries, err := os.ReadDir(path) ++ if err != nil { ++ t.Fatalf("ReadDir(%q) failed: %v", path, err) ++ } ++ ++ names := make([]string, len(entries)) ++ for i, entry := range entries { ++ names[i] = entry.Name() ++ } ++ sort.Strings(names) ++ return names ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,18 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo ++export GOPROXY=off ++export GOSUMDB=off ++export GOTOOLCHAIN=local ++export GOFLAGS="${GOFLAGS:-} -mod=readonly" ++exec go test -v ./usercase-test-coderl/... diff --git a/tasks/format-code-task-001317/tests/test.sh b/tasks/format-code-task-001317/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..61b5fcdf8906418c2e46d7a34e9b5251d704d6ad --- /dev/null +++ b/tasks/format-code-task-001317/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/compile_to_instructions_test.go +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001317/tests/test_command.sh b/tasks/format-code-task-001317/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001317/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001343/environment/Dockerfile b/tasks/format-code-task-001343/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8f094306ed1831f19bd7af602439ff6c61a453fe --- /dev/null +++ b/tasks/format-code-task-001343/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:00b4bf750bdf03e65d10c69f7ac40dd33a176ea6e104b34a77f0080d3151bd89 diff --git a/tasks/format-code-task-001343/environment/setup/files/blocklist b/tasks/format-code-task-001343/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001343/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001343/environment/setup/setup.sh b/tasks/format-code-task-001343/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001343/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001343/tests/test.patch b/tasks/format-code-task-001343/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e2915ffd4bba252481b86a3f418384a6e06a3df0 --- /dev/null +++ b/tasks/format-code-task-001343/tests/test.patch @@ -0,0 +1,210 @@ +diff --git a/tests/docs_update_test.py b/tests/docs_update_test.py +new file mode 100644 +index 00000000..2cc3c88c +--- /dev/null ++++ b/tests/docs_update_test.py +@@ -0,0 +1,99 @@ ++import ast ++import pathlib ++ ++from absl.testing import absltest ++ ++ ++class DocsUpdateTest(absltest.TestCase): ++ ++ def _read_doc(self, relative_path): ++ repo_root = pathlib.Path(__file__).resolve().parents[1] ++ return (repo_root / relative_path).read_text(encoding='utf-8') ++ ++ def _rst_code_blocks(self, text, directives=('.. testcode::',)): ++ lines = text.splitlines() ++ blocks = [] ++ i = 0 ++ while i < len(lines): ++ if lines[i].strip() not in directives: ++ i += 1 ++ continue ++ i += 1 ++ while i < len(lines) and not lines[i].strip(): ++ i += 1 ++ block = [] ++ while i < len(lines) and (not lines[i].strip() or lines[i].startswith(' ')): ++ block.append(lines[i][2:] if lines[i].startswith(' ') else '') ++ i += 1 ++ blocks.append('\n'.join(block)) ++ return blocks ++ ++ def _call_names(self, code): ++ names = set() ++ for node in ast.walk(ast.parse(code)): ++ if not isinstance(node, ast.Call): ++ continue ++ func = node.func ++ if isinstance(func, ast.Attribute): ++ if isinstance(func.value, ast.Name): ++ names.add('%s.%s' % (func.value.id, func.attr)) ++ names.add(func.attr) ++ elif isinstance(func, ast.Name): ++ names.add(func.id) ++ return names ++ ++ def test_model_surgery_uses_separator_traversal(self): ++ blocks = self._rst_code_blocks(self._read_doc('docs/howtos/model_surgery.rst')) ++ separator_calls = [] ++ manual_path_conversions = [] ++ for block in blocks: ++ tree = ast.parse(block) ++ for node in ast.walk(tree): ++ if not isinstance(node, ast.Call): ++ continue ++ func = node.func ++ attr = func.attr if isinstance(func, ast.Attribute) else '' ++ if attr in ('flatten_dict', 'unflatten_dict'): ++ if any(keyword.arg == 'sep' for keyword in node.keywords): ++ separator_calls.append(attr) ++ if attr in ('join', 'split'): ++ manual_path_conversions.append(attr) ++ ++ self.assertIn('flatten_dict', separator_calls) ++ self.assertIn('unflatten_dict', separator_calls) ++ self.assertEmpty(manual_path_conversions) ++ ++ def test_optimizer_docs_use_optax_not_flax_optim_recommendation(self): ++ for doc_path in ('docs/howtos/model_surgery.rst', ++ 'docs/howtos/state_params.rst'): ++ with self.subTest(doc_path=doc_path): ++ doc = self._read_doc(doc_path) ++ blocks = self._rst_code_blocks( ++ doc, directives=('.. testsetup::', '.. testcode::')) ++ imported_modules = set() ++ imported_from_flax = set() ++ calls = set() ++ for block in blocks: ++ tree = ast.parse(block) ++ calls.update(self._call_names(block)) ++ for node in ast.walk(tree): ++ if isinstance(node, ast.Import): ++ imported_modules.update(alias.name for alias in node.names) ++ elif isinstance(node, ast.ImportFrom) and node.module == 'flax': ++ imported_from_flax.update(alias.name for alias in node.names) ++ ++ self.assertIn('optax', imported_modules) ++ self.assertIn('init', calls) ++ self.assertNotIn('optim', imported_from_flax) ++ self.assertNotIn('apply_gradient', calls) ++ self.assertNotIn('create', calls) ++ ++ for doc_path in ('README.md', 'docs/overview.md'): ++ with self.subTest(doc_path=doc_path): ++ for line in self._read_doc(doc_path).splitlines(): ++ if '**Optimizers**' in line: ++ self.assertNotIn('flax.optim', line) ++ ++ ++if __name__ == '__main__': ++ absltest.main() +diff --git a/tests/traverse_util_test.py b/tests/traverse_util_test.py +index 8ac2b57d..5ea33e72 100644 +--- a/tests/traverse_util_test.py ++++ b/tests/traverse_util_test.py +@@ -151,6 +151,53 @@ class TraversalTest(absltest.TestCase): + ('bar', 'a'): 2, + }) + ++ def test_flatten_dict_sep_string_keys(self): ++ cases = ( ++ (('left',), 1, '/'), ++ (('outer', 'inner'), 2, '.'), ++ (('root', 'branch', 'leaf'), 3, ':'), ++ ) ++ for path, value, sep in cases: ++ with self.subTest(path=path, sep=sep): ++ nested = value ++ for key in reversed(path): ++ nested = {key: nested} ++ ++ flat = traverse_util.flatten_dict(nested, sep=sep) ++ ++ self.assertLen(flat, 1) ++ flat_key, flat_value = next(iter(flat.items())) ++ self.assertEqual(flat_value, value) ++ self.assertIsInstance(flat_key, str) ++ self.assertEqual(flat_key.split(sep), list(path)) ++ ++ nested = {'left': {'right': 4}} ++ tuple_key, = traverse_util.flatten_dict(nested).keys() ++ self.assertEqual(tuple_key, ('left', 'right')) ++ ++ def test_unflatten_dict_sep_string_keys(self): ++ cases = ( ++ (('left',), 1, '/'), ++ (('outer', 'inner'), 2, '.'), ++ (('root', 'branch', 'leaf'), 3, ':'), ++ ) ++ for path, value, sep in cases: ++ with self.subTest(path=path, sep=sep): ++ flat_key = sep.join(path) ++ unflattened = traverse_util.unflatten_dict({flat_key: value}, sep=sep) ++ cursor = unflattened ++ for key in path[:-1]: ++ self.assertIsInstance(cursor, dict) ++ cursor = cursor[key] ++ self.assertEqual(cursor[path[-1]], value) ++ ++ round_trip = traverse_util.flatten_dict(unflattened, sep=sep) ++ self.assertEqual(round_trip, {flat_key: value}) ++ ++ self.assertEqual( ++ traverse_util.unflatten_dict({('left', 'right'): 4}), ++ {'left': {'right': 4}}) ++ + def test_unflatten_dict(self): + flat_xs = { + ('foo',): 1, +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,42 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++ ++set +u ++source /testbed/.build_env/.venv/bin/activate ++set -u ++ ++pip install -e /testbed --no-deps -q 2>/dev/null || true ++ ++LAXNUMPY=$(python -c "import jax._src.numpy.lax_numpy as m; print(m.__file__)") ++if ! grep -q "from jax._src.numpy.setops import isin" "$LAXNUMPY"; then ++ echo ' ++# Compatibility shim: isin was moved to jax._src.numpy.setops ++from jax._src.numpy.setops import isin ++' >> "$LAXNUMPY" ++fi ++ ++ ++case "${1:-}" in ++ base) ++ python -m pytest \ ++ tests/traverse_util_test.py::TraversalTest::test_flatten_dict \ ++ tests/traverse_util_test.py::TraversalTest::test_unflatten_dict \ ++ tests/traverse_util_test.py::TraversalTest::test_flatten_dict_keep_empty \ ++ tests/traverse_util_test.py::TraversalTest::test_flatten_dict_is_leaf \ ++ tests/traverse_util_test.py::ModelParamTraversalTest \ ++ -v -o "filterwarnings=" ++ ;; ++ new) ++ python -m pytest \ ++ tests/traverse_util_test.py::TraversalTest::test_flatten_dict_sep_string_keys \ ++ tests/traverse_util_test.py::TraversalTest::test_unflatten_dict_sep_string_keys \ ++ tests/docs_update_test.py \ ++ -v -o "filterwarnings=" ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-001343/tests/test.sh b/tasks/format-code-task-001343/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..1db95331343cd085f94a2913eda9f89be0baa227 --- /dev/null +++ b/tasks/format-code-task-001343/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/docs_update_test.py +tests/traverse_util_test.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001343/tests/test_command.sh b/tasks/format-code-task-001343/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-001343/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh base && bash /testbed/mimo_test_command.sh new \ No newline at end of file diff --git a/tasks/format-code-task-001372/environment/Dockerfile b/tasks/format-code-task-001372/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..be9cd96a94af4646098bbe5bd7ab6c0ea48235a7 --- /dev/null +++ b/tasks/format-code-task-001372/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:cb0ef531bd07202ca1edf5ac9768113723bbf85d926517926a9271e59e881791 diff --git a/tasks/format-code-task-001372/environment/setup/files/blocklist b/tasks/format-code-task-001372/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001372/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001372/environment/setup/setup.sh b/tasks/format-code-task-001372/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001372/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001372/tests/test.patch b/tasks/format-code-task-001372/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..189d6b0cb32b4558794fce32148c647388f43968 --- /dev/null +++ b/tasks/format-code-task-001372/tests/test.patch @@ -0,0 +1,191 @@ +diff --git a/tests/unit/core/test_pyformat_pandas.py b/tests/unit/core/test_pyformat_pandas.py +new file mode 100644 +index 00000000..b456147f +--- /dev/null ++++ b/tests/unit/core/test_pyformat_pandas.py +@@ -0,0 +1,148 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++from __future__ import annotations ++ ++import pandas ++import pytest ++ ++import bigframes.core.pyformat as pyformat ++ ++ ++def test_pyformat_dry_run_embeds_dataframe_as_empty_table_expression(): ++ df = pandas.DataFrame( ++ { ++ "int_col": [1, 2, 3], ++ "str_col": ["a", "b", "c"], ++ "float_col": [1.5, 2.5, 3.5], ++ "bool_col": [True, False, True], ++ } ++ ) ++ ++ got = pyformat.pyformat( ++ "SELECT * FROM {df}", ++ pyformat_args={"df": df}, ++ dry_run=True, ++ ) ++ ++ assert got == ( ++ "SELECT * FROM UNNEST(ARRAY>[])" ++ ) ++ ++ ++def test_pyformat_dry_run_preserves_column_order(): ++ df = pandas.DataFrame( ++ { ++ "z": [1], ++ "a": ["x"], ++ "m": [2.0], ++ } ++ ) ++ ++ got = pyformat.pyformat( ++ "{df}", ++ pyformat_args={"df": df}, ++ dry_run=True, ++ ) ++ ++ assert got == "UNNEST(ARRAY>[])" ++ ++ ++def test_pyformat_dry_run_handles_array_columns(): ++ df = pandas.DataFrame( ++ { ++ "id": [1, 2], ++ "values": [[1, 2], [3]], ++ } ++ ) ++ ++ got = pyformat.pyformat( ++ "SELECT * FROM {df}", ++ pyformat_args={"df": df}, ++ dry_run=True, ++ ) ++ ++ assert got == ( ++ "SELECT * FROM UNNEST(ARRAY" ++ ">>[])" ++ ) ++ ++ ++def test_pyformat_dry_run_widens_narrow_numeric_types(): ++ df = pandas.DataFrame( ++ { ++ "small_int": pandas.array([1, 2, 3], dtype="int32"), ++ "small_float": pandas.array([1.0, 2.0, 3.0], dtype="float32"), ++ } ++ ) ++ ++ got = pyformat.pyformat( ++ "SELECT * FROM {df}", ++ pyformat_args={"df": df}, ++ dry_run=True, ++ ) ++ ++ assert got == ( ++ "SELECT * FROM UNNEST(ARRAY>[])" ++ ) ++ ++ ++def test_pyformat_dry_run_ignores_dataframe_index(): ++ df = pandas.DataFrame( ++ {"col": [1, 2, 3]}, ++ index=pandas.Index(["r1", "r2", "r3"], name="my_index"), ++ ) ++ ++ got = pyformat.pyformat( ++ "SELECT * FROM {df}", ++ pyformat_args={"df": df}, ++ dry_run=True, ++ ) ++ ++ ++ assert got == "SELECT * FROM UNNEST(ARRAY>[])" ++ ++ ++def test_pyformat_without_session_and_not_dry_run_raises_valueerror(): ++ df = pandas.DataFrame({"a": [1, 2, 3]}) ++ ++ with pytest.raises(ValueError): ++ pyformat.pyformat( ++ "SELECT * FROM {df}", ++ pyformat_args={"df": df}, ++ ) ++ ++ ++def test_pyformat_unreferenced_dataframe_is_ignored(): ++ df = pandas.DataFrame({"a": [1, 2, 3]}) ++ ++ ++ ++ got = pyformat.pyformat( ++ "SELECT 1", ++ pyformat_args={"df": df}, ++ ) ++ assert got == "SELECT 1" +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,32 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++ ++ ++SITE_PKGS=/testbed/.venv/lib/python3.12/site-packages ++PYRUN=(python -c 'import site, sys; site.addsitedir("'"$SITE_PKGS"'"); import pytest; sys.exit(pytest.main(sys.argv[1:]))') ++ ++ ++ ++PYTEST_ARGS=(-q -o "filterwarnings=") ++ ++ ++"${PYRUN[@]}" \ ++ tests/unit/core/test_pyformat.py \ ++ tests/unit/test_local_data.py \ ++ tests/unit/core/test_dtypes.py \ ++ "${PYTEST_ARGS[@]}" ++ ++ ++"${PYRUN[@]}" \ ++ tests/unit/core/test_pyformat_pandas.py \ ++ "${PYTEST_ARGS[@]}" diff --git a/tasks/format-code-task-001372/tests/test.sh b/tasks/format-code-task-001372/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..613704ca64d94916b7f20f7875e45c388756ab61 --- /dev/null +++ b/tasks/format-code-task-001372/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/unit/core/test_pyformat_pandas.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001372/tests/test_command.sh b/tasks/format-code-task-001372/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001372/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001375/environment/Dockerfile b/tasks/format-code-task-001375/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b795032598d22586f4be799a52867b4ff2a12c2b --- /dev/null +++ b/tasks/format-code-task-001375/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:faa8d42d9bece8fcdd9e419677cb79a5ea696ef4f3dccf1ecd3dd6339b0e1c74 diff --git a/tasks/format-code-task-001375/environment/setup/files/blocklist b/tasks/format-code-task-001375/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001375/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001375/environment/setup/setup.sh b/tasks/format-code-task-001375/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001375/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001375/tests/test.patch b/tasks/format-code-task-001375/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..f9adeea2447b60c9367e903aabbf40ecda6e1bfb --- /dev/null +++ b/tasks/format-code-task-001375/tests/test.patch @@ -0,0 +1,515 @@ +diff --git a/usercase-test-coderl/buffer-list.test.js b/usercase-test-coderl/buffer-list.test.js +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/buffer-list.test.js +@@ -0,0 +1,487 @@ ++const assert = require('assert'); ++const fs = require('fs'); ++const path = require('path'); ++const vm = require('vm'); ++ ++const REPO_ROOT = '/workspace/repo'; ++const BUILD_FILE = path.join(REPO_ROOT, 'build', 'omnitone.js'); ++ ++function loadOmnitone(extra = {}) { ++ const sandbox = { ++ window: {}, ++ navigator: { ++ userAgent: 'Mozilla/5.0 Chrome/77.0.0 Linux', ++ }, ++ performance: { ++ now: () => 12.345, ++ }, ++ logs: [], ++ console: { ++ log: (...args) => sandbox.logs.push(args.join(' ')), ++ }, ++ AudioBuffer: function AudioBuffer() {}, ++ }; ++ ++ sandbox.window.console = sandbox.console; ++ sandbox.window.navigator = sandbox.navigator; ++ sandbox.window.performance = sandbox.performance; ++ sandbox.window.AudioContext = function AudioContext() {}; ++ sandbox.window.OfflineAudioContext = function OfflineAudioContext() {}; ++ sandbox.AudioContext = sandbox.window.AudioContext; ++ sandbox.OfflineAudioContext = sandbox.window.OfflineAudioContext; ++ sandbox.window.atob = (value) => Buffer.from(value, 'base64').toString('binary'); ++ sandbox.XMLHttpRequest = function XMLHttpRequest() { ++ throw new Error('Unexpected XMLHttpRequest constructor'); ++ }; ++ sandbox.fetch = function fetch() { ++ throw new Error('Unexpected fetch call'); ++ }; ++ ++ Object.assign(sandbox, extra); ++ sandbox.window.XMLHttpRequest = sandbox.XMLHttpRequest; ++ sandbox.window.fetch = sandbox.fetch; ++ vm.createContext(sandbox); ++ vm.runInContext(fs.readFileSync(BUILD_FILE, 'utf8'), sandbox, { ++ filename: BUILD_FILE, ++ }); ++ return sandbox; ++} ++ ++function bufferIds(audioBuffers) { ++ return Array.from(audioBuffers, (audioBuffer) => audioBuffer.id); ++} ++ ++function bytesFromArrayBuffer(arrayBuffer) { ++ return Array.from(new Uint8Array(arrayBuffer)); ++} ++ ++function taggedArrayBuffer(tag, bytes = []) { ++ const arrayBuffer = new ArrayBuffer(bytes.length); ++ const view = new Uint8Array(arrayBuffer); ++ view.set(bytes); ++ Object.defineProperty(arrayBuffer, 'tag', {value: tag}); ++ return arrayBuffer; ++} ++ ++function createDecodeTask(arrayBuffer, success, failure) { ++ let resolvePromise; ++ let rejectPromise; ++ const promise = new Promise((resolve, reject) => { ++ resolvePromise = resolve; ++ rejectPromise = reject; ++ }); ++ promise.catch(() => {}); ++ ++ return { ++ tag: arrayBuffer.tag, ++ success(audioBuffer) { ++ if (typeof success === 'function') { ++ success(audioBuffer); ++ } ++ resolvePromise(audioBuffer); ++ }, ++ failure(error) { ++ if (typeof failure === 'function') { ++ failure(error); ++ } ++ rejectPromise(error); ++ }, ++ promise, ++ }; ++} ++ ++async function flushAsync() { ++ await Promise.resolve(); ++ await Promise.resolve(); ++ await Promise.resolve(); ++} ++ ++function makeUrlHarness() { ++ const events = []; ++ const decodeTasks = []; ++ const fetchTasks = []; ++ class FakeXHR { ++ constructor() { ++ FakeXHR.instances.push(this); ++ this._listeners = {}; ++ } ++ open(method, url) { ++ this.method = method; ++ this.url = url; ++ events.push(['open', method, url]); ++ } ++ addEventListener(type, listener) { ++ this._listeners[type] = this._listeners[type] || []; ++ this._listeners[type].push(listener); ++ } ++ _emit(type, event = {}) { ++ for (const listener of this._listeners[type] || []) { ++ listener.call(this, event); ++ } ++ const handler = this[`on${type}`]; ++ if (typeof handler === 'function') { ++ handler.call(this, event); ++ } ++ } ++ send() { ++ events.push(['send', this.url]); ++ } ++ } ++ FakeXHR.instances = []; ++ ++ const fakeFetch = (url) => { ++ events.push(['fetch', url]); ++ return new Promise((resolve, reject) => { ++ fetchTasks.push({url, resolve, reject}); ++ }); ++ }; ++ ++ const sandbox = loadOmnitone({XMLHttpRequest: FakeXHR, fetch: fakeFetch}); ++ const context = new sandbox.AudioContext(); ++ context.decodeAudioData = (arrayBuffer, success, failure) => { ++ events.push(['decode', arrayBuffer.tag]); ++ const task = createDecodeTask(arrayBuffer, success, failure); ++ decodeTasks.push(task); ++ return task.promise; ++ }; ++ ++ function requestedUrls() { ++ return [ ++ ...FakeXHR.instances.map((instance) => instance.url), ++ ...fetchTasks.map((task) => task.url), ++ ]; ++ } ++ ++ async function respondUrl(url, status, statusText, tag) { ++ await flushAsync(); ++ const xhr = FakeXHR.instances.find((instance) => instance.url === url); ++ if (xhr) { ++ xhr.status = status; ++ xhr.statusText = statusText; ++ xhr.response = taggedArrayBuffer(tag); ++ xhr.readyState = 4; ++ xhr._emit('readystatechange'); ++ xhr._emit('load'); ++ await flushAsync(); ++ return; ++ } ++ ++ const fetchTask = fetchTasks.find((task) => task.url === url); ++ assert.ok(fetchTask, `Expected URL request for ${url}`); ++ fetchTask.resolve({ ++ ok: status === 200, ++ status, ++ statusText, ++ arrayBuffer: () => Promise.resolve(taggedArrayBuffer(tag)), ++ }); ++ await flushAsync(); ++ } ++ ++ async function failUrl(url, error) { ++ await flushAsync(); ++ const xhr = FakeXHR.instances.find((instance) => instance.url === url); ++ if (xhr) { ++ xhr._emit('error', error); ++ await flushAsync(); ++ return; ++ } ++ ++ const fetchTask = fetchTasks.find((task) => task.url === url); ++ assert.ok(fetchTask, `Expected URL request for ${url}`); ++ fetchTask.reject(error); ++ await flushAsync(); ++ } ++ ++ return { ++ sandbox, ++ context, ++ FakeXHR, ++ events, ++ decodeTasks, ++ requestedUrls, ++ respondUrl, ++ failUrl, ++ }; ++} ++ ++async function loadDefaultUrlOutOfOrder() { ++ const {sandbox, context, events, decodeTasks, requestedUrls, respondUrl} = ++ makeUrlHarness(); ++ const promise = sandbox.Omnitone.createBufferList( ++ context, ['/hrir/wy.wav', '/hrir/zx.wav']); ++ ++ await respondUrl('/hrir/zx.wav', 200, 'OK', 'arraybuffer:zx'); ++ await respondUrl('/hrir/wy.wav', 200, 'OK', 'arraybuffer:wy'); ++ decodeTasks.find((task) => task.tag === 'arraybuffer:zx') ++ .success({id: 'zxBuffer'}); ++ decodeTasks.find((task) => task.tag === 'arraybuffer:wy') ++ .success({id: 'wyBuffer'}); ++ ++ return { ++ resultIds: bufferIds(await promise), ++ requestedUrls: requestedUrls().sort(), ++ decodedTags: events ++ .filter((event) => event[0] === 'decode') ++ .map((event) => event[1]) ++ .sort(), ++ }; ++} ++ ++async function loadExplicitUrlOutOfOrder() { ++ const {sandbox, context, events, decodeTasks, requestedUrls, respondUrl} = ++ makeUrlHarness(); ++ const promise = sandbox.Omnitone.createBufferList( ++ context, ++ ['/hrir/front.wav', '/hrir/middle.wav', '/hrir/rear.wav'], ++ {dataType: 'url'}); ++ ++ await respondUrl('/hrir/rear.wav', 200, 'OK', 'arraybuffer:rear'); ++ await respondUrl('/hrir/front.wav', 200, 'OK', 'arraybuffer:front'); ++ await respondUrl('/hrir/middle.wav', 200, 'OK', 'arraybuffer:middle'); ++ decodeTasks.find((task) => task.tag === 'arraybuffer:rear') ++ .success({id: 'rearBuffer'}); ++ decodeTasks.find((task) => task.tag === 'arraybuffer:middle') ++ .success({id: 'middleBuffer'}); ++ decodeTasks.find((task) => task.tag === 'arraybuffer:front') ++ .success({id: 'frontBuffer'}); ++ ++ return { ++ resultIds: bufferIds(await promise), ++ requestedUrls: requestedUrls().sort(), ++ decodedTags: events ++ .filter((event) => event[0] === 'decode') ++ .map((event) => event[1]) ++ .sort(), ++ }; ++} ++ ++async function loadBase64OutOfOrder() { ++ const sandbox = loadOmnitone(); ++ const context = new sandbox.AudioContext(); ++ const decodeInputs = []; ++ const decodeTasks = []; ++ context.decodeAudioData = (arrayBuffer, success, failure) => { ++ decodeInputs.push(bytesFromArrayBuffer(arrayBuffer)); ++ const task = createDecodeTask(arrayBuffer, success, failure); ++ decodeTasks.push(task); ++ return task.promise; ++ }; ++ ++ const promise = sandbox.Omnitone.createBufferList( ++ context, ['QVo=', 'eHk='], {dataType: 'base64'}); ++ ++ await flushAsync(); ++ decodeTasks[1].success({id: 'audioBufferB'}); ++ decodeTasks[0].success({id: 'audioBufferA'}); ++ ++ return {resultIds: bufferIds(await promise), decodeInputs}; ++} ++ ++async function promiseRejected(promise) { ++ const timeout = new Promise((resolve) => { ++ setTimeout(() => resolve(false), 25); ++ }); ++ return Promise.race([ ++ promise.then(() => false, () => true), ++ timeout, ++ ]); ++} ++ ++describe('Omnitone.createBufferList acceptance', function() { ++ it('loads default URL data and preserves caller order', async function() { ++ ++ ++ ++ assert.deepStrictEqual(await loadDefaultUrlOutOfOrder(), { ++ resultIds: ['wyBuffer', 'zxBuffer'], ++ requestedUrls: ['/hrir/wy.wav', '/hrir/zx.wav'], ++ decodedTags: ['arraybuffer:wy', 'arraybuffer:zx'], ++ }); ++ }); ++ ++ it('honors explicit url dataType while preserving a three-item order', async function() { ++ ++ ++ ++ assert.deepStrictEqual(await loadExplicitUrlOutOfOrder(), { ++ resultIds: ['frontBuffer', 'middleBuffer', 'rearBuffer'], ++ requestedUrls: ['/hrir/front.wav', '/hrir/middle.wav', '/hrir/rear.wav'], ++ decodedTags: [ ++ 'arraybuffer:front', ++ 'arraybuffer:middle', ++ 'arraybuffer:rear', ++ ], ++ }); ++ }); ++ ++ it('converts base64 payloads to ArrayBuffers before decoding', async function() { ++ ++ ++ assert.deepStrictEqual(await loadBase64OutOfOrder(), { ++ resultIds: ['audioBufferA', 'audioBufferB'], ++ decodeInputs: [ ++ [65, 90], ++ [120, 121], ++ ], ++ }); ++ }); ++ ++ it('throws Error for a non-AudioContext context', function() { ++ ++ ++ const sandbox = loadOmnitone(); ++ ++ ++ assert.throws( ++ () => sandbox.Omnitone.createBufferList({}, ['/hrir/wy.wav']), ++ (error) => { ++ assert.strictEqual(error.name, 'Error'); ++ return true; ++ }); ++ }); ++ ++ it('rejects when a URL request returns a non-200 HTTP status', async function() { ++ ++ ++ const {sandbox, context, respondUrl} = makeUrlHarness(); ++ const promise = sandbox.Omnitone.createBufferList(context, ['/missing.wav']); ++ ++ await respondUrl('/missing.wav', 404, 'Not Found', 'arraybuffer:missing'); ++ ++ ++ assert.strictEqual(await promiseRejected(promise), true); ++ }); ++ ++ it('rejects when a URL request hits a network error', async function() { ++ ++ ++ const {sandbox, context, failUrl} = makeUrlHarness(); ++ const promise = sandbox.Omnitone.createBufferList( ++ context, ['/network.wav', '/still-pending.wav']); ++ ++ await failUrl('/network.wav', new Error('network failed')); ++ ++ ++ assert.strictEqual(await promiseRejected(promise), true); ++ }); ++ ++ it('rejects when decodeAudioData fails for a URL payload', async function() { ++ ++ ++ const {sandbox, context, decodeTasks, respondUrl} = makeUrlHarness(); ++ const promise = sandbox.Omnitone.createBufferList( ++ context, ['/bad.wav', '/pending.wav']); ++ ++ await respondUrl('/bad.wav', 200, 'OK', 'arraybuffer:bad'); ++ decodeTasks[0].failure('decoder exploded'); ++ ++ ++ assert.strictEqual(await promiseRejected(promise), true); ++ }); ++ ++ it('logs per-item and final success messages when verbose is true', async function() { ++ ++ ++ const sandbox = loadOmnitone(); ++ const context = new sandbox.AudioContext(); ++ context.decodeAudioData = (arrayBuffer, success, failure) => { ++ const task = createDecodeTask(arrayBuffer, success, failure); ++ task.success({id: bytesFromArrayBuffer(arrayBuffer).join('-')}); ++ return task.promise; ++ }; ++ const logCountBeforeLoad = sandbox.logs.length; ++ ++ await sandbox.Omnitone.createBufferList( ++ context, ['QQ==', 'Qg=='], {dataType: 'base64', verbose: true}); ++ ++ const loadLogs = sandbox.logs.slice(logCountBeforeLoad); ++ ++ assert.ok(loadLogs.length >= 3); ++ assert.ok(loadLogs.every((line) => line.trim() !== '')); ++ }); ++ ++ it('is referentially transparent for repeated base64 calls', async function() { ++ assert.deepStrictEqual( ++ await loadBase64OutOfOrder(), ++ { ++ resultIds: ['audioBufferA', 'audioBufferB'], ++ decodeInputs: [ ++ [65, 90], ++ [120, 121], ++ ], ++ }); ++ assert.deepStrictEqual(await loadBase64OutOfOrder(), { ++ resultIds: ['audioBufferA', 'audioBufferB'], ++ decodeInputs: [ ++ [65, 90], ++ [120, 121], ++ ], ++ }); ++ }); ++ ++ it('keeps caller order while decoding distinct base64 payloads', async function() { ++ const sandbox = loadOmnitone(); ++ const context = new sandbox.AudioContext(); ++ const bufferData = ['QVo=', 'eHk=']; ++ const options = {dataType: 'base64', verbose: false}; ++ context.decodeAudioData = (arrayBuffer, success) => { ++ success({id: bytesFromArrayBuffer(arrayBuffer).join('-')}); ++ }; ++ ++ assert.deepStrictEqual( ++ bufferIds(await sandbox.Omnitone.createBufferList( ++ context, bufferData, options)), ++ ['65-90', '120-121']); ++ ++ assert.deepStrictEqual(bufferIds(await sandbox.Omnitone.createBufferList( ++ context, ['QVo=', 'eHk='], {dataType: 'base64', verbose: false})), [ ++ '65-90', ++ '120-121', ++ ]); ++ }); ++ ++ it('accepts OfflineAudioContext for base64 input', async function() { ++ ++ ++ const sandbox = loadOmnitone(); ++ const context = new sandbox.OfflineAudioContext(); ++ const decodeTasks = []; ++ context.decodeAudioData = (arrayBuffer, success, failure) => { ++ const task = createDecodeTask(arrayBuffer, success, failure); ++ decodeTasks.push(task); ++ return task.promise; ++ }; ++ ++ const promise = sandbox.Omnitone.createBufferList( ++ context, ['QQ==', 'Qg=='], {dataType: 'base64'}); ++ ++ await flushAsync(); ++ decodeTasks[1].success({id: 'audioBufferB'}); ++ decodeTasks[0].success({id: 'audioBufferA'}); ++ ++ ++ assert.deepStrictEqual(bufferIds(await promise), [ ++ 'audioBufferA', ++ 'audioBufferB', ++ ]); ++ }); ++ ++ it('does not perform URL loading on the base64 path', async function() { ++ const sandbox = loadOmnitone({ ++ XMLHttpRequest: function XMLHttpRequest() { ++ throw new Error('Base64 path must not create XMLHttpRequest'); ++ }, ++ fetch: function fetch() { ++ throw new Error('Base64 path must not call fetch'); ++ }, ++ }); ++ const context = new sandbox.AudioContext(); ++ context.decodeAudioData = (arrayBuffer, success) => success({id: 'audioBufferA'}); ++ ++ ++ assert.deepStrictEqual( ++ bufferIds(await sandbox.Omnitone.createBufferList( ++ context, ['QVo='], {dataType: 'base64'})), ++ ['audioBufferA']); ++ }); ++}); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,18 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo ++test -x ./node_modules/.bin/rollup ++test -x ./node_modules/.bin/mocha ++mkdir -p build ++./node_modules/.bin/rollup -c >/dev/null ++exec ./node_modules/.bin/mocha /workspace/repo/usercase-test-coderl/buffer-list.test.js --reporter spec diff --git a/tasks/format-code-task-001375/tests/test.sh b/tasks/format-code-task-001375/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..3ab33b3fda426f6eab22d8b4b49b4c44214dde95 --- /dev/null +++ b/tasks/format-code-task-001375/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/buffer-list.test.js +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001375/tests/test_command.sh b/tasks/format-code-task-001375/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001375/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001381/environment/Dockerfile b/tasks/format-code-task-001381/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..42153c1b80b3c99608f81dcae7ffe4048db39f70 --- /dev/null +++ b/tasks/format-code-task-001381/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:42b98fd93b63eca9ce2060dbf56f8243093346979f2cf26b3510b12abd6a4f1a diff --git a/tasks/format-code-task-001381/environment/setup/files/blocklist b/tasks/format-code-task-001381/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001381/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001381/environment/setup/setup.sh b/tasks/format-code-task-001381/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001381/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001381/tests/test.patch b/tasks/format-code-task-001381/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..39029d7be6197847e7f1539f20662334b6938d48 --- /dev/null +++ b/tasks/format-code-task-001381/tests/test.patch @@ -0,0 +1,251 @@ +diff --git a/usercase-test-coderl/typed_window_input_test.go b/usercase-test-coderl/typed_window_input_test.go +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/typed_window_input_test.go +@@ -0,0 +1,213 @@ ++package usercase_test_coderl ++ ++import ( ++ "fmt" ++ "os" ++ "os/exec" ++ "strings" ++ "testing" ++ "time" ++ ++ "github.com/gopxl/pixel/v2" ++ "github.com/gopxl/pixel/v2/backends/opengl" ++) ++ ++func TestMain(m *testing.M) { ++ opengl.Run(func() { ++ os.Exit(m.Run()) ++ }) ++} ++ ++func TestTypedCollectsCharactersUntilFrameUpdate(t *testing.T) { ++ ++ ++ win := newWindow(t, "pixel-typed-ab") ++ defer win.Destroy() ++ ++ id := focusWindow(t, "pixel-typed-ab") ++ drainInput(win) ++ assertTyped(t, win, "") ++ ++ sendXDo(t, "type", "--window", id, "--delay", "0", "ab") ++ win.UpdateInput() ++ assertTyped(t, win, "ab") ++ ++ win.UpdateInput() ++ assertTyped(t, win, "") ++} ++ ++func TestTypedReturnsUnicodeUTF8Text(t *testing.T) { ++ ++ ++ mapEacuteKey(t) ++ win := newWindow(t, "pixel-typed-unicode") ++ defer win.Destroy() ++ ++ id := focusWindow(t, "pixel-typed-unicode") ++ drainInput(win) ++ sendXDo(t, "key", "--window", id, "--delay", "0", "eacute") ++ win.UpdateInput() ++ assertTyped(t, win, "é") ++ if got := fmt.Sprintf("% x", []byte(win.Typed())); got != "c3 a9" { ++ t.Fatalf("Typed() bytes = %q, want %q", got, "c3 a9") ++ } ++ ++ win.UpdateInput() ++ assertTyped(t, win, "") ++} ++ ++func TestTypedClearsAfterEachInputAdvanceVariant(t *testing.T) { ++ ++ ++ win := newWindow(t, "pixel-typed-advance") ++ defer win.Destroy() ++ ++ id := focusWindow(t, "pixel-typed-advance") ++ drainInput(win) ++ ++ sendXDo(t, "type", "--window", id, "--delay", "0", "c") ++ win.UpdateInput() ++ assertTyped(t, win, "c") ++ win.Update() ++ assertTyped(t, win, "") ++ ++ sendXDo(t, "type", "--window", id, "--delay", "0", "d") ++ win.UpdateInput() ++ assertTyped(t, win, "d") ++ win.UpdateInput() ++ assertTyped(t, win, "") ++ ++ sendXDo(t, "type", "--window", id, "--delay", "0", "e") ++ win.UpdateInput() ++ assertTyped(t, win, "e") ++ win.UpdateInputWait(20 * time.Millisecond) ++ assertTyped(t, win, "") ++} ++ ++func TestNonTextKeyStateIsSeparateFromTypedText(t *testing.T) { ++ ++ ++ win := newWindow(t, "pixel-typed-nontext") ++ defer win.Destroy() ++ ++ id := focusWindow(t, "pixel-typed-nontext") ++ drainInput(win) ++ sendXDo(t, "keydown", "--window", id, "Escape", "Left", "F1") ++ win.UpdateInput() ++ assertTyped(t, win, "") ++ assertPressed(t, win, pixel.KeyEscape, true) ++ assertPressed(t, win, pixel.KeyLeft, true) ++ assertPressed(t, win, pixel.KeyF1, true) ++ ++ sendXDo(t, "keyup", "--window", id, "Escape", "Left", "F1") ++ win.UpdateInput() ++ assertTyped(t, win, "") ++ assertPressed(t, win, pixel.KeyEscape, false) ++ assertPressed(t, win, pixel.KeyLeft, false) ++ assertPressed(t, win, pixel.KeyF1, false) ++} ++ ++func TestTypedBuffersAreIndependentPerWindow(t *testing.T) { ++ ++ ++ a := newWindow(t, "pixel-typed-independent-a") ++ defer a.Destroy() ++ b := newWindow(t, "pixel-typed-independent-b") ++ defer b.Destroy() ++ ++ aID := focusWindow(t, "pixel-typed-independent-a") ++ drainInput(a) ++ drainInput(b) ++ sendXDo(t, "type", "--window", aID, "--delay", "0", "x") ++ a.UpdateInput() ++ b.UpdateInput() ++ assertTyped(t, a, "x") ++ assertTyped(t, b, "") ++ ++ bID := focusWindow(t, "pixel-typed-independent-b") ++ sendXDo(t, "type", "--window", bID, "--delay", "0", "y") ++ a.UpdateInput() ++ b.UpdateInput() ++ assertTyped(t, a, "") ++ assertTyped(t, b, "y") ++} ++ ++func TestTypedWorksForNewWindowCreateUseDestroy(t *testing.T) { ++ ++ ++ ++ win := newWindow(t, "pixel-typed-create-use-destroy") ++ id := focusWindow(t, "pixel-typed-create-use-destroy") ++ drainInput(win) ++ sendXDo(t, "type", "--window", id, "--delay", "0", "q") ++ win.UpdateInput() ++ assertTyped(t, win, "q") ++ win.Destroy() ++} ++ ++func newWindow(t *testing.T, title string) *opengl.Window { ++ t.Helper() ++ win, err := opengl.NewWindow(opengl.WindowConfig{ ++ Title: title, ++ Bounds: pixel.R(0, 0, 160, 120), ++ }) ++ if err != nil { ++ t.Fatalf("NewWindow(%q) failed: %v", title, err) ++ } ++ return win ++} ++ ++func focusWindow(t *testing.T, title string) string { ++ t.Helper() ++ deadline := time.Now().Add(3 * time.Second) ++ for time.Now().Before(deadline) { ++ out, err := exec.Command("xdotool", "search", "--name", title).CombinedOutput() ++ if err == nil { ++ fields := strings.Fields(string(out)) ++ if len(fields) > 0 { ++ sendXDo(t, "windowfocus", fields[0]) ++ return fields[0] ++ } ++ } ++ time.Sleep(50 * time.Millisecond) ++ } ++ t.Fatalf("could not find X window with title %q", title) ++ return "" ++} ++ ++func drainInput(win *opengl.Window) { ++ for i := 0; i < 3; i++ { ++ win.UpdateInputWait(20 * time.Millisecond) ++ } ++} ++ ++func sendXDo(t *testing.T, args ...string) { ++ t.Helper() ++ cmd := exec.Command("xdotool", args...) ++ if out, err := cmd.CombinedOutput(); err != nil { ++ t.Fatalf("xdotool %s failed: %v\n%s", strings.Join(args, " "), err, out) ++ } ++ time.Sleep(20 * time.Millisecond) ++} ++ ++func mapEacuteKey(t *testing.T) { ++ t.Helper() ++ cmd := exec.Command("xmodmap", "-e", "keycode 49 = eacute Eacute eacute Eacute") ++ if out, err := cmd.CombinedOutput(); err != nil { ++ t.Fatalf("xmodmap eacute binding failed: %v\n%s", err, out) ++ } ++} ++ ++func assertTyped(t *testing.T, win *opengl.Window, want string) { ++ t.Helper() ++ if got := win.Typed(); got != want { ++ t.Fatalf("Typed() = %q, want %q", got, want) ++ } ++} ++ ++func assertPressed(t *testing.T, win *opengl.Window, button pixel.Button, want bool) { ++ t.Helper() ++ if got := win.Pressed(button); got != want { ++ t.Fatalf("Pressed(%v) = %t, want %t", button, got, want) ++ } ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,28 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++ ++for tool in xvfb-run xdotool xmodmap; do ++ if ! command -v "$tool" >/dev/null 2>&1; then ++ echo "missing required offline test tool: $tool" >&2 ++ exit 127 ++ fi ++done ++ ++export GOPROXY=off ++export GOSUMDB=off ++export GOTOOLCHAIN=local ++export GOFLAGS="${GOFLAGS:-} -mod=readonly" ++ ++exec xvfb-run -a go test -v -count=1 ./usercase-test-coderl/... diff --git a/tasks/format-code-task-001381/tests/test.sh b/tasks/format-code-task-001381/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..77d5a50e799319cd58802d8b4f29d5e4753bd962 --- /dev/null +++ b/tasks/format-code-task-001381/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/typed_window_input_test.go +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001381/tests/test_command.sh b/tasks/format-code-task-001381/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001381/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001386/environment/Dockerfile b/tasks/format-code-task-001386/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b89bf16550580f1a75b19c3d3f8e15946633e5d6 --- /dev/null +++ b/tasks/format-code-task-001386/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:936e8461fd8beff89c1007741f3f83c6a253491c4fa85b3833d70aa620cef87f diff --git a/tasks/format-code-task-001386/environment/setup/files/blocklist b/tasks/format-code-task-001386/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001386/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001386/environment/setup/setup.sh b/tasks/format-code-task-001386/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001386/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001386/tests/test.patch b/tasks/format-code-task-001386/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..38a4184251fae51d05eee1b22f2afec3a1e47ee7 --- /dev/null +++ b/tasks/format-code-task-001386/tests/test.patch @@ -0,0 +1,55 @@ +diff --git a/lint/lint_test.go b/lint/lint_test.go +index 29defeb..735990d 100644 +--- a/lint/lint_test.go ++++ b/lint/lint_test.go +@@ -106,6 +106,30 @@ func TestResultSet(t *testing.T) { + require.Len(t, byRule["rule1"], 1) + require.Len(t, byRule["rule2"], 1) + }) ++ ++ t.Run("Honors Configuration given config present before results added", func(t *testing.T) { ++ c := NewConfigurationFile() ++ appendConfigExclude(t, "rule1", "", "", "", c) ++ ++ r := ResultSet{} ++ r.Configure(c) ++ r.AddResult(newResultContext(t, "rule1", "", "", "", Error)) ++ ++ require.Equal(t, Exclude, r.MaximumSeverity()) ++ require.Equal(t, Exclude, r.ByRule()["rule1"][0].Result.Severity) ++ }) ++ ++ t.Run("Honors Configuration given config added after results added", func(t *testing.T) { ++ c := NewConfigurationFile() ++ appendConfigExclude(t, "rule1", "", "", "", c) ++ ++ r := ResultSet{} ++ r.AddResult(newResultContext(t, "rule1", "", "", "", Error)) ++ r.Configure(c) ++ ++ require.Equal(t, Exclude, r.MaximumSeverity()) ++ require.Equal(t, Exclude, r.ByRule()["rule1"][0].Result.Severity) ++ }) + } + + func TestConfiguration(t *testing.T) { +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,4 @@ ++H4sIAAAAAAAAA+3RTQrCMBCG4ax7irmAbRJNu/Is0j+0UBuwqee3dqGiqBuLiO+zmYEM5IMvLoam ++rTZ1d0zUXPQoc26ao/s57cZZY2221JlV2phUWyVutkQ3hj7kBxF18D68unv3/qPia/+h7sOm9Pt9 ++3lVxv/vcH2/7d5f+bboc78wqNU6J/lyE5/68/7KSqfiirqKtl/MqcdI2XUhkcZRF6YcurE307ZwA ++AAAAAAAAAAAAAAAAHp0Ai3W60QAoAAA= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-001386/tests/test.sh b/tasks/format-code-task-001386/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..45a9dcbf8112b72d476a27d4b68eb448daa933d4 --- /dev/null +++ b/tasks/format-code-task-001386/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +lint/lint_test.go +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001386/tests/test_command.sh b/tasks/format-code-task-001386/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001386/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001388/environment/Dockerfile b/tasks/format-code-task-001388/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..4db0b382e4f29a3cba37bb68fe88ff3423ae729f --- /dev/null +++ b/tasks/format-code-task-001388/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:7e8ca241a5af3610460a37a56329ac9b78e902cd84dc15ed1ecb2dc7f2096746 diff --git a/tasks/format-code-task-001388/environment/setup/files/blocklist b/tasks/format-code-task-001388/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001388/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001388/environment/setup/setup.sh b/tasks/format-code-task-001388/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001388/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001388/tests/test.patch b/tasks/format-code-task-001388/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..1e0bc29c8ddb00740d230b0a5ec35a1410c45b41 --- /dev/null +++ b/tasks/format-code-task-001388/tests/test.patch @@ -0,0 +1,313 @@ +diff --git a/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/AnalyticsConfig.test.tsx b/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/AnalyticsConfig.test.tsx +index 9c48ffde49f..1761ec638a0 100644 +--- a/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/AnalyticsConfig.test.tsx ++++ b/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/AnalyticsConfig.test.tsx +@@ -102,4 +102,65 @@ describe('Render', () => { + })); + expect(screen.queryByText('is no longer supported', { exact: false })).toBeInTheDocument(); + }); ++ ++ describe('when datasource is readOnly', () => { ++ it('should disable Load Workspaces button when readOnly even if required fields are present', () => { ++ setup((props) => ({ ++ ...props, ++ ++ ++ disabled: true, ++ getWorkspaces: jest.fn().mockResolvedValue([]), ++ options: { ++ ...props.options, ++ readOnly: true, ++ jsonData: { ++ ...props.options.jsonData, ++ azureLogAnalyticsSameAs: true, ++ tenantId: 'e7f3f661-a933-4b3f-8176-51c4f982ec48', ++ clientId: '44693801-6ee6-49de-9b2d-9106972f9572', ++ subscriptionId: 'e3fe4fde-ad5e-4d60-9974-e2f3562ffdf2', ++ cloudName: 'azuremonitor', ++ }, ++ secureJsonFields: { ++ ...props.options.secureJsonFields, ++ clientSecret: true, ++ }, ++ }, ++ } as any)); ++ ++ ++ const button = screen.queryByRole('button', { name: /Load Workspaces/i }); ++ if (button) { ++ expect(button).toBeDisabled(); ++ } else { ++ expect(button).toBeNull(); ++ } ++ }); ++ ++ it('should keep Load Workspaces button enabled when not readOnly and required fields are set', () => { ++ setup((props) => ({ ++ ...props, ++ getWorkspaces: jest.fn().mockResolvedValue([]), ++ options: { ++ ...props.options, ++ readOnly: false, ++ jsonData: { ++ ...props.options.jsonData, ++ azureLogAnalyticsSameAs: true, ++ tenantId: 'e7f3f661-a933-4b3f-8176-51c4f982ec48', ++ clientId: '44693801-6ee6-49de-9b2d-9106972f9572', ++ subscriptionId: 'e3fe4fde-ad5e-4d60-9974-e2f3562ffdf2', ++ cloudName: 'azuremonitor', ++ }, ++ secureJsonFields: { ++ ...props.options.secureJsonFields, ++ clientSecret: true, ++ }, ++ }, ++ })); ++ const button = screen.getByRole('button', { name: /Load Workspaces/i }); ++ expect(button).not.toBeDisabled(); ++ }); ++ }); + }); +diff --git a/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/AzureCredentialsForm.test.tsx b/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/AzureCredentialsForm.test.tsx +index 67161abf641..b5ec333bb4a 100644 +--- a/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/AzureCredentialsForm.test.tsx ++++ b/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/AzureCredentialsForm.test.tsx +@@ -2,7 +2,7 @@ import React from 'react'; + import { shallow } from 'enzyme'; + import AzureCredentialsForm, { Props } from './AzureCredentialsForm'; + import { LegacyForms, Button } from '@grafana/ui'; +-const { Input } = LegacyForms; ++const { Input, Select } = LegacyForms; + + const setup = (propsFunc?: (props: Props) => Props) => { + let props: Props = { +@@ -86,5 +86,32 @@ describe('Render', () => { + })); + expect(wrapper.find(Button).exists()).toBe(false); + }); ++ ++ it('should disable auth type select when managed identity is enabled', () => { ++ const wrapper = setup((props) => ({ ++ ...props, ++ managedIdentityEnabled: true, ++ disabled: true, ++ })); ++ const selects = wrapper.find(Select); ++ expect(selects.length).toBeGreaterThan(0); ++ ++ selects.forEach((sel) => { ++ expect(sel.prop('isDisabled')).toBe(true); ++ }); ++ }); ++ ++ it('should disable azure cloud select', () => { ++ const wrapper = setup((props) => ({ ++ ...props, ++ managedIdentityEnabled: false, ++ disabled: true, ++ })); ++ const selects = wrapper.find(Select); ++ expect(selects.length).toBeGreaterThan(0); ++ selects.forEach((sel) => { ++ expect(sel.prop('isDisabled')).toBe(true); ++ }); ++ }); + }); + }); +diff --git a/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/InsightsConfig.test.tsx b/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/InsightsConfig.test.tsx +index 5452215bb14..07cf6e0708f 100644 +--- a/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/InsightsConfig.test.tsx ++++ b/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/InsightsConfig.test.tsx +@@ -1,6 +1,8 @@ + import React from 'react'; + import { shallow } from 'enzyme'; + import InsightsConfig, { Props } from './InsightsConfig'; ++import { LegacyForms, Button } from '@grafana/ui'; ++const { Input } = LegacyForms; + + const setup = (propOverrides?: object) => { + const props: Props = { +@@ -81,4 +83,81 @@ describe('Render', () => { + }); + expect(wrapper).toMatchSnapshot(); + }); ++ ++ describe('when datasource is readOnly', () => { ++ it('should disable api key input when api key is not yet configured', () => { ++ const wrapper = setup({ ++ ++ ++ disabled: true, ++ options: { ++ readOnly: true, ++ secureJsonFields: { ++ appInsightsApiKey: false, ++ }, ++ jsonData: { ++ appInsightsAppId: 'cddcc020-2c94-460a-a3d0-df3147ffa792', ++ }, ++ secureJsonData: { ++ appInsightsApiKey: '', ++ }, ++ }, ++ }); ++ const inputs = wrapper.find(Input); ++ expect(inputs.length).toBeGreaterThan(0); ++ inputs.forEach((input) => { ++ expect(input.prop('disabled')).toBeTruthy(); ++ }); ++ }); ++ ++ it('should disable application id input', () => { ++ const wrapper = setup({ ++ disabled: true, ++ options: { ++ readOnly: true, ++ secureJsonFields: { ++ appInsightsApiKey: false, ++ }, ++ jsonData: { ++ appInsightsAppId: 'cddcc020-2c94-460a-a3d0-df3147ffa792', ++ }, ++ secureJsonData: { ++ appInsightsApiKey: '', ++ }, ++ }, ++ }); ++ ++ const inputs = wrapper.find(Input); ++ ++ const appIdInput = inputs.findWhere( ++ (n) => n.prop('value') === 'cddcc020-2c94-460a-a3d0-df3147ffa792' ++ ); ++ expect(appIdInput.exists()).toBe(true); ++ expect(appIdInput.first().prop('disabled')).toBeTruthy(); ++ }); ++ ++ it('should disable reset button when api key is configured', () => { ++ const wrapper = setup({ ++ disabled: true, ++ options: { ++ readOnly: true, ++ secureJsonFields: { ++ appInsightsApiKey: true, ++ }, ++ jsonData: { ++ appInsightsAppId: 'cddcc020-2c94-460a-a3d0-df3147ffa792', ++ }, ++ secureJsonData: { ++ appInsightsApiKey: 'e7f3f661-a933-4b3f-8176-51c4f982ec48', ++ }, ++ }, ++ }); ++ ++ ++ const buttons = wrapper.find(Button); ++ buttons.forEach((btn) => { ++ expect(btn.prop('disabled')).toBeTruthy(); ++ }); ++ }); ++ }); + }); +diff --git a/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/MonitorConfig.test.tsx b/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/MonitorConfig.test.tsx +new file mode 100644 +index 00000000000..7e778955fa7 +--- /dev/null ++++ b/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/MonitorConfig.test.tsx +@@ -0,0 +1,74 @@ ++import React from 'react'; ++import { shallow } from 'enzyme'; ++import { MonitorConfig, Props } from './MonitorConfig'; ++import { AzureCredentialsForm } from './AzureCredentialsForm'; ++ ++const setup = (propsFunc?: (props: Props) => Props) => { ++ let props: Props = { ++ options: { ++ id: 21, ++ uid: 'x', ++ orgId: 1, ++ name: 'Azure Monitor-10-10', ++ type: 'grafana-azure-monitor-datasource', ++ typeName: 'Azure', ++ typeLogoUrl: '', ++ access: 'proxy', ++ url: '', ++ password: '', ++ user: '', ++ database: '', ++ basicAuth: false, ++ basicAuthUser: '', ++ basicAuthPassword: '', ++ withCredentials: false, ++ isDefault: false, ++ secureJsonFields: {}, ++ jsonData: { ++ cloudName: 'azuremonitor', ++ subscriptionId: '', ++ }, ++ version: 1, ++ readOnly: false, ++ }, ++ updateOptions: jest.fn(), ++ getSubscriptions: jest.fn(), ++ }; ++ ++ if (propsFunc) { ++ props = propsFunc(props); ++ } ++ ++ return shallow(); ++}; ++ ++describe('MonitorConfig readOnly', () => { ++ it('should pass disabled=true to AzureCredentialsForm when options.readOnly is true', () => { ++ const wrapper = setup((props) => ({ ++ ...props, ++ ++ ++ disabled: true, ++ options: { ++ ...props.options, ++ readOnly: true, ++ }, ++ } as any)); ++ const form = wrapper.find(AzureCredentialsForm); ++ expect(form.exists()).toBe(true); ++ expect(form.prop('disabled')).toBe(true); ++ }); ++ ++ it('should pass disabled=false (or falsy) to AzureCredentialsForm when options.readOnly is false', () => { ++ const wrapper = setup((props) => ({ ++ ...props, ++ options: { ++ ...props.options, ++ readOnly: false, ++ }, ++ })); ++ const form = wrapper.find(AzureCredentialsForm); ++ expect(form.exists()).toBe(true); ++ expect(form.prop('disabled')).toBeFalsy(); ++ }); ++}); +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000000..f3acdf55463 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["yarn jest --testPathPattern=\"(AzureCredentialsForm|MonitorConfig|AnalyticsConfig|InsightsConfig)\\.test\" -t \"readOnly|when disabled|MonitorConfig\""] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++yarn jest --testPathPattern="(AzureCredentialsForm|MonitorConfig|AnalyticsConfig|InsightsConfig)\.test" -t "readOnly|when disabled|MonitorConfig" ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001388/tests/test.sh b/tasks/format-code-task-001388/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..b018df3ff994ca52b091e2fdfe5a43a514ac971a --- /dev/null +++ b/tasks/format-code-task-001388/tests/test.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +public/app/plugins/datasource/grafana-azure-monitor-datasource/components/AnalyticsConfig.test.tsx +public/app/plugins/datasource/grafana-azure-monitor-datasource/components/AzureCredentialsForm.test.tsx +public/app/plugins/datasource/grafana-azure-monitor-datasource/components/InsightsConfig.test.tsx +public/app/plugins/datasource/grafana-azure-monitor-datasource/components/MonitorConfig.test.tsx +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001388/tests/test_command.sh b/tasks/format-code-task-001388/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001388/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001451/environment/Dockerfile b/tasks/format-code-task-001451/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a825edea6666a0b7345506ebe784217dd34dee4e --- /dev/null +++ b/tasks/format-code-task-001451/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:65197aff6a6bc9bb03a46a0d1c98e8109189e936a01650676cc3ce485f852d9f diff --git a/tasks/format-code-task-001451/environment/setup/files/blocklist b/tasks/format-code-task-001451/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001451/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001451/environment/setup/setup.sh b/tasks/format-code-task-001451/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001451/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001451/tests/test.patch b/tasks/format-code-task-001451/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..c7c41d2783b219ccdfe9a207b44a88d0ecbab0eb --- /dev/null +++ b/tasks/format-code-task-001451/tests/test.patch @@ -0,0 +1,313 @@ +diff --git a/internal/sdk/codespec_state_migration_test.go b/internal/sdk/codespec_state_migration_test.go +new file mode 100644 +index 000000000..9c43ebc29 +--- /dev/null ++++ b/internal/sdk/codespec_state_migration_test.go +@@ -0,0 +1,297 @@ ++package sdk_test ++ ++import ( ++ "context" ++ "errors" ++ "fmt" ++ "strings" ++ "testing" ++ "time" ++ ++ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ++ "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" ++ "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" ++) ++ ++type codespecBaseResource struct{} ++ ++func (codespecBaseResource) Arguments() map[string]*schema.Schema { ++ return map[string]*schema.Schema{ ++ "current_name": { ++ Type: schema.TypeString, ++ Optional: true, ++ }, ++ } ++} ++ ++func (codespecBaseResource) Attributes() map[string]*schema.Schema { return nil } ++func (codespecBaseResource) ModelObject() interface{} { return nil } ++func (codespecBaseResource) ResourceType() string { return "azurerm_codespec_migrating" } ++ ++func codespecNoopResourceFunc() sdk.ResourceFunc { ++ return sdk.ResourceFunc{ ++ Timeout: time.Minute, ++ Func: func(context.Context, sdk.ResourceMetaData) error { ++ return nil ++ }, ++ } ++} ++ ++func (codespecBaseResource) Create() sdk.ResourceFunc { return codespecNoopResourceFunc() } ++func (codespecBaseResource) Read() sdk.ResourceFunc { return codespecNoopResourceFunc() } ++func (codespecBaseResource) Delete() sdk.ResourceFunc { return codespecNoopResourceFunc() } ++func (codespecBaseResource) IDValidationFunc() pluginsdk.SchemaValidateFunc { ++ return func(interface{}, string) ([]string, []error) { return nil, nil } ++} ++ ++type codespecMigratingResource struct { ++ codespecBaseResource ++ version int ++ upgrades map[int]pluginsdk.StateUpgrade ++} ++ ++func (r codespecMigratingResource) SchemaVersion() int { return r.version } ++func (r codespecMigratingResource) StateUpgrades() map[int]pluginsdk.StateUpgrade { ++ return r.upgrades ++} ++ ++type codespecUpgrade struct { ++ snapshot map[string]*pluginsdk.Schema ++ upgrade pluginsdk.StateUpgraderFunc ++} ++ ++func (u codespecUpgrade) Schema() map[string]*pluginsdk.Schema { return u.snapshot } ++func (u codespecUpgrade) UpgradeFunc() pluginsdk.StateUpgraderFunc { ++ return u.upgrade ++} ++ ++type codespecContextKey struct{} ++ ++func codespecMigrationFixture(t *testing.T) (codespecMigratingResource, []map[string]*pluginsdk.Schema, context.Context, interface{}) { ++ t.Helper() ++ ++ snapshots := []map[string]*pluginsdk.Schema{ ++ { ++ "legacy_name": { ++ Type: pluginsdk.TypeString, ++ Optional: true, ++ }, ++ }, ++ { ++ "name": { ++ Type: pluginsdk.TypeString, ++ Optional: true, ++ }, ++ }, ++ } ++ ++ ctx := context.WithValue(context.Background(), codespecContextKey{}, "migration-context") ++ metadata := &struct{ marker string }{marker: "migration-metadata"} ++ checkInputs := func(ctx context.Context, meta interface{}) error { ++ if got := ctx.Value(codespecContextKey{}); got != "migration-context" { ++ return fmt.Errorf("migration context was not forwarded: %#v", got) ++ } ++ if meta != metadata { ++ return fmt.Errorf("migration metadata was not forwarded: %#v", meta) ++ } ++ return nil ++ } ++ ++ return codespecMigratingResource{ ++ version: 2, ++ upgrades: map[int]pluginsdk.StateUpgrade{ ++ 0: codespecUpgrade{ ++ snapshot: snapshots[0], ++ upgrade: func(ctx context.Context, raw map[string]interface{}, meta interface{}) (map[string]interface{}, error) { ++ if err := checkInputs(ctx, meta); err != nil { ++ return nil, err ++ } ++ raw["name"] = raw["legacy_name"] ++ delete(raw, "legacy_name") ++ raw["migration_step"] = 1 ++ return raw, nil ++ }, ++ }, ++ 1: codespecUpgrade{ ++ snapshot: snapshots[1], ++ upgrade: func(ctx context.Context, raw map[string]interface{}, meta interface{}) (map[string]interface{}, error) { ++ if err := checkInputs(ctx, meta); err != nil { ++ return nil, err ++ } ++ if raw["migration_step"] != 1 { ++ return nil, fmt.Errorf("second migration ran before the first: %#v", raw) ++ } ++ raw["current_name"] = strings.ToUpper(raw["name"].(string)) ++ delete(raw, "name") ++ raw["migration_step"] = 2 ++ return raw, nil ++ }, ++ }, ++ }, ++ }, snapshots, ctx, metadata ++} ++ ++func codespecWrap(resource sdk.Resource) (*schema.Resource, error) { ++ wrapper := sdk.NewResourceWrapper(resource) ++ return wrapper.Resource() ++} ++ ++func TestCodespecTypedStateMigrationPublishesProtocolMetadata(t *testing.T) { ++ resource, snapshots, _, _ := codespecMigrationFixture(t) ++ wrapped, err := codespecWrap(resource) ++ if err != nil { ++ t.Fatalf("wrapping migrating resource: %v", err) ++ } ++ ++ if got, want := wrapped.SchemaVersion, 2; got != want { ++ t.Fatalf("SchemaVersion = %d, want %d", got, want) ++ } ++ if got, want := len(wrapped.StateUpgraders), 2; got != want { ++ t.Fatalf("len(StateUpgraders) = %d, want %d", got, want) ++ } ++ ++ for version, upgrader := range wrapped.StateUpgraders { ++ if got := upgrader.Version; got != version { ++ t.Errorf("StateUpgraders[%d].Version = %d, want %d", version, got, version) ++ } ++ expectedType := (&schema.Resource{Schema: snapshots[version]}).CoreConfigSchema().ImpliedType() ++ if !upgrader.Type.Equals(expectedType) { ++ t.Errorf("StateUpgraders[%d] uses the wrong snapshot type\ngot: %s\nwant: %s", version, upgrader.Type.FriendlyName(), expectedType.FriendlyName()) ++ } ++ } ++} ++ ++func TestCodespecTypedStateMigrationDispatchesEachStep(t *testing.T) { ++ resource, _, ctx, metadata := codespecMigrationFixture(t) ++ wrapped, err := codespecWrap(resource) ++ if err != nil { ++ t.Fatalf("wrapping migrating resource: %v", err) ++ } ++ if len(wrapped.StateUpgraders) != 2 { ++ t.Fatalf("len(StateUpgraders) = %d, want 2", len(wrapped.StateUpgraders)) ++ } ++ ++ state := map[string]interface{}{"legacy_name": "mixedCase"} ++ for version, upgrader := range wrapped.StateUpgraders { ++ state, err = upgrader.Upgrade(ctx, state, metadata) ++ if err != nil { ++ t.Fatalf("running migration %d: %v", version, err) ++ } ++ } ++ ++ if got, want := state["current_name"], "MIXEDCASE"; got != want { ++ t.Errorf("current_name = %#v, want %#v", got, want) ++ } ++ if got, want := state["migration_step"], 2; got != want { ++ t.Errorf("migration_step = %#v, want %#v", got, want) ++ } ++ if _, exists := state["legacy_name"]; exists { ++ t.Error("legacy_name remains after the migration chain") ++ } ++ if _, exists := state["name"]; exists { ++ t.Error("intermediate name remains after the migration chain") ++ } ++} ++ ++func TestCodespecTypedStateMigrationPropagatesUpgradeErrors(t *testing.T) { ++ wantErr := errors.New("codespec migration failed") ++ resource := codespecMigratingResource{ ++ version: 1, ++ upgrades: map[int]pluginsdk.StateUpgrade{ ++ 0: codespecUpgrade{ ++ snapshot: map[string]*pluginsdk.Schema{}, ++ upgrade: func(context.Context, map[string]interface{}, interface{}) (map[string]interface{}, error) { ++ return nil, wantErr ++ }, ++ }, ++ }, ++ } ++ ++ wrapped, err := codespecWrap(resource) ++ if err != nil { ++ t.Fatalf("wrapping migrating resource: %v", err) ++ } ++ if len(wrapped.StateUpgraders) != 1 { ++ t.Fatalf("len(StateUpgraders) = %d, want 1", len(wrapped.StateUpgraders)) ++ } ++ _, err = wrapped.StateUpgraders[0].Upgrade(context.Background(), map[string]interface{}{}, nil) ++ if !errors.Is(err, wantErr) { ++ t.Fatalf("Upgrade error = %v, want %v", err, wantErr) ++ } ++} ++ ++func TestCodespecTypedStateMigrationRejectsInvalidDeclarations(t *testing.T) { ++ validUpgrade := codespecUpgrade{ ++ snapshot: map[string]*pluginsdk.Schema{}, ++ upgrade: func(_ context.Context, raw map[string]interface{}, _ interface{}) (map[string]interface{}, error) { ++ return raw, nil ++ }, ++ } ++ ++ testCases := map[string]codespecMigratingResource{ ++ "negative schema version": { ++ version: -1, ++ }, ++ "missing final source version": { ++ version: 2, ++ upgrades: map[int]pluginsdk.StateUpgrade{0: validUpgrade}, ++ }, ++ "gap and out of range version": { ++ version: 2, ++ upgrades: map[int]pluginsdk.StateUpgrade{0: validUpgrade, 2: validUpgrade}, ++ }, ++ "upgrade declared for version zero": { ++ version: 0, ++ upgrades: map[int]pluginsdk.StateUpgrade{0: validUpgrade}, ++ }, ++ "nil upgrade": { ++ version: 1, ++ upgrades: map[int]pluginsdk.StateUpgrade{0: nil}, ++ }, ++ } ++ ++ for name, resource := range testCases { ++ t.Run(name, func(t *testing.T) { ++ panicked := false ++ var err error ++ func() { ++ defer func() { ++ if recover() != nil { ++ panicked = true ++ } ++ }() ++ _, err = codespecWrap(resource) ++ }() ++ if panicked { ++ t.Fatal("ResourceWrapper.Resource panicked; invalid declarations must return an error") ++ } ++ if err == nil { ++ t.Fatal("ResourceWrapper.Resource accepted an invalid state migration declaration") ++ } ++ }) ++ } ++} ++ ++func TestCodespecTypedStateMigrationPreservesNonMigratingResources(t *testing.T) { ++ wrapped, err := codespecWrap(codespecBaseResource{}) ++ if err != nil { ++ t.Fatalf("wrapping ordinary resource: %v", err) ++ } ++ if got := wrapped.SchemaVersion; got != 0 { ++ t.Fatalf("ordinary resource SchemaVersion = %d, want 0", got) ++ } ++ if got := len(wrapped.StateUpgraders); got != 0 { ++ t.Fatalf("ordinary resource has %d state upgraders, want none", got) ++ } ++ ++ versionZero, err := codespecWrap(codespecMigratingResource{}) ++ if err != nil { ++ t.Fatalf("wrapping an opted-in version-zero resource: %v", err) ++ } ++ if got := versionZero.SchemaVersion; got != 0 { ++ t.Fatalf("version-zero resource SchemaVersion = %d, want 0", got) ++ } ++ if got := len(versionZero.StateUpgraders); got != 0 { ++ t.Fatalf("version-zero resource has %d state upgraders, want none", got) ++ } ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,5 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++go test ./internal/sdk -run '^TestCodespecTypedStateMigration' -count=1 diff --git a/tasks/format-code-task-001451/tests/test.sh b/tasks/format-code-task-001451/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..b9bb7f7e7c98812eb39d5fa683123718826865b5 --- /dev/null +++ b/tasks/format-code-task-001451/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +internal/sdk/codespec_state_migration_test.go +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001451/tests/test_command.sh b/tasks/format-code-task-001451/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001451/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001456/environment/Dockerfile b/tasks/format-code-task-001456/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06778b756c6b22f7a12845f1608f195c28aa1db9 --- /dev/null +++ b/tasks/format-code-task-001456/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:a1be2d69e7f75d9c27236affa7ce8458a95e46d91a734426dfe436938cede3f2 diff --git a/tasks/format-code-task-001456/environment/setup/files/blocklist b/tasks/format-code-task-001456/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001456/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001456/environment/setup/setup.sh b/tasks/format-code-task-001456/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001456/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001456/tests/test.patch b/tasks/format-code-task-001456/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..341fc079f212c6aae46299e92e61546ee98aef8c --- /dev/null +++ b/tasks/format-code-task-001456/tests/test.patch @@ -0,0 +1,277 @@ +diff --git a/command/agent/cache/pass_through_test.go b/command/agent/cache/pass_through_test.go +new file mode 100644 +index 0000000000..206ad66245 +--- /dev/null ++++ b/command/agent/cache/pass_through_test.go +@@ -0,0 +1,241 @@ ++package cache ++ ++import ( ++ "context" ++ "errors" ++ "io" ++ "net/http" ++ "net/http/httptest" ++ "strings" ++ "testing" ++ ++ hclog "github.com/hashicorp/go-hclog" ++ "github.com/hashicorp/vault/api" ++) ++ ++type scriptedProxier struct { ++ responses []*SendResponse ++ errs []error ++ next int ++} ++ ++func (p *scriptedProxier) Send(ctx context.Context, req *SendRequest) (*SendResponse, error) { ++ if p.next >= len(p.responses) { ++ return nil, errors.New("scripted proxier exhausted") ++ } ++ resp := p.responses[p.next] ++ var err error ++ if p.next < len(p.errs) { ++ err = p.errs[p.next] ++ } ++ p.next++ ++ return resp, err ++} ++ ++func makeSendResponse(status int, contentType, body string, extra http.Header) *SendResponse { ++ header := make(http.Header) ++ if contentType != "" { ++ header.Set("Content-Type", contentType) ++ } ++ for key, values := range extra { ++ for _, value := range values { ++ header.Add(key, value) ++ } ++ } ++ return &SendResponse{ ++ Response: &api.Response{ ++ Response: &http.Response{ ++ StatusCode: status, ++ Status: http.StatusText(status), ++ Header: header, ++ Body: io.NopCloser(strings.NewReader(body)), ++ Request: httptest.NewRequest("GET", "http://example.com/v1/secret/data/example", nil), ++ }, ++ }, ++ ResponseBody: []byte(body), ++ } ++} ++ ++func readResponseBody(t *testing.T, resp *SendResponse) string { ++ t.Helper() ++ if resp.ResponseBody != nil { ++ return string(resp.ResponseBody) ++ } ++ data, err := io.ReadAll(resp.Response.Body) ++ if err != nil { ++ t.Fatal(err) ++ } ++ return string(data) ++} ++ ++func TestAgentCacheListenerPassesThroughVaultErrorResponses(t *testing.T) { ++ tests := []struct { ++ name string ++ status int ++ body string ++ header string ++ }{ ++ { ++ name: "not found response", ++ status: http.StatusNotFound, ++ body: `{"errors":["missing path from upstream"]}`, ++ header: "missing-path-case", ++ }, ++ { ++ name: "permission response", ++ status: http.StatusForbidden, ++ body: `{"errors":["denied by upstream"]}`, ++ header: "permission-case", ++ }, ++ { ++ name: "bad request response", ++ status: http.StatusBadRequest, ++ body: `{"errors":["bad request from upstream"]}`, ++ header: "bad-request-case", ++ }, ++ } ++ ++ for _, tc := range tests { ++ t.Run(tc.name, func(t *testing.T) { ++ upstreamHeaders := http.Header{ ++ "X-Vault-Test-Passthrough": []string{tc.header}, ++ "X-Vault-Request": []string{"request-" + tc.header}, ++ } ++ proxier := &scriptedProxier{ ++ responses: []*SendResponse{ ++ makeSendResponse(tc.status, "application/json", tc.body, upstreamHeaders), ++ }, ++ errs: []error{errors.New("vault returned an HTTP error response")}, ++ } ++ ++ handler := Handler(context.Background(), hclog.NewNullLogger(), proxier, nil) ++ rec := httptest.NewRecorder() ++ req := httptest.NewRequest("GET", "http://example.com/v1/secret/data/example", nil) ++ handler.ServeHTTP(rec, req) ++ ++ if rec.Code != tc.status { ++ t.Fatalf("expected upstream status %d to pass through, got %d with body %q", tc.status, rec.Code, rec.Body.String()) ++ } ++ if rec.Code == http.StatusInternalServerError { ++ t.Fatalf("expected Vault-originated error not to be rewritten as a 500") ++ } ++ if got := rec.Body.String(); got != tc.body { ++ t.Fatalf("expected upstream body %q, got %q", tc.body, got) ++ } ++ if strings.Contains(rec.Body.String(), "failed to get the response:") { ++ t.Fatalf("expected Vault-originated response body, got Agent wrapper body %q", rec.Body.String()) ++ } ++ if got := rec.Header().Get("X-Vault-Test-Passthrough"); got != tc.header { ++ t.Fatalf("expected passthrough header %q, got %q", tc.header, got) ++ } ++ if got := rec.Header().Get("X-Vault-Request"); got != "request-"+tc.header { ++ t.Fatalf("expected Vault request header to pass through, got %q", got) ++ } ++ }) ++ } ++} ++ ++func TestAgentCacheListenerPreservesErrorsReturnedByAPIProxy(t *testing.T) { ++ const body = `{"errors":["api proxy saw bad input"]}` ++ ++ upstream := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ++ w.Header().Set("Content-Type", "application/json") ++ w.Header().Set("X-Vault-Request", "api-proxy-request") ++ w.WriteHeader(http.StatusBadRequest) ++ io.WriteString(w, body) ++ })) ++ defer upstream.Close() ++ ++ client, err := api.NewClient(&api.Config{Address: upstream.URL}) ++ if err != nil { ++ t.Fatal(err) ++ } ++ proxier, err := NewAPIProxy(&APIProxyConfig{ ++ Client: client, ++ Logger: hclog.NewNullLogger(), ++ }) ++ if err != nil { ++ t.Fatal(err) ++ } ++ ++ handler := Handler(context.Background(), hclog.NewNullLogger(), proxier, nil) ++ rec := httptest.NewRecorder() ++ req := httptest.NewRequest("GET", "http://example.com/v1/secret/data/api-proxy-error", nil) ++ handler.ServeHTTP(rec, req) ++ ++ if rec.Code != http.StatusBadRequest { ++ t.Fatalf("expected APIProxy-backed Vault error status to pass through, got %d with body %q", rec.Code, rec.Body.String()) ++ } ++ if got := rec.Body.String(); got != body { ++ t.Fatalf("expected APIProxy-backed Vault error body %q, got %q", body, got) ++ } ++ if got := rec.Header().Get("X-Vault-Request"); got != "api-proxy-request" { ++ t.Fatalf("expected APIProxy-backed Vault header to pass through, got %q", got) ++ } ++} ++ ++func TestAgentCacheListenerKeepsFallbackForProxyErrorsWithoutHTTPResponse(t *testing.T) { ++ proxier := &scriptedProxier{ ++ responses: []*SendResponse{nil}, ++ errs: []error{errors.New("dial tcp failed before receiving a response")}, ++ } ++ ++ handler := Handler(context.Background(), hclog.NewNullLogger(), proxier, nil) ++ rec := httptest.NewRecorder() ++ req := httptest.NewRequest("GET", "http://example.com/v1/secret/data/example", nil) ++ handler.ServeHTTP(rec, req) ++ ++ if rec.Code != http.StatusInternalServerError { ++ t.Fatalf("expected no-response proxy failure to remain a 500, got %d with body %q", rec.Code, rec.Body.String()) ++ } ++ if !strings.Contains(rec.Body.String(), "failed to get the response:") { ++ t.Fatalf("expected fallback wrapper in response body, got %q", rec.Body.String()) ++ } ++} ++ ++func TestLeaseCacheDoesNotCacheNonSuccessOrNonJSONResponses(t *testing.T) { ++ tests := []struct { ++ name string ++ first *SendResponse ++ second *SendResponse ++ }{ ++ { ++ name: "unsuccessful JSON response", ++ first: makeSendResponse(http.StatusBadRequest, "application/json", `{"lease_id":"first","renewable":true,"data":{"value":"bad-request"}}`, nil), ++ second: makeSendResponse(http.StatusOK, "application/json", `{"lease_id":"second","renewable":true,"data":{"value":"after-error"}}`, nil), ++ }, ++ { ++ name: "successful non JSON response", ++ first: makeSendResponse(http.StatusOK, "text/plain", `{"lease_id":"first","renewable":true,"data":{"value":"plain-text"}}`, nil), ++ second: makeSendResponse(http.StatusOK, "application/json", `{"lease_id":"second","renewable":true,"data":{"value":"after-plain-text"}}`, nil), ++ }, ++ } ++ ++ for _, tc := range tests { ++ t.Run(tc.name, func(t *testing.T) { ++ lc := testNewLeaseCache(t, []*SendResponse{tc.first, tc.second}) ++ req := &SendRequest{ ++ Token: "root", ++ Request: httptest.NewRequest("GET", "http://example.com/v1/secret/data/cache-test", nil), ++ } ++ ++ first, err := lc.Send(context.Background(), req) ++ if err != nil { ++ t.Fatalf("first send returned error: %v", err) ++ } ++ if first.Response.StatusCode != tc.first.Response.StatusCode || readResponseBody(t, first) != string(tc.first.ResponseBody) { ++ t.Fatalf("first response mismatch: got status=%d body=%q, want status=%d body=%q", ++ first.Response.StatusCode, readResponseBody(t, first), tc.first.Response.StatusCode, string(tc.first.ResponseBody)) ++ } ++ ++ second, err := lc.Send(context.Background(), req) ++ if err != nil { ++ t.Fatalf("second send returned error; first response may have been treated as cacheable success: %v", err) ++ } ++ if second.Response.StatusCode != tc.second.Response.StatusCode || readResponseBody(t, second) != string(tc.second.ResponseBody) { ++ t.Fatalf("second identical request should consume the next upstream response, got status=%d body=%q, want status=%d body=%q", ++ second.Response.StatusCode, readResponseBody(t, second), tc.second.Response.StatusCode, string(tc.second.ResponseBody)) ++ } ++ }) ++ } ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,25 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++export GOPATH=/root/go ++export GO111MODULE=off ++ ++ ++mkdir -p /root/go/src/github.com/hashicorp ++ln -sf /testbed /root/go/src/github.com/hashicorp/vault 2>/dev/null ++ ++cd /root/go/src/github.com/hashicorp/vault ++ ++case "${1:-}" in ++ base) ++ go test -vet=off -v -count=1 ./command/agent/cache/ -run 'Test(APIProxy|Cache_|LeaseCache_(EmptyToken|SendNonCacheableNonTokenLease|HandleCacheClear)|Cache_DeriveNamespaceAndRevocationPath)' -timeout 120s ++ ;; ++ new) ++ go test -vet=off -v -count=1 ./command/agent/cache/ -run 'TestAgentCacheListener(PassesThroughVaultErrorResponses|PreservesErrorsReturnedByAPIProxy|KeepsFallbackForProxyErrorsWithoutHTTPResponse|KeepsFallbackForProxyErrorsWithNonErrorResponse)|TestLeaseCacheDoesNotCacheNonSuccessOrNonJSONResponses' -timeout 120s ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-001456/tests/test.sh b/tasks/format-code-task-001456/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..0da8015b8b87b1a3db965bccbe6c363a124d0f44 --- /dev/null +++ b/tasks/format-code-task-001456/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +command/agent/cache/pass_through_test.go +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001456/tests/test_command.sh b/tasks/format-code-task-001456/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-001456/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh base && bash /testbed/mimo_test_command.sh new \ No newline at end of file diff --git a/tasks/format-code-task-001460/environment/Dockerfile b/tasks/format-code-task-001460/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..cf4a5cee84263309cb86c9fd8101f985100f2a60 --- /dev/null +++ b/tasks/format-code-task-001460/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:88fa5bc61651535e7b70eb3a1e6a1b84762f00c96b71e4283ba1efac68f12003 diff --git a/tasks/format-code-task-001460/environment/setup/files/blocklist b/tasks/format-code-task-001460/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001460/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001460/environment/setup/setup.sh b/tasks/format-code-task-001460/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001460/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001460/tests/test.patch b/tasks/format-code-task-001460/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..0c34013c5e96235c7c58afc3616755c6a1c45566 --- /dev/null +++ b/tasks/format-code-task-001460/tests/test.patch @@ -0,0 +1,319 @@ +diff --git a/ninja_crud/testing/views/create_model_view_test.py b/ninja_crud/testing/views/create_model_view_test.py +index 8bf3b10..1cfd61c 100644 +--- a/ninja_crud/testing/views/create_model_view_test.py ++++ b/ninja_crud/testing/views/create_model_view_test.py +@@ -55,13 +55,13 @@ class CreateModelViewTest(AbstractModelViewTest): + content = json.loads(response.content) + + if self.model_view.detail: +- model = self.model_view._related_model_class ++ model_class = self.model_view._related_model_class + else: +- model = self.model_viewset_test_case.model_viewset_class.model_class ++ model_class = self.model_viewset_test_case.model_viewset_class.model + TestAssertionHelper.assert_content_equals_schema( + test_case=self.model_viewset_test_case, + content=content, +- queryset=model.objects.get_queryset(), ++ queryset=model_class.objects.get_queryset(), + schema_class=self.model_view.output_schema, + ) + +diff --git a/ninja_crud/testing/views/delete_model_view_test.py b/ninja_crud/testing/views/delete_model_view_test.py +index 501b430..70c3f3c 100644 +--- a/ninja_crud/testing/views/delete_model_view_test.py ++++ b/ninja_crud/testing/views/delete_model_view_test.py +@@ -49,7 +49,7 @@ class DeleteModelViewTest(AbstractModelViewTest): + ): + self.model_viewset_test_case.assertEqual(response.content, b"") + +- model_class = self.model_viewset_test_case.model_viewset_class.model_class ++ model_class = self.model_viewset_test_case.model_viewset_class.model + queryset = model_class.objects.filter(id=path_parameters["id"]) + self.model_viewset_test_case.assertEqual(queryset.count(), 0) + +diff --git a/ninja_crud/testing/views/list_model_view_test.py b/ninja_crud/testing/views/list_model_view_test.py +index 77b0798..6b738d3 100644 +--- a/ninja_crud/testing/views/list_model_view_test.py ++++ b/ninja_crud/testing/views/list_model_view_test.py +@@ -57,7 +57,7 @@ class ListModelViewTest(AbstractModelViewTest): + content = json.loads(response.content) + + queryset = self.model_view._get_queryset( +- self.model_viewset_test_case.model_viewset_class.model_class, ++ self.model_viewset_test_case.model_viewset_class.model, + path_parameters["id"] if "id" in path_parameters else None, + ) + +diff --git a/ninja_crud/testing/views/retrieve_model_view_test.py b/ninja_crud/testing/views/retrieve_model_view_test.py +index 70ee0e3..c6c3946 100644 +--- a/ninja_crud/testing/views/retrieve_model_view_test.py ++++ b/ninja_crud/testing/views/retrieve_model_view_test.py +@@ -52,7 +52,7 @@ class RetrieveModelViewTest(AbstractModelViewTest): + content = json.loads(response.content) + + queryset = self.model_view._get_queryset( +- self.model_viewset_test_case.model_viewset_class.model_class, ++ self.model_viewset_test_case.model_viewset_class.model, + path_parameters["id"], + ) + TestAssertionHelper.assert_content_equals_schema( +diff --git a/ninja_crud/testing/views/update_model_view_test.py b/ninja_crud/testing/views/update_model_view_test.py +index 8e5b482..a1e0ec6 100644 +--- a/ninja_crud/testing/views/update_model_view_test.py ++++ b/ninja_crud/testing/views/update_model_view_test.py +@@ -58,7 +58,7 @@ class UpdateModelViewTest(AbstractModelViewTest): + TestAssertionHelper.assert_content_equals_schema( + test_case=self.model_viewset_test_case, + content=content, +- queryset=self.model_viewset_test_case.model_viewset_class.model_class.objects.get_queryset(), ++ queryset=self.model_viewset_test_case.model_viewset_class.model.objects.get_queryset(), + schema_class=self.model_view.output_schema, + ) + +diff --git a/tests/test_app/views/collection_views.py b/tests/test_app/views/collection_views.py +index faa1465..4db1605 100644 +--- a/tests/test_app/views/collection_views.py ++++ b/tests/test_app/views/collection_views.py +@@ -37,7 +37,7 @@ def user_is_creator(func): + + + class CollectionViewSet(ModelViewSet): +- model_class = Collection ++ model = Collection + input_schema = CollectionIn + output_schema = CollectionOut + filter_schema = CollectionFilter +diff --git a/tests/test_app/views/item_views.py b/tests/test_app/views/item_views.py +index 5428b9c..b13b4fd 100644 +--- a/tests/test_app/views/item_views.py ++++ b/tests/test_app/views/item_views.py +@@ -31,7 +31,7 @@ def user_is_collection_creator(func): + + + class ItemViewSet(ModelViewSet): +- model_class = Item ++ model = Item + input_schema = ItemIn + output_schema = ItemOut + filter_schema = OrderableFilterSchema +diff --git a/tests/test_app/views/user_views.py b/tests/test_app/views/user_views.py +index 53e20eb..5720da6 100644 +--- a/tests/test_app/views/user_views.py ++++ b/tests/test_app/views/user_views.py +@@ -15,7 +15,7 @@ router = Router() + + + class UserViewSet(ModelViewSet): +- model_class = User ++ model = User + input_schema = UserIn + output_schema = UserOut + +diff --git a/tests/testing/viewsets/test_model_viewset_test_case.py b/tests/testing/viewsets/test_model_viewset_test_case.py +index 775d483..0d31e5a 100644 +--- a/tests/testing/viewsets/test_model_viewset_test_case.py ++++ b/tests/testing/viewsets/test_model_viewset_test_case.py +@@ -12,7 +12,7 @@ from ninja_crud.viewsets import ModelViewSet + class TestModelViewSetTestCase(unittest.TestCase): + def test_get_associated_model_view_ok(self): + class ExampleModelViewSet(ModelViewSet): +- model_class = Department ++ model = Department + + list_view = ListModelView(output_schema=DepartmentOut) + +@@ -27,7 +27,7 @@ class TestModelViewSetTestCase(unittest.TestCase): + + def test_get_associated_model_view_not_found(self): + class ExampleModelViewSet(ModelViewSet): +- model_class = Department ++ model = Department + + class TestExampleModelViewSet(ModelViewSetTestCase): + test_list_view = ListModelViewTest() +@@ -40,7 +40,7 @@ class TestModelViewSetTestCase(unittest.TestCase): + + def test_check_all_model_views_associated_ok(self): + class ExampleModelViewSet(ModelViewSet): +- model_class = Department ++ model = Department + + list_view = ListModelView(output_schema=DepartmentOut) + +@@ -54,7 +54,7 @@ class TestModelViewSetTestCase(unittest.TestCase): + + def test_check_all_model_views_associated_not_found(self): + class ExampleModelViewSet(ModelViewSet): +- model_class = Department ++ model = Department + + list_view = ListModelView(output_schema=DepartmentOut) + other_list_view = ListModelView(output_schema=DepartmentOut) +diff --git a/tests/views/test_retrieve_model_view.py b/tests/views/test_retrieve_model_view.py +index ea20209..0221359 100644 +--- a/tests/views/test_retrieve_model_view.py ++++ b/tests/views/test_retrieve_model_view.py +@@ -48,7 +48,7 @@ class TestRetrieveModelView(TestCase): + model_view = RetrieveModelView(output_schema=ItemOut) + + class ItemModelViewSet(ModelViewSet): +- model_class = Item ++ model = Item + default_input_schema = None + default_output_schema = None + +@@ -58,7 +58,7 @@ class TestRetrieveModelView(TestCase): + model_view = RetrieveModelView() + + class ItemModelViewSet(ModelViewSet): +- model_class = Item ++ model = Item + default_input_schema = None + default_output_schema = ItemOut + +@@ -68,7 +68,7 @@ class TestRetrieveModelView(TestCase): + model_view = RetrieveModelView() + + class ItemModelViewSet(ModelViewSet): +- model_class = Item ++ model = Item + default_input_schema = None + default_output_schema = None + +diff --git a/tests/viewsets/test_model_attribute_contract.py b/tests/viewsets/test_model_attribute_contract.py +new file mode 100644 +index 0000000..36cea98 +--- /dev/null ++++ b/tests/viewsets/test_model_attribute_contract.py +@@ -0,0 +1,90 @@ ++import re ++from pathlib import Path ++ ++from django.test import TestCase ++from ninja import Router ++ ++from examples.models import Department ++from examples.schemas import DepartmentIn, DepartmentOut ++from ninja_crud import views, viewsets ++ ++ ++class ModelAttributeContractTest(TestCase): ++ def test_model_viewset_accepts_model_attribute_when_registering_routes(self): ++ class DepartmentViewSet(viewsets.ModelViewSet): ++ model = Department ++ default_input_schema = DepartmentIn ++ default_output_schema = DepartmentOut ++ ++ list_view = views.ListModelView() ++ create_view = views.CreateModelView() ++ retrieve_view = views.RetrieveModelView() ++ update_view = views.UpdateModelView() ++ delete_view = views.DeleteModelView() ++ ++ router = Router() ++ ++ try: ++ DepartmentViewSet.register_routes(router) ++ except Exception as exc: ++ self.fail( ++ "ModelViewSet subclasses that declare a Django model with " ++ f"`model` should register CRUD routes successfully: {exc!r}" ++ ) ++ ++ def test_base_model_viewset_accepts_model_attribute_when_registering_routes(self): ++ class DepartmentBaseViewSet(viewsets.BaseModelViewSet): ++ model = Department ++ default_input_schema = DepartmentIn ++ default_output_schema = DepartmentOut ++ ++ router = Router() ++ ++ try: ++ DepartmentBaseViewSet.register_routes(router) ++ except Exception as exc: ++ self.fail( ++ "BaseModelViewSet subclasses should use the public `model` " ++ f"configuration when registering CRUD routes: {exc!r}" ++ ) ++ ++ def test_invalid_model_attribute_is_rejected(self): ++ with self.assertRaises(Exception): ++ ++ class InvalidModelViewSet(viewsets.ModelViewSet): ++ model = object ++ ++ list_view = views.ListModelView(output_schema=DepartmentOut) ++ ++ def test_public_documentation_and_examples_use_model_spelling(self): ++ repo_root = Path(__file__).resolve().parents[2] ++ public_files = [ ++ repo_root / "README.md", ++ repo_root / "docs" / "guides" / "04-Examples.md", ++ repo_root / "examples" / "views" / "department_views.py", ++ repo_root / "examples" / "views" / "employee_views.py", ++ repo_root / "ninja_crud" / "viewsets" / "model_viewset.py", ++ repo_root / "ninja_crud" / "viewsets" / "base_model_viewset.py", ++ repo_root / "ninja_crud" / "views" / "create_model_view.py", ++ repo_root / "ninja_crud" / "views" / "list_model_view.py", ++ repo_root / "ninja_crud" / "views" / "retrieve_model_view.py", ++ repo_root / "ninja_crud" / "views" / "update_model_view.py", ++ repo_root / "ninja_crud" / "views" / "delete_model_view.py", ++ ] ++ ++ combined_text = "\n".join(path.read_text() for path in public_files) ++ ++ self.assertRegex( ++ combined_text, ++ re.compile(r"^\s*model\s*=\s*Department\b", re.MULTILINE), ++ "Public Department viewset examples should demonstrate `model = ...`.", ++ ) ++ ++ for path in public_files: ++ text = path.read_text() ++ self.assertNotRegex( ++ text, ++ re.compile(r"^\s*model_class\s*=", re.MULTILINE), ++ f"{path.relative_to(repo_root)} should not teach the old " ++ "`model_class = ...` spelling in public viewset examples.", ++ ) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,35 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++ ++ ++pip install --break-system-packages --no-input "Django>=4.2,<5.0" "django-ninja>=0.21" 2>/dev/null ++pip install --break-system-packages --no-input -e . 2>/dev/null ++ ++ ++case "${1:-}" in ++ base) ++ DJANGO_SETTINGS_MODULE=tests.test_settings python3 -m django test \ ++ tests.views.test_create_model_view \ ++ tests.views.test_delete_model_view \ ++ tests.views.test_list_model_view \ ++ tests.views.test_update_model_view \ ++ tests.viewsets.test_model_viewset \ ++ --verbosity=2 ++ ;; ++ new) ++ DJANGO_SETTINGS_MODULE=tests.test_settings python3 -m django test \ ++ tests.testing.viewsets.test_model_viewset_test_case \ ++ tests.views.test_retrieve_model_view \ ++ tests.test_app.tests.test_collection_views \ ++ tests.test_app.tests.test_item_views \ ++ tests.test_app.tests.test_user_views \ ++ tests.viewsets.test_model_attribute_contract \ ++ --verbosity=2 ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-001460/tests/test.sh b/tasks/format-code-task-001460/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..4d7a91ab46e29c5330a3a962416b6554d1d7616f --- /dev/null +++ b/tasks/format-code-task-001460/tests/test.sh @@ -0,0 +1,48 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +ninja_crud/testing/views/create_model_view_test.py +ninja_crud/testing/views/delete_model_view_test.py +ninja_crud/testing/views/list_model_view_test.py +ninja_crud/testing/views/retrieve_model_view_test.py +ninja_crud/testing/views/update_model_view_test.py +tests/test_app/views/collection_views.py +tests/test_app/views/item_views.py +tests/test_app/views/user_views.py +tests/testing/viewsets/test_model_viewset_test_case.py +tests/views/test_retrieve_model_view.py +tests/viewsets/test_model_attribute_contract.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001460/tests/test_command.sh b/tasks/format-code-task-001460/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-001460/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh base && bash /testbed/mimo_test_command.sh new \ No newline at end of file diff --git a/tasks/format-code-task-001469/environment/Dockerfile b/tasks/format-code-task-001469/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..eb04bf1509387a031ac7c4b3fa317d23a44bd737 --- /dev/null +++ b/tasks/format-code-task-001469/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:27b0985db0ec65cb26cbc7032deb9e8bdb60e7b5a2124c3776879e2b9c9bf9f7 diff --git a/tasks/format-code-task-001469/environment/setup/files/blocklist b/tasks/format-code-task-001469/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001469/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001469/environment/setup/setup.sh b/tasks/format-code-task-001469/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001469/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001469/tests/test.patch b/tasks/format-code-task-001469/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..8b5cd0fd7f5638ba6d0398c7fc0925ba4aca494d --- /dev/null +++ b/tasks/format-code-task-001469/tests/test.patch @@ -0,0 +1,328 @@ +diff --git a/tests/hikari/impl/test_flatten_action_row_builders.py b/tests/hikari/impl/test_flatten_action_row_builders.py +new file mode 100644 +index 00000000..b99bb138 +--- /dev/null ++++ b/tests/hikari/impl/test_flatten_action_row_builders.py +@@ -0,0 +1,297 @@ ++# -*- coding: utf-8 -*- ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++import pytest ++ ++from hikari import channels ++from hikari import components ++from hikari import emojis ++from hikari.impl import special_endpoints ++ ++ ++def _component(row): ++ built = row.build() ++ assert built["type"] == components.ComponentType.ACTION_ROW ++ assert len(built["components"]) == 1 ++ return built["components"][0] ++ ++ ++class TestAddInteractiveButton: ++ def test_returns_the_row_for_chaining(self): ++ row = special_endpoints.MessageActionRowBuilder() ++ assert row.add_interactive_button(components.ButtonStyle.PRIMARY, "cid") is row ++ ++ def test_minimal_serialization(self): ++ row = special_endpoints.MessageActionRowBuilder() ++ row.add_interactive_button(components.ButtonStyle.SECONDARY, "cid") ++ ++ assert _component(row) == { ++ "type": components.ComponentType.BUTTON, ++ "style": components.ButtonStyle.SECONDARY, ++ "disabled": False, ++ "custom_id": "cid", ++ } ++ ++ def test_full_serialization_with_unicode_emoji(self): ++ row = special_endpoints.MessageActionRowBuilder() ++ row.add_interactive_button( ++ components.ButtonStyle.DANGER, "cid", emoji="\N{THINKING FACE}", label="hello", is_disabled=True ++ ) ++ ++ assert _component(row) == { ++ "type": components.ComponentType.BUTTON, ++ "style": components.ButtonStyle.DANGER, ++ "disabled": True, ++ "label": "hello", ++ "emoji": {"name": "\N{THINKING FACE}"}, ++ "custom_id": "cid", ++ } ++ ++ def test_serialization_with_custom_emoji(self): ++ row = special_endpoints.MessageActionRowBuilder() ++ row.add_interactive_button(components.ButtonStyle.PRIMARY, "cid", emoji=54321) ++ ++ assert _component(row)["emoji"] == {"id": "54321"} ++ ++ def test_appends_to_components(self): ++ row = special_endpoints.MessageActionRowBuilder() ++ row.add_interactive_button(components.ButtonStyle.PRIMARY, "cid") ++ assert len(row.components) == 1 ++ ++ ++class TestAddLinkButton: ++ def test_returns_the_row_for_chaining(self): ++ row = special_endpoints.MessageActionRowBuilder() ++ assert row.add_link_button("https://example.com") is row ++ ++ def test_serialization(self): ++ row = special_endpoints.MessageActionRowBuilder() ++ row.add_link_button("https://example.com", label="click", is_disabled=True) ++ ++ assert _component(row) == { ++ "type": components.ComponentType.BUTTON, ++ "style": components.ButtonStyle.LINK, ++ "disabled": True, ++ "label": "click", ++ "url": "https://example.com", ++ } ++ ++ def test_serialization_with_custom_emoji(self): ++ row = special_endpoints.MessageActionRowBuilder() ++ row.add_link_button("https://example.com", emoji=12345) ++ ++ component = _component(row) ++ assert component["url"] == "https://example.com" ++ assert component["emoji"] == {"id": "12345"} ++ assert "custom_id" not in component ++ ++ ++class TestAddSelectMenu: ++ @pytest.mark.parametrize( ++ "type_", ++ [ ++ components.ComponentType.USER_SELECT_MENU, ++ components.ComponentType.ROLE_SELECT_MENU, ++ components.ComponentType.MENTIONABLE_SELECT_MENU, ++ ], ++ ) ++ def test_returns_the_row_for_chaining(self, type_): ++ row = special_endpoints.MessageActionRowBuilder() ++ assert row.add_select_menu(type_, "cid") is row ++ ++ def test_minimal_serialization(self): ++ row = special_endpoints.MessageActionRowBuilder() ++ row.add_select_menu(components.ComponentType.ROLE_SELECT_MENU, "cid") ++ ++ assert _component(row) == { ++ "type": components.ComponentType.ROLE_SELECT_MENU, ++ "custom_id": "cid", ++ "min_values": 0, ++ "max_values": 1, ++ "disabled": False, ++ } ++ ++ def test_full_serialization(self): ++ row = special_endpoints.MessageActionRowBuilder() ++ row.add_select_menu( ++ components.ComponentType.MENTIONABLE_SELECT_MENU, ++ "cid", ++ placeholder="pick one", ++ min_values=2, ++ max_values=5, ++ is_disabled=True, ++ ) ++ ++ assert _component(row) == { ++ "type": components.ComponentType.MENTIONABLE_SELECT_MENU, ++ "custom_id": "cid", ++ "placeholder": "pick one", ++ "min_values": 2, ++ "max_values": 5, ++ "disabled": True, ++ } ++ ++ def test_raises_on_invalid_type(self): ++ row = special_endpoints.MessageActionRowBuilder() ++ with pytest.raises(ValueError): ++ row.add_select_menu(999999, "cid") ++ ++ ++class TestAddChannelMenu: ++ def test_returns_the_row_for_chaining(self): ++ row = special_endpoints.MessageActionRowBuilder() ++ assert row.add_channel_menu("cid") is row ++ ++ def test_minimal_serialization(self): ++ row = special_endpoints.MessageActionRowBuilder() ++ row.add_channel_menu("cid") ++ ++ component = _component(row) ++ assert component["type"] == components.ComponentType.CHANNEL_SELECT_MENU ++ assert component["custom_id"] == "cid" ++ assert component["min_values"] == 0 ++ assert component["max_values"] == 1 ++ assert component["disabled"] is False ++ ++ def test_serialization_with_channel_types(self): ++ row = special_endpoints.MessageActionRowBuilder() ++ row.add_channel_menu( ++ "cid", ++ channel_types=[channels.ChannelType.GUILD_TEXT, channels.ChannelType.GUILD_VOICE], ++ placeholder="where", ++ min_values=1, ++ max_values=2, ++ is_disabled=True, ++ ) ++ ++ assert _component(row) == { ++ "type": components.ComponentType.CHANNEL_SELECT_MENU, ++ "custom_id": "cid", ++ "placeholder": "where", ++ "min_values": 1, ++ "max_values": 2, ++ "disabled": True, ++ "channel_types": [channels.ChannelType.GUILD_TEXT, channels.ChannelType.GUILD_VOICE], ++ } ++ ++ ++class TestAddTextMenu: ++ def test_returns_the_menu_builder(self): ++ row = special_endpoints.MessageActionRowBuilder() ++ menu = row.add_text_menu("cid") ++ assert menu is not row ++ ++ def test_parent_references_the_row(self): ++ row = special_endpoints.MessageActionRowBuilder() ++ menu = row.add_text_menu("cid") ++ assert menu.parent is row ++ ++ def test_menu_is_attached_before_options_added(self): ++ row = special_endpoints.MessageActionRowBuilder() ++ row.add_text_menu("cid") ++ assert len(row.components) == 1 ++ ++ def test_minimal_serialization(self): ++ row = special_endpoints.MessageActionRowBuilder() ++ row.add_text_menu("cid") ++ ++ assert _component(row) == { ++ "type": components.ComponentType.TEXT_SELECT_MENU, ++ "custom_id": "cid", ++ "min_values": 0, ++ "max_values": 1, ++ "disabled": False, ++ "options": [], ++ } ++ ++ def test_serialization_with_settings(self): ++ row = special_endpoints.MessageActionRowBuilder() ++ row.add_text_menu("cid", placeholder="pick", min_values=1, max_values=4, is_disabled=True) ++ ++ component = _component(row) ++ assert component["placeholder"] == "pick" ++ assert component["min_values"] == 1 ++ assert component["max_values"] == 4 ++ assert component["disabled"] is True ++ ++ def test_add_option_returns_the_menu_for_chaining(self): ++ row = special_endpoints.MessageActionRowBuilder() ++ menu = row.add_text_menu("cid") ++ assert menu.add_option("label", "value") is menu ++ ++ def test_add_option_minimal_serialization(self): ++ row = special_endpoints.MessageActionRowBuilder() ++ menu = row.add_text_menu("cid") ++ menu.add_option("label", "value") ++ ++ assert _component(row)["options"] == [{"label": "label", "value": "value", "default": False}] ++ ++ def test_add_option_full_serialization(self): ++ row = special_endpoints.MessageActionRowBuilder() ++ menu = row.add_text_menu("cid") ++ menu.add_option("label", "value", description="desc", emoji="\N{GRINNING FACE}", is_default=True) ++ ++ assert _component(row)["options"] == [ ++ { ++ "label": "label", ++ "value": "value", ++ "default": True, ++ "description": "desc", ++ "emoji": {"name": "\N{GRINNING FACE}"}, ++ } ++ ] ++ ++ def test_add_option_with_custom_emoji(self): ++ row = special_endpoints.MessageActionRowBuilder() ++ menu = row.add_text_menu("cid") ++ menu.add_option("label", "value", emoji=98765) ++ ++ assert _component(row)["options"][0]["emoji"] == {"id": "98765"} ++ ++ def test_multiple_options_preserve_order(self): ++ row = special_endpoints.MessageActionRowBuilder() ++ menu = row.add_text_menu("cid") ++ menu.add_option("a", "1").add_option("b", "2") ++ ++ options = _component(row)["options"] ++ assert [opt["label"] for opt in options] == ["a", "b"] ++ assert [opt["value"] for opt in options] == ["1", "2"] ++ ++ def test_round_trip_back_to_row(self): ++ row = special_endpoints.MessageActionRowBuilder() ++ result = row.add_text_menu("cid").add_option("a", "1").parent ++ assert result is row ++ ++ ++class TestSingleComponentTypeConstraint: ++ def test_mixing_button_then_menu_raises(self): ++ row = special_endpoints.MessageActionRowBuilder() ++ row.add_interactive_button(components.ButtonStyle.PRIMARY, "cid") ++ with pytest.raises(ValueError): ++ row.add_select_menu(components.ComponentType.USER_SELECT_MENU, "other") ++ ++ def test_mixing_menu_then_button_raises(self): ++ row = special_endpoints.MessageActionRowBuilder() ++ row.add_text_menu("cid") ++ with pytest.raises(ValueError): ++ row.add_link_button("https://example.com") +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,20 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++ ++ ++python -m pytest tests/hikari/impl/test_special_endpoints.py \ ++ --deselect "tests/hikari/impl/test_special_endpoints.py::TestMessageActionRowBuilder::test_add_select_menu" \ ++ --deselect "tests/hikari/impl/test_special_endpoints.py::TestTextSelectMenuBuilder::test_add_add_option" ++ ++ ++python -m pytest tests/hikari/impl/test_flatten_action_row_builders.py diff --git a/tasks/format-code-task-001469/tests/test.sh b/tasks/format-code-task-001469/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..351d8db09facb1eef42036fd54b7642f413a7045 --- /dev/null +++ b/tasks/format-code-task-001469/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/hikari/impl/test_flatten_action_row_builders.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001469/tests/test_command.sh b/tasks/format-code-task-001469/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001469/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001494/environment/Dockerfile b/tasks/format-code-task-001494/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f637fbeb0030ae1d49c0fd0aa7fc4921b8460231 --- /dev/null +++ b/tasks/format-code-task-001494/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:646a8b947e102508cf1301de7055ed465920a62af978ed1eefdb78eb0927fd3e diff --git a/tasks/format-code-task-001494/environment/setup/files/blocklist b/tasks/format-code-task-001494/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001494/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001494/environment/setup/setup.sh b/tasks/format-code-task-001494/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001494/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001494/tests/test.patch b/tasks/format-code-task-001494/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..9e984564ed43af6dc527dabd12e9cbbe068ead05 --- /dev/null +++ b/tasks/format-code-task-001494/tests/test.patch @@ -0,0 +1,108 @@ +diff --git a/tests/components/alexa/__init__.py b/tests/components/alexa/__init__.py +index f853c4ef848cb0..48406a11aef1f2 100644 +--- a/tests/components/alexa/__init__.py ++++ b/tests/components/alexa/__init__.py +@@ -171,6 +171,12 @@ def __init__(self, properties): + """Initialize class.""" + self.properties = properties + ++ def assert_not_has_property(self, namespace, name): ++ """Assert a property does not exist.""" ++ for prop in self.properties: ++ if prop["namespace"] == namespace and prop["name"] == name: ++ assert False, "Property %s:%s exists" ++ + def assert_equal(self, namespace, name, value): + """Assert a property is equal to a given value.""" + for prop in self.properties: +diff --git a/tests/components/alexa/test_capabilities.py b/tests/components/alexa/test_capabilities.py +index f8ad3f57c420e0..357e0e3026d47c 100644 +--- a/tests/components/alexa/test_capabilities.py ++++ b/tests/components/alexa/test_capabilities.py +@@ -1,7 +1,15 @@ + """Test Alexa capabilities.""" + import pytest + +-from homeassistant.const import STATE_LOCKED, STATE_UNLOCKED, STATE_UNKNOWN ++from homeassistant.const import ( ++ ATTR_UNIT_OF_MEASUREMENT, ++ TEMP_CELSIUS, ++ STATE_LOCKED, ++ STATE_UNLOCKED, ++ STATE_UNKNOWN, ++ STATE_UNAVAILABLE, ++) ++from homeassistant.components import climate + from homeassistant.components.alexa import smart_home + from tests.common import async_mock_service + +@@ -368,3 +376,47 @@ async def test_report_cover_percentage_state(hass): + + properties = await reported_properties(hass, "cover.closed") + properties.assert_equal("Alexa.PercentageController", "percentage", 0) ++ ++ ++async def test_temperature_sensor_sensor(hass): ++ """Test TemperatureSensor reports sensor temperature correctly.""" ++ for bad_value in (STATE_UNKNOWN, STATE_UNAVAILABLE, "not-number"): ++ hass.states.async_set( ++ "sensor.temp_living_room", ++ bad_value, ++ {ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS}, ++ ) ++ ++ properties = await reported_properties(hass, "sensor.temp_living_room") ++ properties.assert_not_has_property("Alexa.TemperatureSensor", "temperature") ++ ++ hass.states.async_set( ++ "sensor.temp_living_room", "34", {ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS} ++ ) ++ properties = await reported_properties(hass, "sensor.temp_living_room") ++ properties.assert_equal( ++ "Alexa.TemperatureSensor", "temperature", {"value": 34.0, "scale": "CELSIUS"} ++ ) ++ ++ ++async def test_temperature_sensor_climate(hass): ++ """Test TemperatureSensor reports climate temperature correctly.""" ++ for bad_value in (STATE_UNKNOWN, STATE_UNAVAILABLE, "not-number"): ++ hass.states.async_set( ++ "climate.downstairs", ++ climate.HVAC_MODE_HEAT, ++ {climate.ATTR_CURRENT_TEMPERATURE: bad_value}, ++ ) ++ ++ properties = await reported_properties(hass, "climate.downstairs") ++ properties.assert_not_has_property("Alexa.TemperatureSensor", "temperature") ++ ++ hass.states.async_set( ++ "climate.downstairs", ++ climate.HVAC_MODE_HEAT, ++ {climate.ATTR_CURRENT_TEMPERATURE: 34}, ++ ) ++ properties = await reported_properties(hass, "climate.downstairs") ++ properties.assert_equal( ++ "Alexa.TemperatureSensor", "temperature", {"value": 34.0, "scale": "CELSIUS"} ++ ) +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,6 @@ ++H4sIAAAAAAAAA+3SQWuDMBgGYM/+iiAetkPVtFphsMMOhV42xyiDnUKsYQ3YRGoq3b/fpxvrGLS9 ++tIyx9zmYmLySD79E5VbXlVCmi71LSUieZcNIfo7DnGdjzrM8Hfc5zqc88Vh2sYq+2bZObhjzNta6 ++Y7lT+39UtO+/U60TS7teS1NF7ep8Z5zq/yQd7/ufpNT/dMozjyXnK+Gwf97/ZcWGxpeq8n21a+zG ++sceX2cOzeCqKxW0Qzov7WRw1b3RDgq/A3WJOW/tcXGpzE/bLlOlkzYLwaviEaaMdG10H/sfra21L ++2p5EecRznxbdypoJG60ZTakM1j/amG5hY40yNJW12snPuykbWepaO61aquhQVoj+UCH6yKjzf/sP ++AwAAAAAAAAAAAAAAAAAAAABczjvFe85jACgAAA== +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-001494/tests/test.sh b/tasks/format-code-task-001494/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..850e5ec64de9800403c224c47527e5d3e45c624a --- /dev/null +++ b/tasks/format-code-task-001494/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/components/alexa/__init__.py +tests/components/alexa/test_capabilities.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001494/tests/test_command.sh b/tasks/format-code-task-001494/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001494/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001512/environment/Dockerfile b/tasks/format-code-task-001512/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..21e0a309ae5a815841a40ed94709a7cb6c3885d5 --- /dev/null +++ b/tasks/format-code-task-001512/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:47983b1ed0988af480b510a413d19937bda952e39841d3dd88d749e74869c1ac diff --git a/tasks/format-code-task-001512/environment/setup/files/blocklist b/tasks/format-code-task-001512/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001512/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001512/environment/setup/setup.sh b/tasks/format-code-task-001512/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001512/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001512/tests/test.patch b/tasks/format-code-task-001512/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..5853648272228fd4395e87b545a39b1f0168951c --- /dev/null +++ b/tasks/format-code-task-001512/tests/test.patch @@ -0,0 +1,165 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000000..fb285d3fee9 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest tests/components/forked_daapd/test_media_player.py -k \"test_setup_entry_raises_not_ready_when_config_returns_none or test_unload_entry_after_failed_setup_does_not_crash or test_setup_entry_success_unchanged_when_config_valid\" -v"] ++} +diff --git a/tests/components/forked_daapd/test_media_player.py b/tests/components/forked_daapd/test_media_player.py +index ea9cf557570..b9e2c5e7b93 100644 +--- a/tests/components/forked_daapd/test_media_player.py ++++ b/tests/components/forked_daapd/test_media_player.py +@@ -1,8 +1,10 @@ + """The media player tests for the forked_daapd media player platform.""" +-from unittest.mock import patch ++from unittest.mock import MagicMock, patch + + import pytest + ++from homeassistant.exceptions import IntegrationError ++ + from homeassistant.components.forked_daapd.browse_media import create_media_content_id + from homeassistant.components.forked_daapd.const import ( + CONF_LIBRESPOT_JAVA_PORT, +@@ -962,3 +964,126 @@ async def test_play_media_source(hass: HomeAssistant, mock_api_object) -> None: + position=0, + playback_from_position=0, + ) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++async def test_setup_entry_raises_not_ready_when_config_returns_none( ++ hass: HomeAssistant, config_entry ++) -> None: ++ """When the server returns no config, async_setup_entry must not crash ++ with AttributeError. It must raise PlatformNotReady (or any IntegrationError ++ subclass) so Home Assistant retries the platform setup later. ++ """ ++ from homeassistant.components.forked_daapd.media_player import async_setup_entry ++ ++ config_entry.add_to_hass(hass) ++ ++ async def get_request_side_effect(update_type): ++ return None ++ ++ with patch( ++ "homeassistant.components.forked_daapd.media_player.ForkedDaapdAPI", ++ autospec=True, ++ ) as mock_api: ++ mock_api.return_value.get_request.side_effect = get_request_side_effect ++ mock_api.return_value.full_url.return_value = "" ++ mock_api.return_value.get_pipes.return_value = SAMPLE_PIPES ++ mock_api.return_value.get_playlists.return_value = SAMPLE_PLAYLISTS ++ ++ mock_add_entities = MagicMock() ++ ++ ++ ++ with pytest.raises(IntegrationError): ++ await async_setup_entry(hass, config_entry, mock_add_entities) ++ ++ ++ ++ mock_api.return_value.start_websocket_handler.assert_not_called() ++ ++ ++async def test_unload_entry_after_failed_setup_does_not_crash( ++ hass: HomeAssistant, config_entry ++) -> None: ++ """When platform setup failed (server config returned None), unloading ++ the config entry must still succeed without raising. ++ ++ Pre-fix, async_unload_entry would either KeyError (HASS_DATA_UPDATER_KEY ++ never set) or AttributeError (websocket_handler is None) when the user ++ later removes / reloads the integration. ++ """ ++ from homeassistant.components.forked_daapd import async_unload_entry ++ from homeassistant.components.forked_daapd.media_player import async_setup_entry ++ ++ config_entry.add_to_hass(hass) ++ ++ async def get_request_side_effect(update_type): ++ return None ++ ++ with patch( ++ "homeassistant.components.forked_daapd.media_player.ForkedDaapdAPI", ++ autospec=True, ++ ) as mock_api: ++ mock_api.return_value.get_request.side_effect = get_request_side_effect ++ mock_api.return_value.full_url.return_value = "" ++ mock_api.return_value.get_pipes.return_value = SAMPLE_PIPES ++ mock_api.return_value.get_playlists.return_value = SAMPLE_PLAYLISTS ++ ++ mock_add_entities = MagicMock() ++ with pytest.raises(IntegrationError): ++ await async_setup_entry(hass, config_entry, mock_add_entities) ++ ++ ++ ++ ++ ++ with patch.object( ++ hass.config_entries, ++ "async_unload_platforms", ++ return_value=True, ++ ): ++ ++ result = await async_unload_entry(hass, config_entry) ++ assert result is True ++ ++ ++async def test_setup_entry_success_unchanged_when_config_valid( ++ hass: HomeAssistant, config_entry ++) -> None: ++ """Preservation test: when the server returns a valid config, the ++ platform must still set up successfully and start the websocket handler. ++ """ ++ from homeassistant.components.forked_daapd.media_player import async_setup_entry ++ ++ config_entry.add_to_hass(hass) ++ ++ async def get_request_side_effect(update_type): ++ if update_type == "outputs": ++ return {"outputs": SAMPLE_OUTPUTS_ON} ++ return { ++ "config": SAMPLE_CONFIG, ++ "player": SAMPLE_PLAYER_PAUSED, ++ "queue": SAMPLE_QUEUE, ++ }[update_type] ++ ++ with patch( ++ "homeassistant.components.forked_daapd.media_player.ForkedDaapdAPI", ++ autospec=True, ++ ) as mock_api: ++ mock_api.return_value.get_request.side_effect = get_request_side_effect ++ mock_api.return_value.full_url.return_value = "" ++ mock_api.return_value.get_pipes.return_value = SAMPLE_PIPES ++ mock_api.return_value.get_playlists.return_value = SAMPLE_PLAYLISTS ++ ++ mock_add_entities = MagicMock() ++ ++ await async_setup_entry(hass, config_entry, mock_add_entities) ++ await hass.async_block_till_done() ++ ++ mock_api.return_value.start_websocket_handler.assert_called_once() +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m pytest tests/components/forked_daapd/test_media_player.py -k "test_setup_entry_raises_not_ready_when_config_returns_none or test_unload_entry_after_failed_setup_does_not_crash or test_setup_entry_success_unchanged_when_config_valid" -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001512/tests/test.sh b/tasks/format-code-task-001512/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..f520dc0159e1e8f099f3beb7d7828609fd8c6cff --- /dev/null +++ b/tasks/format-code-task-001512/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test_commands.json +tests/components/forked_daapd/test_media_player.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001512/tests/test_command.sh b/tasks/format-code-task-001512/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001512/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001515/environment/Dockerfile b/tasks/format-code-task-001515/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..2800562a3b9a35c8ade1a2e60d18f2c6231729b7 --- /dev/null +++ b/tasks/format-code-task-001515/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:0681acdb44d6fe39421956d4459c56e8afe82ffe6915b694074c7f53ab894e49 diff --git a/tasks/format-code-task-001515/environment/setup/files/blocklist b/tasks/format-code-task-001515/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001515/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001515/environment/setup/setup.sh b/tasks/format-code-task-001515/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001515/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001515/tests/test.patch b/tasks/format-code-task-001515/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..22aeb582407372bb2651461e6f84b1a03b9d8ae0 --- /dev/null +++ b/tasks/format-code-task-001515/tests/test.patch @@ -0,0 +1,103 @@ +diff --git a/src/client/utils.test.ts b/src/client/utils.test.ts +index baaa82d2..00a5df98 100644 +--- a/src/client/utils.test.ts ++++ b/src/client/utils.test.ts +@@ -46,6 +46,76 @@ describe('replaceUrlParams', () => { + const replacedUrl = replaceUrlParam(url, params) + expect(replacedUrl).toBe('http://localhost/year/2024/month/2') + }) ++ ++ it('Should replace optional path parameter when value is provided', () => { ++ const url = 'http://localhost/something/:firstId/:secondId/:version?' ++ const params = { ++ firstId: 'first', ++ secondId: 'second', ++ version: 'v1', ++ } ++ const replacedUrl = replaceUrlParam(url, params) ++ expect(replacedUrl).toBe('http://localhost/something/first/second/v1') ++ }) ++ ++ it('Should remove optional path parameter when value is undefined', () => { ++ const url = 'http://localhost/something/:firstId/:secondId/:version?' ++ const params = { ++ firstId: 'first', ++ secondId: 'second', ++ version: undefined, ++ } ++ const replacedUrl = replaceUrlParam(url, params as Record) ++ expect(replacedUrl).toBe('http://localhost/something/first/second') ++ }) ++ ++ it('Should remove optional path parameter when value is null', () => { ++ const url = 'http://localhost/something/:firstId/:secondId/:version?' ++ const params = { ++ firstId: 'first', ++ secondId: 'second', ++ version: null, ++ } ++ const replacedUrl = replaceUrlParam(url, params as unknown as Record) ++ expect(replacedUrl).toBe('http://localhost/something/first/second') ++ }) ++ ++ it('Should replace optional path parameter with regex pattern when value is provided', () => { ++ const url = 'http://localhost/posts/:id{[0-9]+}?' ++ const params = { ++ id: '42', ++ } ++ const replacedUrl = replaceUrlParam(url, params) ++ expect(replacedUrl).toBe('http://localhost/posts/42') ++ }) ++ ++ it('Should remove optional path parameter with regex pattern when value is undefined', () => { ++ const url = 'http://localhost/posts/:id{[0-9]+}?' ++ const params = { ++ id: undefined, ++ } ++ const replacedUrl = replaceUrlParam(url, params as Record) ++ expect(replacedUrl).toBe('http://localhost/posts') ++ }) ++ ++ it('Should not insert literal "undefined" or "null" when optional value is missing', () => { ++ const url = 'http://localhost/something/:firstId/:secondId/:version?' ++ const undefinedResult = replaceUrlParam(url, { ++ firstId: 'first', ++ secondId: 'second', ++ version: undefined, ++ } as Record) ++ expect(undefinedResult).not.toContain('undefined') ++ expect(undefinedResult).not.toContain(':version') ++ ++ const nullResult = replaceUrlParam(url, { ++ firstId: 'first', ++ secondId: 'second', ++ version: null, ++ } as unknown as Record) ++ expect(nullResult).not.toContain('null') ++ expect(nullResult).not.toContain(':version') ++ }) + }) + + describe('replaceUrlProtocol', () => { +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..b29f7389 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["npx vitest --run src/client/utils.test.ts"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++npx vitest --run src/client/utils.test.ts ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001515/tests/test.sh b/tasks/format-code-task-001515/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..87531f04a269e2c4e23c3bba5b4754c5382b2e10 --- /dev/null +++ b/tasks/format-code-task-001515/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +src/client/utils.test.ts +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001515/tests/test_command.sh b/tasks/format-code-task-001515/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001515/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001523/environment/Dockerfile b/tasks/format-code-task-001523/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..40acf76630fe79284f085060b98909dce41a8efb --- /dev/null +++ b/tasks/format-code-task-001523/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:090c62530aafca48a8c67345dc39bb68c47d84247594d015d71cf45000962660 diff --git a/tasks/format-code-task-001523/environment/setup/files/blocklist b/tasks/format-code-task-001523/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001523/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001523/environment/setup/setup.sh b/tasks/format-code-task-001523/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001523/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001523/tests/test.patch b/tasks/format-code-task-001523/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..6f59d13d386ea4a8fcbb54f143b18af782314dac --- /dev/null +++ b/tasks/format-code-task-001523/tests/test.patch @@ -0,0 +1,340 @@ +diff --git a/usercase-test-coderl/raw_reader.test.js b/usercase-test-coderl/raw_reader.test.js +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/raw_reader.test.js +@@ -0,0 +1,315 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++'use strict'; ++ ++const assert = require('assert'); ++const fs = require('fs'); ++ ++function loadHproseFromPublicSource() { ++ const fallbackFiles = [ ++ 'src/Init.js', ++ 'src/Helper.js', ++ 'src/Polyfill.js', ++ 'src/BytesIO.js', ++ 'src/Tags.js', ++ 'src/ClassManager.js', ++ 'src/Writer.js', ++ 'src/Reader.js', ++ 'src/Formatter.js', ++ 'src/Loader.js' ++ ]; ++ let files = fallbackFiles; ++ try { ++ const gulpfile = fs.readFileSync('/workspace/repo/gulpfile.js', 'utf8'); ++ const concatSourceList = gulpfile.match(/gulp\.src\(\[([\s\S]*?)\]\)\s*\.pipe\(concat\('hprose-html5\.src\.js'\)\)/); ++ if (concatSourceList) { ++ const parsedFiles = []; ++ const sourceFilePattern = /['"](src\/[^'"]+\.js)['"]/g; ++ let match; ++ while ((match = sourceFilePattern.exec(concatSourceList[1])) !== null) { ++ parsedFiles.push(match[1]); ++ } ++ if (parsedFiles.length > 0) { ++ ++ files = parsedFiles; ++ } ++ } ++ } ++ catch (error) { ++ files = fallbackFiles; ++ } ++ const source = files.map((file) => fs.readFileSync(`/workspace/repo/${file}`, 'utf8')).join('\n'); ++ const moduleObject = { exports: {} }; ++ return new Function('module', 'define', `${source}\nreturn module.exports;`)(moduleObject, undefined); ++} ++ ++const hprose = loadHproseFromPublicSource(); ++ ++function rawToString(raw) { ++ return hprose.BytesIO.toString(raw); ++} ++ ++function readRawObservation(reader, stream) { ++ const before = stream.position; ++ const raw = reader.readRaw(); ++ return { ++ before, ++ after: stream.position, ++ text: rawToString(raw), ++ length: raw.length ++ }; ++} ++ ++function test(name, fn) { ++ try { ++ fn(); ++ console.log(`ok - ${name}`); ++ } ++ catch (error) { ++ console.error(`not ok - ${name}`); ++ throw error; ++ } ++} ++ ++test('RawReader returns exact raw bytes for one string value', () => { ++ ++ ++ ++ ++ const stream = new hprose.BytesIO('s5"Hello"'); ++ const reader = new hprose.RawReader(stream); ++ ++ assert.strictEqual(stream.position, 0); ++ assert.deepStrictEqual(readRawObservation(reader, stream), { ++ before: 0, ++ after: 9, ++ text: 's5"Hello"', ++ length: 9 ++ }); ++ assert.strictEqual(stream.position, 9); ++}); ++ ++test('RawReader advances through adjacent values one complete value at a time', () => { ++ ++ ++ ++ ++ const stream = new hprose.BytesIO('i123;s3"abc"'); ++ const reader = new hprose.RawReader(stream); ++ ++ assert.deepStrictEqual(readRawObservation(reader, stream), { ++ before: 0, ++ after: 5, ++ text: 'i123;', ++ length: 5 ++ }); ++ assert.deepStrictEqual(readRawObservation(reader, stream), { ++ before: 5, ++ after: 12, ++ text: 's3"abc"', ++ length: 7 ++ }); ++}); ++ ++test('RawReader includes the full nested list structure', () => { ++ ++ ++ ++ ++ const stream = new hprose.BytesIO('a2{12}'); ++ const reader = new hprose.RawReader(stream); ++ ++ assert.deepStrictEqual(readRawObservation(reader, stream), { ++ before: 0, ++ after: 6, ++ text: 'a2{12}', ++ length: 6 ++ }); ++}); ++ ++test('RawReader includes class definition bytes and the following object bytes', () => { ++ ++ ++ ++ ++ const stream = new hprose.BytesIO('c4"User"2{s4"name"s3"age"}o0{s3"Bob"i42;}'); ++ const reader = new hprose.RawReader(stream); ++ ++ assert.deepStrictEqual(readRawObservation(reader, stream), { ++ before: 0, ++ after: 41, ++ text: 'c4"User"2{s4"name"s3"age"}o0{s3"Bob"i42;}', ++ length: 41 ++ }); ++}); ++ ++test('RawReader preserves raw error payloads', () => { ++ ++ ++ ++ ++ const stream = new hprose.BytesIO('Es4"fail"'); ++ const reader = new hprose.RawReader(stream); ++ ++ assert.deepStrictEqual(readRawObservation(reader, stream), { ++ before: 0, ++ after: 9, ++ text: 'Es4"fail"', ++ length: 9 ++ }); ++}); ++ ++test('Reader exposes readRaw and uses its current stream position', () => { ++ ++ ++ ++ ++ const stream = new hprose.BytesIO('i123;s3"abc"'); ++ const reader = new hprose.Reader(stream); ++ ++ assert.strictEqual(typeof reader.readRaw, 'function'); ++ assert.deepStrictEqual(readRawObservation(reader, stream), { ++ before: 0, ++ after: 5, ++ text: 'i123;', ++ length: 5 ++ }); ++ assert.deepStrictEqual(readRawObservation(reader, stream), { ++ before: 5, ++ after: 12, ++ text: 's3"abc"', ++ length: 7 ++ }); ++}); ++ ++test('Reader readRaw does not decode objects or update reference tables', () => { ++ ++ ++ ++ ++ function User() { ++ constructed += 1; ++ this.name = ''; ++ this.age = 0; ++ } ++ let constructed = 0; ++ hprose.ClassManager.register(User, 'User'); ++ ++ const rawBytes = 'c4"User"2{s4"name"s3"age"}o0{s3"Bob"i42;}'; ++ const trailingObjectBytes = 'o0{s3"Ada"i7;}'; ++ const stream = new hprose.BytesIO(rawBytes + trailingObjectBytes); ++ const reader = new hprose.Reader(stream); ++ ++ assert.strictEqual(constructed, 0); ++ assert.deepStrictEqual(readRawObservation(reader, stream), { ++ before: 0, ++ after: 41, ++ text: 'c4"User"2{s4"name"s3"age"}o0{s3"Bob"i42;}', ++ length: 41 ++ }); ++ ++ assert.strictEqual(constructed, 0); ++ ++ assert.throws( ++ () => reader.unserialize(), ++ (error) => error instanceof Error || error instanceof TypeError ++ ); ++ ++ assert.ok(stream.position >= 41); ++ ++ const decodeStream = new hprose.BytesIO(rawBytes); ++ const decodingReader = new hprose.Reader(decodeStream); ++ const decoded = decodingReader.unserialize(); ++ assert.strictEqual(decoded.constructor.name, 'User'); ++ assert.strictEqual(decoded.name, 'Bob'); ++ assert.strictEqual(decoded.age, 42); ++ ++ assert.strictEqual(constructed, 1); ++ assert.strictEqual(decodeStream.position, 41); ++}); ++ ++test('readRaw rejects an invalid serialization tag with the Reader unexpected-tag Error', () => { ++ ++ ++ ++ ++ const rawStream = new hprose.BytesIO('x'); ++ const rawReader = new hprose.RawReader(rawStream); ++ assert.throws( ++ () => rawReader.readRaw(), ++ ++ (error) => error.constructor === Error && ++ /unexpected/i.test(error.message) && ++ /tag/i.test(error.message) ++ ); ++ ++ assert.ok(rawStream.position >= 0); ++ ++ const readerStream = new hprose.BytesIO('x'); ++ const reader = new hprose.Reader(readerStream); ++ assert.throws( ++ () => reader.readRaw(), ++ ++ (error) => error.constructor === Error && ++ /unexpected/i.test(error.message) && ++ /tag/i.test(error.message) ++ ); ++ ++ assert.ok(readerStream.position >= 0); ++}); ++ ++test('independent RawReader instances advance only their own streams', () => { ++ ++ ++ ++ ++ const aStream = new hprose.BytesIO('i1;i2;'); ++ const bStream = new hprose.BytesIO('s3"abc"'); ++ const a = new hprose.RawReader(aStream); ++ const b = new hprose.RawReader(bStream); ++ ++ assert.deepStrictEqual(readRawObservation(a, aStream), { ++ before: 0, ++ after: 3, ++ text: 'i1;', ++ length: 3 ++ }); ++ assert.deepStrictEqual(readRawObservation(b, bStream), { ++ before: 0, ++ after: 7, ++ text: 's3"abc"', ++ length: 7 ++ }); ++ assert.deepStrictEqual(readRawObservation(a, aStream), { ++ before: 3, ++ after: 6, ++ text: 'i2;', ++ length: 3 ++ }); ++ assert.strictEqual(bStream.position, 7); ++}); ++ ++test('construct-read-drop cycles remain independent', () => { ++ ++ ++ ++ ++ const observations = []; ++ for (let i = 0; i < 200; i += 1) { ++ const stream = new hprose.BytesIO('c4"User"2{s4"name"s3"age"}o0{s3"Bob"i42;}'); ++ const reader = new hprose.RawReader(stream); ++ const raw = reader.readRaw(); ++ assert.strictEqual(rawToString(raw), 'c4"User"2{s4"name"s3"age"}o0{s3"Bob"i42;}'); ++ assert.strictEqual(stream.position, 41); ++ observations.push(stream.position); ++ } ++ ++ ++ assert.deepStrictEqual(observations, new Array(200).fill(41)); ++}); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,15 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo ++ ++node --expose-gc /workspace/repo/usercase-test-coderl/raw_reader.test.js diff --git a/tasks/format-code-task-001523/tests/test.sh b/tasks/format-code-task-001523/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..5e27a86cf65512a92e582741fc4f0b9bbbf3da2d --- /dev/null +++ b/tasks/format-code-task-001523/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/raw_reader.test.js +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001523/tests/test_command.sh b/tasks/format-code-task-001523/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001523/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001524/environment/Dockerfile b/tasks/format-code-task-001524/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..58ba75b4f2b6d448f39bc2d53f4f945120c3e057 --- /dev/null +++ b/tasks/format-code-task-001524/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:003dd14f857bf27d0bccd99401f0e02fb2f52b9707e9b6773831e402bb21d088 diff --git a/tasks/format-code-task-001524/environment/setup/files/blocklist b/tasks/format-code-task-001524/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001524/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001524/environment/setup/setup.sh b/tasks/format-code-task-001524/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001524/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001524/tests/test.patch b/tasks/format-code-task-001524/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..35f41cbe9da9d45ebde4197a7a1e2b28c0614db5 --- /dev/null +++ b/tasks/format-code-task-001524/tests/test.patch @@ -0,0 +1,246 @@ +diff --git a/usercase-test-coderl/usecase.sh b/usercase-test-coderl/usecase.sh +new file mode 100755 +--- /dev/null ++++ b/usercase-test-coderl/usecase.sh +@@ -0,0 +1,224 @@ ++#!/usr/bin/env bash ++ ++set -u ++export LANG=C LC_ALL=C TZ=UTC ++ ++( cd /workspace/repo && python3 - <<'PY' ++import pycparser ++PY ++) || { echo "FAIL: build/dependency check" >&2; exit 1; } ++ ++PYTHON=${PYTHON:-python3} ++BIN=/workspace/repo/generate-wrapper.py ++ ++TMP=$(mktemp -d); trap 'rm -rf "$TMP"' EXIT ++fail() { echo "FAIL: $*" >&2; exit 1; } ++ ++run_tool() { ++ "$PYTHON" "$BIN" "$@" >out 2>err ++ ec=$? ++} ++ ++assert_stdout_exact() { ++ ++ : ++} ++ ++assert_empty_stderr() { ++ [ ! -s err ] || fail "$1 stderr: $(cat err)" ++} ++ ++assert_line() { ++ file=$1 ++ expected=$2 ++ label=$3 ++ grep -Fqx -- "$expected" "$file" || fail "$label missing line: $expected" ++} ++ ++assert_file_regex() { ++ file=$1 ++ pattern=$2 ++ label=$3 ++ "$PYTHON" - "$file" "$pattern" "$label" <<'PY' ++import re ++import sys ++ ++path, pattern, label = sys.argv[1:] ++with open(path, encoding="utf-8") as fh: ++ text = fh.read() ++if not re.search(pattern, text, re.MULTILINE | re.DOTALL): ++ print(f"FAIL: {label} missing pattern: {pattern}", file=sys.stderr) ++ sys.exit(1) ++PY ++} ++ ++assert_no_text() { ++ needle=$1 ++ shift ++ for file in "$@"; do ++ if grep -Fq -- "$needle" "$file"; then ++ fail "$file unexpectedly contains $needle" ++ fi ++ done ++} ++ ++assert_generated_function() { ++ fn=$1 ++ label=$2 ++ ++ assert_file_regex demo-wrap.h "#\\s*define\\s+${fn}\\b" "$label header macro" ++ assert_file_regex demo-wrap.h "extern\\s+int\\s*\\(\\s*\\*[^;]*${fn}[^;]*\\)\\s*\\(\\s*void\\s*\\)\\s*;" "$label header extern" ++ assert_file_regex demo-wrap.c "=[^;]*dlsym\\s*\\([^;]*\"${fn}\"[^;]*\\)" "$label implementation dlsym" ++} ++ ++BASE_STDOUT="cpp_args: ['-E', '-include', '/workspace/repo/attributes.h', '-I', '/workspace/repo/fake_libc_include']" ++ONE_DIR_STDOUT="cpp_args: ['-E', '-include', '/workspace/repo/attributes.h', '-I', '/workspace/repo/fake_libc_include', '-I', 'extra']" ++TWO_DIR_STDOUT="cpp_args: ['-E', '-include', '/workspace/repo/attributes.h', '-I', '/workspace/repo/fake_libc_include', '-I', 'extra', '-I', 'more']" ++ ++ ++ ++ ++cd "$TMP"; mkdir F1; cd F1 || exit 1 ++mkdir extra ++cat > public.h <<'EOF' ++#include "dep.h" ++int public_api(void); ++EOF ++cat > extra/dep.h <<'EOF' ++int dep_api(void); ++EOF ++run_tool --include public.h --include-dir extra --sys-include public.h --soname libdemo.so --init-name demo --output-header demo-wrap.h --output-implementation demo-wrap.c ++[ "$ec" -eq 0 ] || fail "F1 exit $ec; want 0" ++assert_stdout_exact "$ONE_DIR_STDOUT" "F1" ++assert_empty_stderr "F1" ++assert_generated_function dep_api "F1 dep_api" ++assert_generated_function public_api "F1 public_api" ++ ++ ++ ++ ++cd "$TMP"; mkdir F2; cd F2 || exit 1 ++cat > public.h <<'EOF' ++int public_api(void); ++int _private_api(void); ++int skip_me(void); ++int still_api(void); ++EOF ++run_tool --include public.h --sys-include public.h --soname libdemo.so --init-name demo --output-header demo-wrap.h --output-implementation demo-wrap.c --omit-prefix _ --omit-prefix skip ++[ "$ec" -eq 0 ] || fail "F2 exit $ec; want 0" ++assert_stdout_exact "$BASE_STDOUT" "F2" ++assert_empty_stderr "F2" ++assert_generated_function public_api "F2 public_api" ++assert_generated_function still_api "F2 still_api" ++assert_no_text _private_api demo-wrap.h demo-wrap.c ++assert_no_text skip_me demo-wrap.h demo-wrap.c ++ ++ ++ ++ ++cd "$TMP"; mkdir F3; cd F3 || exit 1 ++mkdir extra more ++cat > public.h <<'EOF' ++#include "dep.h" ++#include "vendor.h" ++int public_api(void); ++EOF ++cat > extra/dep.h <<'EOF' ++int dep_api(void); ++EOF ++cat > more/vendor.h <<'EOF' ++int vendor_api(void); ++EOF ++run_tool --include public.h --include-dir extra --include-dir more --sys-include public.h --soname libdemo.so --init-name demo --output-header demo-wrap.h --output-implementation demo-wrap.c --ignore-headers dep.h --ignore-headers vendor.h ++[ "$ec" -eq 0 ] || fail "F3 exit $ec; want 0" ++assert_stdout_exact "$TWO_DIR_STDOUT" "F3" ++assert_empty_stderr "F3" ++assert_generated_function public_api "F3 public_api" ++assert_no_text dep_api demo-wrap.h demo-wrap.c ++assert_no_text vendor_api demo-wrap.h demo-wrap.c ++ ++ ++ ++ ++cd "$TMP"; mkdir F4; cd F4 || exit 1 ++mkdir extra ++cat > public.h <<'EOF' ++#include "dep.h" ++int public_api(void); ++EOF ++cat > extra/dep.h <<'EOF' ++int dep_api(void); ++EOF ++run_tool --include public.h --include-dir extra --sys-include public.h --soname libdemo.so --init-name demo --output-header demo-wrap.h --output-implementation demo-wrap.c --ignore-other ++[ "$ec" -eq 0 ] || fail "F4 exit $ec; want 0" ++assert_stdout_exact "$ONE_DIR_STDOUT" "F4" ++assert_empty_stderr "F4" ++assert_generated_function public_api "F4 public_api" ++assert_no_text dep_api demo-wrap.h demo-wrap.c ++ ++ ++ ++ ++cd "$TMP"; mkdir F5; cd F5 || exit 1 ++mkdir extra ++cat > public.h <<'EOF' ++#include "dep.h" ++int public_api(void); ++EOF ++cat > extra/dep.h <<'EOF' ++int dep_api(void); ++EOF ++run_tool --include public.h --include-dir extra --sys-include public.h --soname libdemo.so --init-name demo --output-header demo-wrap.h --output-implementation demo-wrap.c --no-ignore-other ++[ "$ec" -eq 0 ] || fail "F5 exit $ec; want 0" ++assert_stdout_exact "$ONE_DIR_STDOUT" "F5" ++assert_empty_stderr "F5" ++assert_generated_function dep_api "F5 dep_api" ++assert_generated_function public_api "F5 public_api" ++ ++ ++ ++ ++cd "$TMP"; mkdir F6; cd F6 || exit 1 ++cat > public.h <<'EOF' ++int public_api(void); ++EOF ++run_tool --include public.h --sys-include public.h --soname libdemo.so --init-name demo --output-header demo-wrap.h --output-implementation demo-wrap.c --include-dir ++[ "$ec" -ne 0 ] || fail "F6 exit $ec; want nonzero" ++[ ! -s out ] || fail "F6 stdout should be empty: $(cat out)" ++ ++grep -Eiq -- 'usage|error' err || fail "F6 stderr missing include-dir usage error: $(cat err)" ++[ ! -e demo-wrap.h ] || fail "F6 unexpectedly created demo-wrap.h" ++[ ! -e demo-wrap.c ] || fail "F6 unexpectedly created demo-wrap.c" ++ ++ ++ ++ ++cd "$TMP"; mkdir F7; cd F7 || exit 1 ++cat > public.h <<'EOF' ++int public_api(void); ++EOF ++run_tool --include public.h --sys-include public.h --soname libdemo.so --init-name demo --output-header demo-wrap.h --output-implementation demo-wrap.c --omit-prefix ++[ "$ec" -ne 0 ] || fail "F7 exit $ec; want nonzero" ++[ ! -s out ] || fail "F7 stdout should be empty: $(cat out)" ++ ++grep -Eiq -- 'usage|error' err || fail "F7 stderr missing omit-prefix usage error: $(cat err)" ++[ ! -e demo-wrap.h ] || fail "F7 unexpectedly created demo-wrap.h" ++[ ! -e demo-wrap.c ] || fail "F7 unexpectedly created demo-wrap.c" ++ ++ ++ ++ ++cd "$TMP"; mkdir F8; cd F8 || exit 1 ++cat > public.h <<'EOF' ++int public_api(void); ++EOF ++run_tool --include public.h --sys-include public.h --soname libdemo.so --init-name demo --output-header demo-wrap.h --output-implementation demo-wrap.c --ignore-headers ++[ "$ec" -ne 0 ] || fail "F8 exit $ec; want nonzero" ++[ ! -s out ] || fail "F8 stdout should be empty: $(cat out)" ++ ++grep -Eiq -- 'usage|error' err || fail "F8 stderr missing ignore-headers usage error: $(cat err)" ++[ ! -e demo-wrap.h ] || fail "F8 unexpectedly created demo-wrap.h" ++[ ! -e demo-wrap.c ] || fail "F8 unexpectedly created demo-wrap.c" ++ ++echo "PASS" ++exit 0 +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,12 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++exec bash /workspace/repo/usercase-test-coderl/usecase.sh diff --git a/tasks/format-code-task-001524/tests/test.sh b/tasks/format-code-task-001524/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d4d80bb634b14076ae561be99f395189577b7ac6 --- /dev/null +++ b/tasks/format-code-task-001524/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/usecase.sh +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001524/tests/test_command.sh b/tasks/format-code-task-001524/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001524/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001541/environment/Dockerfile b/tasks/format-code-task-001541/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..bcea7b6c54750b4784faa132304bae11078844d3 --- /dev/null +++ b/tasks/format-code-task-001541/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:0608844e1c5f40da080bc07610ac0ec8e1ed49462d60c5ad3d8099174ed097e9 diff --git a/tasks/format-code-task-001541/environment/setup/files/blocklist b/tasks/format-code-task-001541/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001541/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001541/environment/setup/setup.sh b/tasks/format-code-task-001541/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001541/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001541/tests/test.patch b/tasks/format-code-task-001541/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..71885de732a3c0410b3bf125ce74f66729d843af --- /dev/null +++ b/tasks/format-code-task-001541/tests/test.patch @@ -0,0 +1,2228 @@ +diff --git a/pkg/client/didexchange/client_test.go b/pkg/client/didexchange/client_test.go +index 06f04890a..3337122f7 100644 +--- a/pkg/client/didexchange/client_test.go ++++ b/pkg/client/didexchange/client_test.go +@@ -47,8 +47,8 @@ func TestNew(t *testing.T) { + require.NotNil(t, svc) + + _, err = New(&mockprovider.Provider{ +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: mockstore.NewMockStoreProvider(), + ServiceMap: map[string]interface{}{ + didexchange.DIDExchange: svc, + mediator.Coordination: &mockroute.MockMediatorSvc{}, +@@ -71,8 +71,8 @@ func TestNew(t *testing.T) { + + t.Run("test route service cast error", func(t *testing.T) { + _, err := New(&mockprovider.Provider{ +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: mockstore.NewMockStoreProvider(), + ServiceMap: map[string]interface{}{ + didexchange.DIDExchange: &mocksvc.MockDIDExchangeSvc{}, + mediator.Coordination: &mocksvc.MockDIDExchangeSvc{}, +@@ -92,7 +92,7 @@ func TestNew(t *testing.T) { + require.NotNil(t, svc) + + _, err = New(&mockprovider.Provider{ +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), + StorageProviderValue: &mockstore.MockStoreProvider{ + ErrOpenStoreHandle: fmt.Errorf("failed to open store")}, + ServiceMap: map[string]interface{}{ +@@ -104,7 +104,7 @@ func TestNew(t *testing.T) { + require.Contains(t, err.Error(), "failed to open store") + }) + +- t.Run("test error from open transient store", func(t *testing.T) { ++ t.Run("test error from open protocol state store", func(t *testing.T) { + svc, err := didexchange.New(&mockprotocol.MockProvider{ + ServiceMap: map[string]interface{}{ + mediator.Coordination: &mockroute.MockMediatorSvc{}, +@@ -115,15 +115,15 @@ func TestNew(t *testing.T) { + + _, err = New(&mockprovider.Provider{ + StorageProviderValue: mockstore.NewMockStoreProvider(), +- TransientStorageProviderValue: &mockstore.MockStoreProvider{ +- ErrOpenStoreHandle: fmt.Errorf("failed to open transient store")}, ++ ProtocolStateStorageProviderValue: &mockstore.MockStoreProvider{ ++ ErrOpenStoreHandle: fmt.Errorf("failed to open protocol state store")}, + ServiceMap: map[string]interface{}{ + didexchange.DIDExchange: svc, + mediator.Coordination: &mockroute.MockMediatorSvc{}, + }, + ServiceEndpointValue: "endpoint"}) + require.Error(t, err) +- require.Contains(t, err.Error(), "failed to open transient store") ++ require.Contains(t, err.Error(), "failed to open protocol state store") + }) + } + +@@ -138,8 +138,8 @@ func TestClient_CreateInvitation(t *testing.T) { + require.NotNil(t, svc) + + c, err := New(&mockprovider.Provider{ +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: mockstore.NewMockStoreProvider(), + ServiceMap: map[string]interface{}{ + didexchange.DIDExchange: svc, + mediator.Coordination: &mockroute.MockMediatorSvc{}, +@@ -167,8 +167,8 @@ func TestClient_CreateInvitation(t *testing.T) { + require.NotNil(t, svc) + + c, err := New(&mockprovider.Provider{ +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: mockstore.NewMockStoreProvider(), + ServiceMap: map[string]interface{}{ + didexchange.DIDExchange: svc, + mediator.Coordination: &mockroute.MockMediatorSvc{}, +@@ -196,8 +196,8 @@ func TestClient_CreateInvitation(t *testing.T) { + require.NotNil(t, svc) + + c, err := New(&mockprovider.Provider{ +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- StorageProviderValue: mockstore.NewCustomMockStoreProvider(store), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: mockstore.NewCustomMockStoreProvider(store), + ServiceMap: map[string]interface{}{ + didexchange.DIDExchange: svc, + mediator.Coordination: &mockroute.MockMediatorSvc{}, +@@ -222,8 +222,8 @@ func TestClient_CreateInvitation(t *testing.T) { + require.NotNil(t, svc) + + c, err := New(&mockprovider.Provider{ +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: mockstore.NewMockStoreProvider(), + ServiceMap: map[string]interface{}{ + didexchange.DIDExchange: svc, + mediator.Coordination: &mockroute.MockMediatorSvc{RoutingKeys: routingKeys, RouterEndpoint: endpoint}, +@@ -252,8 +252,8 @@ func TestClient_CreateInvitation(t *testing.T) { + require.NotNil(t, svc) + + c, err := New(&mockprovider.Provider{ +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: mockstore.NewMockStoreProvider(), + ServiceMap: map[string]interface{}{ + didexchange.DIDExchange: svc, + mediator.Coordination: &mockroute.MockMediatorSvc{ConfigErr: errors.New("router config error")}, +@@ -282,8 +282,8 @@ func TestClient_CreateInvitation(t *testing.T) { + require.NotNil(t, svc) + + c, err := New(&mockprovider.Provider{ +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: mockstore.NewMockStoreProvider(), + ServiceMap: map[string]interface{}{ + didexchange.DIDExchange: svc, + mediator.Coordination: &mockroute.MockMediatorSvc{ +@@ -315,8 +315,8 @@ func TestClient_CreateInvitationWithDID(t *testing.T) { + require.NotNil(t, svc) + + c, err := New(&mockprovider.Provider{ +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: mockstore.NewMockStoreProvider(), + ServiceMap: map[string]interface{}{ + didexchange.DIDExchange: svc, + mediator.Coordination: &mockroute.MockMediatorSvc{}, +@@ -351,8 +351,8 @@ func TestClient_CreateInvitationWithDID(t *testing.T) { + require.NotNil(t, svc) + + c, err := New(&mockprovider.Provider{ +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- StorageProviderValue: mockstore.NewCustomMockStoreProvider(store), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: mockstore.NewCustomMockStoreProvider(store), + ServiceMap: map[string]interface{}{ + didexchange.DIDExchange: svc, + mediator.Coordination: &mockroute.MockMediatorSvc{}, +@@ -382,8 +382,8 @@ func TestClient_QueryConnectionByID(t *testing.T) { + require.NotNil(t, svc) + + c, err := New(&mockprovider.Provider{ +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: mockstore.NewMockStoreProvider(), + ServiceMap: map[string]interface{}{ + didexchange.DIDExchange: svc, + mediator.Coordination: &mockroute.MockMediatorSvc{}, +@@ -418,8 +418,8 @@ func TestClient_QueryConnectionByID(t *testing.T) { + } + + c, err := New(&mockprovider.Provider{ +- TransientStorageProviderValue: mockstore.NewCustomMockStoreProvider(store), +- StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewCustomMockStoreProvider(store), ++ StorageProviderValue: mockstore.NewMockStoreProvider(), + ServiceMap: map[string]interface{}{ + didexchange.DIDExchange: svc, + mediator.Coordination: &mockroute.MockMediatorSvc{}, +@@ -447,8 +447,8 @@ func TestClient_QueryConnectionByID(t *testing.T) { + require.NotNil(t, svc) + + c, err := New(&mockprovider.Provider{ +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: mockstore.NewMockStoreProvider(), + ServiceMap: map[string]interface{}{ + didexchange.DIDExchange: svc, + mediator.Coordination: &mockroute.MockMediatorSvc{}, +@@ -478,8 +478,8 @@ func TestClient_GetConnection(t *testing.T) { + require.NotNil(t, svc) + s := &mockstore.MockStore{Store: make(map[string][]byte), ErrGet: ErrConnectionNotFound} + c, err := New(&mockprovider.Provider{ +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: mockstore.NewMockStoreProvider(), + ServiceMap: map[string]interface{}{ + didexchange.DIDExchange: svc, + mediator.Coordination: &mockroute.MockMediatorSvc{}, +@@ -508,8 +508,8 @@ func TestClientGetConnectionAtState(t *testing.T) { + + // create client + c, err := New(&mockprovider.Provider{ +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: mockstore.NewMockStoreProvider(), + ServiceMap: map[string]interface{}{ + didexchange.DIDExchange: svc, + mediator.Coordination: &mockroute.MockMediatorSvc{}, +@@ -534,12 +534,12 @@ func TestClient_CreateConnection(t *testing.T) { + invitationDID := newPeerDID(t).ID + implicit := true + storageProvider := &mockprovider.Provider{ +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: mockstore.NewMockStoreProvider(), + } + c, err := New(&mockprovider.Provider{ +- TransientStorageProviderValue: storageProvider.TransientStorageProvider(), +- StorageProviderValue: storageProvider.StorageProvider(), ++ ProtocolStateStorageProviderValue: storageProvider.ProtocolStateStorageProvider(), ++ StorageProviderValue: storageProvider.StorageProvider(), + ServiceMap: map[string]interface{}{ + didexchange.DIDExchange: &mocksvc.MockDIDExchangeSvc{ + CreateConnRecordFunc: func(r *connection.Record, td *did.Doc) error { +@@ -577,8 +577,8 @@ func TestClient_CreateConnection(t *testing.T) { + + t.Run("test create connection - error", func(t *testing.T) { + c, err := New(&mockprovider.Provider{ +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: mockstore.NewMockStoreProvider(), + ServiceMap: map[string]interface{}{ + didexchange.DIDExchange: &mocksvc.MockDIDExchangeSvc{ + CreateConnRecordFunc: func(*connection.Record, *did.Doc) error { +@@ -611,8 +611,8 @@ func TestClient_RemoveConnection(t *testing.T) { + require.NotNil(t, svc) + + c, err := New(&mockprovider.Provider{ +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: mockstore.NewMockStoreProvider(), + ServiceMap: map[string]interface{}{ + didexchange.DIDExchange: svc, + mediator.Coordination: &mockroute.MockMediatorSvc{}, +@@ -644,8 +644,8 @@ func TestClient_RemoveConnection(t *testing.T) { + require.NoError(t, err) + require.NotNil(t, svc) + c, err := New(&mockprovider.Provider{ +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: mockstore.NewMockStoreProvider(), + ServiceMap: map[string]interface{}{ + didexchange.DIDExchange: svc, + mediator.Coordination: &mockroute.MockMediatorSvc{}, +@@ -662,8 +662,8 @@ func TestClient_RemoveConnection(t *testing.T) { + func TestClient_HandleInvitation(t *testing.T) { + t.Run("test success", func(t *testing.T) { + c, err := New(&mockprovider.Provider{ +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: mockstore.NewMockStoreProvider(), + ServiceMap: map[string]interface{}{ + didexchange.DIDExchange: &mocksvc.MockDIDExchangeSvc{}, + mediator.Coordination: &mockroute.MockMediatorSvc{}, +@@ -682,8 +682,8 @@ func TestClient_HandleInvitation(t *testing.T) { + + t.Run("test error from handle msg", func(t *testing.T) { + c, err := New(&mockprovider.Provider{ +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: mockstore.NewMockStoreProvider(), + ServiceMap: map[string]interface{}{ + didexchange.DIDExchange: &mocksvc.MockDIDExchangeSvc{HandleFunc: func(msg service.DIDCommMsg) (string, error) { + return "", fmt.Errorf("handle error") +@@ -705,8 +705,8 @@ func TestClient_HandleInvitation(t *testing.T) { + func TestClient_CreateImplicitInvitation(t *testing.T) { + t.Run("test success", func(t *testing.T) { + c, err := New(&mockprovider.Provider{ +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: mockstore.NewMockStoreProvider(), + ServiceMap: map[string]interface{}{ + didexchange.DIDExchange: &mocksvc.MockDIDExchangeSvc{}, + mediator.Coordination: &mockroute.MockMediatorSvc{}, +@@ -722,8 +722,8 @@ func TestClient_CreateImplicitInvitation(t *testing.T) { + + t.Run("test error from service", func(t *testing.T) { + c, err := New(&mockprovider.Provider{ +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: mockstore.NewMockStoreProvider(), + ServiceMap: map[string]interface{}{ + didexchange.DIDExchange: &mocksvc.MockDIDExchangeSvc{ + ImplicitInvitationErr: errors.New("implicit error")}, +@@ -746,8 +746,8 @@ func TestClient_CreateImplicitInvitationWithDID(t *testing.T) { + + t.Run("test success", func(t *testing.T) { + c, err := New(&mockprovider.Provider{ +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: mockstore.NewMockStoreProvider(), + ServiceMap: map[string]interface{}{ + didexchange.DIDExchange: &mocksvc.MockDIDExchangeSvc{}, + mediator.Coordination: &mockroute.MockMediatorSvc{}, +@@ -763,8 +763,8 @@ func TestClient_CreateImplicitInvitationWithDID(t *testing.T) { + + t.Run("test error from service", func(t *testing.T) { + c, err := New(&mockprovider.Provider{ +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: mockstore.NewMockStoreProvider(), + ServiceMap: map[string]interface{}{ + didexchange.DIDExchange: &mocksvc.MockDIDExchangeSvc{ + ImplicitInvitationErr: errors.New("implicit with DID error")}, +@@ -782,8 +782,8 @@ func TestClient_CreateImplicitInvitationWithDID(t *testing.T) { + + t.Run("test missing required DID info", func(t *testing.T) { + c, err := New(&mockprovider.Provider{ +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: mockstore.NewMockStoreProvider(), + ServiceMap: map[string]interface{}{ + didexchange.DIDExchange: &mocksvc.MockDIDExchangeSvc{}, + mediator.Coordination: &mockroute.MockMediatorSvc{}, +@@ -816,8 +816,8 @@ func TestClient_QueryConnectionsByParams(t *testing.T) { + + storageProvider := mockstore.NewMockStoreProvider() + c, err := New(&mockprovider.Provider{ +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- StorageProviderValue: storageProvider, ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: storageProvider, + ServiceMap: map[string]interface{}{ + didexchange.DIDExchange: svc, + mediator.Coordination: &mockroute.MockMediatorSvc{}, +@@ -856,8 +856,8 @@ func TestClient_QueryConnectionsByParams(t *testing.T) { + + storageProvider := mockstore.NewMockStoreProvider() + c, err := New(&mockprovider.Provider{ +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- StorageProviderValue: storageProvider, ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: storageProvider, + ServiceMap: map[string]interface{}{ + didexchange.DIDExchange: svc, + mediator.Coordination: &mockroute.MockMediatorSvc{}, +@@ -946,8 +946,8 @@ func TestClient_QueryConnectionsByParams(t *testing.T) { + + storageProvider := mockstore.NewMockStoreProvider() + c, err := New(&mockprovider.Provider{ +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- StorageProviderValue: storageProvider, ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: storageProvider, + ServiceMap: map[string]interface{}{ + didexchange.DIDExchange: svc, + mediator.Coordination: &mockroute.MockMediatorSvc{}, +@@ -964,11 +964,11 @@ func TestClient_QueryConnectionsByParams(t *testing.T) { + } + + func TestServiceEvents(t *testing.T) { +- transientStore := mockstore.NewMockStoreProvider() ++ protocolStateStore := mockstore.NewMockStoreProvider() + store := mockstore.NewMockStoreProvider() + didExSvc, err := didexchange.New(&mockprotocol.MockProvider{ +- TransientStoreProvider: transientStore, +- StoreProvider: store, ++ ProtocolStateStoreProvider: protocolStateStore, ++ StoreProvider: store, + ServiceMap: map[string]interface{}{ + mediator.Coordination: &mockroute.MockMediatorSvc{}, + }, +@@ -977,8 +977,8 @@ func TestServiceEvents(t *testing.T) { + + // create the client + c, err := New(&mockprovider.Provider{ +- TransientStorageProviderValue: transientStore, +- StorageProviderValue: store, ++ ProtocolStateStorageProviderValue: protocolStateStore, ++ StorageProviderValue: store, + ServiceMap: map[string]interface{}{ + didexchange.DIDExchange: didExSvc, + mediator.Coordination: &mockroute.MockMediatorSvc{}, +@@ -1068,8 +1068,8 @@ func TestAcceptExchangeRequest(t *testing.T) { + + // create the client + c, err := New(&mockprovider.Provider{ +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- StorageProviderValue: store, ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: store, + ServiceMap: map[string]interface{}{ + didexchange.DIDExchange: didExSvc, + mediator.Coordination: &mockroute.MockMediatorSvc{}, +@@ -1161,8 +1161,8 @@ func TestAcceptInvitation(t *testing.T) { + + // create the client + c, err := New(&mockprovider.Provider{ +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- StorageProviderValue: store, ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: store, + ServiceMap: map[string]interface{}{ + didexchange.DIDExchange: didExSvc, + mediator.Coordination: &mockroute.MockMediatorSvc{}, +diff --git a/pkg/client/didexchange/example_test.go b/pkg/client/didexchange/example_test.go +index f7ece51f2..9f8eabe53 100644 +--- a/pkg/client/didexchange/example_test.go ++++ b/pkg/client/didexchange/example_test.go +@@ -122,11 +122,11 @@ func ExampleClient_CreateInvitationWithDID() { + } + + func mockContext() provider { +- transientStoreProvider := mockstore.NewMockStoreProvider() ++ protocolStateStoreProvider := mockstore.NewMockStoreProvider() + storeProvider := mockstore.NewMockStoreProvider() + mockProvider := &mockprotocol.MockProvider{ +- TransientStoreProvider: transientStoreProvider, +- StoreProvider: storeProvider, ++ ProtocolStateStoreProvider: protocolStateStoreProvider, ++ StoreProvider: storeProvider, + ServiceMap: map[string]interface{}{ + mediator.Coordination: &mockroute.MockMediatorSvc{}, + }, +@@ -138,9 +138,9 @@ func mockContext() provider { + } + + context := &mockprovider.Provider{ +- LegacyKMSValue: &mockkms.CloseableKMS{CreateSigningKeyValue: "sample-key"}, +- TransientStorageProviderValue: transientStoreProvider, +- StorageProviderValue: storeProvider, ++ LegacyKMSValue: &mockkms.CloseableKMS{CreateSigningKeyValue: "sample-key"}, ++ ProtocolStateStorageProviderValue: protocolStateStoreProvider, ++ StorageProviderValue: storeProvider, + ServiceMap: map[string]interface{}{ + didexchange.DIDExchange: svc, + mediator.Coordination: &mockroute.MockMediatorSvc{}, +diff --git a/pkg/client/mediator/example_test.go b/pkg/client/mediator/example_test.go +index 28d5e61ed..600eaa3c0 100644 +--- a/pkg/client/mediator/example_test.go ++++ b/pkg/client/mediator/example_test.go +@@ -101,11 +101,11 @@ func performDIDExchangeWithRouter(client *didexClient.Client) string { + } + + func didClientMockContext() *mockprovider.Provider { +- transientStoreProvider := mockstore.NewMockStoreProvider() ++ protocolStateStoreProvider := mockstore.NewMockStoreProvider() + storeProvider := mockstore.NewMockStoreProvider() + mockProvider := &mockprotocol.MockProvider{ +- TransientStoreProvider: transientStoreProvider, +- StoreProvider: storeProvider, ++ ProtocolStateStoreProvider: protocolStateStoreProvider, ++ StoreProvider: storeProvider, + ServiceMap: map[string]interface{}{ + mediator.Coordination: &mockroute.MockMediatorSvc{}, + }, +@@ -117,9 +117,9 @@ func didClientMockContext() *mockprovider.Provider { + } + + context := &mockprovider.Provider{ +- LegacyKMSValue: &mockkms.CloseableKMS{CreateSigningKeyValue: "sample-key"}, +- TransientStorageProviderValue: transientStoreProvider, +- StorageProviderValue: storeProvider, ++ LegacyKMSValue: &mockkms.CloseableKMS{CreateSigningKeyValue: "sample-key"}, ++ ProtocolStateStorageProviderValue: protocolStateStoreProvider, ++ StorageProviderValue: storeProvider, + ServiceMap: map[string]interface{}{ + didexchange.DIDExchange: svc, + mediator.Coordination: routeService(), +diff --git a/pkg/client/outofband/client_test.go b/pkg/client/outofband/client_test.go +index 5a8d3a8eb..309096071 100644 +--- a/pkg/client/outofband/client_test.go ++++ b/pkg/client/outofband/client_test.go +@@ -512,9 +512,9 @@ type didcommMsg struct { + + func withTestProvider() *mockprovider.Provider { + return &mockprovider.Provider{ +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- StorageProviderValue: mockstore.NewMockStoreProvider(), +- LegacyKMSValue: &mockkms.CloseableKMS{CreateEncryptionKeyValue: "sample-key"}, ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: mockstore.NewMockStoreProvider(), ++ LegacyKMSValue: &mockkms.CloseableKMS{CreateEncryptionKeyValue: "sample-key"}, + ServiceMap: map[string]interface{}{ + mediator.Coordination: &mockroute.MockMediatorSvc{}, + outofband.Name: &stubOOBService{}, +diff --git a/pkg/client/outofband/example_test.go b/pkg/client/outofband/example_test.go +index 826326626..6403eb998 100644 +--- a/pkg/client/outofband/example_test.go ++++ b/pkg/client/outofband/example_test.go +@@ -293,9 +293,9 @@ func ExampleClient_AcceptInvitation() { //nolint:gocyclo,gocognit + + func getContext(agent string) *mockprovider.Provider { + return &mockprovider.Provider{ +- LegacyKMSValue: &mocklegacykms.CloseableKMS{}, +- StorageProviderValue: mem.NewProvider(), +- TransientStorageProviderValue: mem.NewProvider(), ++ LegacyKMSValue: &mocklegacykms.CloseableKMS{}, ++ StorageProviderValue: mem.NewProvider(), ++ ProtocolStateStorageProviderValue: mem.NewProvider(), + ServiceMap: map[string]interface{}{ + outofband.Name: &stubOOBService{ + Event: nil, +diff --git a/pkg/controller/command/didexchange/command_test.go b/pkg/controller/command/didexchange/command_test.go +index 9c482808d..28872c8fb 100644 +--- a/pkg/controller/command/didexchange/command_test.go ++++ b/pkg/controller/command/didexchange/command_test.go +@@ -500,7 +500,7 @@ func TestCommand_AcceptInvitation(t *testing.T) { + t.Run("test accept invitation complete flow", func(t *testing.T) { + store := mockstore.NewMockStoreProvider() + didExSvc, err := didexsvc.New(&protocol.MockProvider{ +- TransientStoreProvider: store, ++ ProtocolStateStoreProvider: store, + ServiceMap: map[string]interface{}{ + mediator.Coordination: &mockroute.MockMediatorSvc{}, + }, +@@ -513,8 +513,8 @@ func TestCommand_AcceptInvitation(t *testing.T) { + + // create the client + cmd, err := New(&mockprovider.Provider{ +- TransientStorageProviderValue: store, +- StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: store, ++ StorageProviderValue: mockstore.NewMockStoreProvider(), + ServiceMap: map[string]interface{}{ + didexsvc.DIDExchange: didExSvc, + mediator.Coordination: &mockroute.MockMediatorSvc{}, +@@ -721,11 +721,11 @@ func TestCommand_AcceptExchangeRequest(t *testing.T) { + }) + + t.Run("test accept exchange request complete flow", func(t *testing.T) { +- transientStore := mockstore.NewMockStoreProvider() ++ protocolStateStore := mockstore.NewMockStoreProvider() + store := mockstore.NewMockStoreProvider() + didExSvc, err := didexsvc.New( + &protocol.MockProvider{ +- TransientStoreProvider: transientStore, StoreProvider: store, ++ ProtocolStateStoreProvider: protocolStateStore, StoreProvider: store, + ServiceMap: map[string]interface{}{ + mediator.Coordination: &mockroute.MockMediatorSvc{}, + }, +@@ -739,8 +739,8 @@ func TestCommand_AcceptExchangeRequest(t *testing.T) { + + // create the client + cmd, err := New(&mockprovider.Provider{ +- TransientStorageProviderValue: transientStore, +- StorageProviderValue: store, ++ ProtocolStateStorageProviderValue: protocolStateStore, ++ StorageProviderValue: store, + ServiceMap: map[string]interface{}{ + didexsvc.DIDExchange: didExSvc, + mediator.Coordination: &mockroute.MockMediatorSvc{}, +@@ -930,8 +930,8 @@ func TestCommand_RemoveConnection(t *testing.T) { + + func mockProvider() *mockprovider.Provider { + return &mockprovider.Provider{ +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: mockstore.NewMockStoreProvider(), + ServiceMap: map[string]interface{}{ + didexsvc.DIDExchange: &mockdidexchange.MockDIDExchangeSvc{}, + mediator.Coordination: &mockroute.MockMediatorSvc{}, +diff --git a/pkg/controller/rest/didexchange/operation_test.go b/pkg/controller/rest/didexchange/operation_test.go +index 0ce6a6455..a237e120b 100644 +--- a/pkg/controller/rest/didexchange/operation_test.go ++++ b/pkg/controller/rest/didexchange/operation_test.go +@@ -43,8 +43,8 @@ import ( + + func TestOperation_GetAPIHandlers(t *testing.T) { + svc, err := New(&mockprovider.Provider{ +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: mockstore.NewMockStoreProvider(), + ServiceMap: map[string]interface{}{ + didexsvc.DIDExchange: &mockdidexchange.MockDIDExchangeSvc{}, + mediator.Coordination: &mockroute.MockMediatorSvc{}, +@@ -409,8 +409,8 @@ func TestEmptyID(t *testing.T) { + const response = `{"code":2000,"message":"empty connection ID"}` + + prov := &mockprovider.Provider{ +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: mockstore.NewMockStoreProvider(), + ServiceMap: map[string]interface{}{ + didexsvc.DIDExchange: &mockdidexchange.MockDIDExchangeSvc{}, + mediator.Coordination: &mockroute.MockMediatorSvc{}, +@@ -477,7 +477,7 @@ type fails struct { + } + + func getHandlerWithError(t *testing.T, lookup string, f *fails) rest.Handler { +- transientStore := mockstore.MockStore{Store: make(map[string][]byte)} ++ protocolStateStore := mockstore.MockStore{Store: make(map[string][]byte)} + store := mockstore.MockStore{Store: make(map[string][]byte)} + connRec := &connection.Record{State: "complete", ConnectionID: "1234", ThreadID: "th1234"} + +@@ -508,10 +508,10 @@ func getHandlerWithError(t *testing.T, lookup string, f *fails) rest.Handler { + }, + mediator.Coordination: &mockroute.MockMediatorSvc{}, + }, +- LegacyKMSValue: &mockkms.CloseableKMS{CreateEncryptionKeyValue: "sample-key"}, +- ServiceEndpointValue: "endpoint", +- TransientStorageProviderValue: &mockstore.MockStoreProvider{Store: &transientStore}, +- StorageProviderValue: &mockstore.MockStoreProvider{Store: &store}}, ++ LegacyKMSValue: &mockkms.CloseableKMS{CreateEncryptionKeyValue: "sample-key"}, ++ ServiceEndpointValue: "endpoint", ++ ProtocolStateStorageProviderValue: &mockstore.MockStoreProvider{Store: &protocolStateStore}, ++ StorageProviderValue: &mockstore.MockStoreProvider{Store: &store}}, + webnotifier.NewHTTPNotifier(nil), + "", true, + ) +diff --git a/pkg/didcomm/protocol/didexchange/persistence_test.go b/pkg/didcomm/protocol/didexchange/persistence_test.go +index 686682e73..a6bddea88 100644 +--- a/pkg/didcomm/protocol/didexchange/persistence_test.go ++++ b/pkg/didcomm/protocol/didexchange/persistence_test.go +@@ -68,7 +68,7 @@ func TestConnectionRecorder_SaveConnectionRecord(t *testing.T) { + t.Run("save connection record error", func(t *testing.T) { + const errMsg = "get error" + record, err := newConnectionStore(&protocol.MockProvider{ +- TransientStoreProvider: mockstorage.NewCustomMockStoreProvider(&mockstorage.MockStore{ ++ ProtocolStateStoreProvider: mockstorage.NewCustomMockStoreProvider(&mockstorage.MockStore{ + Store: make(map[string][]byte), + ErrPut: fmt.Errorf(errMsg), + }), +@@ -82,7 +82,7 @@ func TestConnectionRecorder_SaveConnectionRecord(t *testing.T) { + t.Run("save connection record error", func(t *testing.T) { + const errMsg = "get error" + record, err := newConnectionStore(&protocol.MockProvider{ +- TransientStoreProvider: mockstorage.NewCustomMockStoreProvider(&mockstorage.MockStore{ ++ ProtocolStateStoreProvider: mockstorage.NewCustomMockStoreProvider(&mockstorage.MockStore{ + Store: make(map[string][]byte), + ErrPut: fmt.Errorf(errMsg), + }), +diff --git a/pkg/didcomm/protocol/didexchange/service_test.go b/pkg/didcomm/protocol/didexchange/service_test.go +index 74e75f374..4893fbf91 100644 +--- a/pkg/didcomm/protocol/didexchange/service_test.go ++++ b/pkg/didcomm/protocol/didexchange/service_test.go +@@ -68,12 +68,12 @@ func TestServiceNew(t *testing.T) { + require.Contains(t, err.Error(), "failed to open store") + }) + +- t.Run("test error from open transient store", func(t *testing.T) { ++ t.Run("test error from open protocol state store", func(t *testing.T) { + _, err := New( +- &protocol.MockProvider{TransientStoreProvider: &mockstorage.MockStoreProvider{ +- ErrOpenStoreHandle: fmt.Errorf("failed to open transient store")}}) ++ &protocol.MockProvider{ProtocolStateStoreProvider: &mockstorage.MockStoreProvider{ ++ ErrOpenStoreHandle: fmt.Errorf("failed to open protocol state store")}}) + require.Error(t, err) +- require.Contains(t, err.Error(), "failed to open transient store") ++ require.Contains(t, err.Error(), "failed to open protocol state store") + }) + + t.Run("test service new error - no route service found", func(t *testing.T) { +@@ -233,10 +233,10 @@ func msgEventListener(t *testing.T, statusCh chan service.StateMsg, respondedFla + + // did-exchange flow with role Invitee + func TestService_Handle_Invitee(t *testing.T) { +- transientStore := mockstorage.NewMockStoreProvider() ++ protocolStateStore := mockstorage.NewMockStoreProvider() + store := mockstorage.NewMockStoreProvider() + prov := &protocol.MockProvider{StoreProvider: store, +- TransientStoreProvider: transientStore, ++ ProtocolStateStoreProvider: protocolStateStore, + ServiceMap: map[string]interface{}{ + mediator.Coordination: &mockroute.MockMediatorSvc{}, + }, +@@ -398,9 +398,9 @@ func TestService_Handle_EdgeCases(t *testing.T) { + }) + + t.Run("handleInbound - connection record error", func(t *testing.T) { +- transientStore := &mockstorage.MockStore{Store: make(map[string][]byte), ErrPut: errors.New("db error")} ++ protocolStateStore := &mockstorage.MockStore{Store: make(map[string][]byte), ErrPut: errors.New("db error")} + prov := &protocol.MockProvider{ +- TransientStoreProvider: mockstorage.NewCustomMockStoreProvider(transientStore), ++ ProtocolStateStoreProvider: mockstorage.NewCustomMockStoreProvider(protocolStateStore), + ServiceMap: map[string]interface{}{ + mediator.Coordination: &mockroute.MockMediatorSvc{}, + }, +@@ -432,7 +432,7 @@ func TestService_Handle_EdgeCases(t *testing.T) { + err = svc.RegisterActionEvent(make(chan service.DIDCommAction)) + require.NoError(t, err) + +- transientStore := &mockStore{ ++ protocolStateStore := &mockStore{ + get: func(s string) (bytes []byte, e error) { + return nil, storage.ErrDataNotFound + }, +@@ -446,7 +446,7 @@ func TestService_Handle_EdgeCases(t *testing.T) { + } + + svc.connectionStore, err = newConnectionStore(&protocol.MockProvider{ +- TransientStoreProvider: mockstorage.NewCustomMockStoreProvider(transientStore), ++ ProtocolStateStoreProvider: mockstorage.NewCustomMockStoreProvider(protocolStateStore), + }) + require.NotNil(t, svc.connectionStore) + require.NoError(t, err) +@@ -508,7 +508,7 @@ func TestService_CurrentState(t *testing.T) { + require.NoError(t, err) + + connectionStore, err := newConnectionStore(&protocol.MockProvider{ +- TransientStoreProvider: mockstorage.NewCustomMockStoreProvider(&mockStore{ ++ ProtocolStateStoreProvider: mockstorage.NewCustomMockStoreProvider(&mockStore{ + get: func(string) ([]byte, error) { return connRec, nil }, + }), + }) +@@ -527,7 +527,7 @@ func TestService_CurrentState(t *testing.T) { + + t.Run("forwards generic error from store", func(t *testing.T) { + connectionStore, err := newConnectionStore(&protocol.MockProvider{ +- TransientStoreProvider: mockstorage.NewCustomMockStoreProvider(&mockStore{ ++ ProtocolStateStoreProvider: mockstorage.NewCustomMockStoreProvider(&mockStore{ + get: func(string) ([]byte, error) { + return nil, errors.New("test") + }, +@@ -595,13 +595,13 @@ func TestCreateConnection(t *testing.T) { + } + storedInVDRI := false + storageProvider := &mockprovider.Provider{ +- StorageProviderValue: mockstorage.NewMockStoreProvider(), +- TransientStorageProviderValue: mockstorage.NewMockStoreProvider(), ++ StorageProviderValue: mockstorage.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstorage.NewMockStoreProvider(), + } + provider := &mockprovider.Provider{ +- LegacyKMSValue: &mocklegacykms.CloseableKMS{}, +- StorageProviderValue: storageProvider.StorageProvider(), +- TransientStorageProviderValue: storageProvider.TransientStorageProvider(), ++ LegacyKMSValue: &mocklegacykms.CloseableKMS{}, ++ StorageProviderValue: storageProvider.StorageProvider(), ++ ProtocolStateStorageProviderValue: storageProvider.ProtocolStateStorageProvider(), + VDRIRegistryValue: &mockvdri.MockVDRIRegistry{ + StoreFunc: func(result *did.Doc) error { + storedInVDRI = true +@@ -631,9 +631,9 @@ func TestCreateConnection(t *testing.T) { + t.Run("wraps vdri registry error", func(t *testing.T) { + expected := errors.New("test") + s, err := New(&mockprovider.Provider{ +- LegacyKMSValue: &mocklegacykms.CloseableKMS{}, +- StorageProviderValue: mockstorage.NewMockStoreProvider(), +- TransientStorageProviderValue: mockstorage.NewMockStoreProvider(), ++ LegacyKMSValue: &mocklegacykms.CloseableKMS{}, ++ StorageProviderValue: mockstorage.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstorage.NewMockStoreProvider(), + VDRIRegistryValue: &mockvdri.MockVDRIRegistry{ + PutErr: expected, + }, +@@ -655,8 +655,8 @@ func TestCreateConnection(t *testing.T) { + StorageProviderValue: &mockstorage.MockStoreProvider{ + Store: &mockstorage.MockStore{ErrPut: expected}, + }, +- TransientStorageProviderValue: mockstorage.NewMockStoreProvider(), +- VDRIRegistryValue: &mockvdri.MockVDRIRegistry{}, ++ ProtocolStateStorageProviderValue: mockstorage.NewMockStoreProvider(), ++ VDRIRegistryValue: &mockvdri.MockVDRIRegistry{}, + ServiceMap: map[string]interface{}{ + mediator.Coordination: &mockroute.MockMediatorSvc{}, + }, +@@ -944,7 +944,7 @@ func TestServiceErrors(t *testing.T) { + }} + + prov := &protocol.MockProvider{ +- TransientStoreProvider: mockstorage.NewCustomMockStoreProvider( ++ ProtocolStateStoreProvider: mockstorage.NewCustomMockStoreProvider( + mockStore, + ), + ServiceMap: map[string]interface{}{ +@@ -1066,7 +1066,7 @@ func TestInvitationRecord(t *testing.T) { + + // db error + svc, err = New(&protocol.MockProvider{ +- TransientStoreProvider: mockstorage.NewCustomMockStoreProvider(&mockstorage.MockStore{ ++ ProtocolStateStoreProvider: mockstorage.NewCustomMockStoreProvider(&mockstorage.MockStore{ + Store: make(map[string][]byte), ErrPut: errors.New("db error"), + }), + ServiceMap: map[string]interface{}{ +@@ -1110,7 +1110,7 @@ func TestRequestRecord(t *testing.T) { + + t.Run("fails on db error", func(t *testing.T) { + svc, err := New(&protocol.MockProvider{ +- TransientStoreProvider: mockstorage.NewCustomMockStoreProvider( ++ ProtocolStateStoreProvider: mockstorage.NewCustomMockStoreProvider( + &mockstorage.MockStore{Store: make(map[string][]byte), ErrPut: errors.New("db error")}, + ), + ServiceMap: map[string]interface{}{ +@@ -1343,7 +1343,7 @@ func TestAcceptInvitation(t *testing.T) { + + err = svc.AcceptInvitation(generateRandomID(), "", "") + require.Error(t, err) +- require.Contains(t, err.Error(), "accept exchange invitation : get transient data : data not found") ++ require.Contains(t, err.Error(), "accept exchange invitation : get protocol state data : data not found") + }) + + t.Run("accept invitation - state error", func(t *testing.T) { +@@ -1362,7 +1362,7 @@ func TestAcceptInvitation(t *testing.T) { + err = svc.connectionStore.saveConnectionRecord(connRecord) + require.NoError(t, err) + +- err = svc.storeEventTransientData(&message{ConnRecord: connRecord}) ++ err = svc.storeEventProtocolStateData(&message{ConnRecord: connRecord}) + require.NoError(t, err) + + err = svc.AcceptInvitation(id, "", "") +@@ -1384,7 +1384,7 @@ func TestAcceptInvitation(t *testing.T) { + State: StateIDRequested, + } + +- err = svc.storeEventTransientData(&message{ConnRecord: connRecord}) ++ err = svc.storeEventProtocolStateData(&message{ConnRecord: connRecord}) + require.NoError(t, err) + + err = svc.AcceptInvitation(id, "", "") +@@ -1475,7 +1475,7 @@ func TestAcceptInvitationWithPublicDID(t *testing.T) { + + err = svc.AcceptInvitation(generateRandomID(), "sample-public-did", "sample-label") + require.Error(t, err) +- require.Contains(t, err.Error(), "accept exchange invitation : get transient data : data not found") ++ require.Contains(t, err.Error(), "accept exchange invitation : get protocol state data : data not found") + }) + + t.Run("accept invitation - state error", func(t *testing.T) { +@@ -1494,7 +1494,7 @@ func TestAcceptInvitationWithPublicDID(t *testing.T) { + err = svc.connectionStore.saveConnectionRecord(connRecord) + require.NoError(t, err) + +- err = svc.storeEventTransientData(&message{ConnRecord: connRecord}) ++ err = svc.storeEventProtocolStateData(&message{ConnRecord: connRecord}) + require.NoError(t, err) + + err = svc.AcceptInvitation(id, "sample-public-did", "sample-label") +@@ -1516,7 +1516,7 @@ func TestAcceptInvitationWithPublicDID(t *testing.T) { + State: StateIDRequested, + } + +- err = svc.storeEventTransientData(&message{ConnRecord: connRecord}) ++ err = svc.storeEventProtocolStateData(&message{ConnRecord: connRecord}) + require.NoError(t, err) + + err = svc.AcceptInvitation(id, "sample-public-did", "sample-label") +@@ -1525,8 +1525,8 @@ func TestAcceptInvitationWithPublicDID(t *testing.T) { + }) + } + +-func TestEventTransientData(t *testing.T) { +- t.Run("event transient data - success", func(t *testing.T) { ++func TestEventProtocolStateData(t *testing.T) { ++ t.Run("event protocol state data - success", func(t *testing.T) { + svc, err := New(&protocol.MockProvider{ + ServiceMap: map[string]interface{}{ + mediator.Coordination: &mockroute.MockMediatorSvc{}, +@@ -1539,15 +1539,15 @@ func TestEventTransientData(t *testing.T) { + msg := &message{ + ConnRecord: &connection.Record{ConnectionID: connID}, + } +- err = svc.storeEventTransientData(msg) ++ err = svc.storeEventProtocolStateData(msg) + require.NoError(t, err) + +- retrievedMsg, err := svc.getEventTransientData(connID) ++ retrievedMsg, err := svc.getEventProtocolStateData(connID) + require.NoError(t, err) + require.Equal(t, msg, retrievedMsg) + }) + +- t.Run("event transient data - data not found", func(t *testing.T) { ++ t.Run("event protocol state data - data not found", func(t *testing.T) { + svc, err := New(&protocol.MockProvider{ + ServiceMap: map[string]interface{}{ + mediator.Coordination: &mockroute.MockMediatorSvc{}, +@@ -1557,14 +1557,14 @@ func TestEventTransientData(t *testing.T) { + + err = svc.AcceptExchangeRequest(generateRandomID(), "", "") + require.Error(t, err) +- require.Contains(t, err.Error(), "accept exchange request : get transient data : data not found") ++ require.Contains(t, err.Error(), "accept exchange request : get protocol state data : data not found") + + err = svc.AcceptExchangeRequest(generateRandomID(), "sample-public-did", "sample-label") + require.Error(t, err) +- require.Contains(t, err.Error(), "accept exchange request : get transient data : data not found") ++ require.Contains(t, err.Error(), "accept exchange request : get protocol state data : data not found") + }) + +- t.Run("event transient data - invalid data", func(t *testing.T) { ++ t.Run("event protocol state data - invalid data", func(t *testing.T) { + svc, err := New(&protocol.MockProvider{ + ServiceMap: map[string]interface{}{ + mediator.Coordination: &mockroute.MockMediatorSvc{}, +@@ -1577,9 +1577,9 @@ func TestEventTransientData(t *testing.T) { + err = svc.connectionStore.SaveEvent(connID, []byte("invalid data")) + require.NoError(t, err) + +- _, err = svc.getEventTransientData(connID) ++ _, err = svc.getEventProtocolStateData(connID) + require.Error(t, err) +- require.Contains(t, err.Error(), "get transient data : invalid character") ++ require.Contains(t, err.Error(), "get protocol state data : invalid character") + }) + } + +@@ -1751,10 +1751,10 @@ func TestService_CreateImplicitInvitation(t *testing.T) { + + t.Run("error during saving connection", func(t *testing.T) { + routeSvc := &mockroute.MockMediatorSvc{} +- transientStore := mockstorage.NewMockStoreProvider() +- transientStore.Store.ErrPut = errors.New("store put error") ++ protocolStateStore := mockstorage.NewMockStoreProvider() ++ protocolStateStore.Store.ErrPut = errors.New("store put error") + prov := &protocol.MockProvider{ +- TransientStoreProvider: transientStore, ++ ProtocolStateStoreProvider: protocolStateStore, + ServiceMap: map[string]interface{}{ + mediator.Coordination: routeSvc, + }, +diff --git a/pkg/didcomm/protocol/mediator/service_test.go b/pkg/didcomm/protocol/mediator/service_test.go +index fdde92d46..5dea498e9 100644 +--- a/pkg/didcomm/protocol/mediator/service_test.go ++++ b/pkg/didcomm/protocol/mediator/service_test.go +@@ -48,8 +48,8 @@ func TestServiceNew(t *testing.T) { + ServiceMap: map[string]interface{}{ + messagepickup.MessagePickup: &mockmessagep.MockMessagePickupSvc{}, + }, +- StorageProviderValue: mockstore.NewMockStoreProvider(), +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), + }) + require.NoError(t, err) + require.Equal(t, Coordination, svc.Name()) +@@ -82,8 +82,8 @@ func TestServiceHandleInbound(t *testing.T) { + ServiceMap: map[string]interface{}{ + messagepickup.MessagePickup: &mockmessagep.MockMessagePickupSvc{}, + }, +- StorageProviderValue: mockstore.NewMockStoreProvider(), +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), + }) + require.NoError(t, err) + +@@ -104,9 +104,9 @@ func TestServiceHandleOutbound(t *testing.T) { + ServiceMap: map[string]interface{}{ + messagepickup.MessagePickup: &mockmessagep.MockMessagePickupSvc{}, + }, +- StorageProviderValue: &mockstore.MockStoreProvider{Store: &mockstore.MockStore{Store: s}}, +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- LegacyKMSValue: &mockkms.CloseableKMS{}, ++ StorageProviderValue: &mockstore.MockStoreProvider{Store: &mockstore.MockStore{Store: s}}, ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ LegacyKMSValue: &mockkms.CloseableKMS{}, + OutboundDispatcherValue: &mockdispatcher.MockOutbound{ + ValidateSendToDID: func(msg interface{}, myDID, theirDID string) error { + require.Equal(t, myDID, MYDID) +@@ -165,8 +165,8 @@ func TestServiceHandleOutbound(t *testing.T) { + ServiceMap: map[string]interface{}{ + messagepickup.MessagePickup: &mockmessagep.MockMessagePickupSvc{}, + }, +- StorageProviderValue: mockstore.NewMockStoreProvider(), +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), + }) + require.NoError(t, err) + s.connectionLookup = &connectionsStub{ +@@ -188,8 +188,8 @@ func TestServiceHandleOutbound(t *testing.T) { + ServiceMap: map[string]interface{}{ + messagepickup.MessagePickup: &mockmessagep.MockMessagePickupSvc{}, + }, +- StorageProviderValue: mockstore.NewMockStoreProvider(), +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), + }) + require.NoError(t, err) + s.connectionLookup = &connectionsStub{ +@@ -212,10 +212,10 @@ func TestServiceRequestMsg(t *testing.T) { + ServiceMap: map[string]interface{}{ + messagepickup.MessagePickup: &mockmessagep.MockMessagePickupSvc{}, + }, +- StorageProviderValue: mockstore.NewMockStoreProvider(), +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- LegacyKMSValue: &mockkms.CloseableKMS{}, +- OutboundDispatcherValue: &mockdispatcher.MockOutbound{}}) ++ StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ LegacyKMSValue: &mockkms.CloseableKMS{}, ++ OutboundDispatcherValue: &mockdispatcher.MockOutbound{}}) + require.NoError(t, err) + + err = svc.RegisterActionEvent(make(chan service.DIDCommAction)) +@@ -233,10 +233,10 @@ func TestServiceRequestMsg(t *testing.T) { + ServiceMap: map[string]interface{}{ + messagepickup.MessagePickup: &mockmessagep.MockMessagePickupSvc{}, + }, +- StorageProviderValue: mockstore.NewMockStoreProvider(), +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- LegacyKMSValue: &mockkms.CloseableKMS{}, +- OutboundDispatcherValue: &mockdispatcher.MockOutbound{}}) ++ StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ LegacyKMSValue: &mockkms.CloseableKMS{}, ++ OutboundDispatcherValue: &mockdispatcher.MockOutbound{}}) + require.NoError(t, err) + + msg := &service.DIDCommMsgMap{"@id": map[int]int{}} +@@ -256,10 +256,10 @@ func TestServiceRequestMsg(t *testing.T) { + ServiceMap: map[string]interface{}{ + messagepickup.MessagePickup: &mockmessagep.MockMessagePickupSvc{}, + }, +- StorageProviderValue: mockstore.NewMockStoreProvider(), +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- LegacyKMSValue: &mockkms.CloseableKMS{}, +- ServiceEndpointValue: endpoint, ++ StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ LegacyKMSValue: &mockkms.CloseableKMS{}, ++ ServiceEndpointValue: endpoint, + OutboundDispatcherValue: &mockdispatcher.MockOutbound{ + ValidateSend: func(msg interface{}, senderVerKey string, des *service.Destination) error { + res, err := json.Marshal(msg) +@@ -295,8 +295,8 @@ func TestServiceRequestMsg(t *testing.T) { + ServiceMap: map[string]interface{}{ + messagepickup.MessagePickup: &mockmessagep.MockMessagePickupSvc{}, + }, +- StorageProviderValue: mockstore.NewMockStoreProvider(), +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), + LegacyKMSValue: &mockkms.CloseableKMS{ + CreateKeyErr: expected, + }, +@@ -321,10 +321,10 @@ func TestEvents(t *testing.T) { + ServiceMap: map[string]interface{}{ + messagepickup.MessagePickup: &mockmessagep.MockMessagePickupSvc{}, + }, +- StorageProviderValue: mockstore.NewMockStoreProvider(), +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- LegacyKMSValue: &mockkms.CloseableKMS{}, +- OutboundDispatcherValue: &mockdispatcher.MockOutbound{}}) ++ StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ LegacyKMSValue: &mockkms.CloseableKMS{}, ++ OutboundDispatcherValue: &mockdispatcher.MockOutbound{}}) + require.NoError(t, err) + + events := make(chan service.DIDCommAction) +@@ -353,9 +353,9 @@ func TestEvents(t *testing.T) { + ServiceMap: map[string]interface{}{ + messagepickup.MessagePickup: &mockmessagep.MockMessagePickupSvc{}, + }, +- StorageProviderValue: mockstore.NewMockStoreProvider(), +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- LegacyKMSValue: &mockkms.CloseableKMS{}, ++ StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ LegacyKMSValue: &mockkms.CloseableKMS{}, + OutboundDispatcherValue: &mockdispatcher.MockOutbound{ + ValidateSendToDID: func(msg interface{}, myDID, theirDID string) error { + dispatched <- struct{}{} +@@ -392,9 +392,9 @@ func TestEvents(t *testing.T) { + ServiceMap: map[string]interface{}{ + messagepickup.MessagePickup: &mockmessagep.MockMessagePickupSvc{}, + }, +- StorageProviderValue: mockstore.NewMockStoreProvider(), +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- LegacyKMSValue: &mockkms.CloseableKMS{}, ++ StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ LegacyKMSValue: &mockkms.CloseableKMS{}, + OutboundDispatcherValue: &mockdispatcher.MockOutbound{ + ValidateSendToDID: func(msg interface{}, myDID, theirDID string) error { + dispatched <- struct{}{} +@@ -430,10 +430,10 @@ func TestEvents(t *testing.T) { + ServiceMap: map[string]interface{}{ + messagepickup.MessagePickup: &mockmessagep.MockMessagePickupSvc{}, + }, +- StorageProviderValue: mockstore.NewMockStoreProvider(), +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- LegacyKMSValue: &mockkms.CloseableKMS{}, +- OutboundDispatcherValue: &mockdispatcher.MockOutbound{}}) ++ StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ LegacyKMSValue: &mockkms.CloseableKMS{}, ++ OutboundDispatcherValue: &mockdispatcher.MockOutbound{}}) + require.NoError(t, err) + + _, err = svc.HandleInbound(generateRequestMsgPayload(t, "123"), "", "") +@@ -448,10 +448,10 @@ func TestEvents(t *testing.T) { + ServiceMap: map[string]interface{}{ + messagepickup.MessagePickup: &mockmessagep.MockMessagePickupSvc{}, + }, +- StorageProviderValue: mockstore.NewMockStoreProvider(), +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- LegacyKMSValue: &mockkms.CloseableKMS{}, +- ServiceEndpointValue: "http://other.com", ++ StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ LegacyKMSValue: &mockkms.CloseableKMS{}, ++ ServiceEndpointValue: "http://other.com", + OutboundDispatcherValue: &mockdispatcher.MockOutbound{ + ValidateSendToDID: func(msg interface{}, myDID, theirDID string) error { + res, err := json.Marshal(msg) +@@ -526,10 +526,10 @@ func TestServiceGrantMsg(t *testing.T) { + ServiceMap: map[string]interface{}{ + messagepickup.MessagePickup: &mockmessagep.MockMessagePickupSvc{}, + }, +- StorageProviderValue: mockstore.NewMockStoreProvider(), +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- LegacyKMSValue: &mockkms.CloseableKMS{}, +- OutboundDispatcherValue: &mockdispatcher.MockOutbound{}}) ++ StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ LegacyKMSValue: &mockkms.CloseableKMS{}, ++ OutboundDispatcherValue: &mockdispatcher.MockOutbound{}}) + require.NoError(t, err) + + msgID := randomID() +@@ -544,10 +544,10 @@ func TestServiceGrantMsg(t *testing.T) { + ServiceMap: map[string]interface{}{ + messagepickup.MessagePickup: &mockmessagep.MockMessagePickupSvc{}, + }, +- StorageProviderValue: mockstore.NewMockStoreProvider(), +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- LegacyKMSValue: &mockkms.CloseableKMS{}, +- OutboundDispatcherValue: &mockdispatcher.MockOutbound{}}) ++ StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ LegacyKMSValue: &mockkms.CloseableKMS{}, ++ OutboundDispatcherValue: &mockdispatcher.MockOutbound{}}) + require.NoError(t, err) + + msg := &service.DIDCommMsgMap{"@id": map[int]int{}} +@@ -564,10 +564,10 @@ func TestServiceUpdateKeyListMsg(t *testing.T) { + ServiceMap: map[string]interface{}{ + messagepickup.MessagePickup: &mockmessagep.MockMessagePickupSvc{}, + }, +- StorageProviderValue: mockstore.NewMockStoreProvider(), +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- LegacyKMSValue: &mockkms.CloseableKMS{}, +- OutboundDispatcherValue: &mockdispatcher.MockOutbound{}}) ++ StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ LegacyKMSValue: &mockkms.CloseableKMS{}, ++ OutboundDispatcherValue: &mockdispatcher.MockOutbound{}}) + require.NoError(t, err) + + msgID := randomID() +@@ -585,10 +585,10 @@ func TestServiceUpdateKeyListMsg(t *testing.T) { + ServiceMap: map[string]interface{}{ + messagepickup.MessagePickup: &mockmessagep.MockMessagePickupSvc{}, + }, +- StorageProviderValue: mockstore.NewMockStoreProvider(), +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- LegacyKMSValue: &mockkms.CloseableKMS{}, +- OutboundDispatcherValue: &mockdispatcher.MockOutbound{}}) ++ StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ LegacyKMSValue: &mockkms.CloseableKMS{}, ++ OutboundDispatcherValue: &mockdispatcher.MockOutbound{}}) + require.NoError(t, err) + + msg := &service.DIDCommMsgMap{"@id": map[int]int{}} +@@ -608,9 +608,9 @@ func TestServiceUpdateKeyListMsg(t *testing.T) { + ServiceMap: map[string]interface{}{ + messagepickup.MessagePickup: &mockmessagep.MockMessagePickupSvc{}, + }, +- StorageProviderValue: mockstore.NewMockStoreProvider(), +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- LegacyKMSValue: &mockkms.CloseableKMS{}, ++ StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ LegacyKMSValue: &mockkms.CloseableKMS{}, + OutboundDispatcherValue: &mockdispatcher.MockOutbound{ + ValidateSend: func(msg interface{}, senderVerKey string, des *service.Destination) error { + res, err := json.Marshal(msg) +@@ -654,10 +654,10 @@ func TestServiceKeylistUpdateResponseMsg(t *testing.T) { + ServiceMap: map[string]interface{}{ + messagepickup.MessagePickup: &mockmessagep.MockMessagePickupSvc{}, + }, +- StorageProviderValue: mockstore.NewMockStoreProvider(), +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- LegacyKMSValue: &mockkms.CloseableKMS{}, +- OutboundDispatcherValue: &mockdispatcher.MockOutbound{}}) ++ StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ LegacyKMSValue: &mockkms.CloseableKMS{}, ++ OutboundDispatcherValue: &mockdispatcher.MockOutbound{}}) + require.NoError(t, err) + + msgID := randomID() +@@ -676,10 +676,10 @@ func TestServiceKeylistUpdateResponseMsg(t *testing.T) { + ServiceMap: map[string]interface{}{ + messagepickup.MessagePickup: &mockmessagep.MockMessagePickupSvc{}, + }, +- StorageProviderValue: mockstore.NewMockStoreProvider(), +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- LegacyKMSValue: &mockkms.CloseableKMS{}, +- OutboundDispatcherValue: &mockdispatcher.MockOutbound{}}) ++ StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ LegacyKMSValue: &mockkms.CloseableKMS{}, ++ OutboundDispatcherValue: &mockdispatcher.MockOutbound{}}) + require.NoError(t, err) + + msg := &service.DIDCommMsgMap{"@id": map[int]int{}} +@@ -697,10 +697,10 @@ func TestServiceForwardMsg(t *testing.T) { + ServiceMap: map[string]interface{}{ + messagepickup.MessagePickup: &mockmessagep.MockMessagePickupSvc{}, + }, +- StorageProviderValue: mockstore.NewMockStoreProvider(), +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- LegacyKMSValue: &mockkms.CloseableKMS{}, +- OutboundDispatcherValue: &mockdispatcher.MockOutbound{}}) ++ StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ LegacyKMSValue: &mockkms.CloseableKMS{}, ++ OutboundDispatcherValue: &mockdispatcher.MockOutbound{}}) + require.NoError(t, err) + + err = svc.routeStore.Put(to, []byte("did:example:123")) +@@ -718,10 +718,10 @@ func TestServiceForwardMsg(t *testing.T) { + ServiceMap: map[string]interface{}{ + messagepickup.MessagePickup: &mockmessagep.MockMessagePickupSvc{}, + }, +- StorageProviderValue: mockstore.NewMockStoreProvider(), +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- LegacyKMSValue: &mockkms.CloseableKMS{}, +- OutboundDispatcherValue: &mockdispatcher.MockOutbound{}}) ++ StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ LegacyKMSValue: &mockkms.CloseableKMS{}, ++ OutboundDispatcherValue: &mockdispatcher.MockOutbound{}}) + require.NoError(t, err) + + msg := &service.DIDCommMsgMap{"@id": map[int]int{}} +@@ -739,10 +739,10 @@ func TestServiceForwardMsg(t *testing.T) { + ServiceMap: map[string]interface{}{ + messagepickup.MessagePickup: &mockmessagep.MockMessagePickupSvc{}, + }, +- StorageProviderValue: mockstore.NewMockStoreProvider(), +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- LegacyKMSValue: &mockkms.CloseableKMS{}, +- OutboundDispatcherValue: &mockdispatcher.MockOutbound{}}) ++ StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ LegacyKMSValue: &mockkms.CloseableKMS{}, ++ OutboundDispatcherValue: &mockdispatcher.MockOutbound{}}) + require.NoError(t, err) + + err = svc.handleForward(generateForwardMsgPayload(t, msgID, to, nil)) +@@ -769,9 +769,9 @@ func TestServiceForwardMsg(t *testing.T) { + ServiceMap: map[string]interface{}{ + messagepickup.MessagePickup: &mockmessagep.MockMessagePickupSvc{}, + }, +- StorageProviderValue: mockstore.NewMockStoreProvider(), +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- LegacyKMSValue: &mockkms.CloseableKMS{}, ++ StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ LegacyKMSValue: &mockkms.CloseableKMS{}, + OutboundDispatcherValue: &mockdispatcher.MockOutbound{ + ValidateForward: func(msg interface{}, des *service.Destination) error { + require.Equal(t, content, msg) +@@ -825,9 +825,9 @@ func TestMessagePickup(t *testing.T) { + require.Equal(t, content, message) + return nil + }}}, +- StorageProviderValue: mockstore.NewMockStoreProvider(), +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- LegacyKMSValue: &mockkms.CloseableKMS{}, ++ StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ LegacyKMSValue: &mockkms.CloseableKMS{}, + OutboundDispatcherValue: &mockdispatcher.MockOutbound{ + ValidateForward: func(_ interface{}, _ *service.Destination) error { + return errors.New("websocket connection failed") +@@ -867,9 +867,9 @@ func TestMessagePickup(t *testing.T) { + messagepickup.MessagePickup: &mockmessagep.MockMessagePickupSvc{ + AddMessageErr: errors.New("add error"), + }}, +- StorageProviderValue: mockstore.NewMockStoreProvider(), +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- LegacyKMSValue: &mockkms.CloseableKMS{}, ++ StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ LegacyKMSValue: &mockkms.CloseableKMS{}, + OutboundDispatcherValue: &mockdispatcher.MockOutbound{ + ValidateForward: func(_ interface{}, _ *service.Destination) error { + return errors.New("websocket connection failed") +@@ -904,9 +904,9 @@ func TestRegister(t *testing.T) { + ServiceMap: map[string]interface{}{ + messagepickup.MessagePickup: &mockmessagep.MockMessagePickupSvc{}, + }, +- StorageProviderValue: &mockstore.MockStoreProvider{Store: &mockstore.MockStore{Store: s}}, +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- LegacyKMSValue: &mockkms.CloseableKMS{}, ++ StorageProviderValue: &mockstore.MockStoreProvider{Store: &mockstore.MockStore{Store: s}}, ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ LegacyKMSValue: &mockkms.CloseableKMS{}, + OutboundDispatcherValue: &mockdispatcher.MockOutbound{ + ValidateSendToDID: func(msg interface{}, myDID, theirDID string) error { + require.Equal(t, myDID, MYDID) +@@ -950,8 +950,8 @@ func TestRegister(t *testing.T) { + StorageProviderValue: &mockstore.MockStoreProvider{ + Store: &mockstore.MockStore{Store: s, ErrPut: errors.New("save error")}, + }, +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- LegacyKMSValue: &mockkms.CloseableKMS{}, ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ LegacyKMSValue: &mockkms.CloseableKMS{}, + OutboundDispatcherValue: &mockdispatcher.MockOutbound{ + ValidateSendToDID: func(msg interface{}, myDID, theirDID string) error { + request, ok := msg.(*Request) +@@ -984,10 +984,10 @@ func TestRegister(t *testing.T) { + ServiceMap: map[string]interface{}{ + messagepickup.MessagePickup: &mockmessagep.MockMessagePickupSvc{}, + }, +- StorageProviderValue: &mockstore.MockStoreProvider{Store: &mockstore.MockStore{Store: s}}, +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- LegacyKMSValue: &mockkms.CloseableKMS{}, +- OutboundDispatcherValue: &mockdispatcher.MockOutbound{}}) ++ StorageProviderValue: &mockstore.MockStoreProvider{Store: &mockstore.MockStore{Store: s}}, ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ LegacyKMSValue: &mockkms.CloseableKMS{}, ++ OutboundDispatcherValue: &mockdispatcher.MockOutbound{}}) + require.NoError(t, err) + + connRec := &connection.Record{ +@@ -1007,10 +1007,10 @@ func TestRegister(t *testing.T) { + ServiceMap: map[string]interface{}{ + messagepickup.MessagePickup: &mockmessagep.MockMessagePickupSvc{}, + }, +- StorageProviderValue: &mockstore.MockStoreProvider{Store: &mockstore.MockStore{Store: s}}, +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- LegacyKMSValue: &mockkms.CloseableKMS{}, +- OutboundDispatcherValue: &mockdispatcher.MockOutbound{}}) ++ StorageProviderValue: &mockstore.MockStoreProvider{Store: &mockstore.MockStore{Store: s}}, ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ LegacyKMSValue: &mockkms.CloseableKMS{}, ++ OutboundDispatcherValue: &mockdispatcher.MockOutbound{}}) + require.NoError(t, err) + + connRec := &connection.Record{ +@@ -1032,9 +1032,9 @@ func TestRegister(t *testing.T) { + ServiceMap: map[string]interface{}{ + messagepickup.MessagePickup: &mockmessagep.MockMessagePickupSvc{}, + }, +- StorageProviderValue: mockstore.NewMockStoreProvider(), +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- LegacyKMSValue: &mockkms.CloseableKMS{}, ++ StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ LegacyKMSValue: &mockkms.CloseableKMS{}, + OutboundDispatcherValue: &mockdispatcher.MockOutbound{ + ValidateSendToDID: func(msg interface{}, myDID, theirDID string) error { + return fmt.Errorf("error send") +@@ -1053,8 +1053,8 @@ func TestRegister(t *testing.T) { + }, + StorageProviderValue: &mockstore.MockStoreProvider{ + Store: &mockstore.MockStore{ErrGet: fmt.Errorf("get error")}}, +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- LegacyKMSValue: &mockkms.CloseableKMS{}, ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ LegacyKMSValue: &mockkms.CloseableKMS{}, + OutboundDispatcherValue: &mockdispatcher.MockOutbound{ + ValidateSendToDID: func(msg interface{}, myDID, theirDID string) error { + return fmt.Errorf("error send") +@@ -1075,8 +1075,8 @@ func TestUnregister(t *testing.T) { + ServiceMap: map[string]interface{}{ + messagepickup.MessagePickup: &mockmessagep.MockMessagePickupSvc{}, + }, +- StorageProviderValue: &mockstore.MockStoreProvider{Store: &mockstore.MockStore{Store: s}}, +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: &mockstore.MockStoreProvider{Store: &mockstore.MockStore{Store: s}}, ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), + }, + ) + require.NoError(t, err) +@@ -1097,7 +1097,7 @@ func TestUnregister(t *testing.T) { + StorageProviderValue: &mockstore.MockStoreProvider{ + Store: &mockstore.MockStore{Store: s}, + }, +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), + }, + ) + require.NoError(t, err) +@@ -1117,7 +1117,7 @@ func TestUnregister(t *testing.T) { + StorageProviderValue: &mockstore.MockStoreProvider{ + Store: &mockstore.MockStore{Store: s, ErrGet: errors.New("get error")}, + }, +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), + }, + ) + require.NoError(t, err) +@@ -1138,9 +1138,9 @@ func TestKeylistUpdate(t *testing.T) { + ServiceMap: map[string]interface{}{ + messagepickup.MessagePickup: &mockmessagep.MockMessagePickupSvc{}, + }, +- StorageProviderValue: &mockstore.MockStoreProvider{Store: &mockstore.MockStore{Store: s}}, +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- LegacyKMSValue: &mockkms.CloseableKMS{}, ++ StorageProviderValue: &mockstore.MockStoreProvider{Store: &mockstore.MockStore{Store: s}}, ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ LegacyKMSValue: &mockkms.CloseableKMS{}, + OutboundDispatcherValue: &mockdispatcher.MockOutbound{ + ValidateSendToDID: func(msg interface{}, myDID, theirDID string) error { + require.Equal(t, myDID, MYDID) +@@ -1191,9 +1191,9 @@ func TestKeylistUpdate(t *testing.T) { + ServiceMap: map[string]interface{}{ + messagepickup.MessagePickup: &mockmessagep.MockMessagePickupSvc{}, + }, +- StorageProviderValue: &mockstore.MockStoreProvider{Store: &mockstore.MockStore{Store: s}}, +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- LegacyKMSValue: &mockkms.CloseableKMS{}, ++ StorageProviderValue: &mockstore.MockStoreProvider{Store: &mockstore.MockStore{Store: s}}, ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ LegacyKMSValue: &mockkms.CloseableKMS{}, + OutboundDispatcherValue: &mockdispatcher.MockOutbound{ + ValidateSendToDID: func(msg interface{}, myDID, theirDID string) error { + require.Equal(t, myDID, MYDID) +@@ -1252,10 +1252,10 @@ func TestKeylistUpdate(t *testing.T) { + ServiceMap: map[string]interface{}{ + messagepickup.MessagePickup: &mockmessagep.MockMessagePickupSvc{}, + }, +- StorageProviderValue: &mockstore.MockStoreProvider{Store: &mockstore.MockStore{Store: s}}, +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- LegacyKMSValue: &mockkms.CloseableKMS{}, +- OutboundDispatcherValue: &mockdispatcher.MockOutbound{}}) ++ StorageProviderValue: &mockstore.MockStoreProvider{Store: &mockstore.MockStore{Store: s}}, ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ LegacyKMSValue: &mockkms.CloseableKMS{}, ++ OutboundDispatcherValue: &mockdispatcher.MockOutbound{}}) + require.NoError(t, err) + + connRec := &connection.Record{ +@@ -1279,9 +1279,9 @@ func TestKeylistUpdate(t *testing.T) { + StorageProviderValue: &mockstore.MockStoreProvider{ + Store: &mockstore.MockStore{Store: s, ErrGet: errors.New("get error")}, + }, +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- LegacyKMSValue: &mockkms.CloseableKMS{}, +- OutboundDispatcherValue: &mockdispatcher.MockOutbound{}}) ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ LegacyKMSValue: &mockkms.CloseableKMS{}, ++ OutboundDispatcherValue: &mockdispatcher.MockOutbound{}}) + require.NoError(t, err) + + err = svc.AddKey("recKey") +@@ -1299,10 +1299,10 @@ func TestConfig(t *testing.T) { + ServiceMap: map[string]interface{}{ + messagepickup.MessagePickup: &mockmessagep.MockMessagePickupSvc{}, + }, +- StorageProviderValue: &mockstore.MockStoreProvider{Store: &mockstore.MockStore{Store: s}}, +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- LegacyKMSValue: &mockkms.CloseableKMS{}, +- OutboundDispatcherValue: &mockdispatcher.MockOutbound{}}) ++ StorageProviderValue: &mockstore.MockStoreProvider{Store: &mockstore.MockStore{Store: s}}, ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ LegacyKMSValue: &mockkms.CloseableKMS{}, ++ OutboundDispatcherValue: &mockdispatcher.MockOutbound{}}) + require.NoError(t, err) + + require.NoError(t, svc.saveRouterConnectionID("connID-123")) +@@ -1323,10 +1323,10 @@ func TestConfig(t *testing.T) { + ServiceMap: map[string]interface{}{ + messagepickup.MessagePickup: &mockmessagep.MockMessagePickupSvc{}, + }, +- StorageProviderValue: &mockstore.MockStoreProvider{Store: &mockstore.MockStore{Store: s}}, +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- LegacyKMSValue: &mockkms.CloseableKMS{}, +- OutboundDispatcherValue: &mockdispatcher.MockOutbound{}}) ++ StorageProviderValue: &mockstore.MockStoreProvider{Store: &mockstore.MockStore{Store: s}}, ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ LegacyKMSValue: &mockkms.CloseableKMS{}, ++ OutboundDispatcherValue: &mockdispatcher.MockOutbound{}}) + require.NoError(t, err) + + conf, err := svc.Config() +@@ -1341,10 +1341,10 @@ func TestConfig(t *testing.T) { + ServiceMap: map[string]interface{}{ + messagepickup.MessagePickup: &mockmessagep.MockMessagePickupSvc{}, + }, +- StorageProviderValue: &mockstore.MockStoreProvider{Store: &mockstore.MockStore{Store: s}}, +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- LegacyKMSValue: &mockkms.CloseableKMS{}, +- OutboundDispatcherValue: &mockdispatcher.MockOutbound{}}) ++ StorageProviderValue: &mockstore.MockStoreProvider{Store: &mockstore.MockStore{Store: s}}, ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ LegacyKMSValue: &mockkms.CloseableKMS{}, ++ OutboundDispatcherValue: &mockdispatcher.MockOutbound{}}) + require.NoError(t, err) + + require.NoError(t, svc.saveRouterConnectionID("connID-123")) +@@ -1361,10 +1361,10 @@ func TestConfig(t *testing.T) { + ServiceMap: map[string]interface{}{ + messagepickup.MessagePickup: &mockmessagep.MockMessagePickupSvc{}, + }, +- StorageProviderValue: &mockstore.MockStoreProvider{Store: &mockstore.MockStore{Store: s}}, +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- LegacyKMSValue: &mockkms.CloseableKMS{}, +- OutboundDispatcherValue: &mockdispatcher.MockOutbound{}}) ++ StorageProviderValue: &mockstore.MockStoreProvider{Store: &mockstore.MockStore{Store: s}}, ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ LegacyKMSValue: &mockkms.CloseableKMS{}, ++ OutboundDispatcherValue: &mockdispatcher.MockOutbound{}}) + require.NoError(t, err) + + require.NoError(t, svc.saveRouterConnectionID("connID-123")) +@@ -1385,9 +1385,9 @@ func TestConfig(t *testing.T) { + StorageProviderValue: &mockstore.MockStoreProvider{ + Store: &mockstore.MockStore{Store: s, ErrGet: errors.New("get error")}, + }, +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- LegacyKMSValue: &mockkms.CloseableKMS{}, +- OutboundDispatcherValue: &mockdispatcher.MockOutbound{}}) ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ LegacyKMSValue: &mockkms.CloseableKMS{}, ++ OutboundDispatcherValue: &mockdispatcher.MockOutbound{}}) + require.NoError(t, err) + + require.NoError(t, svc.saveRouterConnectionID("connID-123")) +@@ -1410,8 +1410,8 @@ func TestGetConnection(t *testing.T) { + ServiceMap: map[string]interface{}{ + messagepickup.MessagePickup: &mockmessagep.MockMessagePickupSvc{}, + }, +- StorageProviderValue: &mockstore.MockStoreProvider{Store: &mockstore.MockStore{Store: s}}, +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: &mockstore.MockStoreProvider{Store: &mockstore.MockStore{Store: s}}, ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), + }, + ) + require.NoError(t, err) +@@ -1430,8 +1430,8 @@ func TestGetConnection(t *testing.T) { + ServiceMap: map[string]interface{}{ + messagepickup.MessagePickup: &mockmessagep.MockMessagePickupSvc{}, + }, +- StorageProviderValue: &mockstore.MockStoreProvider{Store: &mockstore.MockStore{Store: s}}, +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: &mockstore.MockStoreProvider{Store: &mockstore.MockStore{Store: s}}, ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), + }, + ) + require.NoError(t, err) +@@ -1449,8 +1449,8 @@ func TestGetConnection(t *testing.T) { + ServiceMap: map[string]interface{}{ + messagepickup.MessagePickup: &mockmessagep.MockMessagePickupSvc{}, + }, +- StorageProviderValue: &mockstore.MockStoreProvider{Store: &mockstore.MockStore{Store: s}}, +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: &mockstore.MockStoreProvider{Store: &mockstore.MockStore{Store: s}}, ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), + }, + ) + require.NoError(t, err) +@@ -1473,7 +1473,7 @@ func TestGetConnection(t *testing.T) { + StorageProviderValue: &mockstore.MockStoreProvider{ + Store: &mockstore.MockStore{Store: s, ErrGet: errors.New("get error")}, + }, +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), + }, + ) + require.NoError(t, err) +diff --git a/pkg/didcomm/protocol/messagepickup/service_test.go b/pkg/didcomm/protocol/messagepickup/service_test.go +index 20799b282..a77d42532 100644 +--- a/pkg/didcomm/protocol/messagepickup/service_test.go ++++ b/pkg/didcomm/protocol/messagepickup/service_test.go +@@ -42,8 +42,8 @@ func TestServiceNew(t *testing.T) { + svc, err := New(&mockprovider.Provider{ + StorageProviderValue: &mockstore.MockStoreProvider{ + ErrOpenStoreHandle: fmt.Errorf("error opening the store")}, +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- OutboundDispatcherValue: nil, ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ OutboundDispatcherValue: nil, + }, &mockTransportProvider{ + packagerValue: &mockPackager{}, + }) +@@ -139,8 +139,8 @@ func TestHandleInbound(t *testing.T) { + require.NoError(t, err) + + svc, err := New(&mockprovider.Provider{ +- StorageProviderValue: mockstore.NewMockStoreProvider(), +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), + OutboundDispatcherValue: &mockdispatcher.MockOutbound{ + ValidateSendToDID: func(msg interface{}, myDID, theirDID string) error { + require.Equal(t, myDID, MYDID) +@@ -231,8 +231,8 @@ func TestHandleInbound(t *testing.T) { + require.NoError(t, err) + + svc, err := New(&mockprovider.Provider{ +- StorageProviderValue: mockstore.NewMockStoreProvider(), +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), + OutboundDispatcherValue: &mockdispatcher.MockOutbound{ + ValidateSendToDID: func(msg interface{}, myDID, theirDID string) error { + require.Equal(t, myDID, MYDID) +@@ -302,9 +302,9 @@ func TestHandleInbound(t *testing.T) { + t.Run("test MessagePickupService.HandleInbound() - BatchPickup - get error", func(t *testing.T) { + mockStore := mockstore.NewMockStoreProvider() + svc, err := New(&mockprovider.Provider{ +- StorageProviderValue: mockStore, +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- OutboundDispatcherValue: nil, ++ StorageProviderValue: mockStore, ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ OutboundDispatcherValue: nil, + }, &mockTransportProvider{ + packagerValue: &mockPackager{}, + }) +@@ -328,9 +328,9 @@ func TestHandleInbound(t *testing.T) { + t.Run("test MessagePickupService.pullMessages() - put inbox error", func(t *testing.T) { + mockStore := mockstore.NewMockStoreProvider() + svc, err := New(&mockprovider.Provider{ +- StorageProviderValue: mockStore, +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- OutboundDispatcherValue: nil, ++ StorageProviderValue: mockStore, ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ OutboundDispatcherValue: nil, + }, &mockTransportProvider{ + packagerValue: &mockPackager{}, + }) +@@ -451,9 +451,9 @@ func TestAddMessage(t *testing.T) { + t.Run("test MessagePickupService.AddMessage() - success", func(t *testing.T) { + mockStore := mockstore.NewMockStoreProvider() + svc, err := New(&mockprovider.Provider{ +- StorageProviderValue: mockStore, +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- OutboundDispatcherValue: nil, ++ StorageProviderValue: mockStore, ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ OutboundDispatcherValue: nil, + }, &mockTransportProvider{ + packagerValue: &mockPackager{}, + }) +@@ -500,9 +500,9 @@ func TestAddMessage(t *testing.T) { + t.Run("test MessagePickupService.AddMessage() - put error", func(t *testing.T) { + mockStore := mockstore.NewMockStoreProvider() + svc, err := New(&mockprovider.Provider{ +- StorageProviderValue: mockStore, +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- OutboundDispatcherValue: nil, ++ StorageProviderValue: mockStore, ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ OutboundDispatcherValue: nil, + }, &mockTransportProvider{ + packagerValue: &mockPackager{}, + }) +@@ -529,9 +529,9 @@ func TestAddMessage(t *testing.T) { + t.Run("test MessagePickupService.AddMessage() - get error", func(t *testing.T) { + mockStore := mockstore.NewMockStoreProvider() + svc, err := New(&mockprovider.Provider{ +- StorageProviderValue: mockStore, +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- OutboundDispatcherValue: nil, ++ StorageProviderValue: mockStore, ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ OutboundDispatcherValue: nil, + }, &mockTransportProvider{ + packagerValue: &mockPackager{}, + }) +@@ -553,8 +553,8 @@ func TestStatusRequest(t *testing.T) { + s := make(map[string][]byte) + + provider := &mockprovider.Provider{ +- StorageProviderValue: mockstore.NewMockStoreProvider(), +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), + OutboundDispatcherValue: &mockdispatcher.MockOutbound{ + ValidateSendToDID: func(msg interface{}, myDID, theirDID string) error { + require.Equal(t, myDID, MYDID) +@@ -629,8 +629,8 @@ func TestStatusRequest(t *testing.T) { + s := make(map[string][]byte) + + provider := &mockprovider.Provider{ +- StorageProviderValue: mockstore.NewMockStoreProvider(), +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), + OutboundDispatcherValue: &mockdispatcher.MockOutbound{ + ValidateSendToDID: func(msg interface{}, myDID, theirDID string) error { + return errors.New("send error") +@@ -666,8 +666,8 @@ func TestBatchPickup(t *testing.T) { + s := make(map[string][]byte) + + provider := &mockprovider.Provider{ +- StorageProviderValue: mockstore.NewMockStoreProvider(), +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), + OutboundDispatcherValue: &mockdispatcher.MockOutbound{ + ValidateSendToDID: func(msg interface{}, myDID, theirDID string) error { + require.Equal(t, myDID, MYDID) +@@ -746,8 +746,8 @@ func TestBatchPickup(t *testing.T) { + s := make(map[string][]byte) + + provider := &mockprovider.Provider{ +- StorageProviderValue: mockstore.NewMockStoreProvider(), +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), + OutboundDispatcherValue: &mockdispatcher.MockOutbound{ + ValidateSendToDID: func(msg interface{}, myDID, theirDID string) error { + return errors.New("send error") +@@ -819,8 +819,8 @@ func TestNoop(t *testing.T) { + s := make(map[string][]byte) + + provider := &mockprovider.Provider{ +- StorageProviderValue: mockstore.NewMockStoreProvider(), +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), + OutboundDispatcherValue: &mockdispatcher.MockOutbound{ + ValidateSendToDID: func(msg interface{}, myDID, theirDID string) error { + require.Equal(t, myDID, MYDID) +@@ -858,8 +858,8 @@ func TestNoop(t *testing.T) { + s := make(map[string][]byte) + + provider := &mockprovider.Provider{ +- StorageProviderValue: mockstore.NewMockStoreProvider(), +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), ++ StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), + OutboundDispatcherValue: &mockdispatcher.MockOutbound{ + ValidateSendToDID: func(msg interface{}, myDID, theirDID string) error { + return errors.New("send error") +@@ -924,9 +924,9 @@ func TestGetConnection(t *testing.T) { + + func getService() (*Service, error) { + svc, err := New(&mockprovider.Provider{ +- StorageProviderValue: mockstore.NewMockStoreProvider(), +- TransientStorageProviderValue: mockstore.NewMockStoreProvider(), +- OutboundDispatcherValue: nil, ++ StorageProviderValue: mockstore.NewMockStoreProvider(), ++ ProtocolStateStorageProviderValue: mockstore.NewMockStoreProvider(), ++ OutboundDispatcherValue: nil, + }, &mockTransportProvider{ + packagerValue: &mockPackager{}, + }) +diff --git a/pkg/didcomm/protocol/outofband/service_test.go b/pkg/didcomm/protocol/outofband/service_test.go +index 88d6bad9d..be07e187e 100644 +--- a/pkg/didcomm/protocol/outofband/service_test.go ++++ b/pkg/didcomm/protocol/outofband/service_test.go +@@ -52,10 +52,10 @@ func TestNew(t *testing.T) { + _, err := New(provider) + require.Error(t, err) + }) +- t.Run("wraps error thrown from transient store when it cannot be opened", func(t *testing.T) { ++ t.Run("wraps error thrown from protocol state store when it cannot be opened", func(t *testing.T) { + expected := errors.New("test") + provider := testProvider() +- provider.TransientStoreProvider = &mockstore.MockStoreProvider{ ++ provider.ProtocolStateStoreProvider = &mockstore.MockStoreProvider{ + ErrOpenStoreHandle: expected, + } + _, err := New(provider) +@@ -414,10 +414,10 @@ func TestHandleRequestCallback(t *testing.T) { + require.Error(t, err) + require.True(t, errors.Is(err, expected)) + }) +- t.Run("wraps error returned by the transient store", func(t *testing.T) { ++ t.Run("wraps error returned by the protocol state store", func(t *testing.T) { + expected := errors.New("test") + provider := testProvider() +- provider.TransientStoreProvider = &mockstore.MockStoreProvider{ ++ provider.ProtocolStateStoreProvider = &mockstore.MockStoreProvider{ + Store: &mockstore.MockStore{ + ErrPut: expected, + }, +@@ -478,11 +478,11 @@ func TestHandleDIDEvent(t *testing.T) { + t.Error("timeout") + } + }) +- t.Run("wraps error returned by the transient store", func(t *testing.T) { ++ t.Run("wraps error returned by the protocol state store", func(t *testing.T) { + expected := errors.New("test") + const connID = "123" + provider := testProvider() +- provider.TransientStoreProvider = &mockstore.MockStoreProvider{ ++ provider.ProtocolStateStoreProvider = &mockstore.MockStoreProvider{ + Store: &mockstore.MockStore{ + Store: make(map[string][]byte), + ErrGet: expected, +@@ -605,7 +605,7 @@ func TestHandleDIDEvent(t *testing.T) { + )) + + s.store = &mockstore.MockStore{ +- Store: provider.TransientStoreProvider.Store.Store, ++ Store: provider.ProtocolStateStoreProvider.Store.Store, + ErrPut: expected, + } + +@@ -1115,8 +1115,8 @@ func TestChooseTarget(t *testing.T) { + + func testProvider() *protocol.MockProvider { + return &protocol.MockProvider{ +- StoreProvider: mockstore.NewMockStoreProvider(), +- TransientStoreProvider: mockstore.NewMockStoreProvider(), ++ StoreProvider: mockstore.NewMockStoreProvider(), ++ ProtocolStateStoreProvider: mockstore.NewMockStoreProvider(), + ServiceMap: map[string]interface{}{ + didexchange.DIDExchange: &mockdidexchange.MockDIDExchangeSvc{}, + }, +diff --git a/pkg/framework/aries/example_test.go b/pkg/framework/aries/example_test.go +index 4f6ceae75..26fdf0e34 100644 +--- a/pkg/framework/aries/example_test.go ++++ b/pkg/framework/aries/example_test.go +@@ -18,7 +18,7 @@ func Example() { + framework, err := New( + WithInboundTransport(newMockInTransport()), + WithStoreProvider(newMockDBProvider()), +- WithTransientStoreProvider(newMockDBProvider()), ++ WithProtocolStateStoreProvider(newMockDBProvider()), + ) + if err != nil { + fmt.Println("failed to create framework") +diff --git a/pkg/framework/aries/framework_test.go b/pkg/framework/aries/framework_test.go +index b714bb966..14559973e 100644 +--- a/pkg/framework/aries/framework_test.go ++++ b/pkg/framework/aries/framework_test.go +@@ -544,16 +544,16 @@ func TestFramework(t *testing.T) { + require.NoError(t, err) + }) + +- t.Run("test transient store - with user provided transient store", func(t *testing.T) { ++ t.Run("test protocol state store - with user provided protocol state store", func(t *testing.T) { + path, cleanup := generateTempDir(t) + defer cleanup() + dbPath = path + s := storage.NewMockStoreProvider() + +- aries, err := New(WithInboundTransport(&mockInboundTransport{}), WithTransientStoreProvider(s)) ++ aries, err := New(WithInboundTransport(&mockInboundTransport{}), WithProtocolStateStoreProvider(s)) + require.NoError(t, err) + require.NotEmpty(t, aries) +- require.Equal(t, s, aries.transientStoreProvider) ++ require.Equal(t, s, aries.protocolStateStoreProvider) + }) + + t.Run("test new with outbound transport service", func(t *testing.T) { +diff --git a/pkg/framework/context/context_test.go b/pkg/framework/context/context_test.go +index 78b599b9f..7aeca2233 100644 +--- a/pkg/framework/context/context_test.go ++++ b/pkg/framework/context/context_test.go +@@ -340,11 +340,11 @@ func TestNewProvider(t *testing.T) { + require.Equal(t, s, prov.StorageProvider()) + }) + +- t.Run("test new with transient storage provider", func(t *testing.T) { ++ t.Run("test new with protocol state storage provider", func(t *testing.T) { + s := storage.NewMockStoreProvider() +- prov, err := New(WithTransientStorageProvider(s)) ++ prov, err := New(WithProtocolStateStorageProvider(s)) + require.NoError(t, err) +- require.Equal(t, s, prov.TransientStorageProvider()) ++ require.Equal(t, s, prov.ProtocolStateStorageProvider()) + }) + + t.Run("test new with vdri", func(t *testing.T) { +diff --git a/pkg/store/connection/connection_lookup_test.go b/pkg/store/connection/connection_lookup_test.go +index 8d358b51e..77d3c8a5e 100644 +--- a/pkg/store/connection/connection_lookup_test.go ++++ b/pkg/store/connection/connection_lookup_test.go +@@ -33,12 +33,12 @@ func TestNewConnectionReader(t *testing.T) { + lookup, err := NewLookup(&mockProvider{}) + require.NoError(t, err) + require.NotNil(t, lookup) +- require.NotNil(t, lookup.transientStore) ++ require.NotNil(t, lookup.protocolStateStore) + require.NotNil(t, lookup.store) + }) + +- t.Run("create new connection reader failure due to transient store error", func(t *testing.T) { +- lookup, err := NewLookup(&mockProvider{transientStoreError: fmt.Errorf(sampleErrMsg)}) ++ t.Run("create new connection reader failure due to protocol state store error", func(t *testing.T) { ++ lookup, err := NewLookup(&mockProvider{protocolStateStoreError: fmt.Errorf(sampleErrMsg)}) + require.Error(t, err) + require.Contains(t, err.Error(), sampleErrMsg) + require.Nil(t, lookup) +@@ -99,7 +99,7 @@ func TestConnectionReader_GetAndQueryConnectionRecord(t *testing.T) { + require.Len(t, records, noOfItems) + }) + +- t.Run("get connection record - from transient store", func(t *testing.T) { ++ t.Run("get connection record - from protocol state store", func(t *testing.T) { + lookup, e := NewLookup(&mockProvider{}) + require.NoError(t, e) + require.NotNil(t, lookup) +@@ -112,7 +112,7 @@ func TestConnectionReader_GetAndQueryConnectionRecord(t *testing.T) { + } + + // prepare data +- saveInStore(lookup.transientStore, connectionIDS) ++ saveInStore(lookup.protocolStateStore, connectionIDS) + + for _, connectionID := range connectionIDS { + connection, err := lookup.GetConnectionRecord(connectionID) +@@ -137,7 +137,7 @@ func TestConnectionReader_GetAndQueryConnectionRecord(t *testing.T) { + require.NotNil(t, lookup) + + // prepare data +- saveInStore(lookup.transientStore, connectionIDS) ++ saveInStore(lookup.protocolStateStore, connectionIDS) + + for _, connectionID := range connectionIDS { + connection, err := lookup.GetConnectionRecord(connectionID) +@@ -185,7 +185,7 @@ func TestConnectionReader_GetConnectionRecordAtState(t *testing.T) { + // prepare data in store + saveInStore(store.store, connectionIDS) + +- // should fail since data doesn't exists in transient store ++ + for _, connectionID := range connectionIDS { + connection, err := store.GetConnectionRecordAtState(connectionID, state) + require.Error(t, err) +@@ -193,8 +193,8 @@ func TestConnectionReader_GetConnectionRecordAtState(t *testing.T) { + require.Nil(t, connection) + } + +- // prepare data in transient store +- saveInStore(store.transientStore, connectionIDS) ++ ++ saveInStore(store.protocolStateStore, connectionIDS) + + for _, connectionID := range connectionIDS { + connection, err := store.GetConnectionRecordAtState(connectionID, state) +@@ -257,7 +257,7 @@ func TestConnectionReader_GetConnectionRecordByNSThreadID(t *testing.T) { + // prepare data in store + saveInStore(store.store, nsThreadIDs, false) + +- // should fail since data doesn't exists in transient store ++ + for _, nsThreadID := range nsThreadIDs { + connection, err := store.GetConnectionRecordByNSThreadID(nsThreadID) + require.Error(t, err) +@@ -265,11 +265,11 @@ func TestConnectionReader_GetConnectionRecordByNSThreadID(t *testing.T) { + require.Nil(t, connection) + } + +- // prepare only ns thread data in transient store ++ + // skip connection +- saveInStore(store.transientStore, nsThreadIDs, true) ++ saveInStore(store.protocolStateStore, nsThreadIDs, true) + +- // should fail since data doesn't exists in transient store ++ + for _, nsThreadID := range nsThreadIDs { + connection, err := store.GetConnectionRecordByNSThreadID(nsThreadID) + require.Error(t, err) +@@ -277,10 +277,10 @@ func TestConnectionReader_GetConnectionRecordByNSThreadID(t *testing.T) { + require.Nil(t, connection) + } + +- // prepare data in transient store +- saveInStore(store.transientStore, nsThreadIDs, false) ++ ++ saveInStore(store.protocolStateStore, nsThreadIDs, false) + +- // should fail since data doesn't exists in transient store ++ + for _, nsThreadID := range nsThreadIDs { + connection, err := store.GetConnectionRecordByNSThreadID(nsThreadID) + require.NoError(t, err) +@@ -294,13 +294,13 @@ func TestConnectionRecorder_QueryConnectionRecord(t *testing.T) { + t.Run("test query connection record", func(t *testing.T) { + store := &mockstorage.MockStore{Store: make(map[string][]byte)} + +- transientStore, err := mem.NewProvider().OpenStore(Namespace) ++ protocolStateStore, err := mem.NewProvider().OpenStore(Namespace) + require.NoError(t, err) + + const ( +- storeCount = 5 +- overlap = 3 +- transientStoreCount = 4 ++ storeCount = 5 ++ overlap = 3 ++ protocolStateStoreCount = 4 + ) + + for i := 0; i < storeCount+overlap; i++ { +@@ -312,22 +312,22 @@ func TestConnectionRecorder_QueryConnectionRecord(t *testing.T) { + err = store.Put(fmt.Sprintf("%s_abc%d", connIDKeyPrefix, i), val) + require.NoError(t, err) + } +- for i := overlap; i < transientStoreCount+storeCount; i++ { ++ for i := overlap; i < protocolStateStoreCount+storeCount; i++ { + val, jsonErr := json.Marshal(&Record{ + ConnectionID: string(i), + }) + require.NoError(t, jsonErr) + +- err = transientStore.Put(fmt.Sprintf("%s_abc%d", connIDKeyPrefix, i), val) ++ err = protocolStateStore.Put(fmt.Sprintf("%s_abc%d", connIDKeyPrefix, i), val) + require.NoError(t, err) + } + +- recorder, err := NewLookup(&mockProvider{store: store, transientStore: transientStore}) ++ recorder, err := NewLookup(&mockProvider{store: store, protocolStateStore: protocolStateStore}) + require.NoError(t, err) + require.NotNil(t, recorder) + result, err := recorder.QueryConnectionRecords() + require.NoError(t, err) +- require.Len(t, result, storeCount+transientStoreCount) ++ require.Len(t, result, storeCount+protocolStateStoreCount) + }) + + t.Run("test query connection record failure", func(t *testing.T) { +@@ -382,20 +382,20 @@ func TestGetConnectionIDByDIDs(t *testing.T) { + + // mockProvider for connection recorder + type mockProvider struct { +- transientStoreError error +- storeError error +- store storage.Store +- transientStore storage.Store ++ protocolStateStoreError error ++ storeError error ++ store storage.Store ++ protocolStateStore storage.Store + } + +-// TransientStorageProvider is mock transient storage provider for connection recorder +-func (p *mockProvider) TransientStorageProvider() storage.Provider { +- if p.transientStoreError != nil { +- return &mockstorage.MockStoreProvider{ErrOpenStoreHandle: p.transientStoreError} ++ ++func (p *mockProvider) ProtocolStateStorageProvider() storage.Provider { ++ if p.protocolStateStoreError != nil { ++ return &mockstorage.MockStoreProvider{ErrOpenStoreHandle: p.protocolStateStoreError} + } + +- if p.transientStore != nil { +- return mockstorage.NewCustomMockStoreProvider(p.transientStore) ++ if p.protocolStateStore != nil { ++ return mockstorage.NewCustomMockStoreProvider(p.protocolStateStore) + } + + return mockstorage.NewMockStoreProvider() +diff --git a/pkg/store/connection/connection_recorder_test.go b/pkg/store/connection/connection_recorder_test.go +index 10f787346..e22afcb72 100644 +--- a/pkg/store/connection/connection_recorder_test.go ++++ b/pkg/store/connection/connection_recorder_test.go +@@ -35,8 +35,8 @@ func Test_NewConnectionRecorder(t *testing.T) { + require.NotNil(t, recorder) + }) + +- t.Run("create new connection recorder - transient store error", func(t *testing.T) { +- lookup, err := NewRecorder(&mockProvider{transientStoreError: fmt.Errorf(sampleErrMsg)}) ++ t.Run("create new connection recorder - protocol state store error", func(t *testing.T) { ++ lookup, err := NewRecorder(&mockProvider{protocolStateStoreError: fmt.Errorf(sampleErrMsg)}) + require.Error(t, err) + require.Contains(t, err.Error(), sampleErrMsg) + require.Nil(t, lookup) +@@ -138,7 +138,7 @@ func Test_RemoveConnectionRecordsForStates(t *testing.T) { + require.NoError(t, err) + + recorder, err := NewRecorder(&protocol.MockProvider{ +- TransientStoreProvider: mockstorage.NewCustomMockStoreProvider(store), ++ ProtocolStateStoreProvider: mockstorage.NewCustomMockStoreProvider(store), + }) + require.NoError(t, err) + require.NotNil(t, recorder) +@@ -155,7 +155,7 @@ func Test_RemoveConnectionRecordsForStates(t *testing.T) { + } + + recorder, err := NewRecorder(&protocol.MockProvider{ +- TransientStoreProvider: mockstorage.NewCustomMockStoreProvider(store), ++ ProtocolStateStoreProvider: mockstorage.NewCustomMockStoreProvider(store), + }) + require.NoError(t, err) + require.NotNil(t, recorder) +@@ -185,7 +185,7 @@ func Test_RemoveConnectionRecordsForStates(t *testing.T) { + require.NoError(t, err) + + recorder, err := NewRecorder(&protocol.MockProvider{ +- TransientStoreProvider: mockstorage.NewCustomMockStoreProvider(store), ++ ProtocolStateStoreProvider: mockstorage.NewCustomMockStoreProvider(store), + }) + require.NoError(t, err) + require.NotNil(t, recorder) +@@ -230,7 +230,7 @@ func TestConnectionStore_SaveInvitation(t *testing.T) { + require.Equal(t, value, &v1) + + var v2 mockInvitation +- err = getAndUnmarshal(k, &v2, recorder.transientStore) ++ err = getAndUnmarshal(k, &v2, recorder.protocolStateStore) + require.Error(t, err) + require.Contains(t, err.Error(), "data not found") + }) +@@ -384,14 +384,14 @@ func TestConnectionRecorder_SaveConnectionRecord(t *testing.T) { + require.NotNil(t, recordFound) + require.Equal(t, record, recordFound) + +- // make sure it exists only in transient store ++ + var r1 Record + err = getAndUnmarshal(getConnectionKeyPrefix()(record.ConnectionID), &r1, recorder.store) + require.Error(t, err) + require.Contains(t, err.Error(), "data not found") + + var r2 Record +- err = getAndUnmarshal(getConnectionKeyPrefix()(record.ConnectionID), &r2, recorder.transientStore) ++ err = getAndUnmarshal(getConnectionKeyPrefix()(record.ConnectionID), &r2, recorder.protocolStateStore) + require.NoError(t, err) + require.Equal(t, record, &r2) + }) +@@ -417,9 +417,9 @@ func TestConnectionRecorder_SaveConnectionRecord(t *testing.T) { + require.NotNil(t, recordFound) + require.Equal(t, record, recordFound) + +- // make sure it exists only in both permanent and transient store ++ + var r1 Record +- err = getAndUnmarshal(getConnectionKeyPrefix()(record.ConnectionID), &r1, recorder.transientStore) ++ err = getAndUnmarshal(getConnectionKeyPrefix()(record.ConnectionID), &r1, recorder.protocolStateStore) + require.NoError(t, err) + require.Equal(t, record, &r1) + +@@ -432,7 +432,7 @@ func TestConnectionRecorder_SaveConnectionRecord(t *testing.T) { + t.Run("save connection record error scenario 1", func(t *testing.T) { + const errMsg = "get error" + record, err := NewRecorder(&protocol.MockProvider{ +- TransientStoreProvider: mockstorage.NewCustomMockStoreProvider(&mockstorage.MockStore{ ++ ProtocolStateStoreProvider: mockstorage.NewCustomMockStoreProvider(&mockstorage.MockStore{ + Store: make(map[string][]byte), + ErrPut: fmt.Errorf(errMsg), + }), +@@ -485,9 +485,9 @@ func TestConnectionRecorder_RemoveConnection(t *testing.T) { + err = recorder.RemoveConnection(record.ConnectionID) + require.NoError(t, err) + +- // make sure no records exist in both permanent and transient store ++ + var r1 Record +- err = getAndUnmarshal(getConnectionKeyPrefix()(record.ConnectionID), &r1, recorder.transientStore) ++ err = getAndUnmarshal(getConnectionKeyPrefix()(record.ConnectionID), &r1, recorder.protocolStateStore) + require.Error(t, err) + require.Contains(t, err.Error(), "data not found") + +@@ -496,14 +496,14 @@ func TestConnectionRecorder_RemoveConnection(t *testing.T) { + require.Error(t, err) + require.Contains(t, err.Error(), "data not found") + +- itr := recorder.transientStore.Iterator( ++ itr := recorder.protocolStateStore.Iterator( + getConnectionStateKeyPrefix()(record.ConnectionID), + getConnectionStateKeyPrefix()(record.ConnectionID)+storage.EndKeySuffix, + ) + defer itr.Release() + + for itr.Next() { +- t.Errorf("transient store still has connection state records: key=%s", itr.Key()) ++ t.Errorf("protocol state store still has connection state records: key=%s", itr.Key()) + } + + var r3 Record +@@ -555,10 +555,10 @@ func TestConnectionRecorder_RemoveConnection(t *testing.T) { + require.Error(t, err) + require.Contains(t, err.Error(), errMsg) + }) +- t.Run("save and remove connection record - failed to delete from the transient store", func(t *testing.T) { ++ t.Run("save and remove connection record - failed to delete from the protocol state store", func(t *testing.T) { + const errMsg = "get error" + recorder, err := NewRecorder(&protocol.MockProvider{ +- TransientStoreProvider: mockstorage.NewCustomMockStoreProvider(&mockstorage.MockStore{ ++ ProtocolStateStoreProvider: mockstorage.NewCustomMockStoreProvider(&mockstorage.MockStore{ + Store: make(map[string][]byte), + ErrDelete: fmt.Errorf(errMsg), + }), +@@ -584,7 +584,7 @@ func TestConnectionRecorder_RemoveConnection(t *testing.T) { + t.Run("save and remove connection record - failed to iterate connection states records", func(t *testing.T) { + const errMsg = "get error" + recorder, err := NewRecorder(&protocol.MockProvider{ +- TransientStoreProvider: mockstorage.NewCustomMockStoreProvider(&mockstorage.MockStore{ ++ ProtocolStateStoreProvider: mockstorage.NewCustomMockStoreProvider(&mockstorage.MockStore{ + Store: make(map[string][]byte), + ErrItr: fmt.Errorf(errMsg), + }), +@@ -677,7 +677,7 @@ func TestConnectionRecorder_ConnectionRecordMappings(t *testing.T) { + t.Run("save connection record with mapping - store failure", func(t *testing.T) { + const errMsg = "put error" + recorder, err := NewRecorder(&protocol.MockProvider{ +- TransientStoreProvider: mockstorage.NewCustomMockStoreProvider(&mockstorage.MockStore{ ++ ProtocolStateStoreProvider: mockstorage.NewCustomMockStoreProvider(&mockstorage.MockStore{ + Store: make(map[string][]byte), + ErrPut: fmt.Errorf(errMsg), + }), +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,6 @@ ++H4sIAAAAAAAAA+3SXY6CMBAHcJ45RS8gX4o+eZNNDJQBG6FD2uJ6/C1mE8mKug8as9n/76XNzKSd ++ZhqVg2qrHeljHLxK4m3y/Lx6P9fzPs2zNMvWWbZcBUmarn1I5C/raGKwrjBCBIbZ3at7lP+josv8 ++HVm3k9x1ha4iu3/eHY/mv5nMP02Xfv6rdZIHInleC7f98/nLSpwHX1IVhg2LcS8WkgfttqlYONUR ++D04sk8SKxZHclutafIRCRHF/aGLZKtIurlRFJ7kvdEPXyY4qVTg21xl/Mtel/27TFGtnuG3JxN9/ ++8dbpl0Ljm75R5aPjMXFv2LHk9rdlM03P1FhbNNQreRj6e4Vz76xN0dEnm0NcGEV2NjM+kU5ukrO+ ++JRrjmqRTrMN3/x8AAAAAAAAAAAAAAAAAAAAAeK8vGi1VWwAoAAA= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-001541/tests/test.sh b/tasks/format-code-task-001541/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..69418e4f655539db7f793ca0197b5d745d53acec --- /dev/null +++ b/tasks/format-code-task-001541/tests/test.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +pkg/client/didexchange/client_test.go +pkg/client/didexchange/example_test.go +pkg/client/mediator/example_test.go +pkg/client/outofband/client_test.go +pkg/client/outofband/example_test.go +pkg/controller/command/didexchange/command_test.go +pkg/controller/rest/didexchange/operation_test.go +pkg/didcomm/protocol/didexchange/persistence_test.go +pkg/didcomm/protocol/didexchange/service_test.go +pkg/didcomm/protocol/mediator/service_test.go +pkg/didcomm/protocol/messagepickup/service_test.go +pkg/didcomm/protocol/outofband/service_test.go +pkg/framework/aries/example_test.go +pkg/framework/aries/framework_test.go +pkg/framework/context/context_test.go +pkg/store/connection/connection_lookup_test.go +pkg/store/connection/connection_recorder_test.go +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001541/tests/test_command.sh b/tasks/format-code-task-001541/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001541/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001546/environment/Dockerfile b/tasks/format-code-task-001546/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c2387810fa2444cc5eacf754b6dcc4fbd1362a26 --- /dev/null +++ b/tasks/format-code-task-001546/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:4ce2e58c67d40bfe52b2491c90de97bd434253440759945cd35a8d22f52d5f4b diff --git a/tasks/format-code-task-001546/environment/setup/files/blocklist b/tasks/format-code-task-001546/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001546/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001546/environment/setup/setup.sh b/tasks/format-code-task-001546/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001546/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001546/tests/test.patch b/tasks/format-code-task-001546/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..12ecdb42a55b2442b9c02741e6652520d25009a3 --- /dev/null +++ b/tasks/format-code-task-001546/tests/test.patch @@ -0,0 +1,166 @@ +diff --git a/cart/infrastructure/InMemoryBehaviour_test.go b/cart/infrastructure/InMemoryBehaviour_test.go +index 810e36fb3..6ba8ccb87 100644 +--- a/cart/infrastructure/InMemoryBehaviour_test.go ++++ b/cart/infrastructure/InMemoryBehaviour_test.go +@@ -2,6 +2,7 @@ package infrastructure + + import ( + "context" ++ "reflect" + "testing" + + domaincart "flamingo.me/flamingo-commerce/v3/cart/domain/cart" +@@ -189,3 +190,98 @@ func TestInMemoryBehaviour_CleanDelivery(t *testing.T) { + }) + } + } ++ ++func TestInMemoryBehaviour_RemoveVoucher(t *testing.T) { ++ type args struct { ++ ctx context.Context ++ cart *domaincart.Cart ++ couponCodeToRemove string ++ } ++ tests := []struct { ++ name string ++ args args ++ want *domaincart.Cart ++ }{ ++ { ++ name: "Remove voucher from cart with vouchers", ++ args: args{ ++ ctx: nil, ++ cart: &domaincart.Cart{ ++ AppliedCouponCodes: []domaincart.CouponCode{ ++ {Code: "OFF20"}, ++ {Code: "dummy-voucher-20"}, ++ {Code: "SALE"}, ++ }, ++ }, ++ couponCodeToRemove: "dummy-voucher-20", ++ }, ++ want: &domaincart.Cart{ ++ AppliedCouponCodes: []domaincart.CouponCode{ ++ {Code: "OFF20"}, ++ {Code: "SALE"}, ++ }, ++ }, ++ }, ++ { ++ name: "Remove voucher from cart without vouchers", ++ args: args{ ++ ctx: nil, ++ cart: &domaincart.Cart{}, ++ couponCodeToRemove: "dummy-voucher-20", ++ }, ++ want: &domaincart.Cart{}, ++ }, ++ { ++ name: "Remove voucher from cart that does not exist", ++ args: args{ ++ ctx: nil, ++ cart: &domaincart.Cart{ ++ AppliedCouponCodes: []domaincart.CouponCode{ ++ {Code: "OFF20"}, ++ {Code: "dummy-voucher-20"}, ++ {Code: "SALE"}, ++ }, ++ }, ++ couponCodeToRemove: "non-existing-voucher", ++ }, ++ want: &domaincart.Cart{ ++ AppliedCouponCodes: []domaincart.CouponCode{ ++ {Code: "OFF20"}, ++ {Code: "dummy-voucher-20"}, ++ {Code: "SALE"}, ++ }, ++ }, ++ }, ++ } ++ for _, tt := range tests { ++ t.Run(tt.name, func(t *testing.T) { ++ cob := &InMemoryBehaviour{} ++ cob.Inject( ++ &InMemoryCartStorage{}, ++ nil, ++ flamingo.NullLogger{}, ++ func() *domaincart.ItemBuilder { ++ return &domaincart.ItemBuilder{} ++ }, ++ func() *domaincart.DeliveryBuilder { ++ return &domaincart.DeliveryBuilder{} ++ }, ++ func() *domaincart.Builder { ++ return &domaincart.Builder{} ++ }, ++ nil, ++ nil, ++ ) ++ ++ if err := cob.cartStorage.StoreCart(tt.args.cart); err != nil { ++ t.Fatalf("cart could not be initialized") ++ } ++ ++ got, _, _ := cob.RemoveVoucher(tt.args.ctx, tt.args.cart, tt.args.couponCodeToRemove) ++ if !reflect.DeepEqual(got, tt.want) { ++ t.Errorf("InMemoryBehaviour.RemoveVoucher() got = %v, want %v", got, tt.want) ++ } ++ ++ }) ++ } ++} +diff --git a/cart/module_test.go b/cart/module_test.go +new file mode 100644 +index 000000000..ded47f7bd +--- /dev/null ++++ b/cart/module_test.go +@@ -0,0 +1,23 @@ ++package cart_test ++ ++import ( ++ "testing" ++ ++ "flamingo.me/dingo" ++ "flamingo.me/flamingo-commerce/v3/cart" ++ "flamingo.me/flamingo/v3/framework/config" ++) ++ ++func TestModule_Configure(t *testing.T) { ++ cfgModule := &config.Module{ ++ Map: new(cart.Module).DefaultConfig(), ++ } ++ ++ cfgModule.Map["session.backend"] = "" ++ cfgModule.Map["oauth.useFake"] = true ++ cfgModule.Map["oauth.preventSimultaneousSessions"] = true ++ ++ if err := dingo.TryModule(cfgModule, new(cart.Module)); err != nil { ++ t.Error(err) ++ } ++} +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,10 @@ ++H4sIAAAAAAAAA+3TX2/TMBAA8D7nU5zEwwApaZwmTfPQB9jYkPgzicEb0uTE1yYosafYaXnYh985 ++rKybgAlpEwLuFyl2e/HZ8TlROTStOke9mU4eS0zyLBtbcrcd+yJLhMhyutH/vpdOIHu0Fe0ZrJM9 ++wKQ3xv3qufvif6nopv4OrTuvTNdJrSJbP9wc99RfiHn2vf5xklL907nIJxA/3BJ+7j+vf6VgLHyJ ++KgiewMcaYW2iziiopYULi4My4QZ72xhtYdu4Glw/6Eo6VFNDgdboNfhT0zg/pEYLrpaOclES7DWc ++GOjxC1bORgDHzVcKYwfOQCW10U0lW1iZvoMSqUF61pp201BSGj+0aKPAooKwgc8BQIhwYC83cURX ++mMSiiMXuCst8nswXWX47TMcqpZN1Ey6KNLlcH/ww3WIv3WKmkiKv0nKeSiwThSkNV4XM0opu8Uxi ++ohZiVuwNz+NcJHEhillya/huum876/f5yGx1a6TavSQ8la01MFwo2ljrH7RD5/fF7xZo3N4txbPg ++5PT96dmnd4evXx2+WT6H659HL8f+8dsXJ2fLkLIvfS3Xxk8E6npWv4IPgx5zu60B+gLW6MCfA1g1 ++tJzfTT6ODDfjS0bTSvZu2uhVLy2dlcoNPU73Q8GfPvSMMcYYY4wxxhhjjDHGGGOMMcYYY/+QK7vq ++MyYAKAAA +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-001546/tests/test.sh b/tasks/format-code-task-001546/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..5ed3dafc9129a895990904dd48e5861a6797c2d3 --- /dev/null +++ b/tasks/format-code-task-001546/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +cart/infrastructure/InMemoryBehaviour_test.go +cart/module_test.go +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001546/tests/test_command.sh b/tasks/format-code-task-001546/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001546/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001652/environment/Dockerfile b/tasks/format-code-task-001652/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..31ba7c06d5570479c121a21e06ad8882f999f089 --- /dev/null +++ b/tasks/format-code-task-001652/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:620b6e736a739d62aca1e3131c028a5673f07d1824976180b723115d4c807629 diff --git a/tasks/format-code-task-001652/environment/setup/files/blocklist b/tasks/format-code-task-001652/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001652/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001652/environment/setup/setup.sh b/tasks/format-code-task-001652/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001652/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001652/tests/test.patch b/tasks/format-code-task-001652/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..cbc97a3349449531335351608173ea20d00cd14c --- /dev/null +++ b/tasks/format-code-task-001652/tests/test.patch @@ -0,0 +1,225 @@ +diff --git a/tests/it/compute/lower.rs b/tests/it/compute/lower.rs +new file mode 100644 +index 00000000000..d8f594174fb +--- /dev/null ++++ b/tests/it/compute/lower.rs +@@ -0,0 +1,186 @@ ++use arrow2::{array::*, compute::lower::*, error::Result}; ++ ++fn with_nulls_utf8() -> Result<()> { ++ let cases = vec![ ++ ++ ( ++ vec![Some("hello"), None, Some("world")], ++ vec![Some("hello"), None, Some("world")], ++ ), ++ ++ ( ++ vec![Some("Hello"), None, Some("wOrld")], ++ vec![Some("hello"), None, Some("world")], ++ ), ++ ++ ( ++ vec![Some("HELLO"), None, Some("WORLD")], ++ vec![Some("hello"), None, Some("world")], ++ ), ++ ++ ( ++ vec![ ++ None, ++ Some("السلام عليكم"), ++ Some("Dobrý den"), ++ Some("שָׁלוֹם"), ++ Some("नमस्ते"), ++ Some("こんにちは"), ++ Some("안녕하세요"), ++ Some("你好"), ++ Some("Olá"), ++ Some("Здравствуйте"), ++ Some("Hola"), ++ ], ++ vec![ ++ None, ++ Some("السلام عليكم"), ++ Some("dobrý den"), ++ Some("שָׁלוֹם"), ++ Some("नमस्ते"), ++ Some("こんにちは"), ++ Some("안녕하세요"), ++ Some("你好"), ++ Some("olá"), ++ Some("здравствуйте"), ++ Some("hola"), ++ ], ++ ), ++ ]; ++ ++ cases ++ .into_iter() ++ .try_for_each::<_, Result<()>>(|(array, expected)| { ++ let array = Utf8Array::::from(&array); ++ let result = lower(&array)?; ++ assert_eq!(array.len(), result.len()); ++ ++ let result = result.as_any().downcast_ref::>().unwrap(); ++ let expected = Utf8Array::::from(&expected); ++ ++ assert_eq!(&expected, result); ++ Ok(()) ++ })?; ++ ++ Ok(()) ++} ++ ++#[test] ++fn with_nulls_string() -> Result<()> { ++ with_nulls_utf8::() ++} ++ ++#[test] ++fn with_nulls_large_string() -> Result<()> { ++ with_nulls_utf8::() ++} ++ ++fn without_nulls_utf8() -> Result<()> { ++ let cases = vec![ ++ ++ (vec!["hello", "world"], vec!["hello", "world"]), ++ ++ (vec!["Hello", "wOrld"], vec!["hello", "world"]), ++ ++ (vec!["HELLO", "WORLD"], vec!["hello", "world"]), ++ ++ ( ++ vec![ ++ "السلام عليكم", ++ "Dobrý den", ++ "שָׁלוֹם", ++ "नमस्ते", ++ "こんにちは", ++ "안녕하세요", ++ "你好", ++ "Olá", ++ "Здравствуйте", ++ "Hola", ++ ], ++ vec![ ++ "السلام عليكم", ++ "dobrý den", ++ "שָׁלוֹם", ++ "नमस्ते", ++ "こんにちは", ++ "안녕하세요", ++ "你好", ++ "olá", ++ "здравствуйте", ++ "hola", ++ ], ++ ), ++ ]; ++ ++ cases ++ .into_iter() ++ .try_for_each::<_, Result<()>>(|(array, expected)| { ++ let array = Utf8Array::::from_slice(&array); ++ let result = lower(&array)?; ++ assert_eq!(array.len(), result.len()); ++ ++ let result = result.as_any().downcast_ref::>().unwrap(); ++ let expected = Utf8Array::::from_slice(&expected); ++ assert_eq!(&expected, result); ++ Ok(()) ++ })?; ++ ++ Ok(()) ++} ++ ++#[test] ++fn without_nulls_string() -> Result<()> { ++ without_nulls_utf8::() ++} ++ ++#[test] ++fn without_nulls_large_string() -> Result<()> { ++ without_nulls_utf8::() ++} ++ ++#[test] ++fn consistency() { ++ use arrow2::datatypes::DataType::*; ++ use arrow2::datatypes::TimeUnit; ++ let datatypes = vec![ ++ Null, ++ Boolean, ++ UInt8, ++ UInt16, ++ UInt32, ++ UInt64, ++ Int8, ++ Int16, ++ Int32, ++ Int64, ++ Float32, ++ Float64, ++ Timestamp(TimeUnit::Second, None), ++ Timestamp(TimeUnit::Millisecond, None), ++ Timestamp(TimeUnit::Microsecond, None), ++ Timestamp(TimeUnit::Nanosecond, None), ++ Time64(TimeUnit::Microsecond), ++ Time64(TimeUnit::Nanosecond), ++ Date32, ++ Time32(TimeUnit::Second), ++ Time32(TimeUnit::Millisecond), ++ Date64, ++ Utf8, ++ LargeUtf8, ++ Binary, ++ LargeBinary, ++ Duration(TimeUnit::Second), ++ Duration(TimeUnit::Millisecond), ++ Duration(TimeUnit::Microsecond), ++ Duration(TimeUnit::Nanosecond), ++ ]; ++ ++ datatypes.into_iter().for_each(|d1| { ++ let array = new_null_array(d1.clone(), 10); ++ if can_lower(&d1) { ++ assert!(lower(array.as_ref()).is_ok()); ++ } else { ++ assert!(lower(array.as_ref()).is_err()); ++ } ++ }); ++} +diff --git a/tests/it/compute/mod.rs b/tests/it/compute/mod.rs +index ff55ab74d7b..d4bd0b008eb 100644 +--- a/tests/it/compute/mod.rs ++++ b/tests/it/compute/mod.rs +@@ -28,6 +28,8 @@ mod length; + mod like; + #[cfg(feature = "compute_limit")] + mod limit; ++#[cfg(feature = "compute_lower")] ++mod lower; + #[cfg(feature = "compute_merge_sort")] + mod merge_sort; + #[cfg(feature = "compute_partition")] +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,4 @@ ++H4sIAAAAAAAAA+3SWwoCIRiGYa9bhRto0mmcoM0Mc7ADVIbj1PYzIYqguikiep+b3xP4y2fWDOtN ++V9ndYSI+RUUzY1KN7msaa5OrqVJlYUqhtC5VLqT5WEc3hj7UXkrhnQvPzr3a/1HZNf9g+1C1brut ++d13Wr953x6v8tS6u+eezmH9RaiWkel8Lj/15/m0nU/CN7UZt7ZdOnmdyPE5lfR4tbB0Gb3sZ/8Z+ ++CLbauKP1ceOyMJ+nldG33wIAAAAAAAAAAAAAAAD8mxO+R9foACgAAA== +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-001652/tests/test.sh b/tasks/format-code-task-001652/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..ba82584c68c5f4ed52ff80c197f94e56a4e14d6b --- /dev/null +++ b/tasks/format-code-task-001652/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/it/compute/lower.rs +tests/it/compute/mod.rs +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001652/tests/test_command.sh b/tasks/format-code-task-001652/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001652/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001663/environment/Dockerfile b/tasks/format-code-task-001663/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..61eff8cdcdd560bccc6754cc5fcf2e251590c9bd --- /dev/null +++ b/tasks/format-code-task-001663/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:3bba88d103e152d16f2d840ab20431cd91bc8ebba36252de4077f6e4ac3fa258 diff --git a/tasks/format-code-task-001663/environment/setup/files/blocklist b/tasks/format-code-task-001663/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001663/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001663/environment/setup/setup.sh b/tasks/format-code-task-001663/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001663/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001663/tests/test.patch b/tasks/format-code-task-001663/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..7b73d7350cc30f63cc4b42291f1d36bb6dadb5ae --- /dev/null +++ b/tasks/format-code-task-001663/tests/test.patch @@ -0,0 +1,287 @@ +diff --git a/cloudconfig/podcfg/image_test.go b/cloudconfig/podcfg/image_test.go +index 3e67ec4e8e..e851a6ea34 100644 +--- a/cloudconfig/podcfg/image_test.go ++++ b/cloudconfig/podcfg/image_test.go +@@ -4,6 +4,8 @@ + package podcfg_test + + import ( ++ "github.com/juju/charm/v8" ++ "github.com/juju/errors" + jc "github.com/juju/testing/checkers" + "github.com/juju/version/v2" + gc "gopkg.in/check.v1" +@@ -11,8 +13,6 @@ import ( + "github.com/juju/juju/cloudconfig/podcfg" + "github.com/juju/juju/controller" + "github.com/juju/juju/testing" +- "github.com/juju/systems" +- "github.com/juju/systems/channel" + ) + + type imageSuite struct { +@@ -34,27 +34,51 @@ func (*imageSuite) TestGetJujuOCIImagePath(c *gc.C) { + c.Assert(path, jc.DeepEquals, "testing-old-repo/jujud-old-operator:2.6-beta3") + } + +-func (*imageSuite) TestImageForBase(c *gc.C) { +- _, err := podcfg.ImageForBase("", systems.Base{}) +- c.Assert(err, gc.ErrorMatches, `base name not valid`) ++func (*imageSuite) TestImageForBaseRejectsEmptyBaseName(c *gc.C) { ++ _, err := podcfg.ImageForBase("", charm.Base{}) ++ c.Assert(err, jc.Satisfies, errors.IsNotValid) ++ c.Assert(err.Error(), gc.Equals, "empty base name not valid") + +- _, err = podcfg.ImageForBase("", systems.Base{Name: "ubuntu"}) +- c.Assert(err, gc.ErrorMatches, `channel "" not valid`) ++ _, err = podcfg.ImageForBase("example.test/juju", charm.Base{ ++ Channel: charm.Channel{ ++ Track: "20.04", ++ Risk: charm.Stable, ++ }, ++ }) ++ c.Assert(err, jc.Satisfies, errors.IsNotValid) ++ c.Assert(err.Error(), gc.Equals, "empty base name not valid") ++} ++ ++func (*imageSuite) TestImageForBaseRejectsInvalidCharmBaseChannel(c *gc.C) { ++ _, err := podcfg.ImageForBase("", charm.Base{Name: "ubuntu"}) ++ c.Assert(err, jc.Satisfies, errors.IsNotValid) + +- _, err = podcfg.ImageForBase("", systems.Base{Name: "ubuntu", Channel: channel.Channel{ ++ _, err = podcfg.ImageForBase("", charm.Base{Name: "ubuntu", Channel: charm.Channel{ + Track: "20.04", + }}) +- c.Assert(err, gc.ErrorMatches, `channel "" not valid`) ++ c.Assert(err, jc.Satisfies, errors.IsNotValid) ++} + +- path, err := podcfg.ImageForBase("", systems.Base{Name: "ubuntu", Channel: channel.Channel{ +- Track: "20.04", Risk: channel.Stable, +- }}) ++func (*imageSuite) TestImageForBaseUsesCharmBaseStable(c *gc.C) { ++ path, err := podcfg.ImageForBase("", charm.Base{ ++ Name: "ubuntu", ++ Channel: charm.Channel{ ++ Track: "20.04", ++ Risk: charm.Stable, ++ }, ++ }) + c.Assert(err, jc.ErrorIsNil) + c.Assert(path, gc.DeepEquals, `jujusolutions/charm-base:ubuntu-20.04`) ++} + +- path, err = podcfg.ImageForBase("", systems.Base{Name: "ubuntu", Channel: channel.Channel{ +- Track: "20.04", Risk: channel.Edge, +- }}) ++func (*imageSuite) TestImageForBaseUsesCharmBaseNonStable(c *gc.C) { ++ path, err := podcfg.ImageForBase("example.test/juju", charm.Base{ ++ Name: "ubuntu", ++ Channel: charm.Channel{ ++ Track: "22.04", ++ Risk: charm.Edge, ++ }, ++ }) + c.Assert(err, jc.ErrorIsNil) +- c.Assert(path, gc.DeepEquals, `jujusolutions/charm-base:ubuntu-20.04-edge`) ++ c.Assert(path, gc.DeepEquals, `example.test/juju/charm-base:ubuntu-22.04-edge`) + } +diff --git a/worker/caasapplicationprovisioner/application_test.go b/worker/caasapplicationprovisioner/application_test.go +index 9f6871bb08..7b4dd8a7bf 100644 +--- a/worker/caasapplicationprovisioner/application_test.go ++++ b/worker/caasapplicationprovisioner/application_test.go +@@ -372,6 +372,164 @@ func (s *ApplicationWorkerSuite) TestWorker(c *gc.C) { + workertest.CleanKill(c, appWorker) + } + ++func (s *ApplicationWorkerSuite) TestWorkerUsesSeriesToResolveCharmBaseImage(c *gc.C) { ++ for _, test := range []struct { ++ series string ++ expectedImage string ++ }{{ ++ series: "focal", ++ expectedImage: "example.test/juju/charm-base:ubuntu-20.04", ++ }, { ++ series: "hirsute", ++ expectedImage: "example.test/juju/charm-base:ubuntu-21.04", ++ }} { ++ c.Logf("series %s", test.series) ++ ++ ctrl := gomock.NewController(c) ++ s.assertWorkerUsesSeriesToResolveCharmBaseImage(c, ctrl, test.series, test.expectedImage) ++ ctrl.Finish() ++ } ++} ++ ++func (s *ApplicationWorkerSuite) assertWorkerUsesSeriesToResolveCharmBaseImage(c *gc.C, ctrl *gomock.Controller, seriesName, expectedImage string) { ++ appCharmURL := &charm.URL{ ++ Schema: "cs", ++ Name: "test", ++ Revision: -1, ++ } ++ appCharmInfo := &charmscommon.CharmInfo{ ++ Meta: &charm.Meta{ ++ Name: "test", ++ Containers: map[string]charm.Container{ ++ "test": { ++ Resource: "test-oci", ++ }, ++ }, ++ Resources: map[string]charmresource.Meta{ ++ "test-oci": { ++ Type: charmresource.TypeContainerImage, ++ }, ++ }, ++ }, ++ Manifest: &charm.Manifest{ ++ Bases: []charm.Base{{ ++ Name: "ubuntu", ++ Channel: charm.Channel{ ++ Track: "20.04", ++ Risk: charm.Stable, ++ }, ++ }}, ++ }, ++ } ++ appProvisioningInfo := api.ProvisioningInfo{ ++ Series: seriesName, ++ CharmURL: appCharmURL, ++ ImageRepo: "example.test/juju", ++ } ++ ociResources := map[string]resources.DockerImageDetails{ ++ "test-oci": { ++ RegistryPath: "example.test/workload:1.0", ++ }, ++ } ++ ++ appStateChan := make(chan struct{}, 1) ++ appStateWatcher := watchertest.NewMockNotifyWatcher(appStateChan) ++ appChan := make(chan struct{}, 1) ++ appWatcher := watchertest.NewMockNotifyWatcher(appChan) ++ appReplicasChan := make(chan struct{}, 1) ++ appReplicasWatcher := watchertest.NewMockNotifyWatcher(appReplicasChan) ++ appScaleChan := make(chan struct{}, 1) ++ appScaleWatcher := watchertest.NewMockNotifyWatcher(appScaleChan) ++ appTrustHashChan := make(chan []string, 1) ++ appTrustHashWatcher := watchertest.NewMockStringsWatcher(appTrustHashChan) ++ ++ brokerApp := caasmocks.NewMockApplication(ctrl) ++ broker := mocks.NewMockCAASBroker(ctrl) ++ facade := mocks.NewMockCAASProvisionerFacade(ctrl) ++ unitFacade := mocks.NewMockCAASUnitProvisionerFacade(ctrl) ++ ++ ensureDone := make(chan struct{}) ++ deleteDone := make(chan struct{}) ++ ++ facade.EXPECT().ApplicationCharmURL("test").Return(appCharmURL, nil).AnyTimes() ++ facade.EXPECT().CharmInfo("cs:test").Return(appCharmInfo, nil).AnyTimes() ++ facade.EXPECT().SetPassword("test", gomock.Any()).Return(nil).AnyTimes() ++ broker.EXPECT().Application("test", caas.DeploymentStateful).Return(brokerApp).AnyTimes() ++ unitFacade.EXPECT().WatchApplicationScale("test").Return(appScaleWatcher, nil).AnyTimes() ++ unitFacade.EXPECT().WatchApplicationTrustHash("test").Return(appTrustHashWatcher, nil).AnyTimes() ++ facade.EXPECT().WatchApplication("test").Return(appStateWatcher, nil).AnyTimes() ++ facade.EXPECT().ProvisioningInfo("test").Return(appProvisioningInfo, nil).AnyTimes() ++ facade.EXPECT().ApplicationOCIResources("test").Return(ociResources, nil).AnyTimes() ++ brokerApp.EXPECT().Exists().Return(caas.DeploymentState{}, nil).AnyTimes() ++ brokerApp.EXPECT().Watch().Return(appWatcher, nil).AnyTimes() ++ brokerApp.EXPECT().WatchReplicas().Return(appReplicasWatcher, nil).AnyTimes() ++ brokerApp.EXPECT().Delete().Return(nil).AnyTimes() ++ facade.EXPECT().Units("test").Return([]names.Tag(nil), nil).AnyTimes() ++ brokerApp.EXPECT().State().Return(caas.ApplicationState{}, nil).AnyTimes() ++ facade.EXPECT().SetOperatorStatus("test", status.Active, "deployed", nil).DoAndReturn(func(string, status.Status, string, map[string]interface{}) error { ++ select { ++ case <-ensureDone: ++ default: ++ close(ensureDone) ++ } ++ return nil ++ }).AnyTimes() ++ brokerApp.EXPECT().Ensure(gomock.Any()).DoAndReturn(func(config caas.ApplicationConfig) error { ++ c.Check(config.CharmBaseImage.RegistryPath, gc.Equals, expectedImage) ++ c.Check(config.Containers["test"].Image.RegistryPath, gc.Equals, "example.test/workload:1.0") ++ return nil ++ }).AnyTimes() ++ facade.EXPECT().GarbageCollect("test", []names.Tag(nil), 0, []string(nil), true).DoAndReturn(func(string, []names.Tag, int, []string, bool) error { ++ select { ++ case <-deleteDone: ++ default: ++ close(deleteDone) ++ } ++ return nil ++ }).AnyTimes() ++ lifeCalls := 0 ++ facade.EXPECT().Life("test").DoAndReturn(func(string) (life.Value, error) { ++ lifeCalls++ ++ if lifeCalls == 1 { ++ return life.Alive, nil ++ } ++ return life.Dead, nil ++ }).AnyTimes() ++ ++ config := caasapplicationprovisioner.AppWorkerConfig{ ++ Name: "test", ++ Facade: facade, ++ Broker: broker, ++ ModelTag: s.modelTag, ++ Clock: s.clock, ++ Logger: s.logger, ++ UnitFacade: unitFacade, ++ } ++ startFunc := caasapplicationprovisioner.NewAppWorker(config) ++ c.Assert(startFunc, gc.NotNil) ++ appWorker, err := startFunc() ++ c.Assert(err, jc.ErrorIsNil) ++ c.Assert(appWorker, gc.NotNil) ++ ++ go appWorker.(appNotifyWorker).Notify() ++ ++ select { ++ case <-ensureDone: ++ case <-time.After(coretesting.ShortWait): ++ c.Fatalf("timed out waiting for worker") ++ } ++ ++ appWorker.(appNotifyWorker).Notify() ++ ++ select { ++ case <-deleteDone: ++ case <-time.After(coretesting.ShortWait): ++ c.Fatalf("timed out waiting for worker to stop") ++ } ++ ++ workertest.CleanKill(c, appWorker) ++} ++ + type appNotifyWorker interface { + worker.Worker + Notify() +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,25 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++ ++set -e ++ ++ ++case "${1:-}" in ++ base) ++ go test -count=1 -v \ ++ ./apiserver/facades/controller/caasunitprovisioner/ \ ++ ./caas/kubernetes/provider/application/ \ ++ ./cloudconfig/podcfg/ \ ++ ./pki/ ++ ;; ++ new) ++ go test -count=1 -v ./cloudconfig/podcfg/ ./worker/caasapplicationprovisioner/ \ ++ -check.f 'TestImageForBaseRejectsEmptyBaseName|TestImageForBaseRejectsInvalidCharmBaseChannel|TestImageForBaseUsesCharmBaseStable|TestImageForBaseUsesCharmBaseNonStable|TestWorkerUsesSeriesToResolveCharmBaseImage' ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-001663/tests/test.sh b/tasks/format-code-task-001663/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..55541587048be8f2717a6e67e1d37a212c71d173 --- /dev/null +++ b/tasks/format-code-task-001663/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +cloudconfig/podcfg/image_test.go +worker/caasapplicationprovisioner/application_test.go +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001663/tests/test_command.sh b/tasks/format-code-task-001663/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-001663/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh base && bash /testbed/mimo_test_command.sh new \ No newline at end of file diff --git a/tasks/format-code-task-001664/environment/Dockerfile b/tasks/format-code-task-001664/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..83abdd92e8e86dc0542b90c4c82b8a1c87560afc --- /dev/null +++ b/tasks/format-code-task-001664/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:990a88be82900adf349ebf2c8337ba7602d91c19b6d6f00ebbbd74f9f398508f diff --git a/tasks/format-code-task-001664/environment/setup/files/blocklist b/tasks/format-code-task-001664/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001664/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001664/environment/setup/setup.sh b/tasks/format-code-task-001664/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001664/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001664/tests/test.patch b/tasks/format-code-task-001664/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..66433979288fc464fbc9690fe1b2a628378d2933 --- /dev/null +++ b/tasks/format-code-task-001664/tests/test.patch @@ -0,0 +1,48 @@ +diff --git a/core/database/schema/schema_test.go b/core/database/schema/schema_test.go +index 728815a8d2e..f6381166b92 100644 +--- a/core/database/schema/schema_test.go ++++ b/core/database/schema/schema_test.go +@@ -192,3 +192,23 @@ func (s *schemaSuite) TestEnsureHashBreaks(c *tc.C) { + _, err = schema.Ensure(c.Context(), s.TxnRunner()) + c.Assert(err, tc.ErrorMatches, `querying current schema version: hash mismatch for version 2`) + } ++ ++func (s *schemaSuite) TestHookIsApplied(c *tc.C) { ++ schema := New( ++ MakePatch("this would fail if the hook is not applied"), ++ ) ++ schema.Hook(func(int, string) (string, error) { ++ return "CREATE TABLE bar (id INTEGER PRIMARY KEY);", nil ++ }) ++ c.Log(&schema.hook) ++ ++ current, err := schema.Ensure(c.Context(), s.TxnRunner()) ++ c.Assert(err, tc.IsNil) ++ c.Assert(current, tc.DeepEquals, ChangeSet{Current: 0, Post: 1}) ++ ++ err = s.TxnRunner().StdTxn(c.Context(), func(ctx context.Context, tx *sql.Tx) error { ++ row := tx.QueryRowContext(ctx, "SELECT * FROM bar") ++ return row.Err() ++ }) ++ c.Assert(err, tc.ErrorIsNil) ++} +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,4 @@ ++H4sIAAAAAAAAA+3RQQ6CMBAFUNacYi5AyyiFlWchpW3ERGhCC15fYKHGRN1ojPG/zTSdJp3JF814 ++ONra9ZNMPiWfVUqtdXZf1zOrDXOZl8Vyz6yqIiH1sYlujCHqgSgZvI/P3r3q/yhxzT+6EGvju073 ++VoT2fX+8yp95e8l/q5b8izKvEsrfN8Jjf56/sbQG3zibWjdl4XSIpqW9JxabIp3r0iUhjR+ctDrq ++Rgcng2ldpyVlE2XGj33ccfrtVQAAAAAAAAAAAAAAAAAAAAAA/s4ZaU1K7gAoAAA= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-001664/tests/test.sh b/tasks/format-code-task-001664/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..2797b658a649681aeb6b67b11dcbab4c9fa9c2ca --- /dev/null +++ b/tasks/format-code-task-001664/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +core/database/schema/schema_test.go +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001664/tests/test_command.sh b/tasks/format-code-task-001664/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001664/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001697/environment/Dockerfile b/tasks/format-code-task-001697/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..1ebc4677ab079a3d4373fa318bcfd7a55429c9f1 --- /dev/null +++ b/tasks/format-code-task-001697/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:c78c25dc49dc459efa6a51cdf5078e4e35febcc6ac630fffdf5e2eb09d357af0 diff --git a/tasks/format-code-task-001697/environment/setup/files/blocklist b/tasks/format-code-task-001697/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001697/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001697/environment/setup/setup.sh b/tasks/format-code-task-001697/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001697/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001697/tests/test.patch b/tasks/format-code-task-001697/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..f9e1a528eca66f241ad21d4619259f0591f9b606 --- /dev/null +++ b/tasks/format-code-task-001697/tests/test.patch @@ -0,0 +1,282 @@ +diff --git a/blockchain/state/sync_test.go b/blockchain/state/sync_test.go +index c83c6ef0bc..a08179be6d 100644 +--- a/blockchain/state/sync_test.go ++++ b/blockchain/state/sync_test.go +@@ -220,17 +220,18 @@ func TestIterativeStateSyncBatched(t *testing.T) { testIterativeStateSync(t, + + func testIterativeStateSync(t *testing.T, count int) { + // Create a random state to copy +- srcDb, srcRoot, srcAccounts := makeTestState(t) ++ srcState, srcRoot, srcAccounts := makeTestState(t) + + // Create a destination state and sync with the scheduler +- dstDb := database.NewMemoryDBManager() +- sched := NewStateSync(srcRoot, dstDb, statedb.NewSyncBloom(1, dstDb.GetMemDB()), nil) ++ dstDiskDb := database.NewMemoryDBManager() ++ dstState := NewDatabase(dstDiskDb) ++ sched := NewStateSync(srcRoot, dstDiskDb, statedb.NewSyncBloom(1, dstDiskDb.GetMemDB()), nil) + + queue := append([]common.Hash{}, sched.Missing(count)...) + for len(queue) > 0 { + results := make([]statedb.SyncResult, len(queue)) + for i, hash := range queue { +- data, err := srcDb.TrieDB().Node(hash) ++ data, err := srcState.TrieDB().Node(hash) + if err != nil { + t.Fatalf("failed to retrieve node data for %x", hash) + } +@@ -239,7 +240,7 @@ func testIterativeStateSync(t *testing.T, count int) { + if _, index, err := sched.Process(results); err != nil { + t.Fatalf("failed to process result #%d: %v", index, err) + } +- batch := dstDb.NewBatch(database.StateTrieDB) ++ batch := dstDiskDb.NewBatch(database.StateTrieDB) + if _, err := sched.Commit(batch); err != nil { + t.Fatalf("failed to commit data: %v", err) + } +@@ -247,59 +248,59 @@ func testIterativeStateSync(t *testing.T, count int) { + queue = append(queue[:0], sched.Missing(count)...) + } + // Cross check that the two states are in sync +- checkStateAccounts(t, dstDb, srcRoot, srcAccounts) ++ checkStateAccounts(t, dstDiskDb, srcRoot, srcAccounts) + +- err := CheckStateConsistency(srcDb.TrieDB().DiskDB(), dstDb, srcRoot, 100, nil) ++ err := CheckStateConsistency(srcState, dstState, srcRoot, 100, nil) + assert.NoError(t, err) + + // Test with quit channel + quit := make(chan struct{}) + + // normal +- err = CheckStateConsistency(srcDb.TrieDB().DiskDB(), dstDb, srcRoot, 100, quit) ++ err = CheckStateConsistency(srcState, dstState, srcRoot, 100, quit) + assert.NoError(t, err) + + // quit + close(quit) +- err = CheckStateConsistency(srcDb.TrieDB().DiskDB(), dstDb, srcRoot, 100, quit) ++ err = CheckStateConsistency(srcState, dstState, srcRoot, 100, quit) + assert.Error(t, err, errStopByQuit) + } + + func TestCheckStateConsistencyMissNode(t *testing.T) { + // Create a random state to copy +- srcDb, srcRoot, _ := makeTestState(t) +- newDb, _, _ := makeTestState(t) ++ srcState, srcRoot, _ := makeTestState(t) ++ newState, _, _ := makeTestState(t) + +- oldState, err := New(srcRoot, NewDatabase(srcDb.TrieDB().DiskDB())) ++ srcStateDB, err := New(srcRoot, srcState) + assert.NoError(t, err) + +- it := NewNodeIterator(oldState) ++ it := NewNodeIterator(srcStateDB) + it.Next() // skip trie root node + + for it.Next() { + if !common.EmptyHash(it.Hash) { + hash := it.Hash +- data, _ := oldState.db.TrieDB().DiskDB().ReadStateTrieNode(hash[:]) ++ data, _ := srcStateDB.db.TrieDB().DiskDB().ReadStateTrieNode(hash[:]) + + // Remove nodes +- oldState.db.TrieDB().DiskDB().GetMemDB().Delete(hash[:]) +- newDb.TrieDB().DiskDB().GetMemDB().Delete(hash[:]) ++ srcState.TrieDB().DiskDB().GetMemDB().Delete(hash[:]) ++ newState.TrieDB().DiskDB().GetMemDB().Delete(hash[:]) + + // Check consistency : errIterator +- err = CheckStateConsistency(srcDb.TrieDB().DiskDB(), newDb.TrieDB().DiskDB(), srcRoot, 100, nil) ++ err = CheckStateConsistency(srcState, newState, srcRoot, 100, nil) + if !errors.Is(err, errIterator) { + t.Log("mismatched err", "err", err, "expErr", errIterator) + t.FailNow() + } + + // Recover nodes +- oldState.db.TrieDB().DiskDB().GetMemDB().Put(hash[:], data) +- newDb.TrieDB().DiskDB().GetMemDB().Put(hash[:], data) ++ srcState.TrieDB().DiskDB().GetMemDB().Put(hash[:], data) ++ newState.TrieDB().DiskDB().GetMemDB().Put(hash[:], data) + } + } + + // Check consistency : no error +- err = CheckStateConsistency(srcDb.TrieDB().DiskDB(), newDb.TrieDB().DiskDB(), srcRoot, 100, nil) ++ err = CheckStateConsistency(srcState, newState, srcRoot, 100, nil) + assert.NoError(t, err) + } + +@@ -307,18 +308,19 @@ func TestCheckStateConsistencyMissNode(t *testing.T) { + // partial results are returned, and the others sent only later. + func TestIterativeDelayedStateSync(t *testing.T) { + // Create a random state to copy +- srcDb, srcRoot, srcAccounts := makeTestState(t) ++ srcState, srcRoot, srcAccounts := makeTestState(t) + + // Create a destination state and sync with the scheduler +- dstDb := database.NewMemoryDBManager() +- sched := NewStateSync(srcRoot, dstDb, statedb.NewSyncBloom(1, dstDb.GetMemDB()), nil) ++ dstDiskDB := database.NewMemoryDBManager() ++ dstState := NewDatabase(dstDiskDB) ++ sched := NewStateSync(srcRoot, dstDiskDB, statedb.NewSyncBloom(1, dstDiskDB.GetMemDB()), nil) + + queue := append([]common.Hash{}, sched.Missing(0)...) + for len(queue) > 0 { + // Sync only half of the scheduled nodes + results := make([]statedb.SyncResult, len(queue)/2+1) + for i, hash := range queue[:len(results)] { +- data, err := srcDb.TrieDB().Node(hash) ++ data, err := srcState.TrieDB().Node(hash) + if err != nil { + t.Fatalf("failed to retrieve node data for %x", hash) + } +@@ -327,7 +329,7 @@ func TestIterativeDelayedStateSync(t *testing.T) { + if _, index, err := sched.Process(results); err != nil { + t.Fatalf("failed to process result #%d: %v", index, err) + } +- batch := dstDb.NewBatch(database.StateTrieDB) ++ batch := dstDiskDB.NewBatch(database.StateTrieDB) + if _, err := sched.Commit(batch); err != nil { + t.Fatalf("failed to commit data: %v", err) + } +@@ -335,9 +337,9 @@ func TestIterativeDelayedStateSync(t *testing.T) { + queue = append(queue[len(results):], sched.Missing(0)...) + } + // Cross check that the two states are in sync +- checkStateAccounts(t, dstDb, srcRoot, srcAccounts) ++ checkStateAccounts(t, dstDiskDB, srcRoot, srcAccounts) + +- err := CheckStateConsistency(srcDb.TrieDB().DiskDB(), dstDb, srcRoot, 100, nil) ++ err := CheckStateConsistency(srcState, dstState, srcRoot, 100, nil) + assert.NoError(t, err) + } + +@@ -349,10 +351,11 @@ func TestIterativeRandomStateSyncBatched(t *testing.T) { testIterativeRandomS + + func testIterativeRandomStateSync(t *testing.T, count int) { + // Create a random state to copy +- srcDb, srcRoot, srcAccounts := makeTestState(t) ++ srcState, srcRoot, srcAccounts := makeTestState(t) + + // Create a destination state and sync with the scheduler + dstDb := database.NewMemoryDBManager() ++ dstState := NewDatabase(dstDb) + sched := NewStateSync(srcRoot, dstDb, statedb.NewSyncBloom(1, dstDb.GetMemDB()), nil) + + queue := make(map[common.Hash]struct{}) +@@ -363,7 +366,7 @@ func testIterativeRandomStateSync(t *testing.T, count int) { + // Fetch all the queued nodes in a random order + results := make([]statedb.SyncResult, 0, len(queue)) + for hash := range queue { +- data, err := srcDb.TrieDB().Node(hash) ++ data, err := srcState.TrieDB().Node(hash) + if err != nil { + t.Fatalf("failed to retrieve node data for %x", hash) + } +@@ -386,7 +389,7 @@ func testIterativeRandomStateSync(t *testing.T, count int) { + // Cross check that the two states are in sync + checkStateAccounts(t, dstDb, srcRoot, srcAccounts) + +- err := CheckStateConsistency(srcDb.TrieDB().DiskDB(), dstDb, srcRoot, 100, nil) ++ err := CheckStateConsistency(srcState, dstState, srcRoot, 100, nil) + assert.NoError(t, err) + } + +@@ -394,10 +397,11 @@ func testIterativeRandomStateSync(t *testing.T, count int) { + // partial results are returned (Even those randomly), others sent only later. + func TestIterativeRandomDelayedStateSync(t *testing.T) { + // Create a random state to copy +- srcDb, srcRoot, srcAccounts := makeTestState(t) ++ srcState, srcRoot, srcAccounts := makeTestState(t) + + // Create a destination state and sync with the scheduler + dstDb := database.NewMemoryDBManager() ++ dstState := NewDatabase(dstDb) + sched := NewStateSync(srcRoot, dstDb, statedb.NewSyncBloom(1, dstDb.GetMemDB()), nil) + + queue := make(map[common.Hash]struct{}) +@@ -410,7 +414,7 @@ func TestIterativeRandomDelayedStateSync(t *testing.T) { + for hash := range queue { + delete(queue, hash) + +- data, err := srcDb.TrieDB().Node(hash) ++ data, err := srcState.TrieDB().Node(hash) + if err != nil { + t.Fatalf("failed to retrieve node data for %x", hash) + } +@@ -436,7 +440,7 @@ func TestIterativeRandomDelayedStateSync(t *testing.T) { + // Cross check that the two states are in sync + checkStateAccounts(t, dstDb, srcRoot, srcAccounts) + +- err := CheckStateConsistency(srcDb.TrieDB().DiskDB(), dstDb, srcRoot, 100, nil) ++ err := CheckStateConsistency(srcState, dstState, srcRoot, 100, nil) + assert.NoError(t, err) + } + +@@ -444,21 +448,22 @@ func TestIterativeRandomDelayedStateSync(t *testing.T) { + // the database. + func TestIncompleteStateSync(t *testing.T) { + // Create a random state to copy +- srcDb, srcRoot, srcAccounts := makeTestState(t) ++ srcState, srcRoot, srcAccounts := makeTestState(t) + +- checkTrieConsistency(srcDb.TrieDB().DiskDB().(database.DBManager), srcRoot) ++ checkTrieConsistency(srcState.TrieDB().DiskDB().(database.DBManager), srcRoot) + + // Create a destination state and sync with the scheduler + dstDb := database.NewMemoryDBManager() ++ dstState := NewDatabase(dstDb) + sched := NewStateSync(srcRoot, dstDb, statedb.NewSyncBloom(1, dstDb.GetMemDB()), nil) + +- added := []common.Hash{} ++ var added []common.Hash + queue := append([]common.Hash{}, sched.Missing(1)...) + for len(queue) > 0 { + // Fetch a batch of state nodes + results := make([]statedb.SyncResult, len(queue)) + for i, hash := range queue { +- data, err := srcDb.TrieDB().Node(hash) ++ data, err := srcState.TrieDB().Node(hash) + if err != nil { + t.Fatalf("failed to retrieve node data for %x", hash) + } +@@ -503,12 +508,12 @@ func TestIncompleteStateSync(t *testing.T) { + t.Fatalf("trie inconsistency not caught, missing: %x", key) + } + +- err := CheckStateConsistency(srcDb.TrieDB().DiskDB(), dstDb, srcRoot, 100, nil) ++ err := CheckStateConsistency(srcState, dstState, srcRoot, 100, nil) + assert.Error(t, err) + + dstDb.GetMemDB().Put(key, value) + } + +- err := CheckStateConsistency(srcDb.TrieDB().DiskDB(), dstDb, srcRoot, 100, nil) ++ err := CheckStateConsistency(srcState, dstState, srcRoot, 100, nil) + assert.NoError(t, err) + } +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,6 @@ ++H4sIAAAAAAAAA+3TsW6DMBQFUOZ8hbdMAUxwM3Vp2iFDOzTdI2NbxQrYETZISP34AkOSoqZZElVR ++7llsPT/khy6EWa0LuVGmiYJriTsLxoa1M16HPWVJPI9jNqdpEFPKFklA2NUmOlI7zytCgspa/1ff ++ufMbFR7y98r5jbBlyY0MXX65O87lz5J0n3+S9vmnD5QGJL7cCKfdef5CkiH4TMnJpyX9lswaMhO2 ++Nv6RkllVGzL96Mov5c63a8+9WrdGfPWllVcV97pR+/LKSN1oWfPiRMMT9yJXcjhd5kpsh5OlNU47 ++r4xoX7Vzb1aqn88/q4K3Sp64/r37Ym15dohR2/Eoo57frzPdz7ErlD+8zZSEUVZYsRU51yZyfT2a ++/HemAAAAAAAAAAAAAAAAAAAAAHA/vgH7W7ECACgAAA== +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-001697/tests/test.sh b/tasks/format-code-task-001697/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..b1e102b9472541f5e056c7bdaaef78edaff7ebe3 --- /dev/null +++ b/tasks/format-code-task-001697/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +blockchain/state/sync_test.go +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001697/tests/test_command.sh b/tasks/format-code-task-001697/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001697/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001711/environment/Dockerfile b/tasks/format-code-task-001711/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..243c269e3c70937b9417d837c446348c4b694f77 --- /dev/null +++ b/tasks/format-code-task-001711/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:0581a62582820fd7e551517a8f54134cf11491d369e65f4786257c2c34fddc8d diff --git a/tasks/format-code-task-001711/environment/setup/files/blocklist b/tasks/format-code-task-001711/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001711/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001711/environment/setup/setup.sh b/tasks/format-code-task-001711/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001711/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001711/tests/test.patch b/tasks/format-code-task-001711/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..1cd402af8c20dca72c0b1006fb433f578fb96d5a --- /dev/null +++ b/tasks/format-code-task-001711/tests/test.patch @@ -0,0 +1,413 @@ +diff --git a/usercase-test-coderl/test_search_paths.py b/usercase-test-coderl/test_search_paths.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_search_paths.py +@@ -0,0 +1,384 @@ ++import copy ++ ++from pbxproj import XcodeProject ++ ++ ++PROJECT_TREE = { ++ "objects": { ++ "PROJ": {"isa": "PBXProject", "buildConfigurationList": "PROJECTCFGS"}, ++ "APP": { ++ "isa": "PBXNativeTarget", ++ "name": "app", ++ "buildConfigurationList": "APPCFGS", ++ "buildPhases": ["COMPILE"], ++ }, ++ "REPORT": { ++ "isa": "PBXAggregateTarget", ++ "name": "report", ++ "buildConfigurationList": "REPORTCFGS", ++ "buildPhases": ["COMPILE"], ++ }, ++ "APPCFGS": { ++ "isa": "XCConfigurationList", ++ "buildConfigurations": ["APPREL", "APPDBG"], ++ }, ++ "REPORTCFGS": { ++ "isa": "XCConfigurationList", ++ "buildConfigurations": ["REPORTREL", "REPORTDBG"], ++ }, ++ "PROJECTCFGS": { ++ "isa": "XCConfigurationList", ++ "buildConfigurations": ["PROJREL", "PROJDBG"], ++ }, ++ "APPREL": { ++ "isa": "XCBuildConfiguration", ++ "name": "Release", ++ "buildSettings": {"base": "a"}, ++ }, ++ "APPDBG": {"isa": "XCBuildConfiguration", "name": "Debug", "id": "APPDBG"}, ++ "REPORTREL": { ++ "isa": "XCBuildConfiguration", ++ "name": "Release", ++ "id": "REPORTREL", ++ }, ++ "REPORTDBG": { ++ "isa": "XCBuildConfiguration", ++ "name": "Debug", ++ "id": "REPORTDBG", ++ }, ++ "PROJREL": {"isa": "XCBuildConfiguration", "name": "Release", "id": "PROJREL"}, ++ "PROJDBG": { ++ "isa": "XCBuildConfiguration", ++ "name": "Debug", ++ "id": "PROJDBG", ++ "buildSettings": {"base": "x"}, ++ }, ++ }, ++ "rootObject": "PROJ", ++} ++ ++PROJECT_PBXPROJ = """// !$*UTF8*$! ++{ ++ objects = { ++ APP = { isa = PBXNativeTarget; buildConfigurationList = APPCFGS; buildPhases = ( COMPILE, ); name = app; }; ++ REPORT = { isa = PBXAggregateTarget; buildConfigurationList = REPORTCFGS; buildPhases = ( COMPILE, ); name = report; }; ++ PROJ = { isa = PBXProject; buildConfigurationList = PROJECTCFGS; }; ++ APPREL = { isa = XCBuildConfiguration; buildSettings = { base = a; }; name = Release; }; ++ APPDBG = { isa = XCBuildConfiguration; id = APPDBG; name = Debug; }; ++ REPORTREL = { isa = XCBuildConfiguration; id = REPORTREL; name = Release; }; ++ REPORTDBG = { isa = XCBuildConfiguration; id = REPORTDBG; name = Debug; }; ++ PROJREL = { isa = XCBuildConfiguration; id = PROJREL; name = Release; }; ++ PROJDBG = { isa = XCBuildConfiguration; buildSettings = { base = x; }; id = PROJDBG; name = Debug; }; ++ APPCFGS = { isa = XCConfigurationList; buildConfigurations = ( APPREL, APPDBG, ); }; ++ PROJECTCFGS = { isa = XCConfigurationList; buildConfigurations = ( PROJREL, PROJDBG, ); }; ++ REPORTCFGS = { isa = XCConfigurationList; buildConfigurations = ( REPORTREL, REPORTDBG, ); }; ++ }; ++ rootObject = PROJ; ++} ++""" ++ ++ ++def _new_project(): ++ return XcodeProject(copy.deepcopy(PROJECT_TREE)) ++ ++ ++def _setting(project, target_name, configuration_name, key): ++ target = project.get_target_by_name(target_name) ++ configuration_list = project.get_object(target.buildConfigurationList) ++ for configuration_id in configuration_list.buildConfigurations: ++ configuration = project.get_object(configuration_id) ++ if configuration.name == configuration_name: ++ build_settings = configuration["buildSettings"] ++ if build_settings is None: ++ return None ++ return build_settings[key] ++ raise AssertionError("configuration not found") ++ ++ ++def _target_state(project, key): ++ return { ++ "app": { ++ "Release": _setting(project, "app", "Release", key), ++ "Debug": _setting(project, "app", "Debug", key), ++ }, ++ "report": { ++ "Release": _setting(project, "report", "Release", key), ++ "Debug": _setting(project, "report", "Debug", key), ++ }, ++ } ++ ++ ++def _values(value): ++ if value is None: ++ return set() ++ if isinstance(value, list): ++ return set(value) ++ return {value} ++ ++ ++def _assert_target_state(project, key, expected): ++ actual = _target_state(project, key) ++ for target_name, configurations in expected.items(): ++ for configuration_name, expected_value in configurations.items(): ++ ++ assert _values(actual[target_name][configuration_name]) == _values(expected_value) ++ ++ ++def test_header_search_paths_mutate_all_targets_then_remove(): ++ ++ ++ ++ ++ project = _new_project() ++ ++ assert callable(project.add_header_search_paths) ++ ++ project.add_header_search_paths("path/to/search") ++ _assert_target_state(project, "HEADER_SEARCH_PATHS", { ++ "app": {"Release": "path/to/search/**", "Debug": "path/to/search/**"}, ++ "report": {"Release": "path/to/search/**", "Debug": "path/to/search/**"}, ++ }) ++ ++ project.add_header_search_paths("path/to/search") ++ ++ _assert_target_state(project, "HEADER_SEARCH_PATHS", { ++ "app": {"Release": "path/to/search/**", "Debug": "path/to/search/**"}, ++ "report": {"Release": "path/to/search/**", "Debug": "path/to/search/**"}, ++ }) ++ ++ project.remove_header_search_paths("path/to/search/**") ++ ++ _assert_target_state(project, "HEADER_SEARCH_PATHS", { ++ "app": {"Release": None, "Debug": None}, ++ "report": {"Release": None, "Debug": None}, ++ }) ++ ++ ++def test_library_search_paths_filter_target_configuration_and_escape_list(): ++ ++ ++ ++ ++ project = _new_project() ++ ++ assert callable(project.add_library_search_paths) ++ ++ project.add_library_search_paths( ++ ["Libraries", "Vendor Libs"], ++ recursive=False, ++ escape=True, ++ target_name="app", ++ configuration_name="Debug", ++ ) ++ ++ _assert_target_state(project, "LIBRARY_SEARCH_PATHS", { ++ "app": {"Release": None, "Debug": ['"Libraries"', '"Vendor Libs"']}, ++ "report": {"Release": None, "Debug": None}, ++ }) ++ ++ ++def test_framework_search_paths_loaded_project_formatting_edges(tmp_path): ++ ++ ++ ++ ++ project_path = tmp_path / "project.pbxproj" ++ project_path.write_text(PROJECT_PBXPROJ) ++ project = XcodeProject.load(str(project_path)) ++ ++ project.add_framework_search_paths("Frameworks", recursive=True, escape=True) ++ ++ _assert_target_state(project, "FRAMEWORK_SEARCH_PATHS", { ++ "app": {"Release": '"Frameworks"/**', "Debug": '"Frameworks"/**'}, ++ "report": {"Release": '"Frameworks"/**', "Debug": '"Frameworks"/**'}, ++ }) ++ ++ project.add_framework_search_paths("$(inherited)", recursive=True, escape=True) ++ ++ _assert_target_state(project, "FRAMEWORK_SEARCH_PATHS", { ++ "app": { ++ "Release": ['"Frameworks"/**', "$(inherited)"], ++ "Debug": ['"Frameworks"/**', "$(inherited)"], ++ }, ++ "report": { ++ "Release": ['"Frameworks"/**', "$(inherited)"], ++ "Debug": ['"Frameworks"/**', "$(inherited)"], ++ }, ++ }) ++ ++ project.add_framework_search_paths("Already/**", recursive=True, escape=False) ++ ++ _assert_target_state(project, "FRAMEWORK_SEARCH_PATHS", { ++ "app": { ++ "Release": ['"Frameworks"/**', "$(inherited)", "Already/**"], ++ "Debug": ['"Frameworks"/**', "$(inherited)", "Already/**"], ++ }, ++ "report": { ++ "Release": ['"Frameworks"/**', "$(inherited)", "Already/**"], ++ "Debug": ['"Frameworks"/**', "$(inherited)", "Already/**"], ++ }, ++ }) ++ ++ ++def test_remove_methods_respect_filters_for_each_search_path_type(): ++ ++ ++ ++ ++ project = _new_project() ++ project.add_library_search_paths( ++ ["Libraries", "Vendor Libs"], ++ recursive=False, ++ escape=True, ++ target_name="app", ++ configuration_name="Debug", ++ ) ++ project.remove_library_search_paths( ++ '"Libraries"', target_name="app", configuration_name="Debug" ++ ) ++ ++ _assert_target_state(project, "LIBRARY_SEARCH_PATHS", { ++ "app": {"Release": None, "Debug": '"Vendor Libs"'}, ++ "report": {"Release": None, "Debug": None}, ++ }) ++ ++ project.add_framework_search_paths("Frameworks", recursive=True, escape=True) ++ project.remove_framework_search_paths( ++ '"Frameworks"/**', target_name="report", configuration_name="Release" ++ ) ++ ++ _assert_target_state(project, "FRAMEWORK_SEARCH_PATHS", { ++ "app": {"Release": '"Frameworks"/**', "Debug": '"Frameworks"/**'}, ++ "report": {"Release": None, "Debug": '"Frameworks"/**'}, ++ }) ++ ++ project.add_search_paths( ++ "USER_HEADER_SEARCH_PATHS", ++ ["Custom", "Custom/**"], ++ recursive=True, ++ escape=False, ++ target_name=["app", "report"], ++ configuration_name="Release", ++ ) ++ project.remove_search_paths( ++ "USER_HEADER_SEARCH_PATHS", ++ ["Custom/**"], ++ target_name="app", ++ configuration_name="Release", ++ ) ++ ++ _assert_target_state(project, "USER_HEADER_SEARCH_PATHS", { ++ "app": {"Release": None, "Debug": None}, ++ "report": {"Release": "Custom/**", "Debug": None}, ++ }) ++ ++ ++def test_empty_project_exposes_search_path_helpers(): ++ ++ ++ ++ ++ project = XcodeProject(tree=None, path=None) ++ ++ assert callable(project.add_header_search_paths) ++ assert callable(project.remove_header_search_paths) ++ ++ ++def test_save_after_mutation_is_repeatable(tmp_path): ++ ++ ++ ++ ++ project = _new_project() ++ project.add_header_search_paths("path/to/search") ++ output = tmp_path / "project.pbxproj" ++ ++ project.save(str(output)) ++ first_text = output.read_text() ++ ++ assert first_text.count("HEADER_SEARCH_PATHS") >= 4 ++ assert first_text.count("path/to/search/**") >= 4 ++ ++ project.save(str(output)) ++ second_text = output.read_text() ++ ++ assert second_text.count("HEADER_SEARCH_PATHS") >= 4 ++ assert second_text.count("path/to/search/**") >= 4 ++ ++ ++def test_two_project_instances_keep_independent_search_path_state(): ++ ++ ++ ++ ++ first = _new_project() ++ second = _new_project() ++ ++ first.add_header_search_paths("Headers") ++ ++ _assert_target_state(first, "HEADER_SEARCH_PATHS", { ++ "app": {"Release": "Headers/**", "Debug": "Headers/**"}, ++ "report": {"Release": "Headers/**", "Debug": "Headers/**"}, ++ }) ++ ++ _assert_target_state(second, "HEADER_SEARCH_PATHS", { ++ "app": {"Release": None, "Debug": None}, ++ "report": {"Release": None, "Debug": None}, ++ }) ++ ++ second.add_library_search_paths("Libraries", recursive=False) ++ ++ _assert_target_state(first, "LIBRARY_SEARCH_PATHS", { ++ "app": {"Release": None, "Debug": None}, ++ "report": {"Release": None, "Debug": None}, ++ }) ++ ++ _assert_target_state(second, "LIBRARY_SEARCH_PATHS", { ++ "app": {"Release": "Libraries", "Debug": "Libraries"}, ++ "report": {"Release": "Libraries", "Debug": "Libraries"}, ++ }) ++ ++ ++def test_repeated_construct_mutate_remove_cycles(): ++ ++ ++ ++ ++ observed = [] ++ for index in range(150): ++ project = _new_project() ++ project.add_header_search_paths("Headers") ++ project.add_library_search_paths( ++ ["Libraries", "Vendor Libs"], ++ recursive=False, ++ escape=True, ++ target_name="app", ++ configuration_name="Debug", ++ ) ++ project.remove_header_search_paths("Headers/**") ++ observed.append( ++ ( ++ _target_state(project, "HEADER_SEARCH_PATHS"), ++ _target_state(project, "LIBRARY_SEARCH_PATHS"), ++ ) ++ ) ++ del project ++ ++ ++ assert all( ++ all( ++ _values(value) == set() ++ for target in header_state.values() ++ for value in target.values() ++ ) ++ and _values(library_state["app"]["Debug"]) == {'"Libraries"', '"Vendor Libs"'} ++ and all( ++ _values(library_state[target_name][configuration_name]) == set() ++ for target_name, configuration_name in ( ++ ("app", "Release"), ++ ("report", "Release"), ++ ("report", "Debug"), ++ ) ++ ) ++ for header_state, library_state in observed ++ ) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,19 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++ ++export PYTHONPATH="/workspace/repo${PYTHONPATH:+:$PYTHONPATH}" ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++ ++exec python -m pytest /workspace/repo/usercase-test-coderl/test_search_paths.py -v diff --git a/tasks/format-code-task-001711/tests/test.sh b/tasks/format-code-task-001711/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..f8362ae0c252977d1c7b4c4cfe0b3f60c1f0e144 --- /dev/null +++ b/tasks/format-code-task-001711/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/test_search_paths.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001711/tests/test_command.sh b/tasks/format-code-task-001711/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001711/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001716/environment/Dockerfile b/tasks/format-code-task-001716/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d37260f9c9f9637725365cadf02cdb8dad9b4e2e --- /dev/null +++ b/tasks/format-code-task-001716/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:c8a65830ada52ce7f562518fc56baf46aa500da8cef333e96685819e3294950e diff --git a/tasks/format-code-task-001716/environment/setup/files/blocklist b/tasks/format-code-task-001716/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001716/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001716/environment/setup/setup.sh b/tasks/format-code-task-001716/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001716/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001716/tests/test.patch b/tasks/format-code-task-001716/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..59e62ada2b92aefcbba05c326f571dbebd36a582 --- /dev/null +++ b/tasks/format-code-task-001716/tests/test.patch @@ -0,0 +1,224 @@ +diff --git a/core/task-executor/tests/cache_results_contract.test.js b/core/task-executor/tests/cache_results_contract.test.js +new file mode 100644 +index 000000000..97986792f +--- /dev/null ++++ b/core/task-executor/tests/cache_results_contract.test.js +@@ -0,0 +1,208 @@ ++'use strict'; ++ ++const assert = require('assert'); ++ ++const implementations = [ ++ ['task-executor', require('../lib/utils/utils').cacheResults], ++ ['worker', require('../../worker/lib/utils').cacheResults] ++]; ++ ++const deferred = () => { ++ let resolve; ++ let reject; ++ const promise = new Promise((res, rej) => { ++ resolve = res; ++ reject = rej; ++ }); ++ return { promise, resolve, reject }; ++}; ++ ++async function expectRejected(promise, expected) { ++ await assert.rejects(promise, error => error === expected); ++} ++ ++async function exercise(name, cacheResults) { ++ let now = 1000; ++ const originalNow = Date.now; ++ Date.now = () => now; ++ try { ++ ++ { ++ let calls = 0; ++ const gate = deferred(); ++ const cached = cacheResults(() => { ++ calls += 1; ++ return gate.promise; ++ }, 50); ++ const first = cached(); ++ const second = cached(); ++ assert.strictEqual(calls, 1, `${name}: concurrent callers duplicated the fetch`); ++ gate.resolve({ value: 'fresh' }); ++ assert.deepStrictEqual(await Promise.all([first, second]), [{ value: 'fresh' }, { value: 'fresh' }]); ++ assert.strictEqual(calls, 1, `${name}: settled value was not reused`); ++ } ++ ++ ++ { ++ now = 1000; ++ let calls = 0; ++ const gate = deferred(); ++ const cached = cacheResults(() => { ++ calls += 1; ++ return calls === 1 ? 'old' : gate.promise; ++ }, 50); ++ assert.strictEqual(await cached(), 'old'); ++ now = 1050; ++ const refresh = cached(); ++ const waiter = cached(); ++ assert.strictEqual(calls, 2); ++ gate.resolve('new'); ++ assert.deepStrictEqual(await Promise.all([refresh, waiter]), ['new', 'new']); ++ } ++ ++ ++ { ++ let calls = 0; ++ const gate = deferred(); ++ const failure = new Error(`${name}: expected failure`); ++ const cached = cacheResults(() => { ++ calls += 1; ++ return calls === 1 ? gate.promise : 'recovered'; ++ }, 50); ++ const first = cached(); ++ const second = cached(); ++ assert.strictEqual(calls, 1); ++ gate.reject(failure); ++ await expectRejected(first, failure); ++ await expectRejected(second, failure); ++ assert.strictEqual(await cached(), 'recovered', `${name}: rejected value was cached`); ++ assert.strictEqual(calls, 2, `${name}: failed fetch was not retried`); ++ } ++ ++ ++ { ++ let calls = 0; ++ const failure = new Error(`${name}: expected synchronous failure`); ++ const cached = cacheResults(() => { ++ calls += 1; ++ if (calls === 1) { ++ throw failure; ++ } ++ return 9; ++ }, 50); ++ const first = cached(); ++ const second = cached(); ++ assert.strictEqual(calls, 1, `${name}: synchronous throw was not coalesced`); ++ await expectRejected(first, failure); ++ await expectRejected(second, failure); ++ assert.strictEqual(await cached(), 9, `${name}: synchronous failure was cached`); ++ assert.strictEqual(calls, 2, `${name}: synchronous failure was not retried`); ++ } ++ ++ ++ ++ { ++ now = 1000; ++ const calls = []; ++ const context = { ++ prefix: 'ctx', ++ fetch(...args) { ++ calls.push({ receiver: this, args }); ++ return `${this.prefix}:${args.join(',')}`; ++ } ++ }; ++ const cached = cacheResults(context.fetch, 50); ++ assert.strictEqual(await cached.call(context, 'one'), 'ctx:one'); ++ now = 1049; ++ assert.strictEqual(await cached.call({ prefix: 'wrong' }, 'two'), 'ctx:one'); ++ assert.strictEqual(calls.length, 1, `${name}: valid entry ignored its TTL`); ++ now = 1050; ++ assert.strictEqual(await cached.call(context, 'three', 3), 'ctx:three,3'); ++ assert.strictEqual(calls.length, 2, `${name}: TTL boundary did not refresh`); ++ assert.strictEqual(calls[1].receiver, context); ++ assert.deepStrictEqual(calls[1].args, ['three', 3]); ++ } ++ ++ ++ { ++ let calls = 0; ++ const gate = deferred(); ++ const cached = cacheResults(() => { ++ calls += 1; ++ return calls === 1 ? gate.promise : calls; ++ }, 50); ++ const first = cached(); ++ now = 5000; ++ gate.resolve('settled'); ++ assert.strictEqual(await first, 'settled'); ++ now = 5049; ++ assert.strictEqual(await cached(), 'settled'); ++ now = 5050; ++ assert.strictEqual(await cached(), 2); ++ assert.strictEqual(calls, 2); ++ } ++ ++ ++ for (const value of [null, false, 0, undefined]) { ++ let calls = 0; ++ const cached = cacheResults(() => { ++ calls += 1; ++ return value; ++ }, 50); ++ assert.strictEqual(await cached(), value); ++ assert.strictEqual(await cached(), value); ++ assert.strictEqual(calls, 1, `${name}: ${String(value)} was not cached`); ++ } ++ ++ ++ { ++ let calls = 0; ++ const firstGate = deferred(); ++ const secondGate = deferred(); ++ const cached = cacheResults(() => { ++ calls += 1; ++ return calls === 1 ? firstGate.promise : secondGate.promise; ++ }, 50); ++ const first = cached(); ++ cached._clearCache(); ++ const second = cached(); ++ assert.strictEqual(calls, 2, `${name}: clear did not invalidate an in-flight generation`); ++ secondGate.resolve('second'); ++ assert.strictEqual(await second, 'second'); ++ firstGate.resolve('first'); ++ assert.strictEqual(await first, 'first'); ++ assert.strictEqual(await cached(), 'second', `${name}: stale generation repopulated cache`); ++ assert.strictEqual(calls, 2); ++ } ++ ++ ++ { ++ let calls = 0; ++ const gate = deferred(); ++ const cached = cacheResults(() => { ++ calls += 1; ++ return calls === 1 ? gate.promise : calls; ++ }, 0); ++ const first = cached(); ++ const second = cached(); ++ assert.strictEqual(calls, 1); ++ gate.resolve('first'); ++ assert.strictEqual(await first, 'first'); ++ assert.strictEqual(await second, 'first'); ++ assert.strictEqual(await cached(), 2, `${name}: zero TTL reused a settled value`); ++ assert.strictEqual(calls, 2); ++ } ++ } ++ finally { ++ Date.now = originalNow; ++ } ++} ++ ++(async () => { ++ for (const [name, cacheResults] of implementations) { ++ await exercise(name, cacheResults); ++ } ++})().catch(error => { ++ console.error(error.stack || error); ++ process.exitCode = 1; ++}); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,5 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++node core/task-executor/tests/cache_results_contract.test.js diff --git a/tasks/format-code-task-001716/tests/test.sh b/tasks/format-code-task-001716/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..8af7df10bf770383373fac234c48e7255feb584f --- /dev/null +++ b/tasks/format-code-task-001716/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +core/task-executor/tests/cache_results_contract.test.js +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001716/tests/test_command.sh b/tasks/format-code-task-001716/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001716/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001718/environment/Dockerfile b/tasks/format-code-task-001718/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..2873f14db8c3ae7b2b473f863e91ff8fd7f2dae6 --- /dev/null +++ b/tasks/format-code-task-001718/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:7ee2e5d3b62e9c46ccadfb4b109f5917f92cda56b2b906778f0acf47598a9dcd diff --git a/tasks/format-code-task-001718/environment/setup/files/blocklist b/tasks/format-code-task-001718/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001718/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001718/environment/setup/setup.sh b/tasks/format-code-task-001718/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001718/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001718/tests/test.patch b/tasks/format-code-task-001718/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..a816a7aa12a7bba3fef10e328ce077914719806a --- /dev/null +++ b/tasks/format-code-task-001718/tests/test.patch @@ -0,0 +1,133 @@ +diff --git a/pkg/validation/cluster_test.go b/pkg/validation/cluster_test.go +index 1046f99e1..fa09d1081 100644 +--- a/pkg/validation/cluster_test.go ++++ b/pkg/validation/cluster_test.go +@@ -74,6 +74,106 @@ func TestValidateClusterSpec(t *testing.T) { + } + } + ++func hasPodSecurityPolicyError(errs field.ErrorList) bool { ++ for _, e := range errs { ++ msg := strings.ToLower(e.Error()) ++ if strings.Contains(msg, "podsecuritypolicy") || strings.Contains(msg, "pod security policy") { ++ return true ++ } ++ } ++ return false ++} ++ ++func TestValidateClusterSpecPodSecurityPolicy(t *testing.T) { ++ versionManager := version.New([]*version.Version{ ++ {Version: semverlib.MustParse("1.24.0")}, ++ {Version: semverlib.MustParse("1.24.99")}, ++ {Version: semverlib.MustParse("1.25.0")}, ++ {Version: semverlib.MustParse("1.26.0")}, ++ }, nil, nil) ++ ++ tests := []struct { ++ name string ++ spec *kubermaticv1.ClusterSpec ++ expectPSP bool ++ }{ ++ { ++ name: "PSP via UsePodSecurityPolicyAdmissionPlugin on v1.25 should error", ++ spec: &kubermaticv1.ClusterSpec{ ++ Version: *semver.NewSemverOrDie("1.25.0"), ++ UsePodSecurityPolicyAdmissionPlugin: true, ++ }, ++ expectPSP: true, ++ }, ++ { ++ name: "PSP via UsePodSecurityPolicyAdmissionPlugin on v1.26 should error", ++ spec: &kubermaticv1.ClusterSpec{ ++ Version: *semver.NewSemverOrDie("1.26.0"), ++ UsePodSecurityPolicyAdmissionPlugin: true, ++ }, ++ expectPSP: true, ++ }, ++ { ++ name: "PSP via UsePodSecurityPolicyAdmissionPlugin on v1.24 should NOT error", ++ spec: &kubermaticv1.ClusterSpec{ ++ Version: *semver.NewSemverOrDie("1.24.0"), ++ UsePodSecurityPolicyAdmissionPlugin: true, ++ }, ++ expectPSP: false, ++ }, ++ { ++ name: "PSP via UsePodSecurityPolicyAdmissionPlugin on boundary v1.24.99 should NOT error", ++ spec: &kubermaticv1.ClusterSpec{ ++ Version: *semver.NewSemverOrDie("1.24.99"), ++ UsePodSecurityPolicyAdmissionPlugin: true, ++ }, ++ expectPSP: false, ++ }, ++ { ++ name: "no PSP enabled on v1.25 should NOT error", ++ spec: &kubermaticv1.ClusterSpec{ ++ Version: *semver.NewSemverOrDie("1.25.0"), ++ UsePodSecurityPolicyAdmissionPlugin: false, ++ }, ++ expectPSP: false, ++ }, ++ { ++ name: "PSP via AdmissionPlugins list on v1.25 should error", ++ spec: &kubermaticv1.ClusterSpec{ ++ Version: *semver.NewSemverOrDie("1.25.0"), ++ AdmissionPlugins: []string{"PodSecurityPolicy"}, ++ }, ++ expectPSP: true, ++ }, ++ { ++ name: "PSP via AdmissionPlugins list on v1.24 should NOT error", ++ spec: &kubermaticv1.ClusterSpec{ ++ Version: *semver.NewSemverOrDie("1.24.0"), ++ AdmissionPlugins: []string{"PodSecurityPolicy"}, ++ }, ++ expectPSP: false, ++ }, ++ { ++ name: "non-PSP admission plugin on v1.25 should NOT error", ++ spec: &kubermaticv1.ClusterSpec{ ++ Version: *semver.NewSemverOrDie("1.25.0"), ++ AdmissionPlugins: []string{"EventRateLimit"}, ++ }, ++ expectPSP: false, ++ }, ++ } ++ ++ for _, test := range tests { ++ t.Run(test.name, func(t *testing.T) { ++ errs := ValidateClusterSpec(test.spec, dc, features.FeatureGate{}, versionManager, nil) ++ got := hasPodSecurityPolicyError(errs) ++ if got != test.expectPSP { ++ t.Errorf("expected PSP error=%v, got=%v; full errors: %v", test.expectPSP, got, errs.ToAggregate()) ++ } ++ }) ++ } ++} ++ + func TestValidateContainerRuntime(t *testing.T) { + tests := []struct { + name string +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..502716818 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["go test ./pkg/validation/ -run TestValidateClusterSpecPodSecurityPolicy -v"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++go test ./pkg/validation/ -run TestValidateClusterSpecPodSecurityPolicy -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001718/tests/test.sh b/tasks/format-code-task-001718/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..5ef4b6be6888f368d6a0732fe122231dcd0f7473 --- /dev/null +++ b/tasks/format-code-task-001718/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +pkg/validation/cluster_test.go +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001718/tests/test_command.sh b/tasks/format-code-task-001718/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001718/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001720/environment/Dockerfile b/tasks/format-code-task-001720/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..abd5eb361f82a54dae603d8e6ebf6a8e5f585d51 --- /dev/null +++ b/tasks/format-code-task-001720/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:5ad943826caf15a67deeccbb17860a7a39f2e2bf361c4bcc8ceade294a0e9517 diff --git a/tasks/format-code-task-001720/environment/setup/files/blocklist b/tasks/format-code-task-001720/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001720/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001720/environment/setup/setup.sh b/tasks/format-code-task-001720/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001720/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001720/tests/test.patch b/tasks/format-code-task-001720/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e8f7748810ccd91c1c79106e780d1901bcf32a41 --- /dev/null +++ b/tasks/format-code-task-001720/tests/test.patch @@ -0,0 +1,454 @@ +diff --git a/pkg/nfs/path_confinement_verifier_test.go b/pkg/nfs/path_confinement_verifier_test.go +new file mode 100644 +index 00000000..ba0cfd92 +--- /dev/null ++++ b/pkg/nfs/path_confinement_verifier_test.go +@@ -0,0 +1,438 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++package nfs ++ ++import ( ++ "os" ++ "path/filepath" ++ "testing" ++ ++ "github.com/container-storage-interface/spec/lib/go/csi" ++ "golang.org/x/net/context" ++ "google.golang.org/grpc/codes" ++ "google.golang.org/grpc/status" ++ mount "k8s.io/mount-utils" ++) ++ ++func codespecConfinementServers(t *testing.T) (*ControllerServer, *NodeServer, *mount.FakeMounter, string) { ++ t.Helper() ++ workingDir := t.TempDir() ++ mounter := mount.NewFakeMounter(nil) ++ driver := NewDriver(&DriverOptions{ ++ DriverName: DefaultDriverName, ++ WorkingMountDir: workingDir, ++ MountPermissions: 0755, ++ DefaultOnDeletePolicy: delete, ++ }) ++ ns := NewNodeServer(driver, mounter) ++ driver.ns = ns ++ return NewControllerServer(driver), ns, mounter, workingDir ++} ++ ++func codespecMountCapability() *csi.VolumeCapability { ++ return &csi.VolumeCapability{ ++ AccessType: &csi.VolumeCapability_Mount{Mount: &csi.VolumeCapability_MountVolume{}}, ++ AccessMode: &csi.VolumeCapability_AccessMode{ ++ Mode: csi.VolumeCapability_AccessMode_MULTI_NODE_MULTI_WRITER, ++ }, ++ } ++} ++ ++func codespecAssertNoControllerSideEffects(t *testing.T, mounter *mount.FakeMounter, workingDir string) { ++ t.Helper() ++ if actions := mounter.GetLog(); len(actions) != 0 { ++ t.Fatalf("request reached the mounter: %+v", actions) ++ } ++ entries, err := os.ReadDir(workingDir) ++ if err != nil { ++ t.Fatalf("working directory was changed or removed: %v", err) ++ } ++ if len(entries) != 0 { ++ t.Fatalf("working directory was populated: %v", entries) ++ } ++} ++ ++func codespecAssertCode(t *testing.T, err error, want codes.Code) { ++ t.Helper() ++ if got := status.Code(err); got != want { ++ t.Fatalf("unexpected gRPC result: got %v (%v), want %v", got, err, want) ++ } ++} ++ ++func TestCodespecNodePublishConfinesShareAndSubDir(t *testing.T) { ++ tests := []struct { ++ name string ++ context map[string]string ++ }{ ++ {name: "parent subdirectory", context: map[string]string{paramServer: "nfs.example", paramShare: "/exports", paramSubDir: "tenant/../private"}}, ++ {name: "absolute subdirectory", context: map[string]string{paramServer: "nfs.example", paramShare: "/exports", paramSubDir: "/private"}}, ++ {name: "dot component", context: map[string]string{paramServer: "nfs.example", paramShare: "/exports", paramSubDir: "tenant/./private"}}, ++ {name: "unsafe substituted metadata", context: map[string]string{paramServer: "nfs.example", paramShare: "/exports", paramSubDir: "tenant/" + pvcNamespaceMetadata + "/data", pvcNamespaceKey: "../private"}}, ++ {name: "parent share component", context: map[string]string{paramServer: "nfs.example", paramShare: "/exports/../private", paramSubDir: "data"}}, ++ } ++ ++ for _, tc := range tests { ++ t.Run(tc.name, func(t *testing.T) { ++ _, ns, mounter, _ := codespecConfinementServers(t) ++ target := filepath.Join(t.TempDir(), "target") ++ _, err := ns.NodePublishVolume(context.Background(), &csi.NodePublishVolumeRequest{ ++ VolumeId: "volume-safe", ++ TargetPath: target, ++ VolumeContext: tc.context, ++ VolumeCapability: codespecMountCapability(), ++ }) ++ codespecAssertCode(t, err, codes.InvalidArgument) ++ if actions := mounter.GetLog(); len(actions) != 0 { ++ t.Fatalf("invalid publish reached the mounter: %+v", actions) ++ } ++ if _, statErr := os.Stat(target); !os.IsNotExist(statErr) { ++ t.Fatalf("invalid publish created its target: %v", statErr) ++ } ++ }) ++ } ++} ++ ++func TestCodespecNodePublishAllowsSafeNestedSubDir(t *testing.T) { ++ tests := []struct { ++ name string ++ share string ++ subDir string ++ wantSource string ++ }{ ++ {name: "nested export and subdirectory", share: "/exports/team/", subDir: "tenant/project/.data", wantSource: "[2001:db8::1]:/exports/team/tenant/project/.data"}, ++ {name: "root export", share: "/", subDir: "tenant/data", wantSource: "[2001:db8::1]:/tenant/data"}, ++ } ++ for _, tc := range tests { ++ t.Run(tc.name, func(t *testing.T) { ++ _, ns, mounter, _ := codespecConfinementServers(t) ++ target := filepath.Join(t.TempDir(), "target") ++ _, err := ns.NodePublishVolume(context.Background(), &csi.NodePublishVolumeRequest{ ++ VolumeId: "volume-safe", ++ TargetPath: target, ++ VolumeContext: map[string]string{ ++ paramServer: "2001:db8::1", ++ paramShare: tc.share, ++ paramSubDir: tc.subDir, ++ }, ++ VolumeCapability: codespecMountCapability(), ++ }) ++ if err != nil { ++ t.Fatalf("safe nested publish failed: %v", err) ++ } ++ found := false ++ for _, action := range mounter.GetLog() { ++ if action.Action == mount.FakeActionMount && action.Source == tc.wantSource && action.Target == target { ++ found = true ++ } ++ } ++ if !found { ++ t.Fatalf("safe source was not mounted; actions: %+v", mounter.GetLog()) ++ } ++ }) ++ } ++} ++ ++func TestCodespecCreateVolumeRejectsUnsafeGeneratedPaths(t *testing.T) { ++ tests := []struct { ++ name string ++ volumeName string ++ parameters map[string]string ++ }{ ++ {name: "unsafe default subdirectory", volumeName: "../escape", parameters: map[string]string{paramServer: "nfs.example", paramShare: "/exports"}}, ++ {name: "delimiter in volume name", volumeName: "pv#other", parameters: map[string]string{paramServer: "nfs.example", paramShare: "/exports"}}, ++ {name: "parent subdirectory", volumeName: "pv-safe", parameters: map[string]string{paramServer: "nfs.example", paramShare: "/exports", paramSubDir: "tenant/../escape"}}, ++ {name: "absolute subdirectory", volumeName: "pv-safe", parameters: map[string]string{paramServer: "nfs.example", paramShare: "/exports", paramSubDir: "/escape"}}, ++ {name: "unsafe metadata expansion", volumeName: "pv-safe", parameters: map[string]string{paramServer: "nfs.example", paramShare: "/exports", paramSubDir: "tenant/" + pvcNameMetadata + "/data", pvcNameKey: "../escape"}}, ++ {name: "unsafe share", volumeName: "pv-safe", parameters: map[string]string{paramServer: "nfs.example", paramShare: "/exports/../private", paramSubDir: "data"}}, ++ {name: "delimiter in server", volumeName: "pv-safe", parameters: map[string]string{paramServer: "nfs.example#other", paramShare: "/exports", paramSubDir: "data"}}, ++ {name: "delimiter in share", volumeName: "pv-safe", parameters: map[string]string{paramServer: "nfs.example", paramShare: "/exports#other", paramSubDir: "data"}}, ++ {name: "delimiter in subdirectory", volumeName: "pv-safe", parameters: map[string]string{paramServer: "nfs.example", paramShare: "/exports", paramSubDir: "data#other"}}, ++ } ++ ++ for _, tc := range tests { ++ t.Run(tc.name, func(t *testing.T) { ++ cs, _, mounter, workingDir := codespecConfinementServers(t) ++ _, err := cs.CreateVolume(context.Background(), &csi.CreateVolumeRequest{ ++ Name: tc.volumeName, ++ Parameters: tc.parameters, ++ VolumeCapabilities: []*csi.VolumeCapability{codespecMountCapability()}, ++ }) ++ codespecAssertCode(t, err, codes.InvalidArgument) ++ codespecAssertNoControllerSideEffects(t, mounter, workingDir) ++ }) ++ } ++} ++ ++func TestCodespecCreateVolumePreservesSafeNestedSubDir(t *testing.T) { ++ cs, _, mounter, _ := codespecConfinementServers(t) ++ resp, err := cs.CreateVolume(context.Background(), &csi.CreateVolumeRequest{ ++ Name: "pv-safe", ++ Parameters: map[string]string{ ++ paramServer: "nfs.example", ++ paramShare: "/exports/team/", ++ paramSubDir: "tenant/project/.data", ++ }, ++ VolumeCapabilities: []*csi.VolumeCapability{codespecMountCapability()}, ++ }) ++ if err != nil { ++ t.Fatalf("safe nested provisioning failed: %v", err) ++ } ++ if got, want := resp.GetVolume().GetVolumeId(), "nfs.example#exports/team#tenant/project/.data#pv-safe#"; got != want { ++ t.Fatalf("unexpected volume ID: got %q, want %q", got, want) ++ } ++ if got := resp.GetVolume().GetVolumeContext()[paramSubDir]; got != "tenant/project/.data" { ++ t.Fatalf("nested subdirectory changed: got %q", got) ++ } ++ found := false ++ for _, action := range mounter.GetLog() { ++ if action.Action == mount.FakeActionMount && (action.Source == "nfs.example:/exports/team" || action.Source == "nfs.example:/exports/team/") { ++ found = true ++ } ++ } ++ if !found { ++ t.Fatalf("safe share was not mounted; actions: %+v", mounter.GetLog()) ++ } ++} ++ ++func TestCodespecContentSourceValidationPrecedesDestinationMutation(t *testing.T) { ++ tests := []struct { ++ name string ++ source *csi.VolumeContentSource ++ }{ ++ { ++ name: "unsafe volume ID", ++ source: &csi.VolumeContentSource{Type: &csi.VolumeContentSource_Volume{ ++ Volume: &csi.VolumeContentSource_VolumeSource{VolumeId: "nfs.example#exports#../escape#source-pv#"}, ++ }}, ++ }, ++ { ++ name: "empty volume subdirectory", ++ source: &csi.VolumeContentSource{Type: &csi.VolumeContentSource_Volume{ ++ Volume: &csi.VolumeContentSource_VolumeSource{VolumeId: "nfs.example#exports###"}, ++ }}, ++ }, ++ { ++ name: "unsafe volume ID working component", ++ source: &csi.VolumeContentSource{Type: &csi.VolumeContentSource_Volume{ ++ Volume: &csi.VolumeContentSource_VolumeSource{VolumeId: "nfs.example#exports#source#../source-pv#"}, ++ }}, ++ }, ++ { ++ name: "unsafe snapshot archive path", ++ source: &csi.VolumeContentSource{Type: &csi.VolumeContentSource_Snapshot{ ++ Snapshot: &csi.VolumeContentSource_SnapshotSource{SnapshotId: "nfs.example#exports#snap-safe#../snap-safe#source-pv"}, ++ }}, ++ }, ++ { ++ name: "noncanonical snapshot archive path", ++ source: &csi.VolumeContentSource{Type: &csi.VolumeContentSource_Snapshot{ ++ Snapshot: &csi.VolumeContentSource_SnapshotSource{SnapshotId: "nfs.example#exports#snap-safe#other-safe-path#source-pv"}, ++ }}, ++ }, ++ } ++ ++ for _, tc := range tests { ++ t.Run(tc.name, func(t *testing.T) { ++ cs, _, mounter, workingDir := codespecConfinementServers(t) ++ _, err := cs.CreateVolume(context.Background(), &csi.CreateVolumeRequest{ ++ Name: "destination-pv", ++ Parameters: map[string]string{ ++ paramServer: "nfs.example", ++ paramShare: "/exports", ++ }, ++ VolumeCapabilities: []*csi.VolumeCapability{codespecMountCapability()}, ++ VolumeContentSource: tc.source, ++ }) ++ codespecAssertCode(t, err, codes.NotFound) ++ codespecAssertNoControllerSideEffects(t, mounter, workingDir) ++ }) ++ } ++} ++ ++func TestCodespecCreateSnapshotValidatesAllPathsBeforeMount(t *testing.T) { ++ tests := []struct { ++ name string ++ request *csi.CreateSnapshotRequest ++ wantCode codes.Code ++ }{ ++ { ++ name: "unsafe source volume ID", ++ request: &csi.CreateSnapshotRequest{ ++ Name: "snap-safe", ++ SourceVolumeId: "nfs.example#exports#../escape#source-pv#", ++ }, ++ wantCode: codes.NotFound, ++ }, ++ { ++ name: "unsafe snapshot name", ++ request: &csi.CreateSnapshotRequest{ ++ Name: "../snap", ++ SourceVolumeId: "nfs.example#exports#source#source-pv#", ++ }, ++ wantCode: codes.InvalidArgument, ++ }, ++ { ++ name: "delimiter in snapshot name", ++ request: &csi.CreateSnapshotRequest{ ++ Name: "snap#other", ++ SourceVolumeId: "nfs.example#exports#source#source-pv#", ++ }, ++ wantCode: codes.InvalidArgument, ++ }, ++ { ++ name: "unsafe snapshot share override", ++ request: &csi.CreateSnapshotRequest{ ++ Name: "snap-safe", ++ SourceVolumeId: "nfs.example#exports#source#source-pv#", ++ Parameters: map[string]string{paramShare: "/snapshots/../private"}, ++ }, ++ wantCode: codes.InvalidArgument, ++ }, ++ { ++ name: "delimiter in snapshot server override", ++ request: &csi.CreateSnapshotRequest{ ++ Name: "snap-safe", ++ SourceVolumeId: "nfs.example#exports#source#source-pv#", ++ Parameters: map[string]string{paramServer: "nfs.example#other"}, ++ }, ++ wantCode: codes.InvalidArgument, ++ }, ++ { ++ name: "delimiter in snapshot share override", ++ request: &csi.CreateSnapshotRequest{ ++ Name: "snap-safe", ++ SourceVolumeId: "nfs.example#exports#source#source-pv#", ++ Parameters: map[string]string{paramShare: "/snapshots#other"}, ++ }, ++ wantCode: codes.InvalidArgument, ++ }, ++ } ++ ++ for _, tc := range tests { ++ t.Run(tc.name, func(t *testing.T) { ++ cs, _, mounter, workingDir := codespecConfinementServers(t) ++ _, err := cs.CreateSnapshot(context.Background(), tc.request) ++ codespecAssertCode(t, err, tc.wantCode) ++ codespecAssertNoControllerSideEffects(t, mounter, workingDir) ++ }) ++ } ++} ++ ++func TestCodespecUnsafeDeleteIDsStayIdempotentWithoutSideEffects(t *testing.T) { ++ t.Run("volumes", func(t *testing.T) { ++ ids := []string{ ++ "nfs.example#exports###delete", ++ "nfs.example#exports#../sentinel#safe#delete", ++ "nfs.example#exports#data#../safe#delete", ++ "nfs.example#exports/../private#data#safe#delete", ++ "nfs.example#exports#data#.#delete", ++ "nfs.example#exports#data#safe#delete#extra", ++ "nfs.example/exports/.", ++ } ++ for _, id := range ids { ++ t.Run(id, func(t *testing.T) { ++ cs, _, mounter, workingDir := codespecConfinementServers(t) ++ if err := os.MkdirAll(filepath.Join(workingDir, "sentinel"), 0755); err != nil { ++ t.Fatal(err) ++ } ++ mounter.ResetLog() ++ resp, err := cs.DeleteVolume(context.Background(), &csi.DeleteVolumeRequest{VolumeId: id}) ++ if err != nil || resp == nil { ++ t.Fatalf("unsafe delete was not idempotent: resp=%v err=%v", resp, err) ++ } ++ if actions := mounter.GetLog(); len(actions) != 0 { ++ t.Fatalf("unsafe volume ID reached the mounter: %+v", actions) ++ } ++ if _, statErr := os.Stat(filepath.Join(workingDir, "sentinel")); statErr != nil { ++ t.Fatalf("unsafe volume ID changed local data: %v", statErr) ++ } ++ }) ++ } ++ }) ++ ++ t.Run("snapshots", func(t *testing.T) { ++ ids := []string{ ++ "nfs.example#exports###source-pv", ++ "nfs.example#exports#snap-safe#snap-safe#", ++ "nfs.example#exports#snap-safe#different-path#source-pv", ++ "nfs.example#exports#snap-safe#snap-safe#../source-pv", ++ "nfs.example#exports#.#.#source-pv", ++ } ++ for _, id := range ids { ++ t.Run(id, func(t *testing.T) { ++ cs, _, mounter, workingDir := codespecConfinementServers(t) ++ if err := os.MkdirAll(filepath.Join(workingDir, "sentinel"), 0755); err != nil { ++ t.Fatal(err) ++ } ++ mounter.ResetLog() ++ resp, err := cs.DeleteSnapshot(context.Background(), &csi.DeleteSnapshotRequest{SnapshotId: id}) ++ if err != nil || resp == nil { ++ t.Fatalf("unsafe delete was not idempotent: resp=%v err=%v", resp, err) ++ } ++ if actions := mounter.GetLog(); len(actions) != 0 { ++ t.Fatalf("unsafe snapshot ID reached the mounter: %+v", actions) ++ } ++ if _, statErr := os.Stat(filepath.Join(workingDir, "sentinel")); statErr != nil { ++ t.Fatalf("unsafe snapshot ID changed local data: %v", statErr) ++ } ++ }) ++ } ++ }) ++ ++ cs, _, mounter, workingDir := codespecConfinementServers(t) ++ resp, err := cs.DeleteVolume(context.Background(), &csi.DeleteVolumeRequest{VolumeId: "malformed-id"}) ++ if err != nil || resp == nil { ++ t.Fatalf("malformed delete compatibility changed: resp=%v err=%v", resp, err) ++ } ++ codespecAssertNoControllerSideEffects(t, mounter, workingDir) ++} ++ ++func TestCodespecLegacyNestedVolumeIDRemainsUsable(t *testing.T) { ++ tests := []struct { ++ name string ++ volumeID string ++ wantID string ++ }{ ++ {name: "legacy slash ID with nested base", volumeID: "nfs.example/exports/team/source-pv", wantID: "nfs.example#exports/team#snap-safe#snap-safe#source-pv"}, ++ {name: "compact three-field ID", volumeID: "nfs.example#exports/team#source-pv", wantID: "nfs.example#exports/team#snap-safe#snap-safe#source-pv"}, ++ } ++ for _, tc := range tests { ++ t.Run(tc.name, func(t *testing.T) { ++ cs, _, _, workingDir := codespecConfinementServers(t) ++ sourcePath := filepath.Join(workingDir, "source-pv", "source-pv") ++ if err := os.MkdirAll(sourcePath, 0755); err != nil { ++ t.Fatal(err) ++ } ++ if err := os.WriteFile(filepath.Join(sourcePath, "payload"), []byte("compatible"), 0644); err != nil { ++ t.Fatal(err) ++ } ++ resp, err := cs.CreateSnapshot(context.Background(), &csi.CreateSnapshotRequest{ ++ Name: "snap-safe", ++ SourceVolumeId: tc.volumeID, ++ }) ++ if err != nil { ++ t.Fatalf("valid volume ID was rejected: %v", err) ++ } ++ if got := resp.GetSnapshot().GetSnapshotId(); got != tc.wantID { ++ t.Fatalf("unexpected snapshot ID: got %q, want %q", got, tc.wantID) ++ } ++ if !resp.GetSnapshot().GetReadyToUse() { ++ t.Fatal("snapshot from valid volume ID is not ready") ++ } ++ }) ++ } ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,5 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++go test ./pkg/nfs -run '^(TestCodespec.*|TestNfsVolFromId|TestNewNFSVolume|TestNodePublishVolume|TestDeleteVolume|TestCreateSnapshot|TestDeleteSnapshot)$' -count=1 diff --git a/tasks/format-code-task-001720/tests/test.sh b/tasks/format-code-task-001720/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..bd6c733043ef0591f9eb09708da1363fe3d7a613 --- /dev/null +++ b/tasks/format-code-task-001720/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +pkg/nfs/path_confinement_verifier_test.go +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001720/tests/test_command.sh b/tasks/format-code-task-001720/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001720/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001727/environment/Dockerfile b/tasks/format-code-task-001727/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..860bc280e6f68db7a84ca4967c4a2ad2dff7eca4 --- /dev/null +++ b/tasks/format-code-task-001727/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:8c43ce6f1d557ccec6696f763e4fef801b754a44e31527ef551b6fc4d1f26c02 diff --git a/tasks/format-code-task-001727/environment/setup/files/blocklist b/tasks/format-code-task-001727/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001727/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001727/environment/setup/setup.sh b/tasks/format-code-task-001727/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001727/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001727/tests/test.patch b/tasks/format-code-task-001727/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..74532601cec2e31540e48edf6ff1eb92e786ba5e --- /dev/null +++ b/tasks/format-code-task-001727/tests/test.patch @@ -0,0 +1,70 @@ +diff --git a/provider/aws/aws_test.go b/provider/aws/aws_test.go +index c87de29f..6dd2a5bc 100644 +--- a/provider/aws/aws_test.go ++++ b/provider/aws/aws_test.go +@@ -1388,3 +1388,43 @@ func addZoneTags(tagMap map[string][]*route53.Tag, zoneID string, tags map[strin + func validateRecords(t *testing.T, records []*route53.ResourceRecordSet, expected []*route53.ResourceRecordSet) { + assert.ElementsMatch(t, expected, records) + } ++ ++func TestAWSCanonicalHostedZoneApSoutheast3ALB(t *testing.T) { ++ ++ ++ ++ zone := canonicalHostedZone("foo.ap-southeast-3.elb.amazonaws.com") ++ assert.Equal(t, "Z08888821HLRG5A9ZRTER", zone) ++} ++ ++func TestAWSCanonicalHostedZoneApSoutheast3NLB(t *testing.T) { ++ ++ ++ ++ zone := canonicalHostedZone("foo.elb.ap-southeast-3.amazonaws.com") ++ assert.Equal(t, "Z01971771FYVNCOVWJU1G", zone) ++} ++ ++func TestAWSCanonicalHostedZoneApSoutheast3NonEmpty(t *testing.T) { ++ ++ ++ ++ ++ assert.NotEmpty(t, canonicalHostedZone("foo.ap-southeast-3.elb.amazonaws.com")) ++ assert.NotEmpty(t, canonicalHostedZone("foo.elb.ap-southeast-3.amazonaws.com")) ++} ++ ++func TestAWSCanonicalHostedZonePreservesExisting(t *testing.T) { ++ ++ ++ assert.Equal(t, "Z1LMS91P8CMLE5", canonicalHostedZone("foo.ap-southeast-1.elb.amazonaws.com")) ++ assert.Equal(t, "Z1GM3OXH4ZPM65", canonicalHostedZone("foo.ap-southeast-2.elb.amazonaws.com")) ++ assert.Equal(t, "ZKVM4W9LS7TM", canonicalHostedZone("foo.elb.ap-southeast-1.amazonaws.com")) ++ assert.Equal(t, "ZCT6FZBF4DROD", canonicalHostedZone("foo.elb.ap-southeast-2.amazonaws.com")) ++} ++ ++func TestAWSCanonicalHostedZoneUnknownHost(t *testing.T) { ++ ++ ++ assert.Equal(t, "", canonicalHostedZone("foo.example.org")) ++} +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..49efcdb2 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["go test -run 'TestAWSCanonicalHostedZoneApSoutheast3ALB|TestAWSCanonicalHostedZoneApSoutheast3NLB|TestAWSCanonicalHostedZoneApSoutheast3NonEmpty|TestAWSCanonicalHostedZonePreservesExisting|TestAWSCanonicalHostedZoneUnknownHost' -v ./provider/aws/"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++go test -run 'TestAWSCanonicalHostedZoneApSoutheast3ALB|TestAWSCanonicalHostedZoneApSoutheast3NLB|TestAWSCanonicalHostedZoneApSoutheast3NonEmpty|TestAWSCanonicalHostedZonePreservesExisting|TestAWSCanonicalHostedZoneUnknownHost' -v ./provider/aws/ ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001727/tests/test.sh b/tasks/format-code-task-001727/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..f0c9b6e9014d5951691c58898a0b65ad339545b3 --- /dev/null +++ b/tasks/format-code-task-001727/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +provider/aws/aws_test.go +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001727/tests/test_command.sh b/tasks/format-code-task-001727/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001727/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001729/environment/Dockerfile b/tasks/format-code-task-001729/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..dac1add5f3c12e78726785076ba0062849c2a9dc --- /dev/null +++ b/tasks/format-code-task-001729/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:5bcaed342c408a975b74c9a5d52f5ca189c33565fc58b752c8bb83c16ae9ee95 diff --git a/tasks/format-code-task-001729/environment/setup/files/blocklist b/tasks/format-code-task-001729/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001729/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001729/environment/setup/setup.sh b/tasks/format-code-task-001729/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001729/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001729/tests/test.patch b/tasks/format-code-task-001729/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..9075e7d06ec4e2fbf3d8741459537188b0758c3b --- /dev/null +++ b/tasks/format-code-task-001729/tests/test.patch @@ -0,0 +1,291 @@ +diff --git a/api/krusty/component_test.go b/api/krusty/component_test.go +new file mode 100644 +index 000000000..7b0c2ff06 +--- /dev/null ++++ b/api/krusty/component_test.go +@@ -0,0 +1,247 @@ ++ ++ ++ ++package krusty_test ++ ++import ( ++ "strings" ++ "testing" ++ ++ kusttest_test "sigs.k8s.io/kustomize/api/testutils/kusttest" ++) ++ ++ ++ ++func writeComp(th kusttest_test.Harness, dir string, content string) { ++ th.WriteF(dir+"/kustomization.yaml", ` ++apiVersion: kustomize.config.k8s.io/v1alpha1 ++kind: Component ++`+content) ++} ++ ++ ++ ++func writeComponentTestBase(th kusttest_test.Harness) { ++ th.WriteK("/app/base", ` ++resources: ++- deploy.yaml ++configMapGenerator: ++- name: my-configmap ++ literals: ++ - testValue=1 ++ - otherValue=10 ++`) ++ th.WriteF("/app/base/deploy.yaml", ` ++apiVersion: v1 ++kind: Deployment ++metadata: ++ name: storefront ++spec: ++ replicas: 1 ++`) ++} ++ ++ ++ ++ ++ ++func TestComponentBasic(t *testing.T) { ++ th := kusttest_test.MakeHarness(t) ++ writeComponentTestBase(th) ++ writeComp(th, "/app/comp", ` ++namePrefix: comp- ++replicas: ++- name: storefront ++ count: 3 ++resources: ++- stub.yaml ++configMapGenerator: ++- name: my-configmap ++ behavior: merge ++ literals: ++ - testValue=2 ++ - compValue=5 ++`) ++ th.WriteF("/app/comp/stub.yaml", ` ++apiVersion: v1 ++kind: Deployment ++metadata: ++ name: stub ++spec: ++ replicas: 1 ++`) ++ th.WriteK("/app/prod", ` ++resources: ++- ../base ++- db.yaml ++components: ++- ../comp ++`) ++ th.WriteF("/app/prod/db.yaml", ` ++apiVersion: v1 ++kind: Deployment ++metadata: ++ name: db ++spec: ++ type: Logical ++`) ++ m := th.Run("/app/prod", th.MakeDefaultOptions()) ++ th.AssertActualEqualsExpected(m, ` ++apiVersion: v1 ++kind: Deployment ++metadata: ++ name: comp-storefront ++spec: ++ replicas: 3 ++--- ++apiVersion: v1 ++data: ++ compValue: "5" ++ otherValue: "10" ++ testValue: "2" ++kind: ConfigMap ++metadata: ++ annotations: {} ++ labels: {} ++ name: comp-my-configmap-ct5bgtbccd ++--- ++apiVersion: v1 ++kind: Deployment ++metadata: ++ name: comp-db ++spec: ++ type: Logical ++--- ++apiVersion: v1 ++kind: Deployment ++metadata: ++ name: comp-stub ++spec: ++ replicas: 1 ++`) ++} ++ ++ ++ ++ ++func TestComponentPatchesPriorResource(t *testing.T) { ++ th := kusttest_test.MakeHarness(t) ++ writeComponentTestBase(th) ++ writeComp(th, "/app/comp", ` ++patchesStrategicMerge: ++- patch.yaml ++`) ++ th.WriteF("/app/comp/patch.yaml", ` ++apiVersion: v1 ++kind: Deployment ++metadata: ++ name: storefront ++spec: ++ replicas: 42 ++`) ++ th.WriteK("/app/prod", ` ++resources: ++- ../base ++components: ++- ../comp ++`) ++ m := th.Run("/app/prod", th.MakeDefaultOptions()) ++ th.AssertActualEqualsExpected(m, ` ++apiVersion: v1 ++kind: Deployment ++metadata: ++ name: storefront ++spec: ++ replicas: 42 ++--- ++apiVersion: v1 ++data: ++ otherValue: "10" ++ testValue: "1" ++kind: ConfigMap ++metadata: ++ name: my-configmap-7k9t4h74f8 ++`) ++} ++ ++ ++ ++func TestComponentsAppliedInOrder(t *testing.T) { ++ th := kusttest_test.MakeHarness(t) ++ writeComponentTestBase(th) ++ writeComp(th, "/app/comp1", ` ++configMapGenerator: ++- name: my-configmap ++ behavior: merge ++ literals: ++ - testValue=2 ++`) ++ writeComp(th, "/app/comp2", ` ++configMapGenerator: ++- name: my-configmap ++ behavior: merge ++ literals: ++ - testValue=3 ++`) ++ th.WriteK("/app/prod", ` ++resources: ++- ../base ++components: ++- ../comp1 ++- ../comp2 ++`) ++ m := th.Run("/app/prod", th.MakeDefaultOptions()) ++ th.AssertActualEqualsExpected(m, ` ++apiVersion: v1 ++kind: Deployment ++metadata: ++ name: storefront ++spec: ++ replicas: 1 ++--- ++apiVersion: v1 ++data: ++ otherValue: "10" ++ testValue: "3" ++kind: ConfigMap ++metadata: ++ annotations: {} ++ labels: {} ++ name: my-configmap-mc6kg25g4h ++`) ++} ++ ++ ++ ++func TestComponentRejectedInResources(t *testing.T) { ++ th := kusttest_test.MakeHarness(t) ++ writeComp(th, "/app/comp", ` ++namePrefix: comp- ++`) ++ th.WriteK("/app/prod", ` ++resources: ++- ../comp ++`) ++ err := th.RunWithErr("/app/prod", th.MakeDefaultOptions()) ++ if !strings.Contains(err.Error(), "Component") { ++ t.Fatalf("error should mention the Component kind, got: %v", err) ++ } ++} ++ ++ ++ ++ ++func TestNonComponentRejectedInComponents(t *testing.T) { ++ th := kusttest_test.MakeHarness(t) ++ th.WriteK("/app/notcomp", ` ++namePrefix: x- ++`) ++ th.WriteK("/app/prod", ` ++components: ++- ../notcomp ++`) ++ err := th.RunWithErr("/app/prod", th.MakeDefaultOptions()) ++ if !strings.Contains(err.Error(), "Component") { ++ t.Fatalf("error should mention the Component kind, got: %v", err) ++ } ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,33 @@ ++#!/usr/bin/env bash ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++ ++ ++ ++ ++ ++cd /testbed/api ++if grep -q 'sigs.k8s.io/kustomize/kyaml v0.1.11' go.mod; then ++ sed -i 's#sigs.k8s.io/kustomize/kyaml v0.1.11#sigs.k8s.io/kustomize/kyaml v0.1.10#' go.mod ++ grep -v 'kyaml v0.1.11' go.sum > go.sum.tmp && mv go.sum.tmp go.sum ++fi ++export GOFLAGS=-mod=mod ++export GOPROXY=off ++export GOSUMDB=off ++ ++REG='TestIssue1251_CompositeDiamond_Failure|TestIssue1251_Patches|TestComplexComposition|TestTargetMustHave|TestBaseMustHave|TestResourceNotFound|TestBasicDiamond' ++NEW='TestComponentBasic|TestComponentPatchesPriorResource|TestComponentsAppliedInOrder|TestComponentRejectedInResources|TestNonComponentRejectedInComponents' ++ ++ ++go test ./krusty/ -count=1 -run "$REG" ++ ++ ++go test ./krusty/ -count=1 -run "$NEW" diff --git a/tasks/format-code-task-001729/tests/test.sh b/tasks/format-code-task-001729/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..541c6f0db2df5db995a30081c12597eeaec64af3 --- /dev/null +++ b/tasks/format-code-task-001729/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +api/krusty/component_test.go +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001729/tests/test_command.sh b/tasks/format-code-task-001729/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001729/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001773/environment/Dockerfile b/tasks/format-code-task-001773/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..65b924720fa990aff6e597a9fedc64ef531cac32 --- /dev/null +++ b/tasks/format-code-task-001773/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:cf6c8ac93be90aec18b5979206e18a2bc673633be13e9b42bfc4d9eec2f3126f diff --git a/tasks/format-code-task-001773/environment/setup/files/blocklist b/tasks/format-code-task-001773/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001773/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001773/environment/setup/setup.sh b/tasks/format-code-task-001773/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001773/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001773/tests/test.patch b/tasks/format-code-task-001773/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..54ff63dada9ba46b06b97441edcadee1fb028605 --- /dev/null +++ b/tasks/format-code-task-001773/tests/test.patch @@ -0,0 +1,282 @@ +diff --git a/libs/commands/exec/src/lib/codespec-env-files.spec.ts b/libs/commands/exec/src/lib/codespec-env-files.spec.ts +new file mode 100644 +index 00000000..8a0ce590 +--- /dev/null ++++ b/libs/commands/exec/src/lib/codespec-env-files.spec.ts +@@ -0,0 +1,263 @@ ++import { commandRunner, initFixtureFactory } from "@lerna/test-helpers"; ++import fs from "fs-extra"; ++import path from "path"; ++ ++const initFixture = initFixtureFactory(__dirname); ++// eslint-disable-next-line @typescript-eslint/no-var-requires ++const lernaExec = commandRunner(require("../command")); ++ ++const CAPTURE_KEYS = [ ++ "CODESPEC_FILE_ONLY", ++ "CODESPEC_QUOTED", ++ "CODESPEC_COMMENTED", ++ "CODESPEC_IGNORED", ++ "CODESPEC_FILE_EMPTY", ++ "CODESPEC_ORDER", ++ "CODESPEC_PARENT", ++ "CODESPEC_INLINE", ++ "CODESPEC_INLINE_PARENT", ++ "CODESPEC_EQUALS", ++ "CODESPEC_EMPTY", ++ "CODESPEC_LAYER", ++ "CODESPEC_ROOT_ONLY", ++ "CODESPEC_PACKAGE_ONLY", ++ "LERNA_PACKAGE_NAME", ++ "LERNA_ROOT_PATH", ++]; ++ ++const initEnvFixture = async () => { ++ const cwd = await initFixture("basic"); ++ const script = [ ++ 'const fs = require("fs");', ++ `const keys = ${JSON.stringify(CAPTURE_KEYS)};`, ++ "const captured = Object.fromEntries(keys.map((key) => [key, process.env[key]]));", ++ 'fs.writeFileSync("codespec-env-capture.json", JSON.stringify(captured));', ++ ].join("\n"); ++ ++ await Promise.all( ++ ["package-1", "package-2"].map((name) => ++ fs.writeFile(path.join(cwd, "packages", name, "codespec-capture-env.js"), script) ++ ) ++ ); ++ ++ return cwd; ++}; ++ ++const readCapture = (cwd: string, packageName: string) => ++ fs.readJson(path.join(cwd, "packages", packageName, "codespec-env-capture.json")); ++ ++const captureExists = (cwd: string, packageName: string) => ++ fs.pathExists(path.join(cwd, "packages", packageName, "codespec-env-capture.json")); ++ ++const invoke = async (cwd: string, ...args: string[]) => { ++ try { ++ await lernaExec(cwd)(...args); ++ return { ok: true as const }; ++ } catch (error) { ++ return { ok: false as const, message: (error as Error).message }; ++ } ++}; ++ ++describe("lerna exec explicit environment overlays", () => { ++ const originalEnvironment = new Map(CAPTURE_KEYS.map((key) => [key, process.env[key]])); ++ ++ beforeEach(() => { ++ for (const key of CAPTURE_KEYS) delete process.env[key]; ++ process.env.CODESPEC_PARENT = "from-parent"; ++ process.env.CODESPEC_INLINE_PARENT = "from-parent"; ++ }); ++ ++ afterEach(() => { ++ expect(process.env.CODESPEC_PARENT).toBe("from-parent"); ++ expect(process.env.CODESPEC_INLINE_PARENT).toBe("from-parent"); ++ for (const key of CAPTURE_KEYS) { ++ if (key !== "CODESPEC_PARENT" && key !== "CODESPEC_INLINE_PARENT") { ++ expect(process.env[key]).toBeUndefined(); ++ } ++ } ++ process.exitCode = undefined; ++ }); ++ ++ afterAll(() => { ++ for (const [key, value] of originalEnvironment) { ++ if (value === undefined) delete process.env[key]; ++ else process.env[key] = value; ++ } ++ }); ++ ++ it("parses ordered root files and applies parent, inline, empty, and reserved-value precedence", async () => { ++ const cwd = await initEnvFixture(); ++ await fs.writeFile( ++ path.join(cwd, "codespec-base.env"), ++ [ ++ "CODESPEC_FILE_ONLY=from-file", ++ 'CODESPEC_QUOTED="hello world"', ++ "# CODESPEC_IGNORED=bad", ++ "CODESPEC_COMMENTED=kept", ++ "CODESPEC_FILE_EMPTY=", ++ "CODESPEC_ORDER=base", ++ "CODESPEC_PARENT=from-file", ++ "CODESPEC_INLINE=from-file", ++ "CODESPEC_INLINE_PARENT=from-file", ++ "LERNA_PACKAGE_NAME=spoofed", ++ "LERNA_ROOT_PATH=/spoofed", ++ "", ++ ].join("\n") ++ ); ++ await fs.writeFile( ++ path.join(cwd, "codespec-override.env"), ++ "CODESPEC_ORDER=override\nCODESPEC_INLINE=from-later-file\n" ++ ); ++ ++ const outcome = await invoke( ++ cwd, ++ "--no-sort", ++ "--env-file", ++ "codespec-base.env", ++ "--env-file", ++ "codespec-override.env", ++ "--env", ++ "CODESPEC_INLINE=first=with-equals", ++ "--env", ++ "CODESPEC_INLINE=last", ++ "--env", ++ "CODESPEC_INLINE_PARENT=from-inline", ++ "--env", ++ "CODESPEC_EQUALS=left=middle=right", ++ "--env", ++ "CODESPEC_EMPTY=", ++ "--env", ++ "LERNA_PACKAGE_NAME=inline-spoof", ++ "--env", ++ "LERNA_ROOT_PATH=/inline-spoof", ++ "--", ++ "node", ++ "codespec-capture-env.js" ++ ); ++ ++ expect(outcome).toEqual({ ok: true }); ++ const packageOne = await readCapture(cwd, "package-1"); ++ const packageTwo = await readCapture(cwd, "package-2"); ++ for (const [capture, packageName] of [ ++ [packageOne, "package-1"], ++ [packageTwo, "package-2"], ++ ] as const) { ++ expect(capture).toMatchObject({ ++ CODESPEC_FILE_ONLY: "from-file", ++ CODESPEC_QUOTED: "hello world", ++ CODESPEC_COMMENTED: "kept", ++ CODESPEC_FILE_EMPTY: "", ++ CODESPEC_ORDER: "override", ++ CODESPEC_PARENT: "from-parent", ++ CODESPEC_INLINE: "last", ++ CODESPEC_INLINE_PARENT: "from-inline", ++ CODESPEC_EQUALS: "left=middle=right", ++ CODESPEC_EMPTY: "", ++ LERNA_PACKAGE_NAME: packageName, ++ LERNA_ROOT_PATH: cwd, ++ }); ++ expect(capture).not.toHaveProperty("CODESPEC_IGNORED"); ++ } ++ }); ++ ++ it("layers optional package-relative files in order during parallel execution", async () => { ++ const cwd = await initEnvFixture(); ++ await fs.writeFile( ++ path.join(cwd, "codespec-common.env"), ++ "CODESPEC_LAYER=root\nCODESPEC_ROOT_ONLY=root\nCODESPEC_ORDER=root\n" ++ ); ++ await fs.writeFile( ++ path.join(cwd, "packages/package-1/codespec-package.env"), ++ "CODESPEC_LAYER=package-one\nCODESPEC_PACKAGE_ONLY=one\nCODESPEC_ORDER=first\nCODESPEC_PARENT=package-one\n" ++ ); ++ await fs.writeFile( ++ path.join(cwd, "packages/package-1/codespec-package-override.env"), ++ "CODESPEC_ORDER=package-one-later\n" ++ ); ++ await fs.writeFile( ++ path.join(cwd, "packages/package-2/codespec-package-override.env"), ++ "CODESPEC_ORDER=package-two-later\n" ++ ); ++ ++ const outcome = await invoke( ++ cwd, ++ "--parallel", ++ "--env-file", ++ "codespec-common.env", ++ "--package-env-file", ++ "codespec-package.env", ++ "--package-env-file", ++ "codespec-package-override.env", ++ "--", ++ "node", ++ "codespec-capture-env.js" ++ ); ++ ++ expect(outcome).toEqual({ ok: true }); ++ const packageOne = await readCapture(cwd, "package-1"); ++ expect(packageOne).toMatchObject({ ++ CODESPEC_LAYER: "package-one", ++ CODESPEC_ROOT_ONLY: "root", ++ CODESPEC_PACKAGE_ONLY: "one", ++ CODESPEC_ORDER: "package-one-later", ++ CODESPEC_PARENT: "from-parent", ++ LERNA_PACKAGE_NAME: "package-1", ++ LERNA_ROOT_PATH: cwd, ++ }); ++ const packageTwo = await readCapture(cwd, "package-2"); ++ expect(packageTwo).toMatchObject({ ++ CODESPEC_LAYER: "root", ++ CODESPEC_ROOT_ONLY: "root", ++ CODESPEC_ORDER: "package-two-later", ++ CODESPEC_PARENT: "from-parent", ++ LERNA_PACKAGE_NAME: "package-2", ++ LERNA_ROOT_PATH: cwd, ++ }); ++ expect(packageTwo).not.toHaveProperty("CODESPEC_PACKAGE_ONLY"); ++ for (const capture of [packageOne, packageTwo]) { ++ expect(capture).not.toHaveProperty("CODESPEC_FILE_ONLY"); ++ expect(capture).not.toHaveProperty("CODESPEC_INLINE"); ++ expect(capture).not.toHaveProperty("CODESPEC_EMPTY"); ++ } ++ }); ++ ++ it("rejects a missing root environment file before starting any package command", async () => { ++ const cwd = await initEnvFixture(); ++ ++ const outcome = await invoke( ++ cwd, ++ "--env-file", ++ "codespec-missing.env", ++ "--", ++ "node", ++ "codespec-capture-env.js" ++ ); ++ ++ expect(outcome).toEqual({ ++ ok: false, ++ message: "Environment file not found: codespec-missing.env", ++ }); ++ await expect(captureExists(cwd, "package-1")).resolves.toBe(false); ++ await expect(captureExists(cwd, "package-2")).resolves.toBe(false); ++ }); ++ ++ it("rejects an invalid inline assignment before starting any package command", async () => { ++ const cwd = await initEnvFixture(); ++ ++ const outcome = await invoke( ++ cwd, ++ "--env", ++ "CODESPEC_BROKEN", ++ "--", ++ "node", ++ "codespec-capture-env.js" ++ ); ++ ++ expect(outcome).toEqual({ ++ ok: false, ++ message: 'Invalid environment assignment "CODESPEC_BROKEN"; expected KEY=VALUE', ++ }); ++ await expect(captureExists(cwd, "package-1")).resolves.toBe(false); ++ await expect(captureExists(cwd, "package-2")).resolves.toBe(false); ++ }); ++}); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++./node_modules/.bin/jest --config libs/commands/exec/jest.config.ts --runInBand \ ++ libs/commands/exec/src/lib/exec-command.spec.ts --testNamePattern='should run a command$' ++./node_modules/.bin/jest --config libs/commands/exec/jest.config.ts --runInBand \ ++ libs/commands/exec/src/lib/codespec-env-files.spec.ts diff --git a/tasks/format-code-task-001773/tests/test.sh b/tasks/format-code-task-001773/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..56164e37851422b71fdb795f88fceefd8ed1ae09 --- /dev/null +++ b/tasks/format-code-task-001773/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +libs/commands/exec/src/lib/codespec-env-files.spec.ts +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001773/tests/test_command.sh b/tasks/format-code-task-001773/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001773/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001774/environment/Dockerfile b/tasks/format-code-task-001774/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..9708f283f9cacfb9e0a8806c937e56c6fe54834c --- /dev/null +++ b/tasks/format-code-task-001774/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:0f28c8fe40b31638ec9d67ea9641d1928b8d35fa143eac6f0bef2ceb0bc5325f diff --git a/tasks/format-code-task-001774/environment/setup/files/blocklist b/tasks/format-code-task-001774/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001774/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001774/environment/setup/setup.sh b/tasks/format-code-task-001774/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001774/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001774/tests/test.patch b/tasks/format-code-task-001774/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..926b7b46ed5aa709165b81325aa58d2995fdbe8e --- /dev/null +++ b/tasks/format-code-task-001774/tests/test.patch @@ -0,0 +1,152 @@ +diff --git a/jwk/jwk_test.go b/jwk/jwk_test.go +index 5ca4c3081..1ff5f849a 100644 +--- a/jwk/jwk_test.go ++++ b/jwk/jwk_test.go +@@ -1,6 +1,7 @@ + package jwk_test + + import ( ++ "bytes" + "context" + "crypto" + "crypto/ecdsa" +@@ -1653,3 +1654,119 @@ func TestGH491(t *testing.T) { + return + } + } ++ ++func TestSetWithPrivateParams(t *testing.T) { ++ k1, err := jwxtest.GenerateRsaJwk() ++ if !assert.NoError(t, err, `jwxtest.GenerateRsaJwk should succeed`) { ++ return ++ } ++ k2, err := jwxtest.GenerateEcdsaJwk() ++ if !assert.NoError(t, err, `jwxtest.GenerateEcdsaJwk should succeed`) { ++ return ++ } ++ k3, err := jwxtest.GenerateSymmetricJwk() ++ if !assert.NoError(t, err, `jwxtest.GenerateSymmetricJwk should succeed`) { ++ return ++ } ++ ++ t.Run("JWK instead of JWKS", func(t *testing.T) { ++ var buf bytes.Buffer ++ _ = k1.Set(`renewal_kid`, "foo") ++ _ = json.NewEncoder(&buf).Encode(k1) ++ ++ var check = func(t *testing.T, buf []byte) { ++ set, err := jwk.Parse(buf) ++ if !assert.NoError(t, err, `jwk.Parse should succeed`) { ++ return ++ } ++ ++ if !assert.Equal(t, 1, set.Len(), `set.Len() should be 1`) { ++ return ++ } ++ ++ v, ok := set.Field(`renewal_kid`) ++ if !assert.True(t, ok, `set.Field("renewal_kid") should return ok = true`) { ++ return ++ } ++ ++ if !assert.Equal(t, `foo`, v, `set.Field("renewal_kid") should return "foo"`) { ++ return ++ } ++ ++ key, ok := set.Get(0) ++ if !assert.True(t, ok, `set.Get(0) should return ok = true`) { ++ return ++ } ++ ++ v, ok = key.Get(`renewal_kid`) ++ if !assert.True(t, ok, `key.Get("renewal_kid") should return ok = true`) { ++ return ++ } ++ ++ if !assert.Equal(t, `foo`, v, `key.Get("renewal_kid") should return "foo"`) { ++ return ++ } ++ } ++ ++ t.Run("Check original buffer", func(t *testing.T) { ++ check(t, buf.Bytes()) ++ }) ++ t.Run("Check serialized", func(t *testing.T) { ++ set, err := jwk.Parse(buf.Bytes()) ++ if !assert.NoError(t, err, `jwk.Parse should succeed`) { ++ return ++ } ++ js, err := json.MarshalIndent(set, "", " ") ++ if !assert.NoError(t, err, `json.MarshalIndent should succeed`) { ++ return ++ } ++ check(t, js) ++ }) ++ }) ++ t.Run("JWKS with multiple keys", func(t *testing.T) { ++ var buf bytes.Buffer ++ buf.WriteString(`{"renewal_kid":"foo","keys":[`) ++ enc := json.NewEncoder(&buf) ++ _ = enc.Encode(k1) ++ buf.WriteByte(',') ++ _ = enc.Encode(k2) ++ buf.WriteByte(',') ++ _ = enc.Encode(k3) ++ buf.WriteString(`]}`) ++ ++ var check = func(t *testing.T, buf []byte) { ++ set, err := jwk.Parse(buf) ++ if !assert.NoError(t, err, `jwk.Parse should succeed`) { ++ return ++ } ++ ++ if !assert.Equal(t, 3, set.Len(), `set.Len() should be 3`) { ++ return ++ } ++ ++ v, ok := set.Field(`renewal_kid`) ++ if !assert.True(t, ok, `set.Field("renewal_kid") should return ok = true`) { ++ return ++ } ++ ++ if !assert.Equal(t, `foo`, v, `set.Field("renewal_kid") should return "foo"`) { ++ return ++ } ++ } ++ ++ t.Run("Check original buffer", func(t *testing.T) { ++ check(t, buf.Bytes()) ++ }) ++ t.Run("Check serialized", func(t *testing.T) { ++ set, err := jwk.Parse(buf.Bytes()) ++ if !assert.NoError(t, err, `jwk.Parse should succeed`) { ++ return ++ } ++ js, err := json.MarshalIndent(set, "", " ") ++ if !assert.NoError(t, err, `json.MarshalIndent should succeed`) { ++ return ++ } ++ check(t, js) ++ }) ++ }) ++} +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,4 @@ ++H4sIAAAAAAAAA+3RSQrCQBCF4V57irpAhorpZOVZghlwToPp6PWN2SjisFFE/L9NFd0N/eCFZb/a ++1kXTHiLzKfEgt3acg9s57moT1TybJllqYtVMYyP2Y4mu9J2f70XM3jn/7N2r+x8VXvr3TeeLyu12 ++87YOu+X7/njZf5pf+k+Gc00ztUbi90V47M/7r2oZiy+berJwcl4ljNbHTSTBQYLK9a2f6eTbMQEA ++AAAAAAAAAAAAAADccQJU3PP2ACgAAA== +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-001774/tests/test.sh b/tasks/format-code-task-001774/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..a33b983c6147efe7a7aa57613e1152e6abb70513 --- /dev/null +++ b/tasks/format-code-task-001774/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +jwk/jwk_test.go +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001774/tests/test_command.sh b/tasks/format-code-task-001774/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001774/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001780/environment/Dockerfile b/tasks/format-code-task-001780/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..fffe626411258242f93c63e85ae32ba5dd0fe30b --- /dev/null +++ b/tasks/format-code-task-001780/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:e342b9875e2109501428fc2cf890edc29a9399da11e39f185f727d2284f5ee45 diff --git a/tasks/format-code-task-001780/environment/setup/files/blocklist b/tasks/format-code-task-001780/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001780/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001780/environment/setup/setup.sh b/tasks/format-code-task-001780/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001780/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001780/tests/test.patch b/tasks/format-code-task-001780/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..6faeb497020ad21ec670139e5e28f1f5c46d7902 --- /dev/null +++ b/tasks/format-code-task-001780/tests/test.patch @@ -0,0 +1,135 @@ +diff --git a/p2p/net/mock/mock_test.go b/p2p/net/mock/mock_test.go +index e188cfd802..2ea1bf18dd 100644 +--- a/p2p/net/mock/mock_test.go ++++ b/p2p/net/mock/mock_test.go +@@ -12,6 +12,7 @@ import ( + "time" + + "github.com/libp2p/go-libp2p/core/crypto" ++ "github.com/libp2p/go-libp2p/core/event" + "github.com/libp2p/go-libp2p/core/network" + "github.com/libp2p/go-libp2p/core/peer" + "github.com/libp2p/go-libp2p/core/protocol" +@@ -600,3 +601,83 @@ func TestStreamsWithLatency(t *testing.T) { + t.Fatalf("Expected write to take ~%s (+/- %s), but took %s", latency.String(), tolerance.String(), delta.String()) + } + } ++ ++func TestEventBus(t *testing.T) { ++ const peers = 2 ++ ++ ctx, cancel := context.WithTimeout(context.Background(), time.Second) ++ defer cancel() ++ ++ mn, err := FullMeshLinked(peers) ++ if err != nil { ++ t.Fatal(err) ++ } ++ defer mn.Close() ++ ++ sub0, err := mn.Hosts()[0].EventBus().Subscribe(new(event.EvtPeerConnectednessChanged)) ++ if err != nil { ++ t.Fatal(err) ++ } ++ defer sub0.Close() ++ sub1, err := mn.Hosts()[1].EventBus().Subscribe(new(event.EvtPeerConnectednessChanged)) ++ if err != nil { ++ t.Fatal(err) ++ } ++ defer sub1.Close() ++ ++ id0, id1 := mn.Hosts()[0].ID(), mn.Hosts()[1].ID() ++ ++ _, err = mn.ConnectPeers(id0, id1) ++ if err != nil { ++ t.Fatal(err) ++ } ++ for range make([]int, peers) { ++ select { ++ case evt := <-sub0.Out(): ++ evnt := evt.(event.EvtPeerConnectednessChanged) ++ if evnt.Peer != id1 { ++ t.Fatal("wrong remote peer") ++ } ++ if evnt.Connectedness != network.Connected { ++ t.Fatal("wrong connectedness type") ++ } ++ case evt := <-sub1.Out(): ++ evnt := evt.(event.EvtPeerConnectednessChanged) ++ if evnt.Peer != id0 { ++ t.Fatal("wrong remote peer") ++ } ++ if evnt.Connectedness != network.Connected { ++ t.Fatal("wrong connectedness type") ++ } ++ case <-ctx.Done(): ++ t.Fatal("didn't get connectedness events in time") ++ } ++ } ++ ++ err = mn.DisconnectPeers(id0, id1) ++ if err != nil { ++ t.Fatal(err) ++ } ++ for range make([]int, peers) { ++ select { ++ case evt := <-sub0.Out(): ++ evnt := evt.(event.EvtPeerConnectednessChanged) ++ if evnt.Peer != id1 { ++ t.Fatal("wrong remote peer") ++ } ++ if evnt.Connectedness != network.NotConnected { ++ t.Fatal("wrong connectedness type") ++ } ++ case evt := <-sub1.Out(): ++ evnt := evt.(event.EvtPeerConnectednessChanged) ++ if evnt.Peer != id0 { ++ t.Fatal("wrong remote peer") ++ } ++ if evnt.Connectedness != network.NotConnected { ++ t.Fatal("wrong connectedness type") ++ } ++ case <-ctx.Done(): ++ t.Fatal("didn't get connectedness events in time") ++ } ++ } ++} +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,23 @@ ++H4sIAAAAAAAAA+1XbU/bSBDmK/4VQ3o6bCB2bN4kjlStKOXQnUoL3H1F6806WeHsBu8ailr++82u ++X+IkvtJKrU7VeQR4PTM7z7Mzk83gxzlPRzdM3AdrP0oGKIf7+/aJsvy063A/CsPD8GDf+IXhQRiu ++wf4PY9SQXGmSAaxlUuov+T1n/0nFn9dfM6VvqJxOiRj5avL9MJ6p/8FgL6rrvxcdYv33DqL9NRh8 ++Pwr/Lv/z+r/YCGIugpioiaOYhj5z6AhsL8Rs5Dgv4C7ntD+WcD/wd3f9AWB3wJ1OFerCfjQw+siP ++gGQMuMD2mRHN45TBA9cTOJMQ+lG47WOg90TTCegJg6kc5ehBCcUXLeFBZrcYQOYYWk+4Qm/0D/0K ++e1MBgkWhjzS4AgITko3AYHEMw7JMZpDgL6K9HFpAg4dyyWYpoUhMF3QI2Hbv87GQGRuB0nlsXCO/ ++eSSEy4UiCTN4MyI4VXg0/OHa9YAniLNpNJplgqRw/ecVBspyqlWBOpJiU8O0Pi77OGNUI1xKHmWu ++faQ1lffM2mx4wDzQW1WSdq9RT6W4Z5niUkCSC6pxoWyOleZpCoKxEQY0hy7SQIyH7znOh7/OT24+ ++IKdhLzA9G4xlMLsdB5jzYIw5wAPjjqDMbPV8VVY3qE4VmHz0HBPo7CIafGWweQ5fFW3Rc+rCV31U ++V9LNijTYkhRV9Bw6wdiQbz9A75f6KEG1p+dQouFluw2Oj2Hz7OL04u2mE6D6qAhc1NpxZoTekjGz ++hXasW4Nbo5/npa8ImsIXhdqBW8ZmrcVZol7mLaijNaiv2prUF3g6fDqTmQbXWe9lLEmxj3q4LHb2 ++HKy3IYCfoRMpBLNMrjTRzKWGZFPjwZILfHLWM6bzTMCWu7Vk9NyS3HtpO8L9lXqe8zSHSzkT+oop ++VSMq2KIrWg+2Vl0byG6LeQVbNaCTTE7bwVsCtTFaAG8h/CVwPDfLNE84lpJdsrscb8lzkUiXI1Kr ++xZy/1bCYg/a9y1T4IhUpEj7GQm9RuzJQdrEYurAth6LLKa2DnVTB6Gow+nywqjV+Z2kqbW7ohFd1 ++qJV1W9Salp6Ye68ATpqpKO/e07ucpC7Zgbi4mhO8+D89eRBLmTai22+ojLnlp8n/m6Q5u0hc4u3A ++si5uoFT7LMCC4xxCETgaAvFPUzZ1PXyPzXtcv+NXhyL+u3z6lrN0hN8lG0NQcVOBQSqiCUkVc9af ++nHVzy3MTafAbPo8XY6Bqe9vuSyw6Gq8fZ8z1/MKBe8ZkiSDUqgk5bVTHeYOXW5HGhPjnYsQ+7kAS ++FysPPn9GTv47MmWGN+rtstC+FlI8TmWuStP8vbBfJImZLgpj+YKWdmRD0gKbRZETQ7O0+H9wUeau ++dKk01nEpfesmgW3bh8O6ilcpp6zcbdJRlvrK9lVFqCxizat8r1BXYAvcdfzIaC7yOZMlvydb4VKJ ++gGy54UoWC21X5KXqOqS83FTf3lNfaimy2krxT9hCX5H5eix4nSpphywzntrpzMx9OLDhBGamMDN0 ++DIpxVOF9jTtqzYQo6DXmDzT40aAHDxOOkwaOyGk+YqqcjHdxJw4XuUJNcwgpnB/MfIjzCdIgMU4i ++htllLsoZGjlVs4IZ1xW4+J/MmOkjmEWzQDAdGB/758Y4IDnPQYJmDf176FMcuPUwhL7mU4aDKeAJ ++FPjBwnbnv/4PpZNOOumkk0466aSTTjrppJNOOumkk0466aSTTjr5VvkHbGuM0wAoAAA= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-001780/tests/test.sh b/tasks/format-code-task-001780/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..0b7dc2adad5ded9f60181044e9281712e70a8e33 --- /dev/null +++ b/tasks/format-code-task-001780/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +p2p/net/mock/mock_test.go +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001780/tests/test_command.sh b/tasks/format-code-task-001780/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001780/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001787/environment/Dockerfile b/tasks/format-code-task-001787/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..1f806323010252338f62b99b588bb158154cbfc6 --- /dev/null +++ b/tasks/format-code-task-001787/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:b961596bc33c3119884eeaaaf269e967f1923ca74aa4e7e1e4d560ce8cc19e35 diff --git a/tasks/format-code-task-001787/environment/setup/files/blocklist b/tasks/format-code-task-001787/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001787/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001787/environment/setup/setup.sh b/tasks/format-code-task-001787/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001787/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001787/tests/test.patch b/tasks/format-code-task-001787/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..73c659846817f41e753734d638fdfec7de1257a2 --- /dev/null +++ b/tasks/format-code-task-001787/tests/test.patch @@ -0,0 +1,34 @@ +diff --git a/channeldb/migrations_test.go b/channeldb/migrations_test.go +index 13991d6e7cb..3627f142321 100644 +--- a/channeldb/migrations_test.go ++++ b/channeldb/migrations_test.go +@@ -626,7 +626,7 @@ func TestOutgoingPaymentsMigration(t *testing.T) { + t.Fatal("migration 'paymentStatusesMigration' wasn't applied") + } + +- sentPayments, err := d.FetchPayments() ++ sentPayments, err := d.fetchPaymentsMigration9() + if err != nil { + t.Fatalf("unable to fetch sent payments: %v", err) + } +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,5 @@ ++H4sIAAAAAAAAA+3STWuDMBwGcM/5FBnbVWNSozDYYaftMizDe4kaVKhJibFs334q7BW2XlpK2fO7 ++5OUfkpAnUTl223qjzZ4FpxJPMimXdvKzXfpcCs5lmq2yJIg5T3kSUHmyG30xDl45SgNnrf9r3aH6 ++hYo+8/d68JvK9r0ydTS0xzvjUP5CrD7yF3LOP0mFCGh8vCv87p/nf33Fys6wUg0tqWq6fIJS14To ++l511nj7kz3le3DG786yxIY+4eC+t74vHb4V5p9ubeZqQxtJ5KxruaehGQ4tpkI++sZ1p1uq118YP ++T13jlO+soRGrWmWM3tYlI+d+EgAAAAAAAAAAAAAAAAAAAACAi/EGAEAdpAAoAAA= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-001787/tests/test.sh b/tasks/format-code-task-001787/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d184e7ea106d73c34ab5cc14f2b970cdc2e896ce --- /dev/null +++ b/tasks/format-code-task-001787/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +channeldb/migrations_test.go +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001787/tests/test_command.sh b/tasks/format-code-task-001787/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001787/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001809/environment/Dockerfile b/tasks/format-code-task-001809/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..261ab2886431dd9b5ed40da184f05fd2394b929a --- /dev/null +++ b/tasks/format-code-task-001809/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:5601987ef363ec995429cf247bce6a0eb563bc9763c481573520d1d5eb0fd86a diff --git a/tasks/format-code-task-001809/environment/setup/files/blocklist b/tasks/format-code-task-001809/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001809/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001809/environment/setup/setup.sh b/tasks/format-code-task-001809/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001809/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001809/tests/test.patch b/tasks/format-code-task-001809/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..882fcd65e8e0350e0da2f1f7175477ec6da10342 --- /dev/null +++ b/tasks/format-code-task-001809/tests/test.patch @@ -0,0 +1,213 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..b4cc23a15 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest tests/unit/test_sqs.py -k \"msg_size or batch_size\" -v"] ++} +diff --git a/tests/unit/test_sqs.py b/tests/unit/test_sqs.py +index fce5a19dc..19392f8ed 100644 +--- a/tests/unit/test_sqs.py ++++ b/tests/unit/test_sqs.py +@@ -62,3 +62,186 @@ def test_except_check_message_size(): + def test_check_message_size(): + message_body = "a" + provider.check_message_size(message_body, DEFAULT_MAXIMUM_MESSAGE_SIZE) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++def _single_string_attribute(name="k", value="v"): ++ return {name: {"DataType": "String", "StringValue": value}} ++ ++ ++def test_msg_size_body_within_limit_no_attributes_passes(): ++ ++ provider.check_message_size( ++ message_body="a", message_attributes=None, max_message_size=100 ++ ) ++ ++ ++def test_msg_size_body_within_limit_empty_attributes_passes(): ++ ++ provider.check_message_size( ++ message_body="a", message_attributes={}, max_message_size=100 ++ ) ++ ++ ++def test_msg_size_body_only_at_limit_passes(): ++ ++ provider.check_message_size( ++ message_body="a" * 100, message_attributes=None, max_message_size=100 ++ ) ++ ++ ++def test_msg_size_body_only_exceeds_limit_raises(): ++ ++ with pytest.raises(localstack.services.sqs.exceptions.InvalidParameterValue): ++ provider.check_message_size( ++ message_body="a" * 101, message_attributes=None, max_message_size=100 ++ ) ++ ++ ++def test_msg_size_body_at_limit_with_attributes_raises(): ++ ++ ++ with pytest.raises(localstack.services.sqs.exceptions.InvalidParameterValue): ++ provider.check_message_size( ++ message_body="a" * 100, ++ message_attributes=_single_string_attribute(), ++ max_message_size=100, ++ ) ++ ++ ++def test_msg_size_body_plus_attributes_exactly_at_limit_passes(): ++ ++ ++ ++ ++ provider.check_message_size( ++ message_body="a" * 92, ++ message_attributes=_single_string_attribute(), ++ max_message_size=100, ++ ) ++ ++ ++def test_msg_size_body_plus_attributes_over_limit_by_one_raises(): ++ ++ ++ with pytest.raises(localstack.services.sqs.exceptions.InvalidParameterValue): ++ provider.check_message_size( ++ message_body="a" * 93, ++ message_attributes=_single_string_attribute(), ++ max_message_size=100, ++ ) ++ ++ ++def test_msg_size_attributes_counted_via_name_type_and_value(): ++ ++ ++ ++ ++ attrs = {"longname": {"DataType": "String", "StringValue": "longvalue"}} ++ provider.check_message_size( ++ message_body="a" * 77, message_attributes=attrs, max_message_size=100 ++ ) ++ with pytest.raises(localstack.services.sqs.exceptions.InvalidParameterValue): ++ provider.check_message_size( ++ message_body="a" * 78, message_attributes=attrs, max_message_size=100 ++ ) ++ ++ ++def test_msg_size_multiple_attributes_summed(): ++ ++ ++ ++ ++ attrs = { ++ "k1": {"DataType": "String", "StringValue": "v1"}, ++ "k2": {"DataType": "String", "StringValue": "v2"}, ++ } ++ provider.check_message_size( ++ message_body="a" * 80, message_attributes=attrs, max_message_size=100 ++ ) ++ with pytest.raises(localstack.services.sqs.exceptions.InvalidParameterValue): ++ provider.check_message_size( ++ message_body="a" * 81, message_attributes=attrs, max_message_size=100 ++ ) ++ ++ ++def test_msg_size_issue_reproduction_exact(): ++ ++ ++ ++ with pytest.raises(localstack.services.sqs.exceptions.InvalidParameterValue): ++ provider.check_message_size( ++ message_body="x" * DEFAULT_MAXIMUM_MESSAGE_SIZE, ++ message_attributes=_single_string_attribute(), ++ max_message_size=DEFAULT_MAXIMUM_MESSAGE_SIZE, ++ ) ++ ++ ++ ++ provider.check_message_size( ++ message_body="x" * (DEFAULT_MAXIMUM_MESSAGE_SIZE - 8), ++ message_attributes=_single_string_attribute(), ++ max_message_size=DEFAULT_MAXIMUM_MESSAGE_SIZE, ++ ) ++ ++ ++def test_batch_size_includes_attributes_raises(): ++ ++ ++ ++ ++ ++ entries = [ ++ { ++ "Id": "1", ++ "MessageBody": "a" * 8, ++ "MessageAttributes": _single_string_attribute(), ++ }, ++ {"Id": "2", "MessageBody": "b" * 3}, ++ ] ++ from localstack.aws.api.sqs import BatchRequestTooLong ++ ++ with pytest.raises(BatchRequestTooLong): ++ provider.SqsProvider()._assert_valid_batch_size(entries, 18) ++ ++ ++def test_batch_size_with_attributes_at_limit_passes(): ++ ++ entries = [ ++ { ++ "Id": "1", ++ "MessageBody": "a" * 8, ++ "MessageAttributes": _single_string_attribute(), ++ }, ++ {"Id": "2", "MessageBody": "b" * 3}, ++ ] ++ provider.SqsProvider()._assert_valid_batch_size(entries, 19) ++ ++ ++def test_batch_size_without_attributes_preserved(): ++ ++ entries = [ ++ {"Id": "1", "MessageBody": "a" * 10}, ++ {"Id": "2", "MessageBody": "b" * 5}, ++ ] ++ provider.SqsProvider()._assert_valid_batch_size(entries, 15) ++ from localstack.aws.api.sqs import BatchRequestTooLong ++ ++ with pytest.raises(BatchRequestTooLong): ++ provider.SqsProvider()._assert_valid_batch_size(entries, 14) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m pytest tests/unit/test_sqs.py -k "msg_size or batch_size" -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001809/tests/test.sh b/tasks/format-code-task-001809/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..acdeb794375f88ddb1d0994f13053d135bafe578 --- /dev/null +++ b/tasks/format-code-task-001809/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test_commands.json +tests/unit/test_sqs.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001809/tests/test_command.sh b/tasks/format-code-task-001809/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001809/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001831/environment/Dockerfile b/tasks/format-code-task-001831/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..77f92e72fa91a795a51877fc65fd77b512654cc8 --- /dev/null +++ b/tasks/format-code-task-001831/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:0f6f886ca57715fc8e1d799c198aa901542c529a85d8edd67b0816dedafa5a03 diff --git a/tasks/format-code-task-001831/environment/setup/files/blocklist b/tasks/format-code-task-001831/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001831/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001831/environment/setup/setup.sh b/tasks/format-code-task-001831/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001831/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001831/tests/test.patch b/tasks/format-code-task-001831/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..afa51644cb6874c612b46e5fa61506584b7d89b6 --- /dev/null +++ b/tasks/format-code-task-001831/tests/test.patch @@ -0,0 +1,188 @@ +diff --git a/usercase-test-coderl/test_siu_call.py b/usercase-test-coderl/test_siu_call.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_siu_call.py +@@ -0,0 +1,160 @@ ++ ++ ++ ++ ++import json ++import subprocess ++import sys ++ ++import pytest ++ ++from siuba.siu import _, call ++ ++ ++def test_call_range_implicitly_receives_piped_value(): ++ ++ ++ ++ actual = 1 >> call(range) ++ ++ assert actual == range(0, 1) ++ assert list(actual) == [0] ++ ++ ++def test_explicit_placeholder_can_be_first_positional_argument(): ++ ++ ++ ++ actual = 1 >> call(range, _, 2) ++ ++ assert actual == range(1, 2) ++ assert list(actual) == [1] ++ ++ ++def test_explicit_placeholder_can_be_later_positional_argument(): ++ ++ ++ ++ actual = 1 >> call(range, 2, 3, _) ++ ++ assert actual == range(2, 3, 1) ++ assert list(actual) == [2] ++ ++ ++def test_preserves_bound_callable_positional_and_keyword_arguments(): ++ ++ ++ ++ actual = "," >> call("a,b,c".split, _, maxsplit=1) ++ ++ assert actual == ["a", "b,c"] ++ ++ ++def test_preserves_format_positional_and_keyword_arguments(): ++ ++ ++ ++ actual = 1 >> call("{0}_{1}_{b}".format, _, 2, b=3) ++ ++ assert actual == "1_2_3" ++ ++ ++def test_keyword_values_can_be_siu_expressions(): ++ ++ ++ ++ actual = {"sep": ",", "limit": 1} >> call( ++ "a,b,c".split, ++ _["sep"], ++ maxsplit=_["limit"], ++ ) ++ ++ assert actual == ["a", "b,c"] ++ ++ ++def test_complete_siu_expression_as_only_argument(): ++ ++ ++ ++ actual = "abc" >> call(_[0].upper()) ++ ++ assert actual == "A" ++ ++ ++def test_siu_expression_first_argument_with_extra_args_raises_specific_error(): ++ ++ ++ ++ ++ with pytest.raises(NotImplementedError): ++ call(_[0], 1) ++ ++ ++def test_constructing_deferred_step_does_not_execute_target_callable(): ++ ++ ++ ++ seen = [] ++ ++ def record(value): ++ seen.append(value) ++ return value * 10 ++ ++ step = call(record) ++ ++ assert seen == [] ++ assert 4 >> step == 40 ++ assert seen == [4] ++ ++ ++def test_referential_transparency_same_input_same_value(): ++ step = call(range) ++ ++ assert list(3 >> step) == [0, 1, 2] ++ assert list(3 >> step) == [0, 1, 2] ++ ++ ++def test_does_not_mutate_caller_input(): ++ data = {"sep": ",", "limit": 1} ++ ++ actual = data >> call("a,b,c".split, _["sep"], maxsplit=_["limit"]) ++ ++ assert actual == ["a", "b,c"] ++ ++ assert {"sep": ",", "limit": 1} >> call("a,b,c".split, _["sep"], maxsplit=_["limit"]) == ["a", "b,c"] ++ ++ assert "," >> call("a,b,c".split, _, maxsplit=1) == ["a", "b,c"] ++ ++ ++def test_no_global_state_across_fresh_python_process(): ++ in_process = list(1 >> call(range, _, 4)) ++ script = """ ++import json ++import sys ++sys.path.insert(0, "/workspace/repo") ++from siuba.siu import _, call ++sys.stdout.write(json.dumps(list(1 >> call(range, _, 4)))) ++""" ++ ++ completed = subprocess.run( ++ [sys.executable, "-c", script], ++ check=True, ++ text=True, ++ capture_output=True, ++ ) ++ fresh_process = json.loads(completed.stdout) ++ ++ assert in_process == [1, 2, 3] ++ assert fresh_process == [1, 2, 3] ++ ++ ++def test_call_evaluates_from_clean_cwd(monkeypatch, tmp_path): ++ monkeypatch.chdir(tmp_path) ++ ++ before = sorted(path.relative_to(tmp_path).as_posix() for path in tmp_path.rglob("*")) ++ actual = list(3 >> call(range, _, 5)) ++ ++ assert before == [] ++ assert actual == [3, 4] ++ ++ assert list(3 >> call(range, _, 5)) == [3, 4] +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,18 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo ++export PYTHONPATH="/workspace/repo${PYTHONPATH:+:${PYTHONPATH}}" ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++export PIP_NO_INDEX=1 ++export PIP_DISABLE_PIP_VERSION_CHECK=1 ++exec python -m pytest -o addopts='' /workspace/repo/usercase-test-coderl/test_siu_call.py -v diff --git a/tasks/format-code-task-001831/tests/test.sh b/tasks/format-code-task-001831/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..b53b70cfdb10d0b52a0c7102d656004903af4494 --- /dev/null +++ b/tasks/format-code-task-001831/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/test_siu_call.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001831/tests/test_command.sh b/tasks/format-code-task-001831/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001831/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001836/environment/Dockerfile b/tasks/format-code-task-001836/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..56bd9d5c7dba7c2d29d59c4cc73534a7c9459bea --- /dev/null +++ b/tasks/format-code-task-001836/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:3747d45ee69df463268ac1871819d19db38055ee48ed067a43825db06ac2e920 diff --git a/tasks/format-code-task-001836/environment/setup/files/blocklist b/tasks/format-code-task-001836/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001836/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001836/environment/setup/setup.sh b/tasks/format-code-task-001836/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001836/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001836/tests/test.patch b/tasks/format-code-task-001836/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..297ba55180186924cda6cb250ec279a0471eaa7d --- /dev/null +++ b/tasks/format-code-task-001836/tests/test.patch @@ -0,0 +1,605 @@ +diff --git a/usercase-test-coderl/test_static_capabilities.py b/usercase-test-coderl/test_static_capabilities.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_static_capabilities.py +@@ -0,0 +1,579 @@ ++ ++ ++ ++import json ++import os ++import socket ++import subprocess ++import sys ++import textwrap ++ ++import pytest ++ ++import capa.rules ++import capa.capabilities.common ++import capa.capabilities.static ++import capa.features.common as ccommon ++import capa.features.file as ffile ++import capa.features.insn as finsn ++from capa.features.address import NO_ADDRESS, AbsoluteVirtualAddress ++from capa.features.extractors.base_extractor import ( ++ BBHandle, ++ InsnHandle, ++ SampleHashes, ++ FunctionHandle, ++ StaticFeatureExtractor, ++) ++ ++ ++RULES_YAML = [ ++ """ ++ rule: ++ meta: ++ name: push 1000 ++ scopes: ++ static: instruction ++ dynamic: process ++ features: ++ - and: ++ - mnemonic: push ++ - number: 1000 ++ """, ++ """ ++ rule: ++ meta: ++ name: tight loop ++ scopes: ++ static: basic block ++ dynamic: process ++ features: ++ - characteristic: tight loop ++ """, ++ """ ++ rule: ++ meta: ++ name: kill thread loop ++ scopes: ++ static: function ++ dynamic: process ++ features: ++ - and: ++ - characteristic: loop ++ - match: tight loop ++ """, ++ """ ++ rule: ++ meta: ++ name: kill thread program ++ scopes: ++ static: file ++ dynamic: process ++ features: ++ - and: ++ - section: .text ++ - match: kill thread loop ++ """, ++ """ ++ rule: ++ meta: ++ name: push observed program ++ scopes: ++ static: file ++ dynamic: process ++ features: ++ - and: ++ - format: pe ++ - match: push 1000 ++ """, ++ """ ++ rule: ++ meta: ++ name: global arch program ++ scopes: ++ static: file ++ dynamic: process ++ features: ++ - arch: i386 ++ """, ++ """ ++ rule: ++ meta: ++ name: library only push ++ scopes: ++ static: instruction ++ dynamic: process ++ features: ++ - and: ++ - mnemonic: push ++ - number: 777 ++ """, ++ """ ++ rule: ++ meta: ++ name: library only recursive function ++ scopes: ++ static: function ++ dynamic: process ++ features: ++ - characteristic: recursive call ++ """, ++ """ ++ rule: ++ meta: ++ name: import file rule ++ scopes: ++ static: file ++ dynamic: process ++ features: ++ - import: kernel32.CreateFileA ++ """, ++] ++ ++ ++FULL_SUMMARY = { ++ "feature_counts": { ++ "file": 7, ++ "functions": [ ++ {"address": {"type": "absolute", "value": 4198400}, "count": 9}, ++ {"address": {"type": "absolute", "value": 4202496}, "count": 2}, ++ ], ++ }, ++ "library_functions": [ ++ {"address": {"type": "absolute", "value": 4206592}, "name": "static_lib_helper"}, ++ ], ++ "matches": { ++ "global arch program": ["NO_ADDRESS"], ++ "import file rule": ["NO_ADDRESS"], ++ "kill thread loop": [4198400], ++ "kill thread program": ["NO_ADDRESS"], ++ "push 1000": [4223396], ++ "push observed program": ["NO_ADDRESS"], ++ "tight loop": [4198432], ++ }, ++} ++ ++NO_GLOBAL_SUMMARY = { ++ "feature_counts": { ++ "file": 5, ++ "functions": [ ++ {"address": {"type": "absolute", "value": 4198400}, "count": 7}, ++ {"address": {"type": "absolute", "value": 4202496}, "count": 0}, ++ ], ++ }, ++ "library_functions": [ ++ {"address": {"type": "absolute", "value": 4206592}, "name": "static_lib_helper"}, ++ ], ++ "matches": { ++ "import file rule": ["NO_ADDRESS"], ++ "kill thread loop": [4198400], ++ "kill thread program": ["NO_ADDRESS"], ++ "push 1000": [4223396], ++ "tight loop": [4198432], ++ }, ++} ++ ++NO_FILE_SECTION_SUMMARY = { ++ "feature_counts": { ++ "file": 6, ++ "functions": [ ++ {"address": {"type": "absolute", "value": 4198400}, "count": 9}, ++ {"address": {"type": "absolute", "value": 4202496}, "count": 2}, ++ ], ++ }, ++ "library_functions": [ ++ {"address": {"type": "absolute", "value": 4206592}, "name": "static_lib_helper"}, ++ ], ++ "matches": { ++ "global arch program": ["NO_ADDRESS"], ++ "import file rule": ["NO_ADDRESS"], ++ "kill thread loop": [4198400], ++ "push 1000": [4223396], ++ "push observed program": ["NO_ADDRESS"], ++ "tight loop": [4198432], ++ }, ++} ++ ++ ++class ToyStaticExtractor(StaticFeatureExtractor): ++ def __init__(self, variant="full"): ++ super().__init__(SampleHashes(md5="0" * 32, sha1="1" * 40, sha256="2" * 64)) ++ self.variant = variant ++ self.functions = [ ++ FunctionHandle(AbsoluteVirtualAddress(0x401000), "main"), ++ FunctionHandle(AbsoluteVirtualAddress(0x402000), "helper"), ++ FunctionHandle(AbsoluteVirtualAddress(0x403000), "lib"), ++ ] ++ self.basic_blocks = { ++ 0x401000: [ ++ BBHandle(AbsoluteVirtualAddress(0x401020), "main-bb0"), ++ BBHandle(AbsoluteVirtualAddress(0x401050), "main-bb1"), ++ ], ++ 0x402000: [BBHandle(AbsoluteVirtualAddress(0x402010), "helper-bb0")], ++ 0x403000: [BBHandle(AbsoluteVirtualAddress(0x403010), "lib-bb0")], ++ } ++ self.instructions = { ++ 0x401020: [ ++ InsnHandle(AbsoluteVirtualAddress(0x4071A4), "push-1000"), ++ InsnHandle(AbsoluteVirtualAddress(0x4071AA), "nop"), ++ ], ++ 0x401050: [InsnHandle(AbsoluteVirtualAddress(0x407200), "close")], ++ 0x402010: [InsnHandle(AbsoluteVirtualAddress(0x402012), "mov")], ++ 0x403010: [InsnHandle(AbsoluteVirtualAddress(0x403020), "push-777")], ++ } ++ ++ def snapshot(self): ++ return { ++ "variant": self.variant, ++ "functions": [(int(f.address), f.inner) for f in self.functions], ++ "basic_blocks": { ++ str(k): [(int(bb.address), bb.inner) for bb in v] for k, v in sorted(self.basic_blocks.items()) ++ }, ++ "instructions": { ++ str(k): [(int(insn.address), insn.inner) for insn in v] for k, v in sorted(self.instructions.items()) ++ }, ++ } ++ ++ def get_base_address(self): ++ return AbsoluteVirtualAddress(0x400000) ++ ++ def extract_global_features(self): ++ if self.variant != "no-global": ++ yield ccommon.Arch("i386"), NO_ADDRESS ++ yield ccommon.Format("pe"), NO_ADDRESS ++ ++ def extract_file_features(self): ++ if self.variant != "no-file-section": ++ yield ffile.Section(".text"), AbsoluteVirtualAddress(0x401000) ++ yield ffile.Import("kernel32.CreateFileA"), AbsoluteVirtualAddress(0x401234) ++ ++ def get_functions(self): ++ yield from self.functions ++ ++ def is_library_function(self, addr): ++ return int(addr) == 0x403000 ++ ++ def get_function_name(self, addr): ++ if int(addr) == 0x403000: ++ return "static_lib_helper" ++ raise KeyError(addr) ++ ++ def extract_function_features(self, fh): ++ if int(fh.address) == 0x401000: ++ yield ccommon.Characteristic("loop"), fh.address ++ elif int(fh.address) == 0x403000: ++ yield ccommon.Characteristic("recursive call"), fh.address ++ ++ def get_basic_blocks(self, fh): ++ yield from self.basic_blocks[int(fh.address)] ++ ++ def extract_basic_block_features(self, fh, bbh): ++ if int(bbh.address) == 0x401020: ++ yield ccommon.Characteristic("tight loop"), bbh.address ++ ++ def get_instructions(self, fh, bbh): ++ yield from self.instructions[int(bbh.address)] ++ ++ def extract_insn_features(self, fh, bbh, ih): ++ if int(ih.address) == 0x4071A4: ++ yield finsn.Mnemonic("push"), ih.address ++ yield finsn.Number(1000), ih.address ++ elif int(ih.address) == 0x4071AA: ++ yield finsn.Mnemonic("nop"), ih.address ++ elif int(ih.address) == 0x403020: ++ yield finsn.Mnemonic("push"), ih.address ++ yield finsn.Number(777), ih.address ++ ++ ++def make_ruleset(): ++ return capa.rules.RuleSet([capa.rules.Rule.from_yaml(textwrap.dedent(rule)) for rule in RULES_YAML]) ++ ++ ++def address_to_plain(addr): ++ if addr == NO_ADDRESS: ++ return "NO_ADDRESS" ++ return int(addr) ++ ++ ++def summarize(capabilities): ++ return { ++ "matches": { ++ name: [address_to_plain(location) for location, _ in results] ++ for name, results in sorted(capabilities.matches.items()) ++ }, ++ "feature_counts": { ++ "file": capabilities.feature_counts.file, ++ "functions": [ ++ {"address": count.address.model_dump(mode="json"), "count": count.count} ++ for count in capabilities.feature_counts.functions ++ ], ++ }, ++ "library_functions": [ ++ {"address": library.address.model_dump(mode="json"), "name": library.name} ++ for library in capabilities.library_functions ++ ], ++ } ++ ++ ++def ruleset_snapshot(ruleset): ++ return sorted((name, str(rule.scopes)) for name, rule in ruleset.rules.items()) ++ ++ ++def assert_match_contains(summary, rule_name, expected_location=None): ++ assert rule_name in summary["matches"] ++ if expected_location is not None: ++ assert expected_location in summary["matches"][rule_name] ++ ++ ++def assert_no_match(summary, rule_name): ++ assert not summary["matches"].get(rule_name) ++ ++ ++def expected_analyzed_function_addresses(extractor): ++ return { ++ int(function.address) ++ for function in extractor.get_functions() ++ if not extractor.is_library_function(function.address) ++ } ++ ++ ++def assert_full_static_behavior(capabilities, extractor): ++ summary = summarize(capabilities) ++ ++ assert isinstance(capabilities, capa.capabilities.common.Capabilities) ++ assert_match_contains(summary, "push 1000", 4223396) ++ assert_match_contains(summary, "tight loop") ++ assert_match_contains(summary, "kill thread loop") ++ assert_match_contains(summary, "kill thread program") ++ assert_match_contains(summary, "global arch program") ++ assert_match_contains(summary, "import file rule") ++ assert_match_contains(summary, "push observed program") ++ assert_no_match(summary, "library only push") ++ assert_no_match(summary, "library only recursive function") ++ assert_library_function_was_skipped(summary) ++ assert_feature_counts_are_populated(summary, extractor) ++ ++ ++def assert_library_function_was_skipped(summary): ++ assert summary["library_functions"] == [ ++ {"address": {"type": "absolute", "value": 4206592}, "name": "static_lib_helper"}, ++ ] ++ ++ ++def assert_feature_counts_are_populated(summary, extractor): ++ counts = summary["feature_counts"] ++ assert isinstance(counts["file"], int) ++ assert counts["file"] > 0 ++ ++ functions_by_address = { ++ item["address"]["value"]: item["count"] ++ for item in counts["functions"] ++ } ++ assert set(functions_by_address) == expected_analyzed_function_addresses(extractor) ++ for function in extractor.get_functions(): ++ if extractor.is_library_function(function.address): ++ assert int(function.address) not in functions_by_address ++ assert all(isinstance(count, int) and count >= 0 for count in functions_by_address.values()) ++ assert functions_by_address[4198400] > 0 ++ ++ ++def test_common_entrypoint_instruction_rule_returns_push_1000_at_4071a4(): ++ ++ ++ ++ ++ capabilities = capa.capabilities.common.find_capabilities(make_ruleset(), ToyStaticExtractor(), disable_progress=True) ++ ++ ++ assert_match_contains(summarize(capabilities), "push 1000", 4223396) ++ ++ ++def test_static_entrypoint_returns_full_static_capability_summary(): ++ ++ ++ ++ ++ extractor = ToyStaticExtractor() ++ capabilities = capa.capabilities.static.find_static_capabilities( ++ make_ruleset(), extractor, disable_progress=True ++ ) ++ ++ ++ assert_full_static_behavior(capabilities, extractor) ++ ++ ++def test_basic_block_function_and_file_rule_chain_matches_after_one_call(): ++ ++ ++ ++ ++ capabilities = capa.capabilities.common.find_capabilities(make_ruleset(), ToyStaticExtractor(), disable_progress=True) ++ ++ summary = summarize(capabilities) ++ ++ assert_match_contains(summary, "tight loop") ++ assert_match_contains(summary, "kill thread loop") ++ assert_match_contains(summary, "kill thread program") ++ ++ ++def test_file_scope_rules_match_raw_file_global_and_promoted_lower_scope_features(): ++ ++ ++ ++ ++ capabilities = capa.capabilities.common.find_capabilities(make_ruleset(), ToyStaticExtractor(), disable_progress=True) ++ ++ summary = summarize(capabilities) ++ ++ assert_match_contains(summary, "global arch program") ++ assert_match_contains(summary, "import file rule") ++ assert_match_contains(summary, "kill thread program") ++ assert_match_contains(summary, "push observed program") ++ ++ ++def test_no_global_variant_drops_global_dependent_file_matches_but_keeps_file_and_promoted_matches(): ++ ++ ++ ++ ++ extractor = ToyStaticExtractor("no-global") ++ capabilities = capa.capabilities.common.find_capabilities( ++ make_ruleset(), extractor, disable_progress=True ++ ) ++ ++ summary = summarize(capabilities) ++ ++ assert_no_match(summary, "global arch program") ++ assert_no_match(summary, "push observed program") ++ assert_match_contains(summary, "import file rule") ++ assert_match_contains(summary, "kill thread program") ++ assert_match_contains(summary, "push 1000", 4223396) ++ assert_library_function_was_skipped(summary) ++ assert_feature_counts_are_populated(summary, extractor) ++ ++ ++def test_no_file_section_variant_drops_section_dependent_file_match_only(): ++ ++ ++ ++ ++ extractor = ToyStaticExtractor("no-file-section") ++ capabilities = capa.capabilities.common.find_capabilities( ++ make_ruleset(), extractor, disable_progress=True ++ ) ++ ++ summary = summarize(capabilities) ++ ++ assert_no_match(summary, "kill thread program") ++ assert_match_contains(summary, "global arch program") ++ assert_match_contains(summary, "import file rule") ++ assert_match_contains(summary, "push observed program") ++ assert_match_contains(summary, "push 1000", 4223396) ++ assert_library_function_was_skipped(summary) ++ assert_feature_counts_are_populated(summary, extractor) ++ ++ ++def test_library_functions_are_skipped_and_recorded_with_names(): ++ ++ ++ ++ ++ capabilities = capa.capabilities.common.find_capabilities(make_ruleset(), ToyStaticExtractor(), disable_progress=True) ++ ++ summary = summarize(capabilities) ++ ++ assert_library_function_was_skipped(summary) ++ assert_no_match(summary, "library only push") ++ assert_no_match(summary, "library only recursive function") ++ ++ ++def test_feature_counts_include_non_library_functions_and_file_scope_count(): ++ ++ ++ ++ ++ extractor = ToyStaticExtractor() ++ capabilities = capa.capabilities.common.find_capabilities(make_ruleset(), extractor, disable_progress=True) ++ ++ ++ assert_feature_counts_are_populated(summarize(capabilities), extractor) ++ ++ ++def test_static_matcher_rejects_non_static_extractor_with_specific_exception_type(): ++ ++ ++ ++ ++ ++ with pytest.raises(Exception): ++ capa.capabilities.static.find_static_capabilities(make_ruleset(), object(), disable_progress=True) ++ ++ ++def test_referential_transparency_same_input_same_output(): ++ ruleset = make_ruleset() ++ extractor = ToyStaticExtractor() ++ ++ first = summarize(capa.capabilities.common.find_capabilities(ruleset, extractor, disable_progress=True)) ++ second = summarize(capa.capabilities.common.find_capabilities(ruleset, extractor, disable_progress=True)) ++ ++ ++ assert_match_contains(first, "push 1000", 4223396) ++ assert_match_contains(second, "push 1000", 4223396) ++ assert first == second ++ ++ ++def test_does_not_mutate_ruleset_or_extractor_inputs(): ++ ruleset = make_ruleset() ++ extractor = ToyStaticExtractor() ++ ++ first = summarize(capa.capabilities.common.find_capabilities(ruleset, extractor, disable_progress=True)) ++ ++ ++ second = summarize(capa.capabilities.common.find_capabilities(ruleset, extractor, disable_progress=True)) ++ assert first["matches"] == second["matches"] ++ assert_match_contains(second, "push 1000", 4223396) ++ ++ ++def test_no_global_state_matches_fresh_interpreter_result(): ++ in_process = summarize( ++ capa.capabilities.common.find_capabilities(make_ruleset(), ToyStaticExtractor(), disable_progress=True) ++ ) ++ script = """ ++import importlib.util ++import json ++import sys ++ ++sys.path.insert(0, "/workspace/repo") ++spec = importlib.util.spec_from_file_location("fixture_static_caps", "/workspace/repo/usercase-test-coderl/test_static_capabilities.py") ++module = importlib.util.module_from_spec(spec) ++spec.loader.exec_module(module) ++caps = module.capa.capabilities.common.find_capabilities(module.make_ruleset(), module.ToyStaticExtractor(), disable_progress=True) ++sys.stdout.write(json.dumps(module.summarize(caps), sort_keys=True)) ++""" ++ ++ completed = subprocess.run( ++ [sys.executable, "-c", script], ++ text=True, ++ stdout=subprocess.PIPE, ++ stderr=subprocess.PIPE, ++ check=True, ++ ) ++ ++ fresh_process = json.loads(completed.stdout) ++ ++ assert in_process["matches"] == fresh_process["matches"] ++ assert_match_contains(fresh_process, "push 1000", 4223396) ++ ++ ++def test_no_undeclared_cwd_writes_or_network_connections(tmp_path, monkeypatch): ++ def fail_socket(*args, **kwargs): ++ raise AssertionError("static capability matching must not open network sockets") ++ ++ monkeypatch.setattr(socket, "socket", fail_socket) ++ monkeypatch.chdir(tmp_path) ++ before = sorted(os.listdir(tmp_path)) ++ ++ summary = summarize(capa.capabilities.common.find_capabilities(make_ruleset(), ToyStaticExtractor(), disable_progress=True)) ++ ++ ++ assert sorted(os.listdir(tmp_path)) == before ++ assert_match_contains(summary, "push 1000", 4223396) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,16 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo ++export PYTHONPATH="/workspace/repo${PYTHONPATH:+:${PYTHONPATH}}" ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++exec python -m pytest /workspace/repo/usercase-test-coderl/test_static_capabilities.py -v diff --git a/tasks/format-code-task-001836/tests/test.sh b/tasks/format-code-task-001836/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d6f0644cde4da8e9ba44b9205d0b84be378d89c0 --- /dev/null +++ b/tasks/format-code-task-001836/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/test_static_capabilities.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001836/tests/test_command.sh b/tasks/format-code-task-001836/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001836/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001838/environment/Dockerfile b/tasks/format-code-task-001838/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..729eb175a42e2f26eb257aff0151ed9a250866b4 --- /dev/null +++ b/tasks/format-code-task-001838/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:79346c74d3f09c5217ed3897a649d82f28c024f2bfb0afa0e58562c377b4df9a diff --git a/tasks/format-code-task-001838/environment/setup/files/blocklist b/tasks/format-code-task-001838/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001838/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001838/environment/setup/setup.sh b/tasks/format-code-task-001838/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001838/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001838/tests/test.patch b/tasks/format-code-task-001838/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..d3623363a6f23d1dcef5164a5d785d21ec79b386 --- /dev/null +++ b/tasks/format-code-task-001838/tests/test.patch @@ -0,0 +1,340 @@ +diff --git a/spec/lib/supported_mime_types_spec.rb b/spec/lib/supported_mime_types_spec.rb +index c9990d410..fb442445f 100644 +--- a/spec/lib/supported_mime_types_spec.rb ++++ b/spec/lib/supported_mime_types_spec.rb +@@ -2,12 +2,12 @@ + + RSpec.describe SupportedMimeTypes do + it "includes STL files in model list" do +- expect(described_class.model_types).to include("model/stl") ++ expect(described_class.model_types.map(&:to_s)).to include("model/stl") + expect(described_class.model_extensions).to include("stl") + end + + it "includes PNG files in image list" do +- expect(described_class.image_types).to include("image/png") ++ expect(described_class.image_types.map(&:to_s)).to include("image/png") + expect(described_class.image_extensions).to include("png") + end + +diff --git a/spec/requests/model_files_request_spec.rb b/spec/requests/model_files_request_spec.rb +new file mode 100644 +index 000000000..d00c702e2 +--- /dev/null ++++ b/spec/requests/model_files_request_spec.rb +@@ -0,0 +1,49 @@ ++require "rails_helper" ++require "support/mock_directory" ++ ++RSpec.describe "Model Files" do ++ around do |ex| ++ MockDirectory.create([ ++ "model_one/test.stl", ++ "model_one/test.jpg" ++ ]) do |path| ++ @library_path = path ++ ex.run ++ end ++ end ++ ++ # rubocop:disable RSpec/InstanceVariable ++ let(:library) { create(:library, path: @library_path) } ++ # rubocop:enable RSpec/InstanceVariable ++ let(:model) { create(:model, library: library, path: "model_one") } ++ let(:stl_file) { create(:model_file, model: model, filename: "test.stl") } ++ let(:jpg_file) { create(:model_file, model: model, filename: "test.jpg") } ++ ++ describe "GET a model file in its original file format" do ++ before do ++ get library_model_model_file_path(library, model, stl_file, format: :stl) ++ end ++ ++ it "returns http success" do ++ expect(response).to have_http_status(:success) ++ end ++ ++ it "has correct MIME type" do ++ expect(response.media_type).to eq("model/stl") ++ end ++ end ++ ++ describe "GET an image file in its original file format" do ++ before do ++ get library_model_model_file_path(library, model, jpg_file, format: :jpg) ++ end ++ ++ it "returns http success" do ++ expect(response).to have_http_status(:success) ++ end ++ ++ it "has correct MIME type" do ++ expect(response.media_type).to eq("image/jpeg") ++ end ++ end ++end +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,250 @@ ++H4sIAAAAAAAAA+w825LcNnZ+7q9gRg+Sq9QUwDsnsascW9nsZuV1pGzlYcvVBYJgDzXdZC/Jnot3 ++19+egzvAZvdoHHlTqWQeLDYOcACc+zkAHFbHdldvWHf35otf6w/BX56m4l/4m/8rvnEa4QilOInx ++FwjjNI+/CNJfbUXO33GcyBAEXwx9P13q9xT8f+lfaPn/G7Zv2h37/HNwBmdJco7/aZplhv8oyYD/ ++Mfz7RYA+/1JO//6P83/sjwNlwdXNNB3G6zdvhmP1uGX7MeyH7dVq204b2ePVNXzfHKsvg78Efx3Y ++of+rHSMhIe33b178hcP+FkLTVfC31YqjC65+/jqIwyiMrlarF8E/H7t6xwJWb1nwnrS7MWi7cWKk ++vg5g4uDlwNtevg4k1mvV8EY2r3iXK/F99VogzkMUFleA948jC3447klAxmC6YQE5HIKRDXdskIMO ++AFNjsjDRIz58++FD0PRDME6POzbeMDaNsv9IxnFtZvr6qyC7sqsnXR1MA+nGA2hM8DtyRz7QoT1M ++wZ8WiCI38HGs+Ni220qsP8pp5s1XspmO83a5dBzGchmgtcHvPvzh++CbH347BvcwW8DIyMLgPZAy ++2PcDuw7Or0VovaaM/qWmiEKMNXnes7odA1KTw8SGYOqD4dgF39Cp7bvgW1LB3tsuOAx9fRRtij18 ++kEKWhkjj4sPuWPCur9kuuCHjZmT0OLDNAQh93w81dBMCUNHh8TCBBLwUcoPD/OXKR/Fh6gcC4nNH ++hpZ0kx7Y7qFxA6uhbByBcAoFDiNAIFZW9xNYOo+gEZceASR0GtdkXE9ku+VbW/ed6lPyTchOTdOu ++d21FBnoDKzFMwUK0gVpHmDuowFYEU7tnXBKH/ri9CSiBAd32H4OB/fnYAoU44WjfNe32De8eDpWc ++gP8YO3JQQofDBIT1tR52HTRkNzJYDKA9BNeW9EHdr4JASvrWrCu9WrGuNt1rdsd2/WHPuul1cD2x ++cZLDXgAzdzsg/SOrjtuXIN6P9zdsENzlukSBZ5z749QfAvYAfBNTci3YsikgQc3HbUFEYEtjv2N6 ++KRIhLOewIxOo2X68Dv50vR9amH4P9LiHfx+yZCO+f9Sjxj/v2onFZhegeQoyjAdGtaLo3hOsgwy1 ++1RDMTY2CNsDWfnjcVP3ktN0aaY+dvtujRQNaUPiAtZhcgZMwN9CaTKQC3dvQHSMdG9ZEiOlmYLR3 ++8dldHKue9gcjhzPmznupaS/3anHRPdnpwAbOBNJRR3TLs8M4TlCH8dZaH2TJ3u4PO9jhnYKhMIoA ++fA7X+DiueXgB/05sb/AlZwVUS+Y3lKszyBoIIxghSVstZwFIIXug7CDk8QD6PwZgzMHpUBBoEKrg ++peq5LNShXt49q9aqp9K8JFS7fRF8144gv4+BQz5AIj7FvOOR3nC38+Hffy/UXihGsyPwtR3I4WYU ++HoaBCRDE4WoHa3gExxpUQ38PXipUStgFFVNm4ciNBOgcmMZbvk1H1WGqewb6OrJlI/+u7dofhp6T ++ewCLT2/XoF/t+qCbql1fvdkTYMTw5v3bb7579zbc12IFyr3ORxhdsTK8a2F4ZwCFpNSHw8CJDhLL ++6jEAjroMBa7cMnbgHcTewUPvWipJCH6l4wDFmwqWwEWiqz/NoY1iXiNr4peSrBfBf7ZdDVQGgQLp ++6HpOfLo7gkX7qe8Y52MgBPN1MPZBJf07X8P0E4etuXZztNI8O40nVk3Zs/1433auXYPvjzwQ+lH5 ++EAq6aHyLsFU6QqmAHpvxCE7mwfWfynkxkEFWbz721WbJwiTCC2lXBmAJXXfH3a6u1sqJG211nNqe ++7XtgpwHhjC9KGdf+wJ2zUF4YHrkKbqF2jXftyMyCStMO9AJigDZMzDhVs1zBw/XIpgnINa65r2TW ++bpZX7qZIDTQ1Yme2cEugGcKBU6ru+i0PFuzmEjuKu/wNRCINueuHFvyECRBNF+WLNmQAam/Zw8Gs ++y8ywb6dpPJoJEt1+17L7DcjoAcSsm8yawZv9T0f99u80/wt3Pb39rHNczv/yPM5ik/9hkf8lKEH/ ++n//9Pf5+8/YdWM0BDMDk2Fc3C3wDcB6BjNfwEQREuCAqYv9XPPnC6EsB0KADmO7g1VfBKeyOjcfD ++oR+mU3DX9skQvBJ6ZRrBJ48gi2xa1wM3Z8ErcMsozEL8pbOUPRiPqn94/mLAjp4DSct5dhcq/Xju ++JvlKxR6iMNd7gK3D/iBzOTg/D737a9xPh9l+OS2et92+49boF5Diid0IjqWvA7GrNEyevyuQPmH+ ++636/5hkJjwI8QXC39tyNnV09xDjUft7qGdVGIrsREQyJTElLX/zlp61bd7iZ9rv1SLp2an9iUsix ++mgnclL/LiT1Mz5fkX0dctxAlkl1bm41bbe1v+207tAKCwyJM3T1IfjxrKlWAELSJrWowsEOtIljy ++OaiOl6iuYorgVQwCbOYmQwWpghwWmWEGTMc79cXjP8iRppYKcjjLt5ANz6QUHc1G2g6yEYgtaggs ++ZJFtVPPlustHSBaGR5kniuFJGGmYjngUE5y18e5Ty+SIzG3vRiFFApFHAWEA/jvSAWGNi28vijzP ++wehL8tJAhfNZUnwhEA5eiRh4WZNgT2ko7ME/Bbnrbxx1+vv5m/MmGIRmpy2KaYXMDWJtSD6lZGCf ++1QbbTAXJyLJE/2AdvQHst5q7ple7rRkFw77TegCxwHEYIL5di1qvb92QFdd6qLTca13AYcbpa7pA ++pL5VXp6XvSJ3Q8YCOyq6P4K53OzVL1lNBBkH0zBftszaTtzKvNwXvCo5Tc6KRHYqEH76ELzK3D0v ++yJSeXFoXUPW5BBr2CFuCHLMG5I02t+xRJFxqh2YywskDbkvvWbKTyzjWXWRdlZs5aNJtltEoNKuz ++XA5eJQ4CyKPZA+9ZaAroaiXfSpRoGwCsGbcH7VbteG3lYzAXeipRIITh/l7Zru3Y3PHQm2N3+7g5 ++cJPPBUQ3i3RarCDEqW6Dicgjb8SaJCeiiq3VAljHhAZvDn2/40s0pKUDGUfeG5ne8+K8XI8XGDgG ++2GwMnIbcvFqlmxVz2UsuiE72lH2/XIXkwhFdlExiNHWOCDoxX3fOdImsranFlhyP6lQvuFBFT8g9 ++1zPHOhs59UzFHPFmtmUuu/i8Op9O4y3S9tDsEsUNjra0XlxrlSxH6Fbw/BvjZ2TZYZF7SYhdqR8P ++PajYMOoEiAw167QSafmq26ZZ76gQukyztO4pP4kScqgpLg47OFcKv0nLrAOwvXn4W5xZbWxmGyop ++UGpJKlADapvwx6m7c6uYXeJ3ZqkgSvNccAo7wHEYsDLs+IymkbPmYbIm/EwmS9aglceH9bY7PtVl ++fxx3C32G/UUUBnx2OExQk+G+7U6hD0W2eRp8YXqvh7cC51RKWj1sRFQgcGMEWbkmNXdYjmBpu2v6 ++6LA2dW2zG+j45u0k3kXWvdlwEYfxE7KgRvAzFyFlyA+p9cqFc3AyNVmR1gk2l5LETqRjC3meZFqP +++4oNH/VeuInHkZAvJ9kRauHrcNdPoISke1QA0/kwPKqFYWeX4w3b7RZ6TzdmH7jw9r3mZUMyKafm ++AsRpELdBuWWbIpU8ZfIaDR6Z/hg+SySCUmUpjZwhljiapf2BLUTIDuMvRi4GeNNub6Qvj20g4Qma ++FBUur2FhsqvlqPJLM0CeSklBj84vI/GiMRVBRq7NFZZLfdu1zmMvPqXmMBlGFaSKOw2WqIehHXUw ++KnNQZxg0dFV/rxYQhdFMPvk2+XHLFpzACIqstlyoQNqxyOBSeOK3AxKIGpyAGze7mFQK4l5QYA1x ++OC8jr3MBzanHkhtTa+j1UZqMFVXzRxP/8TjND7N11UCKzhOSpcF+dpyEsxBpViTgdOJEX47SvIjE ++1cvEMwfz2xrSnJ2LzOxKRx6gwrZLLeM2e8encZkvwo606lFrv/LlofD6uKnlci8ZuXnQxVlOlikB ++z0VnF7Swbwl6DkoJcyBgZsHwbdlGXv3hKjVBfiAiesxlR8VywMJpM/Q7UUp1cmTtRKA3mnsPzeRq ++3Yzsjp9oKrcg013+4bjSat0KN6Gtfqk6lSbp1j7JyQLVYZXI286rbHJBXJal2yqsOH7e8CIG883q ++ru8bciMcrqOcKvmRHS2/ZhVAbBTE9ahOEi+LxZHrTjya+jULnrT+gvq4Loc4PlOdbAp6mlh5z0DB ++a3WxzeO+swzemtpWWX/IQscoiiDYLz0KF6CoZQbzw0EvvXYzWdlHZ8vYWktV3OADTSQhQxGvQdKG ++N2Y28pfpl0swpQVmEFDQqw2c62a0B7nayu849MfJdOMckDvE59HJEx5+9KEoY2WIX0IJ43MRvCzW +++2XgJ8bayPjTBp/G/M8c9/wJZ2nAJw1bSB+eM+6XbPFMwrE81gTFyFZdlgPo5YjYy5odhYGYi4Cl ++lqpdOK2jriZhx2CIOE/oZeJ6ZnXec9jKvFktz/z0Jegi0KGD0+OEpRa2wLcT4OK0Z6ivzAy25lTk ++HcLGWRujS2B+6D8zfn7peLnu5t1L4dmgQcfv1Mrs3ir+6UmuFBUniJUnbiIMjm2LOmWLQu8sx6Rm ++pqcIu5aK7+pQevn40xwTnwdzYVqGXjpXlUd2n/XM9eJJx69z2CfvPeniO05dFuhAwh+zEGJHl1N7 ++r4ygnepyQJG5c8yP8ryquQ5b5JWc9FyAkvKKwD+Iz8z9zOxnaj8T+xnbz8h+YvuJwoG6P92Vy9zW ++p7RzFJh7xx+nyQMHFy6+2RUpGVFly/IxJ7iH3oHY9s92m8OzMWb6W5WsuoGESLR8G/QTa6d7Nugj +++dSsUubPsbU+EiWObZhpTjiTU0n0a+lhel5OPbDJ4d2wH3GHo+d0An3kOaKTupu4GM8NqOuYeNua ++7lqBWNa0Im+AAQKkdO27d2Sh+vMbahvtGSMnMNem3bvB4GbqwhFravtpgqdwjklOdG9bBYjnlf3l ++ipEnjLld48NeZGqJQS0LVTEvp1lFEZfAzalE7NXaJBCoALQRV0vHs532Pb09hbrYRXvmjzKSsjjO ++n1jAjSjZwr2+hDArNX7KBGrRAlB8VszGs+J5beaZNb9z7F3k3Cfw7RLXLm/Q3Z6BiZ2rKxbqYjwX ++8TRzDnXU6akMWi05ZB1H2CUz8/mKg7wN4mzfxrEyJnMBflHRLVJdrhv6Gi+LhaLM5fYRaqWQp6eV ++R/E2QJdHRYiN5/KzXJ40F1WOXcvjzXUtb8pv7tt6ulGLTqQ0WmlzJwQjUjolVJcOwCSr825m7fNO ++OdnYO0nTbPWs7+kjCJFQuPU7PU6at0U6zIgV41kn73GHCGdLX5/m9b3lcPfMmtIF3X7GmrQ5Redo ++ldgRM4Zj12DM7iIgW1izz+ZkucQeggDAGBl5VKFu25nNii7yGoMZZp1o6XSy1HUPFfyC7nxuJY62 ++kb8Uu2UT7++qi2mXk+hQBXDL+b17Jsj6cpvTInuLxLySEe7bmV0f2PrZmekugl5tgE7BG26JNvI0 ++7OSMeY4EOd7zPAZu6JQBlO8nZEkdmSZNrMQtBV08qZkXTrV0iwuWwgzNkGu28nsDs2Kzc15xQZsc ++oMte7zhH3eiXYc1i3j/vocs856Cz3H7WYSH7X+5xOod9dTDLixfuMhh6qbESj3obJ84pHFU577Sk ++58zdYq9XK58VDDzj4bpQPfOaHiGK1Kbb1UndwbPH7n2hExT4l60KzdDNHIBTMznFOTfDS6s1tuPk ++sYzUKg31XsCJkMPGhtbMqRnnx3yePTvvbsXJv6NaMsPCtpbG7Zgsw5oGUcyVmYGeXN2Xi9x690VV ++P7OiyFLXfw0jMoV0LtB+tUC5uuIJa6OBFypb+iIND43LE2fLd6lanWeA0tCdO6X0XJtXtZkD9a05 ++efn3TIzsjDh99YDc41/vnqbtyx4m1o0ybFYnKCf43D7I5rg24Y7k8cPqh99/8x//8of37z4A3DOP ++89+8mHzSxuuUvFFbTfdbD/AK57LBmEj46ZlM+9tFcVIaXa2+e/vD2++/e/v9t799K1bu3u2217Mu ++XgnWL+NUx9MLovI1uAbPLn/Kl2McaO9FqsusQh3lZceVvbJord3ClUL5lpkD/XuC8u2cbr905c9e ++CLlwSU6+HJSd5P02+XRPtHj3xQQ6kXM6l7tW5s6WfEwtwLPrSNaueTdVCtOiA1P5sJo3u5c8rCZ/ ++dB8KRCowmp/Jr9zTdUthfbIrn6uKFn3Yat4F8lZzZGieQopWdYwnX/jxlsPWPeib1cjly00J4CVy ++IRlimKWl+D9XmKbT2p58/Cg6yLqRReok7Cs/EVpd8lRYYnMTlNUsOVj5ETw3TXyME8b+/LVTojLv ++bk1EYy9YLcQwskgrgCYw+Vk/2ZfNMw+6OvWb9szJeYy7OnUw8rEl7+dZdXunYvXtv7799t8+/PGd ++thbzd20Q0pMozb7KCUERI1FWZ5RGmMYxy1BSVVFBUJ6WlL9dzNI4xriiSYRR2pRZk6OSpSgnDakM +++vlbNT0BjuKsSfKoLrK6QmnWlHkVZyiKS1wxWFNW0iKpyyYv6zKLq5KWVYqgH4twTDHLvAmcx2Ea ++fxpXFDZBcZaWDJCTCGc0iRHfVREVWRnjOq/KvInSqIpynEbQN60ZrqK0SFmz8qPwGfYECJBUcZUg ++TCmgY00VN7TOmrhmaQaYGEW4QEUSV3nSpEmc5k1aVCjiG01RabB7r5809qYhNa2qsgLCA0nLqmFl ++kpG8zGOgRkQqCv8pUZmzCtdVnuUpg+UUSYESimlBV77vnmFnKSmTPKUUFswKVNd1k1NW5wg3SUJY ++TZOmiLIIaIRSQF9AW0STIo4i2BRCbO5n5I1nw9cK52lSNClKSZXXrGExi7K8KnBUNilmiNYcljGS ++UFrHLCnjLM3iPM5KFBUoNdjd9zmGMDEGliURgiElibOIFTSjiAsramJUlg2l8JGlRYHKqKRRzPKS ++CqqhhrJqNQtc5pSJGCyQJFmWgPxlKIuzmJVN1qQlyHTNQCobUgBTadpUeUxrFOdVlUckQQ1JymI1 ++z1Jm+EGOKS7jOqFZmSR1kTZpHKUp7KPK8igr6wi4nOKqhgUwVFaYkIgy2gB3i4KW5ClXLv24IRau ++KZCZFRxPFjcFiBNMVkcoIXHJCM1ZRLKkiWiGKKhCnYMcZCAHNKrLGls+z5//GCXAJcrqtIQN4ByB ++VFYggTVKK1DtgjEgH0pjlINEkYamLClK3ADdKhBcxGBrq5MYeDYBwkkB3fM8QUla4gIMRFHGpEka ++BNLEDUcR52mTUdBYBIxvaJ5WZYJYzfIo1rJ07smLnoXEdcEQArtT4yoGkUF1BmKQV3kJLQglcQHr ++QAjHObcheZJXTUlwDdAKs5osB0byVYyeoyAEJ4RS2EEUR3WcIlYyjHEaA0UawsDSgUTjvEagviXY ++RNCaBCgZg8Voyljwwn0/o/FGwLmMRlkM1iBKkihKuDIUDLS2BM6nZVWimJQpGBOQPFZFDWw1bUDM ++E5gp5hfPnGc0GmuZJhlOcZpTXGckLqKKRnkNClqDBcJlCkoFZqdJU1bmWQqCBOYBgxQBQZI6Lnge ++7j/GMWTIKCctmNoq5QrESlplcZImdcLtWpQwaCNxXvxXe2e2Y9lxnWld76fIpgWofUFVzINgGdBA ++S2zIUkODG31FxGgRlooEixSshh++v38Xa58cTpV84b5ogCmIVcw8uYeItf5hxYpgrxu2mTW0CGKQ ++lobocuZ4saXngp1tTAYOCsGbTdRv7g24jzhA3QU6A8mBeEklZbtstRbgz8TkdgyRYvHFxqArzlOc ++2zrngxU8AmVNz6p3JUBq56UYKYW69XtCiptZNT4sEoRUEBy/3F5046npbE4J6ssATAADfUi7t1pW ++nrGn1Ftr0FId8J6CfJU6Ge9Smt99Hs83KV0MTnAOYmlEkn2WLrwvpOh02QMBALwyUZSVY3GbF4S7 ++WzQBMgDD13Fnq9O7a2uuW2ews/HwAuBqkAo+NXBqQ0euEmvQCEjDZPthSuTNoPU6m01BKfNsZ9Q1 ++1jWT6NNtHrwBe5s/mLYyC8O5NrmY+dishW/aGFadcfotShul+LiPR+v6qh/YW1RbYqr0RVBk49zY ++pmvy82ymGxEfumYVftbQC/w7YFxa9S7ZsOxovh8vtm69u/J0vDxMl6Otweq54QMHUYWebUXjeOJ8 ++BFt8DTVlA6GAHvApMU86ag5fbvS6coZX7PBejMOMHSbDuUttrofVh7eZoWkdHuxtW5vAJUInpgQi ++OgZvr+PFdrHrsU3ZvBxMBw2VPHMzyawVvC+1F2RNWJE3shOMGs2QSrEQLoidAJKb87Gfbjq7rkzQ ++AZgFKi0hWlBnC0RhTNdMTYOZcM3u4YD1pYeMPuSSWwbB8wz9eO/WtYtKe0yAP0CWYcdKvBSozIu3 ++R4Q1EX/neJGNvCRAQ5ID5rvl5GZs397h3ga4d3cgjfeOvWXbrOO5CfAB10txld5BANt4Q+djrLsb ++Ox0hn8NANi10iVGMP9lG92hsLMnuGhoIydttTAgX2LPYnqbrpqwGrSCvM0Iy87GY4VdRXp/hbbC8 ++bzPeDVTaGrxmJojbIDWQeuihDFZPs4o3G/EWmOoIB+h/ofaewDniNwFbx5ONe9eYr2g912NIifbs ++ChwAajmCmaysHqHrPAhjeiVpMsKpjg1dtzTAMr9f2Pq32/8uUAkEBNkCkRFexEPqAIeFLklNgIkk ++JbRnsI6cImJBCN/7bIybRavW/0R14O2GwCuziqsJpvEGJPMW9WMmz7AGcYKAUfKOmlIFxnAlCWVf ++QYq5uj7hS7l3w8e7At/dB9MEJKaknE9cNCHJUjoBa+EfoosGZEBmgpAxQeJdDNsa5oRwdvl4urfw ++AviI2Eoel5TF7nHG5FADrlpEwCx1wXVzNriVQK4RsyD0AYxcbGYOc9zdoXiFEOrRMgwoB9mYWgQ1 ++hfgW4qwOzQ/rGxcNAqDGPUJG+EOVGRo8/dPf3qZ4RZZSt6EljWecAaIM4c4mPbrgkFmYIOIW01Z4 ++QW+LNDn87TrE21s5nu9UvJSMI2wc+LIy3ghfwpOuniIvMDGGBQ4gzdtKeaMRUMLEn0l9T+VK3ueF ++n+09vC4NdE+AhmcNkxhCiILCSDegjX+EimzbRNSGRMIAStCuCWrpqObKPBzPdzBeF0Z7VXiq4vua ++XAaoYxF0SMZiZLshQsCMZEHLeH7qEz6a18sObjt1+9N9kFeCRVxHrt5LGxqPG0ZY5QJ1Q8ykE6Qu ++Sp82zOgm6l3G3JAarTSkaXlRHXt6eT4MJ4MJ0Iad1gPtDiqvCA3kooXBu0Wjmp2tlcjdSCeEFeSS ++4MtTJj3aZHl5gG7Q43vi/mtliEMDA0FInxCO1Y8SkNEOOctgMMREIOoJqt0oDY+tPJ5v1bxkvymO ++NAZvS5wdfzLgz0ysYIrJPNCcoQ0R9VFBn1UwUx6rI83PQ8x63N3wedOjBKaHpJxZg3lraKMMKIPx ++CxlGyo8m+EEDYIaKHCTxUkirAv+VejzbF3rNIcCKKyh4dnS9Qb+QegzCZqRJTrdQYhPji7HruEo7 ++YGxMBSwGZBKPx9/aQXoDLdQBSkWebWLncSs4V8RHWyhWiUmibXgp1Zgz4gOcnA6MQ6PiAvcHb3T2 ++9d5yFKTPjajf4jw0gSvwFy9iUF2BRFweBex6jyEU1PBYxCa+G9iz29fnd3rS2X6xLmbxLHTo10DD ++SNi0HRk27kzcjonrwCqQFhbhgBnD3+y1kH5i6PDemzx9FYS5Bx4n+jr2tdNyAV+PLoXLRvVWAiXZ ++lEtszNlGVmA+sVdoOhWGXt7ltop6k7H4jIbYk7uItqteUaJrvBXqLWfvNWwkOSnYQuvkYsQ5W2Ao ++o8n68aH9uVdyNJR9NeLzjSWOEm07iT56NrWDZ30yTMVJaiFiMzqyoyoIDBinpvs3eTktdSqhCNwl ++/R06XhO85MJo+srEC/9xzrwDhqvij/QgPhjjJPDc/NB9nswMxgyJCIEheDD7ER+8y7Rjw4eEOrCd ++XGob8B99g4k7kbHAla88Dne+U+L/dsfxrYywAjgaSjjxAS5shMEeZCwXAp2IDaA1eXA72OwBtYJN ++hJ93QbefQ/Zik/Ij79JKRQzx2/w+nAB0GimsCg8v6zNZHwADAg9gRLe3icvHRyMSSg3Hvd3Nl5Cw ++xCZyBKBW0ic8RpEQrUpn3CDWOe6c0SrmtIcz5j2xs+QMMGPT8d590FdhjYtExNRChZthDNC/znJX ++8eTjZn7jqFEWhHRBVhJsJAoUCB8hHcU8z3dTX/wQhcttJpQI/IYmkJ/jNz0aeyMeGgI1aHK7im5I ++H5Ucm4oMCdNrj+fbrq/5RFRNTImHUxYAlYA1gAHPmAuY6Bf5sUKwwEpzxqaITJw7hl1zNja24/6+ ++5isgMZiWeDZ82EA3bk1wFrdpehxzuN2LBFyJVrWs5NpEDxofAoEDw63n60hvd0dfDw9LNLCsT7v8 ++yHalhnwKcSyushyzUEuTwYXtIomXbAue2QGwNsZJD/9iT/QVLqBzxd4l+VCQJ3Y0IIqmJjSbpDTJ ++s/lRBnO369uQe70jlngzMkoU9HyL9KUDwecp5CKyCTuLvlwIB4dEI94915MXxu0mDEI0cGxWRc66 ++SLz0s67wZG/1VSYrcBRiqQLAyATInmcEmBeKBw+HA7NZ4g3mR7YBFYAAfkhvgwtu8bi3BfsqWWBg ++O6CHD22IU6QgED9AXKAEJgTnsYuRv4+EkCURliEiI8Kn+UTiHh/ewnwxv8pUGX9ZVUz0MaCIQx9B ++fMLdIo4OwpHuYjqXQ7TB1WimkgFoFMNxb5fyjR7h2IXuHsBqDlsllwr57qF1E7diRq3E7rishUC1 ++xKPKVlyAKvA9jjt7na/BD7D14sGxyWN11f7wQ90agz2sqkz54YlVFdbMCKN0Q7gHgiXgfL3sz71t ++z1fMECwoQTCR+VOlbBN3PB/swL38HiFKx01V1IkU6MkWEDl1RgilZO4sp77b4nxhzCaXGFsDhgEi ++BAf4Crzw7Ct6rzGu2/Ho25eOqCubWMt1wJYWvG7Hs+3Qt/WAGDxmc2aiPdVeVPCbVlcJZmYCyXqU ++VTU9FRS/m7AF+IzUwxTv1o6Xm6pvZtpkshBgHGMAKjXAqd5voiEOVAG+OYJgk/gJXQsSvF3SchsI ++Q7is44N7oi9aQmyQ7ExZrGiNwFu0GCrZ35zDamSidcGnzePfkbdajXPRI/AItHpa9g9ulb4mYIpq ++gDTiPDX+vz3z1wWMXWEDvaCtjFYiJLtWkVWKecIwWeF3vGf/9AXGHem618hIJFCy7SDJ7DHM8Aai ++E6rtpaE9Ffi1o4K1SuCreFgG8vhP7cK+FmYEyrVF21zpEAkGISLOCCM8p1sE0KrMHBJ7gfRa95ve ++YhdOCvJnst3Zy32l2zD4gdiTd1hTHM3QYoCGG/MxFjfitiNiQvjCVYGpgZcsUdp3lHy82BF+q/qi ++KMiq5GxQgWmoMI/oNB5IxrDCrsyBbCgyytZcOxqiaJEsGfyeO57v/76pmwQPDWIiSB8Dp7JDOUJX ++FhdVHbZ254o5qGg0G6fLAQGSocxtILPj5S7yC5ydRy2rwu0zDt2mtHk+mGDHOcdChqHJJBtajHtU ++zJ4RGDnr58Al2+PFLvELMgMAyO937JWVK9P6MuAytb5F4Kisz5XAo0waZIO4zQuFALVNt4wk2cud ++49djG3i5Mf16kqKlGpVG8BAoPdSTh1E8csMBOz1uGNhGjXmLzVbbTyPxeP/5BTi7pZT9QthovUYL ++fUj6xGAvXB3mMxMLxD2CVMvt3Dto+RzDBSvXsy74dMf5NYNYGkILA+IdF1OW2DwKOr2iKGAlc66x ++AzOq5ucO2qBnpLDsLrHu4+W+9UvKRDeib37DPyIOG7kZl9vwNGqoALUi9YnsMEobbmPgQlKM3AL8 ++j/fsfr8eHVVt0KYnTzDGgShTMXZxZfwUr2MZ2ImaSZPhsmRJbaTURjVspMRxZw/9bb1LBZHlVnBy ++t83yqiAxQogRniUu6G+kkXqodlUZDjBTsndrveYsoj3fiX89NnYe/TCtiq/oDiJOC3VAvQgcnY41 ++Q4M4DwXhPHbAq2OlN0jAq2x7PN+nf2Etghc51TAmwzNjCDK0LkqurMEwQMsD+YIe4+G1BlYSWjUl ++mGwhcc4VmGeb+y8XEAhry1BXKcMFVW70yz7L5j7aolKeceqVGExwhwDDBEOQpiix6c6RfnpEwIVM ++CDakPvSi+n9gRnPWIs8mxeUcl/pIygrqCmBYilXdcpiWGTHGS4Px+KCBK8XrJPLRLdlk51whHbvo ++F9LGatg6VNCbHVPvT4NTPNmIl1tivpzice+4ggunK8o4QfOA/trTRzDJqnWkQlwLwWhgCNmsxQ3K ++xN1EaMc6U/Ha7Vx9eXaswRV1Af0AA+JKVM1gmJlTIsvhrYA+hhvsX/X0Y6RJ6iojLRgwYIRxNsf9 ++kxAe1QZgv9FPgwzjMki4rdzLlKdGAzNAJxQwm9HZasxyAxTGdCElz2Lt8xMUrgiZJIFpG5McnUrx ++PaCnOlSrC0WQGTNAFjJOQW+FwkJaZLOipsjLiT45dOHCPdjPqqTPXMr651TO6fMIITBfIUFg4F6S ++gS5xQZgPJr6fZejRzvj420c33NaLudyKKsuvElTcYJCNOAFZkVZD3C6Q2Iyou4ZFeuaTVdFM0Hb9 ++23d7UtooECQkPiAcSLjVILdFmsMVhUAyapnp+K7uwEje0qpMgfDoQAdeOd+93d0iGv6pTozLAHGB ++glzQfOi7omJr1sJ4t4wvlr2pmyrpbfVYCr+VcRUfvtPTStpQ5S3BP2pdQPrZCKz3iHpp5BkAT+iq ++RtCmqCBhfgx6HMWHXAKP3nOrl5WuzPAggBl5kLr1YYuK3lHLe36QlsnxXWIALb9cMQXfNYK1ucpo ++gev3bnS/ppYzlKVqKRwrRgOdF9gJ/mONsv5DcHXaLl8KBCItAGnwhNtG9MMM8wN3ejlVbmPriwrr ++y7pVfBKhdxSJBBVZSx7CINMQm8QMgV8BDRV8pDFrvjt+76+uORBFvUB4xQRLYAt7TDOCv2tFNcsA ++jjPVU93iqwkXoiMDwUuNSP5tYDw7SuMCYeSjmrFI8V2mcH4Z/q+WscVkF9NrGZnRKoSH8Q0xnWGw ++PPmRqjfH3UM2bmAWJ+40zki09h4QOk2F+GJUYpDy4WMbQQ5ptoB/ZD5E/itWCLArV18c1XFbQYY9 ++lg0FhFGbIYbIIcgJMIIH06QFORCsTBTvAt4rbg0NjSLwDGc2x50DP65RsbkhX1vryyNSsNCIVxOA ++2UCcoqQZD8bfIhKL2si0cuf4G6o96WWPx8eC3OxcQa7HhGjFbSKahzVaR1SfDwpMFdiKKEcSRr3J ++CbsZB4kndaXVerz/cJFLXaRa2tQtDHrFD+6CNswJk4gLxeLiKBCFE4SP0JeaU+YMTDWvRfS099/i ++aUQabBMqBvgLXf+NTWOxUiS1AUZ6wbzBvvoMN2uILVLDmzFXQMAyRG4c7z3o5Epn0Bz728lOgjEC ++90NUjm5nvKZWtkaf6LI4sUR8zY2aUbNl11rmqZPed1zKRYdLRqGhpA0w5By4FDZ6Camlej5Wt868 ++xGKIHLwrqYRlBKrgc63n3bvF0+ng4fB0IDYe3ehZrSr8IHqDImeRL1JJTE0ZYXvZLnUIzEQkm7bK ++fO8dnqM5/2PMSVS3cQokMXJd/WOIBXKJ+0YL/8HQFoEd93LIox0cEIZcPgPr8QEwtx4nHOdIDVXt ++hoy+YZ6rmB2gGMx1R/dOtZ0iHdrCxiMm0kDK54BWicfTY2Su5Mpo8no2mZZ1OpSVbZYQnmLx4SE4 ++UxT2XC2jQjx2F7UNfINTQcWTuwfIXHAJlY0ctMKavXouBoKR5x7ciKs1G9SbrB4hsAnL5LFtaLex ++1TuEVT6eHkNzLdkB8UkLpIvYF5W0pOlFixJIo+7gVdD021hsvFbqwirLq+26BvWcHE/PrbnkTMs7 ++VYfWxdsu1XrQoAgHALgPtUcVVLTcM74cia9O69Yan8b9kgD7eHb6zQW9zLzi16jmglwnLYe6whPG ++bk2GuK6dxRdTFXGtYPoZIvxpy9keftw5Q+dKfxObOI+5IsuH6QgVWWhCbkFwm0hAWm+0EPdRZ2zT ++JBKdsnRMzPH81J2bo0ury5BOj8zF9OwJBjKPSzXWFeA7C3d4tDbSyOakQPYDWYZ0GaeHee8pMrdm ++UTwan29a4LSjiRPQa2KzjEBJ2WoubbODt6u2OWJP5SpEiYvDzuse90+RuRXFuw0RJ3CaQmcZooJI ++W6fAGhCpVhCSalOu24obXgaWWvssa65zifrOkS8Xdu22rFbvUDfkenCYhAh54GSQNeombd04I7XY ++hZimej+6NTLZqnYd790k8vYAmAsCEsoC5HDObiuDUQXwHalql1MrZgvox4WUwxQ5C7wsyfyFVYWy ++ejnuHAdz4YDg71ya1uqaBaFw8A36S2qlNstEGVVbK6O15aY6RIXBwnMTpi0fLw5xuZnsSr43zEup ++GpuN+UArDORgUPsYloo4I3JnVW8/bzZjUdqqKRmEOJ4dBXMZ4X6W6TsqHdiSx2vEzMQ99tra9qiM ++qBKHt/OsGdSOmHJaW3RYOGOPFwfKXChQUDK2aJ03wJj40yGPWSHvBqpg59XUUauqGcwpbKuxDmg8 ++6c9+XvnlcTLX1T02sQupsjcMRcxmp9CLOlLBklzQUivPgmaMZa2qnQKoCBVsSlvnatidQ2lurR54 ++RBMC6AL+723L2QPktehLhKMUE4JHrWCZF0Gt1jbAMdAYkbrSefXH59hcgBtXyhEF0Ca6UGuYncyV ++viLq006Ad0ZXlqYaEoAR8RIbUI+I793add3nx91cUYLU6prIjY9qzoErTCUeBEDrTmIAo5qwVw3L ++nwgkm9QL1xDcaIN2otjd43EuhRpbPXtGk8enN3CWaagBiMVRoVH8MIga63AFDvQ306o3G3wYoOjq ++/Xh+yM6lJAEMSB7ZGHkFT/4Z4iEGh+sBYdVYMXwozqtZCBvQCXhTk+ozvIA/YfLegTwXumDWGGbs ++YWNYt5Z9uTYUWVFBW0ZfGYq+FoqSwAMc0hCqFQu58/bBnx/hc+u4HbwxrCEEIwwBCp4dB90g17JU ++VOqyh70tdTNPp4g0QZWyqZWh49mxPrcy91KvlQ8Ocdi3U7MhOV21o0AutgT1kqM1yDODYu36b8KH ++jhVAC9jTaj49HOhCcuRhCaQhphzFgnMpCTnakIkZtijgGBGDQdA6eHc+YPRQw77uIgTO7y789Aig ++G08zT/g1i7nLCBwgcWgB0sun2jkbYzohVhTiRsog1CFQQJB0hWLOHo0PHBR0M0st4L0sgAc8N20P ++qqrbOWAJ7VZUVV4xWbmuWSQC9vLNVIwB7HiWfu6dFnSlUknt7HRVHxRRx2V5/Lm02q5SktYdCMih ++FRmAgADgQ0yxsW1bDMjxcO/IoFs4xjkGXgwHDO3seS5Z4A5GsVqCwzPaCBiTaNqsYmZh9hkd+dTl ++vb2u/vzEnpudwZnwYTSAA8eJQSYaFQ5WkkpLPbdmQN9SPfhhf+4tCtqkVCxQdmqlZ+f+XNq8KBCi ++A8t3D2Vv5C6YuwARLbtB0trksrTfzFRMK+FD8gOQWxid7e3ST463uZAd1NUalz4slxsSxFFqhE/O ++pcON1oY8oaBzlbVJ41aeYs0cJdgeXf7xqTe3ygPEi47g4bkLLhVVZ8ZZbC9qtzXdlRhOxs8jkRsO ++fxclaLNH0+xHl793SM61ZOdIT9lFhnUllThNA+Nx2cNmBw6ptNIMngl57n1NatJQ+xQawcLJj27z ++9JCca5isuH8HclWaOaBKI24LGlf694aP6SSiKom5SpUhcYJz02jhKZ9LwXdPvLm1mxARHpsBKPSx ++h9T1iCHPUbRURy47hGsuSBKU2mza6aLoYaAI2RWOD5yPc+Gm2VpGQet2wnWmokiZA4NBKqvh02dE ++7OgmI2PQbaBpJlvc2NvV7v3xvlN2rlnYIqBgmEDfJRSInuaEdzgntTlgZ8AQIkENFmqwwhGi+8Bx +++XpN9suzeq4chq1DUPM94hvRPqP+iXKH6JyKSUEQp92eexhte3KhAhJ8HGVmpj+eHeZzzewAzlw/ ++m/K0LWMUr7aQmEvV7lFHwL9dF18eQIDNIG9gFbU3wedzJf7O+T+Xgd9hM7AFQYH6YDZXiWnvjteO ++uBLuzKSic7Y2AmJ3WgsRkYZVqGqQUHrdO93n0pMjnhsW+cXgg5pXnYskWA9wSRtrMDrcJ6qIgHlg ++OHiVqlUGBtKcqu/5GUEXpC2LHMIluvMXIKyVGYTi8HoMMioexMYA1yX2zrv3DhnbmoJadJcQ+eVJ ++Q1ekLO1gHehGSMl5IBHj3JkEwACq7KqPNO0hVTHr3O6q3SjocM/f/Nnw854jhS7tN2VYMftZO86Y ++1+ryIv1dIfOTj+TAtgkxQ7zPTZZGFFPB76sY5EJ6fIf3HEx0zTFCHbrr/DqOkscbjojE9JCss/Ea ++SEvwLE5PZgWkdN1NfagEntWGsuP58UZXyMOeErtEDHiDXleDbIno9oZBM+k0lRONovWT1JsH/mYm ++lTeMGM7zdl4ckvTIl62I9wLACOsMTuHruZyv/CWmoB4FWL28rRNjNS3mhH+HbjuDZx9f++kZSZcu ++qQtABJyYwFERqeprb+htrBmqNi6IneBSA82qqMMSp/Z0pKmtWPZs6fzguUg3Fa7eLUOuTqeNOKEg ++ChzMntBk00v0a78bVhNGC2g8OFdLEhZOLpD+nftcpytdM4Ef8cYlldm0c0sdSwlpXJCdUGVkilKe ++GRLSF1EX/YjSebwnaWnu3uNlQbFXfinxQki6yTfK9lqvl3PZqhqL9dHSFnNBgK28zuHMls8j6syd ++29wvXHY+b6ElLKOKJT2pk6/boLVY3LFZ1WvvN4Ioa11oe4AlqscKhaCi8nvv86x66Rx0RQglg3cu ++4uFz6zeUScKvou4MQJDYNbKXS/23llCwYsF17g1476lTF3zv4bWFOamDo8CbGFyILGiJk3fCRBbt ++RAp6+pBKzmrMDlp7jRW8OpPv+YlUt7WnqWbYqLotE9lRqAPzBRYF21pO6hfoWqG1JFzD0mnDlZl1 ++7UG8JHO898CoW/tLQH6WAN43w0hr56o3VWtqpPrUThdtEyCGtsNtdgQ84sJ0zGaDkvrx4TOkLhWm ++tVIeGROJtlsm56iKa5nB8BdSQ24qLW/UkU4c8+xa39MjZSAiHB84SOrWowW2aUlJB0AgRBFhriNC ++SXC8lAF/zXlSRE5kuxab+1aPMf+Gie3nysH946huzTFwYsEGy3TVjcCL+DRVpqZWZhbfmyeYqdXP ++VG3Yb1bQA/uhVBVN90+wukhJ3dPVOyKlqHPfraZOh6TGPBP9JkKXjtwwFY2qxhxVgrScyaRog+Hx ++9GyrCzs8SBi1+0gLkoCF1k4NTjWo4YPMKtizCtEZ4Nia1AzaErg/Nd/bLHh8Qtat5w7/3FuqTB4f ++rYRHIHOXDkQAJtqMVp3E+J4SyDmD+iXFMcxIvITNP16cs3VrIEbb+lTABEnbqV1vNdudtaOZeEGf ++igIyUS7ZtGaa5Ilq7vXcQ388P63rEqBay3FlQLFcAwoT1Hi8NUzWAk8L7U+sBpqJ4Ajow8HYTVVW ++tRlHF/7goV6XkdeWJuQODw97LW2p5q4LNMYHVOT07B1JmBv6gysnhpEcm63qOJAd753c8u3RYFew ++G0k/IoQhcB097pYCxWrLeVHVFpDJXHiqM8wmNHfi6vA3ebxc1eA/PQDs1puQChQDF/rI3Kp/UTsi ++SBZIxiGZAHrJsijBm2FJq1UV8iA3i+sU5Nw5MOwKRY07r4zcPjcow8AwFDrZjsV4a+lZxx8QiMxG ++kT5LS60YJLWDgL69+t2zwC7Mb12NTqgbnCieeMIwCTIDickYZAX+SA0yvVYrfA3o3B5Lj1lC7dyZ ++8qHjwa4pBgxbAiolR716m0hQcigjjgaEmGPQXs2CoJ6kUS66jwParELp7JR7fsjYbeHQqknGc6Xi ++0WjqRwbl+Vk+q7QmDnjqdOGGsRlaMo0qLlRb7LTuOH77h5/+74d/+eS3v/v0N7/+1jS9PUT3OH76 ++h1///Fef/Pzhf336+1/yo7db4I/vffd1+/rh2aj+2Xr9l1dagFEWQmrzh2/++F93D8NXjvH8k6/n ++f9rk4veszlAy2lLtvqflaRu+92D+6x7h/V8oBdz7w/e++uKLrz/0ub/18/9Pv/7uv73qn79+1dub ++Px5v1tcPH6/jGPPhDIa+5nH83cPv+PY3Xz581QmSA1Goktz//Mnvf/njj77/y9/88yevfnj+RJf5 ++0ff1/Y+O9Zf2p4ePvv/fzx88qGfz4WMdgvLHv/9IF/zDmwV3r4c/fzE/35+v+fCL9WcpEb7Zvn6Y ++X6w3r3/An+vL9Xo+fPFaq91/0ZbvX3z+9S+/6Q9frS+/ePPuQd6m+Ge/+OSf/+nTX33y43fP/epR ++XH97dd35Z1+83p//Kwb/3bkYx5//bX7+1cPHXz48/k396Bg8yz+++ParcV7i4R/+4eEH3977Z//0 ++ix8cH3/88fH0WX708NEHnuajd5/++ae/+8lP+fNXv/nZT3712U9/+5Nf/+yXn50Hk3GBr7/65vZJ ++odhv/vB7vn19i1vrtT55/Ubv9Nf21etXryHsh8a/tb/gE6W8ns7Zqy++/Pr80MfOnXP26ps3X736 ++0xej/enxFHLVT1+TGn/608P/+N23c7Fej3NhUL/9GZP3DeLx4c/trw+dufz8zRuZ6rbl2b9axNLf ++H3ogpv/tZT7+eH/1xf9Zrz/mXv92Trf7x1dz/eWVDm56+I//eHj86Udxd65ovzta4Hg7Cw/r39f4 ++dlF69h+Nr5bi47c/+fRXv/vsk1//y4/P33l2eY3l/V9/dwTD09/XI/z2m9dnpAIR/8rT6Ntvnl7j ++LC/qH6/+9Hl/9W3Fes2zAfqzr//65XrzmX5Kjrz91LcLOW9enYdufXYK8M+u1Z23n/yOob77+u7r ++u6/vvr77+u7ru6//l1//F27SzuYAoAAA +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-001838/tests/test.sh b/tasks/format-code-task-001838/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d474475bd1b74ee1073d68023859de0c59c2bad9 --- /dev/null +++ b/tasks/format-code-task-001838/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +spec/lib/supported_mime_types_spec.rb +spec/requests/model_files_request_spec.rb +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001838/tests/test_command.sh b/tasks/format-code-task-001838/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001838/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001919/environment/Dockerfile b/tasks/format-code-task-001919/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..9059c595fd8fb9acbd3bd2e9d913c4c36378f9e7 --- /dev/null +++ b/tasks/format-code-task-001919/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:fe1a649b454bd6566c0493883b2dbdfe076beaf7a8537ee2bdea13df69bc20d8 diff --git a/tasks/format-code-task-001919/environment/setup/files/blocklist b/tasks/format-code-task-001919/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001919/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001919/environment/setup/setup.sh b/tasks/format-code-task-001919/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001919/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001919/tests/test.patch b/tasks/format-code-task-001919/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..3e04d557057ae2afd2777f2adad05566b1347250 --- /dev/null +++ b/tasks/format-code-task-001919/tests/test.patch @@ -0,0 +1,351 @@ +diff --git a/usercase-test-coderl/get-value.test.js b/usercase-test-coderl/get-value.test.js +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/get-value.test.js +@@ -0,0 +1,321 @@ ++const test = require("node:test"); ++const assert = require("node:assert/strict"); ++const childProcess = require("node:child_process"); ++const fs = require("node:fs"); ++const http = require("node:http"); ++const https = require("node:https"); ++const net = require("node:net"); ++const os = require("node:os"); ++const path = require("node:path"); ++const tls = require("node:tls"); ++ ++ ++ ++const createMapper = require("/workspace/repo/dist/lib/index.js"); ++const { getValue } = createMapper; ++ ++function clone(value) { ++ return JSON.parse(JSON.stringify(value)); ++} ++ ++function listTree(root) { ++ const entries = []; ++ ++ function walk(current, relative) { ++ for (const dirent of fs.readdirSync(current, { withFileTypes: true })) { ++ const childRelative = relative ? `${relative}/${dirent.name}` : dirent.name; ++ const childPath = path.join(current, dirent.name); ++ entries.push(`${dirent.isDirectory() ? "dir" : "file"}:${childRelative}`); ++ if (dirent.isDirectory()) { ++ walk(childPath, childRelative); ++ } ++ } ++ } ++ ++ walk(root, ""); ++ return entries.sort(); ++} ++ ++test("reads a nested object property with dot syntax", () => { ++ ++ ++ const source = { foo: { bar: "baz" } }; ++ ++ const actual = getValue(source, "foo.bar"); ++ ++ assert.strictEqual(actual, "baz"); ++}); ++ ++test("selects a root array item by bracket index", () => { ++ ++ ++ const source = ["foo", "bar"]; ++ ++ const actual = getValue(source, "[1]"); ++ ++ assert.strictEqual(actual, "bar"); ++}); ++ ++test("preserves nested projection shape across two array traversals", () => { ++ ++ ++ const source = { ++ foo: [ ++ { ++ baz: [ ++ { fog: { baz: "bar" } }, ++ { fog: { baz: "const" } } ++ ] ++ } ++ ] ++ }; ++ ++ const actual = getValue(source, "foo[].baz[].fog.baz"); ++ ++ assert.deepStrictEqual(actual, [["bar", "const"]]); ++}); ++ ++test("selects an indexed value from a property array", () => { ++ ++ ++ const source = { foo: { baz: ["bar", "foo"] } }; ++ ++ const actual = getValue(source, "foo.baz[1]"); ++ ++ assert.strictEqual(actual, "foo"); ++}); ++ ++test("projects a property from every object in a property array", () => { ++ ++ ++ const source = { foo: { baz: [{ fog: "bar" }] } }; ++ ++ const actual = getValue(source, "foo.baz[].fog"); ++ ++ assert.deepStrictEqual(actual, ["bar"]); ++}); ++ ++test("returns undefined when a path cannot be resolved", () => { ++ ++ ++ const source = { foo: {} }; ++ ++ const actual = getValue(source, "fish[0].b"); ++ ++ assert.strictEqual(actual, undefined); ++}); ++ ++test("returns undefined when every projected value is undefined", () => { ++ ++ ++ const source = { foo: { baz: [{}, {}] } }; ++ ++ const actual = getValue(source, "foo.baz[].fog"); ++ ++ assert.strictEqual(actual, undefined); ++}); ++ ++test("returns undefined when every projected value is null", () => { ++ ++ ++ const source = { foo: { baz: [{ fog: null }, { fog: null }] } }; ++ ++ const actual = getValue(source, "foo.baz[].fog"); ++ ++ assert.strictEqual(actual, undefined); ++}); ++ ++test("keeps projection slots when at least one projected value is meaningful", () => { ++ ++ ++ const source = { foo: { baz: [{ fog: null }, { fog: "ok" }, {}] } }; ++ ++ const actual = getValue(source, "foo.baz[].fog"); ++ ++ ++ assert.ok(Array.isArray(actual)); ++ assert.strictEqual(actual.length, 3); ++ assert.ok(actual[0] === null || actual[0] === undefined); ++ assert.strictEqual(actual[1], "ok"); ++ assert.ok(actual[2] === null || actual[2] === undefined); ++}); ++ ++test("mapper source paths use the same extraction behavior before writing the destination", () => { ++ ++ ++ const mapper = createMapper(); ++ mapper ++ .map("foo.bar").to("read.dot") ++ .map("foo.baz[1]").to("read.second") ++ .map("foo.items[].fog").to("read.fogs"); ++ ++ const source = { ++ foo: { ++ bar: "baz", ++ baz: ["bar", "foo"], ++ items: [{ fog: "bar" }, { fog: "const" }] ++ } ++ }; ++ ++ const actual = mapper.execute(source); ++ ++ assert.deepStrictEqual(actual, { read: { dot: "baz", second: "foo", fogs: ["bar", "const"] } }); ++}); ++ ++test("raises TypeError for a non-string path", () => { ++ const source = { foo: "bar" }; ++ ++ assert.throws(() => getValue(source, 3), TypeError); ++}); ++ ++test("returns the same value for repeated calls with the same inputs", () => { ++ const source = { ++ foo: [ ++ { ++ baz: [ ++ { fog: { baz: "bar" } }, ++ { fog: { baz: "const" } } ++ ] ++ } ++ ] ++ }; ++ ++ assert.deepStrictEqual( ++ getValue(source, "foo[].baz[].fog.baz"), ++ getValue(source, "foo[].baz[].fog.baz") ++ ); ++}); ++ ++test("does not modify fromObject", () => { ++ const source = { ++ foo: [ ++ { ++ baz: [ ++ { fog: { baz: "bar" } }, ++ { fog: { baz: "const" } } ++ ] ++ } ++ ], ++ untouched: { keep: ["alpha", "beta"] } ++ }; ++ const before = clone(source); ++ ++ const actual = getValue(source, "foo[].baz[].fog.baz"); ++ ++ assert.deepStrictEqual(actual, [["bar", "const"]]); ++ assert.deepStrictEqual(source, before); ++}); ++ ++test("matches a fresh-process result for the same input", () => { ++ const source = { ++ foo: [ ++ { ++ baz: [ ++ { fog: { baz: "bar" } }, ++ { fog: { baz: "const" } } ++ ] ++ } ++ ] ++ }; ++ const inProcess = getValue(source, "foo[].baz[].fog.baz"); ++ const script = ` ++ const createMapper = require("/workspace/repo/dist/lib/index.js"); ++ const source = { foo: [{ baz: [{ fog: { baz: "bar" } }, { fog: { baz: "const" } }] }] }; ++ process.stdout.write(JSON.stringify(createMapper.getValue(source, "foo[].baz[].fog.baz"))); ++ `; ++ ++ const freshProcess = JSON.parse(childProcess.execFileSync(process.execPath, ["-e", script], { encoding: "utf8" })); ++ ++ assert.deepStrictEqual(freshProcess, inProcess); ++ assert.deepStrictEqual(freshProcess, [["bar", "const"]]); ++}); ++ ++test("does not perform undeclared filesystem, network, or global writes", () => { ++ const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "map-factory-getvalue-")); ++ const originalCwd = process.cwd(); ++ const globalKeysBefore = Object.keys(globalThis).sort(); ++ const hadFetch = Object.prototype.hasOwnProperty.call(globalThis, "fetch"); ++ const originalFetch = globalThis.fetch; ++ const originals = { ++ appendFile: fs.appendFile, ++ appendFileSync: fs.appendFileSync, ++ createWriteStream: fs.createWriteStream, ++ mkdir: fs.mkdir, ++ mkdirSync: fs.mkdirSync, ++ open: fs.open, ++ openSync: fs.openSync, ++ writeFile: fs.writeFile, ++ writeFileSync: fs.writeFileSync, ++ promisesWriteFile: fs.promises.writeFile, ++ httpGet: http.get, ++ httpRequest: http.request, ++ httpsGet: https.get, ++ httpsRequest: https.request, ++ netConnect: net.connect, ++ netSocketConnect: net.Socket.prototype.connect, ++ tlsConnect: tls.connect ++ }; ++ const fail = () => { ++ throw new Error("getValue attempted undeclared IO"); ++ }; ++ const isWriteFlag = flags => { ++ if (typeof flags === "number") { ++ return Boolean(flags & (fs.constants.O_WRONLY | fs.constants.O_RDWR | fs.constants.O_APPEND | fs.constants.O_CREAT | fs.constants.O_TRUNC)); ++ } ++ return typeof flags === "string" && /[wa+]/.test(flags); ++ }; ++ ++ try { ++ process.chdir(tmp); ++ const beforeTree = listTree(tmp); ++ fs.appendFile = fail; ++ fs.appendFileSync = fail; ++ fs.createWriteStream = fail; ++ fs.mkdir = fail; ++ fs.mkdirSync = fail; ++ fs.writeFile = fail; ++ fs.writeFileSync = fail; ++ fs.promises.writeFile = fail; ++ fs.open = (file, flags, ...rest) => isWriteFlag(flags) ? fail() : originals.open.call(fs, file, flags, ...rest); ++ fs.openSync = (file, flags, ...rest) => isWriteFlag(flags) ? fail() : originals.openSync.call(fs, file, flags, ...rest); ++ http.get = fail; ++ http.request = fail; ++ https.get = fail; ++ https.request = fail; ++ net.connect = fail; ++ net.Socket.prototype.connect = fail; ++ tls.connect = fail; ++ globalThis.fetch = fail; ++ ++ const actual = getValue({ foo: { bar: "baz" } }, "foo.bar"); ++ ++ assert.strictEqual(actual, "baz"); ++ assert.deepStrictEqual(listTree(tmp), beforeTree); ++ assert.deepStrictEqual(Object.keys(globalThis).sort(), globalKeysBefore); ++ } finally { ++ fs.appendFile = originals.appendFile; ++ fs.appendFileSync = originals.appendFileSync; ++ fs.createWriteStream = originals.createWriteStream; ++ fs.mkdir = originals.mkdir; ++ fs.mkdirSync = originals.mkdirSync; ++ fs.open = originals.open; ++ fs.openSync = originals.openSync; ++ fs.writeFile = originals.writeFile; ++ fs.writeFileSync = originals.writeFileSync; ++ fs.promises.writeFile = originals.promisesWriteFile; ++ http.get = originals.httpGet; ++ http.request = originals.httpRequest; ++ https.get = originals.httpsGet; ++ https.request = originals.httpsRequest; ++ net.connect = originals.netConnect; ++ net.Socket.prototype.connect = originals.netSocketConnect; ++ tls.connect = originals.tlsConnect; ++ if (hadFetch) { ++ globalThis.fetch = originalFetch; ++ } else { ++ delete globalThis.fetch; ++ } ++ process.chdir(originalCwd); ++ fs.rmSync(tmp, { recursive: true, force: true }); ++ } ++}); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,20 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo ++export PATH="/workspace/repo/node_modules/.bin:${PATH}" ++test -x /workspace/repo/node_modules/.bin/rimraf ++test -x /workspace/repo/node_modules/.bin/babel ++/workspace/repo/node_modules/.bin/rimraf dist/* ++/workspace/repo/node_modules/.bin/babel ./src -d dist >/dev/null 2>&1 ++cp ./src/lib/*.d.ts ./dist/lib/ ++exec node --test /workspace/repo/usercase-test-coderl/get-value.test.js diff --git a/tasks/format-code-task-001919/tests/test.sh b/tasks/format-code-task-001919/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..9f5edd0d402dc334adabc036c9d2cd2698efbf2d --- /dev/null +++ b/tasks/format-code-task-001919/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/get-value.test.js +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001919/tests/test_command.sh b/tasks/format-code-task-001919/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001919/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001926/environment/Dockerfile b/tasks/format-code-task-001926/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..623e9ebdbd10e4f708a7140aa611bfc43bcecba7 --- /dev/null +++ b/tasks/format-code-task-001926/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:a22716610fa56066ef0823eb7b43cbe7093d23f757a87bca44a0761e1b770945 diff --git a/tasks/format-code-task-001926/environment/setup/files/blocklist b/tasks/format-code-task-001926/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001926/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001926/environment/setup/setup.sh b/tasks/format-code-task-001926/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001926/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001926/tests/test.patch b/tasks/format-code-task-001926/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..6f1bcec4d20fb6495de3b99ce03690b07a81150b --- /dev/null +++ b/tasks/format-code-task-001926/tests/test.patch @@ -0,0 +1,257 @@ +diff --git a/usercase-test-coderl/test_cell_count_density.py b/usercase-test-coderl/test_cell_count_density.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_cell_count_density.py +@@ -0,0 +1,230 @@ ++ ++ ++ ++import json ++import subprocess ++import sys ++ ++import numpy as np ++import pytest ++ ++from mrinufft.density import cell_count, get_density ++ ++ ++def assert_weights(actual, expected): ++ ++ assert isinstance(actual, np.ndarray) ++ assert actual.shape == (len(expected),) ++ ++ np.testing.assert_allclose(actual, expected, rtol=1e-12, atol=1e-12) ++ ++ ++def test_two_2d_points_in_same_grid_cell_get_equal_half_weights(): ++ ++ ++ ++ ++ traj = np.array([[0.0, 0.0], [0.25, 0.25]]) ++ ++ actual = cell_count(traj, (2, 2), osf=1.0) ++ ++ assert_weights(actual, [0.5, 0.5]) ++ ++ ++def test_isolated_2d_point_gets_twice_duplicate_cell_weight(): ++ ++ ++ ++ ++ traj = np.array([[-0.25, -0.25], [0.25, 0.25], [0.25, 0.25]]) ++ ++ actual = cell_count(traj, (2, 2), osf=1.0) ++ ++ assert_weights(actual, [0.5, 0.25, 0.25]) ++ ++ ++def test_each_2d_point_in_distinct_cell_gets_uniform_quarter_weight(): ++ ++ ++ ++ ++ traj = np.array( ++ [[-0.25, -0.25], [-0.25, 0.25], [0.25, -0.25], [0.25, 0.25]] ++ ) ++ ++ actual = cell_count(traj, (2, 2), osf=1.0) ++ ++ assert_weights(actual, [0.25, 0.25, 0.25, 0.25]) ++ ++ ++def test_fractional_oversampling_uses_int_scaled_bin_count(): ++ ++ ++ ++ ++ traj = np.array([[-0.25, -0.25], [-0.1, -0.1], [0.1, 0.1], [0.25, 0.25]]) ++ ++ actual = cell_count(traj, (2, 2), osf=1.5) ++ ++ assert_weights( ++ actual, ++ [0.3333333333333333, 0.16666666666666666, 0.16666666666666666, 0.3333333333333333], ++ ) ++ ++ ++def test_leading_dimensions_are_flattened_before_cell_counting(): ++ ++ ++ ++ ++ traj = np.array( ++ [ ++ [[-0.25, -0.25], [0.25, 0.25]], ++ [[0.25, 0.25], [-0.25, 0.25]], ++ ] ++ ) ++ ++ actual = cell_count(traj, (2, 2), osf=1.0) ++ ++ assert_weights( ++ actual, ++ [0.3333333333333333, 0.16666666666666666, 0.16666666666666666, 0.3333333333333333], ++ ) ++ ++ ++def test_3d_coordinates_are_counted_against_3d_shape(): ++ ++ ++ ++ ++ traj = np.array( ++ [ ++ [-0.25, -0.25, -0.25], ++ [0.25, 0.25, 0.25], ++ [0.25, 0.25, 0.25], ++ [-0.25, 0.25, 0.25], ++ ] ++ ) ++ ++ actual = cell_count(traj, (2, 2, 2), osf=1.0) ++ ++ assert_weights( ++ actual, ++ [0.3333333333333333, 0.16666666666666666, 0.16666666666666666, 0.3333333333333333], ++ ) ++ ++ ++def test_lower_unit_kspace_boundary_is_included_in_counting(): ++ ++ ++ ++ ++ traj = np.array([[-0.5, -0.5], [-0.25, -0.25], [0.25, 0.25]]) ++ ++ actual = cell_count(traj, (2, 2), osf=1.0) ++ ++ assert_weights(actual, [0.25, 0.25, 0.5]) ++ ++ ++def test_get_density_resolves_cell_count_estimator(): ++ ++ ++ ++ ++ actual = get_density("cell_count") ++ ++ ++ assert callable(actual) ++ traj = np.array([[0.0, 0.0], [0.25, 0.25]]) ++ assert_weights(actual(traj, (2, 2), osf=1.0), cell_count(traj, (2, 2), osf=1.0)) ++ ++ ++def test_get_density_direct_call_forwards_arguments_to_cell_count(): ++ ++ ++ ++ ++ traj = np.array([[0.0, 0.0], [0.25, 0.25]]) ++ ++ actual = get_density("cell_count", traj, (2, 2), osf=2.0) ++ ++ assert_weights(actual, [0.5, 0.5]) ++ ++ ++def test_shape_dimension_mismatch_raises_value_error(): ++ ++ ++ ++ ++ traj = np.array([[0.0, 0.0], [0.25, 0.25]]) ++ ++ ++ with pytest.raises(ValueError): ++ cell_count(traj, (2, 2, 2), osf=1.0) ++ ++ ++def test_referential_transparency_same_input_returns_equal_array(): ++ traj = np.array([[-0.25, -0.25], [0.25, 0.25], [0.25, 0.25]]) ++ ++ first = cell_count(traj, (2, 2), osf=1.0) ++ second = cell_count(traj, (2, 2), osf=1.0) ++ ++ ++ np.testing.assert_allclose(first, second, rtol=1e-12, atol=1e-12) ++ assert_weights(first, [0.5, 0.25, 0.25]) ++ ++ ++def test_cell_count_does_not_mutate_traj(): ++ traj = np.array( ++ [ ++ [[-0.25, -0.25], [0.25, 0.25]], ++ [[0.25, 0.25], [-0.25, 0.25]], ++ ] ++ ) ++ original = traj.copy() ++ ++ actual = cell_count(traj, (2, 2), osf=1.0) ++ ++ assert_weights( ++ actual, ++ [0.3333333333333333, 0.16666666666666666, 0.16666666666666666, 0.3333333333333333], ++ ) ++ np.testing.assert_array_equal(traj, original) ++ ++ ++def test_cell_count_has_no_same_key_global_cache_state_across_processes(): ++ traj = np.array([[-0.25, -0.25], [-0.1, -0.1], [0.1, 0.1], [0.25, 0.25]]) ++ in_process = cell_count(traj, (2, 2), osf=1.5).tolist() ++ script = """ ++import json ++import numpy as np ++from mrinufft.density import cell_count ++traj = np.array([[-0.25, -0.25], [-0.1, -0.1], [0.1, 0.1], [0.25, 0.25]]) ++print(json.dumps(cell_count(traj, (2, 2), osf=1.5).tolist())) ++""" ++ ++ completed = subprocess.run( ++ [sys.executable, "-c", script], ++ check=True, ++ text=True, ++ stdout=subprocess.PIPE, ++ stderr=subprocess.PIPE, ++ ) ++ fresh_process = json.loads(completed.stdout) ++ ++ ++ assert_weights( ++ np.asarray(in_process), ++ [0.3333333333333333, 0.16666666666666666, 0.16666666666666666, 0.3333333333333333], ++ ) ++ np.testing.assert_allclose(fresh_process, in_process, rtol=1e-12, atol=1e-12) ++ ++ ++def test_cell_count_is_independent_of_current_working_directory(monkeypatch, tmp_path): ++ ++ monkeypatch.chdir(tmp_path) ++ traj = np.array([[-0.25, -0.25], [0.25, 0.25], [0.25, 0.25]]) ++ ++ actual = cell_count(traj, (2, 2), osf=1.0) ++ ++ assert_weights(actual, [0.5, 0.25, 0.25]) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,17 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++export PYTHONPATH="/workspace/repo/src${PYTHONPATH:+:${PYTHONPATH}}" ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++exec python -m pytest /workspace/repo/usercase-test-coderl/test_cell_count_density.py -v diff --git a/tasks/format-code-task-001926/tests/test.sh b/tasks/format-code-task-001926/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..2a5b934f55aaf81d024dfc86385853bffec3da57 --- /dev/null +++ b/tasks/format-code-task-001926/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/test_cell_count_density.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001926/tests/test_command.sh b/tasks/format-code-task-001926/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001926/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001943/environment/Dockerfile b/tasks/format-code-task-001943/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b4606020af13eaf26db6923b66dc69defc2ecd2c --- /dev/null +++ b/tasks/format-code-task-001943/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:1b40f9ab0d84a21d66d96232a4fea60a740ce170be521b0f8b6d318dec6d88f9 diff --git a/tasks/format-code-task-001943/environment/setup/files/blocklist b/tasks/format-code-task-001943/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001943/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001943/environment/setup/setup.sh b/tasks/format-code-task-001943/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001943/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001943/tests/test.patch b/tasks/format-code-task-001943/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..6f07e57a02522350f6ca73d0f8557eb975d1799b --- /dev/null +++ b/tasks/format-code-task-001943/tests/test.patch @@ -0,0 +1,123 @@ +diff --git a/mne_bids/tests/test_path.py b/mne_bids/tests/test_path.py +index bcf42f68..b82e96a3 100644 +--- a/mne_bids/tests/test_path.py ++++ b/mne_bids/tests/test_path.py +@@ -1491,3 +1491,96 @@ def test_dont_create_dirs_on_fpath_access(tmp_path): + bp = BIDSPath(subject="01", datatype="eeg", root=tmp_path) + bp.fpath # accessing .fpath is required for this regression test + assert not (tmp_path / "sub-01").exists() ++ ++ ++def test_bidspath_basename_uses_recording_long_form(): ++ """BIDSPath.basename uses BIDS-spec 'recording-' (not 'rec-').""" ++ bp = BIDSPath(subject="01", recording="seven", suffix="physio", check=False) ++ assert "_recording-seven" in bp.basename ++ assert "_rec-seven" not in bp.basename ++ assert bp.basename == "sub-01_recording-seven_physio" ++ ++ ++def test_bidspath_basename_full_entities_recording_long_form(): ++ """Full-entities BIDSPath basename uses 'recording-' (not 'rec-').""" ++ bp = BIDSPath( ++ subject="one", ++ session="two", ++ task="three", ++ acquisition="four", ++ run=1, ++ processing="six", ++ recording="seven", ++ suffix="ieeg", ++ extension=".json", ++ datatype="ieeg", ++ ) ++ expected = ( ++ "sub-one_ses-two_task-three_acq-four_run-1_proc-six_" ++ "recording-seven_ieeg.json" ++ ) ++ assert bp.basename == expected ++ ++ ++def test_allowed_path_entities_short_uses_recording_key(): ++ """ALLOWED_PATH_ENTITIES_SHORT maps 'recording' -> 'recording', no 'rec'.""" ++ assert "rec" not in ALLOWED_PATH_ENTITIES_SHORT ++ assert ALLOWED_PATH_ENTITIES_SHORT["recording"] == "recording" ++ ++ ++def test_get_entities_from_fname_parses_recording_entity(): ++ """get_entities_from_fname parses '_recording-A_' filenames.""" ++ fname = "sub-01_recording-A_physio.tsv" ++ entities = get_entities_from_fname(fname) ++ assert entities["recording"] == "A" ++ assert entities["subject"] == "01" ++ ++ ++def test_get_entities_from_fname_rejects_legacy_rec_entity(): ++ """get_entities_from_fname raises KeyError on legacy '_rec-' filenames.""" ++ fname = "sub-01_rec-A_physio.tsv" ++ with pytest.raises(KeyError, match="Unexpected entity"): ++ get_entities_from_fname(fname, on_error="raise") ++ ++ ++def test_find_matching_paths_filters_by_recording(tmp_path): ++ """find_matching_paths(recordings=...) filters files named with 'recording-'.""" ++ eeg_dir = tmp_path / "sub-01" / "eeg" ++ eeg_dir.mkdir(parents=True) ++ file_a = eeg_dir / "sub-01_recording-A_physio.tsv" ++ file_b = eeg_dir / "sub-01_recording-B_physio.tsv" ++ file_a.touch() ++ file_b.touch() ++ ++ ++ all_paths = find_matching_paths(tmp_path) ++ names_all = sorted(p.fpath.name for p in all_paths) ++ assert names_all == [ ++ "sub-01_recording-A_physio.tsv", ++ "sub-01_recording-B_physio.tsv", ++ ] ++ ++ ++ found = find_matching_paths(tmp_path, recordings="A") ++ found_names = [p.fpath.name for p in found] ++ assert found_names == ["sub-01_recording-A_physio.tsv"] ++ ++ ++ found_b = find_matching_paths(tmp_path, recordings="B") ++ found_b_names = [p.fpath.name for p in found_b] ++ assert found_b_names == ["sub-01_recording-B_physio.tsv"] ++ ++ ++def test_find_matching_paths_recording_list_filter(tmp_path): ++ """find_matching_paths(recordings=[...]) accepts list and filters correctly.""" ++ eeg_dir = tmp_path / "sub-01" / "eeg" ++ eeg_dir.mkdir(parents=True) ++ for rec in ("A", "B", "C"): ++ (eeg_dir / f"sub-01_recording-{rec}_physio.tsv").touch() ++ ++ found = find_matching_paths(tmp_path, recordings=["A", "C"]) ++ names = sorted(p.fpath.name for p in found) ++ assert names == [ ++ "sub-01_recording-A_physio.tsv", ++ "sub-01_recording-C_physio.tsv", ++ ] +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..28c45c2e +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest mne_bids/tests/test_path.py -k \"test_bidspath_basename_uses_recording_long_form or test_bidspath_basename_full_entities_recording_long_form or test_allowed_path_entities_short_uses_recording_key or test_get_entities_from_fname_parses_recording_entity or test_get_entities_from_fname_rejects_legacy_rec_entity or test_find_matching_paths_filters_by_recording or test_find_matching_paths_recording_list_filter\" -v"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m pytest -v -rA mne_bids/tests/test_path.py::test_bidspath_basename_uses_recording_long_form mne_bids/tests/test_path.py::test_bidspath_basename_full_entities_recording_long_form mne_bids/tests/test_path.py::test_allowed_path_entities_short_uses_recording_key mne_bids/tests/test_path.py::test_get_entities_from_fname_parses_recording_entity mne_bids/tests/test_path.py::test_get_entities_from_fname_rejects_legacy_rec_entity mne_bids/tests/test_path.py::test_find_matching_paths_filters_by_recording mne_bids/tests/test_path.py::test_find_matching_paths_recording_list_filter ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001943/tests/test.sh b/tasks/format-code-task-001943/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..96821db4387d80be21060837e164cfd5923d81f1 --- /dev/null +++ b/tasks/format-code-task-001943/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +mne_bids/tests/test_path.py +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001943/tests/test_command.sh b/tasks/format-code-task-001943/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001943/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001944/environment/Dockerfile b/tasks/format-code-task-001944/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..16fdf0b998f4126897af4c99cfed490f020ea216 --- /dev/null +++ b/tasks/format-code-task-001944/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:06c3f789c1789235d920c0297c1d175ad0b6ef52f476a7e966b643d64e5df9c1 diff --git a/tasks/format-code-task-001944/environment/setup/files/blocklist b/tasks/format-code-task-001944/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001944/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001944/environment/setup/setup.sh b/tasks/format-code-task-001944/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001944/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001944/tests/test.patch b/tasks/format-code-task-001944/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..7efc5fbd0c8190ceb00d85afb50c8a227acdbe44 --- /dev/null +++ b/tasks/format-code-task-001944/tests/test.patch @@ -0,0 +1,108 @@ +diff --git a/mne_bids/tests/test_read.py b/mne_bids/tests/test_read.py +index 01ab0336..3bcbe703 100644 +--- a/mne_bids/tests/test_read.py ++++ b/mne_bids/tests/test_read.py +@@ -294,6 +294,81 @@ def test_handle_events_reading(): + assert ids == ['n/a'] + + ++def test_handle_events_reading_hierarchical_from_issue(): ++ """Reproduce the issue: ambiguous trial_type/value yields hierarchy.""" ++ raw = _read_raw_fif(raw_fname) ++ events = { ++ 'onset': [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0], ++ 'duration': [0.0] * 8, ++ 'trial_type': ['response', 'response', 'stimulus', 'response', ++ 'stimulus', 'response', 'stimulus', 'response'], ++ 'value': ['202', '202', '11', '201', '12', '201', '14', '201'], ++ } ++ tmp_dir = _TempDir() ++ events_fname = op.join(tmp_dir, 'sub-01_task-test_events.tsv') ++ _to_tsv(events, events_fname) ++ ++ raw = _handle_events_reading(events_fname, raw) ++ descriptions = set(raw.annotations.description) ++ assert descriptions == {'response/201', 'response/202', ++ 'stimulus/11', 'stimulus/12', 'stimulus/14'} ++ ++ ++def test_handle_events_reading_unique_mapping_keeps_plain(): ++ """1:1 trial_type<>value mapping must keep plain trial_type names.""" ++ raw = _read_raw_fif(raw_fname) ++ ++ events = { ++ 'onset': [1.0, 2.0, 3.0, 4.0], ++ 'duration': [0.0] * 4, ++ 'trial_type': ['response', 'response', 'stimulus', 'stimulus'], ++ 'value': ['201', '201', '11', '11'], ++ } ++ tmp_dir = _TempDir() ++ events_fname = op.join(tmp_dir, 'sub-01_task-test_events.tsv') ++ _to_tsv(events, events_fname) ++ ++ raw = _handle_events_reading(events_fname, raw) ++ descriptions = set(raw.annotations.description) ++ assert descriptions == {'response', 'stimulus'} ++ ++ ++def test_handle_events_reading_mixed_only_ambiguous_hierarchical(): ++ """Only ambiguous trial_types should get hierarchical names.""" ++ raw = _read_raw_fif(raw_fname) ++ ++ events = { ++ 'onset': [1.0, 2.0, 3.0, 4.0, 5.0], ++ 'duration': [0.0] * 5, ++ 'trial_type': ['response', 'response', 'cue', 'cue', 'response'], ++ 'value': ['201', '202', '5', '5', '201'], ++ } ++ tmp_dir = _TempDir() ++ events_fname = op.join(tmp_dir, 'sub-01_task-test_events.tsv') ++ _to_tsv(events, events_fname) ++ ++ raw = _handle_events_reading(events_fname, raw) ++ descriptions = set(raw.annotations.description) ++ assert descriptions == {'response/201', 'response/202', 'cue'} ++ ++ ++def test_handle_events_reading_no_value_column_uses_trial_type(): ++ """When no value column exists, plain trial_type is used (preservation).""" ++ raw = _read_raw_fif(raw_fname) ++ events = { ++ 'onset': [1.0, 2.0, 3.0], ++ 'duration': [0.0] * 3, ++ 'trial_type': ['response', 'response', 'stimulus'], ++ } ++ tmp_dir = _TempDir() ++ events_fname = op.join(tmp_dir, 'sub-01_task-test_events.tsv') ++ _to_tsv(events, events_fname) ++ ++ raw = _handle_events_reading(events_fname, raw) ++ descriptions = set(raw.annotations.description) ++ assert descriptions == {'response', 'stimulus'} ++ ++ + @pytest.mark.filterwarnings(warning_str['channel_unit_changed']) + def test_handle_scans_reading(): + """Test reading data from a BIDS scans.tsv file.""" +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..ee408bda +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest mne_bids/tests/test_read.py -v -k \"test_handle_events_reading_hierarchical_from_issue or test_handle_events_reading_unique_mapping_keeps_plain or test_handle_events_reading_mixed_only_ambiguous_hierarchical or test_handle_events_reading_no_value_column_uses_trial_type\""] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m pytest -v -rA mne_bids/tests/test_read.py::test_handle_events_reading_hierarchical_from_issue mne_bids/tests/test_read.py::test_handle_events_reading_unique_mapping_keeps_plain mne_bids/tests/test_read.py::test_handle_events_reading_mixed_only_ambiguous_hierarchical mne_bids/tests/test_read.py::test_handle_events_reading_no_value_column_uses_trial_type ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001944/tests/test.sh b/tasks/format-code-task-001944/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..17c64e12347ad6c8edc54f8d1a8af686c850ec71 --- /dev/null +++ b/tasks/format-code-task-001944/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +mne_bids/tests/test_read.py +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001944/tests/test_command.sh b/tasks/format-code-task-001944/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001944/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001975/environment/Dockerfile b/tasks/format-code-task-001975/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7f238255af2addb8aad743d1ff67f4a205e6621d --- /dev/null +++ b/tasks/format-code-task-001975/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:7e2b4f226eedbef1e8bffe6b19718763133bb4f93e96e4260c0967f3190009cf diff --git a/tasks/format-code-task-001975/environment/setup/files/blocklist b/tasks/format-code-task-001975/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001975/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001975/environment/setup/setup.sh b/tasks/format-code-task-001975/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001975/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001975/tests/test.patch b/tasks/format-code-task-001975/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ee65d7f7dd2aa7a2b7d9615c19376c2ae2708256 --- /dev/null +++ b/tasks/format-code-task-001975/tests/test.patch @@ -0,0 +1,126 @@ +diff --git a/tests/test_amqp.py b/tests/test_amqp.py +index 064e07ca..3092bd43 100644 +--- a/tests/test_amqp.py ++++ b/tests/test_amqp.py +@@ -531,8 +531,8 @@ def test_ack_multiple(self): + exchange = yield from channel.declare_exchange('direct', auto_delete=True) + queue = yield from channel.declare_queue(queue_name, auto_delete=False) + +- with self.assertRaises(TimeoutError): +- yield from queue.get(timeout=1) ++ with self.assertRaises(aio_pika.exceptions.QueueEmpty): ++ yield from queue.get() + + yield from queue.unbind(exchange, routing_key) + yield from queue.delete() +@@ -1109,6 +1109,34 @@ def test_declaration_result_with_messages(self): + + yield from wait((client.close(), client.closing), loop=self.loop) + ++ @pytest.mark.asyncio ++ def test_queue_empty_exception(self): ++ ++ client = yield from connect(AMQP_URL, loop=self.loop) ++ queue_name = self.get_random_name("test_get_on_empty_queue") ++ channel = yield from client.channel() ++ queue = yield from channel.declare_queue(queue_name, auto_delete=True) ++ ++ with self.assertRaises(aio_pika.exceptions.QueueEmpty): ++ yield from queue.get(timeout=5) ++ ++ yield from queue.delete() ++ yield from wait((client.close(), client.closing), loop=self.loop) ++ ++ @pytest.mark.asyncio ++ def test_queue_empty_fail_false(self): ++ ++ client = yield from connect(AMQP_URL, loop=self.loop) ++ queue_name = self.get_random_name("test_get_on_empty_queue") ++ channel = yield from client.channel() ++ queue = yield from channel.declare_queue(queue_name, auto_delete=True) ++ ++ result = yield from queue.get(fail=False) ++ self.assertIsNone(result) ++ ++ yield from queue.delete() ++ yield from wait((client.close(), client.closing), loop=self.loop) ++ + + class MessageTestCase(unittest.TestCase): + def test_message_copy(self): +diff --git a/tests/test_amqp_robust.py b/tests/test_amqp_robust.py +index c79454c1..02293d53 100644 +--- a/tests/test_amqp_robust.py ++++ b/tests/test_amqp_robust.py +@@ -543,8 +543,8 @@ def test_ack_multiple(self): + exchange = yield from channel.declare_exchange('direct', auto_delete=True) + queue = yield from channel.declare_queue(queue_name, auto_delete=False) + +- with self.assertRaises(TimeoutError): +- yield from queue.get(timeout=1) ++ with self.assertRaises(aio_pika.exceptions.QueueEmpty): ++ yield from queue.get() + + yield from queue.unbind(exchange, routing_key) + yield from queue.delete() +@@ -1130,6 +1130,34 @@ def test_declaration_result_with_messages(self): + + yield from wait((client.close(), client.closing), loop=self.loop) + ++ @pytest.mark.asyncio ++ def test_queue_empty_exception(self): ++ ++ client = yield from connect_robust(AMQP_URL, loop=self.loop) ++ queue_name = self.get_random_name("test_get_on_empty_queue") ++ channel = yield from client.channel() ++ queue = yield from channel.declare_queue(queue_name, auto_delete=True) ++ ++ with self.assertRaises(aio_pika.exceptions.QueueEmpty): ++ yield from queue.get(timeout=5) ++ ++ yield from queue.delete() ++ yield from wait((client.close(), client.closing), loop=self.loop) ++ ++ @pytest.mark.asyncio ++ def test_queue_empty_fail_false(self): ++ ++ client = yield from connect_robust(AMQP_URL, loop=self.loop) ++ queue_name = self.get_random_name("test_get_on_empty_queue") ++ channel = yield from client.channel() ++ queue = yield from channel.declare_queue(queue_name, auto_delete=True) ++ ++ result = yield from queue.get(fail=False) ++ self.assertIsNone(result) ++ ++ yield from queue.delete() ++ yield from wait((client.close(), client.closing), loop=self.loop) ++ + + class MessageTestCase(unittest.TestCase): + def test_message_copy(self): +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,10 @@ ++H4sIAAAAAAAAA+2UUU/bMBDH+5xPcetQAYkkTdqkUyfQeEDiYdWAbc+Rk7ippcRObScD1n332Sms ++ULb1BbRNu9+D7fjOd3/77Hhpw8o8obz1ey/F0DCJoq43bPfdOIjCIJgMozgc9YZBEA9HPYheTNED ++GqWJBOhJIfTv/HbZ/1G8Tf01VTrJRFURnntq8Xw5dtQ/CCfBj/pHofELxnEY9GD4fBJ+zX9e/yyH ++rvApzR3nNZxx1UgKVyRNmZ5dAlMgG84ZL+AL0wtgPJOUKJpDRa6hokqRgoJit9Rhc3gFsltYLTNd ++gjlY3Sg48XPa+rwpSwhPBsFb0AvKHTDcO7uKypZKcHOqSbYwSqxVlZTWEDlzZoV9pPpJSjApudBA ++SqMpv4FM8DkrjP7ceaiDtqSEfVLXJcuIZoJPC6rtjT9Yex3ZwMld4MQGPvT2jdaN7hUU0mhxlxDG ++b8ajaBzFsFrB10e7+HkqtSPV0SakyfokoNKiTkw8GAy2z1Zqa3h0VN8ch17XQmo4nV1eJJ+v3h/3 ++SbWsp75fNKbI0659V4qMlAuhtN+/9784/XR+3N87/zA78736xv4OUsane3beONlt9fcOOoO5A0yD ++e9h31p9FKVJjHnmxF0SOEo3MKPii1t29ctu7WD7JNGuJpmaZXggObgVmZFzANmr9+7FqTf7tqUSK ++1DxUa3Hb7ho5f/rhIAiCIAiCIAiCIAiCIAiCIAiCIAiCIAiC/CV8ByPdBkcAKAAA +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-001975/tests/test.sh b/tasks/format-code-task-001975/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..cd099df80638ecbeb4800b7f9624a845af54439a --- /dev/null +++ b/tasks/format-code-task-001975/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/test_amqp.py +tests/test_amqp_robust.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001975/tests/test_command.sh b/tasks/format-code-task-001975/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001975/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001981/environment/Dockerfile b/tasks/format-code-task-001981/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d8988da549af8772185aaaaa52acf54d3d2546a5 --- /dev/null +++ b/tasks/format-code-task-001981/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:400313bbe17f33c07d7dbe190e22cfd7d0fc81dfa1637123c5e933b210c6e7dd diff --git a/tasks/format-code-task-001981/environment/setup/files/blocklist b/tasks/format-code-task-001981/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001981/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001981/environment/setup/setup.sh b/tasks/format-code-task-001981/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001981/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001981/tests/test.patch b/tasks/format-code-task-001981/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..1aa892bac599ea0cf849f0b49ca60f62d008653b --- /dev/null +++ b/tasks/format-code-task-001981/tests/test.patch @@ -0,0 +1,175 @@ +diff --git a/socorro/unittest/app/test_crontabber_launcher.py b/socorro/unittest/app/test_crontabber_launcher.py +new file mode 100644 +index 000000000..a46dbdcd4 +--- /dev/null ++++ b/socorro/unittest/app/test_crontabber_launcher.py +@@ -0,0 +1,21 @@ ++import os ++import subprocess ++ ++ ++ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..')) ++ ++ ++def test_socorro_launcher_supports_crontabber_help(): ++ process = subprocess.Popen( ++ ['./scripts/socorro', 'crontabber', '--help'], ++ cwd=ROOT, ++ stdout=subprocess.PIPE, ++ stderr=subprocess.PIPE, ++ ) ++ stdout, stderr = process.communicate() ++ output = (stdout + stderr).decode('utf-8', 'replace') ++ lowered = output.lower() ++ ++ assert process.returncode == 0, output ++ assert 'unknown' not in lowered and 'unsupported' not in lowered ++ assert 'crontabber' in lowered +diff --git a/socorro/unittest/cron/test_crontabber_jobs_values.py b/socorro/unittest/cron/test_crontabber_jobs_values.py +new file mode 100644 +index 000000000..72d7f786a +--- /dev/null ++++ b/socorro/unittest/cron/test_crontabber_jobs_values.py +@@ -0,0 +1,74 @@ ++import configman ++from crontabber.base import BaseCronApp ++ ++from socorro.cron.crontabber_app import CronTabberApp ++from socorro.cron.crontabber_app import DEFAULT_JOBS ++from socorro.cron.crontabber_app import STAGE_JOBS ++from socorro.cron.jobs.bugzilla import BugzillaCronApp ++from socorro.cron.jobs.fetch_adi_from_hive import FAKEFetchADIFromHiveCronApp ++ ++ ++class TestOwnedInlineCronApp(BaseCronApp): ++ def run(self): ++ pass ++ ++ ++class TestOwnedAlternateCronApp(BaseCronApp): ++ def run(self): ++ pass ++ ++ ++INLINE_TEST_JOBS = '%s.TestOwnedInlineCronApp|1h' % __name__ ++ALTERNATE_TEST_JOBS = '%s.TestOwnedAlternateCronApp|1h' % __name__ ++ ++ ++def configured_jobs_for(jobs_value): ++ config_manager = configman.ConfigurationManager( ++ [CronTabberApp.get_required_config()], ++ values_source_list=[{'crontabber.jobs': jobs_value}], ++ app_name='test-crontabber-jobs-values', ++ ) ++ with config_manager.context() as config: ++ return config.crontabber.jobs ++ ++ ++def configured_job_classes(jobs_value): ++ return set( ++ job_class ++ for job_name, job_class in configured_jobs_for(jobs_value).class_list ++ ) ++ ++ ++def test_crontabber_jobs_accepts_inline_spec(): ++ job_classes = configured_job_classes(INLINE_TEST_JOBS) ++ ++ assert TestOwnedInlineCronApp in job_classes ++ ++ ++def test_crontabber_jobs_accepts_default_jobs_value_path(): ++ job_classes = configured_job_classes('socorro.cron.crontabber_app.DEFAULT_JOBS') ++ ++ assert BugzillaCronApp in job_classes ++ ++ ++def test_crontabber_jobs_accepts_a_second_python_jobs_value_path(): ++ job_classes = configured_job_classes( ++ 'socorro.unittest.cron.test_crontabber_jobs_values.ALTERNATE_TEST_JOBS' ++ ) ++ ++ assert TestOwnedAlternateCronApp in job_classes ++ assert BugzillaCronApp not in job_classes ++ ++ ++def test_stage_jobs_value_contains_default_jobs_and_fake_hive_job(): ++ default_classes = configured_job_classes(DEFAULT_JOBS) ++ stage_classes = configured_job_classes(STAGE_JOBS) ++ ++ assert default_classes.issubset(stage_classes) ++ assert FAKEFetchADIFromHiveCronApp in stage_classes ++ ++ ++def test_crontabber_jobs_accepts_stage_jobs_value_path(): ++ job_classes = configured_job_classes('socorro.cron.crontabber_app.STAGE_JOBS') ++ ++ assert FAKEFetchADIFromHiveCronApp in job_classes +diff --git a/socorro/unittest/docker/test_crontabber_helpers.py b/socorro/unittest/docker/test_crontabber_helpers.py +new file mode 100644 +index 000000000..9fc09fee3 +--- /dev/null ++++ b/socorro/unittest/docker/test_crontabber_helpers.py +@@ -0,0 +1,27 @@ ++import os ++ ++ ++ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..')) ++ ++ ++def executable_text(path): ++ with open(os.path.join(ROOT, path)) as script: ++ lines = [ ++ line.strip() ++ for line in script ++ if line.strip() and not line.lstrip().startswith('#') ++ ] ++ return ' '.join(lines) ++ ++ ++def test_docker_crontabber_helpers_use_socorro_entrypoint(): ++ run_crontabber = executable_text('docker/run_crontabber.sh') ++ run_update_data = executable_text('docker/run_update_data.sh') ++ ++ assert './scripts/socorro crontabber' in run_crontabber ++ assert './scripts/socorro crontabber' in run_update_data ++ ++ combined = run_crontabber + ' ' + run_update_data ++ assert 'python socorro/cron/crontabber_app.py' not in combined ++ assert '--job=ftpscraper' in run_update_data ++ assert '--job=featured-versions-automatic' in run_update_data +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,30 @@ ++#!/bin/bash ++set -euo pipefail ++ ++cd /testbed ++find /testbed -name '*.pyc' -delete ++ ++ ++set +u ++export PATH="$HOME/.pyenv/bin:$PATH" ++eval "$(pyenv init -)" ++eval "$(pyenv virtualenv-init -)" ++pyenv activate socorro-env ++export PYTHONPATH=/testbed ++set -u ++ ++case "${1:-}" in ++ base) ++ python -m pytest -q socorro/unittest/app/test_for_application_defaults.py ++ ;; ++ new) ++ python -m pytest -q \ ++ socorro/unittest/app/test_crontabber_launcher.py \ ++ socorro/unittest/docker/test_crontabber_helpers.py \ ++ socorro/unittest/cron/test_crontabber_jobs_values.py ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-001981/tests/test.sh b/tasks/format-code-task-001981/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..741a77aa2aa09c7d52dd9403b37e603adf9370ca --- /dev/null +++ b/tasks/format-code-task-001981/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +socorro/unittest/app/test_crontabber_launcher.py +socorro/unittest/cron/test_crontabber_jobs_values.py +socorro/unittest/docker/test_crontabber_helpers.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001981/tests/test_command.sh b/tasks/format-code-task-001981/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-001981/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh base && bash /testbed/mimo_test_command.sh new \ No newline at end of file diff --git a/tasks/format-code-task-001986/environment/Dockerfile b/tasks/format-code-task-001986/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7f3c5ede319d112a3e29bfe5ea2ce90facd43a3b --- /dev/null +++ b/tasks/format-code-task-001986/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:240841d86785c829f9fd894d64b7ce993e97cf599b4536cd48f227a3ae7aa3dc diff --git a/tasks/format-code-task-001986/environment/setup/files/blocklist b/tasks/format-code-task-001986/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001986/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001986/environment/setup/setup.sh b/tasks/format-code-task-001986/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001986/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001986/tests/test.patch b/tasks/format-code-task-001986/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..356ddb2b8be02ada1247e1d09dd86e5eb97c39d4 --- /dev/null +++ b/tasks/format-code-task-001986/tests/test.patch @@ -0,0 +1,101 @@ +diff --git a/http_service/tests/fixtures/hgmo_try/bad123.json b/http_service/tests/fixtures/hgmo_try/bad123.json +index d985e67952..981362bbc8 100644 +--- a/http_service/tests/fixtures/hgmo_try/bad123.json ++++ b/http_service/tests/fixtures/hgmo_try/bad123.json +@@ -4,7 +4,8 @@ + "node": "bad123", + "parents": [ + "BASE_HISTORY_2" +- ] ++ ], ++ "phase": "draft" + } + ], + "visible": true +diff --git a/http_service/tests/fixtures/hgmo_try/needRemote.json b/http_service/tests/fixtures/hgmo_try/needRemote.json +index f48e52a312..bb5938a4c5 100644 +--- a/http_service/tests/fixtures/hgmo_try/needRemote.json ++++ b/http_service/tests/fixtures/hgmo_try/needRemote.json +@@ -1,10 +1,18 @@ + { + "changesets": [ ++ { ++ "node": "aPublicParent", ++ "parents": [ ++ "REVISION_DOES_NOT_EXIST" ++ ], ++ "phase": "public" ++ }, + { + "node": "needRemote", + "parents": [ + "PULLED_FROM_REMOTE" +- ] ++ ], ++ "phase": "draft" + } + ], + "visible": true +diff --git a/http_service/tests/fixtures/hgmo_try/normal456.json b/http_service/tests/fixtures/hgmo_try/normal456.json +index 9a45082ffb..1248b736cc 100644 +--- a/http_service/tests/fixtures/hgmo_try/normal456.json ++++ b/http_service/tests/fixtures/hgmo_try/normal456.json +@@ -4,13 +4,15 @@ + "node": "localParent456", + "parents": [ + "BASE_HISTORY_1" +- ] ++ ], ++ "phase": "draft" + }, + { + "node": "normal456", + "parents": [ + "localParent456" +- ] ++ ], ++ "phase": "draft" + } + ], + "visible": true +diff --git a/http_service/tests/fixtures/hgmo_try/orphan456.json b/http_service/tests/fixtures/hgmo_try/orphan456.json +index 4774ab3c8b..d21b244cb3 100644 +--- a/http_service/tests/fixtures/hgmo_try/orphan456.json ++++ b/http_service/tests/fixtures/hgmo_try/orphan456.json +@@ -4,7 +4,8 @@ + "node": "orphan456", + "parents": [ + "REVISION_DOES_NOT_EXIST" +- ] ++ ], ++ "phase": "draft" + } + ], + "visible": true +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,11 @@ ++H4sIAAAAAAAAA+2V32+UQBDH75m/YoyJ9wQL3I8m2jYxxthH0/jWNJcF5mDtsuDuct4ljX+7C3eH ++2KC1Sasxnc8LZGe+M8PMAEHSCJmtUG3Y5KkIHSeLRXd13L1299EijuJwHp3MlpMwipZhPIHFk1U0 ++oDGWa4CJrir7O7/77P8pwY/5WzR2lVZlyVUWmOLxctwz/zgKl/38l3PnF82X0XwC4eOV8Gue+fzT ++DLrBJ5h53kt4r0yjEYochAG+4ULyRCJUCj6+/XThiTW8gMOKgL9p/V6dsww3TDVSvgFboPLAIRX4 ++Zt2HZsGm3bBEKOYkrDGaySrl8nDircUgudkZi6X/VWQIJeq00YJLl1WtRQ4FN20WSJocnFctuUXA ++rUVlRKXaAq9cib5LjTZlvdwl0Slcw+2ts+Yaa/C/wNQFOcaYjgri0YcrbzKhwa/vSDpbyi2cj8Y6 ++PYXpxYfLd1Pvqq/XXHvGalHDmTeoBc6GLZIiYfXOFpWaBVHMMmGsX/P0hudo2EAV1Duvjf9zM127 ++9xn6nNDObphtYHGCfuiDXn5jwWj/usjT3jzerX1Hjj5/uQuXjerWpd3DdnFcLbh1cxEGu/MiL6uV ++1TtYi61t+7UWEs1rpwQorK1XBvVGpNgtsmEHL8OOOpbwLIpnwWfjlu+PRQoxu8SycuU+UFjpksv5 ++YvlAXaXrgqteN/Ja7nsLfgnuzlnH4nY/CJMWmDUSV92Za7f7Dnj/+itGEARBEARBEARBEARBEARB ++EARBEARBEM+b73peUekAKAAA +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-001986/tests/test.sh b/tasks/format-code-task-001986/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..c996b9dbc74f9ac570f5560d8cbf395edf26f61e --- /dev/null +++ b/tasks/format-code-task-001986/tests/test.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +http_service/tests/fixtures/hgmo_try/bad123.json +http_service/tests/fixtures/hgmo_try/needRemote.json +http_service/tests/fixtures/hgmo_try/normal456.json +http_service/tests/fixtures/hgmo_try/orphan456.json +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001986/tests/test_command.sh b/tasks/format-code-task-001986/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001986/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001988/environment/Dockerfile b/tasks/format-code-task-001988/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..685b29e851e262ce5a0283556e78b7ca7f4d21a1 --- /dev/null +++ b/tasks/format-code-task-001988/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:a50e9ef85f70748fe365e862dd0d07da44b523e311bf5a3b34d6e52bf463eec4 diff --git a/tasks/format-code-task-001988/environment/setup/files/blocklist b/tasks/format-code-task-001988/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001988/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001988/environment/setup/setup.sh b/tasks/format-code-task-001988/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001988/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001988/tests/test.patch b/tasks/format-code-task-001988/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..fd0628ec3acf03eadc3aae9d34e2e071d67b0758 --- /dev/null +++ b/tasks/format-code-task-001988/tests/test.patch @@ -0,0 +1,70 @@ +diff --git a/tests/test_middleware.py b/tests/test_middleware.py +index 7af5a6cc..07e444f3 100644 +--- a/tests/test_middleware.py ++++ b/tests/test_middleware.py +@@ -1,4 +1,5 @@ + import json ++import re + import time + + try: +@@ -232,6 +233,37 @@ def test_get_exempt_urls_setting_url_path(self): + [u'/authenticate/', u'/callback/', u'/foo/', u'/logout/'] + ) + ++ def test_is_refreshable_url(self): ++ request = self.factory.get('/mdo_fake_view/') ++ request.user = self.user ++ request.session = dict() ++ middleware = SessionRefresh() ++ assert middleware.is_refreshable_url(request) ++ ++ @override_settings(OIDC_EXEMPT_URLS=['mdo_fake_view']) ++ def test_is_not_refreshable_url_exempt_view_name(self): ++ request = self.factory.get('/mdo_fake_view/') ++ request.user = self.user ++ request.session = dict() ++ middleware = SessionRefresh() ++ assert not middleware.is_refreshable_url(request) ++ ++ @override_settings(OIDC_EXEMPT_URLS=['/mdo_fake_view/']) ++ def test_is_not_refreshable_url_exempt_path(self): ++ request = self.factory.get('/mdo_fake_view/') ++ request.user = self.user ++ request.session = dict() ++ middleware = SessionRefresh() ++ assert not middleware.is_refreshable_url(request) ++ ++ @override_settings(OIDC_EXEMPT_URLS=[re.compile(r'^/mdo_.*_view/$')]) ++ def test_is_not_refreshable_url_exempt_pattern(self): ++ request = self.factory.get('/mdo_fake_view/') ++ request.user = self.user ++ request.session = dict() ++ middleware = SessionRefresh() ++ assert not middleware.is_refreshable_url(request) ++ + def test_anonymous(self): + client = ClientWithUser() + resp = client.get('/mdo_fake_view/') +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,6 @@ ++H4sIAAAAAAAAA+3SQU+DMBgGYM78ihrPA4rrOO2wZMumUbZkePBECm0GZtCFFtR/L2A2jYnuskWN ++73Npab+mDe/nJHW+FbEsG9c6F68VMNaPrc9jP6fMp74XUI+165SywLcIO9uLPqi14RUhVqWU+a7u ++2P4f5bznb6Q2caqKgpfC0dnp7jiWvz+62ufvBUPa5j8cUWYR73RP+No/z//ywk3y0k24zuxUkL4J ++EilsreoqlYdv12m6FulKeWryhhtpy+edqgyZ3kzC+TJez6LoOpyv47vl9P52Nu4OakdLY/Jyo/fF ++q4dosQxXk2gxPly1ezGZKsmgIOKRlxtFug3ydr7vySIXYiufeCXJoPHtn/5lAAAAAAAAAAAAAAAA ++AAAAAAC/xisyz4nMACgAAA== +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-001988/tests/test.sh b/tasks/format-code-task-001988/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..4465366875ce17eb3e37c087ff9df7ffb3ae9129 --- /dev/null +++ b/tasks/format-code-task-001988/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/test_middleware.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001988/tests/test_command.sh b/tasks/format-code-task-001988/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001988/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002012/environment/Dockerfile b/tasks/format-code-task-002012/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..73d0b2614e4c89694de6f0bec03e7f48762c232a --- /dev/null +++ b/tasks/format-code-task-002012/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:80f380a8f69d7abe877000ef99191eb2cafbe22a24d54c9b2705bfcb3a7816b0 diff --git a/tasks/format-code-task-002012/environment/setup/files/blocklist b/tasks/format-code-task-002012/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002012/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002012/environment/setup/setup.sh b/tasks/format-code-task-002012/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002012/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002012/tests/test.patch b/tasks/format-code-task-002012/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e43c59fb9cdc7c40865a144222797002a2ee15a2 --- /dev/null +++ b/tasks/format-code-task-002012/tests/test.patch @@ -0,0 +1,204 @@ +diff --git a/test/test_proxy.py b/test/test_proxy.py +new file mode 100644 +index 0000000..6943924 +--- /dev/null ++++ b/test/test_proxy.py +@@ -0,0 +1,163 @@ ++from mock import Mock, patch ++import pytest ++ ++from nameko import proxy ++from nameko.testing.proxy import MockRPCProxy ++ ++ ++def _context_factory(): ++ context = Mock() ++ return lambda: context ++ ++ ++@patch.object(proxy, 'rpc') ++def test_reset_restores_initial_fallback_false(rpc): ++ rpcproxy = MockRPCProxy( ++ context_factory=_context_factory(), fallback_to_call=False) ++ rpcproxy.fallback_to_call = True ++ ++ rpcproxy.reset() ++ ++ assert rpcproxy.fallback_to_call is False ++ with pytest.raises(RuntimeError): ++ rpcproxy.reset_service.reset_method() ++ assert rpc.call.call_count == 0 ++ ++ ++@patch.object(proxy, 'rpc') ++def test_reset_restores_initial_fallback_true(rpc): ++ rpcproxy = MockRPCProxy( ++ context_factory=_context_factory(), fallback_to_call=True) ++ rpcproxy.fallback_to_call = False ++ ++ rpcproxy.reset() ++ ++ assert rpcproxy.fallback_to_call is True ++ rpcproxy.restored_service.restored_method() ++ assert rpc.call.call_count == 1 ++ assert rpc.call.call_args[0][2] == 'restored_service' ++ assert rpc.call.call_args[0][3]['method'] == 'restored_method' ++ ++ ++@patch.object(proxy, 'rpc') ++def test_attribute_service_proxy_respects_disabled_fallback(rpc): ++ rpcproxy = MockRPCProxy( ++ context_factory=_context_factory(), fallback_to_call=True) ++ rpcproxy.fallback_to_call = False ++ ++ with pytest.raises(RuntimeError): ++ rpcproxy(topic='direct_disabled', method='direct_method') ++ with pytest.raises(RuntimeError): ++ rpcproxy.attribute_disabled.attribute_method() ++ assert rpc.call.call_count == 0 ++ ++ ++@patch.object(proxy, 'rpc') ++def test_attribute_service_proxy_respects_enabled_fallback(rpc): ++ rpcproxy = MockRPCProxy( ++ context_factory=_context_factory(), fallback_to_call=False) ++ rpcproxy.fallback_to_call = True ++ ++ rpcproxy(topic='direct_enabled', method='direct_method', marker='one') ++ rpcproxy.attribute_enabled.attribute_method(marker='two') ++ ++ assert rpc.call.call_count == 2 ++ first_call = rpc.call.call_args_list[0][0] ++ second_call = rpc.call.call_args_list[1][0] ++ assert first_call[2] == 'direct_enabled' ++ assert first_call[3] == { ++ 'method': 'direct_method', ++ 'args': {'marker': 'one'}, ++ } ++ assert second_call[2] == 'attribute_enabled' ++ assert second_call[3] == { ++ 'method': 'attribute_method', ++ 'args': {'marker': 'two'}, ++ } ++ ++ ++@patch.object(proxy, 'rpc') ++def test_add_service_to_whitelist_allows_only_named_services(rpc): ++ rpcproxy = MockRPCProxy( ++ context_factory=_context_factory(), fallback_to_call=False) ++ ++ rpcproxy.add_service_to_whitelist('allowed_service') ++ rpcproxy.allowed_service.allowed_method(token='allowed') ++ ++ assert rpc.call.call_count == 1 ++ assert rpc.call.call_args[0][2] == 'allowed_service' ++ assert rpc.call.call_args[0][3] == { ++ 'method': 'allowed_method', ++ 'args': {'token': 'allowed'}, ++ } ++ ++ with pytest.raises(RuntimeError): ++ rpcproxy.blocked_service.blocked_method() ++ assert rpc.call.call_count == 1 ++ ++ ++@patch.object(proxy, 'rpc') ++def test_whitelist_is_cleared_by_reset(rpc): ++ rpcproxy = MockRPCProxy( ++ context_factory=_context_factory(), fallback_to_call=False) ++ ++ rpcproxy.add_service_to_whitelist('first_allowed') ++ rpcproxy.add_service_to_whitelist('second_allowed') ++ rpcproxy.first_allowed.before_reset() ++ assert rpc.call.call_count == 1 ++ ++ rpcproxy.reset() ++ ++ assert rpcproxy.fallback_to_call is False ++ with pytest.raises(RuntimeError): ++ rpcproxy.first_allowed.after_reset() ++ with pytest.raises(RuntimeError): ++ rpcproxy.second_allowed.after_reset() ++ assert rpc.call.call_count == 1 ++ ++ ++@patch.object(proxy, 'rpc') ++def test_reset_without_mutation_keeps_initial_fallback_disabled(rpc): ++ rpcproxy = MockRPCProxy( ++ context_factory=_context_factory(), fallback_to_call=False) ++ ++ rpcproxy.reset() ++ ++ assert rpcproxy.fallback_to_call is False ++ with pytest.raises(RuntimeError): ++ rpcproxy.unmutated_service.unmutated_method() ++ assert rpc.call.call_count == 0 ++ ++ ++@patch.object(proxy, 'rpc') ++def test_reset_without_mutation_keeps_initial_fallback_enabled(rpc): ++ rpcproxy = MockRPCProxy( ++ context_factory=_context_factory(), fallback_to_call=True) ++ ++ rpcproxy.reset() ++ ++ assert rpcproxy.fallback_to_call is True ++ rpcproxy.enabled_without_mutation.enabled_method() ++ assert rpc.call.call_count == 1 ++ assert rpc.call.call_args[0][2] == 'enabled_without_mutation' ++ assert rpc.call.call_args[0][3]['method'] == 'enabled_method' ++ ++ ++@patch.object(proxy, 'rpc') ++def test_reset_keep_routings_still_resets_fallback_and_whitelist(rpc): ++ rpcproxy = MockRPCProxy( ++ context_factory=_context_factory(), fallback_to_call=False) ++ response = object() ++ rpcproxy.add_dummy('kept_service', 'kept_method', response) ++ rpcproxy.add_service_to_whitelist('temporary_service') ++ rpcproxy.temporary_service.before_reset() ++ assert rpc.call.call_count == 1 ++ rpcproxy.fallback_to_call = True ++ ++ rpcproxy.reset(keep_routings=True) ++ ++ assert rpcproxy.fallback_to_call is False ++ assert rpcproxy.kept_service.kept_method() is response ++ with pytest.raises(RuntimeError): ++ rpcproxy.temporary_service.after_reset() ++ assert rpc.call.call_count == 1 +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,30 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++run_proxy_tests() { ++python3 - "$@" <<'PY' ++import builtins ++import sys ++ ++builtins.basestring = str ++builtins.unicode = str ++ ++import pytest ++sys.exit(pytest.main(sys.argv[1:])) ++PY ++} ++ ++case "${1:-}" in ++ base) ++ echo "No pre-existing regression tests are required for this Fixture.A patch." ++ exit 0 ++ ;; ++ new) ++ run_proxy_tests -xvs --noconftest test/test_proxy.py ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-002012/tests/test.sh b/tasks/format-code-task-002012/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..64c49ba6223ba512cf1ead81f08c940546d9fa89 --- /dev/null +++ b/tasks/format-code-task-002012/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test/test_proxy.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002012/tests/test_command.sh b/tasks/format-code-task-002012/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-002012/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh base && bash /testbed/mimo_test_command.sh new \ No newline at end of file diff --git a/tasks/format-code-task-002023/environment/Dockerfile b/tasks/format-code-task-002023/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..aaa3e588ef4ac4c5ed6ffc45e15eedaff0863f21 --- /dev/null +++ b/tasks/format-code-task-002023/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:cf78c67534a5a6a367971916adae0dad5537a93bcb29223ca35fa600fd6ce051 diff --git a/tasks/format-code-task-002023/environment/setup/files/blocklist b/tasks/format-code-task-002023/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002023/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002023/environment/setup/setup.sh b/tasks/format-code-task-002023/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002023/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002023/tests/test.patch b/tasks/format-code-task-002023/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e264da0ef66af64bcc8260f080d22c66eb1c528f --- /dev/null +++ b/tasks/format-code-task-002023/tests/test.patch @@ -0,0 +1,72 @@ +diff --git a/nautobot/extras/tests/test_jobs.py b/nautobot/extras/tests/test_jobs.py +index 3fe3d3f9d28..7bbdc1ad624 100644 +--- a/nautobot/extras/tests/test_jobs.py ++++ b/nautobot/extras/tests/test_jobs.py +@@ -7,6 +7,7 @@ + import uuid + import tempfile + ++from constance.test import override_config + from django.conf import settings + from django.contrib.contenttypes.models import ContentType + from django.core.files.uploadedfile import SimpleUploadedFile +@@ -620,6 +621,34 @@ def test_output_file_to_database(self): + # unfortunately with FileField(storage=callable), the callable gets evaluated only at declaration time, not at + # usage/runtime, so override_settings(JOB_FILE_IO_STORAGE) doesn't work the way you'd hope it would. + ++ def test_output_file_too_large(self): ++ module = "file_output" ++ name = "FileOutputJob" ++ data = {"lines": 1} ++ ++ ++ with override_config(JOB_CREATE_FILE_MAX_SIZE=len("Hello world!\n")): ++ job_result = create_job_result_and_run_job(module, name, **data) ++ self.assertEqual(job_result.status, JobResultStatusChoices.STATUS_SUCCESS, job_result.traceback) ++ self.assertEqual(1, job_result.files.count()) ++ self.assertEqual(job_result.files.first().name, "output.txt") ++ self.assertEqual(job_result.files.first().file.read().decode("utf-8"), "Hello World!\n") ++ ++ ++ with override_config(JOB_CREATE_FILE_MAX_SIZE=len("Hello world!\n") - 1): ++ job_result = create_job_result_and_run_job(module, name, **data) ++ self.assertEqual(job_result.status, JobResultStatusChoices.STATUS_FAILURE) ++ self.assertIn("ValueError", job_result.traceback) ++ self.assertEqual(0, job_result.files.count()) ++ ++ ++ with override_config(JOB_CREATE_FILE_MAX_SIZE=10 << 20): ++ with override_settings(JOB_CREATE_FILE_MAX_SIZE=len("Hello world!\n") - 1): ++ job_result = create_job_result_and_run_job(module, name, **data) ++ self.assertEqual(job_result.status, JobResultStatusChoices.STATUS_FAILURE) ++ self.assertIn("ValueError", job_result.traceback) ++ self.assertEqual(0, job_result.files.count()) ++ + + class RunJobManagementCommandTest(TransactionTestCase): + """Test cases for the `nautobot-server runjob` management command.""" +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,9 @@ ++H4sIAAAAAAAAA+3TXW/aMBQGYK7zK46YtDsSgkh7xSS6sg9pg45Q7TJykgN4MnZmO1E78eN3khVa ++7YubVtO281yQyH6xrXOcMK+lKjPUTdR7KkNyniTdk3z/7N7jZBTHZ/H5cEQ5ehvGPUie7EQP1M4L ++C9Czxvjf5U7N/6XC+/57dD4rzG4ndBm67ePtcaL/cZwc+3+WjMfU/zHdhB4MH+8Iv/af978ooWt8 ++jmUQPIOZdrVFuDLObyymH94BXQZYYikdCJqwtdZSb4JqkylXKCoeWgd7oHAFg89gtJIaYb8HShRe ++3UUgPoOdkBraYnsYvYhKbCJdKxXYdu1BoSRUtDDcz1Dqedyu9C3h0Da00GBQCtwZLb8g3KJrz5yi ++B7q/0hq9Q+2hEVaKXKGDtbFQCi9y4TDAm8rQ3vPp9WpxsVhllxfZfPp+NulrUXuTG9//WeQ6nS1P ++RK6mafpxsbw8EXuzSFeTvjKFUFsq74+Zl4v5q7evJ/1DP6LDclFhLHaj7jhGH6pey01Y3fbbGkwL ++LxvhEagMvhbqYUECZ2pb4LHPUdi0n3sudSTu/tYusaw1+C0CdWhDFW3DsJYKg8OWhxZ0M4fBEG+8 ++FS7sTtf9Zp9M7qhP2gykrmoPgwZGwZ++54wxxhhjjDHGGGOMMcYYY4wxxhhj/6qvMEhSrQAoAAA= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-002023/tests/test.sh b/tasks/format-code-task-002023/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..bbaabf5bfddeda64e189c3a40d6f4939b095447d --- /dev/null +++ b/tasks/format-code-task-002023/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +nautobot/extras/tests/test_jobs.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002023/tests/test_command.sh b/tasks/format-code-task-002023/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002023/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002102/environment/Dockerfile b/tasks/format-code-task-002102/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..cd2a9decb5cc16778bc0f0acddff01ec03f254f6 --- /dev/null +++ b/tasks/format-code-task-002102/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:44b81cd212e05817f256e706df92779a62cc8537f742ea6dbf05f3eb3bf60b03 diff --git a/tasks/format-code-task-002102/environment/setup/files/blocklist b/tasks/format-code-task-002102/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002102/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002102/environment/setup/setup.sh b/tasks/format-code-task-002102/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002102/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002102/tests/test.patch b/tasks/format-code-task-002102/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ed2c3f21a7382162748ccfbb6fb6a67111f9dc43 --- /dev/null +++ b/tasks/format-code-task-002102/tests/test.patch @@ -0,0 +1,480 @@ +diff --git a/usercase-test-coderl/alias_batching_test.go b/usercase-test-coderl/alias_batching_test.go +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/alias_batching_test.go +@@ -0,0 +1,448 @@ ++package usercase_test_coderl ++ ++import ( ++ "context" ++ "encoding/json" ++ "fmt" ++ "io" ++ "net/http" ++ "net/http/httptest" ++ "net/url" ++ "os" ++ "reflect" ++ "runtime" ++ "strings" ++ "testing" ++ ++ elastic "github.com/olivere/elastic/v7" ++) ++ ++ ++ ++ ++ ++ ++ ++func mustMarshalAction(t *testing.T, action elastic.AliasAction) string { ++ t.Helper() ++ src, err := action.Source() ++ if err != nil { ++ t.Fatalf("Source returned error: %v", err) ++ } ++ b, err := json.Marshal(src) ++ if err != nil { ++ t.Fatalf("marshal Source: %v", err) ++ } ++ return string(b) ++} ++ ++func assertJSONEqual(t *testing.T, name string, got string, want string) { ++ t.Helper() ++ var gotValue interface{} ++ if err := json.Unmarshal([]byte(got), &gotValue); err != nil { ++ t.Fatalf("%s: got invalid JSON %q: %v", name, got, err) ++ } ++ var wantValue interface{} ++ if err := json.Unmarshal([]byte(want), &wantValue); err != nil { ++ t.Fatalf("%s: test wanted invalid JSON %q: %v", name, want, err) ++ } ++ ++ if !reflect.DeepEqual(gotValue, wantValue) { ++ t.Fatalf("%s: want JSON %s, got %s", name, want, got) ++ } ++} ++ ++func assertQueryEqual(t *testing.T, raw string, want url.Values) { ++ t.Helper() ++ got, err := url.ParseQuery(raw) ++ if err != nil { ++ t.Fatalf("rawQuery: invalid query %q: %v", raw, err) ++ } ++ ++ if !reflect.DeepEqual(got, want) { ++ t.Fatalf("rawQuery: want %v, got %v from %q", want, got, raw) ++ } ++} ++ ++func countFDs(t *testing.T) int { ++ t.Helper() ++ entries, err := os.ReadDir("/proc/self/fd") ++ if err != nil { ++ t.Fatalf("read /proc/self/fd: %v", err) ++ } ++ return len(entries) ++} ++ ++func newAliasTestClient(t *testing.T, handler http.HandlerFunc) (*elastic.Client, func()) { ++ t.Helper() ++ ts := httptest.NewServer(handler) ++ client, err := elastic.NewSimpleClient(elastic.SetURL(ts.URL)) ++ if err != nil { ++ ts.Close() ++ t.Fatalf("NewSimpleClient: %v", err) ++ } ++ return client, ts.Close ++} ++ ++func TestAliasActionBuildersSourceLiterals(t *testing.T) { ++ ++ ++ cases := []struct { ++ name string ++ got string ++ want string ++ }{ ++ { ++ name: "add single index", ++ got: mustMarshalAction(t, elastic.NewAliasAddAction("alias1").Index("index1")), ++ want: `{"add":{"alias":"alias1","index":"index1"}}`, ++ }, ++ { ++ name: "add two indices", ++ got: mustMarshalAction(t, elastic.NewAliasAddAction("alias1").Index("index1", "index2")), ++ want: `{"add":{"alias":"alias1","indices":["index1","index2"]}}`, ++ }, ++ { ++ name: "add filter", ++ got: mustMarshalAction(t, elastic.NewAliasAddAction("alias1").Index("index1").Filter(elastic.NewTermQuery("user", "olivere"))), ++ want: `{"add":{"alias":"alias1","filter":{"term":{"user":"olivere"}},"index":"index1"}}`, ++ }, ++ { ++ name: "add routing fields", ++ got: mustMarshalAction(t, elastic.NewAliasAddAction("alias1").Index("index1").Routing("routing1").IndexRouting("indexRouting1").SearchRouting("r1", "r2").IsWriteIndex(false)), ++ want: `{"add":{"alias":"alias1","index":"index1","index_routing":"indexRouting1","is_write_index":false,"routing":"routing1","search_routing":"r1,r2"}}`, ++ }, ++ { ++ name: "remove single index", ++ got: mustMarshalAction(t, elastic.NewAliasRemoveAction("alias1").Index("index1")), ++ want: `{"remove":{"alias":"alias1","index":"index1"}}`, ++ }, ++ { ++ name: "remove two indices", ++ got: mustMarshalAction(t, elastic.NewAliasRemoveAction("alias1").Index("index1", "index2")), ++ want: `{"remove":{"alias":"alias1","indices":["index1","index2"]}}`, ++ }, ++ { ++ name: "remove index", ++ got: mustMarshalAction(t, elastic.NewAliasRemoveIndexAction("index1")), ++ want: `{"remove_index":{"index":"index1"}}`, ++ }, ++ } ++ for _, tc := range cases { ++ ++ assertJSONEqual(t, tc.name, tc.got, tc.want) ++ } ++} ++ ++func TestAliasActionValidationErrors(t *testing.T) { ++ ++ ++ cases := []struct { ++ name string ++ err error ++ want string ++ }{ ++ { ++ name: "add missing both", ++ err: elastic.NewAliasAddAction("").Validate(), ++ want: "missing required fields: [Alias Index]", ++ }, ++ { ++ name: "add missing index", ++ err: elastic.NewAliasAddAction("alias1").Validate(), ++ want: "missing required fields: [Index]", ++ }, ++ { ++ name: "add missing alias", ++ err: elastic.NewAliasAddAction("").Index("index1").Validate(), ++ want: "missing required fields: [Alias]", ++ }, ++ { ++ name: "add write index with two indices", ++ err: elastic.NewAliasAddAction("alias1").Index("index1", "index2").IsWriteIndex(true).Validate(), ++ want: "is_write_index", ++ }, ++ { ++ name: "remove missing both", ++ err: elastic.NewAliasRemoveAction("").Validate(), ++ want: "missing required fields: [Alias Index]", ++ }, ++ { ++ name: "remove missing index", ++ err: elastic.NewAliasRemoveAction("alias1").Validate(), ++ want: "missing required fields: [Index]", ++ }, ++ { ++ name: "remove index missing index", ++ err: elastic.NewAliasRemoveIndexAction("").Validate(), ++ want: "missing required field: index", ++ }, ++ } ++ for _, tc := range cases { ++ if tc.err == nil { ++ t.Fatalf("%s: expected concrete error %q, got nil", tc.name, tc.want) ++ } ++ got := tc.err.Error() ++ switch tc.name { ++ case "add missing both", "remove missing both": ++ ++ if !strings.Contains(got, "Alias") || !strings.Contains(got, "Index") { ++ t.Fatalf("%s: want error mentioning Alias and Index, got %q", tc.name, got) ++ } ++ case "add write index with two indices": ++ ++ lower := strings.ToLower(got) ++ if !strings.Contains(lower, "is_write_index") || !strings.Contains(lower, "index") || !(strings.Contains(lower, "more") || strings.Contains(lower, "multiple")) { ++ t.Fatalf("%s: want explanatory is_write_index/multiple-index error, got %q", tc.name, got) ++ } ++ default: ++ if got != tc.want { ++ t.Fatalf("%s: want %q, got %q", tc.name, tc.want, got) ++ } ++ } ++ } ++} ++ ++func TestAliasServiceBatchesActionsQueryParamsHeadersAndDecodesResult(t *testing.T) { ++ ++ ++ var requestCount int ++ var method, path, rawQuery, body string ++ var traceHeader, replaceHeader, opaqueHeader string ++ client, cleanup := newAliasTestClient(t, func(w http.ResponseWriter, r *http.Request) { ++ requestCount++ ++ method = r.Method ++ path = r.URL.Path ++ rawQuery = r.URL.RawQuery ++ traceHeader = r.Header.Get("X-Trace") ++ replaceHeader = r.Header.Get("X-Replace") ++ opaqueHeader = r.Header.Get("X-Opaque-Id") ++ data, err := io.ReadAll(r.Body) ++ if err != nil { ++ t.Fatalf("ReadAll body: %v", err) ++ } ++ body = string(data) ++ w.Header().Set("Content-Type", "application/json") ++ fmt.Fprint(w, `{"acknowledged":true,"shards_acknowledged":false,"index":"index-returned"}`) ++ }) ++ defer cleanup() ++ ++ result, err := client.Alias(). ++ Pretty(true). ++ Human(false). ++ ErrorTrace(true). ++ FilterPath("acknowledged", "index"). ++ Headers(http.Header{ ++ "X-Trace": []string{"trace-1"}, ++ "X-Replace": []string{"replace-1"}, ++ }). ++ ++ Header("X-Opaque-Id", "opaque-1"). ++ Add("index1", "alias1"). ++ AddWithFilter("index2", "alias2", elastic.NewTermQuery("user", "olivere")). ++ Remove("index3", "alias3"). ++ Action(elastic.NewAliasRemoveIndexAction("index4")). ++ Do(context.Background()) ++ if err != nil { ++ t.Fatalf("Do returned error: %v", err) ++ } ++ ++ if requestCount != 1 { ++ t.Fatalf("requestCount: want 1, got %d", requestCount) ++ } ++ if method != "POST" { ++ t.Fatalf("method: want POST, got %s", method) ++ } ++ if path != "/_aliases" { ++ t.Fatalf("path: want /_aliases, got %s", path) ++ } ++ assertQueryEqual(t, rawQuery, url.Values{ ++ "error_trace": []string{"true"}, ++ "filter_path": []string{"acknowledged,index"}, ++ "human": []string{"false"}, ++ "pretty": []string{"true"}, ++ }) ++ if traceHeader != "trace-1" { ++ t.Fatalf("X-Trace: want trace-1, got %s", traceHeader) ++ } ++ if replaceHeader != "replace-1" { ++ t.Fatalf("X-Replace: want replace-1, got %s", replaceHeader) ++ } ++ if opaqueHeader != "opaque-1" { ++ t.Fatalf("X-Opaque-Id: want opaque-1, got %q", opaqueHeader) ++ } ++ wantBody := `{"actions":[{"add":{"alias":"alias1","index":"index1"}},{"add":{"alias":"alias2","filter":{"term":{"user":"olivere"}},"index":"index2"}},{"remove":{"alias":"alias3","index":"index3"}},{"remove_index":{"index":"index4"}}]}` ++ ++ assertJSONEqual(t, "body", body, wantBody) ++ if result.Acknowledged != true { ++ t.Fatalf("Acknowledged: want true, got %v", result.Acknowledged) ++ } ++ if result.ShardsAcknowledged != false { ++ t.Fatalf("ShardsAcknowledged: want false, got %v", result.ShardsAcknowledged) ++ } ++ if result.Index != "index-returned" { ++ t.Fatalf("Index: want index-returned, got %q", result.Index) ++ } ++} ++ ++func TestNewAliasServiceAndRepeatedDoAreIdempotent(t *testing.T) { ++ ++ ++ var bodies []string ++ client, cleanup := newAliasTestClient(t, func(w http.ResponseWriter, r *http.Request) { ++ data, err := io.ReadAll(r.Body) ++ if err != nil { ++ t.Fatalf("ReadAll body: %v", err) ++ } ++ bodies = append(bodies, string(data)) ++ w.Header().Set("Content-Type", "application/json") ++ fmt.Fprint(w, `{"acknowledged":false,"shards_acknowledged":true}`) ++ }) ++ defer cleanup() ++ ++ service := elastic.NewAliasService(client).Add("index1", "alias1") ++ first, err := service.Do(context.Background()) ++ if err != nil { ++ t.Fatalf("first Do returned error: %v", err) ++ } ++ second, err := service.Do(context.Background()) ++ if err != nil { ++ t.Fatalf("second Do returned error: %v", err) ++ } ++ ++ if len(bodies) != 2 { ++ t.Fatalf("bodies length: want 2, got %d", len(bodies)) ++ } ++ ++ assertJSONEqual(t, "first body", bodies[0], `{"actions":[{"add":{"alias":"alias1","index":"index1"}}]}`) ++ assertJSONEqual(t, "second body", bodies[1], `{"actions":[{"add":{"alias":"alias1","index":"index1"}}]}`) ++ if first.Acknowledged != false { ++ t.Fatalf("first Acknowledged: want false, got %v", first.Acknowledged) ++ } ++ if first.ShardsAcknowledged != true { ++ t.Fatalf("first ShardsAcknowledged: want true, got %v", first.ShardsAcknowledged) ++ } ++ if first.Index != "" { ++ t.Fatalf("first Index: want empty string, got %q", first.Index) ++ } ++ if second.Acknowledged != false { ++ t.Fatalf("second Acknowledged: want false, got %v", second.Acknowledged) ++ } ++ if second.ShardsAcknowledged != true { ++ t.Fatalf("second ShardsAcknowledged: want true, got %v", second.ShardsAcknowledged) ++ } ++ if second.Index != "" { ++ t.Fatalf("second Index: want empty string, got %q", second.Index) ++ } ++ client.Stop() ++ client.Stop() ++} ++ ++func TestDoReturnsValidationErrorBeforeHTTPRequest(t *testing.T) { ++ ++ ++ var requestCount int ++ client, cleanup := newAliasTestClient(t, func(w http.ResponseWriter, r *http.Request) { ++ requestCount++ ++ t.Fatalf("unexpected HTTP request %s %s", r.Method, r.URL.String()) ++ }) ++ defer cleanup() ++ ++ result, err := client.Alias().Action(elastic.NewAliasAddAction("alias1")).Do(context.Background()) ++ if result != nil { ++ t.Fatalf("result: want nil, got %#v", result) ++ } ++ if err == nil { ++ t.Fatal("expected concrete validation error, got nil") ++ } ++ if got := err.Error(); got != "missing required fields: [Index]" { ++ t.Fatalf("error: want %q, got %q", "missing required fields: [Index]", got) ++ } ++ if requestCount != 0 { ++ t.Fatalf("requestCount: want 0, got %d", requestCount) ++ } ++} ++ ++func TestAliasServicesKeepIndependentPendingBatches(t *testing.T) { ++ ++ ++ var bodies []string ++ client, cleanup := newAliasTestClient(t, func(w http.ResponseWriter, r *http.Request) { ++ data, err := io.ReadAll(r.Body) ++ if err != nil { ++ t.Fatalf("ReadAll body: %v", err) ++ } ++ bodies = append(bodies, string(data)) ++ w.Header().Set("Content-Type", "application/json") ++ fmt.Fprint(w, `{"acknowledged":true,"shards_acknowledged":true}`) ++ }) ++ defer cleanup() ++ ++ a := client.Alias().Add("a-index-1", "a-alias").Remove("a-index-2", "a-alias") ++ b := client.Alias().Add("b-index-1", "b-alias") ++ if _, err := a.Do(context.Background()); err != nil { ++ t.Fatalf("a.Do returned error: %v", err) ++ } ++ if _, err := b.Do(context.Background()); err != nil { ++ t.Fatalf("b.Do returned error: %v", err) ++ } ++ ++ if len(bodies) != 2 { ++ t.Fatalf("bodies length: want 2, got %d", len(bodies)) ++ } ++ ++ assertJSONEqual(t, "service a body", bodies[0], `{"actions":[{"add":{"alias":"a-alias","index":"a-index-1"}},{"remove":{"alias":"a-alias","index":"a-index-2"}}]}`) ++ assertJSONEqual(t, "service b body", bodies[1], `{"actions":[{"add":{"alias":"b-alias","index":"b-index-1"}}]}`) ++} ++ ++func TestAliasDoCyclesDoNotLeakFDsOrGoroutines(t *testing.T) { ++ ++ ++ runtime.GC() ++ startFDs := countFDs(t) ++ startGoroutines := runtime.NumGoroutine() ++ ++ for i := 0; i < 150; i++ { ++ client, cleanup := newAliasTestClient(t, func(w http.ResponseWriter, r *http.Request) { ++ if r.Method != "POST" { ++ t.Fatalf("method: want POST, got %s", r.Method) ++ } ++ if r.URL.Path != "/_aliases" { ++ t.Fatalf("path: want /_aliases, got %s", r.URL.Path) ++ } ++ if !strings.Contains(r.URL.RawQuery, "pretty=false") { ++ t.Fatalf("rawQuery: want pretty=false in %q", r.URL.RawQuery) ++ } ++ w.Header().Set("Content-Type", "application/json") ++ fmt.Fprint(w, `{"acknowledged":true,"shards_acknowledged":true}`) ++ }) ++ result, err := client.Alias().Pretty(false).Add("index1", "alias1").Do(context.Background()) ++ if err != nil { ++ cleanup() ++ t.Fatalf("cycle %d Do returned error: %v", i, err) ++ } ++ if result.Acknowledged != true { ++ cleanup() ++ t.Fatalf("cycle %d Acknowledged: want true, got %v", i, result.Acknowledged) ++ } ++ if result.ShardsAcknowledged != true { ++ cleanup() ++ t.Fatalf("cycle %d ShardsAcknowledged: want true, got %v", i, result.ShardsAcknowledged) ++ } ++ if result.Index != "" { ++ cleanup() ++ t.Fatalf("cycle %d Index: want empty string, got %q", i, result.Index) ++ } ++ cleanup() ++ } ++ ++ runtime.GC() ++ endFDs := countFDs(t) ++ endGoroutines := runtime.NumGoroutine() ++ if endFDs > startFDs+10 { ++ t.Fatalf("fd count grew beyond bound: start %d, end %d", startFDs, endFDs) ++ } ++ if endGoroutines > startGoroutines+10 { ++ t.Fatalf("goroutine count grew beyond bound: start %d, end %d", startGoroutines, endGoroutines) ++ } ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,22 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++ ++export GOWORK=off ++export GOPROXY=off ++export GOSUMDB=off ++export GOTOOLCHAIN=local ++ ++go list -mod=mod -m all >/dev/null ++exec go test -mod=mod -v -count=1 ./usercase-test-coderl/... diff --git a/tasks/format-code-task-002102/tests/test.sh b/tasks/format-code-task-002102/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..faa93229c833b7ea626eecaa0851d7b978250d86 --- /dev/null +++ b/tasks/format-code-task-002102/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/alias_batching_test.go +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002102/tests/test_command.sh b/tasks/format-code-task-002102/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002102/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002105/environment/Dockerfile b/tasks/format-code-task-002105/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d9c37cca833198084db6284edd2228d6a9b81871 --- /dev/null +++ b/tasks/format-code-task-002105/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:37393dc65b53bb83849e20aacdbc7065d2c4e0b6176b17bceb06eb74aac54189 diff --git a/tasks/format-code-task-002105/environment/setup/files/blocklist b/tasks/format-code-task-002105/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002105/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002105/environment/setup/setup.sh b/tasks/format-code-task-002105/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002105/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002105/tests/test.patch b/tasks/format-code-task-002105/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..3380f041ebfcecdcd227f371d4288164e6cdecbb --- /dev/null +++ b/tasks/format-code-task-002105/tests/test.patch @@ -0,0 +1,542 @@ +diff --git a/usercase-test-coderl/test_custom_model_creation.py b/usercase-test-coderl/test_custom_model_creation.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_custom_model_creation.py +@@ -0,0 +1,503 @@ ++import importlib ++import json ++import threading ++from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer ++from pathlib import Path ++ ++import anyio ++import httpx ++import pytest ++ ++import ollama ++from ollama import AsyncClient, Client, Message, Options ++ ++EMPTY_SHA256 = 'sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' ++ ++ ++def _json_body(request: httpx.Request) -> dict: ++ return json.loads(request.content.decode()) ++ ++ ++def _create_json_transport(records, response_status='success', status_code=200): ++ def handler(request: httpx.Request) -> httpx.Response: ++ records.append((request.method, request.url.path, _json_body(request))) ++ return httpx.Response(status_code, json={'status': response_status}) ++ ++ return httpx.MockTransport(handler) ++ ++ ++def _stream_transport(records): ++ def handler(request: httpx.Request) -> httpx.Response: ++ records.append((request.method, request.url.path, _json_body(request))) ++ return httpx.Response( ++ 200, ++ content=b'{"status":"parsing modelfile"}\n{"status":"creating model layer"}\n{"status":"success"}\n', ++ ) ++ ++ return httpx.MockTransport(handler) ++ ++ ++def _blob_transport(records, status_code): ++ def handler(request: httpx.Request) -> httpx.Response: ++ records.append((request.method, request.url.path, request.content)) ++ return httpx.Response(status_code) ++ ++ return httpx.MockTransport(handler) ++ ++ ++class _RecordingHandler(BaseHTTPRequestHandler): ++ protocol_version = 'HTTP/1.1' ++ ++ def do_POST(self): ++ length = int(self.headers.get('Content-Length', '0')) ++ payload = self.rfile.read(length) ++ self.server.records.append((self.command, self.path, json.loads(payload.decode()))) ++ ++ body = b'{"status":"success"}' ++ self.send_response(200) ++ self.send_header('Content-Type', 'application/json') ++ self.send_header('Content-Length', str(len(body))) ++ if self.server.close_after_response: ++ self.send_header('Connection', 'close') ++ self.close_connection = True ++ self.end_headers() ++ self.wfile.write(body) ++ ++ def log_message(self, format, *args): ++ return None ++ ++ ++class _RecordingServer: ++ def __init__(self, *, close_after_response=False): ++ self._server = ThreadingHTTPServer(('127.0.0.1', 0), _RecordingHandler) ++ self._server.records = [] ++ self._server.close_after_response = close_after_response ++ self.url = f'http://127.0.0.1:{self._server.server_port}' ++ self._thread = threading.Thread(target=self._server.serve_forever, daemon=True) ++ ++ @property ++ def records(self): ++ return self._server.records ++ ++ def __enter__(self): ++ self._thread.start() ++ return self ++ ++ def __exit__(self, exc_type, exc, tb): ++ self._server.shutdown() ++ self._server.server_close() ++ self._thread.join(timeout=5) ++ ++ ++def test_sync_create_from_model_posts_literal_json_and_returns_progress_status(): ++ ++ ++ ++ ++ records = [] ++ client = Client(host='http://testserver', transport=_create_json_transport(records)) ++ ++ response = client.create('dummy', from_='llama2') ++ ++ assert response.status == 'success' ++ ++ assert isinstance(response, ollama.ProgressResponse) ++ assert records == [('POST', '/api/create', {'model': 'dummy', 'stream': False, 'from': 'llama2'})] ++ client.close() ++ ++ ++def test_sync_create_serializes_all_creation_options_with_string_license(): ++ ++ ++ ++ ++ records = [] ++ client = Client(host='http://testserver', transport=_create_json_transport(records)) ++ ++ response = client.create( ++ 'dummy', ++ quantize='q4_k_m', ++ from_='llama2', ++ files={'model.gguf': 'sha256:abc123'}, ++ adapters={'adapter.gguf': 'sha256:def456'}, ++ template='FROM {{ .Model }}', ++ license='MIT', ++ system='Use short answers.', ++ parameters={'stop': ['']}, ++ messages=[{'role': 'user', 'content': 'Hello'}], ++ ) ++ ++ assert response.status == 'success' ++ assert records == [ ++ ( ++ 'POST', ++ '/api/create', ++ { ++ 'model': 'dummy', ++ 'stream': False, ++ 'quantize': 'q4_k_m', ++ 'files': {'model.gguf': 'sha256:abc123'}, ++ 'adapters': {'adapter.gguf': 'sha256:def456'}, ++ 'template': 'FROM {{ .Model }}', ++ 'license': 'MIT', ++ 'system': 'Use short answers.', ++ 'parameters': {'stop': ['']}, ++ 'messages': [{'role': 'user', 'content': 'Hello'}], ++ 'from': 'llama2', ++ }, ++ ), ++ ] ++ client.close() ++ ++ ++def test_sync_create_accepts_options_and_message_models(): ++ ++ ++ ++ ++ records = [] ++ client = Client(host='http://testserver', transport=_create_json_transport(records)) ++ ++ response = client.create('dummy-options', parameters=Options(stop=['']), messages=[Message(role='user', content='Hello from Message')]) ++ ++ assert response.status == 'success' ++ assert records == [ ++ ( ++ 'POST', ++ '/api/create', ++ { ++ 'model': 'dummy-options', ++ 'stream': False, ++ 'parameters': {'stop': ['']}, ++ 'messages': [{'role': 'user', 'content': 'Hello from Message'}], ++ }, ++ ), ++ ] ++ client.close() ++ ++ ++def test_sync_create_stream_returns_progress_iterator_chunks(): ++ ++ ++ ++ ++ records = [] ++ client = Client(host='http://testserver', transport=_stream_transport(records)) ++ ++ chunks = client.create('dummy-stream', from_='llama2', stream=True) ++ statuses = [part.status for part in chunks] ++ ++ assert statuses == ['parsing modelfile', 'creating model layer', 'success'] ++ assert records == [('POST', '/api/create', {'model': 'dummy-stream', 'stream': True, 'from': 'llama2'})] ++ client.close() ++ ++ ++def test_sync_create_blob_uploads_empty_file_and_returns_digest_for_created_blob(tmp_path: Path): ++ ++ ++ ++ ++ records = [] ++ blob = tmp_path / 'empty.gguf' ++ blob.write_bytes(b'') ++ client = Client(host='http://testserver', transport=_blob_transport(records, 201)) ++ ++ digest = client.create_blob(blob) ++ ++ assert digest == EMPTY_SHA256 ++ assert records == [('POST', f'/api/blobs/{EMPTY_SHA256}', b'')] ++ client.close() ++ ++ ++def test_sync_create_blob_returns_digest_for_existing_blob(tmp_path: Path): ++ ++ ++ ++ ++ records = [] ++ blob = tmp_path / 'empty-existing.gguf' ++ blob.write_bytes(b'') ++ client = Client(host='http://testserver', transport=_blob_transport(records, 200)) ++ ++ digest = client.create_blob(str(blob)) ++ ++ assert digest == EMPTY_SHA256 ++ assert records == [('POST', f'/api/blobs/{EMPTY_SHA256}', b'')] ++ client.close() ++ ++ ++def test_sync_create_blob_missing_path_raises_file_not_found_before_upload(tmp_path: Path): ++ ++ ++ ++ ++ records = [] ++ client = Client(host='http://testserver', transport=_blob_transport(records, 201)) ++ ++ ++ with pytest.raises(FileNotFoundError): ++ client.create_blob(tmp_path / 'missing.gguf') ++ ++ assert records == [] ++ client.close() ++ ++ ++def test_sync_create_uses_public_client_api_without_post_close_requirement(): ++ ++ ++ ++ ++ records = [] ++ client = Client(host='http://testserver', transport=_create_json_transport(records)) ++ ++ response = client.create('dummy', from_='llama2') ++ ++ ++ assert response.status == 'success' ++ assert records == [('POST', '/api/create', {'model': 'dummy', 'stream': False, 'from': 'llama2'})] ++ client.close() ++ ++ ++def test_sync_create_omits_none_fields_explicitly_passed(): ++ ++ ++ ++ ++ records = [] ++ client = Client(host='http://testserver', transport=_create_json_transport(records)) ++ ++ response = client.create('dummy-none', quantize=None, from_='llama2', template=None) ++ ++ ++ assert response.status == 'success' ++ assert records == [('POST', '/api/create', {'model': 'dummy-none', 'stream': False, 'from': 'llama2'})] ++ client.close() ++ ++ ++def test_two_sync_clients_keep_independent_request_state(): ++ ++ ++ ++ ++ records_a = [] ++ records_b = [] ++ client_a = Client(host='http://a.test', transport=_create_json_transport(records_a, response_status='success-a')) ++ client_b = Client(host='http://b.test', transport=_create_json_transport(records_b, response_status='success-b')) ++ ++ response_a = client_a.create('model-a', from_='llama2') ++ ++ assert response_a.status == 'success-a' ++ assert records_a == [('POST', '/api/create', {'model': 'model-a', 'stream': False, 'from': 'llama2'})] ++ assert records_b == [] ++ ++ response_b = client_b.create('model-b', from_='mistral') ++ ++ assert response_b.status == 'success-b' ++ assert records_a == [('POST', '/api/create', {'model': 'model-a', 'stream': False, 'from': 'llama2'})] ++ assert records_b == [('POST', '/api/create', {'model': 'model-b', 'stream': False, 'from': 'mistral'})] ++ client_a.close() ++ client_b.close() ++ ++ ++def test_module_level_create_uses_default_sync_client_public_api(monkeypatch): ++ ++ ++ ++ ++ with _RecordingServer(close_after_response=True) as server: ++ with monkeypatch.context() as scoped: ++ scoped.setenv('OLLAMA_HOST', server.url) ++ reloaded = importlib.reload(ollama) ++ response = reloaded.create('dummy', from_='llama2') ++ ++ importlib.reload(ollama) ++ ++ assert response.status == 'success' ++ assert server.records == [('POST', '/api/create', {'model': 'dummy', 'stream': False, 'from': 'llama2'})] ++ ++ ++def test_sync_create_repeated_clients_send_create_requests(): ++ ++ ++ ++ ++ with _RecordingServer() as server: ++ for index in range(3): ++ client = Client(host=server.url) ++ response = client.create(f'leak-check-{index}', from_='llama2') ++ assert response.status == 'success' ++ client.close() ++ ++ ++ assert len(server.records) == 3 ++ assert [record[2]['model'] for record in server.records] == ['leak-check-0', 'leak-check-1', 'leak-check-2'] ++ ++ ++def test_async_create_from_model_posts_literal_json_and_returns_progress_status(): ++ ++ ++ ++ ++ ++ async def run(): ++ records = [] ++ client = AsyncClient(host='http://testserver', transport=_create_json_transport(records)) ++ ++ response = await client.create('dummy', from_='llama2') ++ ++ assert response.status == 'success' ++ ++ assert isinstance(response, ollama.ProgressResponse) ++ assert records == [('POST', '/api/create', {'model': 'dummy', 'stream': False, 'from': 'llama2'})] ++ await client.close() ++ ++ anyio.run(run) ++ ++ ++def test_async_create_serializes_options_with_license_list(): ++ ++ ++ ++ ++ ++ async def run(): ++ records = [] ++ client = AsyncClient(host='http://testserver', transport=_create_json_transport(records)) ++ ++ response = await client.create( ++ 'dummy', ++ quantize='q4_k_m', ++ from_='llama2', ++ adapters={'adapter.gguf': 'sha256:def456'}, ++ template='FROM {{ .Model }}', ++ license=['MIT', 'Apache-2.0'], ++ system='Use short answers.', ++ parameters={'stop': ['']}, ++ messages=[{'role': 'user', 'content': 'Hello'}], ++ ) ++ ++ assert response.status == 'success' ++ assert records == [ ++ ( ++ 'POST', ++ '/api/create', ++ { ++ 'model': 'dummy', ++ 'stream': False, ++ 'quantize': 'q4_k_m', ++ 'adapters': {'adapter.gguf': 'sha256:def456'}, ++ 'template': 'FROM {{ .Model }}', ++ 'license': ['MIT', 'Apache-2.0'], ++ 'system': 'Use short answers.', ++ 'parameters': {'stop': ['']}, ++ 'messages': [{'role': 'user', 'content': 'Hello'}], ++ 'from': 'llama2', ++ }, ++ ), ++ ] ++ await client.close() ++ ++ anyio.run(run) ++ ++ ++def test_async_create_stream_returns_progress_async_iterator_chunks(): ++ ++ ++ ++ ++ ++ async def run(): ++ records = [] ++ client = AsyncClient(host='http://testserver', transport=_stream_transport(records)) ++ ++ chunks = await client.create('dummy-stream', from_='llama2', stream=True) ++ statuses = [] ++ async for part in chunks: ++ statuses.append(part.status) ++ ++ assert statuses == ['parsing modelfile', 'creating model layer', 'success'] ++ assert records == [('POST', '/api/create', {'model': 'dummy-stream', 'stream': True, 'from': 'llama2'})] ++ await client.close() ++ ++ anyio.run(run) ++ ++ ++def test_async_create_blob_uploads_empty_file_and_returns_digest_for_existing_blob(tmp_path: Path): ++ ++ ++ ++ ++ ++ async def run(): ++ records = [] ++ blob = tmp_path / 'async-empty.gguf' ++ blob.write_bytes(b'') ++ client = AsyncClient(host='http://testserver', transport=_blob_transport(records, 200)) ++ ++ digest = await client.create_blob(blob) ++ ++ assert digest == EMPTY_SHA256 ++ assert records == [('POST', f'/api/blobs/{EMPTY_SHA256}', b'')] ++ await client.close() ++ ++ anyio.run(run) ++ ++ ++def test_async_create_blob_missing_path_raises_file_not_found_before_upload(tmp_path: Path): ++ ++ ++ ++ ++ ++ async def run(): ++ records = [] ++ client = AsyncClient(host='http://testserver', transport=_blob_transport(records, 201)) ++ ++ ++ with pytest.raises(FileNotFoundError): ++ await client.create_blob(tmp_path / 'missing-async.gguf') ++ ++ assert records == [] ++ await client.close() ++ ++ anyio.run(run) ++ ++ ++def test_async_create_uses_public_client_api_without_post_close_requirement(): ++ ++ ++ ++ ++ ++ async def run(): ++ records = [] ++ client = AsyncClient(host='http://testserver', transport=_create_json_transport(records)) ++ ++ response = await client.create('dummy', from_='llama2') ++ ++ ++ assert response.status == 'success' ++ assert records == [('POST', '/api/create', {'model': 'dummy', 'stream': False, 'from': 'llama2'})] ++ await client.close() ++ ++ anyio.run(run) ++ ++ ++def test_async_create_omits_none_fields_explicitly_passed(): ++ ++ ++ ++ ++ ++ async def run(): ++ records = [] ++ client = AsyncClient(host='http://testserver', transport=_create_json_transport(records)) ++ ++ response = await client.create('dummy-none', quantize=None, from_='llama2', template=None) ++ ++ ++ assert response.status == 'success' ++ assert records == [('POST', '/api/create', {'model': 'dummy-none', 'stream': False, 'from': 'llama2'})] ++ await client.close() ++ ++ anyio.run(run) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,29 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++ ++export PYTHONPATH="/workspace/repo${PYTHONPATH:+:${PYTHONPATH}}" ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++export PIP_NO_INDEX=1 ++export PIP_DISABLE_PIP_VERSION_CHECK=1 ++ ++python - <<'PY' ++import anyio ++import httpx ++import pydantic ++import pytest ++import ollama ++PY ++ ++exec python -m pytest /workspace/repo/usercase-test-coderl/test_custom_model_creation.py -v diff --git a/tasks/format-code-task-002105/tests/test.sh b/tasks/format-code-task-002105/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..451c15a94b2541a804422c72cf12a9ba10dfaad8 --- /dev/null +++ b/tasks/format-code-task-002105/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/test_custom_model_creation.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002105/tests/test_command.sh b/tasks/format-code-task-002105/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002105/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002151/environment/Dockerfile b/tasks/format-code-task-002151/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..08dc5b2031e79079e3366e0c0697d87c3fcb2823 --- /dev/null +++ b/tasks/format-code-task-002151/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:4f14fcaa8ed254e1c22dc61d8107fa61548d770fc074e98baa4c31704518eb98 diff --git a/tasks/format-code-task-002151/environment/setup/files/blocklist b/tasks/format-code-task-002151/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002151/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002151/environment/setup/setup.sh b/tasks/format-code-task-002151/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002151/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002151/tests/test.patch b/tasks/format-code-task-002151/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..54a9e71cde7fa2f15aa86f529f581218521f3d01 --- /dev/null +++ b/tasks/format-code-task-002151/tests/test.patch @@ -0,0 +1,109 @@ +diff --git a/pkg/util/logging/logger_test.go b/pkg/util/logging/logger_test.go +index 532650efda..dbe9693f9c 100644 +--- a/pkg/util/logging/logger_test.go ++++ b/pkg/util/logging/logger_test.go +@@ -6,35 +6,44 @@ import ( + + ft "github.com/openshift/ansible-service-broker/pkg/fusortest" + +- logging "github.com/op/go-logging" ++ "github.com/sirupsen/logrus" + ) + + func TestLevelFromString(t *testing.T) { + testCases := []struct { + LogLevel string +- Level logging.Level ++ Level logrus.Level + }{ + { ++ LogLevel: "panic", ++ Level: logrus.PanicLevel, ++ }, { + LogLevel: "critical", +- Level: logging.CRITICAL, ++ Level: logrus.FatalLevel, ++ }, { ++ LogLevel: "fatal", ++ Level: logrus.FatalLevel, + }, { + LogLevel: "error", +- Level: logging.ERROR, ++ Level: logrus.ErrorLevel, + }, { + LogLevel: "warning", +- Level: logging.WARNING, ++ Level: logrus.WarnLevel, ++ }, { ++ LogLevel: "warn", ++ Level: logrus.WarnLevel, + }, { + LogLevel: "notice", +- Level: logging.NOTICE, ++ Level: logrus.InfoLevel, + }, { + LogLevel: "info", +- Level: logging.INFO, ++ Level: logrus.InfoLevel, + }, { + LogLevel: "debug", +- Level: logging.DEBUG, ++ Level: logrus.DebugLevel, + }, { + LogLevel: "nothing", +- Level: logging.DEBUG, ++ Level: logrus.DebugLevel, + }, + } + +@@ -45,10 +54,6 @@ func TestLevelFromString(t *testing.T) { + } + } + +-func TestNewLog(t *testing.T) { +- ft.AssertNotNil(t, NewLog()) +-} +- + func TestInitializeLog(t *testing.T) { + testCases := []struct { + Config LogConfig +@@ -75,6 +80,16 @@ func TestInitializeLog(t *testing.T) { + ShouldError: false, + Name: "logDoesExist", + }, ++ { ++ Config: LogConfig{ ++ LogFile: "testdata/testing.log", ++ Stdout: false, ++ Level: "critical", ++ Color: false, ++ }, ++ ShouldError: false, ++ Name: "logIsCritical", ++ }, + { + Config: LogConfig{ + LogFile: "", +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,7 @@ ++H4sIAAAAAAAAA+3ST2vbMBgG8Jz9Kd7Ry3qwFZvYOfVQ2MgOKylbew6ypdhabMlIckq//WSX/qHQ ++BkbCKH1+FxlJlh7pVVIOqhUbqfdsdirzYJnnUxu8bqfvNM/m2TLL8yzMS9NiXswoP1miFwbnuSWa ++WWP8e/MOjX9QyXP9vXR+U5mu41okrjneHofqX6TFU/0XeRbqvyiyxYzmx4vwtk9e/7MvrFSaldw1 ++USVoegSlFFF0Rr+lp6Gn1fr68uYHufuuVXpHzpBvJPXW/JGVJ+VIdb2xnpetJB46vKOKa6NVxVvq ++uW+ibieUpbgnNl4iqw1ztmK18s1QJuHBMdNL7Rq19VGrKXZb/ZTj8C+Ma6fC3rGTdq8qGZfW7KQd ++D/Br0FPWUOA6nGVcku7CErQy1BkxtNKRUG5MLujr44kGN3bLnu2lFsaeT9fyrylW6zRNr9bfbn9+ ++vzDbLdXmIUa8p4T1u5oNXrWsNXWtdM2i//0aAAAAAAAAAAAAAAAAAAAAAOCj+QsaoAFZACgAAA== +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-002151/tests/test.sh b/tasks/format-code-task-002151/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..e5e416ba977b739ab164e69c72af37a3bd3784e1 --- /dev/null +++ b/tasks/format-code-task-002151/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +pkg/util/logging/logger_test.go +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002151/tests/test_command.sh b/tasks/format-code-task-002151/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002151/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002156/environment/Dockerfile b/tasks/format-code-task-002156/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8ada0b5fd6bc74016cf7a816d7a728beae98bfe7 --- /dev/null +++ b/tasks/format-code-task-002156/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:a604bf328d28228ce0f04c0b032240e484f9991b8825eeec451954f62c731564 diff --git a/tasks/format-code-task-002156/environment/setup/files/blocklist b/tasks/format-code-task-002156/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002156/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002156/environment/setup/setup.sh b/tasks/format-code-task-002156/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002156/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002156/tests/test.patch b/tasks/format-code-task-002156/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..4c4b11fb5f16a2bd9e76592277ce5b5d3dfa2527 --- /dev/null +++ b/tasks/format-code-task-002156/tests/test.patch @@ -0,0 +1,131 @@ +diff --git a/pkg/cmd/experimental/syncgroups/groupdetector/groupdetector_test.go b/pkg/cmd/experimental/syncgroups/groupdetector/groupdetector_test.go +index 95eea02f5a..faffa28799 100644 +--- a/pkg/cmd/experimental/syncgroups/groupdetector/groupdetector_test.go ++++ b/pkg/cmd/experimental/syncgroups/groupdetector/groupdetector_test.go +@@ -43,9 +43,21 @@ func TestGroupBasedDetectorExists(t *testing.T) { + expectedExists: false, + }, + { +- name: "no error", ++ name: "no error, no entries", + groupGetter: &puppetGetterExtractor{}, + expectedErr: nil, ++ expectedExists: false, ++ }, ++ { ++ name: "no error, empty entries", ++ groupGetter: &puppetGetterExtractor{returnVal: []*ldap.Entry{}}, ++ expectedErr: nil, ++ expectedExists: false, ++ }, ++ { ++ name: "no error, has entries", ++ groupGetter: &puppetGetterExtractor{returnVal: []*ldap.Entry{dummyEntry}}, ++ expectedErr: nil, + expectedExists: true, + }, + } +@@ -129,23 +141,32 @@ func TestCompoundDetectorExists(t *testing.T) { + { + name: "none fail to locate", + locators: []interfaces.LDAPGroupDetector{ +- NewGroupBasedDetector(&puppetGetterExtractor{}), ++ NewGroupBasedDetector(&puppetGetterExtractor{returnVal: []*ldap.Entry{dummyEntry}}), + NewMemberBasedDetector(&puppetGetterExtractor{returnVal: []*ldap.Entry{dummyEntry}}), + }, + expectedErr: nil, + expectedExists: true, + }, + { +- name: "one fails to locate", ++ name: "one locator returns no entries", + locators: []interfaces.LDAPGroupDetector{ + NewGroupBasedDetector(&puppetGetterExtractor{}), + NewMemberBasedDetector(&puppetGetterExtractor{returnVal: []*ldap.Entry{dummyEntry}}), + }, + expectedErr: nil, +- expectedExists: true, ++ expectedExists: false, ++ }, ++ { ++ name: "one locator reports missing", ++ locators: []interfaces.LDAPGroupDetector{ ++ NewGroupBasedDetector(&errEntryNotFoundGetterExtractor{}), ++ NewMemberBasedDetector(&puppetGetterExtractor{returnVal: []*ldap.Entry{dummyEntry}}), ++ }, ++ expectedErr: nil, ++ expectedExists: false, + }, + { +- name: "all fail to locate", ++ name: "all fail to locate because of errors", + locators: []interfaces.LDAPGroupDetector{ + NewGroupBasedDetector(&errEntryNotFoundGetterExtractor{}), + NewMemberBasedDetector(&errOutOfBoundsGetterExtractor{}), +@@ -153,6 +174,15 @@ func TestCompoundDetectorExists(t *testing.T) { + expectedErr: nil, + expectedExists: false, + }, ++ { ++ name: "all locate no entries", ++ locators: []interfaces.LDAPGroupDetector{ ++ NewGroupBasedDetector(&puppetGetterExtractor{}), ++ NewMemberBasedDetector(&puppetGetterExtractor{returnVal: []*ldap.Entry{}}), ++ }, ++ expectedErr: nil, ++ expectedExists: false, ++ }, + { + name: "one errors", + locators: []interfaces.LDAPGroupDetector{ +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,46 @@ ++#!/bin/bash ++set -euo pipefail ++ ++cd /testbed ++ ++ ++ ++dev-switch go 1.24 2>/dev/null || true ++ ++ ++OS_ROOT=/testbed ++OS_OUTPUT="${OS_ROOT}/_output/local" ++OS_GOPATH="${OS_OUTPUT}/go" ++OS_GO_PACKAGE="github.com/openshift/origin" ++ ++mkdir -p "${OS_GOPATH}/src/github.com/openshift" ++ln -sf "${OS_ROOT}" "${OS_GOPATH}/src/${OS_GO_PACKAGE}" ++ ++ ++ ++if [ ! -d /testbed/.build_env/godeps_override/src/github.com/ugorji/go/codec ]; then ++ mkdir -p /testbed/.build_env/godeps_override/src/github.com/ugorji/go/codec ++ cp -r /testbed/Godeps/_workspace/src/github.com/ugorji/go/codec/* \ ++ /testbed/.build_env/godeps_override/src/github.com/ugorji/go/codec/ ++ sed -i 's|"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789__"|"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"|' \ ++ /testbed/.build_env/godeps_override/src/github.com/ugorji/go/codec/gen.go ++fi ++ ++export GO111MODULE=off ++export GOPATH="/testbed/.build_env/godeps_override:${OS_GOPATH}:${OS_ROOT}/Godeps/_workspace" ++ ++ ++PKG="github.com/openshift/origin/pkg/cmd/experimental/syncgroups/groupdetector" ++ ++case "${1:-}" in ++ base) ++ go test -count=1 -v -timeout 60s -run '^TestMemberBasedDetectorExists$' "$PKG" ++ ;; ++ new) ++ go test -count=1 -v -timeout 60s -run '^(TestGroupBasedDetectorExists|TestCompoundDetectorExists)$' "$PKG" ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-002156/tests/test.sh b/tasks/format-code-task-002156/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d8a4ca2d79d094c235e212d7a2938216e7f63a4a --- /dev/null +++ b/tasks/format-code-task-002156/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +pkg/cmd/experimental/syncgroups/groupdetector/groupdetector_test.go +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002156/tests/test_command.sh b/tasks/format-code-task-002156/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-002156/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh base && bash /testbed/mimo_test_command.sh new \ No newline at end of file diff --git a/tasks/format-code-task-002158/environment/Dockerfile b/tasks/format-code-task-002158/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a9cb9bbaa39af903dc73f948e59a61fbbfba7afd --- /dev/null +++ b/tasks/format-code-task-002158/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:b595fd4670bb6309fe385bff3dfe59910621b3aedf2475be36b50c3d853855bb diff --git a/tasks/format-code-task-002158/environment/setup/files/blocklist b/tasks/format-code-task-002158/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002158/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002158/environment/setup/setup.sh b/tasks/format-code-task-002158/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002158/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002158/tests/test.patch b/tasks/format-code-task-002158/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e38a3f72a5ba3427d5626cefefafb2d2cfc0d070 --- /dev/null +++ b/tasks/format-code-task-002158/tests/test.patch @@ -0,0 +1,57 @@ +diff --git a/pkg/cmd/cli/cmd/importimage_test.go b/pkg/cmd/cli/cmd/importimage_test.go +index b1d3206bf25f..1341ab8d38ed 100644 +--- a/pkg/cmd/cli/cmd/importimage_test.go ++++ b/pkg/cmd/cli/cmd/importimage_test.go +@@ -114,6 +114,24 @@ func TestCreateImageImport(t *testing.T) { + }, + }, + }, ++ { ++ ++ name: "testis:latest", ++ stream: &imageapi.ImageStream{ ++ ObjectMeta: kapi.ObjectMeta{ ++ Name: "testis", ++ Namespace: "other", ++ }, ++ Spec: imageapi.ImageStreamSpec{ ++ Tags: map[string]imageapi.TagReference{ ++ "nonlatest": { ++ From: &kapi.ObjectReference{Kind: "DockerImage", Name: "repo.com/somens/someimage:latest"}, ++ }, ++ }, ++ }, ++ }, ++ err: "does not exist on the image stream", ++ }, + } + + for idx, test := range testCases { +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,12 @@ ++H4sIAAAAAAAAA+2UXU/bMBSGe51fcQYXwFCSJjRlm8QFYwzY+Noo+7qpUttNTBPb80dL9+vnFEQR ++GyAm0DTtPBdxFPs9Pn7PcaKB4xXtMzGOW09F27OeZbPRc3OcvSdZmqRJO8myTqudJNl61oLsyTK6 ++hjM21wAtLaW9a9198/8o0bz+lhnbJ7Kuc0EjUz7eHvfUP213k3n909TXv9Ntr7Wg/Xgp3M5/Xv/F ++Z/GAi3iQmzIwzELInATFFRvmvAoIhVlbDBgNgkU4mXBLSrASdiQkUboGy7bkBoikzEdgoDSjuRc0 ++87WkrmJmJaBsHJoLZXEhCwJ2rqS2sHOUJMnB0ZvT/e0NORzO9vBJOOVnjjd7u2CsdsQ6zcAHKMFM ++64qLUVCPKNcQqqvs4r50VjkbFzI2msSFX+0Gke/mWComTMmHNqgEhGZ4pXmQOJaaF1w0GfZKBrKi ++cG2ZK6Q+442+sYIAF94BypQBlQtODEhxaVm6CgNGcmeYj9R41u1Eh2yyLbyQiwI0O2PEGqBOVZx4 ++L4GUuc6JZdpEsCXVFLhtKpBDyYuS6VBp7nOzUx/v0jQmrJ6Cv8Uw5OdgfbrzaE5QH4lIzaIHuXjj ++hAFREOZz4cVp4/5E6pFROWH36OPnke+Fh+8b+yalEHJYMvE125YXNl9vvdl+u7O79+79/sHh0fGH ++jye900+fv3z9lg8IZcOi5GejqhZSfdfGuvHkfPqjnaRrnay7/uJlv7+w8qjxVn28pT85X8GEd+ba ++BWkquvGbQK9u9z4IvLfNLIREOmE3EgjHEGonoOe/bmnmO2Gvzgv/mO1yR8PHalTEpKYxqXgzBn/7 ++h4UgCIIgCIIgCIIgCIIgCIIgCIIgCIIgyC/8BNTiDfoAKAAA +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-002158/tests/test.sh b/tasks/format-code-task-002158/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..42ffe5468ce06cf83c69bce9f9582446e30e95be --- /dev/null +++ b/tasks/format-code-task-002158/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +pkg/cmd/cli/cmd/importimage_test.go +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002158/tests/test_command.sh b/tasks/format-code-task-002158/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002158/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002160/environment/Dockerfile b/tasks/format-code-task-002160/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f3d0d97a49b805cfb91afdd28a38b3a2efb796c7 --- /dev/null +++ b/tasks/format-code-task-002160/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:d46408a799bc3bc689a22fc556f225fcbedaec6431a3e92ddceb83a3bb82db5b diff --git a/tasks/format-code-task-002160/environment/setup/files/blocklist b/tasks/format-code-task-002160/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002160/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002160/environment/setup/setup.sh b/tasks/format-code-task-002160/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002160/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002160/tests/test.patch b/tasks/format-code-task-002160/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..69f8056fb7cec34a790e06c8d967bd99251d8247 --- /dev/null +++ b/tasks/format-code-task-002160/tests/test.patch @@ -0,0 +1,81 @@ +diff --git a/openwisp_radius/tests/test_commands.py b/openwisp_radius/tests/test_commands.py +index 22fce5ef..f28a9504 100644 +--- a/openwisp_radius/tests/test_commands.py ++++ b/openwisp_radius/tests/test_commands.py +@@ -291,7 +291,7 @@ def test_convert_called_station_id_command(self, *args): + radius_acc = self._create_radius_accounting(**options) + + with self.subTest('Test telnet connection error'): +- with patch('logging.Logger.error') as mocked_logger: ++ with patch('logging.Logger.warning') as mocked_logger: + call_command('convert_called_station_id') + mocked_logger.assert_called_once_with( + 'Unable to establish telnet connection to 127.0.0.1 on 7505. ' +@@ -299,7 +299,7 @@ def test_convert_called_station_id_command(self, *args): + ) + + with self.subTest('Test telnet raises OSError'): +- with patch('logging.Logger.error') as mocked_logger, patch( ++ with patch('logging.Logger.warning') as mocked_logger, patch( + 'openwisp_radius.management.commands.base.convert_called_station_id' + '.BaseConvertCalledStationIdCommand._get_raw_management_info', + side_effect=OSError('[Errno 113] No route to host'), +@@ -311,14 +311,15 @@ def test_convert_called_station_id_command(self, *args): + ) + + with self.subTest('Test telnet connection timed out'): +- with patch('logging.Logger.exception') as mocked_logger, patch( ++ with patch('logging.Logger.warning') as mocked_logger, patch( + 'openwisp_radius.management.commands.base.convert_called_station_id' + '.BaseConvertCalledStationIdCommand._get_raw_management_info', +- side_effect=EOFError, ++ side_effect=EOFError('EOFError'), + ): + call_command('convert_called_station_id') + mocked_logger.assert_called_once_with( +- 'Error encountered while connecting to 127.0.0.1:7505. ' 'Skipping!' ++ 'Error encountered while connecting to 127.0.0.1:7505: ' ++ 'EOFError. Skipping!' + ) + + with self.subTest('Test telnet password incorrect'): +@@ -354,7 +355,7 @@ def test_convert_called_station_id_command(self, *args): + 'openwisp_radius.management.commands.base.convert_called_station_id' + '.BaseConvertCalledStationIdCommand._get_openvpn_routing_info', + return_value={options['calling_station_id']: dummy_routing_obj}, +- ), patch('logging.Logger.warn') as mocked_logger: ++ ), patch('logging.Logger.warning') as mocked_logger: + call_command('convert_called_station_id') + mocked_logger.assert_called_once_with( + f'Failed to find a MAC address in "{dummy_routing_obj.common_name}"' +@@ -366,7 +367,7 @@ def test_convert_called_station_id_command(self, *args): + 'openwisp_radius.management.commands.base.convert_called_station_id' + '.BaseConvertCalledStationIdCommand._get_openvpn_routing_info', + return_value={'dd:dd:dd:dd:dd:dd': Routing()}, +- ), patch('logging.Logger.warn') as mocked_logger: ++ ), patch('logging.Logger.warning') as mocked_logger: + call_command('convert_called_station_id') + mocked_logger.assert_called_once_with( + f'Failed to find routing information for {radius_acc.session_id}.' +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,6 @@ ++H4sIAAAAAAAAA+3SUWvCMBAHcJ/9FIcM34ymtgqCD4KiDldFq7CnUm3RjpmUJrrt268G6kTYfKmM ++sf/vJe3lehd6YetD/Br6kTjWS/fSyLQdx6yZ69U8c8fivG1zp5nFOW9lIXLudqILB6WDlKiUSql/ ++yru1/0exr/nrSGl/I/f7QIRM7YrrcWv+Tad9nr9tZ3ncblmtEjWKO8L3/vn8NyGZwa+jsBy9JzLV ++NOt5o24lj9bZ8XQ51rHoPJx2Knnaajz3lr2JP3BX19mVclb2FFFUrVL/secOp/5i4Hljd7jwn6b9 ++5WTQlUkk3mKVWExFWsdiq2j27I2mrul/LmjKdPJXSj70Tgqq7Sl8CcRWmjaU1/LTIIwPipmP2OWF ++VlQ7klX+7d8NAAAAAAAAAAAAAAAAAAAAAFCoT494HDcAKAAA +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-002160/tests/test.sh b/tasks/format-code-task-002160/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..a8db00d947f79b5a4f10ef6a668a46c483f28a15 --- /dev/null +++ b/tasks/format-code-task-002160/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +openwisp_radius/tests/test_commands.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002160/tests/test_command.sh b/tasks/format-code-task-002160/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002160/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002169/environment/Dockerfile b/tasks/format-code-task-002169/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7d34974f510d0989f9cf8c9d4675b08aa774cbcb --- /dev/null +++ b/tasks/format-code-task-002169/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:a3d1bda5bc0c2f4a4752d0692ba65f6cb2b25e0fb52a8f6d23e42a911954c832 diff --git a/tasks/format-code-task-002169/environment/setup/files/blocklist b/tasks/format-code-task-002169/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002169/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002169/environment/setup/setup.sh b/tasks/format-code-task-002169/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002169/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002169/tests/test.patch b/tasks/format-code-task-002169/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..a286a9cea5af64e49175a7408d84c61c92ff1644 --- /dev/null +++ b/tasks/format-code-task-002169/tests/test.patch @@ -0,0 +1,339 @@ +diff --git a/backend/tests/unit/graphql/test_graphql_query.py b/backend/tests/unit/graphql/test_graphql_query.py +index e840f030b..9c61b045a 100644 +--- a/backend/tests/unit/graphql/test_graphql_query.py ++++ b/backend/tests/unit/graphql/test_graphql_query.py +@@ -5,6 +5,7 @@ from graphql import graphql + from infrahub.core import registry + from infrahub.core.branch import Branch + from infrahub.core.constants import BranchSupportType ++from infrahub.core.initialization import create_branch + from infrahub.core.manager import NodeManager + from infrahub.core.node import Node + from infrahub.core.schema import NodeSchema +@@ -527,6 +528,257 @@ async def test_display_label_nested_query(db, session, default_branch: Branch, c + assert DeepDiff(result.data["TestPerson"]["edges"][0]["node"], expected_result, ignore_order=True).to_dict() == {} + + ++async def _execute_diff_summary( ++ db, ++ session, ++ branch: Branch, ++ branch_only: bool | None = None, ++ time_from: str | None = None, ++ time_to: str | None = None, ++) -> list[dict]: ++ arguments = [] ++ variables = {} ++ variable_definitions = [] ++ ++ if branch_only is not None: ++ arguments.append("branch_only: $branch_only") ++ variables["branch_only"] = branch_only ++ variable_definitions.append("$branch_only: Boolean") ++ if time_from is not None: ++ arguments.append("time_from: $time_from") ++ variables["time_from"] = time_from ++ variable_definitions.append("$time_from: String") ++ if time_to is not None: ++ arguments.append("time_to: $time_to") ++ variables["time_to"] = time_to ++ variable_definitions.append("$time_to: String") ++ ++ arguments_source = f"({', '.join(arguments)})" if arguments else "" ++ variables_source = f"({', '.join(variable_definitions)})" if variable_definitions else "" ++ ++ query = f""" ++ query {variables_source} {{ ++ DiffSummary{arguments_source} {{ ++ branch ++ node ++ kind ++ actions ++ }} ++ }} ++ """ ++ ++ result = await graphql( ++ await generate_graphql_schema( ++ session=session, branch=branch, include_mutation=False, include_subscription=False ++ ), ++ source=query, ++ context_value={"infrahub_session": session, "infrahub_database": db, "infrahub_branch": branch}, ++ root_value=None, ++ variable_values=variables, ++ ) ++ ++ assert result.errors is None ++ assert result.data ++ return result.data["DiffSummary"] ++ ++ ++def _summary_by_branch_and_node(diff_summary: list[dict]) -> dict[tuple[str, str], dict]: ++ return {(entry["branch"], entry["node"]): entry for entry in diff_summary} ++ ++ ++def _assert_summary_entry( ++ diff_summary: list[dict], ++ *, ++ branch: str, ++ node: str, ++ kind: str, ++ action: str, ++) -> None: ++ entries = _summary_by_branch_and_node(diff_summary) ++ assert (branch, node) in entries ++ entry = entries[(branch, node)] ++ assert entry["branch"] == branch ++ assert entry["node"] == node ++ assert entry["kind"] == kind ++ assert action in entry["actions"] ++ ++ ++async def test_query_diffsummary_returns_node_level_entries(db, session, default_branch: Branch, car_person_schema): ++ car = registry.get_schema(name="TestCar") ++ person = registry.get_schema(name="TestPerson") ++ ++ p1_main = await Node.init(session=session, schema=person) ++ await p1_main.new(session=session, name="Summary Person One", height=180) ++ await p1_main.save(session=session) ++ p2_main = await Node.init(session=session, schema=person) ++ await p2_main.new(session=session, name="Summary Person Two", height=170) ++ await p2_main.save(session=session) ++ ++ c1_main = await Node.init(session=session, schema=car) ++ await c1_main.new(session=session, name="summary-car-removed", nbr_seats=4, is_electric=True, owner=p1_main) ++ await c1_main.save(session=session) ++ c2_main = await Node.init(session=session, schema=car) ++ await c2_main.new(session=session, name="summary-car-updated", nbr_seats=4, is_electric=True, owner=p1_main) ++ await c2_main.save(session=session) ++ ++ branch2 = await create_branch(branch_name="diffsummary-node-level", session=session) ++ ++ await c1_main.delete(session=session) ++ ++ p1_branch2 = await NodeManager.get_one_by_id_or_default_filter( ++ id=p1_main.id, session=session, schema_name="TestPerson", branch=branch2 ++ ) ++ p1_branch2.name.value = "Summary Person One Branch" ++ await p1_branch2.save(session=session) ++ ++ c2_main.name.value = "summary-car-updated-main" ++ await c2_main.save(session=session) ++ ++ diff_summary = await _execute_diff_summary(db=db, session=session, branch=branch2) ++ ++ _assert_summary_entry( ++ diff_summary, ++ branch="main", ++ node=c1_main.id, ++ kind="TestCar", ++ action="removed", ++ ) ++ _assert_summary_entry( ++ diff_summary, ++ branch="main", ++ node=c2_main.id, ++ kind="TestCar", ++ action="updated", ++ ) ++ _assert_summary_entry( ++ diff_summary, ++ branch="diffsummary-node-level", ++ node=p1_branch2.id, ++ kind="TestPerson", ++ action="updated", ++ ) ++ ++ ++async def test_query_diffsummary_honors_branch_only(db, session, default_branch: Branch, car_person_schema): ++ car = registry.get_schema(name="TestCar") ++ person = registry.get_schema(name="TestPerson") ++ ++ p_main = await Node.init(session=session, schema=person) ++ await p_main.new(session=session, name="Branch Only Person", height=181) ++ await p_main.save(session=session) ++ c_main = await Node.init(session=session, schema=car) ++ await c_main.new(session=session, name="branch-only-car", nbr_seats=2, is_electric=False, owner=p_main) ++ await c_main.save(session=session) ++ ++ branch2 = await create_branch(branch_name="diffsummary-branch-only", session=session) ++ ++ p_branch2 = await NodeManager.get_one_by_id_or_default_filter( ++ id=p_main.id, session=session, schema_name="TestPerson", branch=branch2 ++ ) ++ p_branch2.name.value = "Branch Only Person Updated On Branch" ++ await p_branch2.save(session=session) ++ ++ c_main.name.value = "branch-only-car-updated-on-main" ++ await c_main.save(session=session) ++ ++ default_summary = await _execute_diff_summary(db=db, session=session, branch=branch2) ++ branch_only_summary = await _execute_diff_summary(db=db, session=session, branch=branch2, branch_only=True) ++ ++ default_entries = _summary_by_branch_and_node(default_summary) ++ branch_only_entries = _summary_by_branch_and_node(branch_only_summary) ++ ++ assert ("main", c_main.id) in default_entries ++ assert ("diffsummary-branch-only", p_branch2.id) in default_entries ++ ++ assert ("diffsummary-branch-only", p_branch2.id) in branch_only_entries ++ assert all(entry["branch"] == "diffsummary-branch-only" for entry in branch_only_summary) ++ assert ("main", c_main.id) not in branch_only_entries ++ ++ ++async def test_query_diffsummary_honors_time_window(db, session, default_branch: Branch, car_person_schema): ++ person = registry.get_schema(name="TestPerson") ++ ++ p_main = await Node.init(session=session, schema=person) ++ await p_main.new(session=session, name="Time Window Person", height=165) ++ await p_main.save(session=session) ++ ++ branch2 = await create_branch(branch_name="diffsummary-time-window", session=session) ++ ++ p_branch2 = await NodeManager.get_one_by_id_or_default_filter( ++ id=p_main.id, session=session, schema_name="TestPerson", branch=branch2 ++ ) ++ p_branch2.height.value = 166 ++ await p_branch2.save(session=session) ++ ++ default_summary = await _execute_diff_summary(db=db, session=session, branch=branch2, branch_only=True) ++ _assert_summary_entry( ++ default_summary, ++ branch="diffsummary-time-window", ++ node=p_branch2.id, ++ kind="TestPerson", ++ action="updated", ++ ) ++ ++ future_window_summary = await _execute_diff_summary( ++ db=db, ++ session=session, ++ branch=branch2, ++ branch_only=True, ++ time_from="2100-01-01T00:00:00Z", ++ time_to="2100-01-02T00:00:00Z", ++ ) ++ past_window_summary = await _execute_diff_summary( ++ db=db, ++ session=session, ++ branch=branch2, ++ branch_only=True, ++ time_from="1970-01-01T00:00:00Z", ++ time_to="1970-01-02T00:00:00Z", ++ ) ++ ++ assert ("diffsummary-time-window", p_branch2.id) not in _summary_by_branch_and_node(future_window_summary) ++ assert ("diffsummary-time-window", p_branch2.id) not in _summary_by_branch_and_node(past_window_summary) ++ ++ ++async def test_query_diffsummary_includes_relationship_only_node_as_updated( ++ db, session, default_branch: Branch, car_person_schema ++): ++ car = registry.get_schema(name="TestCar") ++ person = registry.get_schema(name="TestPerson") ++ ++ p1_main = await Node.init(session=session, schema=person) ++ await p1_main.new(session=session, name="Relationship Owner One", height=180) ++ await p1_main.save(session=session) ++ p2_main = await Node.init(session=session, schema=person) ++ await p2_main.new(session=session, name="Relationship Owner Two", height=170) ++ await p2_main.save(session=session) ++ ++ c_main = await Node.init(session=session, schema=car) ++ await c_main.new(session=session, name="relationship-only-car", nbr_seats=4, is_electric=True, owner=p1_main) ++ await c_main.save(session=session) ++ ++ branch2 = await create_branch(branch_name="diffsummary-relationship-only", session=session) ++ c_branch2 = await NodeManager.get_one_by_id_or_default_filter( ++ id=c_main.id, session=session, schema_name="TestCar", branch=branch2 ++ ) ++ p2_branch2 = await NodeManager.get_one_by_id_or_default_filter( ++ id=p2_main.id, session=session, schema_name="TestPerson", branch=branch2 ++ ) ++ ++ await c_branch2.owner.update(data=p2_branch2.id, session=session) ++ await c_branch2.save(session=session) ++ ++ diff_summary = await _execute_diff_summary(db=db, session=session, branch=branch2, branch_only=True) ++ ++ _assert_summary_entry( ++ diff_summary, ++ branch="diffsummary-relationship-only", ++ node=c_branch2.id, ++ kind="TestCar", ++ action="updated", ++ ) ++ ++ + async def test_query_typename(db, session, default_branch: Branch, car_person_schema): + car = registry.get_schema(name="TestCar") + person = registry.get_schema(name="TestPerson") +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,64 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++ ++ ++if ! neo4j status >/dev/null 2>&1; then ++ neo4j start ++ sleep 8 ++fi ++ ++ ++export INFRAHUB_DB_TYPE=neo4j ++ ++ ++neo4j_bolt_ready() { ++ python3 - <<'PY' ++import socket ++with socket.socket() as sock: ++ sock.settimeout(1) ++ sock.connect(("127.0.0.1", 7687)) ++PY ++} ++ ++if ! neo4j_bolt_ready >/dev/null 2>&1; then ++ neo4j stop >/dev/null 2>&1 || true ++ pid_file="/var/lib/neo4j/run/neo4j.pid" ++ if [ -f "$pid_file" ]; then ++ pid="$(cat "$pid_file" 2>/dev/null || true)" ++ if [ -n "$pid" ] && ps -p "$pid" >/dev/null 2>&1; then ++ kill "$pid" >/dev/null 2>&1 || true ++ sleep 2 ++ fi ++ rm -f "$pid_file" ++ fi ++ neo4j start ++fi ++ ++for _ in $(seq 1 60); do ++ if neo4j_bolt_ready >/dev/null 2>&1; then ++ break ++ fi ++ sleep 1 ++done ++ ++if ! neo4j_bolt_ready >/dev/null 2>&1; then ++ echo "Neo4j Bolt port 7687 did not become ready" >&2 ++ exit 1 ++fi ++ ++DIFFSUMMARY_TESTS="test_query_diffsummary_returns_node_level_entries or test_query_diffsummary_honors_branch_only or test_query_diffsummary_honors_time_window or test_query_diffsummary_includes_relationship_only_node_as_updated" ++ ++case "${1:-}" in ++ base) ++ python3 -m pytest backend/tests/unit/graphql/test_graphql_query.py -v -k "not (${DIFFSUMMARY_TESTS})" ++ ;; ++ new) ++ python3 -m pytest backend/tests/unit/graphql/test_graphql_query.py -v -k "(${DIFFSUMMARY_TESTS})" ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-002169/tests/test.sh b/tasks/format-code-task-002169/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..42cabf936cad51458cf35c023fbfbc4950feec27 --- /dev/null +++ b/tasks/format-code-task-002169/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +backend/tests/unit/graphql/test_graphql_query.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002169/tests/test_command.sh b/tasks/format-code-task-002169/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-002169/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh base && bash /testbed/mimo_test_command.sh new \ No newline at end of file diff --git a/tasks/format-code-task-002211/environment/Dockerfile b/tasks/format-code-task-002211/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..34abd14982f4f15937ed5883c1097ab900b5d424 --- /dev/null +++ b/tasks/format-code-task-002211/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:6f1c116977aa179dbd13496e571614970607dd2a68b62045162df92b7daec2bb diff --git a/tasks/format-code-task-002211/environment/setup/files/blocklist b/tasks/format-code-task-002211/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002211/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002211/environment/setup/setup.sh b/tasks/format-code-task-002211/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002211/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002211/tests/test.patch b/tasks/format-code-task-002211/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..90a14f0d2de524be9e393427d872981899c919ff --- /dev/null +++ b/tasks/format-code-task-002211/tests/test.patch @@ -0,0 +1,95 @@ +diff --git a/pandas/tests/plotting/test_frame.py b/pandas/tests/plotting/test_frame.py +index 9ab697cb57..eb000b191f 100644 +--- a/pandas/tests/plotting/test_frame.py ++++ b/pandas/tests/plotting/test_frame.py +@@ -205,6 +205,68 @@ class TestDataFramePlots(TestPlotBase): + with pytest.raises(ValueError): + df.plot(color=["red", "black"], style=["k-", "r--"]) + ++ def test_color_and_marker_style_issue21003(self): ++ ++ ++ df = DataFrame(np.random.random((7, 4))) ++ ++ ax = df.plot(color="green", style="d") ++ for line in ax.get_lines(): ++ assert line.get_color() == "green" ++ assert line.get_marker() == "d" ++ ++ @pytest.mark.parametrize("marker", ["d", "h", "o", "p", "s", "v", "x"]) ++ def test_color_list_with_marker_style(self, marker): ++ ++ ++ df = DataFrame(np.random.random((7, 4))) ++ colors = ["red", "blue", "green", "orange"] ++ ax = df.plot(color=colors, style=marker + "-") ++ line_colors = [line.get_color() for line in ax.get_lines()] ++ assert line_colors == colors ++ for line in ax.get_lines(): ++ assert line.get_marker() == marker ++ assert line.get_linestyle() == "-" ++ ++ def test_subplots_with_marker_style(self): ++ ++ ++ df = DataFrame(np.random.random((7, 4))) ++ axes = df.plot(subplots=True, style="d-") ++ line_colors = [] ++ for ax in axes: ++ lines = ax.get_lines() ++ assert len(lines) == 1 ++ line_colors.append(lines[0].get_color()) ++ assert lines[0].get_marker() == "d" ++ ++ assert len(set(line_colors)) == len(line_colors) ++ ++ def test_colormap_with_marker_style(self): ++ ++ ++ df = DataFrame(np.random.random((7, 4))) ++ ax_cmap = df.plot(colormap="jet", style="d-") ++ ++ ++ ++ cmap_colors = [line.get_color() for line in ax_cmap.get_lines()] ++ ++ assert len({tuple(c) if not isinstance(c, str) else c ++ for c in cmap_colors}) == len(cmap_colors) ++ ++ first = cmap_colors[0] ++ ++ ++ assert not (isinstance(first, str) and first == "#1f77b4") ++ ++ def test_color_and_style_color_letter_still_raises(self): ++ ++ ++ df = DataFrame(np.random.random((7, 4))) ++ with pytest.raises(ValueError): ++ df.plot(color="green", style="b-") ++ + def test_nonnumeric_exclude(self): + df = DataFrame({"A": ["x", "y", "z"], "B": [1, 2, 3]}) + ax = df.plot() +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000000..9eaf4f4d89 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest pandas/tests/plotting/test_frame.py -k \"issue21003 or marker_style or color_letter_still\""] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m pytest pandas/tests/plotting/test_frame.py -k "issue21003 or marker_style or color_letter_still" ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002211/tests/test.sh b/tasks/format-code-task-002211/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d2877252fde9870a9708201b89da0b97764160f8 --- /dev/null +++ b/tasks/format-code-task-002211/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +pandas/tests/plotting/test_frame.py +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002211/tests/test_command.sh b/tasks/format-code-task-002211/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002211/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002218/environment/Dockerfile b/tasks/format-code-task-002218/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..17627f72840e0b7b95f4c7465c8cfa5ffc8d7200 --- /dev/null +++ b/tasks/format-code-task-002218/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:3693ffd91ef5d66ea19dfb26e316e65a63f6cacd1288cf5713bf36594ef969b0 diff --git a/tasks/format-code-task-002218/environment/setup/files/blocklist b/tasks/format-code-task-002218/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002218/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002218/environment/setup/setup.sh b/tasks/format-code-task-002218/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002218/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002218/tests/test.patch b/tasks/format-code-task-002218/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..c5662b3e79921459b78547214f3131c3c7231151 --- /dev/null +++ b/tasks/format-code-task-002218/tests/test.patch @@ -0,0 +1,135 @@ +diff --git a/pandas/tests/indexing/multiindex/test_single_level_multiindex_columns.py b/pandas/tests/indexing/multiindex/test_single_level_multiindex_columns.py +new file mode 100644 +index 0000000000..c19ee13f8a +--- /dev/null ++++ b/pandas/tests/indexing/multiindex/test_single_level_multiindex_columns.py +@@ -0,0 +1,107 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++import numpy as np ++import pytest ++ ++import pandas as pd ++from pandas import DataFrame, Index, MultiIndex, Series ++import pandas._testing as tm ++ ++ ++def _make_single_level_mi_df(): ++ names = ["FirstColumn", "SecondColumn"] ++ data = np.array([[5, 6], [7, 8]]) ++ return DataFrame(data, columns=[names]) ++ ++ ++class TestSingleLevelMultiIndexColumns: ++ def test_columns_is_multiindex_single_level(self): ++ ++ df = _make_single_level_mi_df() ++ assert isinstance(df.columns, MultiIndex) ++ assert df.columns.nlevels == 1 ++ ++ def test_getitem_returns_dataframe(self): ++ ++ ++ df = _make_single_level_mi_df() ++ result = df["FirstColumn"] ++ assert isinstance(result, DataFrame) ++ assert result.shape == (2, 1) ++ ++ assert result.values.ravel().tolist() == [5, 7] ++ ++ assert isinstance(result.columns, MultiIndex) ++ ++ def test_getattr_returns_dataframe(self): ++ ++ df = _make_single_level_mi_df() ++ result = df.FirstColumn ++ assert isinstance(result, DataFrame) ++ assert result.shape == (2, 1) ++ assert result.values.ravel().tolist() == [5, 7] ++ ++ def test_loc_returns_dataframe(self): ++ ++ df = _make_single_level_mi_df() ++ result = df.loc[:, "FirstColumn"] ++ assert isinstance(result, DataFrame) ++ assert result.shape == (2, 1) ++ assert result.values.ravel().tolist() == [5, 7] ++ ++ def test_getitem_second_column(self): ++ ++ df = _make_single_level_mi_df() ++ result = df["SecondColumn"] ++ assert isinstance(result, DataFrame) ++ assert result.shape == (2, 1) ++ assert result.values.ravel().tolist() == [6, 8] ++ ++ def test_getitem_missing_key_raises_keyerror(self): ++ ++ df = _make_single_level_mi_df() ++ with pytest.raises(KeyError): ++ df["NonExistent"] ++ ++ def test_regular_index_returns_series_unchanged(self): ++ ++ ++ df = DataFrame([[1, 2], [3, 4]], columns=["a", "b"]) ++ result = df["a"] ++ assert isinstance(result, Series) ++ assert result.tolist() == [1, 3] ++ ++ def test_multi_level_multiindex_unchanged(self): ++ ++ ++ df = DataFrame( ++ [[1, 2, 3, 4]], ++ columns=MultiIndex.from_tuples( ++ [("A", "x"), ("A", "y"), ("B", "x"), ("B", "y")] ++ ), ++ ) ++ result = df["A"] ++ assert isinstance(result, DataFrame) ++ assert result.shape == (1, 2) ++ assert list(result.columns) == ["x", "y"] ++ ++ def test_getitem_does_not_raise_typeerror(self): ++ ++ ++ ++ df = _make_single_level_mi_df() ++ try: ++ df["FirstColumn"] ++ except TypeError as exc: # pragma: no cover - guard ++ pytest.fail(f"unexpected TypeError: {exc}") +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000000..1ed9748f44 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest pandas/tests/indexing/multiindex/test_single_level_multiindex_columns.py -v"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m pytest pandas/tests/indexing/multiindex/test_single_level_multiindex_columns.py -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002218/tests/test.sh b/tasks/format-code-task-002218/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..6bb0331e2c50ad96fb3e7389b4849fe714225631 --- /dev/null +++ b/tasks/format-code-task-002218/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +pandas/tests/indexing/multiindex/test_single_level_multiindex_columns.py +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002218/tests/test_command.sh b/tasks/format-code-task-002218/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002218/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002220/environment/Dockerfile b/tasks/format-code-task-002220/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..256eca57b4e3cb0e8e8a11f1d0bc7bdbe2f26b7d --- /dev/null +++ b/tasks/format-code-task-002220/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:540d6c4db5bd1bcb222248317e596f52437eb73da4756a2ae1d3fbe7091dce00 diff --git a/tasks/format-code-task-002220/environment/setup/files/blocklist b/tasks/format-code-task-002220/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002220/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002220/environment/setup/setup.sh b/tasks/format-code-task-002220/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002220/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002220/tests/test.patch b/tasks/format-code-task-002220/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..be49c45bcf0259bca2ba306d5f9bcbac3667ac44 --- /dev/null +++ b/tasks/format-code-task-002220/tests/test.patch @@ -0,0 +1,127 @@ +diff --git a/pandas/tests/io/excel/test_openpyxl.py b/pandas/tests/io/excel/test_openpyxl.py +index 640501baff..cc22795a76 100644 +--- a/pandas/tests/io/excel/test_openpyxl.py ++++ b/pandas/tests/io/excel/test_openpyxl.py +@@ -149,3 +149,100 @@ def test_read_with_bad_dimension(datapath, ext, header, expected_data, filename) + result = pd.read_excel(path, header=header) + expected = DataFrame(expected_data) + tm.assert_frame_equal(result, expected) ++ ++ ++def test_append_mode_file_not_corrupted_empty_df(ext): ++ ++ import os ++ ++ df = DataFrame() ++ with tm.ensure_clean(ext) as f: ++ with ExcelWriter(f, mode="w", engine="openpyxl") as writer: ++ df.to_excel(writer) ++ size_after_w = os.path.getsize(f) ++ ++ with ExcelWriter(f, mode="a", engine="openpyxl") as writer: ++ df.to_excel(writer, sheet_name="Sheet2") ++ size_after_a = os.path.getsize(f) ++ ++ ++ ++ ++ assert size_after_a < size_after_w * 1.5, ( ++ f"File bloated after append: {size_after_w} -> {size_after_a}" ++ ) ++ ++ ++def test_append_mode_file_size_matches_fresh_write(ext): ++ ++ ++ import os ++ ++ df = DataFrame({"A": [1, 2, 3]}) ++ ++ with tm.ensure_clean(ext) as f_appended: ++ with ExcelWriter(f_appended, mode="w", engine="openpyxl") as writer: ++ df.to_excel(writer, sheet_name="S1") ++ with ExcelWriter(f_appended, mode="a", engine="openpyxl") as writer: ++ df.to_excel(writer, sheet_name="S2") ++ size_appended = os.path.getsize(f_appended) ++ ++ with tm.ensure_clean(ext) as f_fresh: ++ with ExcelWriter(f_fresh, mode="w", engine="openpyxl") as writer: ++ df.to_excel(writer, sheet_name="S1") ++ df.to_excel(writer, sheet_name="S2") ++ size_fresh = os.path.getsize(f_fresh) ++ ++ ++ assert size_appended < size_fresh * 1.2, ( ++ f"Append-mode file larger than expected: fresh={size_fresh}, " ++ f"appended={size_appended}" ++ ) ++ ++ ++def test_append_mode_repeated_appends_no_bloat(ext): ++ ++ import os ++ ++ df = DataFrame({"A": [1]}) ++ with tm.ensure_clean(ext) as f: ++ with ExcelWriter(f, mode="w", engine="openpyxl") as writer: ++ df.to_excel(writer, sheet_name="S0") ++ size_initial = os.path.getsize(f) ++ ++ for i in range(1, 4): ++ with ExcelWriter(f, mode="a", engine="openpyxl") as writer: ++ df.to_excel(writer, sheet_name=f"S{i}") ++ ++ size_final = os.path.getsize(f) ++ ++ ++ with tm.ensure_clean(ext) as f_fresh: ++ with ExcelWriter(f_fresh, mode="w", engine="openpyxl") as writer: ++ for i in range(4): ++ df.to_excel(writer, sheet_name=f"S{i}") ++ size_fresh = os.path.getsize(f_fresh) ++ ++ ++ ++ assert size_final < size_fresh * 1.5, ( ++ f"Repeated appends bloated file: fresh={size_fresh}, " ++ f"after_appends={size_final}" ++ ) ++ ++ ++def test_append_mode_data_readable(ext): ++ ++ df1 = DataFrame({"A": [1, 2, 3]}) ++ df2 = DataFrame({"B": [4, 5, 6]}) ++ ++ with tm.ensure_clean(ext) as f: ++ with ExcelWriter(f, mode="w", engine="openpyxl") as writer: ++ df1.to_excel(writer, sheet_name="S1", index=False) ++ with ExcelWriter(f, mode="a", engine="openpyxl") as writer: ++ df2.to_excel(writer, sheet_name="S2", index=False) ++ ++ sheets = pd.read_excel(f, sheet_name=None) ++ assert set(sheets.keys()) == {"S1", "S2"} ++ tm.assert_frame_equal(sheets["S1"], df1) ++ tm.assert_frame_equal(sheets["S2"], df2) +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000000..f802b9870d +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest pandas/tests/io/excel/test_openpyxl.py -k 'append_mode_file_not_corrupted_empty_df or append_mode_file_size_matches_fresh_write or append_mode_repeated_appends_no_bloat or append_mode_data_readable' -v"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m pytest pandas/tests/io/excel/test_openpyxl.py -k 'append_mode_file_not_corrupted_empty_df or append_mode_file_size_matches_fresh_write or append_mode_repeated_appends_no_bloat or append_mode_data_readable' -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002220/tests/test.sh b/tasks/format-code-task-002220/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..ea093bca199086028dc38c42249016bf59a1634f --- /dev/null +++ b/tasks/format-code-task-002220/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +pandas/tests/io/excel/test_openpyxl.py +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002220/tests/test_command.sh b/tasks/format-code-task-002220/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002220/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002330/environment/Dockerfile b/tasks/format-code-task-002330/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b1282ac66f661bb70ef7639661728ef6d4da8f3f --- /dev/null +++ b/tasks/format-code-task-002330/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:bbbf3d566727bee14a07b861e60290c31b5b9128e1936db8fad19adfe8b38b0c diff --git a/tasks/format-code-task-002330/environment/setup/files/blocklist b/tasks/format-code-task-002330/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002330/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002330/environment/setup/setup.sh b/tasks/format-code-task-002330/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002330/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002330/tests/test.patch b/tasks/format-code-task-002330/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..71e7f8b3d39fe384d60b009c47e978ce05e5a79b --- /dev/null +++ b/tasks/format-code-task-002330/tests/test.patch @@ -0,0 +1,36 @@ +diff --git a/tests/html_prettier_ignore/__snapshots__/jsfmt.spec.js.snap b/tests/html_prettier_ignore/__snapshots__/jsfmt.spec.js.snap +index 4ad95c841172..a2a76a996b3f 100644 +--- a/tests/html_prettier_ignore/__snapshots__/jsfmt.spec.js.snap ++++ b/tests/html_prettier_ignore/__snapshots__/jsfmt.spec.js.snap +@@ -14,8 +14,7 @@ printWidth: 80 + 123456 + + ++> + + ================================================================================ + `; +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,6 @@ ++H4sIAAAAAAAAA+3STUvDMBwG8J77Kf5O8dam6ZoNBAVvHj14L33JbGablCSTKX54010mgu6yoeLz ++yyEh7+RJWm9U35ZSP7PoVLJgKcSuDj7XuzYXOQ9lLubzKONcLBcRiZPd6ION85Uliqwx/rt5h8b/ ++qHSfv5fOl40Zhkq3qeuOd8ah/PNC7PPnU/7FgvOIsuNd4Wv/PP/zM7ZxltVKs/AHqK5cFzct7T5D ++LdtYbkdjPd3fPtxdz5gZPdOmlUleTEuuLqb+WfxSWU1Kh5fse0qSlTWvUie9aZ5WqpeU31xyeiNf ++qTAqYj1uaR22p+kMxzo/9OVopfdK2lI9amMlW7vV4FM3yiZdu/inHwkAAAAAAAAAAAAAAAAAAAAA ++4Jd6B7NcMTcAKAAA +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-002330/tests/test.sh b/tasks/format-code-task-002330/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..85708d9eab7b704f16b49798a16530c47a216c52 --- /dev/null +++ b/tasks/format-code-task-002330/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/html_prettier_ignore/__snapshots__/jsfmt.spec.js.snap +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002330/tests/test_command.sh b/tasks/format-code-task-002330/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002330/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002352/environment/Dockerfile b/tasks/format-code-task-002352/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e4ff8dac3d6fb48ebe7e0f7b627a4d00533ead7f --- /dev/null +++ b/tasks/format-code-task-002352/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:d093953ea44ff8ab5fdc77a68f6272d2c27b3674dbe38fd66ce378d8c6968c44 diff --git a/tasks/format-code-task-002352/environment/setup/files/blocklist b/tasks/format-code-task-002352/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002352/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002352/environment/setup/setup.sh b/tasks/format-code-task-002352/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002352/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002352/tests/test.patch b/tasks/format-code-task-002352/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..d3b988201dbccb9359486fa143374b42728248c1 --- /dev/null +++ b/tasks/format-code-task-002352/tests/test.patch @@ -0,0 +1,43 @@ +diff --git a/tests/providers/azure/services/network/network_watcher_enabled/network_watcher_enabled_test.py b/tests/providers/azure/services/network/network_watcher_enabled/network_watcher_enabled_test.py +index acc9430fe0..7a5f864871 100644 +--- a/tests/providers/azure/services/network/network_watcher_enabled/network_watcher_enabled_test.py ++++ b/tests/providers/azure/services/network/network_watcher_enabled/network_watcher_enabled_test.py +@@ -33,7 +33,7 @@ def test_no_network_watchers(self): + def test_network_invalid_network_watchers(self): + network_client = mock.MagicMock + locations = ["location"] +- network_client.locations = {AZURE_SUBSCRIPTION: locations} ++ network_client.locations = {AZURE_SUBSCRIPTION_ID: locations} + network_client.subscriptions = {AZURE_SUBSCRIPTION: AZURE_SUBSCRIPTION_ID} + network_watcher_name = "Network Watcher" + network_watcher_id = f"/subscriptions/{AZURE_SUBSCRIPTION_ID}/resourceGroups/NetworkWatcherRG/providers/Microsoft.Network/networkWatchers/NetworkWatcher_*" +@@ -76,7 +76,7 @@ def test_network_invalid_network_watchers(self): + def test_network_valid_network_watchers(self): + network_client = mock.MagicMock + locations = ["location"] +- network_client.locations = {AZURE_SUBSCRIPTION: locations} ++ network_client.locations = {AZURE_SUBSCRIPTION_ID: locations} + network_client.subscriptions = {AZURE_SUBSCRIPTION: AZURE_SUBSCRIPTION_ID} + network_watcher_name = "Network Watcher" + network_watcher_id = f"/subscriptions/{AZURE_SUBSCRIPTION_ID}/resourceGroups/NetworkWatcherRG/providers/Microsoft.Network/networkWatchers/NetworkWatcher_*" +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,5 @@ ++H4sIAAAAAAAAA+3S0WrDIBQG4FznKSy7btSspo8TNB5IWKNBTUr39LOBbmPQ9aZllP0fkiMnkoi/ ++lZmHg23JLbx4FJHtlVpr9rOuc6lqUTeyyaMQUjaiKZh62I6+mWPSgbEieJ9+W3fr/ZOqvvJPFFPb +++XHUzlaxv98/buVfy9fP/NVO5vx3TW4xcb8tXPfP83/ZcDM4bnTsy86y9RIYsuV0Sr13bDuyPMs9 ++dn5EPgW/DJZC5Pp9DsQjhWXoKHJH6ejD26W2R526nkK+WNocyF7rt+fPVtOJbZfyr48CAAAAAAAA ++AAAAAAAAAAAAAODpfADegMLUACgAAA== +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-002352/tests/test.sh b/tasks/format-code-task-002352/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..f8099268f7882d2cb55469cfb871917383aaefcd --- /dev/null +++ b/tasks/format-code-task-002352/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/providers/azure/services/network/network_watcher_enabled/network_watcher_enabled_test.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002352/tests/test_command.sh b/tasks/format-code-task-002352/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002352/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002355/environment/Dockerfile b/tasks/format-code-task-002355/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..71794fd13c21e9b2dceace7398824e97e10bb6ce --- /dev/null +++ b/tasks/format-code-task-002355/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:90edeead79940725afe11e88fe382abd117c4f7927484beb9fa7b339655d547a diff --git a/tasks/format-code-task-002355/environment/setup/files/blocklist b/tasks/format-code-task-002355/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002355/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002355/environment/setup/setup.sh b/tasks/format-code-task-002355/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002355/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002355/tests/test.patch b/tasks/format-code-task-002355/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..4db73da11837f6a4a386dd71ed8d242d99b9eaf4 --- /dev/null +++ b/tasks/format-code-task-002355/tests/test.patch @@ -0,0 +1,75 @@ +diff --git a/tests/test_black.py b/tests/test_black.py +index 645eec7ae78..a3e2ff86383 100644 +--- a/tests/test_black.py ++++ b/tests/test_black.py +@@ -28,7 +28,7 @@ + from click.testing import CliRunner + + import black +-from black import Feature ++from black import Feature, TargetVersion + + try: + import blackd +@@ -464,7 +464,7 @@ def test_python2(self) -> None: + @patch("black.dump_to_file", dump_to_stderr) + def test_python2_print_function(self) -> None: + source, expected = read_data("python2_print_function") +- mode = black.FileMode(target_versions={black.TargetVersion.PY27}) ++ mode = black.FileMode(target_versions={TargetVersion.PY27}) + actual = fs(source, mode=mode) + self.assertFormatEqual(expected, actual) + black.assert_stable(source, actual, mode) +@@ -828,6 +828,31 @@ def err(msg: str, **kwargs: Any) -> None: + "2 files would fail to reformat.", + ) + ++ def test_lib2to3_parse(self) -> None: ++ with self.assertRaises(black.InvalidInput): ++ black.lib2to3_parse("invalid syntax") ++ ++ straddling = "x + y" ++ black.lib2to3_parse(straddling) ++ black.lib2to3_parse(straddling, {TargetVersion.PY27}) ++ black.lib2to3_parse(straddling, {TargetVersion.PY36}) ++ black.lib2to3_parse(straddling, {TargetVersion.PY27, TargetVersion.PY36}) ++ ++ py2_only = "print x" ++ black.lib2to3_parse(py2_only) ++ black.lib2to3_parse(py2_only, {TargetVersion.PY27}) ++ with self.assertRaises(black.InvalidInput): ++ black.lib2to3_parse(py2_only, {TargetVersion.PY36}) ++ with self.assertRaises(black.InvalidInput): ++ black.lib2to3_parse(py2_only, {TargetVersion.PY27, TargetVersion.PY36}) ++ ++ py3_only = "exec(x, end=y)" ++ black.lib2to3_parse(py3_only) ++ with self.assertRaises(black.InvalidInput): ++ black.lib2to3_parse(py3_only, {TargetVersion.PY27}) ++ black.lib2to3_parse(py3_only, {TargetVersion.PY36}) ++ black.lib2to3_parse(py3_only, {TargetVersion.PY27, TargetVersion.PY36}) ++ + def test_get_features_used(self) -> None: + node = black.lib2to3_parse("def f(*, arg): ...\n") + self.assertEqual(black.get_features_used(node), set()) +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,5 @@ ++H4sIAAAAAAAAA+3S0W6DIBQGYK99inO1O1FU3FX3Kg0giaZVGjma9e1HXbIuS7betGna/d8FBwIJ ++kP8IM/f7duvGJU9upYhelVpr9LOuc6lKWcq6auo6KaRsiiohdbMXfTMH1hNRMnnPf527tP+gxDl/ ++doG31g+DHlsRuuvdcSl/qc75q6aK+deNjPkX13vC7/55/ralNXjj2jT4ebLua52L5dQWph9zbblf ++NLv0cOTOjxVlA8VpPEenIXz2jtlruxOHI2XvlGVsNqHzE1P59iLTe/8TAAAAAAAAAAAAAAAAAAAA ++AOAZfQBl9TLJACgAAA== +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-002355/tests/test.sh b/tasks/format-code-task-002355/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..7801b081839efea07d403534fd6bc1291dfad478 --- /dev/null +++ b/tasks/format-code-task-002355/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/test_black.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002355/tests/test_command.sh b/tasks/format-code-task-002355/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002355/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002364/environment/Dockerfile b/tasks/format-code-task-002364/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f308577847c8e23e9c1e3974b62331168bf59eab --- /dev/null +++ b/tasks/format-code-task-002364/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:3c3f7c0c07a6d0b7d6198e0e90ffa83b51e8647eef558ad74281582d901760c1 diff --git a/tasks/format-code-task-002364/environment/setup/files/blocklist b/tasks/format-code-task-002364/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002364/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002364/environment/setup/setup.sh b/tasks/format-code-task-002364/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002364/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002364/tests/test.patch b/tasks/format-code-task-002364/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..efc138c4891612031f9d6a7c731d3955f6300615 --- /dev/null +++ b/tasks/format-code-task-002364/tests/test.patch @@ -0,0 +1,151 @@ +diff --git a/spec/unit/puppet/type/postgresql_psql_refreshonly_spec.rb b/spec/unit/puppet/type/postgresql_psql_refreshonly_spec.rb +new file mode 100644 +index 0000000000..57d7f1a2bc +--- /dev/null ++++ b/spec/unit/puppet/type/postgresql_psql_refreshonly_spec.rb +@@ -0,0 +1,115 @@ ++require 'spec_helper' ++require 'English' ++require 'etc' ++require 'fileutils' ++require 'shellwords' ++require 'tmpdir' ++ ++unless Puppet::Util::SUIDManager.respond_to?(:run_and_capture) ++ module Puppet::Util::SUIDManager ++ def self.run_and_capture(command, _user = nil, _group = nil) ++ output = IO.popen(command, :err => [:child, :out], &:read) ++ [output, $CHILD_STATUS.exitstatus] ++ end ++ end ++end ++ ++describe Puppet::Type.type(:postgresql_psql), 'refreshonly behavior' do ++ let(:type) { Puppet::Type.type(:postgresql_psql) } ++ let(:tmpdir) { Dir.mktmpdir('postgresql_psql_refreshonly') } ++ let(:log_path) { File.join(tmpdir, 'psql_invocations.log') } ++ let(:psql_path) { File.join(tmpdir, 'psql') } ++ let(:current_user) { Etc.getpwuid(Process.uid).name } ++ let(:current_group) { Etc.getgrgid(Process.gid).name } ++ ++ before do ++ File.open(psql_path, 'w') do |file| ++ file.puts '#!/bin/sh' ++ file.puts "printf '%s\n' \"$*\" >> #{Shellwords.escape(log_path)}" ++ end ++ FileUtils.chmod(0755, psql_path) ++ end ++ ++ after do ++ FileUtils.rm_rf(tmpdir) ++ end ++ ++ def recorded_invocations(log_path) ++ return [] unless File.exist?(log_path) ++ File.readlines(log_path) ++ end ++ ++ def unique_sql(prefix) ++ "CREATE TABLE #{prefix}_#{Process.pid}_#{rand(1_000_000)} (id integer)" ++ end ++ ++ def new_psql_resource(type, psql_path, tmpdir, current_user, current_group, command, attributes = {}) ++ type.new({ ++ :name => "rspec #{command}", ++ :command => command, ++ :db => 'postgres', ++ :psql_path => psql_path, ++ :psql_user => current_user, ++ :psql_group => current_group, ++ :cwd => tmpdir, ++ }.merge(attributes)) ++ end ++ ++ it 'executes on a normal sync when refreshonly is omitted' do ++ sql = unique_sql('rl_default_refreshonly') ++ resource = new_psql_resource(type, psql_path, tmpdir, current_user, current_group, sql) ++ before_count = recorded_invocations(log_path).length ++ ++ resource.property(:command).sync ++ ++ invocations = recorded_invocations(log_path) ++ expect(invocations.length).to be > before_count ++ expect(invocations.join).to include(sql) ++ end ++ ++ it 'executes on normal sync when refreshonly is explicitly false' do ++ sql = unique_sql('rl_explicit_false_refreshonly') ++ resource = new_psql_resource(type, psql_path, tmpdir, current_user, current_group, sql, :refreshonly => false) ++ before_count = recorded_invocations(log_path).length ++ ++ resource.property(:command).sync ++ ++ invocations = recorded_invocations(log_path) ++ expect(invocations.length).to be > before_count ++ expect(invocations.join).to include(sql) ++ end ++ ++ it 'does not execute on normal sync when refreshonly is explicitly true' do ++ sql = unique_sql('rl_explicit_true_plain') ++ resource = new_psql_resource(type, psql_path, tmpdir, current_user, current_group, sql, :refreshonly => true) ++ before_count = recorded_invocations(log_path).length ++ ++ resource.property(:command).sync ++ ++ expect(recorded_invocations(log_path).length).to eq(before_count) ++ end ++ ++ it 'executes during refresh when refreshonly is explicitly true' do ++ sql = unique_sql('rl_explicit_true_refresh') ++ resource = new_psql_resource(type, psql_path, tmpdir, current_user, current_group, sql, :refreshonly => true) ++ before_count = recorded_invocations(log_path).length ++ ++ resource.refresh ++ ++ invocations = recorded_invocations(log_path) ++ expect(invocations.length).to be > before_count ++ expect(invocations.join).to include(sql) ++ end ++ ++ it 'accepts boolean refreshonly values' do ++ [true, false, :true, :false].each do |value| ++ expect { new_psql_resource(type, psql_path, tmpdir, current_user, current_group, unique_sql('rl_valid_refreshonly'), :refreshonly => value) }.not_to raise_error ++ end ++ end ++ ++ it 'rejects non-boolean refreshonly values' do ++ ['sometimes', 'yes', 1].each do |value| ++ expect { new_psql_resource(type, psql_path, tmpdir, current_user, current_group, unique_sql('rl_invalid_refreshonly'), :refreshonly => value) }.to raise_error(Puppet::Error) ++ end ++ end ++end +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,25 @@ ++#!/bin/bash ++set -uo pipefail ++ ++cd /testbed ++ ++ ++set +u ++export PATH="$HOME/.rbenv/bin:$HOME/.rbenv/plugins/ruby-build/bin:$PATH" ++eval "$(rbenv init - bash)" ++rbenv global 2.7.8 ++set -u ++ ++ ++case "${1:-}" in ++ base) ++ ruby -e 'puts "No pre-existing postgresql_psql unit specs in base checkout; base regression scope is empty."' ++ ;; ++ new) ++ ruby -S rspec /testbed/spec/unit/puppet/type/postgresql_psql_refreshonly_spec.rb ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-002364/tests/test.sh b/tasks/format-code-task-002364/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..65547a6fb373a2cb738602c638b6b352aba17730 --- /dev/null +++ b/tasks/format-code-task-002364/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +spec/unit/puppet/type/postgresql_psql_refreshonly_spec.rb +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002364/tests/test_command.sh b/tasks/format-code-task-002364/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-002364/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh base && bash /testbed/mimo_test_command.sh new \ No newline at end of file diff --git a/tasks/format-code-task-002390/environment/Dockerfile b/tasks/format-code-task-002390/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b5b63280695798e5acc30a175678503fb5c07482 --- /dev/null +++ b/tasks/format-code-task-002390/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:f9991e37a48b99d8f6ec5b9b293928eda647aa981c8fccd32738f5d5b7b69967 diff --git a/tasks/format-code-task-002390/environment/setup/files/blocklist b/tasks/format-code-task-002390/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002390/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002390/environment/setup/setup.sh b/tasks/format-code-task-002390/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002390/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002390/tests/test.patch b/tasks/format-code-task-002390/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..86671c01e7197d7beb26e05cc4789512c3345e69 --- /dev/null +++ b/tasks/format-code-task-002390/tests/test.patch @@ -0,0 +1,491 @@ +diff --git a/usercase-test-coderl/test_ecosystems_service.py b/usercase-test-coderl/test_ecosystems_service.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_ecosystems_service.py +@@ -0,0 +1,461 @@ ++from __future__ import annotations ++ ++from pathlib import Path ++import subprocess ++from typing import Any ++from urllib.parse import parse_qs, urlparse ++ ++import pytest ++import requests ++from packaging.version import Version ++ ++from pip_audit._service import ( ++ ConnectionError, ++ EcosystemsService, ++ ResolvedDependency, ++ ServiceError, ++ SkippedDependency, ++) ++ ++ ++class _Response: ++ def __init__(self, payload: Any, status_error: Exception | None = None) -> None: ++ self._payload = payload ++ self._status_error = status_error ++ ++ def raise_for_status(self) -> None: ++ if self._status_error is not None: ++ raise self._status_error ++ ++ def json(self) -> Any: ++ return self._payload ++ ++ ++class _RecordingRequest: ++ def __init__(self, *responses: _Response | Exception) -> None: ++ self._responses = list(responses) ++ self.calls: list[tuple[tuple[Any, ...], dict[str, Any]]] = [] ++ ++ def __call__(self, *args: Any, **kwargs: Any) -> _Response: ++ self.calls.append((args, kwargs)) ++ if not self._responses: ++ raise AssertionError("unexpected provider request") ++ response = self._responses.pop(0) ++ if isinstance(response, Exception): ++ raise response ++ return response ++ ++ ++def _resolved() -> ResolvedDependency: ++ return ResolvedDependency("Foo_Bar", Version("1.0.0")) ++ ++ ++def _install_request_recorder( ++ monkeypatch: pytest.MonkeyPatch, *responses: _Response | Exception ++) -> _RecordingRequest: ++ recorder = _RecordingRequest(*responses) ++ ++ ++ monkeypatch.setattr(requests.sessions.Session, "request", recorder) ++ return recorder ++ ++ ++def _call_method_url_kwargs( ++ call: tuple[tuple[Any, ...], dict[str, Any]] ++) -> tuple[str, str, dict[str, Any]]: ++ args, kwargs = call ++ method = args[0] if len(args) > 0 else kwargs.get("method") ++ url = args[1] if len(args) > 1 else kwargs.get("url") ++ assert method is not None ++ assert url is not None ++ return str(method).upper(), str(url), kwargs ++ ++ ++def _assert_esms_request( ++ call: tuple[tuple[Any, ...], dict[str, Any]], expected_timeout: int ++) -> None: ++ method, url, kwargs = _call_method_url_kwargs(call) ++ parsed = urlparse(url) ++ params: dict[str, list[str]] = parse_qs(parsed.query) ++ raw_params = kwargs.get("params") or {} ++ for key, value in raw_params.items(): ++ params[key] = value if isinstance(value, list) else [value] ++ ++ ++ ++ assert method == "GET" ++ assert parsed.scheme == "https" ++ assert parsed.netloc == "advisories.ecosyste.ms" ++ assert parsed.path == "/api/v1/advisories" ++ assert params == {"ecosystem": ["pypi"], "package_name": ["foo-bar"]} ++ assert kwargs["timeout"] == expected_timeout ++ ++ ++def test_skipped_dependency_returns_same_dependency_without_network( ++ tmp_path: Path, monkeypatch: pytest.MonkeyPatch ++) -> None: ++ ++ ++ ++ ++ ++ service = EcosystemsService(cache_dir=tmp_path / "cache", timeout=13) ++ recorder = _install_request_recorder(monkeypatch) ++ dep = SkippedDependency(name="foo", skip_reason="skip-reason") ++ ++ actual_dep, vulns = service.query(dep) ++ ++ assert actual_dep == SkippedDependency(name="foo", skip_reason="skip-reason") ++ assert vulns == [] ++ assert recorder.calls == [] ++ ++ ++def test_resolved_dependency_empty_response_uses_canonical_query_and_timeout( ++ tmp_path: Path, monkeypatch: pytest.MonkeyPatch ++) -> None: ++ ++ ++ ++ ++ ++ service = EcosystemsService(cache_dir=tmp_path / "cache", timeout=13) ++ recorder = _install_request_recorder(monkeypatch, _Response([])) ++ ++ actual_dep, vulns = service.query(_resolved()) ++ ++ assert actual_dep == ResolvedDependency("Foo_Bar", Version("1.0.0")) ++ assert vulns == [] ++ assert len(recorder.calls) == 1 ++ _assert_esms_request(recorder.calls[0], expected_timeout=13) ++ ++ ++def test_advisory_normalization_is_stateful_across_repeated_queries( ++ tmp_path: Path, monkeypatch: pytest.MonkeyPatch ++) -> None: ++ ++ ++ ++ ++ ++ payload = [ ++ { ++ "identifiers": ["GHSA-x", "PYSEC-2024-1", "CVE-2024-1"], ++ "title": "first line\nsecond line", ++ "description": "fallback desc", ++ "withdrawn_at": None, ++ "packages": [ ++ { ++ "package_name": "foo-bar", ++ "ecosystem": "pypi", ++ "versions": [ ++ { ++ "vulnerable_version_range": "< 1.0.1", ++ "first_patched_version": "1.0.1", ++ } ++ ], ++ } ++ ], ++ "published": "2024-01-02T03:04:05Z", ++ } ++ ] ++ service = EcosystemsService(cache_dir=tmp_path / "cache", timeout=13) ++ recorder = _install_request_recorder(monkeypatch, _Response([]), _Response(payload)) ++ ++ first_dep, first_vulns = service.query(_resolved()) ++ second_dep, second_vulns = service.query(_resolved()) ++ ++ assert first_dep == ResolvedDependency("Foo_Bar", Version("1.0.0")) ++ assert first_vulns == [] ++ assert second_dep == ResolvedDependency("Foo_Bar", Version("1.0.0")) ++ assert len(second_vulns) == 1 ++ assert second_vulns[0].id == "PYSEC-2024-1" ++ assert second_vulns[0].aliases == {"GHSA-x", "CVE-2024-1"} ++ assert second_vulns[0].description == "first line second line" ++ assert second_vulns[0].fix_versions == [Version("1.0.1")] ++ ++ assert second_vulns[0].published is None or hasattr(second_vulns[0].published, "isoformat") ++ assert len(recorder.calls) == 2 ++ _assert_esms_request(recorder.calls[0], expected_timeout=13) ++ _assert_esms_request(recorder.calls[1], expected_timeout=13) ++ ++ ++@pytest.mark.parametrize( ++ ("title", "description", "expected"), ++ [ ++ ("", "fallback\ndescription", "fallback description"), ++ (None, "fallback\ndescription", "fallback description"), ++ ("", "", "N/A"), ++ (None, None, "N/A"), ++ ], ++) ++def test_description_fallbacks_are_normalized( ++ tmp_path: Path, ++ monkeypatch: pytest.MonkeyPatch, ++ title: str | None, ++ description: str | None, ++ expected: str, ++) -> None: ++ ++ ++ ++ ++ ++ payload = [ ++ { ++ "identifiers": ["GHSA-y"], ++ "title": title, ++ "description": description, ++ "withdrawn_at": None, ++ "packages": [ ++ { ++ "package_name": "foo-bar", ++ "ecosystem": "pypi", ++ "versions": [ ++ { ++ "vulnerable_version_range": "= 1.0.0", ++ "first_patched_version": "1.0.2", ++ } ++ ], ++ } ++ ], ++ } ++ ] ++ service = EcosystemsService(cache_dir=tmp_path / "cache", timeout=2) ++ _install_request_recorder(monkeypatch, _Response(payload)) ++ ++ actual_dep, vulns = service.query(_resolved()) ++ ++ assert actual_dep == ResolvedDependency("Foo_Bar", Version("1.0.0")) ++ assert len(vulns) == 1 ++ assert vulns[0].id == "GHSA-y" ++ assert vulns[0].aliases == set() ++ assert vulns[0].description == expected ++ assert vulns[0].fix_versions == [Version("1.0.2")] ++ ++ ++def test_filtering_ignores_irrelevant_advisories_and_accepts_exact_match( ++ tmp_path: Path, monkeypatch: pytest.MonkeyPatch ++) -> None: ++ ++ ++ ++ ++ ++ payload = [ ++ { ++ "identifiers": ["PYSEC-withdrawn"], ++ "title": "withdrawn", ++ "description": "d", ++ "withdrawn_at": "2024-01-01T00:00:00Z", ++ "packages": [ ++ { ++ "package_name": "foo-bar", ++ "ecosystem": "pypi", ++ "versions": [ ++ {"vulnerable_version_range": "< 9", "first_patched_version": "9"} ++ ], ++ } ++ ], ++ }, ++ { ++ "identifiers": ["PYSEC-rubygems"], ++ "title": "wrong ecosystem", ++ "description": "d", ++ "withdrawn_at": None, ++ "packages": [ ++ { ++ "package_name": "foo-bar", ++ "ecosystem": "rubygems", ++ "versions": [ ++ {"vulnerable_version_range": "< 9", "first_patched_version": "9"} ++ ], ++ } ++ ], ++ }, ++ { ++ "identifiers": ["PYSEC-other"], ++ "title": "wrong package", ++ "description": "d", ++ "withdrawn_at": None, ++ "packages": [ ++ { ++ "package_name": "other", ++ "ecosystem": "pypi", ++ "versions": [ ++ {"vulnerable_version_range": "< 9", "first_patched_version": "9"} ++ ], ++ } ++ ], ++ }, ++ { ++ "identifiers": ["PYSEC-range"], ++ "title": "wrong range", ++ "description": "d", ++ "withdrawn_at": None, ++ "packages": [ ++ { ++ "package_name": "foo-bar", ++ "ecosystem": "pypi", ++ "versions": [ ++ { ++ "vulnerable_version_range": ">= 2.0.0", ++ "first_patched_version": "2.0.1", ++ } ++ ], ++ } ++ ], ++ }, ++ { ++ "identifiers": ["PYSEC-exact"], ++ "title": "exact match", ++ "description": "d", ++ "withdrawn_at": None, ++ "packages": [ ++ { ++ "package_name": "foo-bar", ++ "ecosystem": "pypi", ++ "versions": [ ++ { ++ "vulnerable_version_range": "= 1.0.0", ++ "first_patched_version": "1.0.3", ++ } ++ ], ++ } ++ ], ++ }, ++ ] ++ service = EcosystemsService(cache_dir=tmp_path / "cache", timeout=5) ++ _install_request_recorder(monkeypatch, _Response(payload)) ++ ++ actual_dep, vulns = service.query(_resolved()) ++ ++ assert actual_dep == ResolvedDependency("Foo_Bar", Version("1.0.0")) ++ assert len(vulns) == 1 ++ assert vulns[0].id == "PYSEC-exact" ++ assert vulns[0].aliases == set() ++ assert vulns[0].description == "exact match" ++ assert vulns[0].fix_versions == [Version("1.0.3")] ++ ++ ++def test_connect_timeout_raises_specific_connection_error( ++ tmp_path: Path, monkeypatch: pytest.MonkeyPatch ++) -> None: ++ ++ ++ ++ ++ ++ service = EcosystemsService(cache_dir=tmp_path / "cache", timeout=6) ++ _install_request_recorder(monkeypatch, requests.ConnectTimeout()) ++ ++ with pytest.raises( ++ ConnectionError, match="Could not connect to ESMS' vulnerability feed" ++ ) as error: ++ service.query(_resolved()) ++ ++ assert str(error.value) == "Could not connect to ESMS' vulnerability feed" ++ ++ ++def test_http_status_error_raises_service_error( ++ tmp_path: Path, monkeypatch: pytest.MonkeyPatch ++) -> None: ++ ++ ++ ++ ++ ++ service = EcosystemsService(cache_dir=tmp_path / "cache", timeout=6) ++ _install_request_recorder(monkeypatch, _Response([], requests.HTTPError("boom"))) ++ ++ with pytest.raises(ServiceError) as error: ++ service.query(_resolved()) ++ ++ ++ ++ assert isinstance(error.value, ServiceError) ++ ++ ++def test_two_service_instances_keep_timeout_and_sessions_independent( ++ tmp_path: Path, monkeypatch: pytest.MonkeyPatch ++) -> None: ++ ++ ++ ++ ++ ++ first = EcosystemsService(cache_dir=tmp_path / "first-cache", timeout=3) ++ second = EcosystemsService(cache_dir=tmp_path / "second-cache", timeout=9) ++ recorder = _install_request_recorder( ++ monkeypatch, _Response([]), _Response([]), _Response([]) ++ ) ++ ++ first_dep, first_vulns = first.query(_resolved()) ++ second_dep, second_vulns = second.query(_resolved()) ++ first_again_dep, first_again_vulns = first.query(_resolved()) ++ ++ assert first_dep == ResolvedDependency("Foo_Bar", Version("1.0.0")) ++ assert first_vulns == [] ++ assert second_dep == ResolvedDependency("Foo_Bar", Version("1.0.0")) ++ assert second_vulns == [] ++ assert first_again_dep == ResolvedDependency("Foo_Bar", Version("1.0.0")) ++ assert first_again_vulns == [] ++ assert len(recorder.calls) == 3 ++ _assert_esms_request(recorder.calls[0], expected_timeout=3) ++ _assert_esms_request(recorder.calls[1], expected_timeout=9) ++ _assert_esms_request(recorder.calls[2], expected_timeout=3) ++ ++ ++def test_constructed_service_can_issue_a_provider_request( ++ tmp_path: Path, monkeypatch: pytest.MonkeyPatch ++) -> None: ++ ++ ++ ++ ++ ++ ++ ++ def fail_if_pip_cache_dir(*args: Any, **kwargs: Any) -> subprocess.CompletedProcess[Any]: ++ raise AssertionError("EcosystemsService should not query pip's cache directory") ++ ++ ++ ++ monkeypatch.setattr(subprocess, "run", fail_if_pip_cache_dir) ++ service = EcosystemsService(cache_dir=None, timeout=1) ++ recorder = _install_request_recorder(monkeypatch, _Response([])) ++ ++ actual_dep, vulns = service.query(_resolved()) ++ ++ assert actual_dep == ResolvedDependency("Foo_Bar", Version("1.0.0")) ++ assert vulns == [] ++ assert len(recorder.calls) == 1 ++ _assert_esms_request(recorder.calls[0], expected_timeout=1) ++ ++ ++def test_construct_query_cycles_remain_stateful( ++ tmp_path: Path, monkeypatch: pytest.MonkeyPatch ++) -> None: ++ ++ ++ ++ ++ ++ dep = _resolved() ++ recorder = _install_request_recorder( ++ monkeypatch, _Response([]), _Response([]), _Response([]), _Response([]), _Response([]) ++ ) ++ ++ ++ ++ for index in range(5): ++ service = EcosystemsService(cache_dir=tmp_path / f"cache-{index}", timeout=1) ++ actual_dep, vulns = service.query(dep) ++ ++ assert actual_dep == ResolvedDependency("Foo_Bar", Version("1.0.0")) ++ assert vulns == [] ++ ++ assert len(recorder.calls) == 5 ++ for call in recorder.calls: ++ _assert_esms_request(call, expected_timeout=1) ++ assert actual_dep == ResolvedDependency("Foo_Bar", Version("1.0.0")) ++ assert vulns == [] +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,20 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++ ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++export PIP_DISABLE_PIP_VERSION_CHECK=1 ++export PIP_NO_INDEX=1 ++ ++exec /opt/stage4a_venv/bin/python -m pytest /workspace/repo/usercase-test-coderl/test_ecosystems_service.py -v diff --git a/tasks/format-code-task-002390/tests/test.sh b/tasks/format-code-task-002390/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..39db7e788fbd76d4d2dfb77eec8f6e14962e32c3 --- /dev/null +++ b/tasks/format-code-task-002390/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/test_ecosystems_service.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002390/tests/test_command.sh b/tasks/format-code-task-002390/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002390/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002397/environment/Dockerfile b/tasks/format-code-task-002397/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..aaccd42d59e0503091851c00a89da4cf40de5b80 --- /dev/null +++ b/tasks/format-code-task-002397/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:b2b1757639a38364fba571ad39cde2570178adb4aa6be4e55d22d8414405ca2c diff --git a/tasks/format-code-task-002397/environment/setup/files/blocklist b/tasks/format-code-task-002397/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002397/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002397/environment/setup/setup.sh b/tasks/format-code-task-002397/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002397/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002397/tests/test.patch b/tasks/format-code-task-002397/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..9d9bf03edbd233df87ce88e5d1e3b12c4a14b30f --- /dev/null +++ b/tasks/format-code-task-002397/tests/test.patch @@ -0,0 +1,56 @@ +diff --git a/tests/accounts/test_core.py b/tests/accounts/test_core.py +index 00d68c21532e..1b0f2c92ae1c 100644 +--- a/tests/accounts/test_core.py ++++ b/tests/accounts/test_core.py +@@ -49,7 +49,7 @@ def test_with_user(self): + + request = pretend.stub( + find_service=lambda iface: service, +- unauthenticated_userid=100, ++ authenticated_userid=100, + ) + + assert accounts._user(request) is user +@@ -62,12 +62,16 @@ def test_without_users(self): + + request = pretend.stub( + find_service=lambda iface: service, +- unauthenticated_userid=100, ++ authenticated_userid=100, + ) + + assert accounts._user(request) is None + assert service.get_user.calls == [pretend.call(100)] + ++ def test_without_userid(self): ++ request = pretend.stub(authenticated_userid=None) ++ assert accounts._user(request) is None ++ + + def test_includeme(monkeypatch): + authn_obj = pretend.stub() +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,9 @@ ++H4sIAAAAAAAAA+3UT2/TMBQA8J7zKZ7GOWnSNeM0JC5oXKCCSohT5TivqTf/w36pyD49TtZ2FQh2 ++2YQQ73exa7/GL+9ZKZpe6XaDdj+fvZQyeV3X05j8PE7zql5U1dViuayWszLNymoG9YtldKaPJALA ++LDhHf4p7av8fVTz2nzDSRjpjhG2LuHu+M57of1XWy1P/L8e4anm1SP0vny+F3/vP+y9bmBrfYJtl ++r+AzEvQeVgPtnIV0K1Rw1qClzE9Ll5Ab2Kd1mI8FmRfjPIuuDxLPl+aNsnMhSe0F4fjg9zbVWWto ++0aNt0UqFMfPKgzps5Ll1ubK+J/ABKQVBOjJlloYgjGqP4yZi2CuJEbyIUasG4jcttNyhGaCRYfDp ++L3GQzneLPKUhwnAWkUtF+J3g3nkslCUMW5FSjxR6Sdp1QEHYOGae3n8KOnu60GgaJUFqJe+g662S ++LljYqYCtirAjo+sxIUWxFbbD4PoIJnZeyLv8oYDwEBqRfHDpFNJ4erFbZW/F4vSTDFwEFK3BN9dl ++URfVBdD9tjhuD0bDl/U7F0wcC/ypt5BucpcaOFYtZquv65uPH1Zv1zfXxw7DWRMPxZ1iU6ek622a ++HL4BAdMxkO+nrkhnt+N69rfvKmOMMcYYY4wxxhhjjDHGGGOMMcYY+9UPe0GL8QAoAAA= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-002397/tests/test.sh b/tasks/format-code-task-002397/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..453d4a039b9e4bfb97a52b91832a3f2467f2faa8 --- /dev/null +++ b/tasks/format-code-task-002397/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/accounts/test_core.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002397/tests/test_command.sh b/tasks/format-code-task-002397/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002397/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002399/environment/Dockerfile b/tasks/format-code-task-002399/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..42a131c08faca960c369367e6be9776b44f9b2cb --- /dev/null +++ b/tasks/format-code-task-002399/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:f7c4ccb5f9846cb507f74b8254ef045fc9504d8bf7379299445700722ebc89ad diff --git a/tasks/format-code-task-002399/environment/setup/files/blocklist b/tasks/format-code-task-002399/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002399/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002399/environment/setup/setup.sh b/tasks/format-code-task-002399/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002399/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002399/tests/test.patch b/tasks/format-code-task-002399/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..4590311500f88708653c8e98e60b484be53bb6f7 --- /dev/null +++ b/tasks/format-code-task-002399/tests/test.patch @@ -0,0 +1,191 @@ +diff --git a/tests/basics/test_ops.py b/tests/basics/test_ops.py +index 2deee09..502afe1 100644 +--- a/tests/basics/test_ops.py ++++ b/tests/basics/test_ops.py +@@ -2,6 +2,26 @@ import torch + import pypose as pp + + ++def _sample_so3_chain(): ++ data = torch.tensor([ ++ [0.10, -0.20, 0.30, 0.93], ++ [-0.15, 0.25, 0.35, 0.89], ++ [0.22, 0.18, -0.27, 0.92], ++ [-0.31, -0.12, 0.21, 0.91], ++ ], dtype=torch.float64) ++ data = data / data.norm(dim=-1, keepdim=True) ++ return pp.SO3(data) ++ ++ ++def _manual_chain(x, op, left): ++ out = [x[0]] ++ accum = x[0] ++ for i in range(1, x.shape[0]): ++ accum = op(x[i], accum) if left else op(accum, x[i]) ++ out.append(accum) ++ return pp.SO3(torch.stack([item.tensor() for item in out])) ++ ++ + class TestOps: + + device = torch.device("cuda" if torch.cuda.is_available() else "cpu") +@@ -12,7 +32,63 @@ class TestOps: + pm = torch.tensor([1, 1, -1], dtype=dtype, device=self.device) + assert torch.equal(x, pm), "Results incorrect." + ++ def test_cumprod_left_and_right_match_manual_noncommutative_chain(self): ++ x = _sample_so3_chain() ++ left_expected = _manual_chain(x, lambda a, b: a @ b, left=True) ++ right_expected = _manual_chain(x, lambda a, b: a @ b, left=False) ++ pp.testing.assert_close(pp.cumprod(x, dim=0, left=True), left_expected, rtol=1e-5, atol=1e-6) ++ pp.testing.assert_close(pp.cumprod(x, dim=0, left=False), right_expected, rtol=1e-5, atol=1e-6) ++ ++ def test_cummul_left_and_right_match_manual_noncommutative_chain(self): ++ x = _sample_so3_chain() ++ left_expected = _manual_chain(x, lambda a, b: a * b, left=True) ++ right_expected = _manual_chain(x, lambda a, b: a * b, left=False) ++ pp.testing.assert_close(pp.cummul(x, dim=0, left=True), left_expected, rtol=1e-5, atol=1e-6) ++ pp.testing.assert_close(pp.cummul(x, dim=0, left=False), right_expected, rtol=1e-5, atol=1e-6) ++ ++ def test_cumops_matches_prefix_first_custom_accumulation(self): ++ x = _sample_so3_chain() ++ op = lambda prefix, current: current @ prefix ++ expected = _manual_chain(x, lambda current, prefix: current @ prefix, left=True) ++ pp.testing.assert_close(pp.cumops(x, dim=0, ops=op), expected, rtol=1e-5, atol=1e-6) ++ ++ def test_cumops_inplace_matches_prefix_first_custom_accumulation(self): ++ x = _sample_so3_chain() ++ y = x.clone() ++ op = lambda prefix, current: current @ prefix ++ expected = _manual_chain(x, lambda current, prefix: current @ prefix, left=True) ++ result = pp.cumops_(y, dim=0, ops=op) ++ pp.testing.assert_close(y, expected, rtol=1e-5, atol=1e-6) ++ pp.testing.assert_close(result, expected, rtol=1e-5, atol=1e-6) ++ ++ def test_inplace_top_level_accepts_left_and_mutates_with_matching_direction(self): ++ x = _sample_so3_chain() ++ cumprod_left = x.clone() ++ expected = _manual_chain(x, lambda a, b: a @ b, left=True) ++ pp.testing.assert_close(pp.cumprod_(cumprod_left, dim=0, left=True), expected, rtol=1e-5, atol=1e-6) ++ pp.testing.assert_close(cumprod_left, expected, rtol=1e-5, atol=1e-6) ++ ++ cumprod_right = x.clone() ++ expected = _manual_chain(x, lambda a, b: a @ b, left=False) ++ pp.testing.assert_close(pp.cumprod_(cumprod_right, dim=0, left=False), expected, rtol=1e-5, atol=1e-6) ++ pp.testing.assert_close(cumprod_right, expected, rtol=1e-5, atol=1e-6) ++ ++ cummul_left = x.clone() ++ expected = _manual_chain(x, lambda a, b: a * b, left=True) ++ pp.testing.assert_close(pp.cummul_(cummul_left, dim=0, left=True), expected, rtol=1e-5, atol=1e-6) ++ pp.testing.assert_close(cummul_left, expected, rtol=1e-5, atol=1e-6) ++ ++ cummul_right = x.clone() ++ expected = _manual_chain(x, lambda a, b: a * b, left=False) ++ pp.testing.assert_close(pp.cummul_(cummul_right, dim=0, left=False), expected, rtol=1e-5, atol=1e-6) ++ pp.testing.assert_close(cummul_right, expected, rtol=1e-5, atol=1e-6) ++ + + if __name__ == '__main__': + test = TestOps() + test.test_pm() ++ test.test_cumprod_left_and_right_match_manual_noncommutative_chain() ++ test.test_cummul_left_and_right_match_manual_noncommutative_chain() ++ test.test_cumops_matches_prefix_first_custom_accumulation() ++ test.test_cumops_inplace_matches_prefix_first_custom_accumulation() ++ test.test_inplace_top_level_accepts_left_and_mutates_with_matching_direction() +diff --git a/tests/lietensor/test_lietensor.py b/tests/lietensor/test_lietensor.py +index cbd1c02..353947d 100644 +--- a/tests/lietensor/test_lietensor.py ++++ b/tests/lietensor/test_lietensor.py +@@ -256,3 +256,55 @@ def test_lietensor(): + + if __name__ == '__main__': + test_lietensor() ++ ++ ++def _sample_so3_chain_for_cumtests(): ++ data = torch.tensor([ ++ [0.10, -0.20, 0.30, 0.93], ++ [-0.15, 0.25, 0.35, 0.89], ++ [0.22, 0.18, -0.27, 0.92], ++ [-0.31, -0.12, 0.21, 0.91], ++ ], dtype=torch.float64) ++ data = data / data.norm(dim=-1, keepdim=True) ++ return pp.SO3(data) ++ ++ ++def _manual_chain_for_cumtests(x, op, left): ++ out = [x[0]] ++ accum = x[0] ++ for i in range(1, x.shape[0]): ++ accum = op(x[i], accum) if left else op(accum, x[i]) ++ out.append(accum) ++ return pp.SO3(torch.stack([item.tensor() for item in out])) ++ ++ ++def test_inplace_lie_tensor_methods_accept_left_and_mutate_with_matching_direction(): ++ x = _sample_so3_chain_for_cumtests() ++ cumprod_left = x.clone() ++ expected = _manual_chain_for_cumtests(x, lambda a, b: a @ b, left=True) ++ pp.testing.assert_close(cumprod_left.cumprod_(dim=0, left=True), expected, rtol=1e-5, atol=1e-6) ++ pp.testing.assert_close(cumprod_left, expected, rtol=1e-5, atol=1e-6) ++ ++ cumprod_right = x.clone() ++ expected = _manual_chain_for_cumtests(x, lambda a, b: a @ b, left=False) ++ pp.testing.assert_close(cumprod_right.cumprod_(dim=0, left=False), expected, rtol=1e-5, atol=1e-6) ++ pp.testing.assert_close(cumprod_right, expected, rtol=1e-5, atol=1e-6) ++ ++ cummul_left = x.clone() ++ expected = _manual_chain_for_cumtests(x, lambda a, b: a * b, left=True) ++ pp.testing.assert_close(cummul_left.cummul_(dim=0, left=True), expected, rtol=1e-5, atol=1e-6) ++ pp.testing.assert_close(cummul_left, expected, rtol=1e-5, atol=1e-6) ++ ++ cummul_right = x.clone() ++ expected = _manual_chain_for_cumtests(x, lambda a, b: a * b, left=False) ++ pp.testing.assert_close(cummul_right.cummul_(dim=0, left=False), expected, rtol=1e-5, atol=1e-6) ++ pp.testing.assert_close(cummul_right, expected, rtol=1e-5, atol=1e-6) ++ ++ ++def test_lie_tensor_cummul_and_cumprod_methods_accept_left_and_match_functional_api(): ++ x = _sample_so3_chain_for_cumtests() ++ pp.testing.assert_close(x.cummul(dim=0, left=True), pp.cummul(x, dim=0, left=True), rtol=1e-5, atol=1e-6) ++ pp.testing.assert_close(x.cummul(dim=0, left=False), pp.cummul(x, dim=0, left=False), rtol=1e-5, atol=1e-6) ++ ++ pp.testing.assert_close(x.cumprod(dim=0, left=True), pp.cumprod(x, dim=0, left=True), rtol=1e-5, atol=1e-6) ++ pp.testing.assert_close(x.cumprod(dim=0, left=False), pp.cumprod(x, dim=0, left=False), rtol=1e-5, atol=1e-6) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,31 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++ ++set +u ++source /testbed/.build_env/venv/bin/activate ++set -u ++pip install -e . --no-input -q 2>/dev/null ++ ++ ++case "${1:-}" in ++ base) ++ python -m pytest tests/basics/test_ops.py::TestOps::test_pm -v ++ ;; ++ new) ++ python -m pytest \ ++ tests/basics/test_ops.py::TestOps::test_cumprod_left_and_right_match_manual_noncommutative_chain \ ++ tests/basics/test_ops.py::TestOps::test_cummul_left_and_right_match_manual_noncommutative_chain \ ++ tests/basics/test_ops.py::TestOps::test_cumops_matches_prefix_first_custom_accumulation \ ++ tests/basics/test_ops.py::TestOps::test_cumops_inplace_matches_prefix_first_custom_accumulation \ ++ tests/basics/test_ops.py::TestOps::test_inplace_top_level_accepts_left_and_mutates_with_matching_direction \ ++ tests/lietensor/test_lietensor.py::test_inplace_lie_tensor_methods_accept_left_and_mutate_with_matching_direction \ ++ tests/lietensor/test_lietensor.py::test_lie_tensor_cummul_and_cumprod_methods_accept_left_and_match_functional_api \ ++ -v ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-002399/tests/test.sh b/tasks/format-code-task-002399/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..71dd99e3d7c2c41e0ee45a7e45d2a3c4a19d7d2d --- /dev/null +++ b/tasks/format-code-task-002399/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/basics/test_ops.py +tests/lietensor/test_lietensor.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002399/tests/test_command.sh b/tasks/format-code-task-002399/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-002399/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh base && bash /testbed/mimo_test_command.sh new \ No newline at end of file diff --git a/tasks/format-code-task-002476/environment/Dockerfile b/tasks/format-code-task-002476/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..5e84dab6b269b961cf0097a2d062f5fad7aa8e39 --- /dev/null +++ b/tasks/format-code-task-002476/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:8a62d3834a7f0bdc9bd1c7b982f4d675c54996a5786d87a48274aff6b6470bc0 diff --git a/tasks/format-code-task-002476/environment/setup/files/blocklist b/tasks/format-code-task-002476/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002476/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002476/environment/setup/setup.sh b/tasks/format-code-task-002476/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002476/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002476/tests/test.patch b/tasks/format-code-task-002476/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..80b943bcbff1340b1928f78e27976cbb70b1a438 --- /dev/null +++ b/tasks/format-code-task-002476/tests/test.patch @@ -0,0 +1,423 @@ +diff --git a/raiden/tests/unit/test_matrix_user_address_manager.py b/raiden/tests/unit/test_matrix_user_address_manager.py +new file mode 100644 +index 000000000..4d26f75bf +--- /dev/null ++++ b/raiden/tests/unit/test_matrix_user_address_manager.py +@@ -0,0 +1,389 @@ ++from unittest.mock import Mock ++ ++import pytest ++from eth_utils import encode_hex, to_normalized_address ++from gevent.event import Event ++from matrix_client.errors import MatrixRequestError ++from matrix_client.user import User ++ ++from raiden.network.transport.matrix import ( ++ AddressReachability, ++ UserAddressManager, ++ UserPresence, ++) ++from raiden.tests.utils.factories import make_signer ++ ++SERVER1 = 'server1' ++SERVER2 = 'server2' ++ ++ ++def make_user(signer, server): ++ user_id = f'@{to_normalized_address(signer.address)}:{server}' ++ displayname = encode_hex(signer.sign(user_id.encode())) ++ user = Mock(spec=User) ++ user.user_id = user_id ++ user.displayname = displayname ++ user.get_display_name = Mock(side_effect=lambda: user.displayname) ++ return user ++ ++ ++class FakeMatrixClient: ++ ++ ++ def __init__(self, user_id): ++ self.user_id = user_id ++ self._presence_listener = None ++ self.get_user_presence = Mock(side_effect=AssertionError('not configured')) ++ ++ def add_presence_listener(self, callback): ++ self._presence_listener = callback ++ ++ def emit_presence(self, user_id, presence): ++ assert self._presence_listener is not None, 'no presence listener registered' ++ event = { ++ 'sender': user_id, ++ 'type': 'm.presence', ++ 'content': {'presence': presence.value}, ++ } ++ self._presence_listener(event) ++ ++ def emit_raw(self, event): ++ assert self._presence_listener is not None, 'no presence listener registered' ++ self._presence_listener(event) ++ ++ ++@pytest.fixture ++def signer1(): ++ return make_signer() ++ ++ ++@pytest.fixture ++def signer2(): ++ return make_signer() ++ ++ ++@pytest.fixture ++def own_signer(): ++ return make_signer() ++ ++ ++@pytest.fixture ++def user1_s1(signer1): ++ return make_user(signer1, SERVER1) ++ ++ ++@pytest.fixture ++def user1_s2(signer1): ++ return make_user(signer1, SERVER2) ++ ++ ++@pytest.fixture ++def user2_s1(signer2): ++ return make_user(signer2, SERVER1) ++ ++ ++@pytest.fixture ++def own_user(own_signer): ++ return make_user(own_signer, SERVER1) ++ ++ ++@pytest.fixture ++def addr1(signer1): ++ return signer1.address ++ ++ ++@pytest.fixture ++def addr2(signer2): ++ return signer2.address ++ ++ ++@pytest.fixture ++def user_registry(user1_s1, user1_s2, user2_s1, own_user): ++ return { ++ u.user_id: u ++ for u in (user1_s1, user1_s2, user2_s1, own_user) ++ } ++ ++ ++@pytest.fixture ++def get_user(user_registry): ++ def _get_user(user_or_id): ++ if not isinstance(user_or_id, str): ++ return user_or_id ++ if user_or_id in user_registry: ++ return user_registry[user_or_id] ++ user = Mock(spec=User) ++ user.user_id = user_or_id ++ user.displayname = 'unknown' ++ user.get_display_name = Mock(side_effect=lambda: user.displayname) ++ return user ++ return _get_user ++ ++ ++@pytest.fixture ++def stop_event(): ++ return Event() ++ ++ ++@pytest.fixture ++def reachability_events(): ++ return [] ++ ++ ++@pytest.fixture ++def presence_events(): ++ return [] ++ ++ ++@pytest.fixture ++def client(own_user): ++ return FakeMatrixClient(own_user.user_id) ++ ++ ++@pytest.fixture ++def manager(client, get_user, reachability_events, presence_events, stop_event): ++ def on_reachability(address, reachability): ++ reachability_events.append((address, reachability)) ++ ++ def on_presence(user, presence): ++ presence_events.append((user, presence)) ++ ++ return UserAddressManager( ++ client=client, ++ get_user_callable=get_user, ++ address_reachability_changed_callback=on_reachability, ++ user_presence_changed_callback=on_presence, ++ stop_event=stop_event, ++ ) ++ ++ ++def reachability_count(events, address): ++ return len([1 for addr, _ in events if addr == address]) ++ ++ ++def test_unknown_address_defaults(manager, addr1, user1_s1): ++ assert set(manager.known_addresses) == set() ++ assert not manager.is_address_known(addr1) ++ assert set(manager.get_userids_for_address(addr1)) == set() ++ assert manager.get_address_reachability(addr1) is AddressReachability.UNKNOWN ++ assert manager.get_userid_presence(user1_s1.user_id) is UserPresence.UNKNOWN ++ ++ ++def test_presence_for_untracked_address_is_ignored( ++ manager, ++ client, ++ addr1, ++ user1_s1, ++ reachability_events, ++ presence_events, ++): ++ client.emit_presence(user1_s1.user_id, UserPresence.ONLINE) ++ ++ assert manager.get_address_reachability(addr1) is AddressReachability.UNKNOWN ++ assert reachability_events == [] ++ assert presence_events == [] ++ assert not manager.is_address_known(addr1) ++ ++ ++def test_presence_for_invalid_or_own_user_is_ignored( ++ manager, ++ client, ++ own_user, ++ reachability_events, ++ presence_events, ++): ++ client.emit_presence('bla:bla', UserPresence.ONLINE) ++ client.emit_presence(own_user.user_id, UserPresence.ONLINE) ++ ++ assert reachability_events == [] ++ assert presence_events == [] ++ ++ ++def test_add_address_then_presence_makes_reachable( ++ manager, ++ client, ++ addr1, ++ user1_s1, ++ reachability_events, ++ presence_events, ++): ++ manager.add_address(addr1) ++ ++ assert manager.is_address_known(addr1) ++ assert set(manager.known_addresses) == {addr1} ++ ++ client.emit_presence(user1_s1.user_id, UserPresence.ONLINE) ++ ++ assert manager.get_address_reachability(addr1) is AddressReachability.REACHABLE ++ assert set(manager.get_userids_for_address(addr1)) == {user1_s1.user_id} ++ assert manager.get_userid_presence(user1_s1.user_id) is UserPresence.ONLINE ++ assert reachability_count(reachability_events, addr1) == 1 ++ assert reachability_events[-1] == (addr1, AddressReachability.REACHABLE) ++ assert len(presence_events) == 1 ++ assert presence_events[-1][0].user_id == user1_s1.user_id ++ assert presence_events[-1][1] is UserPresence.ONLINE ++ ++ ++def test_unavailable_user_is_reachable(manager, client, addr1, user1_s1): ++ manager.add_address(addr1) ++ client.emit_presence(user1_s1.user_id, UserPresence.UNAVAILABLE) ++ assert manager.get_address_reachability(addr1) is AddressReachability.REACHABLE ++ ++ ++def test_offline_user_is_unreachable(manager, client, addr1, user1_s1): ++ manager.add_address(addr1) ++ client.emit_presence(user1_s1.user_id, UserPresence.OFFLINE) ++ assert manager.get_address_reachability(addr1) is AddressReachability.UNREACHABLE ++ ++ ++def test_callbacks_fire_only_on_transition( ++ manager, ++ client, ++ addr1, ++ user1_s1, ++ reachability_events, ++ presence_events, ++): ++ manager.add_address(addr1) ++ client.emit_presence(user1_s1.user_id, UserPresence.ONLINE) ++ client.emit_presence(user1_s1.user_id, UserPresence.ONLINE) ++ client.emit_presence(user1_s1.user_id, UserPresence.ONLINE) ++ ++ assert reachability_count(reachability_events, addr1) == 1 ++ assert len(presence_events) == 1 ++ ++ ++def test_reachability_is_composed_across_users( ++ manager, ++ client, ++ addr1, ++ user1_s1, ++ user1_s2, ++ reachability_events, ++): ++ manager.add_address(addr1) ++ ++ client.emit_presence(user1_s1.user_id, UserPresence.ONLINE) ++ assert manager.get_address_reachability(addr1) is AddressReachability.REACHABLE ++ ++ client.emit_presence(user1_s1.user_id, UserPresence.OFFLINE) ++ assert manager.get_address_reachability(addr1) is AddressReachability.UNREACHABLE ++ ++ ++ ++ client.emit_presence(user1_s2.user_id, UserPresence.ONLINE) ++ assert manager.get_address_reachability(addr1) is AddressReachability.REACHABLE ++ ++ ++ reachable_calls_before = reachability_count(reachability_events, addr1) ++ client.emit_presence(user1_s2.user_id, UserPresence.UNAVAILABLE) ++ assert manager.get_address_reachability(addr1) is AddressReachability.REACHABLE ++ assert reachability_count(reachability_events, addr1) == reachable_calls_before ++ ++ ++ client.emit_presence(user1_s2.user_id, UserPresence.OFFLINE) ++ assert manager.get_address_reachability(addr1) is AddressReachability.UNREACHABLE ++ ++ assert manager.get_userid_presence(user1_s1.user_id) is UserPresence.OFFLINE ++ assert manager.get_userid_presence(user1_s2.user_id) is UserPresence.OFFLINE ++ ++ ++def test_add_userid_implicitly_tracks_address(manager, addr1, user1_s1): ++ manager.add_userid_for_address(addr1, user1_s1.user_id) ++ assert manager.is_address_known(addr1) ++ assert set(manager.get_userids_for_address(addr1)) == {user1_s1.user_id} ++ ++ ++def test_add_userids_for_address(manager, addr2, user2_s1, user1_s2): ++ manager.add_userids_for_address(addr2, {user2_s1.user_id, user1_s2.user_id}) ++ assert manager.is_address_known(addr2) ++ assert set(manager.get_userids_for_address(addr2)) == {user2_s1.user_id, user1_s2.user_id} ++ ++ ++def test_force_presence_does_not_recompute_or_call_back( ++ manager, ++ addr1, ++ user1_s1, ++ reachability_events, ++ presence_events, ++): ++ manager.add_userid_for_address(addr1, user1_s1.user_id) ++ manager.force_user_presence(user1_s1, UserPresence.ONLINE) ++ ++ assert manager.get_userid_presence(user1_s1.user_id) is UserPresence.ONLINE ++ assert manager.get_address_reachability(addr1) is AddressReachability.UNKNOWN ++ assert reachability_events == [] ++ assert presence_events == [] ++ ++ ++ manager.refresh_address_presence(addr1) ++ ++ assert manager.get_address_reachability(addr1) is AddressReachability.REACHABLE ++ assert reachability_count(reachability_events, addr1) == 1 ++ assert reachability_events[-1] == (addr1, AddressReachability.REACHABLE) ++ ++ assert presence_events == [] ++ ++ ++def test_refresh_queries_client_for_uncached_presence( ++ manager, ++ client, ++ addr2, ++ user2_s1, ++): ++ client.get_user_presence = Mock(return_value=UserPresence.ONLINE.value) ++ ++ manager.add_userid_for_address(addr2, user2_s1.user_id) ++ manager.refresh_address_presence(addr2) ++ ++ assert manager.get_address_reachability(addr2) is AddressReachability.REACHABLE ++ client.get_user_presence.assert_called_with(user2_s1.user_id) ++ ++ ++def test_refresh_treats_failed_lookup_as_unknown(manager, client, addr2, user2_s1): ++ client.get_user_presence = Mock(side_effect=MatrixRequestError(404)) ++ ++ manager.add_userid_for_address(addr2, user2_s1.user_id) ++ manager.refresh_address_presence(addr2) ++ ++ assert manager.get_address_reachability(addr2) is AddressReachability.UNKNOWN ++ ++ ++def test_stop_event_disables_presence_processing( ++ manager, ++ client, ++ stop_event, ++ addr1, ++ user1_s1, ++ reachability_events, ++ presence_events, ++): ++ manager.add_address(addr1) ++ stop_event.set() ++ ++ client.emit_presence(user1_s1.user_id, UserPresence.ONLINE) ++ ++ assert reachability_events == [] ++ assert presence_events == [] ++ assert manager.get_address_reachability(addr1) is AddressReachability.UNKNOWN ++ assert manager.get_userid_presence(user1_s1.user_id) is UserPresence.UNKNOWN ++ ++ ++def test_non_presence_events_are_ignored( ++ manager, ++ client, ++ addr1, ++ user1_s1, ++ reachability_events, ++ presence_events, ++): ++ manager.add_address(addr1) ++ client.emit_raw({ ++ 'sender': user1_s1.user_id, ++ 'type': 'm.room.message', ++ 'content': {'presence': UserPresence.ONLINE.value}, ++ }) ++ ++ assert reachability_events == [] ++ assert presence_events == [] ++ assert manager.get_address_reachability(addr1) is AddressReachability.UNKNOWN +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,23 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++ ++ ++ ++ ++/root/.venv/bin/python -m pytest -q \ ++ raiden/tests/unit/test_matrix_transport.py \ ++ raiden/tests/unit/test_utils.py ++ ++ ++/root/.venv/bin/python -m pytest -q \ ++ raiden/tests/unit/test_matrix_user_address_manager.py diff --git a/tasks/format-code-task-002476/tests/test.sh b/tasks/format-code-task-002476/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..588f21f07abe80db2ccdcaeefc3f2f08fcc38f97 --- /dev/null +++ b/tasks/format-code-task-002476/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +raiden/tests/unit/test_matrix_user_address_manager.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002476/tests/test_command.sh b/tasks/format-code-task-002476/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002476/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002482/environment/Dockerfile b/tasks/format-code-task-002482/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d97b089f7d4650367e52dddc49917511e2df16f2 --- /dev/null +++ b/tasks/format-code-task-002482/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:739e6c0a6c1f6db04eb604371a358e1dbc9b0cb00cddcbf6f9b330d637ad0957 diff --git a/tasks/format-code-task-002482/environment/setup/files/blocklist b/tasks/format-code-task-002482/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002482/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002482/environment/setup/setup.sh b/tasks/format-code-task-002482/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002482/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002482/tests/test.patch b/tasks/format-code-task-002482/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..2acf0e3f8aa3f35df53687ae3d175c74413d95a7 --- /dev/null +++ b/tasks/format-code-task-002482/tests/test.patch @@ -0,0 +1,481 @@ +diff --git a/usercase-test-coderl/test_app_command_sync_translations.py b/usercase-test-coderl/test_app_command_sync_translations.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_app_command_sync_translations.py +@@ -0,0 +1,450 @@ ++ ++ ++ ++ ++ ++ ++ ++import pytest ++ ++import discord ++from discord import app_commands ++ ++ ++APPLICATION_ID = 246813579 ++GUILD_ID = 987654321 ++ ++ ++class RecorderHTTP: ++ def __init__(self): ++ self.calls = [] ++ ++ async def bulk_upsert_global_commands(self, application_id, *, payload): ++ self.calls.append(("global", application_id, payload)) ++ return [] ++ ++ async def bulk_upsert_guild_commands(self, application_id, guild_id, *, payload): ++ self.calls.append(("guild", application_id, guild_id, payload)) ++ return [] ++ ++ ++class Guild: ++ id = GUILD_ID ++ ++ ++class SelectiveTranslator(app_commands.Translator): ++ def __init__(self, prefix="xlat"): ++ self.prefix = prefix ++ self.loaded = 0 ++ self.unloaded = 0 ++ self.calls = [] ++ ++ async def load(self): ++ self.loaded += 1 ++ ++ async def unload(self): ++ self.unloaded += 1 ++ ++ async def translate(self, string, locale, context): ++ self.calls.append((str(string), locale.value, context.location.name)) ++ if locale in (discord.Locale.german, discord.Locale.japanese): ++ return f"{self.prefix}:{context.location.name}:{str(string)}:{locale.value}" ++ return None ++ ++ ++class FailingTranslator(app_commands.Translator): ++ async def translate(self, string, locale, context): ++ raise RuntimeError("translation backend down") ++ ++ ++def make_tree(*, application_id=APPLICATION_ID): ++ client = discord.Client(intents=discord.Intents.none(), application_id=application_id) ++ http = RecorderHTTP() ++ client.http = http ++ return app_commands.CommandTree(client), http ++ ++ ++def add_full_global_command_set(tree): ++ @tree.command(name=app_commands.locale_str("launch"), description=app_commands.locale_str("Launch a ship")) ++ @app_commands.rename(style=app_commands.locale_str("ship-style")) ++ @app_commands.describe(style=app_commands.locale_str("Style to launch")) ++ @app_commands.choices( ++ style=[ ++ app_commands.Choice(name=app_commands.locale_str("Scout"), value="scout"), ++ app_commands.Choice(name=app_commands.locale_str("Carrier"), value="carrier"), ++ ] ++ ) ++ async def launch(interaction: discord.Interaction, style: app_commands.Choice[str]) -> None: ++ pass ++ ++ fleet = app_commands.Group( ++ name=app_commands.locale_str("fleet"), ++ description=app_commands.locale_str("Fleet commands"), ++ ) ++ ++ @fleet.command(name=app_commands.locale_str("dock"), description=app_commands.locale_str("Dock a ship")) ++ @app_commands.rename(bay=app_commands.locale_str("dock-bay")) ++ @app_commands.describe(bay=app_commands.locale_str("Bay number")) ++ async def dock(interaction: discord.Interaction, bay: int) -> None: ++ pass ++ ++ tree.add_command(fleet) ++ ++ @tree.context_menu(name=app_commands.locale_str("Inspect Target")) ++ async def inspect_target(interaction: discord.Interaction, user: discord.User) -> None: ++ pass ++ ++ ++def add_simple_global_command(tree, *, name="ping", description="Ping command"): ++ @tree.command(name=app_commands.locale_str(name), description=app_commands.locale_str(description)) ++ async def ping(interaction: discord.Interaction) -> None: ++ pass ++ ++ ++def add_simple_guild_command(tree, guild): ++ @tree.command( ++ name=app_commands.locale_str("guild-only"), ++ description=app_commands.locale_str("Guild command"), ++ guild=guild, ++ ) ++ async def guild_only(interaction: discord.Interaction) -> None: ++ pass ++ ++ ++ALL_LOCALE_VALUES = {locale.value for locale in discord.Locale} ++ ++ ++def assert_translated_for_all_locales(translator, string, location): ++ ++ seen = { ++ locale ++ for called_string, locale, called_location in translator.calls ++ if called_string == string and called_location == location ++ } ++ assert seen == ALL_LOCALE_VALUES ++ ++ ++def find_payload(payload, *, name, type=None): ++ for item in payload: ++ if item.get("name") == name and (type is None or item.get("type") == type): ++ return item ++ raise AssertionError(f"payload item not found: {name!r}") ++ ++ ++def assert_localizations(item, field, expected): ++ ++ assert item.get(field) == expected ++ ++ ++def assert_no_localizations(item): ++ ++ assert "name_localizations" not in item ++ assert "description_localizations" not in item ++ ++ ++@pytest.mark.asyncio ++async def test_global_sync_includes_localized_payload_for_commands_groups_params_choices_and_context_menus(): ++ ++ ++ ++ tree, http = make_tree() ++ add_full_global_command_set(tree) ++ translator = SelectiveTranslator() ++ ++ assert tree.translator is None ++ await tree.set_translator(translator) ++ assert translator.loaded == 1 ++ assert translator.unloaded == 0 ++ ++ synced = await tree.sync() ++ ++ assert synced == [] ++ for string, location in [ ++ ("launch", "command_name"), ++ ("Launch a ship", "command_description"), ++ ("ship-style", "parameter_name"), ++ ("Style to launch", "parameter_description"), ++ ("Scout", "choice_name"), ++ ("Carrier", "choice_name"), ++ ("fleet", "group_name"), ++ ("Fleet commands", "group_description"), ++ ("dock", "command_name"), ++ ("Dock a ship", "command_description"), ++ ("dock-bay", "parameter_name"), ++ ("Bay number", "parameter_description"), ++ ("Inspect Target", "command_name"), ++ ]: ++ assert_translated_for_all_locales(translator, string, location) ++ ++ ++ assert len(http.calls) == 1 ++ route, application_id, payload = http.calls[0] ++ assert route == "global" ++ assert application_id == APPLICATION_ID ++ assert len(payload) == 3 ++ ++ launch = find_payload(payload, name="launch", type=1) ++ assert launch["description"] == "Launch a ship" ++ assert_localizations( ++ launch, ++ "name_localizations", ++ {"de": "xlat:command_name:launch:de", "ja": "xlat:command_name:launch:ja"}, ++ ) ++ assert_localizations( ++ launch, ++ "description_localizations", ++ { ++ "de": "xlat:command_description:Launch a ship:de", ++ "ja": "xlat:command_description:Launch a ship:ja", ++ }, ++ ) ++ style = find_payload(launch["options"], name="ship-style", type=3) ++ assert style["description"] == "Style to launch" ++ assert_localizations( ++ style, ++ "name_localizations", ++ {"de": "xlat:parameter_name:ship-style:de", "ja": "xlat:parameter_name:ship-style:ja"}, ++ ) ++ assert_localizations( ++ style, ++ "description_localizations", ++ { ++ "de": "xlat:parameter_description:Style to launch:de", ++ "ja": "xlat:parameter_description:Style to launch:ja", ++ }, ++ ) ++ scout = find_payload(style["choices"], name="Scout") ++ carrier = find_payload(style["choices"], name="Carrier") ++ assert scout["value"] == "scout" ++ assert carrier["value"] == "carrier" ++ assert_localizations( ++ scout, ++ "name_localizations", ++ {"de": "xlat:choice_name:Scout:de", "ja": "xlat:choice_name:Scout:ja"}, ++ ) ++ assert_localizations( ++ carrier, ++ "name_localizations", ++ {"de": "xlat:choice_name:Carrier:de", "ja": "xlat:choice_name:Carrier:ja"}, ++ ) ++ ++ fleet = find_payload(payload, name="fleet", type=1) ++ assert fleet["description"] == "Fleet commands" ++ assert_localizations( ++ fleet, ++ "name_localizations", ++ {"de": "xlat:group_name:fleet:de", "ja": "xlat:group_name:fleet:ja"}, ++ ) ++ assert_localizations( ++ fleet, ++ "description_localizations", ++ {"de": "xlat:group_description:Fleet commands:de", "ja": "xlat:group_description:Fleet commands:ja"}, ++ ) ++ dock = find_payload(fleet["options"], name="dock", type=1) ++ assert dock["description"] == "Dock a ship" ++ assert_localizations( ++ dock, ++ "name_localizations", ++ {"de": "xlat:command_name:dock:de", "ja": "xlat:command_name:dock:ja"}, ++ ) ++ assert_localizations( ++ dock, ++ "description_localizations", ++ {"de": "xlat:command_description:Dock a ship:de", "ja": "xlat:command_description:Dock a ship:ja"}, ++ ) ++ bay = find_payload(dock["options"], name="dock-bay", type=4) ++ assert bay["description"] == "Bay number" ++ assert_localizations( ++ bay, ++ "name_localizations", ++ {"de": "xlat:parameter_name:dock-bay:de", "ja": "xlat:parameter_name:dock-bay:ja"}, ++ ) ++ assert_localizations( ++ bay, ++ "description_localizations", ++ {"de": "xlat:parameter_description:Bay number:de", "ja": "xlat:parameter_description:Bay number:ja"}, ++ ) ++ ++ inspect = find_payload(payload, name="Inspect Target", type=2) ++ assert_localizations( ++ inspect, ++ "name_localizations", ++ {"de": "xlat:command_name:Inspect Target:de", "ja": "xlat:command_name:Inspect Target:ja"}, ++ ) ++ ++ ++@pytest.mark.asyncio ++async def test_guild_sync_uses_guild_bulk_upsert_with_localized_payload(): ++ ++ ++ ++ guild = Guild() ++ tree, http = make_tree() ++ add_simple_guild_command(tree, guild) ++ translator = SelectiveTranslator() ++ ++ await tree.set_translator(translator) ++ synced = await tree.sync(guild=guild) ++ ++ assert synced == [] ++ assert_translated_for_all_locales(translator, "guild-only", "command_name") ++ assert_translated_for_all_locales(translator, "Guild command", "command_description") ++ ++ ++ assert len(http.calls) == 1 ++ route, application_id, guild_id, payload = http.calls[0] ++ assert route == "guild" ++ assert application_id == APPLICATION_ID ++ assert guild_id == GUILD_ID ++ assert len(payload) == 1 ++ command = find_payload(payload, name="guild-only", type=1) ++ assert command["description"] == "Guild command" ++ assert_localizations( ++ command, ++ "name_localizations", ++ {"de": "xlat:command_name:guild-only:de", "ja": "xlat:command_name:guild-only:ja"}, ++ ) ++ assert_localizations( ++ command, ++ "description_localizations", ++ { ++ "de": "xlat:command_description:Guild command:de", ++ "ja": "xlat:command_description:Guild command:ja", ++ }, ++ ) ++ ++ ++@pytest.mark.asyncio ++async def test_translation_error_prevents_http_submission(): ++ ++ ++ ++ tree, http = make_tree() ++ add_simple_global_command(tree, name="fail", description="Fail command") ++ await tree.set_translator(FailingTranslator()) ++ ++ with pytest.raises(app_commands.TranslationError) as exc_info: ++ await tree.sync() ++ ++ assert type(exc_info.value.__cause__) is RuntimeError ++ ++ assert exc_info.value.string == app_commands.locale_str("fail") ++ assert exc_info.value.locale in set(discord.Locale) ++ assert http.calls == [] ++ ++ ++@pytest.mark.asyncio ++async def test_sync_without_application_id_raises_missing_application_id_before_http(): ++ ++ ++ ++ tree, http = make_tree(application_id=None) ++ add_simple_global_command(tree, name="ping", description="Ping command") ++ ++ with pytest.raises(app_commands.MissingApplicationID) as exc_info: ++ await tree.sync() ++ ++ ++ assert exc_info.type is app_commands.MissingApplicationID ++ assert http.calls == [] ++ ++ ++@pytest.mark.asyncio ++async def test_set_translator_none_is_idempotent_cleanup(): ++ ++ ++ ++ tree, _ = make_tree() ++ translator = SelectiveTranslator() ++ ++ assert tree.translator is None ++ await tree.set_translator(translator) ++ assert translator.loaded == 1 ++ assert translator.unloaded == 0 ++ ++ await tree.set_translator(None) ++ assert tree.translator is None ++ assert translator.loaded == 1 ++ assert translator.unloaded == 1 ++ ++ await tree.set_translator(None) ++ assert tree.translator is None ++ assert translator.loaded == 1 ++ assert translator.unloaded == 1 ++ ++ ++@pytest.mark.asyncio ++async def test_command_tree_translator_state_is_per_client_instance(): ++ ++ ++ ++ tree_a, http_a = make_tree() ++ tree_b, http_b = make_tree() ++ add_simple_global_command(tree_a, name="alpha", description="Alpha command") ++ add_simple_global_command(tree_b, name="beta", description="Beta command") ++ translator = SelectiveTranslator(prefix="a") ++ ++ await tree_a.set_translator(translator) ++ synced_a = await tree_a.sync() ++ synced_b = await tree_b.sync() ++ ++ assert synced_a == [] ++ assert synced_b == [] ++ assert translator.loaded == 1 ++ assert translator.unloaded == 0 ++ assert tree_b.translator is None ++ assert_translated_for_all_locales(translator, "alpha", "command_name") ++ assert_translated_for_all_locales(translator, "Alpha command", "command_description") ++ ++ ++ assert len(http_a.calls) == 1 ++ route_a, application_id_a, payload_a = http_a.calls[0] ++ assert route_a == "global" ++ assert application_id_a == APPLICATION_ID ++ alpha = find_payload(payload_a, name="alpha", type=1) ++ assert alpha["description"] == "Alpha command" ++ assert_localizations( ++ alpha, ++ "name_localizations", ++ {"de": "a:command_name:alpha:de", "ja": "a:command_name:alpha:ja"}, ++ ) ++ assert_localizations( ++ alpha, ++ "description_localizations", ++ {"de": "a:command_description:Alpha command:de", "ja": "a:command_description:Alpha command:ja"}, ++ ) ++ ++ assert len(http_b.calls) == 1 ++ route_b, application_id_b, payload_b = http_b.calls[0] ++ assert route_b == "global" ++ assert application_id_b == APPLICATION_ID ++ beta = find_payload(payload_b, name="beta", type=1) ++ assert beta["description"] == "Beta command" ++ assert_no_localizations(beta) ++ ++ ++@pytest.mark.asyncio ++async def test_translator_install_use_cleanup_cycles_do_not_leave_translators_loaded(): ++ ++ ++ ++ translators = [] ++ http_call_count = 0 ++ ++ for index in range(100): ++ tree, http = make_tree(application_id=APPLICATION_ID + index) ++ add_simple_global_command(tree, name=f"cycle-{index}", description="Cycle command") ++ translator = SelectiveTranslator() ++ await tree.set_translator(translator) ++ synced = await tree.sync() ++ await tree.set_translator(None) ++ ++ assert synced == [] ++ assert tree.translator is None ++ assert len(http.calls) == 1 ++ translators.append(translator) ++ http_call_count += len(http.calls) ++ ++ assert http_call_count == 100 ++ assert sum(translator.loaded for translator in translators) == 100 ++ assert sum(translator.unloaded for translator in translators) == 100 +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,21 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++ ++export PYTHONDONTWRITEBYTECODE=1 ++export PYTHONNOUSERSITE=1 ++export PYTHONPATH="/workspace/repo${PYTHONPATH:+:${PYTHONPATH}}" ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++ ++exec /opt/stage4a_coderl_venv/bin/python -m pytest -p asyncio /workspace/repo/usercase-test-coderl/test_app_command_sync_translations.py -v diff --git a/tasks/format-code-task-002482/tests/test.sh b/tasks/format-code-task-002482/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..3b906a2d622a0568669cadbc1ccaf160da73320c --- /dev/null +++ b/tasks/format-code-task-002482/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/test_app_command_sync_translations.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002482/tests/test_command.sh b/tasks/format-code-task-002482/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002482/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002503/environment/Dockerfile b/tasks/format-code-task-002503/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a88aa24bbf72998e81ecc97c2582af5e6509dc57 --- /dev/null +++ b/tasks/format-code-task-002503/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:5e2a99a55c845b8f1a2fc06b221dbf4e26cb3cd0d8b45b0e70f8d9b606c94afb diff --git a/tasks/format-code-task-002503/environment/setup/files/blocklist b/tasks/format-code-task-002503/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002503/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002503/environment/setup/setup.sh b/tasks/format-code-task-002503/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002503/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002503/tests/test.patch b/tasks/format-code-task-002503/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..38acaaf0307bfaf528decff5af19fa8e47356933 --- /dev/null +++ b/tasks/format-code-task-002503/tests/test.patch @@ -0,0 +1,85 @@ +diff --git a/redisinsight/ui/src/pages/search/utils/tests/argumentAtOffset.spec.ts b/redisinsight/ui/src/pages/search/utils/tests/argumentAtOffset.spec.ts +new file mode 100644 +index 000000000..eb40abea3 +--- /dev/null ++++ b/redisinsight/ui/src/pages/search/utils/tests/argumentAtOffset.spec.ts +@@ -0,0 +1,53 @@ ++import { getArgumentAtOffset } from 'uiSrc/pages/search/utils' ++ ++const tests: Array<{ input: [string, number?]; result: any }> = [ ++ ++ { input: ['FT.SEARCH idx body', 0], result: { value: 'FT.SEARCH', start: 0, stop: 9 } }, ++ { input: ['FT.SEARCH idx body', 5], result: { value: 'FT.SEARCH', start: 0, stop: 9 } }, ++ { input: ['FT.SEARCH idx body', 9], result: { value: 'FT.SEARCH', start: 0, stop: 9 } }, ++ { input: ['FT.SEARCH idx body', 10], result: { value: 'idx', start: 10, stop: 13 } }, ++ { input: ['FT.SEARCH idx body', 13], result: { value: 'idx', start: 10, stop: 13 } }, ++ { input: ['FT.SEARCH idx body', 14], result: { value: 'body', start: 14, stop: 18 } }, ++ { input: ['FT.SEARCH idx body', 18], result: { value: 'body', start: 14, stop: 18 } }, ++ ++ ++ { input: ['hello world', 2], result: { value: 'hello', start: 0, stop: 5 } }, ++ ++ ++ { input: ['FT.SEARCH "idx:bicycle" body', 14], result: { value: '"idx:bicycle"', start: 10, stop: 23 } }, ++ { input: ['FT.SEARCH "idx:bicycle" body', 10], result: { value: '"idx:bicycle"', start: 10, stop: 23 } }, ++ { input: ['FT.SEARCH "idx:bicycle" body', 23], result: { value: '"idx:bicycle"', start: 10, stop: 23 } }, ++ { input: ["FT.SEARCH 'a b' c", 12], result: { value: "'a b'", start: 10, stop: 15 } }, ++ { input: ['"a b c"', 3], result: { value: '"a b c"', start: 0, stop: 7 } }, ++ ++ ++ { input: ['a\\ b c', 2], result: { value: 'a\\ b', start: 0, stop: 4 } }, ++ { input: ['a\\ b c', 5], result: { value: 'c', start: 5, stop: 6 } }, ++ ++ ++ { input: ['LOAD * foo', 4], result: { value: 'LOAD *', start: 0, stop: 6 } }, ++ { input: ['LOAD * foo', 6], result: { value: 'LOAD *', start: 0, stop: 6 } }, ++ { input: ['LOAD * foo', 7], result: { value: 'foo', start: 7, stop: 10 } }, ++ ++ ++ { input: ['ab cd', 3], result: null }, ++ { input: ['ab cd ', 6], result: null }, ++ { input: [' ab', 1], result: null }, ++ { input: ['', 0], result: null }, ++ { input: [' ', 0], result: null }, ++ ++ ++ { input: ['ab cd', 2], result: { value: 'ab', start: 0, stop: 2 } }, ++ { input: ['ab cd', 3], result: { value: 'cd', start: 3, stop: 5 } }, ++] ++ ++describe('getArgumentAtOffset', () => { ++ it.each(tests)('resolves argument for %j', ({ input, result }) => { ++ expect(getArgumentAtOffset(...input)).toEqual(result) ++ }) ++ ++ it('defaults the offset to the end of the query', () => { ++ expect(getArgumentAtOffset('FT.SEARCH idx body')).toEqual({ value: 'body', start: 14, stop: 18 }) ++ expect(getArgumentAtOffset('FT.SEARCH idx body ')).toEqual(null) ++ }) ++}) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,21 @@ ++#!/usr/bin/env bash ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++npx jest \ ++ redisinsight/ui/src/pages/search/utils/tests/query.spec.ts \ ++ redisinsight/ui/src/pages/search/utils/tests/monaco.spec.ts \ ++ redisinsight/ui/src/pages/search/components/query/utils.spec.ts \ ++ -w 1 ++ ++ ++npx jest \ ++ redisinsight/ui/src/pages/search/utils/tests/argumentAtOffset.spec.ts \ ++ -w 1 diff --git a/tasks/format-code-task-002503/tests/test.sh b/tasks/format-code-task-002503/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..321618f99ad8e1028a0e3269975b29239745d661 --- /dev/null +++ b/tasks/format-code-task-002503/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +redisinsight/ui/src/pages/search/utils/tests/argumentAtOffset.spec.ts +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002503/tests/test_command.sh b/tasks/format-code-task-002503/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002503/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002504/environment/Dockerfile b/tasks/format-code-task-002504/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..3cea2300eedd2d6535b72e42742c5e0e2b50c0f3 --- /dev/null +++ b/tasks/format-code-task-002504/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:a99e350584402246eeccb7fa7ba3bb6af74430f9d8fd61c31abdc68d1b3d57c2 diff --git a/tasks/format-code-task-002504/environment/setup/files/blocklist b/tasks/format-code-task-002504/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002504/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002504/environment/setup/setup.sh b/tasks/format-code-task-002504/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002504/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002504/tests/test.patch b/tasks/format-code-task-002504/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ac586816856a5dbdf1b2a52756c803dbae9a99e0 --- /dev/null +++ b/tasks/format-code-task-002504/tests/test.patch @@ -0,0 +1,96 @@ +diff --git a/tests/test_hash_model.py b/tests/test_hash_model.py +index de4bdb89..95339720 100644 +--- a/tests/test_hash_model.py ++++ b/tests/test_hash_model.py +@@ -917,3 +917,25 @@ class TestUpdate(HashModel): + + rematerialized = await TestUpdate.find(TestUpdate.pk == t.pk).first() + assert rematerialized.age == 34 ++ ++ ++@py_test_mark_asyncio ++async def test_literals(): ++ from typing import Literal ++ ++ class TestLiterals(HashModel): ++ flavor: Literal["apple", "pumpkin"] = Field(index=True, default="apple") ++ ++ schema = TestLiterals.redisearch_schema() ++ ++ key_prefix = TestLiterals.make_key( ++ TestLiterals._meta.primary_key_pattern.format(pk="") ++ ) ++ assert schema == ( ++ f"ON HASH PREFIX 1 {key_prefix} SCHEMA pk TAG SEPARATOR | flavor TAG SEPARATOR |" ++ ) ++ await Migrator().run() ++ item = TestLiterals(flavor="pumpkin") ++ await item.save() ++ rematerialized = await TestLiterals.find(TestLiterals.flavor == "pumpkin").first() ++ assert rematerialized.pk == item.pk +diff --git a/tests/test_json_model.py b/tests/test_json_model.py +index 47cfd2f8..24f0f627 100644 +--- a/tests/test_json_model.py ++++ b/tests/test_json_model.py +@@ -1098,6 +1098,7 @@ class ModelWithIntPk(JsonModel): + m = await ModelWithIntPk.find(ModelWithIntPk.my_id == 42).first() + assert m.my_id == 42 + ++ + @py_test_mark_asyncio + async def test_pagination(): + class Test(JsonModel): +@@ -1121,3 +1122,26 @@ async def get_page(cls, offset, limit): + res = await Test.get_page(10, 30) + assert len(res) == 30 + assert res[0].num == 10 ++ ++ ++@py_test_mark_asyncio ++async def test_literals(): ++ from typing import Literal ++ ++ class TestLiterals(JsonModel): ++ flavor: Literal["apple", "pumpkin"] = Field(index=True, default="apple") ++ ++ schema = TestLiterals.redisearch_schema() ++ ++ key_prefix = TestLiterals.make_key( ++ TestLiterals._meta.primary_key_pattern.format(pk="") ++ ) ++ assert schema == ( ++ f"ON JSON PREFIX 1 {key_prefix} SCHEMA $.pk AS pk TAG SEPARATOR | " ++ "$.flavor AS flavor TAG SEPARATOR |" ++ ) ++ await Migrator().run() ++ item = TestLiterals(flavor="pumpkin") ++ await item.save() ++ rematerialized = await TestLiterals.find(TestLiterals.flavor == "pumpkin").first() ++ assert rematerialized.pk == item.pk +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,11 @@ ++H4sIAAAAAAAAA+2U32/TMBDH+5y/4tZJaDwkadJ1Q1SbxMMGQhOTOsETUuUm18YssYPtdBTG/845 ++WX+ABANpE0LcR1XT2Hfnu++dG80aWeZTVMu491gMiOPRqH0SPz7b38koHaRHh2l6TOtJcjRIejB6 ++tIx2aKwTBqBntHa/srtv/x8l2vbfoXXTTFeVUHlki4c7457+J4fD0bb/oyH1//Aopf4PHi6Fn/Of ++939/L55JFc+ELYIsh3YIZpgHgdWNyRBiXbvYYC5tqKtw6efE24vMyaVwGAT7cKZsYxAm3gjoYxql ++pFrAjXRFu3qFwmQF0Fh1Rq+vLt9ApfOmRBvIOexBd0BWSqi95ynEOS5j1ZQlpKdPkjG4AlUARGdp ++0SzRQBjmAiut5GeEFVp435p4wrDUIu/OgLixJi7lrKsjvju5e2tTi6z+Y98PVivya71siVhDEsyl ++1+MdGjlfrQsEQdr4gCTqPWXC7S18AcwKDf2zyeRy8vxOVKXdWtX+GPCTdECafN0RP9PGYOagXvkG ++hsKuVCY1kEhWagUHgygdRs/gRptrO4YkGkYDKIQFpI46qlfXMGsW9mlQyxqkojtBOfW/j3Zy0kXp ++Q/iR8t3k7tM4LxtbgLeGXDixU+n5xdurVy8uLnar9R4vUaGhCQIffCPWQes41RXMDX2J9SsltnKF ++VkOoxDVOvU9Ur3ycSaP8dADd4gW6NgW7MQ6rO0W69e4vjuoupnQglhRid8O3dLsRLoO/fTkZhmEY ++hmEYhmEYhmEYhmEYhmEYhmEYhmF+g2+cadtSACgAAA== +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-002504/tests/test.sh b/tasks/format-code-task-002504/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d0c6c9a88e3480572ad84085631e2c4f1a788e8c --- /dev/null +++ b/tasks/format-code-task-002504/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/test_hash_model.py +tests/test_json_model.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002504/tests/test_command.sh b/tasks/format-code-task-002504/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002504/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002532/environment/Dockerfile b/tasks/format-code-task-002532/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8e655c28754e5987be233570a93e31aadd2cedb9 --- /dev/null +++ b/tasks/format-code-task-002532/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:264728d1ef8322590930a6f3280872f0e9ed39c141e28fae57595fca5ba0f3fb diff --git a/tasks/format-code-task-002532/environment/setup/files/blocklist b/tasks/format-code-task-002532/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002532/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002532/environment/setup/setup.sh b/tasks/format-code-task-002532/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002532/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002532/tests/test.patch b/tasks/format-code-task-002532/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..711e32d1e1fd46ed4cfe1ee3f16568618d3d693d --- /dev/null +++ b/tasks/format-code-task-002532/tests/test.patch @@ -0,0 +1,291 @@ +diff --git a/usercase-test-coderl/fixtures/custom_verbs.dat b/usercase-test-coderl/fixtures/custom_verbs.dat +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/custom_verbs.dat +@@ -0,0 +1,1 @@ ++دوخت#دوز +diff --git a/usercase-test-coderl/fixtures/custom_words.dat b/usercase-test-coderl/fixtures/custom_words.dat +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/custom_words.dat +@@ -0,0 +1,5 @@ ++خانه 100 N ++دوخت 10 V ++دوز 10 V ++زرنگی 8 AJ ++او 7 PRO +diff --git a/usercase-test-coderl/test_lemmatizer_acceptance.py b/usercase-test-coderl/test_lemmatizer_acceptance.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_lemmatizer_acceptance.py +@@ -0,0 +1,247 @@ ++ ++ ++from __future__ import annotations ++ ++import copy ++import subprocess ++import sys ++from pathlib import Path ++ ++import pytest ++ ++from hazm import Lemmatizer ++from hazm import default_verbs ++from hazm import default_words ++ ++ ++FIXTURES = Path("/workspace/repo/usercase-test-coderl/fixtures") ++ ++ ++@pytest.fixture(scope="module") ++def default_lemmatizer() -> Lemmatizer: ++ return Lemmatizer( ++ words_file=default_words, ++ verbs_file=default_verbs, ++ joined_verb_parts=True, ++ ) ++ ++ ++def test_default_data_stems_inflected_known_noun(default_lemmatizer: Lemmatizer) -> None: ++ ++ ++ ++ actual = default_lemmatizer.lemmatize("کتاب‌ها") ++ ++ assert actual == "کتاب" ++ ++ ++def test_default_data_preserves_known_word(default_lemmatizer: Lemmatizer) -> None: ++ ++ ++ ++ actual = default_lemmatizer.lemmatize("آتشفشان") ++ ++ assert actual == "آتشفشان" ++ ++ ++def test_default_data_preserves_unknown_unsupported_token(default_lemmatizer: Lemmatizer) -> None: ++ ++ ++ ++ actual = default_lemmatizer.lemmatize("این_توکن_ساختگی_نیست") ++ ++ assert actual == "این_توکن_ساختگی_نیست" ++ ++ ++def test_default_data_recognizes_present_conjugated_verb(default_lemmatizer: Lemmatizer) -> None: ++ ++ ++ ++ actual = default_lemmatizer.lemmatize("می‌روم") ++ ++ assert actual == "رفت#رو" ++ ++ ++def test_default_data_recognizes_joined_passive_perfect_verb(default_lemmatizer: Lemmatizer) -> None: ++ ++ ++ ++ actual = default_lemmatizer.lemmatize("گفته_شده_است") ++ ++ assert actual == "گفت#گو" ++ ++ ++def test_default_data_recognizes_joined_negative_perfect_verb(default_lemmatizer: Lemmatizer) -> None: ++ ++ ++ ++ actual = default_lemmatizer.lemmatize("نچشیده_است") ++ ++ assert actual == "چشید#چش" ++ ++ ++def test_known_word_with_pos_hint_remains_unchanged(default_lemmatizer: Lemmatizer) -> None: ++ ++ ++ ++ actual = default_lemmatizer.lemmatize("مردم", pos="NOUN") ++ ++ assert actual == "مردم" ++ ++ ++def test_pronoun_pos_hint_remains_unchanged(default_lemmatizer: Lemmatizer) -> None: ++ ++ ++ ++ actual = default_lemmatizer.lemmatize("من", pos="PRON") ++ ++ assert actual == "من" ++ ++ ++def test_adjective_pos_hint_preserves_y_ending_word(default_lemmatizer: Lemmatizer) -> None: ++ ++ ++ ++ actual = default_lemmatizer.lemmatize("اجتماعی", pos="ADJ") ++ ++ assert actual == "اجتماعی" ++ ++ ++def test_verb_pos_hint_uses_verb_lookup(default_lemmatizer: Lemmatizer) -> None: ++ ++ ++ ++ actual = default_lemmatizer.lemmatize("می‌روم", pos="VERB") ++ ++ assert actual == "رفت#رو" ++ ++ ++def test_nonverb_pos_hint_does_not_use_verb_lookup(default_lemmatizer: Lemmatizer) -> None: ++ ++ ++ ++ actual = default_lemmatizer.lemmatize("می‌روم", pos="NOUN") ++ ++ assert actual == "می‌روم" ++ ++ ++def test_custom_files_provide_custom_words_and_verbs() -> None: ++ ++ ++ ++ lemmatizer = Lemmatizer( ++ words_file=FIXTURES / "custom_words.dat", ++ verbs_file=FIXTURES / "custom_verbs.dat", ++ joined_verb_parts=True, ++ ) ++ ++ assert lemmatizer.lemmatize("خانه‌ها") == "خانه" ++ assert lemmatizer.lemmatize("می‌دوزم") == "دوخت#دوز" ++ ++ ++def test_custom_joined_verb_parts_are_in_lookup_when_enabled() -> None: ++ ++ ++ ++ lemmatizer = Lemmatizer( ++ words_file=FIXTURES / "custom_words.dat", ++ verbs_file=FIXTURES / "custom_verbs.dat", ++ joined_verb_parts=True, ++ ) ++ ++ assert lemmatizer.lemmatize("دوخته_است") == "دوخت#دوز" ++ assert lemmatizer.lemmatize("ندوخته_است") == "دوخت#دوز" ++ assert lemmatizer.lemmatize("خواهد_دوخت") == "دوخت#دوز" ++ ++ ++def test_lookup_is_built_at_initialization_time(tmp_path: Path) -> None: ++ ++ ++ ++ words_path = tmp_path / "words.dat" ++ verbs_path = tmp_path / "verbs.dat" ++ words_path.write_text("دوخت\t10\tV\nدوز\t10\tV\n", encoding="utf-8") ++ verbs_path.write_text("دوخت#دوز\n", encoding="utf-8") ++ lemmatizer = Lemmatizer( ++ words_file=words_path, ++ verbs_file=verbs_path, ++ joined_verb_parts=True, ++ ) ++ verbs_path.write_text("بافت#باف\n", encoding="utf-8") ++ ++ actual = lemmatizer.lemmatize("می‌دوزم") ++ ++ assert actual == "دوخت#دوز" ++ ++ ++def test_constructor_raises_specific_error_for_missing_words_file() -> None: ++ ++ with pytest.raises(Exception): ++ Lemmatizer( ++ words_file=FIXTURES / "missing_words.dat", ++ verbs_file=FIXTURES / "custom_verbs.dat", ++ joined_verb_parts=True, ++ ) ++ ++ ++def test_lemmatize_is_referentially_transparent(default_lemmatizer: Lemmatizer) -> None: ++ first = default_lemmatizer.lemmatize("می‌روم") ++ second = default_lemmatizer.lemmatize("می‌روم") ++ ++ assert first == second ++ assert first == "رفت#رو" ++ assert second == "رفت#رو" ++ ++ ++def test_lemmatize_does_not_mutate_input_token(default_lemmatizer: Lemmatizer) -> None: ++ token = "کتاب‌ها" ++ pos = "NOUN" ++ before = copy.deepcopy((token, pos)) ++ ++ actual = default_lemmatizer.lemmatize(token, pos=pos) ++ ++ assert (token, pos) == before ++ assert actual == "کتاب" ++ ++ ++def test_same_input_matches_fresh_process_result(default_lemmatizer: Lemmatizer) -> None: ++ in_process = default_lemmatizer.lemmatize("گفته_شده_است") ++ script = ( ++ "import sys; " ++ "sys.path.insert(0, '/workspace/repo'); " ++ "from hazm import Lemmatizer, default_words, default_verbs; " ++ "lemmatizer = Lemmatizer(words_file=default_words, verbs_file=default_verbs, joined_verb_parts=True); " ++ "sys.stdout.write(lemmatizer.lemmatize('گفته_شده_است'))" ++ ) ++ ++ completed = subprocess.run( ++ [sys.executable, "-c", script], ++ check=True, ++ capture_output=True, ++ text=True, ++ ) ++ ++ assert in_process == "گفت#گو" ++ assert completed.stdout == "گفت#گو" ++ ++ ++def test_constructor_and_lemmatize_do_no_undeclared_side_effects(tmp_path: Path) -> None: ++ words_path = tmp_path / "words.dat" ++ verbs_path = tmp_path / "verbs.dat" ++ words_path.write_text("دوخت\t10\tV\nدوز\t10\tV\nخانه\t8\tN\n", encoding="utf-8") ++ verbs_path.write_text("دوخت#دوز\n", encoding="utf-8") ++ ++ lemmatizer = Lemmatizer( ++ words_file=words_path, ++ verbs_file=verbs_path, ++ joined_verb_parts=True, ++ ) ++ token = "می‌دوزم" ++ before = token ++ first = lemmatizer.lemmatize(token) ++ second = lemmatizer.lemmatize(token) ++ ++ ++ assert first == "دوخت#دوز" ++ assert second == "دوخت#دوز" ++ assert token == before +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,18 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo ++export PIP_NO_INDEX=1 ++export PIP_DISABLE_PIP_VERSION_CHECK=1 ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++python -m pip install --no-index --no-build-isolation -e . pytest >/dev/null ++exec python -m pytest /workspace/repo/usercase-test-coderl/test_lemmatizer_acceptance.py -v diff --git a/tasks/format-code-task-002532/tests/test.sh b/tasks/format-code-task-002532/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..b2824e3089aa4891998287f1bb0f9177c251966b --- /dev/null +++ b/tasks/format-code-task-002532/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/fixtures/custom_verbs.dat +usercase-test-coderl/fixtures/custom_words.dat +usercase-test-coderl/test_lemmatizer_acceptance.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002532/tests/test_command.sh b/tasks/format-code-task-002532/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002532/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002535/environment/Dockerfile b/tasks/format-code-task-002535/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..de028c5d03c0029d2682ebab5bcc105cc295f815 --- /dev/null +++ b/tasks/format-code-task-002535/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:10a79e929c3bf53275734232a093efe7084c5e8340252883fa964e5b9064557d diff --git a/tasks/format-code-task-002535/environment/setup/files/blocklist b/tasks/format-code-task-002535/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002535/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002535/environment/setup/setup.sh b/tasks/format-code-task-002535/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002535/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002535/tests/test.patch b/tasks/format-code-task-002535/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..19773a8ea8b656f0d41a2e03759fa09da06f1a42 --- /dev/null +++ b/tasks/format-code-task-002535/tests/test.patch @@ -0,0 +1,87 @@ +diff --git a/rotkehlchen/tests/fixtures/blockchain.py b/rotkehlchen/tests/fixtures/blockchain.py +index 867858a5d7..83df545fae 100644 +--- a/rotkehlchen/tests/fixtures/blockchain.py ++++ b/rotkehlchen/tests/fixtures/blockchain.py +@@ -671,7 +671,7 @@ def _make_substrate_manager( + rpc_endpoint if rpc_endpoint is not None else KUSAMA_DEFAULT_OWN_RPC_ENDPOINT + ) + substrate_manager = SubstrateManager( +- chain=SupportedBlockchain.KUSAMA, ++ chain=chain_type, + msg_aggregator=messages_aggregator, + greenlet_manager=greenlet_manager, + connect_at_start=connect_at_start, +diff --git a/rotkehlchen/tests/fixtures/greenlets.py b/rotkehlchen/tests/fixtures/greenlets.py +index 3de2f2140c..0004fca960 100644 +--- a/rotkehlchen/tests/fixtures/greenlets.py ++++ b/rotkehlchen/tests/fixtures/greenlets.py +@@ -3,6 +3,9 @@ + from rotkehlchen.greenlets.manager import GreenletManager + + +-@pytest.fixture(scope='session') ++@pytest.fixture + def greenlet_manager(messages_aggregator): +- return GreenletManager(msg_aggregator=messages_aggregator) ++ manager = GreenletManager(msg_aggregator=messages_aggregator) ++ yield manager ++ manager.clear() ++ manager.greenlets.clear() +diff --git a/rotkehlchen/tests/unit/test_substrate_manager.py b/rotkehlchen/tests/unit/test_substrate_manager.py +index 55723842ac..3a0cb4f44c 100644 +--- a/rotkehlchen/tests/unit/test_substrate_manager.py ++++ b/rotkehlchen/tests/unit/test_substrate_manager.py +@@ -4,7 +4,12 @@ + import pytest + + from rotkehlchen.chain.substrate.manager import SubstrateManager +-from rotkehlchen.chain.substrate.types import BlockNumber, KusamaNodeName, NodeNameAttributes ++from rotkehlchen.chain.substrate.types import ( ++ BlockNumber, ++ KusamaNodeName, ++ NodeNameAttributes, ++ PolkadotNodeName, ++) + from rotkehlchen.constants import ZERO + from rotkehlchen.constants.assets import A_KSM + from rotkehlchen.errors.misc import RemoteError +@@ -144,3 +149,18 @@ def test_set_available_nodes_call_order(kusama_manager): + ]) + def test_format_own_rpc_endpoint(endpoint, formatted_endpoint): + assert formatted_endpoint == SubstrateManager._format_own_rpc_endpoint(endpoint) ++ ++ ++def test_connect_to_own_node(polkadot_manager: 'SubstrateManager'): ++ polkadot_manager.connect_at_start = [PolkadotNodeName.OWN, PolkadotNodeName.PARITY] ++ polkadot_manager.own_rpc_endpoint = '' ++ polkadot_manager.attempt_connections() ++ assert [task.task_name for task in polkadot_manager.greenlet_manager.greenlets] == ['polkadot manager connection to parity node'] # noqa: E501 ++ polkadot_manager.greenlet_manager.clear() ++ polkadot_manager.greenlet_manager.greenlets = [] ++ polkadot_manager.own_rpc_endpoint = 'http://localhost:1234' ++ polkadot_manager.attempt_connections() ++ assert [task.task_name for task in polkadot_manager.greenlet_manager.greenlets] == [ ++ 'polkadot manager connection to own node node', ++ 'polkadot manager connection to parity node', ++ ] +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,5 @@ ++H4sIAAAAAAAAA+3SQW6DMBAFUNacwhcIsaEQKZexDB4F1MRG9gDN7evSVqkqtdkkqqL+txkjjD3i ++T9FOw9FqcvM2uxeZ7Op6rcn3uq5VXSrVyJ2sy0y+rWQm6rt19MUU2QQhsuA9/7bv2vsHVVzyZ4qs ++O386GWeL2N/ujmv5l2V1yV82Kf+nRqX85e1a+Nk/z7+zYg2+JZtbmjdxGbjrxXjm3rtKVIVS+edD ++qmnngWZyvAQzjhSK8SyC52fqj11Pbj0qbic38Ps4xamNHAyTTlNlDusH+/3HpDlHHWv22i9OO29J ++bF7mmP/1LwEAAAAAAAAAAAAAAAAAAAAAeBiv1OZm2wAoAAA= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-002535/tests/test.sh b/tasks/format-code-task-002535/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..6f7856a1756baa8a6cd27f4f74b739955c107e67 --- /dev/null +++ b/tasks/format-code-task-002535/tests/test.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +rotkehlchen/tests/fixtures/blockchain.py +rotkehlchen/tests/fixtures/greenlets.py +rotkehlchen/tests/unit/test_substrate_manager.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002535/tests/test_command.sh b/tasks/format-code-task-002535/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002535/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002559/environment/Dockerfile b/tasks/format-code-task-002559/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8d283054b751753b63a3b55e5b9fc43e82c8f7c6 --- /dev/null +++ b/tasks/format-code-task-002559/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:df2857897d3b6abd4d32844fdab19a853afd38fce8a0fd87bcf1957edefef880 diff --git a/tasks/format-code-task-002559/environment/setup/files/blocklist b/tasks/format-code-task-002559/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002559/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002559/environment/setup/setup.sh b/tasks/format-code-task-002559/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002559/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002559/tests/test.patch b/tasks/format-code-task-002559/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..f3779b45d0efca1a4cb2829849c5a73d8693db94 --- /dev/null +++ b/tasks/format-code-task-002559/tests/test.patch @@ -0,0 +1,228 @@ +diff --git a/saleor/checkout/tests/test_tasks.py b/saleor/checkout/tests/test_tasks.py +new file mode 100644 +index 0000000000..94ef32584f +--- /dev/null ++++ b/saleor/checkout/tests/test_tasks.py +@@ -0,0 +1,189 @@ ++from datetime import timedelta ++ ++from django.conf import settings ++from django.utils import timezone ++ ++from ..models import Checkout, CheckoutLine ++from ..tasks import delete_expired_checkouts ++ ++ ++def _make_checkout(channel, *, email="", user=None): ++ return Checkout.objects.create( ++ currency=channel.currency_code, ++ channel=channel, ++ email=email, ++ user=user, ++ ) ++ ++ ++def _add_line(checkout, variant): ++ CheckoutLine.objects.create(checkout=checkout, variant=variant, quantity=1) ++ ++ ++def _age(checkout, delta): ++ ++ Checkout.objects.filter(pk=checkout.pk).update( ++ last_change=timezone.now() - delta ++ ) ++ ++ ++def _exists(checkout): ++ return Checkout.objects.filter(pk=checkout.pk).exists() ++ ++ ++def test_delete_expired_checkouts_removes_stale_empty_checkout(channel_USD): ++ checkout = _make_checkout(channel_USD) ++ _age(checkout, timedelta(hours=12)) ++ ++ delete_expired_checkouts() ++ ++ assert not _exists(checkout) ++ ++ ++def test_delete_expired_checkouts_keeps_recent_empty_checkout(channel_USD): ++ checkout = _make_checkout(channel_USD) ++ _age(checkout, timedelta(hours=2)) ++ ++ delete_expired_checkouts() ++ ++ assert _exists(checkout) ++ ++ ++def test_delete_expired_checkouts_removes_stale_empty_checkout_with_email(channel_USD): ++ ++ ++ checkout = _make_checkout(channel_USD, email="customer@example.com") ++ _age(checkout, timedelta(hours=12)) ++ ++ delete_expired_checkouts() ++ ++ assert not _exists(checkout) ++ ++ ++def test_delete_expired_checkouts_removes_stale_anonymous_checkout_with_lines( ++ channel_USD, variant ++): ++ checkout = _make_checkout(channel_USD) ++ _add_line(checkout, variant) ++ _age(checkout, timedelta(days=45)) ++ ++ delete_expired_checkouts() ++ ++ assert not _exists(checkout) ++ ++ ++def test_delete_expired_checkouts_keeps_recent_anonymous_checkout_with_lines( ++ channel_USD, variant ++): ++ checkout = _make_checkout(channel_USD) ++ _add_line(checkout, variant) ++ _age(checkout, timedelta(days=10)) ++ ++ delete_expired_checkouts() ++ ++ assert _exists(checkout) ++ ++ ++def test_delete_expired_checkouts_keeps_checkout_with_email_within_user_window( ++ channel_USD, variant ++): ++ ++ checkout = _make_checkout(channel_USD, email="customer@example.com") ++ _add_line(checkout, variant) ++ _age(checkout, timedelta(days=45)) ++ ++ delete_expired_checkouts() ++ ++ assert _exists(checkout) ++ ++ ++def test_delete_expired_checkouts_keeps_checkout_with_user_within_user_window( ++ channel_USD, variant, customer_user ++): ++ checkout = _make_checkout(channel_USD, user=customer_user) ++ _add_line(checkout, variant) ++ _age(checkout, timedelta(days=45)) ++ ++ delete_expired_checkouts() ++ ++ assert _exists(checkout) ++ ++ ++def test_delete_expired_checkouts_removes_stale_checkout_with_email( ++ channel_USD, variant ++): ++ checkout = _make_checkout(channel_USD, email="customer@example.com") ++ _add_line(checkout, variant) ++ _age(checkout, timedelta(days=120)) ++ ++ delete_expired_checkouts() ++ ++ assert not _exists(checkout) ++ ++ ++def test_delete_expired_checkouts_removes_stale_checkout_with_user( ++ channel_USD, variant, customer_user ++): ++ checkout = _make_checkout(channel_USD, user=customer_user) ++ _add_line(checkout, variant) ++ _age(checkout, timedelta(days=120)) ++ ++ delete_expired_checkouts() ++ ++ assert not _exists(checkout) ++ ++ ++def test_delete_expired_checkouts_keeps_fresh_checkouts_and_does_not_error( ++ channel_USD, variant ++): ++ fresh_empty = _make_checkout(channel_USD) ++ fresh_with_lines = _make_checkout(channel_USD, email="customer@example.com") ++ _add_line(fresh_with_lines, variant) ++ ++ ++ delete_expired_checkouts() ++ ++ assert _exists(fresh_empty) ++ assert _exists(fresh_with_lines) ++ ++ ++def test_delete_expired_checkouts_mixed_population(channel_USD, variant, customer_user): ++ ++ stale_empty = _make_checkout(channel_USD) ++ _age(stale_empty, timedelta(hours=12)) ++ ++ stale_anonymous = _make_checkout(channel_USD) ++ _add_line(stale_anonymous, variant) ++ _age(stale_anonymous, timedelta(days=45)) ++ ++ stale_user = _make_checkout(channel_USD, email="customer@example.com") ++ _add_line(stale_user, variant) ++ _age(stale_user, timedelta(days=120)) ++ ++ ++ fresh_empty = _make_checkout(channel_USD) ++ _age(fresh_empty, timedelta(hours=2)) ++ ++ recent_anonymous = _make_checkout(channel_USD) ++ _add_line(recent_anonymous, variant) ++ _age(recent_anonymous, timedelta(days=10)) ++ ++ mid_user = _make_checkout(channel_USD, user=customer_user) ++ _add_line(mid_user, variant) ++ _age(mid_user, timedelta(days=45)) ++ ++ delete_expired_checkouts() ++ ++ survivors = set(Checkout.objects.values_list("pk", flat=True)) ++ assert survivors == {fresh_empty.pk, recent_anonymous.pk, mid_user.pk} ++ ++ ++def test_delete_expired_checkouts_is_scheduled_periodically(): ++ schedule = settings.CELERY_BEAT_SCHEDULE ++ entries = [ ++ entry ++ for entry in schedule.values() ++ if entry.get("task") == "saleor.checkout.tasks.delete_expired_checkouts" ++ ] ++ assert len(entries) == 1 ++ assert entries[0]["schedule"] == timedelta(days=1) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,28 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++service postgresql start ++ ++for _ in $(seq 1 30); do ++ if su postgres -c "psql -tAc 'SELECT 1'" >/dev/null 2>&1; then ++ break ++ fi ++ sleep 1 ++done ++ ++PYTEST_ARGS="-p no:cacheprovider -o addopts=--ds=saleor.tests.settings" ++ ++ ++python -m pytest saleor/checkout/tests/test_cart.py $PYTEST_ARGS -q ++ ++ ++python -m pytest saleor/checkout/tests/test_tasks.py $PYTEST_ARGS -q diff --git a/tasks/format-code-task-002559/tests/test.sh b/tasks/format-code-task-002559/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..1043fd32b33663215140370418e8b8199914bda0 --- /dev/null +++ b/tasks/format-code-task-002559/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +saleor/checkout/tests/test_tasks.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002559/tests/test_command.sh b/tasks/format-code-task-002559/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002559/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002561/environment/Dockerfile b/tasks/format-code-task-002561/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..5a1d496365bf9e4b99bb68d358b81d7ed811e901 --- /dev/null +++ b/tasks/format-code-task-002561/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:58a1a8c141354a8a0fef1c1fb7d1d6b6a93833ba26006b4819743aa59c3bd82d diff --git a/tasks/format-code-task-002561/environment/setup/files/blocklist b/tasks/format-code-task-002561/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002561/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002561/environment/setup/setup.sh b/tasks/format-code-task-002561/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002561/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002561/tests/test.patch b/tasks/format-code-task-002561/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..529b472acb1b4a78af5521349eafa1042580f4b0 --- /dev/null +++ b/tasks/format-code-task-002561/tests/test.patch @@ -0,0 +1,474 @@ +diff --git a/usercase-test-coderl/fixtures/preload.js b/usercase-test-coderl/fixtures/preload.js +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/preload.js +@@ -0,0 +1,135 @@ ++const fs = require('fs'); ++const Module = require('module'); ++const stream = require('stream'); ++ ++const configPath = process.env.MOCK_CONFIG_PATH; ++const callsPath = process.env.MOCK_CALLS_PATH; ++const scenario = process.env.MOCK_SCENARIO || ''; ++ ++function readJson(file, fallback) { ++ if (!file || !fs.existsSync(file)) { ++ return fallback; ++ } ++ return JSON.parse(fs.readFileSync(file, 'utf8')); ++} ++ ++function writeJson(file, value) { ++ fs.writeFileSync(file, JSON.stringify(value, null, 2)); ++} ++ ++function record(value) { ++ if (callsPath) { ++ fs.appendFileSync(callsPath, JSON.stringify(value) + '\n'); ++ } ++} ++ ++function configStore() { ++ return { ++ get: function(key) { ++ return readJson(configPath, {})[key]; ++ }, ++ set: function(key, value) { ++ const data = readJson(configPath, {}); ++ data[key] = value; ++ writeJson(configPath, data); ++ }, ++ delete: function(key) { ++ const data = readJson(configPath, {}); ++ delete data[key]; ++ writeJson(configPath, data); ++ } ++ }; ++} ++ ++function tokenResponse(accessToken, refreshToken) { ++ const body = { access_token: accessToken }; ++ if (refreshToken !== undefined) { ++ body.refresh_token = refreshToken; ++ } ++ return { statusCode: 200, body }; ++} ++ ++let sandboxCalls = 0; ++ ++function handleRequest(options, callback) { ++ record({ kind: 'request', uri: options.uri, method: options.method, auth: options.auth, form: options.form }); ++ ++ if (scenario === 'ocapi_invalid_retry' || scenario === 'ocapi_fault_retry' || scenario === 'ocapi_invalid_no_renew') { ++ sandboxCalls += 1; ++ if (sandboxCalls === 1) { ++ const body = scenario === 'ocapi_fault_retry' ++ ? { fault: { type: 'InvalidAccessTokenException' } } ++ ++ : { error: 'invalid_token', error_description: configStore().get('SFCC_CLIENT_TOKEN') }; ++ callback(null, { statusCode: 401, body }); ++ return; ++ } ++ callback(null, { ++ statusCode: 200, ++ body: { ++ data: [{ ++ id: 'sbx-001', ++ realm: 'zzzz', ++ instance: 's01', ++ versions: { app: '6.0.0' }, ++ state: 'started', ++ createdAt: '2024-01-02T03:04:05.000Z', ++ eol: '2024-01-03T03:04:05.000Z', ++ createdBy: 'tester@example.com', ++ autoScheduled: false, ++ resourceProfile: 'medium' ++ }] ++ } ++ }); ++ return; ++ } ++ ++ callback(null, { statusCode: 200, body: { data: [] } }); ++} ++ ++handleRequest.post = function(options, callback) { ++ record({ kind: 'post', uri: options.uri, method: options.method, auth: options.auth, form: options.form }); ++ ++ if (scenario === 'client_auth_renew') { ++ callback(null, tokenResponse('ACCESS_AUTH_RENEW', 'REFRESH_AUTH_RENEW')); ++ } else if (scenario === 'client_auth_no_renew') { ++ callback(null, tokenResponse('ACCESS_AUTH_NO_RENEW', 'REFRESH_SHOULD_BE_CLEARED')); ++ } else if (scenario === 'renew_with_refresh') { ++ callback(null, tokenResponse('ACCESS_RENEWED_FROM_REFRESH', 'REFRESH_ROTATED')); ++ } else if (scenario === 'renew_no_refresh') { ++ callback(null, tokenResponse('ACCESS_RENEWED_FROM_CLIENT_CREDENTIALS')); ++ } else if (scenario === 'renew_failure') { ++ callback(new Error('network down'), { statusCode: 503, body: { error: 'temporarily_unavailable' } }); ++ } else if (scenario === 'ocapi_invalid_retry' || scenario === 'ocapi_fault_retry') { ++ callback(null, tokenResponse('ACCESS_AFTER_AUTO_RENEW', 'REFRESH_AFTER_AUTO_RENEW')); ++ } else { ++ callback(null, tokenResponse('ACCESS_DEFAULT')); ++ } ++}; ++ ++handleRequest.get = handleRequest; ++ ++handleRequest.defaults = function() { ++ return handleRequest; ++}; ++ ++handleRequest.prototype = stream.Writable.prototype; ++ ++function openStub(url) { ++ record({ kind: 'open', url }); ++ return Promise.resolve(); ++} ++ ++const originalLoad = Module._load; ++Module._load = function(request, parent, isMain) { ++ if (request === 'request') { ++ return handleRequest; ++ } ++ if (request === 'open') { ++ return openStub; ++ } ++ if (request.endsWith('/lib/config') || request === './config') { ++ return { obtain: configStore }; ++ } ++ return originalLoad.apply(this, arguments); ++}; +diff --git a/usercase-test-coderl/usecase.sh b/usercase-test-coderl/usecase.sh +new file mode 100755 +--- /dev/null ++++ b/usercase-test-coderl/usecase.sh +@@ -0,0 +1,312 @@ ++#!/usr/bin/env bash ++ ++set -u ++export LANG=C.UTF-8 LC_ALL=C.UTF-8 TZ=UTC FORCE_COLOR=0 NO_COLOR=1 ++ ++REPO=/workspace/repo ++PRELOAD="$REPO/usercase-test-coderl/fixtures/preload.js" ++BIN="$REPO/cli.js" ++ ++if [ ! -d "$REPO/node_modules" ]; then ++ ++ echo "FAIL: missing node_modules" >&2 ++ exit 1 ++fi ++ ++TMP=$(mktemp -d); trap 'rm -rf "$TMP"' EXIT ++cd "$TMP" || exit 1 ++fail() { echo "FAIL: $*" >&2; exit 1; } ++ ++run_cli() { ++ MOCK_SCENARIO="$1" MOCK_CONFIG_PATH="$2" MOCK_CALLS_PATH="$3" \ ++ NODE_OPTIONS="--require $PRELOAD" node "$BIN" "${@:4}" >out 2>err ++} ++ ++json_get() { ++ node -e "const fs=require('fs'); const data=JSON.parse(fs.readFileSync(process.argv[1],'utf8')); const path=process.argv[2].split('.'); let v=data; for (const p of path) v = v && v[p]; if (v === undefined) process.exit(3); if (typeof v === 'object') console.log(JSON.stringify(v)); else console.log(String(v));" "$1" "$2" ++} ++ ++json_has_no_key() { ++ node -e "const fs=require('fs'); const data=JSON.parse(fs.readFileSync(process.argv[1],'utf8')); process.exit(Object.prototype.hasOwnProperty.call(data, process.argv[2]) ? 1 : 0);" "$1" "$2" ++} ++ ++json_key_is_cleared() { ++ node -e "const fs=require('fs'); const data=JSON.parse(fs.readFileSync(process.argv[1],'utf8')); process.exit(data[process.argv[2]] ? 1 : 0);" "$1" "$2" ++} ++ ++json_path_truthy() { ++ node -e "const fs=require('fs'); const data=JSON.parse(fs.readFileSync(process.argv[1],'utf8')); const path=process.argv[2].split('.'); let v=data; for (const p of path) v = v && v[p]; process.exit(v ? 0 : 1);" "$1" "$2" ++} ++ ++json_path_cleared() { ++ node -e "const fs=require('fs'); const data=JSON.parse(fs.readFileSync(process.argv[1],'utf8')); const path=process.argv[2].split('.'); let v=data; for (const p of path) v = v && v[p]; process.exit(v ? 1 : 0);" "$1" "$2" ++} ++ ++last_call_get() { ++ node -e "const fs=require('fs'); const lines=fs.readFileSync(process.argv[1],'utf8').trim().split(/\n+/).filter(Boolean).map(JSON.parse); const item=lines.filter(x => x.kind === process.argv[2]).pop(); const path=process.argv[3].split('.'); let v=item; for (const p of path) v = v && v[p]; if (typeof v === 'object') console.log(JSON.stringify(v)); else console.log(String(v));" "$1" "$2" "$3" ++} ++ ++last_post_get() { ++ last_call_get "$1" post "$2" ++} ++ ++stdout_has_sandbox_id() { ++ node -e "const fs=require('fs'); const lines=fs.readFileSync(process.argv[1],'utf8').trim().split(/\n+/).filter(Boolean); for (let i=lines.length-1;i>=0;i--) { try { const value=JSON.parse(lines[i]); if (Array.isArray(value) && value.some(x => x && x.id === process.argv[2])) process.exit(0); } catch (_) {} } process.exit(1);" "$1" "$2" ++} ++ ++text_shows_state() { ++ node -e "const fs=require('fs'); const text=fs.readFileSync(process.argv[1],'utf8').toLowerCase(); const topic=process.argv[2]; const want=process.argv[3]; const lines=text.split(/\n/).filter(l => l.includes(topic)); if (!lines.length) process.exit(1); const joined=lines.join('\n'); const absent=/(not set|no|false|absent|missing|disabled|not configured)/.test(joined); const present=/(^|[^a-z])(set|yes|true|present|configured|enabled)([^a-z]|$)/.test(joined); if (want === 'present') process.exit(present && !absent ? 0 : 2); process.exit(absent ? 0 : 3);" "$1" "$2" "$3" ++} ++ ++ ++ ++ ++cfg="$TMP/f1-config.json"; calls="$TMP/f1-calls.jsonl"; : >"$calls"; printf '{}' >"$cfg" ++run_cli client_auth_renew "$cfg" "$calls" client:auth my_client_id my_client_secret --renew; ec=$? ++EXPECTED='Authentication succeeded Auto-renewal enabled.' ++[ "$ec" -eq 0 ] || fail "F1 exit $ec; want 0" ++[ "$(cat out)" = "$EXPECTED" ] || fail "F1 stdout: $(cat out)" ++[ ! -s err ] || fail "F1 unexpected stderr: $(cat err)" ++ ++run_cli renew_no_refresh "$cfg" "$calls" client:auth:token; ec=$? ++[ "$ec" -eq 0 ] || fail "F1 token command exit $ec; want 0" ++[ "$(cat out)" = "ACCESS_AUTH_RENEW" ] || fail "F1 access token not stored" ++: >"$calls" ++run_cli renew_with_refresh "$cfg" "$calls" client:auth:renew; ec=$? ++[ "$ec" -eq 0 ] || fail "F1 renewal command exit $ec; want 0" ++[ "$(last_post_get "$calls" auth.user)" = "my_client_id" ] || fail "F1 renewal client credential not stored" ++[ "$(last_post_get "$calls" auth.pass)" = "my_client_secret" ] || fail "F1 renewal secret not stored" ++[ "$(last_post_get "$calls" form.grant_type)" = "refresh_token" ] || fail "F1 stored refresh token was not used" ++[ "$(last_post_get "$calls" form.refresh_token)" = "REFRESH_AUTH_RENEW" ] || fail "F1 refresh token not stored" ++ ++ ++ ++ ++cfg="$TMP/f2-config.json"; calls="$TMP/f2-calls.jsonl"; : >"$calls"; printf '{}' >"$cfg" ++ ++run_cli client_auth_renew "$cfg" "$calls" client:auth my_client_id my_client_secret --renew; ec=$? ++[ "$ec" -eq 0 ] || fail "F2 setup auth exit $ec; want 0" ++: >"$calls" ++run_cli client_auth_no_renew "$cfg" "$calls" client:auth my_client_id my_client_secret; ec=$? ++EXPECTED='Authentication succeeded' ++[ "$ec" -eq 0 ] || fail "F2 exit $ec; want 0" ++[ "$(cat out)" = "$EXPECTED" ] || fail "F2 stdout: $(cat out)" ++[ ! -s err ] || fail "F2 unexpected stderr: $(cat err)" ++run_cli renew_no_refresh "$cfg" "$calls" client:auth:token; ec=$? ++[ "$ec" -eq 0 ] || fail "F2 token command exit $ec; want 0" ++[ "$(cat out)" = "ACCESS_AUTH_NO_RENEW" ] || fail "F2 access token not replaced" ++run_cli renew_no_refresh "$cfg" "$calls" client:auth:renew; ec=$? ++[ "$ec" -ne 0 ] || fail "F2 renewal still possible after non-renew auth" ++run_cli renew_no_refresh "$cfg" "$calls" instance:list -v -j; ec=$? ++[ "$ec" -eq 0 ] || fail "F2 instance visibility exit $ec; want 0" ++json_path_cleared out auth.refresh_token || fail "F2 refresh token still visible as set" ++json_path_cleared out auth.auto_renew_token || fail "F2 renewal credentials still visible as configured" ++ ++ ++ ++ ++cfg="$TMP/f3-config.json"; calls="$TMP/f3-calls.jsonl"; : >"$calls"; printf '{}' >"$cfg" ++ ++run_cli client_auth_renew "$cfg" "$calls" client:auth renew_client renew_secret --renew; ec=$? ++[ "$ec" -eq 0 ] || fail "F3 setup auth exit $ec; want 0" ++: >"$calls" ++run_cli renew_with_refresh "$cfg" "$calls" client:auth:renew; ec=$? ++EXPECTED='Authentication renewal succeeded' ++[ "$ec" -eq 0 ] || fail "F3 exit $ec; want 0" ++[ "$(cat out)" = "$EXPECTED" ] || fail "F3 stdout: $(cat out)" ++[ ! -s err ] || fail "F3 unexpected stderr: $(cat err)" ++[ "$(last_call_get "$calls" post uri)" = "https://account.demandware.com/dwsso/oauth2/access_token" ] || fail "F3 token endpoint mismatch" ++[ "$(last_call_get "$calls" post auth.user)" = "renew_client" ] || fail "F3 basic auth user mismatch" ++[ "$(last_call_get "$calls" post auth.pass)" = "renew_secret" ] || fail "F3 basic auth secret mismatch" ++[ "$(last_call_get "$calls" post form.grant_type)" = "refresh_token" ] || fail "F3 grant_type mismatch" ++[ "$(last_call_get "$calls" post form.refresh_token)" = "REFRESH_AUTH_RENEW" ] || fail "F3 refresh form mismatch" ++run_cli renew_no_refresh "$cfg" "$calls" client:auth:token; ec=$? ++[ "$ec" -eq 0 ] || fail "F3 token command exit $ec; want 0" ++[ "$(cat out)" = "ACCESS_RENEWED_FROM_REFRESH" ] || fail "F3 access token not renewed" ++run_cli renew_no_refresh "$cfg" "$calls" instance:list -v -j; ec=$? ++[ "$ec" -eq 0 ] || fail "F3 instance visibility exit $ec; want 0" ++json_path_truthy out auth.refresh_token || fail "F3 refresh token not updated" ++ ++ ++ ++ ++cfg="$TMP/f4-config.json"; calls="$TMP/f4-calls.jsonl"; : >"$calls"; printf '{}' >"$cfg" ++ ++run_cli renew_no_refresh "$cfg" "$calls" client:auth renew_client renew_secret --renew; ec=$? ++[ "$ec" -eq 0 ] || fail "F4 setup auth exit $ec; want 0" ++: >"$calls" ++run_cli renew_no_refresh "$cfg" "$calls" client:auth:renew; ec=$? ++[ "$ec" -eq 0 ] || fail "F4 exit $ec; want 0" ++[ "$(cat out)" = "Authentication renewal succeeded" ] || fail "F4 stdout: $(cat out)" ++[ ! -s err ] || fail "F4 unexpected stderr: $(cat err)" ++[ "$(last_call_get "$calls" post uri)" = "https://account.demandware.com/dwsso/oauth2/access_token" ] || fail "F4 token endpoint mismatch" ++[ "$(last_call_get "$calls" post auth.user)" = "renew_client" ] || fail "F4 basic auth user mismatch" ++[ "$(last_call_get "$calls" post auth.pass)" = "renew_secret" ] || fail "F4 basic auth secret mismatch" ++[ "$(last_call_get "$calls" post form.grant_type)" = "client_credentials" ] || fail "F4 grant_type mismatch" ++[ "$(last_call_get "$calls" post form.response_type)" = "token" ] || fail "F4 response_type mismatch" ++run_cli renew_no_refresh "$cfg" "$calls" client:auth:token; ec=$? ++[ "$ec" -eq 0 ] || fail "F4 token command exit $ec; want 0" ++[ "$(cat out)" = "ACCESS_RENEWED_FROM_CLIENT_CREDENTIALS" ] || fail "F4 access token not renewed" ++run_cli renew_no_refresh "$cfg" "$calls" instance:list -v -j; ec=$? ++[ "$ec" -eq 0 ] || fail "F4 instance visibility exit $ec; want 0" ++json_path_cleared out auth.refresh_token || fail "F4 unexpected refresh token visible as set" ++ ++ ++ ++ ++cfg="$TMP/f5-config.json"; calls="$TMP/f5-calls.jsonl"; : >"$calls"; printf '{}' >"$cfg" ++run_cli renew_no_refresh "$cfg" "$calls" client:auth:renew; ec=$? ++[ "$ec" -ne 0 ] || fail "F5 exit zero; want non-zero" ++[ ! -s out ] || fail "F5 unexpected stdout: $(cat out)" ++ ++grep -qx '.*Authentication renewal not possible\. Ensure initial authentication is done with --renew flag\.' err \ ++ || fail "F5 stderr: $(cat err)" ++ ++ ++ ++ ++cfg="$TMP/f6-config.json"; calls="$TMP/f6-calls.jsonl"; : >"$calls"; printf '{}' >"$cfg" ++ ++run_cli client_auth_renew "$cfg" "$calls" client:auth renew_client renew_secret --renew; ec=$? ++[ "$ec" -eq 0 ] || fail "F6 setup auth exit $ec; want 0" ++: >"$calls" ++run_cli renew_failure "$cfg" "$calls" client:auth:renew; ec=$? ++[ "$ec" -ne 0 ] || fail "F6 exit zero; want non-zero" ++[ ! -s out ] || fail "F6 unexpected stdout: $(cat out)" ++ ++head -n 1 err | grep -q 'Authentication renewal failed:' \ ++ || fail "F6 stderr first line: $(head -n 1 err)" ++grep -q 'network down' err || fail "F6 stderr missing error detail" ++ ++ ++ ++ ++cfg="$TMP/f7-config.json"; calls="$TMP/f7-calls.jsonl"; : >"$calls"; printf '{}' >"$cfg" ++ ++run_cli client_auth_renew "$cfg" "$calls" client:auth browser_client browser_secret --renew; ec=$? ++[ "$ec" -eq 0 ] || fail "F7 setup auth exit $ec; want 0" ++port=18087 ++MOCK_SCENARIO=login_implicit MOCK_CONFIG_PATH="$cfg" MOCK_CALLS_PATH="$calls" SFCC_OAUTH_LOCAL_PORT="$port" \ ++ NODE_OPTIONS="--require $PRELOAD" node "$BIN" auth:login browser_client >out 2>err & ++pid=$! ++for _ in $(seq 1 50); do ++ if grep -q 'Waiting for user to authenticate' out 2>/dev/null; then ++ break ++ fi ++ sleep 0.1 ++done ++curl -fsS "http://localhost:$port/?access_token=ACCESS_FROM_BROWSER" >/dev/null || fail "F7 browser redirect failed" ++wait "$pid"; ec=$? ++[ "$ec" -eq 0 ] || fail "F7 exit $ec; want 0" ++ ++grep -q 'Authentication succeeded' out || fail "F7 did not report a completed browser login" ++[ ! -s err ] || fail "F7 unexpected stderr: $(cat err)" ++run_cli renew_no_refresh "$cfg" "$calls" client:auth:token; ec=$? ++[ "$ec" -eq 0 ] || fail "F7 token command exit $ec; want 0" ++[ "$(cat out)" = "ACCESS_FROM_BROWSER" ] || fail "F7 access token not stored" ++run_cli renew_no_refresh "$cfg" "$calls" client:auth:renew; ec=$? ++[ "$ec" -ne 0 ] || fail "F7 renewal still possible after implicit browser login" ++run_cli renew_no_refresh "$cfg" "$calls" instance:list -v -j; ec=$? ++[ "$ec" -eq 0 ] || fail "F7 instance visibility exit $ec; want 0" ++json_path_cleared out auth.refresh_token || fail "F7 refresh token still visible as set" ++json_path_cleared out auth.auto_renew_token || fail "F7 renewal credentials still visible as configured" ++ ++ ++ ++ ++cfg="$TMP/f8-config.json"; calls="$TMP/f8-calls.jsonl"; : >"$calls"; printf '{}' >"$cfg" ++ ++run_cli client_auth_renew "$cfg" "$calls" client:auth renew_client renew_secret --renew; ec=$? ++[ "$ec" -eq 0 ] || fail "F8 setup auth exit $ec; want 0" ++: >"$calls" ++run_cli ocapi_invalid_retry "$cfg" "$calls" sandbox:list -j; ec=$? ++EXPECTED_ERR='Warning: Authorization invalid. Auto-renewal enabled. Running authorization...' ++[ "$ec" -eq 0 ] || fail "F8 exit $ec; want 0" ++ ++stdout_has_sandbox_id out sbx-001 || fail "F8 stdout did not include retried sandbox result: $(cat out)" ++[ "$(cat err)" = "$EXPECTED_ERR" ] || fail "F8 stderr: $(cat err)" ++run_cli renew_no_refresh "$cfg" "$calls" client:auth:token; ec=$? ++[ "$ec" -eq 0 ] || fail "F8 token command exit $ec; want 0" ++[ "$(cat out)" = "ACCESS_AFTER_AUTO_RENEW" ] || fail "F8 access token not auto-renewed" ++run_cli renew_no_refresh "$cfg" "$calls" instance:list -v -j; ec=$? ++[ "$ec" -eq 0 ] || fail "F8 instance visibility exit $ec; want 0" ++json_path_truthy out auth.refresh_token || fail "F8 refresh token not auto-renewed" ++node -e "const fs=require('fs'); const calls=fs.readFileSync(process.argv[1],'utf8').trim().split(/\n+/).map(JSON.parse); const reqs=calls.filter(c => c.kind === 'request'); if (reqs.length !== 2) process.exit(1); if (reqs[0].auth.bearer !== 'ACCESS_AUTH_RENEW') process.exit(2); if (reqs[1].auth.bearer !== 'ACCESS_AFTER_AUTO_RENEW') process.exit(3);" "$calls" \ ++ || fail "F8 did not retry original request with renewed bearer token" ++ ++ ++ ++ ++cfg="$TMP/f9-config.json"; calls="$TMP/f9-calls.jsonl"; : >"$calls"; printf '{}' >"$cfg" ++ ++run_cli client_auth_renew "$cfg" "$calls" client:auth renew_client renew_secret --renew; ec=$? ++[ "$ec" -eq 0 ] || fail "F9 setup auth exit $ec; want 0" ++: >"$calls" ++run_cli ocapi_fault_retry "$cfg" "$calls" sandbox:list -j; ec=$? ++[ "$ec" -eq 0 ] || fail "F9 exit $ec; want 0" ++stdout_has_sandbox_id out sbx-001 || fail "F9 stdout did not include retried sandbox result: $(cat out)" ++[ "$(cat err)" = "$EXPECTED_ERR" ] || fail "F9 stderr: $(cat err)" ++node -e "const fs=require('fs'); const calls=fs.readFileSync(process.argv[1],'utf8').trim().split(/\n+/).map(JSON.parse); const reqs=calls.filter(c => c.kind === 'request'); if (reqs.length !== 2) process.exit(1); if (reqs[0].auth.bearer !== 'ACCESS_AUTH_RENEW') process.exit(2); if (reqs[1].auth.bearer !== 'ACCESS_AFTER_AUTO_RENEW') process.exit(3);" "$calls" \ ++ || fail "F9 did not retry original request with renewed bearer token" ++ ++ ++ ++ ++cfg="$TMP/f10-config.json"; calls="$TMP/f10-calls.jsonl"; : >"$calls"; printf '{}' >"$cfg" ++ ++run_cli client_auth_no_renew "$cfg" "$calls" client:auth my_client_id my_client_secret; ec=$? ++[ "$ec" -eq 0 ] || fail "F10 setup auth exit $ec; want 0" ++: >"$calls" ++run_cli ocapi_invalid_no_renew "$cfg" "$calls" sandbox:list -j; ec=$? ++[ "$ec" -ne 0 ] || fail "F10 exit zero; want non-zero" ++[ ! -s out ] || fail "F10 unexpected stdout: $(cat out)" ++grep -q 'Authorization missing or invalid' err || fail "F10 missing normal invalid authorization message" ++grep -q 'sfcc-ci client:auth' err || fail "F10 missing client auth guidance" ++! grep -q 'Auto-renewal enabled' err || fail "F10 unexpectedly attempted auto-renewal" ++node -e "const fs=require('fs'); const calls=fs.readFileSync(process.argv[1],'utf8').trim().split(/\n+/).filter(Boolean).map(JSON.parse); if (calls.filter(c => c.kind === 'request').length !== 1) process.exit(1); if (calls.filter(c => c.kind === 'post').length !== 0) process.exit(2);" "$calls" \ ++ || fail "F10 made renewal request or retried without renewal credentials" ++ ++ ++ ++ ++cfg="$TMP/f11-config.json"; calls="$TMP/f11-calls.jsonl"; : >"$calls"; printf '{}' >"$cfg" ++ ++run_cli client_auth_renew "$cfg" "$calls" client:auth visible_client visible_secret --renew; ec=$? ++[ "$ec" -eq 0 ] || fail "F11 setup auth exit $ec; want 0" ++run_cli renew_no_refresh "$cfg" "$calls" instance:list -v -j; ec=$? ++[ "$ec" -eq 0 ] || fail "F11 exit $ec; want 0" ++ ++json_path_truthy out auth.refresh_token || fail "F11 JSON missing set auth.refresh_token" ++json_path_truthy out auth.auto_renew_token || fail "F11 JSON missing configured auth.auto_renew_token" ++[ ! -s err ] || fail "F11 unexpected stderr: $(cat err)" ++ ++ ++ ++ ++cfg="$TMP/f12-config.json"; calls="$TMP/f12-calls.jsonl"; : >"$calls"; printf '{}' >"$cfg" ++ ++run_cli client_auth_renew "$cfg" "$calls" client:auth visible_client visible_secret --renew; ec=$? ++[ "$ec" -eq 0 ] || fail "F12 setup auth exit $ec; want 0" ++run_cli renew_no_refresh "$cfg" "$calls" instance:list -v; ec=$? ++[ "$ec" -eq 0 ] || fail "F12 exit $ec; want 0" ++ ++text_shows_state out refresh present || fail "F12 missing refresh token present indicator" ++text_shows_state out renew present || fail "F12 missing auto-renew present indicator" ++[ ! -s err ] || fail "F12 unexpected stderr: $(cat err)" ++ ++ ++ ++ ++cfg="$TMP/f13-config.json"; calls="$TMP/f13-calls.jsonl"; : >"$calls"; printf '{}' >"$cfg" ++ ++run_cli client_auth_no_renew "$cfg" "$calls" client:auth visible_client visible_secret; ec=$? ++[ "$ec" -eq 0 ] || fail "F13 setup auth exit $ec; want 0" ++run_cli renew_no_refresh "$cfg" "$calls" instance:list -v; ec=$? ++[ "$ec" -eq 0 ] || fail "F13 exit $ec; want 0" ++ ++text_shows_state out refresh absent || fail "F13 missing refresh token absent indicator" ++text_shows_state out renew absent || fail "F13 missing auto-renew absent indicator" ++[ ! -s err ] || fail "F13 unexpected stderr: $(cat err)" ++ ++echo "PASS" ++exit 0 +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,12 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++exec bash /workspace/repo/usercase-test-coderl/usecase.sh diff --git a/tasks/format-code-task-002561/tests/test.sh b/tasks/format-code-task-002561/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..8a886cf3b2835302be9a926d5c4efa816772ac51 --- /dev/null +++ b/tasks/format-code-task-002561/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/fixtures/preload.js +usercase-test-coderl/usecase.sh +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002561/tests/test_command.sh b/tasks/format-code-task-002561/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002561/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002566/environment/Dockerfile b/tasks/format-code-task-002566/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..33c5d4a59b2ad1248ec0c6bc4633d8ee74ec80e5 --- /dev/null +++ b/tasks/format-code-task-002566/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:343a0efebcc368bbfd892e38f882f8957dc634006e9ca0a03bd614cde33a85e6 diff --git a/tasks/format-code-task-002566/environment/setup/files/blocklist b/tasks/format-code-task-002566/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002566/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002566/environment/setup/setup.sh b/tasks/format-code-task-002566/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002566/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002566/tests/test.patch b/tasks/format-code-task-002566/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..9610336a59e47e24948db64e3a9340318542b59f --- /dev/null +++ b/tasks/format-code-task-002566/tests/test.patch @@ -0,0 +1,146 @@ +diff --git a/tests/unit/modules/test_dockermod.py b/tests/unit/modules/test_dockermod.py +index 116e9bbfaf..f3d837353f 100644 +--- a/tests/unit/modules/test_dockermod.py ++++ b/tests/unit/modules/test_dockermod.py +@@ -165,6 +165,7 @@ class DockerTestCase(TestCase, LoaderModuleMockMixin): + with patch.dict(docker_mod.__salt__, + {'mine.send': mine_send, + 'container_resource.run': MagicMock(), ++ 'config.get': MagicMock(return_value=True), + 'cp.cache_file': MagicMock(return_value=False)}): + with patch.dict(docker_mod.__utils__, + {'docker.get_client_args': client_args_mock}): +@@ -173,6 +174,91 @@ class DockerTestCase(TestCase, LoaderModuleMockMixin): + mine_send.assert_called_with('docker.ps', verbose=True, all=True, + host=True) + ++ def test_docker_lifecycle_updates_mine_by_default(self): ++ ''' ++ Docker lifecycle changes keep updating the mine when no opt-out is set. ++ ''' ++ mine_send = Mock() ++ ++ def config_get(key, default=None): ++ if key == 'docker.update_mine': ++ return default ++ return docker_mod.NOTSET ++ ++ with patch.dict(docker_mod.__salt__, { ++ 'config.get': MagicMock(side_effect=config_get), ++ 'mine.send': mine_send, ++ }), \ ++ patch.dict(docker_mod.__context__, {'docker.client': Mock()}, clear=True), \ ++ patch.object(docker_mod, 'state', MagicMock(return_value='stopped')): ++ docker_mod.stop('default-update-container', timeout=2) ++ ++ self.assertEqual(mine_send.call_count, 1) ++ ++ def test_docker_lifecycle_does_not_update_mine_when_disabled(self): ++ ''' ++ docker.update_mine=False suppresses automatic Docker mine publication. ++ ''' ++ mine_send = Mock() ++ ++ def config_get(key, default=None): ++ if key == 'docker.update_mine': ++ return False ++ return docker_mod.NOTSET ++ ++ with patch.dict(docker_mod.__salt__, { ++ 'config.get': MagicMock(side_effect=config_get), ++ 'mine.send': mine_send, ++ }), \ ++ patch.dict(docker_mod.__context__, {'docker.client': Mock()}, clear=True), \ ++ patch.object(docker_mod, 'state', MagicMock(return_value='stopped')): ++ docker_mod.stop('disabled-update-container', timeout=3) ++ ++ mine_send.assert_not_called() ++ ++ def test_docker_update_mine_disabled_applies_to_repeated_lifecycle_changes(self): ++ ''' ++ The disabled setting is not limited to one sample container or first call. ++ ''' ++ mine_send = Mock() ++ ++ def config_get(key, default=None): ++ if key == 'docker.update_mine': ++ return False ++ return docker_mod.NOTSET ++ ++ with patch.dict(docker_mod.__salt__, { ++ 'config.get': MagicMock(side_effect=config_get), ++ 'mine.send': mine_send, ++ }), \ ++ patch.dict(docker_mod.__context__, {'docker.client': Mock()}, clear=True), \ ++ patch.object(docker_mod, 'state', MagicMock(return_value='stopped')): ++ docker_mod.stop('disabled-update-container-a', timeout=1) ++ docker_mod.stop('disabled-update-container-b', timeout=7) ++ ++ mine_send.assert_not_called() ++ ++ def test_docker_update_mine_disabled_applies_to_other_lifecycle_actions(self): ++ ''' ++ docker.update_mine=False applies beyond one container name or action. ++ ''' ++ mine_send = Mock() ++ ++ def config_get(key, default=None): ++ if key == 'docker.update_mine': ++ return False ++ return docker_mod.NOTSET ++ ++ with patch.dict(docker_mod.__salt__, { ++ 'config.get': MagicMock(side_effect=config_get), ++ 'mine.send': mine_send, ++ }), \ ++ patch.dict(docker_mod.__context__, {'docker.client': Mock()}, clear=True), \ ++ patch.object(docker_mod, 'state', MagicMock(return_value='stopped')): ++ docker_mod.start_('unpublished-container-name') ++ ++ mine_send.assert_not_called() ++ + @skipIf(_docker_py_version() < (1, 5, 0), + 'docker module must be installed to run this test or is too old. >=1.5.0') + def test_list_networks(self, *args): +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,37 @@ ++#!/usr/bin/env bash ++set -uo pipefail ++ ++cd /testbed ++ ++ ++export PATH="$HOME/.pyenv/bin:$PATH" ++if command -v pyenv &>/dev/null; then ++ eval "$(pyenv init --path)" ++ eval "$(pyenv init -)" ++ pyenv global 3.6.15 2>/dev/null || true ++fi ++ ++ ++export PYTHONPATH=/testbed ++ ++case "${1:-}" in ++ base) ++ python --version ++ python -m pytest \ ++ tests/unit/modules/test_dockermod.py::DockerTestCase::test_check_mine_cache_is_refreshed_on_container_change_event \ ++ -v --noconftest -o "addopts=" ++ ;; ++ new) ++ python --version ++ python -m pytest \ ++ tests/unit/modules/test_dockermod.py::DockerTestCase::test_docker_lifecycle_updates_mine_by_default \ ++ tests/unit/modules/test_dockermod.py::DockerTestCase::test_docker_lifecycle_does_not_update_mine_when_disabled \ ++ tests/unit/modules/test_dockermod.py::DockerTestCase::test_docker_update_mine_disabled_applies_to_repeated_lifecycle_changes \ ++ tests/unit/modules/test_dockermod.py::DockerTestCase::test_docker_update_mine_disabled_applies_to_other_lifecycle_actions \ ++ -v --noconftest -o "addopts=" ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-002566/tests/test.sh b/tasks/format-code-task-002566/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..923900a1928d6fbb6dba7456a572d7763c030be3 --- /dev/null +++ b/tasks/format-code-task-002566/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/unit/modules/test_dockermod.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002566/tests/test_command.sh b/tasks/format-code-task-002566/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-002566/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh base && bash /testbed/mimo_test_command.sh new \ No newline at end of file diff --git a/tasks/format-code-task-002595/environment/Dockerfile b/tasks/format-code-task-002595/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ad9e52a9cf6866c694b2eb8d21bdf80796bf354d --- /dev/null +++ b/tasks/format-code-task-002595/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:63dbc3f5728754fc2e9c1f3e787fec3520196a8364b91450171eaeb6ef6719e3 diff --git a/tasks/format-code-task-002595/environment/setup/files/blocklist b/tasks/format-code-task-002595/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002595/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002595/environment/setup/setup.sh b/tasks/format-code-task-002595/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002595/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002595/tests/test.patch b/tasks/format-code-task-002595/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..b6a6c9d5c15a52191c9f61570f13d08b101a009d --- /dev/null +++ b/tasks/format-code-task-002595/tests/test.patch @@ -0,0 +1,130 @@ +diff --git a/test/test_lazy.py b/test/test_lazy.py +index 12e71b6e..611d752a 100644 +--- a/test/test_lazy.py ++++ b/test/test_lazy.py +@@ -422,3 +422,103 @@ def test_(request, case): + result.stdout.re_match_lines( + [r"E Failed: Body parameters are defined for GET request.",] + ) ++ ++ ++def test_hooks_apply_per_test_function(testdir, simple_openapi): ++ ++ testdir.make_test( ++ """ ++from hypothesis import strategies as st ++ ++@pytest.fixture ++def simple_schema(): ++ return schema ++ ++lazy_schema = schemathesis.from_pytest_fixture("simple_schema") ++ ++def before_generate_query(context, strategy): ++ return st.just({"id": "from_apply_hook"}) ++ ++@lazy_schema.hooks.apply(before_generate_query) ++@lazy_schema.parametrize() ++@settings(max_examples=1) ++def test_(request, case): ++ request.config.HYPOTHESIS_CASES += 1 ++ assert case.query["id"] == "from_apply_hook" ++""", ++ schema=simple_openapi, ++ ) ++ result = testdir.runpytest("-v", "-s") ++ ++ result.assert_outcomes(passed=1) ++ result.stdout.re_match_lines([r"Hypothesis calls: 1$"]) ++ ++ ++def test_hooks_apply_per_test_function_named(testdir, simple_openapi): ++ ++ testdir.make_test( ++ """ ++from hypothesis import strategies as st ++ ++@pytest.fixture ++def simple_schema(): ++ return schema ++ ++lazy_schema = schemathesis.from_pytest_fixture("simple_schema") ++ ++def replacement(context, strategy): ++ return st.just({"id": "named_apply"}) ++ ++@lazy_schema.hooks.apply(replacement, name="before_generate_query") ++@lazy_schema.parametrize() ++@settings(max_examples=1) ++def test_(request, case): ++ request.config.HYPOTHESIS_CASES += 1 ++ assert case.query["id"] == "named_apply" ++""", ++ schema=simple_openapi, ++ ) ++ result = testdir.runpytest("-v", "-s") ++ ++ result.assert_outcomes(passed=1) ++ result.stdout.re_match_lines([r"Hypothesis calls: 1$"]) ++ ++ ++def test_hooks_register_schema_level(testdir, simple_openapi): ++ ++ testdir.make_test( ++ """ ++from hypothesis import strategies as st ++ ++@pytest.fixture ++def simple_schema(): ++ return schema ++ ++lazy_schema = schemathesis.from_pytest_fixture("simple_schema") ++ ++@lazy_schema.hooks.register("before_generate_query") ++def schema_hook(context, strategy): ++ return st.just({"id": "from_schema_level"}) ++ ++@lazy_schema.parametrize() ++@settings(max_examples=1) ++def test_(request, case): ++ request.config.HYPOTHESIS_CASES += 1 ++ assert case.query["id"] == "from_schema_level" ++""", ++ schema=simple_openapi, ++ ) ++ result = testdir.runpytest("-v", "-s") ++ ++ result.assert_outcomes(passed=1) ++ result.stdout.re_match_lines([r"Hypothesis calls: 1$"]) ++ ++ ++def test_hooks_attribute_on_lazy_schema(): ++ ++ import schemathesis ++ from schemathesis.hooks import HookDispatcher ++ ++ lazy_schema = schemathesis.from_pytest_fixture("anything") ++ ++ assert isinstance(lazy_schema.hooks, HookDispatcher) +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..592b62e6 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["PYTHONPATH=./src:. /root/.cache/pypoetry/virtualenvs/schemathesis-QnKYwBMZ-py3.9/bin/python -m pytest test/test_lazy.py -v -k 'test_hooks_apply_per_test_function or test_hooks_apply_per_test_function_named or test_hooks_register_schema_level or test_hooks_attribute_on_lazy_schema'"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++PYTHONPATH=./src:. /root/.cache/pypoetry/virtualenvs/schemathesis-QnKYwBMZ-py3.9/bin/python -m pytest -v -rA test/test_lazy.py::test_hooks_apply_per_test_function test/test_lazy.py::test_hooks_apply_per_test_function_named test/test_lazy.py::test_hooks_register_schema_level test/test_lazy.py::test_hooks_attribute_on_lazy_schema ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002595/tests/test.sh b/tasks/format-code-task-002595/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..2e101eac5e083cc07ded499863e4a70609930617 --- /dev/null +++ b/tasks/format-code-task-002595/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test/test_lazy.py +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002595/tests/test_command.sh b/tasks/format-code-task-002595/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002595/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002644/environment/Dockerfile b/tasks/format-code-task-002644/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..708d15828d9427bdcb25824e62f72b154fe696f6 --- /dev/null +++ b/tasks/format-code-task-002644/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:3a75f2d1ce3ea610b1114c0773699fc62c3eec340b3ae71bf5b18efd0dfaab9a diff --git a/tasks/format-code-task-002644/environment/setup/files/blocklist b/tasks/format-code-task-002644/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002644/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002644/environment/setup/setup.sh b/tasks/format-code-task-002644/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002644/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002644/tests/test.patch b/tasks/format-code-task-002644/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ccb787ad9686e219cc966539a4aaea63a2d7603a --- /dev/null +++ b/tasks/format-code-task-002644/tests/test.patch @@ -0,0 +1,157 @@ +diff --git a/sherpa/plot/tests/test_plot.py b/sherpa/plot/tests/test_plot.py +index b632e575..4bfcd6cf 100644 +--- a/sherpa/plot/tests/test_plot.py ++++ b/sherpa/plot/tests/test_plot.py +@@ -653,3 +653,130 @@ def test_histogram_empty_x(): + + dp = sherpaplot.DataHistogramPlot() + assert dp.x is None ++ ++ ++ ++ ++ ++ ++def _fit_for_region_tests(): ++ """Run a fit and return (fit, par0, par1) for region projection/uncertainty tests.""" ++ data = sherpa.Data1D('testdata', _datax, _datay) ++ g1 = sherpa.Gauss1D('g1') ++ f = sherpa.Fit(data, g1) ++ f.fit() ++ return f, g1.fwhm, g1.ampl ++ ++ ++def test_reg_proj_min_max_as_tuples_clipping(): ++ """Issue #1093: min/max as tuples must not raise TypeError ++ even when values are outside parameter limits (clipping branch).""" ++ f, par0, par1 = _fit_for_region_tests() ++ ++ ++ par0.min = par0.val - 1.0 ++ par0.max = par0.val + 1.0 ++ par1.min = par1.val - 0.5 ++ par1.max = par1.val + 0.5 ++ ++ rp = sherpa.RegionProjection() ++ rp.prepare(min=(par0.val - 10.0, par1.val - 10.0), ++ max=(par0.val + 10.0, par1.val + 10.0), ++ nloop=(3, 3)) ++ rp.calc(f, par0, par1) ++ ++ assert rp.x0 is not None ++ assert rp.x1 is not None ++ assert rp.y is not None ++ assert len(rp.x0) == 9 ++ assert len(rp.x1) == 9 ++ ++ ++def test_reg_proj_min_max_as_tuples_in_bounds(): ++ """Issue #1093: min/max as tuples in-bounds must not raise TypeError.""" ++ f, par0, par1 = _fit_for_region_tests() ++ rp = sherpa.RegionProjection() ++ rp.prepare(min=(par0.val - 2.0, par1.val - 2.0), ++ max=(par0.val + 2.0, par1.val + 2.0), ++ nloop=(3, 3)) ++ rp.calc(f, par0, par1) ++ assert rp.x0 is not None ++ assert len(rp.x0) == 9 ++ ++ ++def test_reg_proj_min_max_as_lists(): ++ """Preservation: list min/max (the working syntax) must still work.""" ++ f, par0, par1 = _fit_for_region_tests() ++ rp = sherpa.RegionProjection() ++ rp.prepare(min=[par0.val - 2.0, par1.val - 2.0], ++ max=[par0.val + 2.0, par1.val + 2.0], ++ nloop=(3, 3)) ++ rp.calc(f, par0, par1) ++ assert rp.x0 is not None ++ assert len(rp.x0) == 9 ++ ++ ++def test_reg_proj_tuple_and_list_produce_same_grid(): ++ """Coincidental-correctness: tuple input must produce the same x0/x1 grid ++ as list input (catches fixes that secretly change the values).""" ++ ++ f1, p0a, p1a = _fit_for_region_tests() ++ rp_tuple = sherpa.RegionProjection() ++ rp_tuple.prepare(min=(p0a.val - 1.5, p1a.val - 1.5), ++ max=(p0a.val + 1.5, p1a.val + 1.5), ++ nloop=(4, 4)) ++ rp_tuple.calc(f1, p0a, p1a) ++ ++ ++ f2, p0b, p1b = _fit_for_region_tests() ++ rp_list = sherpa.RegionProjection() ++ rp_list.prepare(min=[p0b.val - 1.5, p1b.val - 1.5], ++ max=[p0b.val + 1.5, p1b.val + 1.5], ++ nloop=(4, 4)) ++ rp_list.calc(f2, p0b, p1b) ++ ++ assert rp_tuple.x0 == pytest.approx(rp_list.x0) ++ assert rp_tuple.x1 == pytest.approx(rp_list.x1) ++ assert rp_tuple.y == pytest.approx(rp_list.y) ++ ++ ++def test_reg_proj_min_tuple_max_none(): ++ """Equivalence class: min tuple + max None must not raise TypeError. ++ Exercises the if-None branch which contains its own item assignment path.""" ++ f, par0, par1 = _fit_for_region_tests() ++ rp = sherpa.RegionProjection() ++ rp.prepare(min=(par0.val - 1.0, par1.val - 1.0), ++ max=None, ++ nloop=(3, 3)) ++ rp.calc(f, par0, par1) ++ assert rp.x0 is not None ++ assert len(rp.x0) == 9 ++ ++ ++def test_reg_proj_min_none_max_tuple(): ++ """Equivalence class: min None + max tuple must not raise TypeError.""" ++ f, par0, par1 = _fit_for_region_tests() ++ rp = sherpa.RegionProjection() ++ rp.prepare(min=None, ++ max=(par0.val + 1.0, par1.val + 1.0), ++ nloop=(3, 3)) ++ rp.calc(f, par0, par1) ++ assert rp.x0 is not None ++ assert len(rp.x0) == 9 ++ ++ ++def test_reg_unc_min_max_as_tuples_clipping(): ++ """Issue #1093: same fix applies to RegionUncertainty.calc.""" ++ f, par0, par1 = _fit_for_region_tests() ++ par0.min = par0.val - 1.0 ++ par0.max = par0.val + 1.0 ++ par1.min = par1.val - 0.5 ++ par1.max = par1.val + 0.5 ++ ++ ru = sherpa.RegionUncertainty() ++ ru.prepare(min=(par0.val - 10.0, par1.val - 10.0), ++ max=(par0.val + 10.0, par1.val + 10.0), ++ nloop=(3, 3)) ++ ru.calc(f, par0, par1) ++ assert ru.x0 is not None ++ assert len(ru.x0) == 9 +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..676ca0c2 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest sherpa/plot/tests/test_plot.py -k \"reg_proj or reg_unc\""] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m pytest -rA sherpa/plot/tests/test_plot.py::test_reg_proj_min_max_as_tuples_clipping sherpa/plot/tests/test_plot.py::test_reg_proj_min_max_as_tuples_in_bounds sherpa/plot/tests/test_plot.py::test_reg_proj_min_max_as_lists sherpa/plot/tests/test_plot.py::test_reg_proj_tuple_and_list_produce_same_grid sherpa/plot/tests/test_plot.py::test_reg_proj_min_tuple_max_none sherpa/plot/tests/test_plot.py::test_reg_proj_min_none_max_tuple sherpa/plot/tests/test_plot.py::test_reg_unc_min_max_as_tuples_clipping ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002644/tests/test.sh b/tasks/format-code-task-002644/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..dbe873ff75c63abcf475c5304121bed7ab83ec71 --- /dev/null +++ b/tasks/format-code-task-002644/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +sherpa/plot/tests/test_plot.py +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002644/tests/test_command.sh b/tasks/format-code-task-002644/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002644/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002675/environment/Dockerfile b/tasks/format-code-task-002675/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..342a248037ee288ba0725fa7d27c1675a9fd9f83 --- /dev/null +++ b/tasks/format-code-task-002675/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:08055395b6e798a83118f5eeb51d17439f65071a7d13238663bd3d2df6f77b7c diff --git a/tasks/format-code-task-002675/environment/setup/files/blocklist b/tasks/format-code-task-002675/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002675/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002675/environment/setup/setup.sh b/tasks/format-code-task-002675/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002675/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002675/tests/test.patch b/tasks/format-code-task-002675/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..67d3ced2f8c330c2f2a7b3c6e2e8d6c49184b355 --- /dev/null +++ b/tasks/format-code-task-002675/tests/test.patch @@ -0,0 +1,133 @@ +diff --git a/src/__tests__/QueryComplexity-test.ts b/src/__tests__/QueryComplexity-test.ts +index cac7527..882b072 100644 +--- a/src/__tests__/QueryComplexity-test.ts ++++ b/src/__tests__/QueryComplexity-test.ts +@@ -166,6 +166,107 @@ describe('QueryComplexity analysis', () => { + expect(visitor.complexity).to.equal(0); + }); + ++ it('should ignore unknown fragments', () => { ++ const ast = parse(` ++ query { ++ ...UnknownFragment ++ variableScalar(count: 100) ++ } ++ `); ++ ++ const context = new CompatibleValidationContext(schema, ast, typeInfo); ++ const visitor = new ComplexityVisitor(context, { ++ maximumComplexity: 100, ++ estimators: [ ++ simpleEstimator({defaultComplexity: 10}) ++ ] ++ }); ++ ++ visit(ast, visitWithTypeInfo(typeInfo, visitor)); ++ expect(visitor.complexity).to.equal(10); ++ }); ++ ++ it('should ignore inline fragment on unknown type', () => { ++ const ast = parse(` ++ query { ++ ...on UnknownType { ++ variableScalar(count: 100) ++ } ++ } ++ `); ++ ++ const context = new CompatibleValidationContext(schema, ast, typeInfo); ++ const visitor = new ComplexityVisitor(context, { ++ maximumComplexity: 100, ++ estimators: [ ++ simpleEstimator({defaultComplexity: 10}) ++ ] ++ }); ++ ++ visit(ast, visitWithTypeInfo(typeInfo, visitor)); ++ expect(visitor.complexity).to.equal(0); ++ }); ++ ++ it('should ignore fragment on unknown type', () => { ++ const ast = parse(` ++ query { ++ ...F ++ } ++ fragment F on UnknownType { ++ variableScalar(count: 100) ++ } ++ `); ++ ++ const context = new CompatibleValidationContext(schema, ast, typeInfo); ++ const visitor = new ComplexityVisitor(context, { ++ maximumComplexity: 100, ++ estimators: [ ++ simpleEstimator({defaultComplexity: 10}) ++ ] ++ }); ++ ++ visit(ast, visitWithTypeInfo(typeInfo, visitor)); ++ expect(visitor.complexity).to.equal(0); ++ }); ++ ++ it('should ignore unused variables', () => { ++ const ast = parse(` ++ query ($unusedVar: ID!) { ++ variableScalar(count: 100) ++ } ++ `); ++ ++ const context = new CompatibleValidationContext(schema, ast, typeInfo); ++ const visitor = new ComplexityVisitor(context, { ++ maximumComplexity: 100, ++ estimators: [ ++ simpleEstimator({defaultComplexity: 10}) ++ ] ++ }); ++ ++ visit(ast, visitWithTypeInfo(typeInfo, visitor)); ++ expect(visitor.complexity).to.equal(10); ++ }); ++ ++ it('should ignore unknown field', () => { ++ const ast = parse(` ++ query { ++ unknownField ++ } ++ `); ++ ++ const context = new CompatibleValidationContext(schema, ast, typeInfo); ++ const visitor = new ComplexityVisitor(context, { ++ maximumComplexity: 100, ++ estimators: [ ++ simpleEstimator({defaultComplexity: 10}) ++ ] ++ }); ++ ++ visit(ast, visitWithTypeInfo(typeInfo, visitor)); ++ expect(visitor.complexity).to.equal(0); ++ }); ++ + it('should report error above threshold', () => { + const ast = parse(` + query { +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,5 @@ ++H4sIAAAAAAAAA+3RQW7DIBAFUK9zCnZZYWNUxwfoCXoCRPC0toLBBVzFty/2JlWlNptEVdT/NsMA ++AsQvj/NgO0XuoyruRWRt02w1+163cd1IIVshpWwLUdeHPMWau73oizkmHRgrgvfpt33X1h9Ueck/ ++UUzK+HHUritjf7s7ruUva3nJX6z5Px1EUzBxuyf87J/nbzq2BX+kbuemMxu96TXj3PRkTtySPsXc ++0XlIubzO1vIUtKHcBHqfh0AsRe58R1WgtyEmClXe4OI0WOLe2YXtYzCVUuslUanqZaawPPtxsuuh ++C1/nyxT3u7/+CQAAAAAAAAAAAAAAAAAAAACAx/MJOwaiBgAoAAA= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-002675/tests/test.sh b/tasks/format-code-task-002675/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..02685a6d9d49acde4f61bb1d1a1011506d359c0b --- /dev/null +++ b/tasks/format-code-task-002675/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +src/__tests__/QueryComplexity-test.ts +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002675/tests/test_command.sh b/tasks/format-code-task-002675/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002675/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002681/environment/Dockerfile b/tasks/format-code-task-002681/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8b167a1f5b1943e2b240a363987fe671311bd8b9 --- /dev/null +++ b/tasks/format-code-task-002681/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:2e25036948c3222832ae604f1b4eb84a12702f7c64b1676a3a778478c2baed5c diff --git a/tasks/format-code-task-002681/environment/setup/files/blocklist b/tasks/format-code-task-002681/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002681/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002681/environment/setup/setup.sh b/tasks/format-code-task-002681/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002681/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002681/tests/test.patch b/tasks/format-code-task-002681/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..3bfec80b808e4d490b7fe92a81d3c25f2607e239 --- /dev/null +++ b/tasks/format-code-task-002681/tests/test.patch @@ -0,0 +1,78 @@ +diff --git a/driver_test.go b/driver_test.go +index 4d7716d34..4a6dbe853 100644 +--- a/driver_test.go ++++ b/driver_test.go +@@ -6,6 +6,7 @@ import ( + "crypto/rsa" + "database/sql" + "database/sql/driver" ++ "errors" + "flag" + "fmt" + "net/http" +@@ -1731,7 +1732,7 @@ func TestCancelQuery(t *testing.T) { + if err == nil { + dbt.Fatal("No timeout error returned") + } +- if err.Error() != "context deadline exceeded" { ++ if !errors.Is(err, context.DeadlineExceeded) { + dbt.Fatalf("Timeout error mismatch: expect %v, receive %v", context.DeadlineExceeded, err.Error()) + } + }) +@@ -1825,7 +1826,7 @@ func TestLargeSetResultCancel(t *testing.T) { + time.Sleep(time.Second) + cancel() + ret := <-c +- if ret.Error() != "context canceled" { ++ if !errors.Is(ret, context.Canceled) { + t.Fatalf("failed to cancel. err: %v", ret) + } + close(c) +diff --git a/retry_test.go b/retry_test.go +index d5201eefc..d0dacbdca 100644 +--- a/retry_test.go ++++ b/retry_test.go +@@ -515,6 +515,18 @@ func TestIsRetryable(t *testing.T) { + res: &http.Response{StatusCode: http.StatusNotFound}, + expected: false, + }, ++ { ++ req: &http.Request{URL: &url.URL{Path: loginRequestPath}}, ++ res: nil, ++ err: &url.Error{Err: context.Canceled}, ++ expected: false, ++ }, ++ { ++ req: &http.Request{URL: &url.URL{Path: loginRequestPath}}, ++ res: nil, ++ err: &url.Error{Err: context.DeadlineExceeded}, ++ expected: false, ++ }, + { + req: &http.Request{URL: &url.URL{Path: loginRequestPath}}, + res: nil, +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,9 @@ ++H4sIAAAAAAAAA+3TX2vbMBAA8Dz7U1zTwdqH2HGYayj0YX8KLWMQmuw5KNLFFrWlTJLd7Nvv5JS0 ++BLa+tIyx+z3EQTqdpDs7XXe6USs0fTZ6K1NSFsXwJMfP4X9ezCgon85yisvzopyNoHizEz3T+SAc ++wMhZG/4U99L8Pyp96n9AH1bStq0wKvX16+3xQv/zaVEe+j8tS+r/h4u8HMH09Y7we/95/09PsrU2 ++2Vr4OpEKhpdgjSrB3da6APOPy5urcdZ5lzVWiiarbIy/fBcnxklyCnedgVAjOAzuJ3RGB4g5PJxt ++nG33w6s4klYW6M0C5XSP7jCkDXjRImyFvBcVnqeUc/H1dr5aXC+/z0H0VisPS4r+JrR572Fh7MOm ++EfcIXtbYCpAORdDWwEOtZU07/ui0Qw8CGtoJpDUGZQyIqWOiW38XTyXWDUIvGq0EHWa4hLSOfmph ++KryMCwPuQvpZGIkNquwLCtVog9c7iahQATpnnaesgpYZG/a3HfLq51W5WS7n0NhKy3iETzbUx1WI ++hTkqlTskqaw/3PmxTHCWnsd9aVkMpK92q+mIIDxFUN/shlZqP7QCXEdXf6rpVU4Z9zOTHiY0C+Oj ++soxhIm1nAoVOgm7RdgGKFtLkb7+ujDHGGGOMMcYYY4wxxhhjjDHGGGPsyC+hTDqcACgAAA== +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-002681/tests/test.sh b/tasks/format-code-task-002681/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..4a171a68e57e8ddf44d8876b8825040165b3832d --- /dev/null +++ b/tasks/format-code-task-002681/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +driver_test.go +retry_test.go +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002681/tests/test_command.sh b/tasks/format-code-task-002681/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002681/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002688/environment/Dockerfile b/tasks/format-code-task-002688/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..2849675233ad205e481dabde274846ddf3cb68e4 --- /dev/null +++ b/tasks/format-code-task-002688/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:a96fec70948691920c4349b28020324d301e12a9ab63ff2a8ef0569926b9ab9c diff --git a/tasks/format-code-task-002688/environment/setup/files/blocklist b/tasks/format-code-task-002688/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002688/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002688/environment/setup/setup.sh b/tasks/format-code-task-002688/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002688/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002688/tests/test.patch b/tasks/format-code-task-002688/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..6179913ccc154f636f70ec1998801c99208b502e --- /dev/null +++ b/tasks/format-code-task-002688/tests/test.patch @@ -0,0 +1,652 @@ +diff --git a/usercase-test-coderl/farm_quorum_write_test.go b/usercase-test-coderl/farm_quorum_write_test.go +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/farm_quorum_write_test.go +@@ -0,0 +1,620 @@ ++package usercase_test_coderl ++ ++import ( ++ "errors" ++ "fmt" ++ "reflect" ++ "strings" ++ "sync" ++ "testing" ++ "time" ++ ++ "github.com/soundcloud/roshi/cluster" ++ "github.com/soundcloud/roshi/common" ++ "github.com/soundcloud/roshi/farm" ++ "github.com/soundcloud/roshi/instrumentation" ++) ++ ++ ++ ++ ++ ++ ++var batch = []common.KeyScoreMember{ ++ {Key: "alpha", Score: 11, Member: "one"}, ++ {Key: "beta", Score: 22, Member: "two"}, ++} ++ ++func TestInsertBroadcastsBatchAndSucceedsAtWriteQuorum(t *testing.T) { ++ ++ ++ c1 := newScriptedCluster("cluster-a", nil, 0) ++ c2 := newScriptedCluster("cluster-b", nil, 5*time.Millisecond) ++ c3 := newScriptedCluster("cluster-c", errors.New("cluster-c denied"), 30*time.Millisecond) ++ instr := &recordingInstrumentation{} ++ f := farm.New([]cluster.Cluster{c1, c2, c3}, 2, farm.SendAllReadAll, farm.NoRepairs, instr) ++ ++ err := f.Insert(batch) ++ if err != nil { ++ t.Fatalf("expected nil insert error, got %v", err) ++ } ++ waitForWriteCalls(t, []*scriptedCluster{c1, c2, c3}, 1, 0, 1) ++ ++ assertCounts(t, "cluster-a", c1.snapshot(), clusterSnapshot{ ++ insertCalls: 1, ++ deleteCalls: 0, ++ insertBatches: [][]common.KeyScoreMember{ ++ { ++ {Key: "alpha", Score: 11, Member: "one"}, ++ {Key: "beta", Score: 22, Member: "two"}, ++ }, ++ }, ++ deleteBatches: [][]common.KeyScoreMember{}, ++ }) ++ assertCounts(t, "cluster-b", c2.snapshot(), clusterSnapshot{ ++ insertCalls: 1, ++ deleteCalls: 0, ++ insertBatches: [][]common.KeyScoreMember{ ++ { ++ {Key: "alpha", Score: 11, Member: "one"}, ++ {Key: "beta", Score: 22, Member: "two"}, ++ }, ++ }, ++ deleteBatches: [][]common.KeyScoreMember{}, ++ }) ++ assertCounts(t, "cluster-c", c3.snapshot(), clusterSnapshot{ ++ insertCalls: 1, ++ deleteCalls: 0, ++ insertBatches: [][]common.KeyScoreMember{ ++ { ++ {Key: "alpha", Score: 11, Member: "one"}, ++ {Key: "beta", Score: 22, Member: "two"}, ++ }, ++ }, ++ deleteBatches: [][]common.KeyScoreMember{}, ++ }) ++ assertInstrumentation(t, instr.snapshot(), instrumentationSnapshot{ ++ insertCalls: 1, ++ insertRecordCountTotal: 2, ++ insertCallDurationCalls: 1, ++ insertRecordDurationCalls: 1, ++ insertQuorumFailures: 0, ++ deleteCalls: 0, ++ deleteRecordCountTotal: 0, ++ deleteCallDurationCalls: 0, ++ deleteRecordDurationCalls: 0, ++ deleteQuorumFailures: 0, ++ }) ++} ++ ++func TestInsertQuorumFailureReturnsJoinedClusterErrors(t *testing.T) { ++ ++ ++ c1 := newScriptedCluster("cluster-a", nil, 0) ++ c2 := newScriptedCluster("cluster-b", errors.New("cluster-b denied"), 5*time.Millisecond) ++ c3 := newScriptedCluster("cluster-c", errors.New("cluster-c denied"), 10*time.Millisecond) ++ instr := &recordingInstrumentation{} ++ f := farm.New([]cluster.Cluster{c1, c2, c3}, 2, farm.SendAllReadAll, farm.NoRepairs, instr) ++ ++ err := f.Insert(batch) ++ ++ assertQuorumError(t, err, []string{"cluster-b denied", "cluster-c denied"}) ++ waitForWriteCalls(t, []*scriptedCluster{c1, c2, c3}, 1, 0, 1) ++ ++ assertInstrumentation(t, instr.snapshot(), instrumentationSnapshot{ ++ insertCalls: 1, ++ insertRecordCountTotal: 2, ++ insertCallDurationCalls: 1, ++ insertRecordDurationCalls: 1, ++ insertQuorumFailures: 1, ++ deleteCalls: 0, ++ deleteRecordCountTotal: 0, ++ deleteCallDurationCalls: 0, ++ deleteRecordDurationCalls: 0, ++ deleteQuorumFailures: 0, ++ }) ++} ++ ++func TestDeleteBroadcastsBatchAndReportsQuorumFailure(t *testing.T) { ++ ++ ++ c1 := newScriptedCluster("cluster-a", nil, 0) ++ c2 := newScriptedCluster("cluster-b", errors.New("cluster-b denied"), 5*time.Millisecond) ++ c3 := newScriptedCluster("cluster-c", errors.New("cluster-c denied"), 10*time.Millisecond) ++ instr := &recordingInstrumentation{} ++ f := farm.New([]cluster.Cluster{c1, c2, c3}, 2, farm.SendAllReadAll, farm.NoRepairs, instr) ++ ++ err := f.Delete(batch) ++ ++ assertQuorumError(t, err, []string{"cluster-b denied", "cluster-c denied"}) ++ waitForWriteCalls(t, []*scriptedCluster{c1, c2, c3}, 0, 1, 1) ++ ++ for name, c := range map[string]*scriptedCluster{"cluster-a": c1, "cluster-b": c2, "cluster-c": c3} { ++ assertCounts(t, name, c.snapshot(), clusterSnapshot{ ++ insertCalls: 0, ++ deleteCalls: 1, ++ insertBatches: [][]common.KeyScoreMember{}, ++ deleteBatches: [][]common.KeyScoreMember{ ++ { ++ {Key: "alpha", Score: 11, Member: "one"}, ++ {Key: "beta", Score: 22, Member: "two"}, ++ }, ++ }, ++ }) ++ } ++ assertInstrumentation(t, instr.snapshot(), instrumentationSnapshot{ ++ insertCalls: 0, ++ insertRecordCountTotal: 0, ++ insertCallDurationCalls: 0, ++ insertRecordDurationCalls: 0, ++ insertQuorumFailures: 0, ++ deleteCalls: 1, ++ deleteRecordCountTotal: 2, ++ deleteCallDurationCalls: 1, ++ deleteRecordDurationCalls: 1, ++ deleteQuorumFailures: 1, ++ }) ++} ++ ++func TestEmptyBatchesReturnNilWithoutClusterWrites(t *testing.T) { ++ ++ ++ c1 := newScriptedCluster("cluster-a", nil, 0) ++ c2 := newScriptedCluster("cluster-b", nil, 0) ++ c3 := newScriptedCluster("cluster-c", nil, 0) ++ instr := &recordingInstrumentation{} ++ f := farm.New([]cluster.Cluster{c1, c2, c3}, 2, farm.SendAllReadAll, farm.NoRepairs, instr) ++ ++ if err := f.Insert([]common.KeyScoreMember{}); err != nil { ++ t.Fatalf("expected nil empty insert error, got %v", err) ++ } ++ if err := f.Delete([]common.KeyScoreMember{}); err != nil { ++ t.Fatalf("expected nil empty delete error, got %v", err) ++ } ++ ++ for name, c := range map[string]*scriptedCluster{"cluster-a": c1, "cluster-b": c2, "cluster-c": c3} { ++ assertCounts(t, name, c.snapshot(), clusterSnapshot{ ++ insertCalls: 0, ++ deleteCalls: 0, ++ insertBatches: [][]common.KeyScoreMember{}, ++ deleteBatches: [][]common.KeyScoreMember{}, ++ }) ++ } ++} ++ ++func TestRepeatedWritesOnOneFarmAccumulateObservableState(t *testing.T) { ++ ++ ++ c1 := newScriptedCluster("cluster-a", nil, 0) ++ c2 := newScriptedCluster("cluster-b", nil, 0) ++ c3 := newScriptedCluster("cluster-c", nil, 0) ++ instr := &recordingInstrumentation{} ++ f := farm.New([]cluster.Cluster{c1, c2, c3}, 2, farm.SendAllReadAll, farm.NoRepairs, instr) ++ ++ if err := f.Insert(batch); err != nil { ++ t.Fatalf("expected nil insert error, got %v", err) ++ } ++ waitForWriteCalls(t, []*scriptedCluster{c1, c2, c3}, 1, 0, 1) ++ assertCounts(t, "cluster-a after insert", c1.snapshot(), clusterSnapshot{ ++ insertCalls: 1, ++ deleteCalls: 0, ++ insertBatches: [][]common.KeyScoreMember{ ++ { ++ {Key: "alpha", Score: 11, Member: "one"}, ++ {Key: "beta", Score: 22, Member: "two"}, ++ }, ++ }, ++ deleteBatches: [][]common.KeyScoreMember{}, ++ }) ++ ++ if err := f.Delete(batch); err != nil { ++ t.Fatalf("expected nil delete error, got %v", err) ++ } ++ waitForWriteCalls(t, []*scriptedCluster{c1, c2, c3}, 1, 1, 1) ++ assertCounts(t, "cluster-a after delete", c1.snapshot(), clusterSnapshot{ ++ insertCalls: 1, ++ deleteCalls: 1, ++ insertBatches: [][]common.KeyScoreMember{ ++ { ++ {Key: "alpha", Score: 11, Member: "one"}, ++ {Key: "beta", Score: 22, Member: "two"}, ++ }, ++ }, ++ deleteBatches: [][]common.KeyScoreMember{ ++ { ++ {Key: "alpha", Score: 11, Member: "one"}, ++ {Key: "beta", Score: 22, Member: "two"}, ++ }, ++ }, ++ }) ++ assertInstrumentation(t, instr.snapshot(), instrumentationSnapshot{ ++ insertCalls: 1, ++ insertRecordCountTotal: 2, ++ insertCallDurationCalls: 1, ++ insertRecordDurationCalls: 1, ++ insertQuorumFailures: 0, ++ deleteCalls: 1, ++ deleteRecordCountTotal: 2, ++ deleteCallDurationCalls: 1, ++ deleteRecordDurationCalls: 1, ++ deleteQuorumFailures: 0, ++ }) ++} ++ ++func TestIndependentFarmsDoNotShareWriteState(t *testing.T) { ++ ++ ++ a1 := newScriptedCluster("a1", nil, 0) ++ a2 := newScriptedCluster("a2", nil, 0) ++ a3 := newScriptedCluster("a3", nil, 0) ++ b1 := newScriptedCluster("b1", nil, 0) ++ b2 := newScriptedCluster("b2", nil, 0) ++ b3 := newScriptedCluster("b3", nil, 0) ++ farmAInstr := &recordingInstrumentation{} ++ farmBInstr := &recordingInstrumentation{} ++ farmA := farm.New([]cluster.Cluster{a1, a2, a3}, 2, farm.SendAllReadAll, farm.NoRepairs, farmAInstr) ++ farmB := farm.New([]cluster.Cluster{b1, b2, b3}, 2, farm.SendAllReadAll, farm.NoRepairs, farmBInstr) ++ ++ if err := farmA.Insert(batch); err != nil { ++ t.Fatalf("expected nil insert error, got %v", err) ++ } ++ waitForWriteCalls(t, []*scriptedCluster{a1, a2, a3}, 1, 0, 1) ++ ++ assertCounts(t, "farm A cluster 1", a1.snapshot(), clusterSnapshot{ ++ insertCalls: 1, ++ deleteCalls: 0, ++ insertBatches: [][]common.KeyScoreMember{ ++ { ++ {Key: "alpha", Score: 11, Member: "one"}, ++ {Key: "beta", Score: 22, Member: "two"}, ++ }, ++ }, ++ deleteBatches: [][]common.KeyScoreMember{}, ++ }) ++ assertCounts(t, "farm B cluster 1", b1.snapshot(), clusterSnapshot{ ++ insertCalls: 0, ++ deleteCalls: 0, ++ insertBatches: [][]common.KeyScoreMember{}, ++ deleteBatches: [][]common.KeyScoreMember{}, ++ }) ++ assertInstrumentation(t, farmAInstr.snapshot(), instrumentationSnapshot{ ++ insertCalls: 1, ++ insertRecordCountTotal: 2, ++ insertCallDurationCalls: 1, ++ insertRecordDurationCalls: 1, ++ insertQuorumFailures: 0, ++ deleteCalls: 0, ++ deleteRecordCountTotal: 0, ++ deleteCallDurationCalls: 0, ++ deleteRecordDurationCalls: 0, ++ deleteQuorumFailures: 0, ++ }) ++ assertInstrumentation(t, farmBInstr.snapshot(), instrumentationSnapshot{ ++ insertCalls: 0, ++ insertRecordCountTotal: 0, ++ insertCallDurationCalls: 0, ++ insertRecordDurationCalls: 0, ++ insertQuorumFailures: 0, ++ deleteCalls: 0, ++ deleteRecordCountTotal: 0, ++ deleteCallDurationCalls: 0, ++ deleteRecordDurationCalls: 0, ++ deleteQuorumFailures: 0, ++ }) ++ ++ _ = farmB ++} ++ ++func TestRepeatedConstructWriteCyclesKeepBehaviorStable(t *testing.T) { ++ ++ ++ ++ for i := 0; i < 150; i++ { ++ c1 := newScriptedCluster("cluster-a", nil, 0) ++ c2 := newScriptedCluster("cluster-b", nil, 0) ++ c3 := newScriptedCluster("cluster-c", nil, 0) ++ f := farm.New([]cluster.Cluster{c1, c2, c3}, 2, farm.SendAllReadAll, farm.NoRepairs, instrumentation.NopInstrumentation{}) ++ if err := f.Insert(batch); err != nil { ++ t.Fatalf("cycle %d: expected nil insert error, got %v", i, err) ++ } ++ waitForWriteCalls(t, []*scriptedCluster{c1, c2, c3}, 1, 0, 1) ++ } ++} ++ ++type scriptedCluster struct { ++ name string ++ writeErr error ++ writeDelay time.Duration ++ mu sync.Mutex ++ insertCalls int ++ deleteCalls int ++ insertBatches [][]common.KeyScoreMember ++ deleteBatches [][]common.KeyScoreMember ++} ++ ++func newScriptedCluster(name string, writeErr error, writeDelay time.Duration) *scriptedCluster { ++ return &scriptedCluster{name: name, writeErr: writeErr, writeDelay: writeDelay} ++} ++ ++func (c *scriptedCluster) Insert(tuples []common.KeyScoreMember) error { ++ c.mu.Lock() ++ c.insertCalls++ ++ c.insertBatches = append(c.insertBatches, cloneBatch(tuples)) ++ c.mu.Unlock() ++ time.Sleep(c.writeDelay) ++ return c.writeErr ++} ++ ++func (c *scriptedCluster) Delete(tuples []common.KeyScoreMember) error { ++ c.mu.Lock() ++ c.deleteCalls++ ++ c.deleteBatches = append(c.deleteBatches, cloneBatch(tuples)) ++ c.mu.Unlock() ++ time.Sleep(c.writeDelay) ++ return c.writeErr ++} ++ ++func (c *scriptedCluster) SelectOffset(keys []string, offset, limit int) <-chan cluster.Element { ++ ch := make(chan cluster.Element) ++ close(ch) ++ return ch ++} ++ ++func (c *scriptedCluster) SelectRange(keys []string, start, stop common.Cursor, limit int) <-chan cluster.Element { ++ ch := make(chan cluster.Element) ++ close(ch) ++ return ch ++} ++ ++func (c *scriptedCluster) Score(keyMembers []common.KeyMember) (map[common.KeyMember]cluster.Presence, error) { ++ return map[common.KeyMember]cluster.Presence{}, nil ++} ++ ++func (c *scriptedCluster) Keys(batchSize int) <-chan []string { ++ ch := make(chan []string) ++ close(ch) ++ return ch ++} ++ ++func (c *scriptedCluster) snapshot() clusterSnapshot { ++ c.mu.Lock() ++ defer c.mu.Unlock() ++ return clusterSnapshot{ ++ insertCalls: c.insertCalls, ++ deleteCalls: c.deleteCalls, ++ insertBatches: cloneBatches(c.insertBatches), ++ deleteBatches: cloneBatches(c.deleteBatches), ++ } ++} ++ ++type clusterSnapshot struct { ++ insertCalls int ++ deleteCalls int ++ insertBatches [][]common.KeyScoreMember ++ deleteBatches [][]common.KeyScoreMember ++} ++ ++func waitForWriteCalls(t *testing.T, clusters []*scriptedCluster, insertCalls, deleteCalls, totalCalls int) { ++ t.Helper() ++ deadline := time.Now().Add(500 * time.Millisecond) ++ for time.Now().Before(deadline) { ++ allReady := true ++ for _, c := range clusters { ++ s := c.snapshot() ++ if s.insertCalls < insertCalls || s.deleteCalls < deleteCalls || s.insertCalls+s.deleteCalls < totalCalls { ++ allReady = false ++ break ++ } ++ } ++ if allReady { ++ return ++ } ++ time.Sleep(time.Millisecond) ++ } ++ for _, c := range clusters { ++ t.Fatalf("timed out waiting for %s writes: got %+v", c.name, c.snapshot()) ++ } ++} ++ ++func assertCounts(t *testing.T, name string, got, expected clusterSnapshot) { ++ t.Helper() ++ if !reflect.DeepEqual(got, expected) { ++ t.Fatalf("%s: expected %+v, got %+v", name, expected, got) ++ } ++} ++ ++func assertQuorumError(t *testing.T, err error, expectedMessages []string) { ++ t.Helper() ++ if err == nil { ++ t.Fatalf("expected non-nil quorum error") ++ } ++ got := fmt.Sprint(err) ++ const prefix = "no quorum (" ++ if !strings.HasPrefix(got, prefix) || !strings.HasSuffix(got, ")") { ++ t.Fatalf("expected quorum error formatted as %q, got %q", "no quorum ()", got) ++ } ++ body := strings.TrimSuffix(strings.TrimPrefix(got, prefix), ")") ++ parts := strings.Split(body, "; ") ++ if len(parts) != len(expectedMessages) { ++ t.Fatalf("expected quorum errors %v, got %v", expectedMessages, parts) ++ } ++ counts := map[string]int{} ++ for _, msg := range expectedMessages { ++ counts[msg]++ ++ } ++ for _, msg := range parts { ++ counts[msg]-- ++ } ++ for msg, count := range counts { ++ if count != 0 { ++ t.Fatalf("expected quorum errors %v, got %v; mismatch at %q", expectedMessages, parts, msg) ++ } ++ } ++} ++ ++type recordingInstrumentation struct { ++ mu sync.Mutex ++ insertCalls int ++ insertRecordCountTotal int ++ insertCallDurationCalls int ++ insertRecordDurationCalls int ++ insertQuorumFailures int ++ deleteCalls int ++ deleteRecordCountTotal int ++ deleteCallDurationCalls int ++ deleteRecordDurationCalls int ++ deleteQuorumFailures int ++} ++ ++func (i *recordingInstrumentation) InsertCall() { ++ i.mu.Lock() ++ defer i.mu.Unlock() ++ i.insertCalls++ ++} ++ ++func (i *recordingInstrumentation) InsertRecordCount(n int) { ++ i.mu.Lock() ++ defer i.mu.Unlock() ++ i.insertRecordCountTotal += n ++} ++ ++func (i *recordingInstrumentation) InsertCallDuration(time.Duration) { ++ i.mu.Lock() ++ defer i.mu.Unlock() ++ i.insertCallDurationCalls++ ++} ++ ++func (i *recordingInstrumentation) InsertRecordDuration(time.Duration) { ++ i.mu.Lock() ++ defer i.mu.Unlock() ++ i.insertRecordDurationCalls++ ++} ++ ++func (i *recordingInstrumentation) InsertQuorumFailure() { ++ i.mu.Lock() ++ defer i.mu.Unlock() ++ i.insertQuorumFailures++ ++} ++ ++func (i *recordingInstrumentation) DeleteCall() { ++ i.mu.Lock() ++ defer i.mu.Unlock() ++ i.deleteCalls++ ++} ++ ++func (i *recordingInstrumentation) DeleteRecordCount(n int) { ++ i.mu.Lock() ++ defer i.mu.Unlock() ++ i.deleteRecordCountTotal += n ++} ++ ++func (i *recordingInstrumentation) DeleteCallDuration(time.Duration) { ++ i.mu.Lock() ++ defer i.mu.Unlock() ++ i.deleteCallDurationCalls++ ++} ++ ++func (i *recordingInstrumentation) DeleteRecordDuration(time.Duration) { ++ i.mu.Lock() ++ defer i.mu.Unlock() ++ i.deleteRecordDurationCalls++ ++} ++ ++func (i *recordingInstrumentation) DeleteQuorumFailure() { ++ i.mu.Lock() ++ defer i.mu.Unlock() ++ i.deleteQuorumFailures++ ++} ++ ++func (i *recordingInstrumentation) SelectCall() {} ++func (i *recordingInstrumentation) SelectKeys(int) {} ++func (i *recordingInstrumentation) SelectSendTo(int) {} ++func (i *recordingInstrumentation) SelectFirstResponseDuration(time.Duration) {} ++func (i *recordingInstrumentation) SelectPartialError() {} ++func (i *recordingInstrumentation) SelectBlockingDuration(time.Duration) {} ++func (i *recordingInstrumentation) SelectOverheadDuration(time.Duration) {} ++func (i *recordingInstrumentation) SelectDuration(time.Duration) {} ++func (i *recordingInstrumentation) SelectSendAllPermitGranted() {} ++func (i *recordingInstrumentation) SelectSendAllPermitRejected() {} ++func (i *recordingInstrumentation) SelectSendAllPromotion() {} ++func (i *recordingInstrumentation) SelectRetrieved(int) {} ++func (i *recordingInstrumentation) SelectReturned(int) {} ++func (i *recordingInstrumentation) SelectRepairNeeded(int) {} ++func (i *recordingInstrumentation) RepairCall() {} ++func (i *recordingInstrumentation) RepairRequest(int) {} ++func (i *recordingInstrumentation) RepairDiscarded(int) {} ++func (i *recordingInstrumentation) RepairWriteSuccess(int) {} ++func (i *recordingInstrumentation) RepairWriteFailure(int) {} ++func (i *recordingInstrumentation) WalkKeys(int) {} ++ ++func (i *recordingInstrumentation) snapshot() instrumentationSnapshot { ++ i.mu.Lock() ++ defer i.mu.Unlock() ++ return instrumentationSnapshot{ ++ insertCalls: i.insertCalls, ++ insertRecordCountTotal: i.insertRecordCountTotal, ++ insertCallDurationCalls: i.insertCallDurationCalls, ++ insertRecordDurationCalls: i.insertRecordDurationCalls, ++ insertQuorumFailures: i.insertQuorumFailures, ++ deleteCalls: i.deleteCalls, ++ deleteRecordCountTotal: i.deleteRecordCountTotal, ++ deleteCallDurationCalls: i.deleteCallDurationCalls, ++ deleteRecordDurationCalls: i.deleteRecordDurationCalls, ++ deleteQuorumFailures: i.deleteQuorumFailures, ++ } ++} ++ ++type instrumentationSnapshot struct { ++ insertCalls int ++ insertRecordCountTotal int ++ insertCallDurationCalls int ++ insertRecordDurationCalls int ++ insertQuorumFailures int ++ deleteCalls int ++ deleteRecordCountTotal int ++ deleteCallDurationCalls int ++ deleteRecordDurationCalls int ++ deleteQuorumFailures int ++} ++ ++func assertInstrumentation(t *testing.T, got, expected instrumentationSnapshot) { ++ t.Helper() ++ if !reflect.DeepEqual(got, expected) { ++ t.Fatalf("expected instrumentation %+v, got %+v", expected, got) ++ } ++} ++ ++func cloneBatch(in []common.KeyScoreMember) []common.KeyScoreMember { ++ out := make([]common.KeyScoreMember, len(in)) ++ copy(out, in) ++ return out ++} ++ ++func cloneBatches(in [][]common.KeyScoreMember) [][]common.KeyScoreMember { ++ out := make([][]common.KeyScoreMember, len(in)) ++ for i := range in { ++ out[i] = cloneBatch(in[i]) ++ } ++ return out ++} ++ ++func TestScriptedClusterSatisfiesPublicInterface(t *testing.T) { ++ ++ ++ var _ cluster.Cluster = (*scriptedCluster)(nil) ++ var _ instrumentation.Instrumentation = (*recordingInstrumentation)(nil) ++} ++ ++func TestQuorumErrorMessageDoesNotDependOnFailureOrder(t *testing.T) { ++ ++ ++ ++ c1 := newScriptedCluster("cluster-a", nil, 0) ++ c2 := newScriptedCluster("cluster-b", errors.New("cluster-b denied"), 20*time.Millisecond) ++ c3 := newScriptedCluster("cluster-c", errors.New("cluster-c denied"), 1*time.Millisecond) ++ f := farm.New([]cluster.Cluster{c1, c2, c3}, 2, farm.SendAllReadAll, farm.NoRepairs, instrumentation.NopInstrumentation{}) ++ ++ err := f.Insert(batch) ++ assertQuorumError(t, err, []string{"cluster-b denied", "cluster-c denied"}) ++ waitForWriteCalls(t, []*scriptedCluster{c1, c2, c3}, 1, 0, 1) ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,22 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++export GOPATH=/root/go ++export GOMODCACHE=/root/go/pkg/mod ++export GOPROXY=off ++export GOSUMDB=off ++export GONOSUMDB='*' ++export GOTOOLCHAIN=local ++export GOFLAGS="${GOFLAGS:-} -mod=readonly" ++exec go test -v -count=1 ./usercase-test-coderl/... diff --git a/tasks/format-code-task-002688/tests/test.sh b/tasks/format-code-task-002688/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..722ba4e3a92a322c64d31c85c0a4c14bb34ac25c --- /dev/null +++ b/tasks/format-code-task-002688/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/farm_quorum_write_test.go +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002688/tests/test_command.sh b/tasks/format-code-task-002688/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002688/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002709/environment/Dockerfile b/tasks/format-code-task-002709/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..da05781bec9a61539ac492798f39b06aa7a23409 --- /dev/null +++ b/tasks/format-code-task-002709/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:6040b596dccbe7c384027dfaa11bde5a69e14bbbf106852483f2b94ecf205908 diff --git a/tasks/format-code-task-002709/environment/setup/files/blocklist b/tasks/format-code-task-002709/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002709/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002709/environment/setup/setup.sh b/tasks/format-code-task-002709/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002709/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002709/tests/test.patch b/tasks/format-code-task-002709/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..37c241e99a35929c17e3e1e1c3e970c58993d855 --- /dev/null +++ b/tasks/format-code-task-002709/tests/test.patch @@ -0,0 +1,76 @@ +diff --git a/test/file_test.py b/test/file_test.py +index 5f4d56c8f8..449a7cae2e 100644 +--- a/test/file_test.py ++++ b/test/file_test.py +@@ -276,6 +276,15 @@ def setUp(self): + def tearDown(self): + self.setUp() + ++ def test_copy(self): ++ src = os.path.join(self.path, 'src.txt') ++ dest = os.path.join(self.path, 'newdir', 'dest.txt') ++ ++ LocalTarget(src).open('w').close() ++ self.fs.copy(src, dest) ++ self.assertTrue(os.path.exists(src)) ++ self.assertTrue(os.path.exists(dest)) ++ + def test_mkdir(self): + testpath = os.path.join(self.path, 'foo/bar') + +diff --git a/test/mock_test.py b/test/mock_test.py +index 45af3b358f..833ab72633 100644 +--- a/test/mock_test.py ++++ b/test/mock_test.py +@@ -64,9 +64,15 @@ def setUp(self): + self.fs.clear() + self.path = "/tmp/foo" + self.path2 = "/tmp/bar" ++ self.path3 = "/tmp/foobar" + self._touch(self.path) + self._touch(self.path2) + ++ def test_copy(self): ++ self.fs.copy(self.path, self.path3) ++ self.assertTrue(self.fs.exists(self.path)) ++ self.assertTrue(self.fs.exists(self.path3)) ++ + def test_exists(self): + self.assertTrue(self.fs.exists(self.path)) + +@@ -79,6 +85,11 @@ def test_remove_recursive(self): + self.assertFalse(self.fs.exists(self.path)) + self.assertFalse(self.fs.exists(self.path2)) + ++ def test_rename(self): ++ self.fs.rename(self.path, self.path3) ++ self.assertFalse(self.fs.exists(self.path)) ++ self.assertTrue(self.fs.exists(self.path3)) ++ + def test_listdir(self): + self.assertEqual(sorted([self.path, self.path2]), sorted(self.fs.listdir("/tmp"))) + +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,8 @@ ++H4sIAAAAAAAAA+3TX2/TMBAA8D77U5xCHzakJA1dEglpDwgmbQ/ANNBeqzS5bobEtvwnWr89thPW ++CWnsZQMh7vfQVOerfb5Ls63jfbdBMeaLl7Ly6rKMT+/XZ/xelG+Koq7qulgvVkVR+QeUL1bRA87Y ++RgMstJT2d3lPrf+jssP8LRq7aeUwNKLLzO3znfHU/Ouiup9/Vfp4cVKt/fxXz1fC4/7z+bcdxMFv ++sWPsFbzvsRHgW9Kjjw8KdrxHAzstB1AaRy6dgZAP2gnD9ADpLibGTTJ7Z9PXYZ8vaMEpUHv/YsER ++F2HHHjvgAvLQyTyLS8cM75TUFi7ffT0/TZbnnz+ezUv5lou3yxBPGI5ND8nyaNqOC24hPU5ivRob ++izCGuHTW8A4P97k++3S9+XBxdZrMZ4a0tHf8hidM7e2tFGtIh+nXyfJnesKMdLrFB6FQTN60lo/+ ++tHjwxXQl3xT5DVsL/j8z9aVDhaJD0XI0THEF8+UhPVTm+xJzB9l+D5tdOQH+LbzxTQtxMxcXapsz ++w0ceZrGJfVb7KRI2uI+kI/vbbxMhhBBCCCGEEEIIIYQQQgghhBBCCPnTfgCnMMohACgAAA== +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-002709/tests/test.sh b/tasks/format-code-task-002709/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..021ec6d0076341c1e25592f6f421a28ca260f49c --- /dev/null +++ b/tasks/format-code-task-002709/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test/file_test.py +test/mock_test.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002709/tests/test_command.sh b/tasks/format-code-task-002709/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002709/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002731/environment/Dockerfile b/tasks/format-code-task-002731/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..232dce1e64151131d67ef0f743c1931ae1eb9c3c --- /dev/null +++ b/tasks/format-code-task-002731/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:3c8bf6c80f74fb7bd0d39ae45464f773743c3450eabc4b3d5862127d47f98999 diff --git a/tasks/format-code-task-002731/environment/setup/files/blocklist b/tasks/format-code-task-002731/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002731/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002731/environment/setup/setup.sh b/tasks/format-code-task-002731/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002731/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002731/tests/test.patch b/tasks/format-code-task-002731/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..98f3fcd9318ea3351ce013e17814a38153e81876 --- /dev/null +++ b/tasks/format-code-task-002731/tests/test.patch @@ -0,0 +1,121 @@ +diff --git a/test/base/request_handler_test.dart b/test/base/request_handler_test.dart +new file mode 100644 +index 000000000..2f441808c +--- /dev/null ++++ b/test/base/request_handler_test.dart +@@ -0,0 +1,89 @@ ++import 'package:test/test.dart'; ++import 'package:aqueduct/aqueduct.dart'; ++import 'dart:async'; ++import 'package:http/http.dart' as http; ++import 'dart:io'; ++import 'dart:mirrors'; ++import 'dart:isolate'; ++ ++void main() { ++ HttpServer server = null; ++ tearDown(() async { ++ await server.close(); ++ }); ++ ++ test("Logging after socket is closed does not throw exception", () async { ++ var handler = new RequestHandler(requestHandler: (Request req) { ++ req.innerRequest.response.detachSocket().then((s) async { ++ s.destroy(); ++ ++ req.toDebugString(includeHeaders: true, includeBody: true, includeContentSize: true, ++ includeElapsedTime: true, includeMethod: true, includeRequestIP: true, includeResource: true, ++ includeStatusCode: true); ++ }); ++ }); ++ ++ var ensureExceptionIsCapturedByDeliver = new Completer(); ++ server = await HttpServer.bind(InternetAddress.LOOPBACK_IP_V4, 8000); ++ server ++ .map((req) => new Request(req)) ++ .listen((req) async { ++ await handler.deliver(req); ++ ++ ++ ensureExceptionIsCapturedByDeliver.complete(true); ++ }); ++ ++ try { ++ await http.get("http://localhost:8000"); ++ } catch (e) {} ++ ++ expect(ensureExceptionIsCapturedByDeliver.future, completes); ++ }); ++ ++ test("Request handler that dies on bad state: header already sent is captured in RequestHandler", () async { ++ var handler = new RequestHandler(requestHandler: (Request req) { ++ req.response.close(); ++ ++ return new Response.ok(null); ++ }); ++ ++ var ensureExceptionIsCapturedByDeliver = new Completer(); ++ server = await HttpServer.bind(InternetAddress.LOOPBACK_IP_V4, 8000); ++ server ++ .map((req) => new Request(req)) ++ .listen((req) async { ++ await handler.deliver(req); ++ ++ ++ ensureExceptionIsCapturedByDeliver.complete(true); ++ }); ++ ++ await http.get("http://localhost:8000"); ++ ++ expect(ensureExceptionIsCapturedByDeliver.future, completes); ++ }); ++ ++ test("Request handler throwing HttpResponseException that dies on bad state: header already sent is captured in RequestHandler", () async { ++ var handler = new RequestHandler(requestHandler: (Request req) { ++ req.response.close(); ++ ++ throw new HTTPResponseException(400, "whocares"); ++ }); ++ ++ var ensureExceptionIsCapturedByDeliver = new Completer(); ++ server = await HttpServer.bind(InternetAddress.LOOPBACK_IP_V4, 8000); ++ server ++ .map((req) => new Request(req)) ++ .listen((req) async { ++ await handler.deliver(req); ++ ++ ++ ensureExceptionIsCapturedByDeliver.complete(true); ++ }); ++ ++ await http.get("http://localhost:8000"); ++ ++ expect(ensureExceptionIsCapturedByDeliver.future, completes); ++ }); ++} +\ No newline at end of file +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,9 @@ ++H4sIAAAAAAAAA+3TX2/TMBAA8D77U9w2NMFD7DhrWqkwJKQ9gOABUd7QVCXxtbFIndR/psKnn50N ++sSHYXlYhxP0i1anvEp/ODq+D7tQKzZWYHEoezctyHKNfx/FeloWMV5FPzya5lOVcTqA8WEV3BOcr ++CzCxfe8fynss/o/iP/ffo/Orpt9uK6O4a59ujcf2fz6d/dh/Oc9jnpzOinwC+dOV8Gf/+f6fHIla ++G1FXrmUOPWTIWKNgPAw1KsZOYBmnwwAXlfUg+R6WF+/hucVd0BYV1N9gCLUbsFmAU1/h9bnkcsZz ++eFXwnOcvmF7DFziCLL10OwgVX5OlxMuX4Fs0DKAJtoNs7ZYfoPV+cAshnO9ttUG+6ftNh9WgHY8n ++8+bhyjatvkLRtJUx2LmYXNUdCosx06GQvDjjuYhrjPlxzDptwj7bz6bZbRL/rgfI+vslpclUzk2l ++cHoKwYx5O7ibkgJ2C7976rZpa81wP/SxXx/ffH57fnxvldTvxbMUOE7dfWdi+V0HCgc0Ck2j0bHY ++UdigT/FPwaQ+QTylcQbSEmPYpvn4Z/xJ+5casAvpG459UR3aVYrwtCz726eMEEIIIYQQQgghhBBC ++CCGEEEIIIYQcyjX2WpehACgAAA== +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-002731/tests/test.sh b/tasks/format-code-task-002731/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..7495732e315e7307dbf13a6c3c350cd511a466b4 --- /dev/null +++ b/tasks/format-code-task-002731/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test/base/request_handler_test.dart +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002731/tests/test_command.sh b/tasks/format-code-task-002731/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002731/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002736/environment/Dockerfile b/tasks/format-code-task-002736/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..fc4f0f221a7d96d4351d14664be7cb7b4904fac3 --- /dev/null +++ b/tasks/format-code-task-002736/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:80b7930a978605a2080e679cb09d51312fb6fd50d0c7e5396432a542a26e55fe diff --git a/tasks/format-code-task-002736/environment/setup/files/blocklist b/tasks/format-code-task-002736/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002736/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002736/environment/setup/setup.sh b/tasks/format-code-task-002736/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002736/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002736/tests/test.patch b/tasks/format-code-task-002736/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..1fcbe5a810e60a76dff32472d81a0599d86c9332 --- /dev/null +++ b/tasks/format-code-task-002736/tests/test.patch @@ -0,0 +1,152 @@ +diff --git a/statsmodels/regression/tests/test_rolling.py b/statsmodels/regression/tests/test_rolling.py +index 4ffcda3b7..da03fa281 100644 +--- a/statsmodels/regression/tests/test_rolling.py ++++ b/statsmodels/regression/tests/test_rolling.py +@@ -283,3 +283,125 @@ def test_min_nobs(basic_data): + mod = RollingOLS(y, x, 150, min_nobs=min_nobs) + res = mod.fit() + assert np.all(res.nobs[res.nobs != 0] >= min_nobs) ++ ++ ++def _gen_simple(nobs=120, nvar=3, seed=12345): ++ rs = np.random.RandomState(seed) ++ x = rs.standard_normal((nobs, nvar)) ++ x = tools.add_constant(x) ++ beta = np.array([1.0, -0.5, 0.7, 0.3]) ++ y = x @ beta + rs.standard_normal(nobs) * 0.5 ++ return y, x ++ ++ ++def test_expanding_default_is_false(): ++ ++ y, x = _gen_simple(nobs=120, nvar=3) ++ window = 60 ++ min_nobs = 12 ++ mod = RollingOLS(y, x, window=window, min_nobs=min_nobs) ++ res = mod.fit() ++ params = np.asarray(res.params) ++ ++ ++ assert np.all(np.isnan(params[:window - 1])) ++ assert not np.any(np.isnan(params[window - 1:])) ++ ++ ++def test_expanding_true_fills_pre_window_indices(): ++ ++ ++ y, x = _gen_simple(nobs=120, nvar=3) ++ window = 60 ++ min_nobs = 12 ++ mod = RollingOLS(y, x, window=window, min_nobs=min_nobs, ++ expanding=True) ++ res = mod.fit() ++ params = np.asarray(res.params) ++ ++ assert np.all(np.isnan(params[:min_nobs - 1])) ++ ++ ++ assert not np.any(np.isnan(params[min_nobs - 1:window - 1])) ++ ++ assert not np.any(np.isnan(params[window - 1:])) ++ ++ ++def test_expanding_matches_ols_at_min_nobs(): ++ ++ ++ from statsmodels.regression.linear_model import OLS ++ y, x = _gen_simple(nobs=120, nvar=3) ++ window = 60 ++ min_nobs = 10 ++ mod = RollingOLS(y, x, window=window, min_nobs=min_nobs, ++ expanding=True) ++ res = mod.fit() ++ params = np.asarray(res.params) ++ expected = OLS(y[:min_nobs], x[:min_nobs]).fit().params ++ assert_allclose(params[min_nobs - 1], expected) ++ ++ ++def test_expanding_matches_ols_within_expanding_phase(): ++ ++ ++ from statsmodels.regression.linear_model import OLS ++ y, x = _gen_simple(nobs=120, nvar=3) ++ window = 50 ++ min_nobs = 8 ++ mod = RollingOLS(y, x, window=window, min_nobs=min_nobs, ++ expanding=True) ++ res = mod.fit() ++ params = np.asarray(res.params) ++ ++ for i in (min_nobs - 1, min_nobs + 5, window // 2, window - 2): ++ expected = OLS(y[:i + 1], x[:i + 1]).fit().params ++ assert_allclose(params[i], expected, ++ err_msg='mismatch at i={}'.format(i)) ++ ++ ++def test_expanding_post_window_matches_rolling(): ++ ++ ++ y, x = _gen_simple(nobs=120, nvar=3) ++ window = 40 ++ min_nobs = 8 ++ res_roll = RollingOLS(y, x, window=window, min_nobs=min_nobs).fit() ++ res_exp = RollingOLS(y, x, window=window, min_nobs=min_nobs, ++ expanding=True).fit() ++ params_roll = np.asarray(res_roll.params) ++ params_exp = np.asarray(res_exp.params) ++ assert_allclose(params_exp[window - 1:], params_roll[window - 1:]) ++ ++ ++def test_expanding_at_window_boundary_matches_rolling_first(): ++ ++ ++ from statsmodels.regression.linear_model import OLS ++ y, x = _gen_simple(nobs=120, nvar=3) ++ window = 30 ++ min_nobs = 5 ++ res_exp = RollingOLS(y, x, window=window, min_nobs=min_nobs, ++ expanding=True).fit() ++ params_exp = np.asarray(res_exp.params) ++ expected = OLS(y[:window], x[:window]).fit().params ++ assert_allclose(params_exp[window - 1], expected) ++ ++ ++def test_expanding_nobs_grows(): ++ ++ ++ y, x = _gen_simple(nobs=100, nvar=3) ++ window = 30 ++ min_nobs = 6 ++ mod = RollingOLS(y, x, window=window, min_nobs=min_nobs, ++ expanding=True) ++ res = mod.fit() ++ nobs_arr = np.asarray(res.nobs) ++ ++ for i in range(min_nobs - 1, window - 1): ++ assert nobs_arr[i] == i + 1, \ ++ 'nobs at i={} expected {} got {}'.format(i, i + 1, nobs_arr[i]) ++ ++ for i in range(window - 1, len(y)): ++ assert nobs_arr[i] == window +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..4706cf86e +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest statsmodels/regression/tests/test_rolling.py -q -k expanding"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m pytest statsmodels/regression/tests/test_rolling.py -q -k expanding ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002736/tests/test.sh b/tasks/format-code-task-002736/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..8b205b76bb19a591e4c8a9be37281e7ea6fe1020 --- /dev/null +++ b/tasks/format-code-task-002736/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +statsmodels/regression/tests/test_rolling.py +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002736/tests/test_command.sh b/tasks/format-code-task-002736/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002736/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002753/environment/Dockerfile b/tasks/format-code-task-002753/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c13fd728ac772b350da9ca092b85e0771ee0e768 --- /dev/null +++ b/tasks/format-code-task-002753/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:93fd4fd03189cf54a1df19fbab0f0805191b8b457d771f7e9641d7afc4dfd5de diff --git a/tasks/format-code-task-002753/environment/setup/files/blocklist b/tasks/format-code-task-002753/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002753/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002753/environment/setup/setup.sh b/tasks/format-code-task-002753/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002753/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002753/tests/test.patch b/tasks/format-code-task-002753/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..cf74a6976d7aa9f85c6acb0f3b67188a498a6225 --- /dev/null +++ b/tasks/format-code-task-002753/tests/test.patch @@ -0,0 +1,49 @@ +diff --git a/packages/core/helper-plugin/lib/src/content-manager/utils/tests/formatContentTypeData.test.js b/packages/core/helper-plugin/lib/src/content-manager/utils/tests/formatContentTypeData.test.js +index 836f8b696080..d78b04851785 100644 +--- a/packages/core/helper-plugin/lib/src/content-manager/utils/tests/formatContentTypeData.test.js ++++ b/packages/core/helper-plugin/lib/src/content-manager/utils/tests/formatContentTypeData.test.js +@@ -87,6 +87,7 @@ describe('STRAPI_HELPER_PLUGIN | utils | formatContentTypeData', () => { + dz: { type: 'dynamiczone', components: ['compos.sub-compo'] }, + jsonString: { type: 'json' }, + jsonObject: { type: 'json' }, ++ jsonBool: { type: 'json' }, + }, + }; + +@@ -119,6 +120,7 @@ describe('STRAPI_HELPER_PLUGIN | utils | formatContentTypeData', () => { + ], + jsonString: 'hello', + jsonObject: { hello: true }, ++ jsonBool: false, + }; + + const expected = { +@@ -136,6 +138,7 @@ describe('STRAPI_HELPER_PLUGIN | utils | formatContentTypeData', () => { + ], + jsonString: '"hello"', + jsonObject: '{\n "hello": true\n}', ++ jsonBool: 'false', + }; + + expect(formatContentTypeData(data, contentType, components)).toEqual(expected); +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,5 @@ ++H4sIAAAAAAAAA+3STW7DIBAFYK99CqquAeOE5ADpEbqPMMY/qQ0W4Kq9fYmzaFSpySZRVPV9G5Dn ++GY88sGruh3pv7DvP7qVItlIua/JzXfZClqIUKyHlOiuE2KRHRN6tozNziMoTknnn4qXctfofxb7n ++H02Ie+3GUdmahe5237g2/9X5/Mttmv96U8iMFLdr4Xf/fP7PT7zqLa9U6PJgIqEm1zVZ7kJl6txO ++H+SQ9oRS7WzTt2RS+k21JnDtvOGdGSbj6TTMbTrlmGSnHGu8s5EdwsUXhr7iwetUstHYSNPVS1HP ++59gPYWki8Mb5UcXdKfH6OZkXFRU71tLp+aP/HwAAAAAAAAAAAAAAAAAAAADAI30BYYte2wAoAAA= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-002753/tests/test.sh b/tasks/format-code-task-002753/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..7502437b1e28ff62c56b0fa07cf783560dec0558 --- /dev/null +++ b/tasks/format-code-task-002753/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +packages/core/helper-plugin/lib/src/content-manager/utils/tests/formatContentTypeData.test.js +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002753/tests/test_command.sh b/tasks/format-code-task-002753/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002753/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002754/environment/Dockerfile b/tasks/format-code-task-002754/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..95afc288b449cd80c14dbede53c687156b90b409 --- /dev/null +++ b/tasks/format-code-task-002754/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:e8f0a3f68f1f447ecd3941a2a36edf7db7e907bec71071f80214ffda338fc4f0 diff --git a/tasks/format-code-task-002754/environment/setup/files/blocklist b/tasks/format-code-task-002754/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002754/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002754/environment/setup/setup.sh b/tasks/format-code-task-002754/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002754/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002754/tests/test.patch b/tasks/format-code-task-002754/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..03b3adb87c58243c7ce451d4f9b32c1e2bbe3b3d --- /dev/null +++ b/tasks/format-code-task-002754/tests/test.patch @@ -0,0 +1,154 @@ +diff --git a/packages/core/upload/admin/src/utils/tests/appendSearchParamsToUrl.test.js b/packages/core/upload/admin/src/utils/tests/appendSearchParamsToUrl.test.js +index cbab676bab5a..0f63f0d1efe8 100644 +--- a/packages/core/upload/admin/src/utils/tests/appendSearchParamsToUrl.test.js ++++ b/packages/core/upload/admin/src/utils/tests/appendSearchParamsToUrl.test.js +@@ -1,38 +1,106 @@ + import { appendSearchParamsToUrl } from '..'; + + describe('appendSearchParamsToUrl', () => { +- const urlString = 'https://example.com/'; + const updateTime = '2023-07-19T03:00:00.000Z'; + + test('returns undefined for undefined url string', () => { + expect(appendSearchParamsToUrl({})).toBeUndefined(); +- expect(appendSearchParamsToUrl({ url: undefined, params: { updatedAt: updateTime }})).toBeUndefined(); ++ expect( ++ appendSearchParamsToUrl({ url: undefined, params: { updatedAt: updateTime } }) ++ ).toBeUndefined(); + }); + +- test('returns original string with no update time', () => { +- expect(appendSearchParamsToUrl({ url: urlString, params: undefined })).toEqual(urlString); +- expect(appendSearchParamsToUrl({ url: urlString, params: 'notAnObject' })).toEqual(urlString); +- expect(appendSearchParamsToUrl({ url: urlString, params: { updatedAt: undefined } })).toEqual(urlString); +- }); ++ describe('absoluteURL', () => { ++ const url = 'https://example.com/'; + +- test('appends update time to string with no search params', () => { +- const expected = `${urlString}?updatedAt=${updateTime.replaceAll(':', '%3A')}`; ++ test('returns original string with no update time', () => { ++ expect(appendSearchParamsToUrl({ url, params: undefined })).toMatchInlineSnapshot( ++ `"https://example.com/"` ++ ); ++ expect(appendSearchParamsToUrl({ url, params: 'notAnObject' })).toMatchInlineSnapshot( ++ `"https://example.com/"` ++ ); ++ expect( ++ appendSearchParamsToUrl({ url, params: { updatedAt: undefined } }) ++ ).toMatchInlineSnapshot(`"https://example.com/"`); ++ }); + +- expect(appendSearchParamsToUrl({ url: urlString, params: { updatedAt: updateTime } })).toEqual(expected); +- }); ++ test('appends update time to string with no search params', () => { ++ expect( ++ appendSearchParamsToUrl({ url, params: { updatedAt: updateTime } }) ++ ).toMatchInlineSnapshot(`"https://example.com/?updatedAt=2023-07-19T03%3A00%3A00.000Z"`); ++ }); + +- test('appends update time to string with search params', () => { +- const urlWithQuery = `${urlString}?query=test`; +- const expected = `${urlWithQuery}&updatedAt=${updateTime.replaceAll(':', '%3A')}`; ++ test('appends update time to string with search params', () => { ++ expect( ++ appendSearchParamsToUrl({ url: `${url}?query=test`, params: { updatedAt: updateTime } }) ++ ).toMatchInlineSnapshot( ++ `"https://example.com/?query=test&updatedAt=2023-07-19T03%3A00%3A00.000Z"` ++ ); ++ }); + +- expect(appendSearchParamsToUrl({ url: urlWithQuery, params: { updatedAt: updateTime } })).toEqual(expected); ++ test('appends multiple search params', () => { ++ expect( ++ appendSearchParamsToUrl({ url, params: { param1: 'example1', param2: 'example2' } }) ++ ).toMatchInlineSnapshot(`"https://example.com/?param1=example1¶m2=example2"`); ++ }); + }); + +- test('appends multiple search params', () => { +- const param1 = 'example1'; +- const param2 = 'example2'; +- const expected = `${urlString}?param1=${param1}¶m2=${param2}`; ++ describe('relativeURL', () => { ++ let originalBackendURL; ++ ++ beforeAll(() => { ++ ++ ++ ++ ++ ++ originalBackendURL = window.strapi.backendURL; ++ window.strapi.backendURL = 'https://appending-search-params.com'; ++ }); ++ ++ afterAll(() => { ++ if (originalBackendURL) { ++ window.strapi.backendURL = originalBackendURL; ++ } ++ }); ++ ++ const url = '/uploads/image.jpg'; ++ ++ test('returns original string with no update time', () => { ++ expect(appendSearchParamsToUrl({ url, params: undefined })).toMatchInlineSnapshot( ++ `"/uploads/image.jpg"` ++ ); ++ expect(appendSearchParamsToUrl({ url, params: 'notAnObject' })).toMatchInlineSnapshot( ++ `"/uploads/image.jpg"` ++ ); ++ expect( ++ appendSearchParamsToUrl({ url, params: { updatedAt: undefined } }) ++ ).toMatchInlineSnapshot(`"https://appending-search-params.com/uploads/image.jpg"`); ++ }); ++ ++ test('appends update time to string with no search params', () => { ++ expect( ++ appendSearchParamsToUrl({ url, params: { updatedAt: updateTime } }) ++ ).toMatchInlineSnapshot( ++ `"https://appending-search-params.com/uploads/image.jpg?updatedAt=2023-07-19T03%3A00%3A00.000Z"` ++ ); ++ }); ++ ++ test('appends update time to string with search params', () => { ++ expect( ++ appendSearchParamsToUrl({ url: `${url}?query=test`, params: { updatedAt: updateTime } }) ++ ).toMatchInlineSnapshot( ++ `"https://appending-search-params.com/uploads/image.jpg?query=test&updatedAt=2023-07-19T03%3A00%3A00.000Z"` ++ ); ++ }); + +- expect(appendSearchParamsToUrl({ url: urlString, params: { param1, param2 } })).toEqual(expected); ++ test('appends multiple search params', () => { ++ expect( ++ appendSearchParamsToUrl({ url, params: { param1: 'example1', param2: 'example2' } }) ++ ).toMatchInlineSnapshot( ++ `"https://appending-search-params.com/uploads/image.jpg?param1=example1¶m2=example2"` ++ ); ++ }); + }); + }); +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,7 @@ ++H4sIAAAAAAAAA+3S3UrDMBQH8F7vKQ4Tdtd27WwLgiI+gfhxPbLmuNVlSUnSyd7etgM3RN2FGyr+ ++f1DSpknOSU6iWVMpOWW9joNTGbeKLOvb1vu2f0+yNEmyvCiKNBgnSZ7kAWUny2hP47ywRIE1xn81 ++7tD/Pyra1d+z89PSrFZCy8gtjhfjUP3zbLKrf9r2J+d5WgQ0Pl4Kn/vn9S8l9YWfsRwMzuimuw0k ++uWYtWZcVO9LMkiXNNuQXTN1Yck3lebA3Na5FuRRzdrGQq0qHXXfY+Eo5Go1IG8m7odFGWB1bVixc ++O6H7CidRHiVR+eyov46UXsWS17FulPo4TGksxwtWNduwVs280t8P1G7/rtHbXQo7Z99vdj/+W4yv ++l34xdunaVJmunbeiruJtimFTKyNkv+zFkzXaU9gf1a3wi/bxbPXlUNTd4d+zsGXbacXKPZhHq4aD ++n74qAAAAAAAAAAAAAAAAAAAAAPALvQKRZV5WACgAAA== +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-002754/tests/test.sh b/tasks/format-code-task-002754/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..b8903a4253a42c38815824d5f477b6bb69391e2f --- /dev/null +++ b/tasks/format-code-task-002754/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +packages/core/upload/admin/src/utils/tests/appendSearchParamsToUrl.test.js +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002754/tests/test_command.sh b/tasks/format-code-task-002754/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002754/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002811/environment/Dockerfile b/tasks/format-code-task-002811/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7f306dbfe079ba3ca3afcd4c8ac114d6bbb5e009 --- /dev/null +++ b/tasks/format-code-task-002811/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:1f783409666a384615360436530ffc0e3f2f7b5a2f3a87e23c604ff2455687ea diff --git a/tasks/format-code-task-002811/environment/setup/files/blocklist b/tasks/format-code-task-002811/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002811/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002811/environment/setup/setup.sh b/tasks/format-code-task-002811/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002811/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002811/tests/test.patch b/tasks/format-code-task-002811/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..0c749f5c2538774a7c3966ff4683ebd018634020 --- /dev/null +++ b/tasks/format-code-task-002811/tests/test.patch @@ -0,0 +1,47 @@ +diff --git a/service/history/nDCActivityReplicator_test.go b/service/history/nDCActivityReplicator_test.go +index f844212df21..4429363a0be 100644 +--- a/service/history/nDCActivityReplicator_test.go ++++ b/service/history/nDCActivityReplicator_test.go +@@ -74,7 +74,7 @@ type ( + mockExecutionMgr *persistence.MockExecutionManager + + logger log.Logger +- historyCache *workflow.Cache ++ historyCache workflow.Cache + + nDCActivityReplicator *nDCActivityReplicatorImpl + } +diff --git a/service/history/workflow/cache_test.go b/service/history/workflow/cache_test.go +index e5a808dbd9f..6677949a55b 100644 +--- a/service/history/workflow/cache_test.go ++++ b/service/history/workflow/cache_test.go +@@ -51,7 +51,7 @@ type ( + controller *gomock.Controller + mockShard *shard.ContextTest + +- cache *Cache ++ cache Cache + } + ) + +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,5 @@ ++H4sIAAAAAAAAA+3RTU7DMBAF4Kw5xVwgifO/YoHYdF3YV6ljiEUSI3ucqrfHpBJUSFAJtaoQ79t4 ++lLHHVl6y9XroNmqa0+hSRNBU1bIGX9elzqo8y+qibMrwPVSijKi62IuOeMetJYqsMfzTvlP9Pyr5 ++zJ+V440049hOXeL6891xKv+8KT7yr0MtsrLOm4jE+Z7wvX+ev+xoCX6ruptnQ+8lxTPF0viJbzOK ++WY/KeKZCCEdJ6pSdtVRprx0bu08ptn6ix3DsTrKeNe/X6nXQsg3dB69Z/WrqztiXp8HsjsavDq37 ++VvbqMPjavw4AAAAAAAAAAAAAAAAAAAAA4OreAMM1QlEAKAAA +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-002811/tests/test.sh b/tasks/format-code-task-002811/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..00b9115e3de99d1a2d3e28070f5437f640daa6c4 --- /dev/null +++ b/tasks/format-code-task-002811/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +service/history/nDCActivityReplicator_test.go +service/history/workflow/cache_test.go +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002811/tests/test_command.sh b/tasks/format-code-task-002811/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002811/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002816/environment/Dockerfile b/tasks/format-code-task-002816/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e2a40580a66aa13aeefc98f2f2c18da0c4518685 --- /dev/null +++ b/tasks/format-code-task-002816/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:7de58dbfb18e63ca3c2cf7d8ac226903dd2291047f867d5c6b201235642c0e00 diff --git a/tasks/format-code-task-002816/environment/setup/files/blocklist b/tasks/format-code-task-002816/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002816/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002816/environment/setup/setup.sh b/tasks/format-code-task-002816/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002816/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002816/tests/test.patch b/tasks/format-code-task-002816/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..654291805b49280251b9775679d1ea98e2f3d5ac --- /dev/null +++ b/tasks/format-code-task-002816/tests/test.patch @@ -0,0 +1,121 @@ +diff --git a/internal/consensus/replay_test.go b/internal/consensus/replay_test.go +index 6c33268a7a1..036614b71e8 100644 +--- a/internal/consensus/replay_test.go ++++ b/internal/consensus/replay_test.go +@@ -1241,6 +1241,7 @@ func (bs *mockBlockStore) LoadBlock(height int64) *types.Block { return bs.chain + func (bs *mockBlockStore) LoadBlockByHash(hash []byte) *types.Block { + return bs.chain[int64(len(bs.chain))-1] + } ++func (bs *mockBlockStore) LoadBlockMetaByHash(hash []byte) *types.BlockMeta { return nil } + func (bs *mockBlockStore) LoadBlockMeta(height int64) *types.BlockMeta { + block := bs.chain[height-1] + return &types.BlockMeta{ +diff --git a/internal/rpc/core/blocks_test.go b/internal/rpc/core/blocks_test.go +index 68237bc0b81..213845bf40e 100644 +--- a/internal/rpc/core/blocks_test.go ++++ b/internal/rpc/core/blocks_test.go +@@ -11,10 +11,10 @@ import ( + + abci "github.com/tendermint/tendermint/abci/types" + sm "github.com/tendermint/tendermint/internal/state" ++ "github.com/tendermint/tendermint/internal/state/mocks" + tmstate "github.com/tendermint/tendermint/proto/tendermint/state" + "github.com/tendermint/tendermint/rpc/coretypes" + rpctypes "github.com/tendermint/tendermint/rpc/jsonrpc/types" +- "github.com/tendermint/tendermint/types" + ) + + func TestBlockchainInfo(t *testing.T) { +@@ -84,7 +84,10 @@ func TestBlockResults(t *testing.T) { + env.StateStore = sm.NewStore(dbm.NewMemDB()) + err := env.StateStore.SaveABCIResponses(100, results) + require.NoError(t, err) +- env.BlockStore = mockBlockStore{height: 100} ++ mockstore := &mocks.BlockStore{} ++ mockstore.On("Height").Return(int64(100)) ++ mockstore.On("Base").Return(int64(1)) ++ env.BlockStore = mockstore + + testCases := []struct { + height int64 +@@ -115,21 +118,3 @@ func TestBlockResults(t *testing.T) { + } + } + } +- +-type mockBlockStore struct { +- height int64 +-} +- +-func (mockBlockStore) Base() int64 { return 1 } +-func (store mockBlockStore) Height() int64 { return store.height } +-func (store mockBlockStore) Size() int64 { return store.height } +-func (mockBlockStore) LoadBaseMeta() *types.BlockMeta { return nil } +-func (mockBlockStore) LoadBlockMeta(height int64) *types.BlockMeta { return nil } +-func (mockBlockStore) LoadBlock(height int64) *types.Block { return nil } +-func (mockBlockStore) LoadBlockByHash(hash []byte) *types.Block { return nil } +-func (mockBlockStore) LoadBlockPart(height int64, index int) *types.Part { return nil } +-func (mockBlockStore) LoadBlockCommit(height int64) *types.Commit { return nil } +-func (mockBlockStore) LoadSeenCommit() *types.Commit { return nil } +-func (mockBlockStore) PruneBlocks(height int64) (uint64, error) { return 0, nil } +-func (mockBlockStore) SaveBlock(block *types.Block, blockParts *types.PartSet, seenCommit *types.Commit) { +-} +diff --git a/rpc/client/rpc_test.go b/rpc/client/rpc_test.go +index 12c13d68675..b2526176a88 100644 +--- a/rpc/client/rpc_test.go ++++ b/rpc/client/rpc_test.go +@@ -359,6 +359,15 @@ func TestClientMethodCalls(t *testing.T) { + require.NoError(t, err) + require.Equal(t, block, blockByHash) + ++ ++ header, err := c.Header(ctx, &apph) ++ require.NoError(t, err) ++ require.Equal(t, block.Block.Header, *header.Header) ++ ++ headerByHash, err := c.HeaderByHash(ctx, block.BlockID.Hash) ++ require.NoError(t, err) ++ require.Equal(t, header, headerByHash) ++ + // now check the results + blockResults, err := c.BlockResults(ctx, &txh) + require.NoError(t, err, "%d: %+v", i, err) +@@ -551,7 +560,6 @@ func TestClientMethodCalls(t *testing.T) { + _, err := c.BroadcastEvidence(ctx, fake) + require.Error(t, err, "BroadcastEvidence(%s) succeeded, but the evidence was fake", fake) + } +- + }) + t.Run("BroadcastEmpty", func(t *testing.T) { + _, err := c.BroadcastEvidence(ctx, nil) +@@ -732,7 +740,6 @@ func TestClientMethodCallsAdvanced(t *testing.T) { + + for _, c := range GetClients(t, n, conf) { + t.Run(fmt.Sprintf("%T", c), func(t *testing.T) { +- + // now we query for the tx. + result, err := c.TxSearch(ctx, fmt.Sprintf("tx.hash='%v'", find.Hash), true, nil, nil, "asc") + require.Nil(t, err) +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,7 @@ ++H4sIAAAAAAAAA+3Su27CMBgF4Mw8hTemXCHp1AF1oVIviF4YkUlciHDsyBdUpD58TVSp0KbQAVSh ++nm+x/dtWHB8HM1vyYsrEKvROJXIu0rRpna9t04/TJE6ifq/Xz7wojrMo9kh6shNtsdpQRYinpDT7 ++1h2aP1PBZ/6GaTPNZVVRUQR6cbxvHMo/28o/SROXfz+LUo9ExzvCz/55/nlBmuBnrOhoZojPOnNJ ++NhXir4ifSyvMZUx8U1ZMWkNcVpoEYSkMU4LyMJdCM6GtDomvrCDdR7d1Mri5UlQv3jaDoXtOekGX ++bMxqTtcDztvKD7JibfV70Vq+kx/1W5kvR0q+rgd1vbtwREWZ6+sXNzFmxiqhJ0qKuRsOvx3tqS6o ++++dnykvXkUp399+Ce6o7t6Dq3N2EYuGvtjWrecmECTt/nT8AAAAAAAAAAAAAAAAAAAAAnLd3PO7d ++aAAoAAA= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-002816/tests/test.sh b/tasks/format-code-task-002816/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..cf708a06f5a8c6a961e8c38be13c2efc4cac48cd --- /dev/null +++ b/tasks/format-code-task-002816/tests/test.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +internal/consensus/replay_test.go +internal/rpc/core/blocks_test.go +rpc/client/rpc_test.go +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002816/tests/test_command.sh b/tasks/format-code-task-002816/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002816/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002827/tests/test_command.sh b/tasks/format-code-task-002827/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002827/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002939/environment/Dockerfile b/tasks/format-code-task-002939/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..9fa41e8ec9343aa86ca8a81172d0a883a4ffe20d --- /dev/null +++ b/tasks/format-code-task-002939/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:7428f7c0903c1f26110e76b741a4fb15bf1b6dcee1e29dbc84160fb0343094ea diff --git a/tasks/format-code-task-002939/environment/setup/files/blocklist b/tasks/format-code-task-002939/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002939/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002939/environment/setup/setup.sh b/tasks/format-code-task-002939/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002939/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002939/tests/test.patch b/tasks/format-code-task-002939/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..1d13e7b9435fd8488416e14510e8d019aa94bcab --- /dev/null +++ b/tasks/format-code-task-002939/tests/test.patch @@ -0,0 +1,375 @@ +diff --git a/usercase-test-coderl/fixtures/private.key b/usercase-test-coderl/fixtures/private.key +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/private.key +@@ -0,0 +1,2 @@ ++ file-key ++ c2VjcmV0 +diff --git a/usercase-test-coderl/test_authenticated_private_api.py b/usercase-test-coderl/test_authenticated_private_api.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_authenticated_private_api.py +@@ -0,0 +1,340 @@ ++ ++ ++import base64 ++import hashlib ++import hmac ++import time ++import urllib.parse ++ ++import pytest ++ ++import krakenex ++ ++ ++FIXTURES = "/workspace/repo/usercase-test-coderl/fixtures" ++ ++ ++class RecordingResponse: ++ def __init__(self, payload): ++ self.payload = payload ++ self.status_code = 200 ++ self.json_calls = [] ++ ++ def json(self, **kwargs): ++ self.json_calls.append(dict(kwargs)) ++ return self.payload ++ ++ def raise_for_status(self): ++ raise AssertionError("raise_for_status should not run for HTTP 200") ++ ++ ++class RecordingSession: ++ def __init__(self, payload=None): ++ self.payload = {"ok": True, "source": "recording"} if payload is None else payload ++ self.posts = [] ++ self.gets = [] ++ self.close_count = 0 ++ ++ def post(self, url, data=None, headers=None, timeout=None): ++ self.posts.append( ++ { ++ "url": url, ++ "data": dict(data), ++ "headers": dict(headers), ++ "timeout": timeout, ++ } ++ ) ++ return RecordingResponse(self.payload) ++ ++ def get(self, url, params=None, headers=None, timeout=None): ++ self.gets.append( ++ { ++ "url": url, ++ "params": dict(params), ++ "headers": dict(headers), ++ "timeout": timeout, ++ } ++ ) ++ raise AssertionError("private query should use POST, not GET") ++ ++ def close(self): ++ self.close_count += 1 ++ return None ++ ++ ++class CountingSession(RecordingSession): ++ open_count = 0 ++ ++ def __init__(self): ++ super().__init__({"ok": True, "source": "counting"}) ++ self.closed = False ++ CountingSession.open_count += 1 ++ ++ def close(self): ++ self.close_count += 1 ++ if not self.closed: ++ self.closed = True ++ CountingSession.open_count -= 1 ++ return None ++ ++ ++def expected_kraken_signature(secret, urlpath, params): ++ postdata = urllib.parse.urlencode(params) ++ encoded = (str(params["nonce"]) + postdata).encode() ++ message = urlpath.encode() + hashlib.sha256(encoded).digest() ++ signature = hmac.new(base64.b64decode(secret), message, hashlib.sha512) ++ return base64.b64encode(signature.digest()).decode() ++ ++ ++def assert_private_post( ++ post, ++ *, ++ method, ++ key, ++ secret, ++ expected_params, ++ timeout, ++ nonce_before_ms, ++ nonce_after_ms, ++): ++ ++ urlpath = urllib.parse.urlparse(post["url"]).path ++ assert urlpath == f"/0/private/{method}" ++ assert set(post["data"]) == set(expected_params) | {"nonce"} ++ for name, value in expected_params.items(): ++ assert post["data"][name] == value ++ ++ nonce = int(post["data"]["nonce"]) ++ assert nonce_before_ms <= nonce <= nonce_after_ms ++ ++ assert post["headers"]["API-Key"] == key ++ ++ assert post["headers"]["API-Sign"] == expected_kraken_signature( ++ secret, urlpath, post["data"] ++ ) ++ assert post["timeout"] == timeout ++ ++ ++def test_constructor_credentials_data_none_signed_post_and_timeout(): ++ ++ ++ ++ api = krakenex.API(key="my-key", secret="c2VjcmV0") ++ session = RecordingSession() ++ api.session = session ++ ++ nonce_before_ms = int(time.time() * 1000) ++ result = api.query_private("Balance", data=None, timeout=12.5) ++ nonce_after_ms = int(time.time() * 1000) ++ ++ assert result == {"ok": True, "source": "recording"} ++ assert len(session.posts) == 1 ++ ++ assert_private_post( ++ session.posts[0], ++ method="Balance", ++ key="my-key", ++ secret="c2VjcmV0", ++ expected_params={}, ++ timeout=12.5, ++ nonce_before_ms=nonce_before_ms, ++ nonce_after_ms=nonce_after_ms, ++ ) ++ assert session.gets == [] ++ ++ ++def test_provided_data_is_kept_with_nonce_and_signed(): ++ ++ ++ ++ api = krakenex.API(key="my-key", secret="c2VjcmV0") ++ session = RecordingSession() ++ api.session = session ++ data = {"asset": "XXBT"} ++ ++ nonce_before_ms = int(time.time() * 1000) ++ result = api.query_private("TradesHistory", data=data, timeout=3) ++ nonce_after_ms = int(time.time() * 1000) ++ ++ assert result == {"ok": True, "source": "recording"} ++ assert len(session.posts) == 1 ++ ++ assert_private_post( ++ session.posts[0], ++ method="TradesHistory", ++ key="my-key", ++ secret="c2VjcmV0", ++ expected_params={"asset": "XXBT"}, ++ timeout=3, ++ nonce_before_ms=nonce_before_ms, ++ nonce_after_ms=nonce_after_ms, ++ ) ++ ++ ++def test_load_key_strips_two_lines_then_private_call_uses_loaded_credentials(): ++ ++ ++ ++ api = krakenex.API() ++ session = RecordingSession({"ok": True, "source": "loaded"}) ++ ++ ++ api.load_key(f"{FIXTURES}/private.key") ++ ++ api.session = session ++ nonce_before_ms = int(time.time() * 1000) ++ result = api.query_private("OpenOrders") ++ nonce_after_ms = int(time.time() * 1000) ++ ++ assert result == {"ok": True, "source": "loaded"} ++ assert len(session.posts) == 1 ++ ++ assert_private_post( ++ session.posts[0], ++ method="OpenOrders", ++ key="file-key", ++ secret="c2VjcmV0", ++ expected_params={}, ++ timeout=None, ++ nonce_before_ms=nonce_before_ms, ++ nonce_after_ms=nonce_after_ms, ++ ) ++ ++ ++@pytest.mark.parametrize( ++ ("key", "secret"), ++ [ ++ ("", "c2VjcmV0"), ++ ("my-key", ""), ++ ], ++) ++def test_query_private_requires_both_credentials_before_sending_request(key, secret): ++ ++ ++ ++ api = krakenex.API(key=key, secret=secret) ++ session = RecordingSession() ++ api.session = session ++ ++ with pytest.raises(Exception) as excinfo: ++ api.query_private("Balance") ++ ++ assert excinfo.type is Exception ++ assert str(excinfo.value) == "Either key or secret is not set! (Use `load_key()`." ++ assert session.posts == [] ++ assert session.gets == [] ++ ++ ++def test_two_api_instances_keep_credentials_independent(): ++ ++ ++ ++ api_a = krakenex.API(key="a-key", secret="c2VjcmV0YQ==") ++ api_b = krakenex.API(key="b-key", secret="c2VjcmV0Yg==") ++ session_a = RecordingSession() ++ session_b = RecordingSession() ++ api_a.session = session_a ++ api_b.session = session_b ++ ++ ++ api_a.load_key(f"{FIXTURES}/private.key") ++ nonce_a_before_ms = int(time.time() * 1000) ++ api_a.query_private("Balance") ++ nonce_a_after_ms = int(time.time() * 1000) ++ nonce_b_before_ms = int(time.time() * 1000) ++ api_b.query_private("Balance") ++ nonce_b_after_ms = int(time.time() * 1000) ++ ++ assert len(session_a.posts) == 1 ++ assert_private_post( ++ session_a.posts[0], ++ method="Balance", ++ key="file-key", ++ secret="c2VjcmV0", ++ expected_params={}, ++ timeout=None, ++ nonce_before_ms=nonce_a_before_ms, ++ nonce_after_ms=nonce_a_after_ms, ++ ) ++ assert len(session_b.posts) == 1 ++ assert_private_post( ++ session_b.posts[0], ++ method="Balance", ++ key="b-key", ++ secret="c2VjcmV0Yg==", ++ expected_params={}, ++ timeout=None, ++ nonce_before_ms=nonce_b_before_ms, ++ nonce_after_ms=nonce_b_after_ms, ++ ) ++ ++def test_query_private_uses_assigned_session_object_for_repeated_private_posts(): ++ ++ ++ ++ api = krakenex.API(key="my-key", secret="c2VjcmV0") ++ session = RecordingSession() ++ api.session = session ++ ++ ++ nonce_1_before_ms = int(time.time() * 1000) ++ api.query_private("Balance") ++ nonce_1_after_ms = int(time.time() * 1000) ++ nonce_2_before_ms = int(time.time() * 1000) ++ api.query_private("OpenOrders") ++ nonce_2_after_ms = int(time.time() * 1000) ++ ++ assert len(session.posts) == 2 ++ assert_private_post( ++ session.posts[0], ++ method="Balance", ++ key="my-key", ++ secret="c2VjcmV0", ++ expected_params={}, ++ timeout=None, ++ nonce_before_ms=nonce_1_before_ms, ++ nonce_after_ms=nonce_1_after_ms, ++ ) ++ assert_private_post( ++ session.posts[1], ++ method="OpenOrders", ++ key="my-key", ++ secret="c2VjcmV0", ++ expected_params={}, ++ timeout=None, ++ nonce_before_ms=nonce_2_before_ms, ++ nonce_after_ms=nonce_2_after_ms, ++ ) ++ ++ ++def test_repeated_construct_query_cycles_keep_requests_on_each_instance_session(): ++ ++ ++ ++ retained_sessions = [] ++ ++ ++ for index in range(3): ++ key = f"key-{index}" ++ api = krakenex.API(key=key, secret="c2VjcmV0") ++ session = RecordingSession({"ok": True, "source": f"session-{index}"}) ++ retained_sessions.append(session) ++ api.session = session ++ nonce_before_ms = int(time.time() * 1000) ++ result = api.query_private("Balance") ++ nonce_after_ms = int(time.time() * 1000) ++ assert result == {"ok": True, "source": f"session-{index}"} ++ assert len(session.posts) == 1 ++ assert_private_post( ++ session.posts[0], ++ method="Balance", ++ key=key, ++ secret="c2VjcmV0", ++ expected_params={}, ++ timeout=None, ++ nonce_before_ms=nonce_before_ms, ++ nonce_after_ms=nonce_after_ms, ++ ) ++ ++ assert len(retained_sessions) == 3 ++ assert [len(session.posts) for session in retained_sessions] == [1, 1, 1] +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,18 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo ++ ++export PYTHONPATH="/workspace/repo${PYTHONPATH:+:${PYTHONPATH}}" ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++ ++exec python -m pytest -p no:cacheprovider /workspace/repo/usercase-test-coderl/test_authenticated_private_api.py -v diff --git a/tasks/format-code-task-002939/tests/test.sh b/tasks/format-code-task-002939/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..0b35e89ccfb2ca6f8814b74db5dcdd1a6ef463d7 --- /dev/null +++ b/tasks/format-code-task-002939/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/fixtures/private.key +usercase-test-coderl/test_authenticated_private_api.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002939/tests/test_command.sh b/tasks/format-code-task-002939/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002939/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002952/environment/Dockerfile b/tasks/format-code-task-002952/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..57946c0f0de6447585a7e3d8f45c7d34373b511c --- /dev/null +++ b/tasks/format-code-task-002952/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:66ed62ce90d43f0629a7ea7444fac463f6bb338a2558e4b1bc94f6f4d8adee1a diff --git a/tasks/format-code-task-002952/environment/setup/files/blocklist b/tasks/format-code-task-002952/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002952/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002952/environment/setup/setup.sh b/tasks/format-code-task-002952/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002952/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002952/tests/test.patch b/tasks/format-code-task-002952/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..30158ae811e3233c577e43ca632ff55813fc55cb --- /dev/null +++ b/tasks/format-code-task-002952/tests/test.patch @@ -0,0 +1,40 @@ +diff --git a/pkg/controller/restore_controller_test.go b/pkg/controller/restore_controller_test.go +index 06fcb2e60d..606c341239 100644 +--- a/pkg/controller/restore_controller_test.go ++++ b/pkg/controller/restore_controller_test.go +@@ -287,7 +287,7 @@ func TestProcessRestore(t *testing.T) { + restore: NewRestore("foo", "bar", "backup-1", "ns-1", "*", api.RestorePhaseNew).Restore, + expectedErr: false, + expectedPhase: string(api.RestorePhaseFailedValidation), +- expectedValidationErrors: []string{"Error retrieving backup: not able to fetch from backup storage"}, ++ expectedValidationErrors: []string{"Error retrieving backup: backup.ark.heptio.com \"backup-1\" not found"}, + backupStoreGetBackupMetadataErr: errors.New("no backup here"), + }, + { +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,11 @@ ++H4sIAAAAAAAAA+3U62/TMBAA8H7OX3EMJDaJJHUfmQTah/EaSBub1vGQEJoy+9KYJnawnW5I/PFc ++UrYhXtuHTQhxvy+pzj7n7tw2OWl1pY7RLNPBbRmSzem0f5Ifn/1nMR2J0WgiNieTwVCIbDgewPTW ++KvpO60PuAAbO2vCnfVet/6OSy/sP6MOxtHWdG5X48ubeccX9i3E2vrj/LKO4mGRicwDDmyvh9/7z +++5cK+os/QRVFd+Go1B4aZz+iDNB69LCzf7B99AJqqxDWFTbpEo2ybuMBGBtgx3YrbYU+oewZUlID ++ocTzNP+5rrRZgC5AB1AWvbkfAM+0D0lUL5R2EDeQdsNN5zb1TqZzHcr2JKEvYlpiE7SNKPk93IF4 ++94qNae4W8OFR934TAakMxP6iv2tkR4XupkBdiWQ0BpqFw0+tdqgefgtmFOmG4/suu5OhaI2kfAMm ++r7GbIQWXeaVVHnDbqCe2bioM+JaqmskSu2m9op2zBqUuNNW1XtlTdDL3CHkR0PUnbCSRwmXsT3WQ ++JcxXFUURnjXW0dz3hRB7+09f7z7bskURyWt1R8Udtgbyquor96Cw0IYq0Iba8sE6pD8AE5ytKnTH ++3Z5kbiN6ed9okjaLeXq5IYXY0XFrXbnPkcp8nMtF27w0hf3SxQ6clej94erk2UI3/hfxe33szc8D ++Wy2sznxn3fnsKHupFap+dc/6cIgSTTjPUquENYilbU3YEhAvIQ66RtsGyIY++ts/OcYYY4wxxhhj ++jDHGGGOMMcYYY4yxG/UVBcRFzQAoAAA= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-002952/tests/test.sh b/tasks/format-code-task-002952/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d22fded3e24e818c28b3c43c183e372759b00a5b --- /dev/null +++ b/tasks/format-code-task-002952/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +pkg/controller/restore_controller_test.go +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002952/tests/test_command.sh b/tasks/format-code-task-002952/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002952/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002955/environment/Dockerfile b/tasks/format-code-task-002955/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..2071ffe9d9933d156cc078eb867a73bb5a53abaf --- /dev/null +++ b/tasks/format-code-task-002955/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:be2a605135a1977a8ce210826f9c30384cfc80bf44434b9fe8c2389fd60aa8fd diff --git a/tasks/format-code-task-002955/environment/setup/files/blocklist b/tasks/format-code-task-002955/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002955/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002955/environment/setup/setup.sh b/tasks/format-code-task-002955/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002955/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002955/tests/test.patch b/tasks/format-code-task-002955/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..f64c0ef85583e8681d22d6315ce3f56487f3a3bc --- /dev/null +++ b/tasks/format-code-task-002955/tests/test.patch @@ -0,0 +1,45 @@ +diff --git a/simulator/virtual_machine_test.go b/simulator/virtual_machine_test.go +index d6d379c36..3174cf8f0 100644 +--- a/simulator/virtual_machine_test.go ++++ b/simulator/virtual_machine_test.go +@@ -184,6 +184,16 @@ func TestCreateVm(t *testing.T) { + {vm.Destroy, types.VirtualMachinePowerStatePoweredOn, true}, + // On -> Off == ok + {vm.PowerOff, types.VirtualMachinePowerStatePoweredOff, false}, ++ ++ {vm.Reset, types.VirtualMachinePowerStatePoweredOff, true}, ++ ++ {vm.PowerOn, types.VirtualMachinePowerStatePoweredOn, false}, ++ ++ {vm.Reset, types.VirtualMachinePowerStatePoweredOn, false}, ++ ++ {vm.Suspend, types.VirtualMachinePowerStateSuspended, false}, ++ ++ {vm.PowerOff, types.VirtualMachinePowerStatePoweredOff, false}, + // Destroy == ok (power is Off) + {vm.Destroy, "", false}, + } +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,8 @@ ++H4sIAAAAAAAAA+3SO2/bMBAAYM/6FVckQCaJpp+Th6Ap3KFBith1lwIGRVEWG5EU+FA69MeXkhO7 ++CJB6iVEUvW+h7vjWMcuDrIut0C0ZnMswmk+nfRu9bPtvOh3REZ2MR7PxYEjpLKZgerYT/SY4zyzA ++wBrj/zTuVP8/KjvW3wvnt9woxXSRuert9jhV//lkfqw/ncf6T2aj8QCGb3eE1/3n9b94R3KpSc5c ++lfAC+keQiyJJLmAlPIQGlnefr9cfwXkbuA9WQGksNFakyhShFg6WJobmu+A+UQ+FtJA2QLrfRXaG ++OMvJTvoq5Fl8WqRVj8yKpNaQulIftjsxPna0yiiZJOJHY6x/OtPiedYxTSm9vbv58unDwpRld4n7 ++oMFXArqNHJTWKHBShZp5Y0krrQ+s3irGK6nFthuU9csJDjvTT4K0hZSboP2CwrcEILVxyat17Hpv ++BfNioy5/dtG94EaXcrdRN6KVXLzM7uPnOV/jHffj3L5jVQVfmEe9DDHYpzZqpVnjKnOIb5l9uHZr ++oZp4AXF51R/o1d9FDjdN/vYzQwghhBBCCCGEEEIIIYQQQgghhBBCZ/ILk0VXlgAoAAA= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-002955/tests/test.sh b/tasks/format-code-task-002955/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..fa85bd2a949ba4a6ade09516e26e1c45d45f75de --- /dev/null +++ b/tasks/format-code-task-002955/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +simulator/virtual_machine_test.go +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002955/tests/test_command.sh b/tasks/format-code-task-002955/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002955/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002963/environment/Dockerfile b/tasks/format-code-task-002963/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..bb24a29523972ed4baef3589a95286bf4de039bd --- /dev/null +++ b/tasks/format-code-task-002963/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:ee307eb1075db6c0a08ec7134c1e1610042ebc5a080e7cb902f030c0d5b1c74c diff --git a/tasks/format-code-task-002963/environment/setup/files/blocklist b/tasks/format-code-task-002963/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002963/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002963/environment/setup/setup.sh b/tasks/format-code-task-002963/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002963/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002963/tests/test.patch b/tasks/format-code-task-002963/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..02a326e2c14887b71c55cd5ccb79fb4a30bc02f0 --- /dev/null +++ b/tasks/format-code-task-002963/tests/test.patch @@ -0,0 +1,233 @@ +diff --git a/usercase-test-coderl/test_evaluation.py b/usercase-test-coderl/test_evaluation.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_evaluation.py +@@ -0,0 +1,205 @@ ++ ++ ++import matplotlib ++ ++matplotlib.use("Agg") ++import matplotlib.pyplot as plt ++import matplotlib.colors as mcolors ++import numpy as np ++import pytest ++ ++from algotrading.evaluation import Evaluation ++ ++ ++PRICES = np.array([100, 110, 90]) ++DATES = ["2020-01-01", "2020-01-02", "2020-02-01"] ++OUTPUT = [10000, 10100, 9900] ++ADJUSTED = [-0.00019386822499793492, 0.009608462092263364, -0.015915411515268343] ++RISK_FREE = [10001.939058171745, 10003.87811634349, 10060.1108033241] ++SHARPE = -6.213195634989451 ++SORTINO = -7.196309096439963 ++ROI = -0.01 ++COMPLETE = (-6.213195634989451, -7.196309096439963, -1.0) ++ ++ ++def expected_risk_free(dates, output): ++ return [ ++ (1 + ((((int(date.split("-")[1]) - 1) * 30 + int(date.split("-")[2])) / 361) * 0.07)) * output[0] ++ for date in dates ++ ] ++ ++ ++def expected_adjusted(dates, output): ++ return [(output[i] - risk_free) / risk_free for i, risk_free in enumerate(expected_risk_free(dates, output))] ++ ++ ++def sample_std(values): ++ return float(np.std(values, ddof=1)) ++ ++ ++def line_with_color(axis, color_name): ++ target = mcolors.to_rgba(color_name) ++ matches = [line for line in axis.lines if mcolors.to_rgba(line.get_color()) == target] ++ assert matches, f"no {color_name} line found" ++ return matches[0] ++ ++ ++def test_constructor_retains_inputs_and_computes_metrics(): ++ ++ ++ ++ ++ evaluation = Evaluation(PRICES, DATES, OUTPUT, "DemoAlgo", "TEST") ++ ++ ++ for method_name in ( ++ "roi", ++ "get_days", ++ "get_adjusted_return", ++ "sharpe_ratio", ++ "sortino_ratio", ++ "complete_evaluation", ++ "plot_output", ++ ): ++ assert callable(getattr(evaluation, method_name)) ++ assert evaluation.get_days("2020-02-01") == 31 ++ assert evaluation.roi() == ROI ++ ++ first = evaluation.get_adjusted_return() ++ ++ assert [float(value) for value in first] == pytest.approx(ADJUSTED) ++ ++ second = evaluation.get_adjusted_return() ++ ++ assert [float(value) for value in second] == pytest.approx(ADJUSTED) ++ assert float(evaluation.sharpe_ratio()) == pytest.approx(SHARPE) ++ assert float(evaluation.sortino_ratio()) == pytest.approx(SORTINO) ++ assert tuple(float(value) for value in evaluation.complete_evaluation()) == pytest.approx(COMPLETE) ++ ++ ++def test_formulas_apply_beyond_documented_sample(): ++ ++ ++ ++ ++ prices = np.array([50, 60, 55, 70]) ++ dates = ["2021-03-05", "2021-03-06", "2021-04-01", "2021-12-31"] ++ output = [20000, 20200, 19800, 21000] ++ evaluation = Evaluation(prices, dates, output, "AltAlgo", "ALT") ++ adjusted = expected_adjusted(dates, output) ++ roi = (output[-1] - output[0]) / output[0] ++ sharpe = (roi - 0.07) / sample_std(adjusted) ++ sortino = (roi - 0.07) / sample_std([value for value in adjusted if value < 0]) ++ ++ ++ assert evaluation.get_days("2021-12-31") == 361 ++ assert evaluation.roi() == pytest.approx(0.05) ++ assert [float(value) for value in evaluation.get_adjusted_return()] == pytest.approx(adjusted) ++ assert float(evaluation.sharpe_ratio()) == pytest.approx(sharpe) ++ assert float(evaluation.sortino_ratio()) == pytest.approx(sortino) ++ assert tuple(float(value) for value in evaluation.complete_evaluation(get_plots=False, verbose=False)) == pytest.approx( ++ (sharpe, sortino, roi * 100) ++ ) ++ ++ ++def test_invalid_date_raises_value_error(): ++ ++ ++ ++ ++ evaluation = Evaluation(PRICES, ["2020-AA-01", "2020-01-02", "2020-02-01"], OUTPUT, "DemoAlgo", "TEST") ++ ++ ++ with pytest.raises(ValueError): ++ evaluation.get_days("2020-AA-01") ++ ++ ++ with pytest.raises(ValueError): ++ evaluation.get_adjusted_return() ++ ++ ++def test_plot_output_uses_populated_risk_free_series(): ++ ++ ++ ++ ++ evaluation = Evaluation(PRICES, DATES, OUTPUT, "DemoAlgo", "TEST") ++ ++ ++ evaluation.get_adjusted_return() ++ original_show = plt.show ++ plt.show = lambda *args, **kwargs: None ++ try: ++ plt.close("all") ++ evaluation.plot_output() ++ axis = plt.gcf().axes[0] ++ blue_line = line_with_color(axis, "blue") ++ assert [float(value) for value in blue_line.get_ydata()] == pytest.approx(RISK_FREE) ++ finally: ++ plt.show = original_show ++ plt.close("all") ++ ++ ++def test_plot_output_draws_expected_chart(): ++ ++ ++ ++ ++ evaluation = Evaluation(PRICES, DATES, OUTPUT, "DemoAlgo", "TEST") ++ evaluation.get_adjusted_return() ++ calls = [] ++ original_show = plt.show ++ plt.show = lambda *args, **kwargs: calls.append("show") ++ try: ++ plt.close("all") ++ evaluation.plot_output() ++ axis = plt.gcf().axes[0] ++ ++ ++ assert calls ++ assert axis.get_xlabel() == "Days" ++ assert axis.get_ylabel() == "INR" ++ assert axis.get_title() == "Running DemoAlgo on TEST stocks" ++ assert any(line.get_visible() for line in axis.get_xgridlines()) ++ assert any(line.get_visible() for line in axis.get_ygridlines()) ++ ++ red_line = line_with_color(axis, "red") ++ blue_line = line_with_color(axis, "blue") ++ green_line = line_with_color(axis, "green") ++ assert [float(value) for value in red_line.get_ydata()] == pytest.approx([10000.0, 10100.0, 9900.0]) ++ assert [float(value) for value in blue_line.get_ydata()] == pytest.approx(RISK_FREE) ++ assert [float(value) for value in green_line.get_ydata()] == pytest.approx([10000.0, 11000.0, 9000.0]) ++ finally: ++ plt.show = original_show ++ plt.close("all") ++ ++ ++def test_repeated_adjusted_return_values_stay_independent(): ++ ++ ++ ++ ++ a = Evaluation(PRICES, DATES, OUTPUT, "DemoAlgoA", "TESTA") ++ b = Evaluation(PRICES, DATES, OUTPUT, "DemoAlgoB", "TESTB") ++ ++ a_first = a.get_adjusted_return() ++ ++ assert [float(value) for value in a_first] == pytest.approx(ADJUSTED) ++ ++ b_first = b.get_adjusted_return() ++ assert [float(value) for value in b_first] == pytest.approx(ADJUSTED) ++ assert [float(value) for value in a.get_adjusted_return()] == pytest.approx(ADJUSTED) ++ assert [float(value) for value in b.get_adjusted_return()] == pytest.approx(ADJUSTED) ++ ++ ++def test_repeated_construct_use_drop_keeps_results_stable(): ++ ++ ++ ++ ++ for _ in range(20): ++ evaluation = Evaluation(PRICES, DATES, OUTPUT, "DemoAlgo", "TEST") ++ ++ assert [float(value) for value in evaluation.get_adjusted_return()] == pytest.approx(ADJUSTED) ++ assert float(evaluation.sharpe_ratio()) == pytest.approx(SHARPE) ++ assert float(evaluation.sortino_ratio()) == pytest.approx(SORTINO) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,18 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo ++ ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++export MPLBACKEND=Agg ++ ++exec python -m pytest /workspace/repo/usercase-test-coderl/test_evaluation.py -v diff --git a/tasks/format-code-task-002963/tests/test.sh b/tasks/format-code-task-002963/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..53a0950280df6936eef85f0827af05a7374bf4bb --- /dev/null +++ b/tasks/format-code-task-002963/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/test_evaluation.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002963/tests/test_command.sh b/tasks/format-code-task-002963/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002963/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002964/environment/Dockerfile b/tasks/format-code-task-002964/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e600f058bb6bb933eac3bbe397eae4830dcae257 --- /dev/null +++ b/tasks/format-code-task-002964/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:2138afcfd4d4c740d1fd393a9739e2ed42a555d0ebd1652d6460b5baef2bcbbd diff --git a/tasks/format-code-task-002964/environment/setup/files/blocklist b/tasks/format-code-task-002964/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002964/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002964/environment/setup/setup.sh b/tasks/format-code-task-002964/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002964/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002964/tests/test.patch b/tasks/format-code-task-002964/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..99aa23165104d755824333e5f46e5dd3b3fc88b5 --- /dev/null +++ b/tasks/format-code-task-002964/tests/test.patch @@ -0,0 +1,180 @@ +diff --git a/usercase-test-coderl/test_momentum_agent.py b/usercase-test-coderl/test_momentum_agent.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_momentum_agent.py +@@ -0,0 +1,151 @@ ++ ++ ++import math ++from numbers import Real ++ ++import pytest ++ ++from algotrading.agents.momentum_agent import Momentum_Agent ++ ++ ++def _compact_agent(): ++ return Momentum_Agent(5, 2, 5, 5, 20, 80, 2, 5, 3) ++ ++ ++def _feed(agent, prices): ++ return [agent.step(price) for price in prices] ++ ++ ++def _assert_finite_number(value): ++ assert isinstance(value, Real) ++ assert math.isfinite(value) ++ ++ ++def test_buy_signal_session_reaches_positive_momentum_state(): ++ ++ ++ ++ ++ agent = _compact_agent() ++ ++ assert agent.step(7) == 0 ++ assert agent.step(1) == 0 ++ assert agent.step(1) == 0 ++ assert agent.step(5) == 0 ++ assert agent.step(2) == 1 ++ assert agent.get_sma(2) == pytest.approx(3.5, rel=0, abs=1e-12) ++ assert agent.get_sma(5) == pytest.approx(3.2, rel=0, abs=1e-12) ++ assert agent.get_stoch_osc(5) == pytest.approx(16.666666666666668, rel=0, abs=1e-12) ++ macd_hist = agent.get_macd_hist(2, 5, 3, 2) ++ ++ _assert_finite_number(macd_hist) ++ assert macd_hist > 0 ++ ++ ++def test_sell_signal_session_reaches_negative_momentum_state(): ++ ++ ++ ++ ++ agent = _compact_agent() ++ ++ assert agent.step(1) == 0 ++ assert agent.step(6) == 0 ++ assert agent.step(7) == 0 ++ assert agent.step(3) == 0 ++ assert agent.step(6) == -1 ++ assert agent.get_sma(2) == pytest.approx(4.5, rel=0, abs=1e-12) ++ assert agent.get_sma(5) == pytest.approx(4.6, rel=0, abs=1e-12) ++ assert agent.get_stoch_osc(5) == pytest.approx(83.33333333333333, rel=0, abs=1e-12) ++ macd_hist = agent.get_macd_hist(2, 5, 3, 6) ++ ++ _assert_finite_number(macd_hist) ++ assert macd_hist < 0 ++ ++ ++def test_full_window_hold_when_only_some_signal_conditions_match(): ++ ++ ++ ++ ++ agent = _compact_agent() ++ ++ assert agent.step(2) == 0 ++ assert agent.step(3) == 0 ++ assert agent.step(4) == 0 ++ assert agent.step(5) == 0 ++ assert agent.step(6) == 0 ++ assert agent.get_sma(2) == pytest.approx(5.5, rel=0, abs=1e-12) ++ assert agent.get_sma(5) == pytest.approx(4.0, rel=0, abs=1e-12) ++ assert agent.get_stoch_osc(5) == pytest.approx(100.0, rel=0, abs=1e-12) ++ macd_hist = agent.get_macd_hist(2, 5, 3, 6) ++ ++ _assert_finite_number(macd_hist) ++ assert macd_hist > 0 ++ ++ ++def test_step_keeps_latest_window_after_more_than_window_size_prices(): ++ ++ ++ ++ ++ agent = _compact_agent() ++ ++ assert _feed(agent, [7, 1, 1, 5, 2, 10]) == [0, 0, 0, 0, 1, 0] ++ assert agent.get_sma(2) == pytest.approx(6.0, rel=0, abs=1e-12) ++ assert agent.get_sma(5) == pytest.approx(3.8, rel=0, abs=1e-12) ++ assert agent.get_stoch_osc(5) == pytest.approx(100.0, rel=0, abs=1e-12) ++ macd_hist = agent.get_macd_hist(2, 5, 3, 10) ++ ++ _assert_finite_number(macd_hist) ++ assert macd_hist > 0 ++ ++ ++def test_indicator_getters_expose_values_after_prices_are_fed(): ++ ++ ++ ++ ++ agent = _compact_agent() ++ ++ _feed(agent, [7, 1, 1, 5, 2]) ++ ++ assert agent.get_sma(2) == pytest.approx(3.5, rel=0, abs=1e-12) ++ stoch_osc = agent.get_stoch_osc(5) ++ _assert_finite_number(stoch_osc) ++ assert 0 <= stoch_osc <= 100 ++ macd_hist = agent.get_macd_hist(2, 5, 3, 2) ++ _assert_finite_number(macd_hist) ++ ++ ++def test_separate_instances_do_not_share_price_memory(): ++ ++ ++ ++ ++ first = _compact_agent() ++ second = _compact_agent() ++ ++ assert _feed(first, [7, 1, 1, 5, 2]) == [0, 0, 0, 0, 1] ++ assert _feed(second, [1, 6, 7, 3]) == [0, 0, 0, 0] ++ assert second.step(6) == -1 ++ assert first.get_sma(5) == pytest.approx(3.2, rel=0, abs=1e-12) ++ assert second.get_sma(5) == pytest.approx(4.6, rel=0, abs=1e-12) ++ assert first.get_stoch_osc(5) == pytest.approx(16.666666666666668, rel=0, abs=1e-12) ++ assert second.get_stoch_osc(5) == pytest.approx(83.33333333333333, rel=0, abs=1e-12) ++ ++ ++def test_long_prior_history_does_not_affect_latest_window_signal(): ++ ++ ++ ++ ++ agent = _compact_agent() ++ ++ for price in range(50, 150): ++ agent.step(price) ++ ++ ++ assert _feed(agent, [7, 1, 1, 5, 2])[-1] == 1 ++ assert agent.get_sma(5) == pytest.approx(3.2, rel=0, abs=1e-12) ++ assert agent.get_stoch_osc(5) == pytest.approx(16.666666666666668, rel=0, abs=1e-12) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,19 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++ ++export PYTHONPATH="/workspace/repo${PYTHONPATH:+:${PYTHONPATH}}" ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++ ++exec python -m pytest /workspace/repo/usercase-test-coderl/test_momentum_agent.py -v diff --git a/tasks/format-code-task-002964/tests/test.sh b/tasks/format-code-task-002964/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..cccc0a78d73ac9b0703364922a2c41c89c0ebba8 --- /dev/null +++ b/tasks/format-code-task-002964/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/test_momentum_agent.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002964/tests/test_command.sh b/tasks/format-code-task-002964/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002964/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002990/environment/Dockerfile b/tasks/format-code-task-002990/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..fbbdd4a749c5b4386c1d75fbec3f62a6825f5090 --- /dev/null +++ b/tasks/format-code-task-002990/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:60cbe4bf3093999c1e009851839c0d77297a8c7c6d4e2bc670ef62fd08bfa88f diff --git a/tasks/format-code-task-002990/environment/setup/files/blocklist b/tasks/format-code-task-002990/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002990/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002990/environment/setup/setup.sh b/tasks/format-code-task-002990/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002990/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002990/tests/test.patch b/tasks/format-code-task-002990/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..6090fa904cb65938f9937a1fd4a22386212713d4 --- /dev/null +++ b/tasks/format-code-task-002990/tests/test.patch @@ -0,0 +1,636 @@ +diff --git a/usercase-test-coderl/client_announce_lifecycle.test.js b/usercase-test-coderl/client_announce_lifecycle.test.js +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/client_announce_lifecycle.test.js +@@ -0,0 +1,565 @@ ++import test from 'tape' ++import { Client, Server } from '../index.js' ++ ++ ++ ++ ++ ++ ++ ++ ++ ++const INFO_HASH = '0123456789012345678901234567890123456789' ++const PEER_ID = '1234567890123456789012345678901234567890' ++const ALT_INFO_HASH = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' ++const ALT_PEER_ID = 'abcdefabcdefabcdefabcdefabcdefabcdefabcd' ++const PORT = 6881 ++ ++function createTrackerServer (serverType, opts = {}) { ++ return new Promise((resolve, reject) => { ++ const server = new Server({ ++ http: serverType === 'http', ++ udp: serverType === 'udp', ++ ws: serverType === 'ws', ++ stats: false, ++ ...opts ++ }) ++ server.once('error', reject) ++ server.on('warning', reject) ++ server.listen(0, () => { ++ const port = server[serverType].address().port ++ const announce = serverType === 'http' ++ ? `http://127.0.0.1:${port}/announce` ++ : serverType === 'udp' ++ ? `udp://127.0.0.1:${port}` ++ : `ws://127.0.0.1:${port}` ++ resolve({ server, announce }) ++ }) ++ }) ++} ++ ++function closeServer (server) { ++ return new Promise(resolve => server.close(() => resolve())) ++} ++ ++function destroyClient (client) { ++ return new Promise(resolve => client.destroy(() => resolve())) ++} ++ ++function wait (ms) { ++ return new Promise(resolve => setTimeout(resolve, ms)) ++} ++ ++function newClient (announce, opts = {}) { ++ return new Client({ ++ infoHash: opts.infoHash || INFO_HASH, ++ peerId: opts.peerId || PEER_ID, ++ announce, ++ port: opts.port || PORT, ++ getAnnounceOpts: opts.getAnnounceOpts, ++ wrtc: {} ++ }) ++} ++ ++function observeClient (t, client, updates) { ++ client.on('update', data => { ++ updates.push({ ++ announce: data.announce, ++ complete: data.complete, ++ incomplete: data.incomplete ++ }) ++ }) ++ client.on('warning', err => { ++ t.fail(`unexpected warning: ${err.message}`) ++ }) ++ client.on('error', err => { ++ t.fail(`unexpected error: ${err.message}`) ++ }) ++} ++ ++async function cleanup (server, client) { ++ if (client && !client.destroyed) await destroyClient(client) ++ if (server && !server.destroyed) await closeServer(server) ++} ++ ++test('public Client constructor exposes lifecycle interval control', t => { ++ t.plan(1) ++ ++ ++ ++ ++ const client = newClient('http://127.0.0.1:1/announce') ++ ++ t.equal(typeof client.setInterval, 'function') ++ client.destroy(() => {}) ++}) ++ ++test('destroy is idempotent when called twice on a started client', async t => { ++ t.plan(2) ++ ++ ++ ++ ++ const { server, announce } = await createTrackerServer('http') ++ const client = newClient(announce, { ++ getAnnounceOpts () { ++ return { numwant: 0 } ++ } ++ }) ++ const updates = [] ++ observeClient(t, client, updates) ++ ++ client.setInterval(100) ++ client.start({ left: 11 }) ++ await wait(80) ++ await destroyClient(client) ++ t.deepEqual(updates, [ ++ { announce, complete: 0, incomplete: 1 } ++ ]) ++ await wait(140) ++ ++ t.equal(updates.length, 1) ++ await closeServer(server) ++}) ++ ++test('start schedules protocol default recurring announce cadences', async t => { ++ t.plan(2) ++ ++ ++ ++ ++ const http = await createTrackerServer('http') ++ const udp = await createTrackerServer('udp') ++ const ws = await createTrackerServer('ws') ++ const originalSetInterval = globalThis.setInterval ++ const originalClearInterval = globalThis.clearInterval ++ const scheduled = [] ++ globalThis.setInterval = (fn, ms, ...args) => { ++ const handle = originalSetInterval(fn, 60 * 60 * 1000, ...args) ++ scheduled.push(ms) ++ return handle ++ } ++ globalThis.clearInterval = handle => originalClearInterval(handle) ++ ++ const client = newClient([http.announce, udp.announce, ws.announce], { ++ getAnnounceOpts () { ++ return { numwant: 0 } ++ } ++ }) ++ client.on('warning', err => { ++ t.fail(`unexpected warning: ${err.message}`) ++ }) ++ client.on('error', err => { ++ t.fail(`unexpected error: ${err.message}`) ++ }) ++ ++ try { ++ client.start({ numwant: 0, left: 9 }) ++ ++ t.deepEqual(scheduled.slice(0, 3).sort((a, b) => a - b), [30000, 1800000, 1800000]) ++ await destroyClient(client) ++ ++ t.equal(scheduled.length, 3) ++ } finally { ++ globalThis.setInterval = originalSetInterval ++ globalThis.clearInterval = originalClearInterval ++ await closeServer(http.server) ++ await closeServer(udp.server) ++ await closeServer(ws.server) ++ } ++}) ++ ++test('http announce response interval drives recurring announces and refreshes getAnnounceOpts', async t => { ++ t.plan(3) ++ ++ ++ ++ ++ const { server, announce } = await createTrackerServer('http', { interval: 1000 }) ++ const seenEvents = [] ++ const seenLeft = [] ++ let left = 99 ++ const client = newClient(announce, { ++ getAnnounceOpts () { ++ left += 1 ++ return { left } ++ } ++ }) ++ const updates = [] ++ observeClient(t, client, updates) ++ server.on('start', (peer, params) => { ++ seenEvents.push('started') ++ seenLeft.push(params.left) ++ }) ++ server.on('update', (peer, params) => { ++ seenEvents.push('update') ++ seenLeft.push(params.left) ++ }) ++ ++ client.start() ++ await wait(2250) ++ ++ ++ t.deepEqual({ ++ first: seenEvents[0], ++ total: seenEvents.length, ++ updates: seenEvents.filter(event => event === 'update').length ++ }, { first: 'started', total: 3, updates: 2 }) ++ const updateLefts = seenEvents ++ .map((event, index) => event === 'update' ? seenLeft[index] : null) ++ .filter(left => left != null) ++ ++ t.ok(updateLefts.length === 2 && updateLefts[1] > updateLefts[0]) ++ t.deepEqual(updates, [ ++ { announce, complete: 0, incomplete: 1 }, ++ { announce, complete: 0, incomplete: 1 }, ++ { announce, complete: 0, incomplete: 1 } ++ ]) ++ ++ await cleanup(server, client) ++}) ++ ++test('udp start adopts UDP announce interval response for recurring announces', async t => { ++ t.plan(3) ++ ++ ++ ++ ++ const { server, announce } = await createTrackerServer('udp', { interval: 1000 }) ++ const seenEvents = [] ++ const seenDownloaded = [] ++ const client = newClient(announce, { ++ getAnnounceOpts () { ++ return { numwant: 0 } ++ } ++ }) ++ const updates = [] ++ observeClient(t, client, updates) ++ server.on('start', (peer, params) => { ++ seenEvents.push('started') ++ seenDownloaded.push(params.downloaded) ++ }) ++ server.on('update', (peer, params) => { ++ seenEvents.push('update') ++ seenDownloaded.push(params.downloaded) ++ }) ++ ++ client.start({ downloaded: 7, left: 12 }) ++ await wait(2250) ++ ++ ++ t.deepEqual({ ++ first: seenEvents[0], ++ total: seenEvents.length, ++ updates: seenEvents.filter(event => event === 'update').length ++ }, { first: 'started', total: 3, updates: 2 }) ++ ++ t.equal(seenDownloaded[0], 7) ++ t.deepEqual(updates, [ ++ { announce, complete: 0, incomplete: 1 }, ++ { announce, complete: 0, incomplete: 1 }, ++ { announce, complete: 0, incomplete: 1 } ++ ]) ++ ++ await cleanup(server, client) ++}) ++ ++test('websocket start uses response interval and public numwant zero without private offer mocks', async t => { ++ t.plan(3) ++ ++ ++ ++ ++ const { server, announce } = await createTrackerServer('ws', { interval: 1000 }) ++ const seenEvents = [] ++ const seenNumwant = [] ++ const client = newClient(announce, { ++ getAnnounceOpts () { ++ return { numwant: 0 } ++ } ++ }) ++ const updates = [] ++ observeClient(t, client, updates) ++ server.on('start', (peer, params) => { ++ seenEvents.push('started') ++ seenNumwant.push(params.numwant) ++ }) ++ server.on('update', (peer, params) => { ++ seenEvents.push('update') ++ seenNumwant.push(params.numwant) ++ }) ++ ++ client.start({ numwant: 0, left: 13 }) ++ await wait(2250) ++ ++ ++ t.deepEqual({ ++ first: seenEvents[0], ++ total: seenEvents.length, ++ updates: seenEvents.filter(event => event === 'update').length ++ }, { first: 'started', total: 3, updates: 2 }) ++ t.deepEqual(seenNumwant, [0, 0, 0]) ++ t.deepEqual(updates, [ ++ { announce, complete: 0, incomplete: 1 }, ++ { announce, complete: 0, incomplete: 1 }, ++ { announce, complete: 0, incomplete: 1 } ++ ]) ++ ++ await cleanup(server, client) ++}) ++ ++test('setInterval before start changes cadence for later scheduled http announces', async t => { ++ t.plan(3) ++ ++ ++ ++ ++ const { server, announce } = await createTrackerServer('http') ++ const seenEvents = [] ++ const client = newClient(announce) ++ const updates = [] ++ observeClient(t, client, updates) ++ server.on('start', () => seenEvents.push('started')) ++ server.on('update', () => seenEvents.push('update')) ++ ++ client.setInterval(120) ++ await wait(270) ++ client.start({ left: 21 }) ++ await wait(190) ++ ++ ++ t.ok(seenEvents.includes('started') && seenEvents.includes('update')) ++ ++ t.equal(seenEvents.filter(event => event === 'update').length, 1) ++ ++ t.equal(updates.length, 2) ++ ++ await cleanup(server, client) ++}) ++ ++test('setInterval after start replaces the existing timer instead of duplicating it', async t => { ++ t.plan(3) ++ ++ ++ ++ ++ const { server, announce } = await createTrackerServer('http') ++ const seenEvents = [] ++ const client = newClient(announce) ++ const updates = [] ++ observeClient(t, client, updates) ++ server.on('start', () => seenEvents.push('started')) ++ server.on('update', () => seenEvents.push('update')) ++ ++ client.start({ left: 31 }) ++ await wait(70) ++ client.setInterval(90) ++ await wait(35) ++ client.setInterval(90) ++ await wait(310) ++ ++ ++ t.deepEqual({ ++ first: seenEvents[0], ++ total: seenEvents.length, ++ updates: seenEvents.filter(event => event === 'update').length ++ }, { first: 'started', total: 2, updates: 1 }) ++ t.deepEqual(updates, [ ++ { announce, complete: 0, incomplete: 1 }, ++ { announce, complete: 0, incomplete: 1 } ++ ]) ++ ++ t.equal(updates.length, 2) ++ ++ await cleanup(server, client) ++}) ++ ++test('setInterval zero disables recurring announce timer', async t => { ++ t.plan(3) ++ ++ ++ ++ ++ const { server, announce } = await createTrackerServer('http') ++ const seenEvents = [] ++ const client = newClient(announce) ++ const updates = [] ++ observeClient(t, client, updates) ++ server.on('start', () => seenEvents.push('started')) ++ server.on('update', () => seenEvents.push('update')) ++ ++ client.start({ left: 41 }) ++ await wait(70) ++ client.setInterval(80) ++ await wait(130) ++ client.setInterval(0) ++ await wait(260) ++ ++ ++ t.deepEqual({ ++ first: seenEvents[0], ++ total: seenEvents.length, ++ updates: seenEvents.filter(event => event === 'update').length ++ }, { first: 'started', total: 2, updates: 1 }) ++ t.deepEqual(updates, [ ++ { announce, complete: 0, incomplete: 1 }, ++ { announce, complete: 0, incomplete: 1 } ++ ]) ++ ++ t.equal(updates.length, 2) ++ ++ await cleanup(server, client) ++}) ++ ++test('two clients keep independent recurring announce timers and default options', async t => { ++ t.plan(4) ++ ++ ++ ++ ++ const { server, announce } = await createTrackerServer('http') ++ const seenByPeer = { ++ [PEER_ID]: [], ++ [ALT_PEER_ID]: [] ++ } ++ const clientA = newClient(announce, { ++ getAnnounceOpts () { ++ return { left: 201 } ++ } ++ }) ++ const clientB = newClient(announce, { ++ infoHash: ALT_INFO_HASH, ++ peerId: ALT_PEER_ID, ++ port: PORT + 1, ++ getAnnounceOpts () { ++ return { left: 301 } ++ } ++ }) ++ const updatesA = [] ++ const updatesB = [] ++ observeClient(t, clientA, updatesA) ++ observeClient(t, clientB, updatesB) ++ server.on('start', (peer, params) => { ++ seenByPeer[params.peer_id].push(`started:${params.left}`) ++ }) ++ server.on('update', (peer, params) => { ++ seenByPeer[params.peer_id].push(`update:${params.left}`) ++ }) ++ ++ clientA.start() ++ clientB.start() ++ await wait(70) ++ clientA.setInterval(80) ++ clientB.setInterval(140) ++ await wait(110) ++ ++ ++ t.deepEqual({ ++ aStarts: seenByPeer[PEER_ID].filter(event => event === 'started:201').length, ++ aUpdates: seenByPeer[PEER_ID].filter(event => event === 'update:201').length ++ }, { aStarts: 1, aUpdates: 1 }) ++ ++ t.deepEqual({ ++ bStarts: seenByPeer[ALT_PEER_ID].filter(event => event === 'started:301').length, ++ bUpdates: seenByPeer[ALT_PEER_ID].filter(event => event === 'update:301').length ++ }, { bStarts: 1, bUpdates: 0 }) ++ await wait(70) ++ ++ t.deepEqual({ ++ bStarts: seenByPeer[ALT_PEER_ID].filter(event => event === 'started:301').length, ++ bUpdates: seenByPeer[ALT_PEER_ID].filter(event => event === 'update:301').length ++ }, { bStarts: 1, bUpdates: 1 }) ++ t.equal(updatesA.length, 2) ++ ++ await destroyClient(clientA) ++ await cleanup(server, clientB) ++}) ++ ++test('destroy clears all recurring announce timers so no later events are emitted', async t => { ++ t.plan(4) ++ ++ ++ ++ ++ const { server, announce } = await createTrackerServer('http') ++ const client = newClient(announce) ++ const updates = [] ++ const postDestroy = { ++ update: 0, ++ peer: 0, ++ warning: 0 ++ } ++ observeClient(t, client, updates) ++ ++ client.start({ left: 51 }) ++ await wait(70) ++ client.setInterval(80) ++ await wait(120) ++ await destroyClient(client) ++ client.on('update', () => { postDestroy.update += 1 }) ++ client.on('peer', () => { postDestroy.peer += 1 }) ++ client.on('warning', () => { postDestroy.warning += 1 }) ++ await wait(240) ++ ++ t.deepEqual(updates, [ ++ { announce, complete: 0, incomplete: 1 }, ++ { announce, complete: 0, incomplete: 1 } ++ ]) ++ t.equal(postDestroy.update, 0) ++ t.equal(postDestroy.peer, 0) ++ t.equal(postDestroy.warning, 0) ++ ++ await closeServer(server) ++}) ++ ++test('leak floor: 100 construct-use-destroy cycles clear all interval handles', async t => { ++ t.plan(3) ++ ++ ++ ++ ++ const { server, announce } = await createTrackerServer('http') ++ const originalSetInterval = globalThis.setInterval ++ const originalClearInterval = globalThis.clearInterval ++ const activeIntervals = new Set() ++ let starts = 0 ++ let updates = 0 ++ server.on('start', () => { starts += 1 }) ++ server.on('update', () => { updates += 1 }) ++ ++ globalThis.setInterval = (fn, ms, ...args) => { ++ const handle = originalSetInterval(fn, ms, ...args) ++ activeIntervals.add(handle) ++ return handle ++ } ++ globalThis.clearInterval = handle => { ++ activeIntervals.delete(handle) ++ return originalClearInterval(handle) ++ } ++ ++ try { ++ for (let i = 0; i < 100; i += 1) { ++ const client = newClient(announce, { ++ peerId: (BigInt(`0x${PEER_ID}`) + BigInt(i)).toString(16).padStart(40, '0'), ++ port: PORT + (i % 100) ++ }) ++ client.on('warning', err => { ++ t.fail(`unexpected warning during leak floor: ${err.message}`) ++ }) ++ client.on('error', err => { ++ t.fail(`unexpected error during leak floor: ${err.message}`) ++ }) ++ client.start({ left: 61 }) ++ await destroyClient(client) ++ } ++ } finally { ++ globalThis.setInterval = originalSetInterval ++ globalThis.clearInterval = originalClearInterval ++ } ++ ++ t.equal(starts, 100) ++ t.equal(updates, 0) ++ t.equal(activeIntervals.size, 0) ++ ++ await closeServer(server) ++}) +diff --git a/usercase-test-coderl/run_client_announce_lifecycle.cjs b/usercase-test-coderl/run_client_announce_lifecycle.cjs +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/run_client_announce_lifecycle.cjs +@@ -0,0 +1,25 @@ ++#!/usr/bin/env node ++'use strict' ++ ++const path = require('path') ++const { pathToFileURL } = require('url') ++const tape = require('tape') ++ ++const testFile = path.resolve(__dirname, 'client_announce_lifecycle.test.js') ++ ++tape.wait() ++tape.createStream().pipe(process.stdout) ++tape.onFinish(() => { ++ ++ ++ process.exit(tape.getHarness()._exitCode) ++}) ++ ++import(pathToFileURL(testFile).href) ++ .then(() => { ++ tape.run() ++ }) ++ .catch(err => { ++ console.error(err) ++ process.exit(1) ++ }) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,31 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++ ++export npm_config_offline=true ++export npm_config_audit=false ++export npm_config_fund=false ++export npm_config_update_notifier=false ++ ++if [ ! -d /workspace/repo/node_modules ]; then ++ echo "isolated offline setup error: /workspace/repo/node_modules is missing" >&2 ++ exit 1 ++fi ++ ++if [ ! -x /workspace/repo/node_modules/.bin/tape ]; then ++ echo "isolated offline setup error: local tape binary is missing" >&2 ++ exit 1 ++fi ++ ++exec node /workspace/repo/usercase-test-coderl/run_client_announce_lifecycle.cjs diff --git a/tasks/format-code-task-002990/tests/test.sh b/tasks/format-code-task-002990/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..6280fe7613aa3755d6c2e5099eb4873ca0448892 --- /dev/null +++ b/tasks/format-code-task-002990/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/client_announce_lifecycle.test.js +usercase-test-coderl/run_client_announce_lifecycle.cjs +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002990/tests/test_command.sh b/tasks/format-code-task-002990/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002990/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002997/environment/Dockerfile b/tasks/format-code-task-002997/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..30f5149b0ef513403e1d5840052273eb211a4407 --- /dev/null +++ b/tasks/format-code-task-002997/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:c6b58fbdccf21d7e7a1dd2ba98f0ad541795fadf91e13bf2b6dfd572746831ca diff --git a/tasks/format-code-task-002997/environment/setup/files/blocklist b/tasks/format-code-task-002997/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002997/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002997/environment/setup/setup.sh b/tasks/format-code-task-002997/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002997/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002997/tests/test.patch b/tasks/format-code-task-002997/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..3513086aa33fb89a33e0f164f91bfd898959147d --- /dev/null +++ b/tasks/format-code-task-002997/tests/test.patch @@ -0,0 +1,560 @@ +diff --git a/usercase-test-coderl/usecase.sh b/usercase-test-coderl/usecase.sh +new file mode 100755 +--- /dev/null ++++ b/usercase-test-coderl/usecase.sh +@@ -0,0 +1,529 @@ ++#!/usr/bin/env bash ++ ++set -u ++export LANG=C LC_ALL=C TZ=UTC ++ ++fail() { echo "FAIL: $*" >&2; exit 1; } ++ ++BUILD_DIR="${TMPDIR:-/tmp}/werf-usecase-coderl-build" ++mkdir -p "$BUILD_DIR" || fail "create build dir" ++ ++has_go_files() { ++ local dir="$1" ++ [ -d "$dir" ] && find "$dir" -maxdepth 1 -name '*.go' -print -quit | grep -q . ++} ++ ++ensure_compile_stubs() { ++ ++ if ! has_go_files cmd/werf/build; then ++ mkdir -p cmd/werf/build || fail "create build command stub dir" ++ cat > cmd/werf/build/build_coderl_stub.go <<'EOF' ++package build ++ ++import ( ++ "context" ++ ++ "github.com/spf13/cobra" ++) ++ ++func NewCmd(ctx context.Context) *cobra.Command { ++ return &cobra.Command{Use: "build", Hidden: true} ++} ++EOF ++ fi ++ ++ if ! has_go_files cmd/werf/chart/ts/build; then ++ mkdir -p cmd/werf/chart/ts/build || fail "create chart ts build command stub dir" ++ cat > cmd/werf/chart/ts/build/build_coderl_stub.go <<'EOF' ++package build ++ ++import ( ++ "context" ++ ++ "github.com/spf13/cobra" ++) ++ ++func NewCmd(ctx context.Context) *cobra.Command { ++ return &cobra.Command{Use: "build", Hidden: true} ++} ++EOF ++ fi ++ ++ if ! has_go_files pkg/build/stage; then ++ mkdir -p pkg/build/stage || fail "create build stage stub dir" ++ cat > pkg/build/stage/stage_coderl_stub.go <<'EOF' ++package stage ++ ++import ( ++ "context" ++ ++ "github.com/werf/werf/v2/pkg/container_backend" ++ "github.com/werf/werf/v2/pkg/image" ++) ++ ++var AllStages = []string{} ++ ++type VirtualMergeOptions struct { ++ VirtualMerge bool ++} ++ ++type StageImage struct { ++ Image container_backend.LegacyImageInterface ++} ++ ++type Conveyor interface{} ++ ++type Interface interface { ++ GetStageID() image.StageID ++ GetDependencies() ([]image.StageID, error) ++ IsEmpty(context.Context) (bool, error) ++ IsEqual(image.StageID) bool ++ LogDetailedName() string ++ GetStageImage() *StageImage ++ Name() string ++ GetDigest() string ++ SelectSuitableStageDesc(context.Context, Conveyor, image.StageDescSet) (*image.StageDesc, error) ++} ++EOF ++ fi ++ ++ if ! has_go_files pkg/build; then ++ mkdir -p pkg/build || fail "create build stub dir" ++ cat > pkg/build/build_coderl_stub.go <<'EOF' ++package build ++ ++import ( ++ "context" ++ ++ v1 "github.com/google/go-containerregistry/pkg/v1" ++ ++ "github.com/werf/werf/v2/pkg/config" ++ "github.com/werf/werf/v2/pkg/container_backend" ++ "github.com/werf/werf/v2/pkg/giterminism_manager" ++ "github.com/werf/werf/v2/pkg/image" ++ "github.com/werf/werf/v2/pkg/storage/manager" ++) ++ ++type ReportFormat string ++ ++const ( ++ ReportJSON ReportFormat = "json" ++ ReportEnvFile ReportFormat = "env" ++) ++ ++type ConveyorOptions struct { ++ LocalGitRepoVirtualMergeOptions interface{} ++ ImagesToProcess config.ImagesToProcess ++ TargetPlatforms []string ++ DeferBuildLog bool ++ SkipImageSpecStage bool ++ UseBuildReport bool ++ BuildReportPath string ++ Parallel bool ++ ParallelTasksLimit int64 ++} ++ ++type ShouldBeBuiltOptions struct { ++ SkipAddManagedImagesRecords bool ++ SkipImageMetadataPublication bool ++ CustomTagFuncList []image.CustomTagFunc ++ ReportPath string ++ ReportFormat ReportFormat ++} ++ ++type IntrospectTarget struct { ++ ImageName string ++ StageName string ++} ++ ++type IntrospectOptions struct { ++ Targets []IntrospectTarget ++} ++ ++type BuildOptions struct { ++ SkipAddManagedImagesRecords bool ++ SkipImageMetadataPublication bool ++ CustomTagFuncList []image.CustomTagFunc ++ ImageBuildOptions container_backend.BuildOptions ++ IntrospectOptions IntrospectOptions ++ ReportPath string ++ ReportFormat ReportFormat ++ Targets []string ++} ++ ++type ExportOptions struct { ++ ExportImageNameList []string ++ ExportTagFuncList []image.ExportTagFunc ++ MutateConfigFunc func(v1.Config) (v1.Config, error) ++} ++ ++type ExportedImage struct { ++ TargetPlatform string ++ Name string ++} ++ ++type Conveyor struct { ++ UseBuildReport bool ++ BuildReportPath string ++} ++ ++func (c *Conveyor) ShouldBeBuilt(ctx context.Context, opts ShouldBeBuiltOptions) (bool, error) { ++ return false, nil ++} ++ ++func (c *Conveyor) Build(ctx context.Context, opts BuildOptions) (bool, error) { ++ return false, nil ++} ++ ++func (c *Conveyor) ExportFromReport(ctx context.Context, opts ExportOptions) error { ++ return nil ++} ++ ++func (c *Conveyor) Export(ctx context.Context, opts ExportOptions) error { ++ return nil ++} ++ ++func (c *Conveyor) GetImagesEnvArrayFromReport(ctx context.Context) ([]string, error) { ++ return nil, nil ++} ++ ++func (c *Conveyor) GetImagesEnvArray() []string { ++ return nil ++} ++ ++func (c *Conveyor) GetExportedImages() []ExportedImage { ++ return nil ++} ++ ++func (c *Conveyor) FetchLastImageStage(ctx context.Context, targetPlatform, imageName string) error { ++ return nil ++} ++ ++func (c *Conveyor) ResolveTargetPlatforms(imageName string) ([]string, error) { ++ return []string{""}, nil ++} ++ ++func (c *Conveyor) GetImageNameForLastImageStage(targetPlatform, imageName string) string { ++ return imageName ++} ++ ++func (c *Conveyor) GetImageInfoGettersFromReport(ctx context.Context, opts image.InfoGetterOptions) ([]*image.InfoGetter, error) { ++ return nil, nil ++} ++ ++func (c *Conveyor) GetImageInfoGetters(opts image.InfoGetterOptions) ([]*image.InfoGetter, error) { ++ return nil, nil ++} ++ ++func (c *Conveyor) GetFullImageNameFromReport(ctx context.Context, imageName string) (string, error) { ++ return imageName, nil ++} ++ ++func (c *Conveyor) GetFullImageName(imageName string) (string, error) { ++ return imageName, nil ++} ++ ++type ConveyorWithRetryWrapper struct{} ++ ++func NewConveyorWithRetryWrapper(werfConfig *config.WerfConfig, giterminismManager giterminism_manager.Interface, projectDir, projectTmpDir string, containerBackend container_backend.ContainerBackend, storageManager *manager.StorageManager, lockManager interface{}, opts ConveyorOptions) *ConveyorWithRetryWrapper { ++ return &ConveyorWithRetryWrapper{} ++} ++ ++func (w *ConveyorWithRetryWrapper) Terminate() {} ++ ++func (w *ConveyorWithRetryWrapper) WithRetryBlock(ctx context.Context, fn func(*Conveyor) error) error { ++ return fn(&Conveyor{}) ++} ++ ++func GenerateImageEnv(imageName, image string) string { ++ return imageName + "=" + image ++} ++EOF ++ fi ++ ++ if ! has_go_files pkg/build/stages; then ++ mkdir -p pkg/build/stages || fail "create build stages stub dir" ++ cat > pkg/build/stages/stages_coderl_stub.go <<'EOF' ++package stages ++ ++import ( ++ "context" ++ "sync" ++ ++ "github.com/werf/werf/v2/pkg/build" ++ "github.com/werf/werf/v2/pkg/docker_registry" ++ "github.com/werf/werf/v2/pkg/image" ++ "github.com/werf/werf/v2/pkg/ref" ++ "github.com/werf/werf/v2/pkg/storage/manager" ++) ++ ++var Mux sync.Mutex ++var StageIDs []image.StageID ++ ++type CopyOptions struct { ++ All bool ++ ProjectName string ++ RegistryClient docker_registry.Interface ++ StorageManager *manager.StorageManager ++ ConveyorWithRetry *build.ConveyorWithRetryWrapper ++ BuildOptions build.BuildOptions ++} ++ ++func Copy(ctx context.Context, from, to *ref.Addr, opts CopyOptions) error { ++ return nil ++} ++EOF ++ fi ++} ++ ++ensure_compile_stubs ++( cd /workspace/repo && go build -tags "dfrunsecurity dfrunnetwork dfrunmount dfssh containers_image_openpgp osusergo exclude_graphdriver_devicemapper netgo no_devmapper static_build cni" -o "$BUILD_DIR/werf" ./cmd/werf ) \ ++ || fail "build" ++BIN="$BUILD_DIR/werf" ++ ++TMP=$(mktemp -d) ++trap 'rm -rf "$TMP"' EXIT ++ ++canonical_graph_file() { ++ python3 - "$1" <<'PY' ++import json ++import sys ++ ++path = sys.argv[1] ++text = open(path, encoding="utf-8").read() ++stripped = text.strip() ++if stripped in ("", "[]"): ++ print("[]") ++ raise SystemExit(0) ++ ++entries = [] ++cur = None ++in_import = False ++ ++def finish(): ++ if cur is not None: ++ entries.append(cur) ++ ++for raw in text.splitlines(): ++ line = raw.rstrip() ++ if not line: ++ continue ++ if line.startswith("- image:"): ++ finish() ++ image = line[len("- image:"):].strip() ++ if not image: ++ raise SystemExit(f"{path}: empty image name") ++ cur = {"image": image} ++ in_import = False ++ elif cur is None: ++ raise SystemExit(f"{path}: graph output must start with an image entry, got {line!r}") ++ elif line == " dependsOn:": ++ cur.setdefault("dependsOn", {}) ++ in_import = False ++ elif line.startswith(" from:"): ++ cur.setdefault("dependsOn", {})["from"] = line[len(" from:"):].strip() ++ in_import = False ++ elif line == " import:": ++ cur.setdefault("dependsOn", {})["import"] = [] ++ in_import = True ++ elif in_import and line.startswith(" - "): ++ cur.setdefault("dependsOn", {}).setdefault("import", []).append(line[len(" - "):].strip()) ++ else: ++ raise SystemExit(f"{path}: unexpected graph line {line!r}") ++ ++finish() ++print(json.dumps(sorted(entries, key=lambda item: item["image"]), sort_keys=True, separators=(",", ":"))) ++PY ++} ++ ++assert_graph_set() { ++ local actual_file="$1" ++ local expected_file="$2" ++ local label="$3" ++ local actual expected ++ ++ actual="$(canonical_graph_file "$actual_file")" ++ expected="$(canonical_graph_file "$expected_file")" ++ [ "$actual" = "$expected" ] || fail "$label: got canonical graph [$actual], want [$expected]" ++} ++ ++make_project_all_final() { ++ local dir="$1" ++ mkdir -p "$dir" || fail "create project" ++ ( ++ cd "$dir" || exit 1 ++ git init -q ++ git config user.email test@example.com ++ git config user.name Test ++ cat > werf.yaml <<'EOF' ++project: graph-test ++configVersion: 1 ++--- ++image: app1 ++fromImage: baseImage ++--- ++image: app2 ++fromImage: baseImage ++import: ++- image: app1 ++ add: /app1 ++ to: /app1 ++ after: install ++--- ++image: baseImage ++from: alpine:3.20 ++EOF ++ git add werf.yaml ++ git commit -q -m init ++ ) || fail "initialize all-final project" ++} ++ ++make_project_with_intermediate_base() { ++ local dir="$1" ++ mkdir -p "$dir" || fail "create project" ++ ( ++ cd "$dir" || exit 1 ++ git init -q ++ git config user.email test@example.com ++ git config user.name Test ++ cat > werf.yaml <<'EOF' ++project: graph-test ++configVersion: 1 ++--- ++image: app1 ++fromImage: baseImage ++--- ++image: app2 ++fromImage: baseImage ++import: ++- image: app1 ++ add: /app1 ++ to: /app1 ++ after: install ++--- ++image: baseImage ++final: false ++from: alpine:3.20 ++EOF ++ git add werf.yaml ++ git commit -q -m init ++ ) || fail "initialize intermediate-base project" ++} ++ ++run_graph() { ++ local project_dir="$1" ++ shift ++ mkdir -p "$TMP/werf-home" "$TMP/werf-tmp" || fail "create werf runtime dirs" ++ "$BIN" \ ++ --dir "$project_dir" \ ++ --home-dir "$TMP/werf-home" \ ++ --tmp-dir "$TMP/werf-tmp" \ ++ --log-color-mode=off \ ++ config graph "$@" ++} ++ ++PROJECT_ALL_FINAL="$TMP/project-all-final" ++PROJECT_INTERMEDIATE="$TMP/project-intermediate" ++make_project_all_final "$PROJECT_ALL_FINAL" ++make_project_with_intermediate_base "$PROJECT_INTERMEDIATE" ++ ++ ++ ++ ++"$BIN" config graph --help >"$TMP/help.out" 2>"$TMP/help.err"; ec=$? ++[ "$ec" -eq 0 ] || fail "F_help exit $ec; want 0" ++ ++tr '[:upper:]' '[:lower:]' <"$TMP/help.out" >"$TMP/help.lower" ++grep -Eq "dependency graph.*werf\\.yaml|werf\\.yaml.*dependency graph" "$TMP/help.lower" || fail "F_help missing dependency graph description for werf.yaml" ++grep -Fxq " werf config graph [IMAGE_NAME...] [options]" "$TMP/help.out" || fail "F_help missing usage syntax" ++ ++[ ! -s "$TMP/help.err" ] || fail "F_help unexpected stderr: $(cat "$TMP/help.err")" ++ ++ ++ ++ ++run_graph "$PROJECT_ALL_FINAL" >"$TMP/all.out" 2>"$TMP/all.err"; ec=$? ++cat >"$TMP/all.expected" <<'EOF' ++- image: app1 ++ dependsOn: ++ from: baseImage ++- image: app2 ++ dependsOn: ++ from: baseImage ++ import: ++ - app1 ++- image: baseImage ++EOF ++[ "$ec" -eq 0 ] || fail "F_all exit $ec; want 0" ++assert_graph_set "$TMP/all.out" "$TMP/all.expected" "F_all stdout" ++[ ! -s "$TMP/all.err" ] || fail "F_all unexpected stderr: $(cat "$TMP/all.err")" ++ ++ ++ ++ ++run_graph "$PROJECT_ALL_FINAL" app2 >"$TMP/app2.out" 2>"$TMP/app2.err"; ec=$? ++APP2_EXPECTED='- image: app2 ++ dependsOn: ++ from: baseImage ++ import: ++ - app1' ++[ "$ec" -eq 0 ] || fail "F_one exit $ec; want 0" ++printf '%s\n' "$APP2_EXPECTED" >"$TMP/app2.expected" ++assert_graph_set "$TMP/app2.out" "$TMP/app2.expected" "F_one stdout" ++[ ! -s "$TMP/app2.err" ] || fail "F_one unexpected stderr: $(cat "$TMP/app2.err")" ++ ++ ++ ++ ++run_graph "$PROJECT_ALL_FINAL" app2 baseImage >"$TMP/many.out" 2>"$TMP/many.err"; ec=$? ++cat >"$TMP/many.expected" <<'EOF' ++- image: app2 ++ dependsOn: ++ from: baseImage ++ import: ++ - app1 ++- image: baseImage ++EOF ++[ "$ec" -eq 0 ] || fail "F_many exit $ec; want 0" ++assert_graph_set "$TMP/many.out" "$TMP/many.expected" "F_many stdout" ++[ ! -s "$TMP/many.err" ] || fail "F_many unexpected stderr: $(cat "$TMP/many.err")" ++ ++ ++ ++ ++run_graph "$PROJECT_INTERMEDIATE" --final-images-only >"$TMP/final.out" 2>"$TMP/final.err"; ec=$? ++cat >"$TMP/final.expected" <<'EOF' ++- image: app1 ++ dependsOn: ++ from: baseImage ++- image: app2 ++ dependsOn: ++ from: baseImage ++ import: ++ - app1 ++EOF ++[ "$ec" -eq 0 ] || fail "F_final exit $ec; want 0" ++assert_graph_set "$TMP/final.out" "$TMP/final.expected" "F_final stdout" ++[ ! -s "$TMP/final.err" ] || fail "F_final unexpected stderr: $(cat "$TMP/final.err")" ++ ++ ++ ++ ++run_graph "$PROJECT_INTERMEDIATE" baseImage --final-images-only >"$TMP/final-empty.out" 2>"$TMP/final-empty.err"; ec=$? ++[ "$ec" -eq 0 ] || fail "F_final_empty exit $ec; want 0" ++ ++[ "$(canonical_graph_file "$TMP/final-empty.out")" = "[]" ] || fail "F_final_empty stdout: $(cat "$TMP/final-empty.out")" ++[ ! -s "$TMP/final-empty.err" ] || fail "F_final_empty unexpected stderr: $(cat "$TMP/final-empty.err")" ++ ++ ++ ++ ++run_graph "$PROJECT_ALL_FINAL" missing-image >"$TMP/missing.out" 2>"$TMP/missing.err"; ec=$? ++[ "$ec" -ne 0 ] || fail "F_missing exit 0; want non-zero" ++[ ! -s "$TMP/missing.out" ] || fail "F_missing unexpected stdout: $(cat "$TMP/missing.out")" ++ ++[ -s "$TMP/missing.err" ] || fail "F_missing expected selection error on stderr" ++grep -Fq "missing-image" "$TMP/missing.err" || fail "F_missing stderr should mention selector: $(cat "$TMP/missing.err")" ++ ++echo "PASS" ++exit 0 +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,21 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++ ++export GOTOOLCHAIN=local ++export GOPROXY=off ++export GOSUMDB=off ++export GOVCS='*:off' ++export GOFLAGS="-mod=readonly" ++export GOTELEMETRY=off ++export WERF_TELEMETRY=0 ++export WERF_ALLOW_INCLUDES_UPDATE=0 ++set -e ++cd /workspace/repo ++exec bash /workspace/repo/usercase-test-coderl/usecase.sh diff --git a/tasks/format-code-task-002997/tests/test.sh b/tasks/format-code-task-002997/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d4d80bb634b14076ae561be99f395189577b7ac6 --- /dev/null +++ b/tasks/format-code-task-002997/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/usecase.sh +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002997/tests/test_command.sh b/tasks/format-code-task-002997/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002997/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002999/environment/Dockerfile b/tasks/format-code-task-002999/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..3d10a16a754f2459daf1ff10a2e8f777dc440531 --- /dev/null +++ b/tasks/format-code-task-002999/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:8d0281287dbefbbd9c8987a838a1d21d6804af2725edc6f2e42283638b72a349 diff --git a/tasks/format-code-task-002999/environment/setup/files/blocklist b/tasks/format-code-task-002999/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002999/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002999/environment/setup/setup.sh b/tasks/format-code-task-002999/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002999/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002999/tests/test.patch b/tasks/format-code-task-002999/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e5288a3a426135295740401de3e03c3f6d53369e --- /dev/null +++ b/tasks/format-code-task-002999/tests/test.patch @@ -0,0 +1,180 @@ +diff --git a/test/new-unit/pgp-keyparams-test.js b/test/new-unit/pgp-keyparams-test.js +new file mode 100644 +index 0000000..76daff6 +--- /dev/null ++++ b/test/new-unit/pgp-keyparams-test.js +@@ -0,0 +1,116 @@ ++define(function(require) { ++ 'use strict'; ++ ++ var PGP = require('js/crypto/pgp'), ++ expect = chai.expect; ++ ++ describe('PGP key params unit tests', function() { ++ var pgp, ++ passphrase = 'asdf', ++ keyId = 'F6F60E9B42CDFF4C', ++ fingerprint = '5856CEF789C3A307E8A1B976F6F60E9B42CDFF4C', ++ emailAddress = 'whiteout.test@t-online.de', ++ userName = 'Whiteout User', ++ bitSize = 512, ++ pubkey = '-----BEGIN PGP PUBLIC KEY BLOCK-----\r\n' + ++ 'Version: OpenPGP.js v0.3.0\r\n' + ++ 'Comment: http://openpgpjs.org\r\n' + ++ '\r\n' + ++ 'xk0EUlhMvAEB/2MZtCUOAYvyLFjDp3OBMGn3Ev8FwjzyPbIF0JUw+L7y2XR5\r\n' + ++ 'RVGvbK88unV3cU/1tOYdNsXI6pSp/Ztjyv7vbBUAEQEAAc0pV2hpdGVvdXQg\r\n' + ++ 'VXNlciA8d2hpdGVvdXQudGVzdEB0LW9ubGluZS5kZT7CXAQQAQgAEAUCUlhM\r\n' + ++ 'vQkQ9vYOm0LN/0wAAAW4Af9C+kYW1AvNWmivdtr0M0iYCUjM9DNOQH1fcvXq\r\n' + ++ 'IiN602mWrkd8jcEzLsW5IUNzVPLhrFIuKyBDTpLnC07Loce1\r\n' + ++ '=6XMW\r\n' + ++ '-----END PGP PUBLIC KEY BLOCK-----\r\n\r\n', ++ privkey = '-----BEGIN PGP PRIVATE KEY BLOCK-----\r\n' + ++ 'Version: OpenPGP.js v0.3.0\r\n' + ++ 'Comment: http://openpgpjs.org\r\n' + ++ '\r\n' + ++ 'xcBeBFJYTLwBAf9jGbQlDgGL8ixYw6dzgTBp9xL/BcI88j2yBdCVMPi+8tl0\r\n' + ++ 'eUVRr2yvPLp1d3FP9bTmHTbFyOqUqf2bY8r+72wVABEBAAH+AwMIhNB4ivtv\r\n' + ++ 'Y2xg6VeMcjjHxZayESHACV+nQx5Tx6ev6xzIF1Qh72fNPDppLhFSFOuTTMsU\r\n' + ++ 'kTN4c+BVYt29spH+cA1jcDAxQ2ULrNAXo+hheOqhpedTs8aCbcLFkJAS16hk\r\n' + ++ 'YSk4OnJgp/z24rVju1SHRSFbgundPzmNgXeX9e8IkviGhhQ11Wc5YwVkx03t\r\n' + ++ 'Z3MdDMF0jyhopbPIoBdyJB0dhvBh98w3JmwpYh9wjUA9MBHD1tvHpRmSZ3BM\r\n' + ++ 'UCmATn2ZLWBRWiYqFbgDnL1GM80pV2hpdGVvdXQgVXNlciA8d2hpdGVvdXQu\r\n' + ++ 'dGVzdEB0LW9ubGluZS5kZT7CXAQQAQgAEAUCUlhMvQkQ9vYOm0LN/0wAAAW4\r\n' + ++ 'Af9C+kYW1AvNWmivdtr0M0iYCUjM9DNOQH1fcvXqIiN602mWrkd8jcEzLsW5\r\n' + ++ 'IUNzVPLhrFIuKyBDTpLnC07Loce1\r\n' + ++ '=ULta\r\n' + ++ '-----END PGP PRIVATE KEY BLOCK-----\r\n'; ++ ++ beforeEach(function() { ++ pgp = new PGP(); ++ }); ++ ++ afterEach(function() {}); ++ ++ describe('from an armored public key', function() { ++ it('should read the key parameters', function() { ++ var params = pgp.getKeyParams(pubkey); ++ ++ expect(params._id).to.equal(keyId); ++ expect(params.fingerprint).to.equal(fingerprint); ++ expect(params.userId).to.equal(emailAddress); ++ expect(params.bitSize).to.equal(bitSize); ++ expect(params.userIds).to.deep.equal([{ ++ name: userName, ++ emailAddress: emailAddress ++ }]); ++ }); ++ }); ++ ++ describe('from an armored private key', function() { ++ it('should read the same key parameters', function() { ++ var params = pgp.getKeyParams(privkey); ++ ++ expect(params._id).to.equal(keyId); ++ expect(params.fingerprint).to.equal(fingerprint); ++ expect(params.userId).to.equal(emailAddress); ++ expect(params.bitSize).to.equal(bitSize); ++ expect(params.userIds).to.deep.equal([{ ++ name: userName, ++ emailAddress: emailAddress ++ }]); ++ }); ++ }); ++ ++ describe('from the currently imported key', function() { ++ it('should describe the imported key when no argument is given', function(done) { ++ pgp.importKeys({ ++ passphrase: passphrase, ++ privateKeyArmored: privkey, ++ publicKeyArmored: pubkey ++ }, function(err) { ++ expect(err).to.not.exist; ++ ++ var params = pgp.getKeyParams(); ++ expect(params._id).to.equal(keyId); ++ expect(params.fingerprint).to.equal(fingerprint); ++ expect(params.userId).to.equal(emailAddress); ++ expect(params.bitSize).to.equal(bitSize); ++ expect(params.userIds).to.deep.equal([{ ++ name: userName, ++ emailAddress: emailAddress ++ }]); ++ done(); ++ }); ++ }); ++ }); ++ ++ describe('error handling', function() { ++ it('should throw when no key is available', function() { ++ expect(function() { ++ pgp.getKeyParams(); ++ }).to.throw(Error); ++ }); ++ ++ it('should throw on unparseable input', function() { ++ expect(function() { ++ pgp.getKeyParams('this is not a valid armored key'); ++ }).to.throw(Error); ++ }); ++ }); ++ }); ++}); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,53 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++ ++TD=/testbed/.build_env/test_deps/node_modules ++RUNNER="$(mktemp /tmp/mrun.XXXXXX.js)" ++trap 'rm -f "$RUNNER"' EXIT ++cat > "$RUNNER" <<'EOF' ++var TD = '/testbed/.build_env/test_deps/node_modules/'; ++global.requirejs = require(TD + 'requirejs'); ++global.chai = require(TD + 'chai'); ++global.sinon = require(TD + 'sinon'); ++var Mocha = require(TD + 'mocha'); ++var mocha = new Mocha({ ui: 'bdd', reporter: 'spec', timeout: 20000 }); ++mocha.suite.emit('pre-require', global, 'global-mocha', mocha); ++ ++global.requirejs.config({ ++ baseUrl: '/testbed/src/lib', ++ paths: { ++ js: '../js', ++ test: '../../test', ++ cryptoLib: '../js/crypto', ++ underscore: 'underscore/underscore-min', ++ openpgp: 'openpgp/openpgp.min' ++ }, ++ nodeRequire: require ++}); ++ ++var testModule = process.argv[2]; ++global.requirejs([testModule], function() { ++ mocha.run(function(failures) { ++ process.exit(failures ? 1 : 0); ++ }); ++}, function(err) { ++ console.error('LOAD_ERROR', err && err.message); ++ process.exit(2); ++}); ++EOF ++ ++ ++node "$RUNNER" test/new-unit/pgp-test ++ ++ ++node "$RUNNER" test/new-unit/pgp-keyparams-test diff --git a/tasks/format-code-task-002999/tests/test.sh b/tasks/format-code-task-002999/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..07c3fe5260ee224bc545aa3dfd1d714efcd5a982 --- /dev/null +++ b/tasks/format-code-task-002999/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test/new-unit/pgp-keyparams-test.js +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002999/tests/test_command.sh b/tasks/format-code-task-002999/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002999/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-003023/environment/Dockerfile b/tasks/format-code-task-003023/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e309af51a80f57c9f033e2add9605018cb35d474 --- /dev/null +++ b/tasks/format-code-task-003023/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:34fae5164af5e9ac6d91dee1a1507849760d7b12fb3ca227ccbf7d01d03dbe1f diff --git a/tasks/format-code-task-003023/environment/setup/files/blocklist b/tasks/format-code-task-003023/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-003023/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-003023/environment/setup/setup.sh b/tasks/format-code-task-003023/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-003023/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-003023/tests/test.patch b/tasks/format-code-task-003023/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..f6f60f33f18507faf82648174cb419306898c778 --- /dev/null +++ b/tasks/format-code-task-003023/tests/test.patch @@ -0,0 +1,466 @@ +diff --git a/usercase-test-coderl/test_agent_tools.py b/usercase-test-coderl/test_agent_tools.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_agent_tools.py +@@ -0,0 +1,439 @@ ++import copy ++import json ++import os ++import subprocess ++import sys ++import textwrap ++import types ++ ++import pytest ++ ++ ++def _install_import_stubs() -> None: ++ sys.path.insert(0, "/workspace/repo/api") ++ ++ sqlalchemy = types.ModuleType("sqlalchemy") ++ ++ class FakeSelect: ++ def __init__(self, *columns): ++ self.columns = columns ++ self.conditions = [] ++ ++ def where(self, *args, **kwargs): ++ self.conditions.extend(args) ++ return self ++ ++ sqlalchemy.select = lambda *args, **kwargs: FakeSelect(*args) ++ sys.modules["sqlalchemy"] = sqlalchemy ++ ++ common = types.ModuleType("common") ++ context = types.ModuleType("common.context") ++ ++ class FakeRequestContext: ++ @staticmethod ++ def get_effective_tenant_id(): ++ return "tenant-from-context" ++ ++ context.RequestContext = FakeRequestContext ++ sys.modules["common"] = common ++ sys.modules["common.context"] = context ++ ++ rag_do = types.ModuleType("module_rag.entity.do.rag_do") ++ ++ class FakeColumn: ++ def __init__(self, name): ++ self.name = name ++ ++ def __eq__(self, other): ++ return ("eq", self.name, other) ++ ++ class FakeRagDataset: ++ id = FakeColumn("id") ++ source_id = FakeColumn("source_id") ++ ++ rag_do.RagDataset = FakeRagDataset ++ sys.modules.setdefault("module_rag.entity", types.ModuleType("module_rag.entity")) ++ sys.modules.setdefault("module_rag.entity.do", types.ModuleType("module_rag.entity.do")) ++ sys.modules["module_rag.entity.do.rag_do"] = rag_do ++ ++ retrieval = types.ModuleType("module_rag.retrieval") ++ retrieval.retrieve = lambda *args, **kwargs: (_ for _ in ()).throw(AssertionError("retrieve not patched")) ++ sys.modules["module_rag.retrieval"] = retrieval ++ ++ sync_db = types.ModuleType("module_task_schedule.sync_db") ++ sync_db.get_sync_session_local = lambda: (_ for _ in ()).throw(AssertionError("db not patched")) ++ sys.modules.setdefault("module_task_schedule", types.ModuleType("module_task_schedule")) ++ sys.modules["module_task_schedule.sync_db"] = sync_db ++ ++ ++_install_import_stubs() ++from module_rag import agent_tools ++ ++ ++def _patch_source_lookup(monkeypatch, source_map=None): ++ source_map = source_map or {} ++ ++ class FakeScalarResult: ++ def __init__(self, rows): ++ self._rows = rows ++ ++ def all(self): ++ return list(self._rows) ++ ++ class FakeExecuteResult: ++ def __init__(self, rows): ++ self._rows = rows ++ ++ def scalars(self): ++ return FakeScalarResult(self._rows) ++ ++ class FakeSession: ++ def execute(self, statement): ++ source_id = None ++ for condition in getattr(statement, "conditions", []): ++ if isinstance(condition, tuple) and condition[:2] == ("eq", "source_id"): ++ source_id = condition[2] ++ return FakeExecuteResult(source_map.get(source_id, [])) ++ ++ def close(self): ++ pass ++ ++ def fake_get_sync_session_local(): ++ return lambda: FakeSession() ++ ++ ++ monkeypatch.setattr(agent_tools, "get_sync_session_local", fake_get_sync_session_local, raising=False) ++ monkeypatch.setattr(sys.modules["module_task_schedule.sync_db"], "get_sync_session_local", fake_get_sync_session_local) ++ ++ ++def _patch_retrieve(monkeypatch, responses): ++ calls = [] ++ ++ def fake_retrieve(tenant_id, query, dataset_ids, *, k=5, retrieval_type="hybrid", rerank=False, **kwargs): ++ calls.append( ++ { ++ "tenant_id": tenant_id, ++ "query": query, ++ "dataset_ids": list(dataset_ids), ++ "k": k, ++ "retrieval_type": retrieval_type, ++ "rerank": rerank, ++ } ++ ) ++ return copy.deepcopy(responses[query]) ++ ++ ++ monkeypatch.setattr(sys.modules["module_rag.retrieval"], "retrieve", fake_retrieve) ++ monkeypatch.setattr(agent_tools, "retrieve", fake_retrieve, raising=False) ++ return calls ++ ++ ++def test_returns_exact_message_when_no_datasets_are_available(monkeypatch): ++ ++ ++ ++ ++ _patch_source_lookup(monkeypatch) ++ ++ actual = agent_tools.search_knowledge_base("anything") ++ ++ assert actual == "未找到可用知识库。" ++ ++ ++def test_source_id_with_no_attached_datasets_returns_no_available_message(monkeypatch): ++ ++ ++ ++ ++ _patch_source_lookup(monkeypatch, {"empty-src": []}) ++ ++ actual = agent_tools.search_knowledge_base("anything", source_id="empty-src", tenant_id=7) ++ ++ assert actual == "未找到可用知识库。" ++ ++ ++def test_returns_exact_message_when_retrieval_has_no_records(monkeypatch): ++ ++ ++ ++ ++ _patch_source_lookup(monkeypatch) ++ _patch_retrieve(monkeypatch, {"empty retrieval": {"total": 0, "records": []}}) ++ ++ actual = agent_tools.search_knowledge_base("empty retrieval", dataset_ids=["kb-empty"], tenant_id=7) ++ ++ assert actual == "知识库中未检索到相关内容。" ++ ++ ++def test_formats_ranked_qa_and_chunk_records_with_trimmed_content(monkeypatch): ++ ++ ++ ++ ++ _patch_source_lookup(monkeypatch) ++ _patch_retrieve( ++ monkeypatch, ++ { ++ "format records": { ++ "total": 2, ++ "records": [ ++ {"content": " 年假为 10 天 ", "chunk_type": "qa"}, ++ {"content": "\n订单表包含金额字段\t", "chunk_type": "chunk"}, ++ ], ++ } ++ }, ++ ) ++ ++ actual = agent_tools.search_knowledge_base("format records", dataset_ids=["kb1"], tenant_id=7) ++ ++ assert actual == "[1] (QA) 年假为 10 天\n\n[2] (片段) 订单表包含金额字段" ++ ++ ++def test_combines_source_and_explicit_datasets_dedupes_and_forwards_options(monkeypatch): ++ ++ ++ ++ ++ _patch_source_lookup(monkeypatch, {"src-a": ["kb2", "kb3"]}) ++ calls = _patch_retrieve( ++ monkeypatch, ++ { ++ "format records": { ++ "records": [ ++ {"content": "年假为 10 天", "chunk_type": "qa"}, ++ {"content": "订单表包含金额字段", "chunk_type": "chunk"}, ++ ] ++ } ++ }, ++ ) ++ ++ actual = agent_tools.search_knowledge_base( ++ "format records", ++ source_id="src-a", ++ dataset_ids=["kb1", "kb2", "kb1"], ++ tenant_id=7, ++ top_k=9, ++ retrieval_type="keyword", ++ rerank=True, ++ ) ++ ++ assert actual == "[1] (QA) 年假为 10 天\n\n[2] (片段) 订单表包含金额字段" ++ assert calls == [ ++ { ++ "tenant_id": 7, ++ "query": "format records", ++ "dataset_ids": ["kb1", "kb2", "kb3"], ++ "k": 9, ++ "retrieval_type": "keyword", ++ "rerank": True, ++ } ++ ] ++ ++ ++def test_omitted_tenant_uses_current_effective_tenant_and_default_options(monkeypatch): ++ ++ ++ ++ ++ _patch_source_lookup(monkeypatch) ++ calls = _patch_retrieve( ++ monkeypatch, ++ {"tenant query": {"records": [{"content": "向量结果", "chunk_type": "chunk"}]}}, ++ ) ++ ++ actual = agent_tools.search_knowledge_base("tenant query", dataset_ids=["kb-v"]) ++ ++ assert actual == "[1] (片段) 向量结果" ++ assert calls == [ ++ { ++ "tenant_id": "tenant-from-context", ++ "query": "tenant query", ++ "dataset_ids": ["kb-v"], ++ "k": 5, ++ "retrieval_type": "hybrid", ++ "rerank": False, ++ } ++ ] ++ ++ ++def test_vector_mode_is_forwarded_to_retrieval_backend(monkeypatch): ++ ++ ++ ++ ++ _patch_source_lookup(monkeypatch) ++ calls = _patch_retrieve( ++ monkeypatch, ++ {"vector query": {"records": [{"content": "向量结果", "chunk_type": "chunk"}]}}, ++ ) ++ ++ actual = agent_tools.search_knowledge_base("vector query", dataset_ids=["kb-v"], tenant_id=8, retrieval_type="vector") ++ ++ assert actual == "[1] (片段) 向量结果" ++ assert calls == [ ++ { ++ "tenant_id": 8, ++ "query": "vector query", ++ "dataset_ids": ["kb-v"], ++ "k": 5, ++ "retrieval_type": "vector", ++ "rerank": False, ++ } ++ ] ++ ++ ++def test_make_kb_tool_delegates_with_fixed_scope_and_top_k(monkeypatch): ++ ++ ++ ++ ++ _patch_source_lookup(monkeypatch) ++ calls = _patch_retrieve( ++ monkeypatch, ++ {"orders 表有哪些字段": {"records": [{"content": "工具闭包结果", "chunk_type": "chunk"}]}}, ++ ) ++ tool = agent_tools.make_kb_tool(dataset_ids=["kb1"], tenant_id=7, top_k=3) ++ ++ actual = tool("orders 表有哪些字段") ++ ++ assert actual == "[1] (片段) 工具闭包结果" ++ assert calls == [ ++ { ++ "tenant_id": 7, ++ "query": "orders 表有哪些字段", ++ "dataset_ids": ["kb1"], ++ "k": 3, ++ "retrieval_type": "hybrid", ++ "rerank": False, ++ } ++ ] ++ ++ ++def test_make_kb_tool_callable_rejects_extra_arguments(monkeypatch): ++ ++ ++ ++ ++ _patch_source_lookup(monkeypatch) ++ tool = agent_tools.make_kb_tool(dataset_ids=["kb1"], tenant_id=7, top_k=3) ++ ++ with pytest.raises(TypeError): ++ tool("orders 表有哪些字段", top_k=9) ++ ++ ++def test_referential_transparency_for_same_input(monkeypatch): ++ _patch_source_lookup(monkeypatch) ++ _patch_retrieve( ++ monkeypatch, ++ {"stable query": {"records": [{"content": "状态稳定", "chunk_type": "qa"}]}}, ++ ) ++ ++ first = agent_tools.search_knowledge_base("stable query", dataset_ids=["kb-state"], tenant_id=9) ++ second = agent_tools.search_knowledge_base("stable query", dataset_ids=["kb-state"], tenant_id=9) ++ ++ assert first == "[1] (QA) 状态稳定" ++ assert second == "[1] (QA) 状态稳定" ++ assert first == second ++ ++ ++def test_dataset_ids_input_list_is_not_mutated(monkeypatch): ++ _patch_source_lookup(monkeypatch, {"src-a": ["kb2", "kb3"]}) ++ _patch_retrieve( ++ monkeypatch, ++ {"mutation query": {"records": [{"content": "列表未变", "chunk_type": "chunk"}]}}, ++ ) ++ dataset_ids = ["kb1", "kb2", "kb1"] ++ before = copy.deepcopy(dataset_ids) ++ ++ actual = agent_tools.search_knowledge_base("mutation query", source_id="src-a", dataset_ids=dataset_ids, tenant_id=7) ++ ++ assert actual == "[1] (片段) 列表未变" ++ assert dataset_ids == before ++ ++ ++def test_same_input_matches_fresh_python_process(monkeypatch): ++ _patch_source_lookup(monkeypatch) ++ _patch_retrieve( ++ monkeypatch, ++ {"state query": {"records": [{"content": "状态稳定", "chunk_type": "qa"}]}}, ++ ) ++ in_process = agent_tools.search_knowledge_base("state query", dataset_ids=["kb-state"], tenant_id=9) ++ ++ script = r''' ++import copy, json, sys, types ++sys.path.insert(0, "/workspace/repo/api") ++sqlalchemy = types.ModuleType("sqlalchemy") ++class FakeSelect: ++ def where(self, *args, **kwargs): ++ return self ++sqlalchemy.select = lambda *args, **kwargs: FakeSelect() ++sys.modules["sqlalchemy"] = sqlalchemy ++common = types.ModuleType("common") ++context = types.ModuleType("common.context") ++class FakeRequestContext: ++ @staticmethod ++ def get_effective_tenant_id(): ++ return "tenant-from-context" ++context.RequestContext = FakeRequestContext ++sys.modules["common"] = common ++sys.modules["common.context"] = context ++rag_do = types.ModuleType("module_rag.entity.do.rag_do") ++class FakeColumn: ++ def __eq__(self, other): ++ return ("eq", other) ++class FakeRagDataset: ++ id = FakeColumn() ++ source_id = FakeColumn() ++rag_do.RagDataset = FakeRagDataset ++sys.modules.setdefault("module_rag.entity", types.ModuleType("module_rag.entity")) ++sys.modules.setdefault("module_rag.entity.do", types.ModuleType("module_rag.entity.do")) ++sys.modules["module_rag.entity.do.rag_do"] = rag_do ++retrieval = types.ModuleType("module_rag.retrieval") ++retrieval.retrieve = lambda *args, **kwargs: (_ for _ in ()).throw(AssertionError("retrieve not patched")) ++sys.modules["module_rag.retrieval"] = retrieval ++sync_db = types.ModuleType("module_task_schedule.sync_db") ++sync_db.get_sync_session_local = lambda: (_ for _ in ()).throw(AssertionError("db not patched")) ++sys.modules.setdefault("module_task_schedule", types.ModuleType("module_task_schedule")) ++sys.modules["module_task_schedule.sync_db"] = sync_db ++from module_rag import agent_tools ++def fake_retrieve(tenant_id, query, dataset_ids, *, k=5, retrieval_type="hybrid", rerank=False, **kwargs): ++ return {"records": [{"content": "状态稳定", "chunk_type": "qa"}]} ++# ++sys.modules["module_rag.retrieval"].retrieve = fake_retrieve ++agent_tools.retrieve = fake_retrieve ++print(json.dumps(agent_tools.search_knowledge_base("state query", dataset_ids=["kb-state"], tenant_id=9), ensure_ascii=False)) ++''' ++ completed = subprocess.run( ++ [sys.executable, "-c", script], ++ check=True, ++ capture_output=True, ++ text=True, ++ ) ++ fresh_process = json.loads(completed.stdout) ++ ++ assert in_process == "[1] (QA) 状态稳定" ++ assert fresh_process == "[1] (QA) 状态稳定" ++ assert in_process == fresh_process ++ ++ ++def test_search_wrapper_calls_backend_and_formats_response(monkeypatch): ++ _patch_source_lookup(monkeypatch) ++ calls = _patch_retrieve( ++ monkeypatch, ++ {"side effect query": {"records": [{"content": "无副作用", "chunk_type": "chunk"}]}}, ++ ) ++ ++ ++ actual = agent_tools.search_knowledge_base("side effect query", dataset_ids=["kb-side"], tenant_id=7) ++ ++ assert actual == "[1] (片段) 无副作用" ++ assert calls == [ ++ { ++ "tenant_id": 7, ++ "query": "side effect query", ++ "dataset_ids": ["kb-side"], ++ "k": 5, ++ "retrieval_type": "hybrid", ++ "rerank": False, ++ } ++ ] +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,17 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++export PIP_NO_INDEX=1 ++export PIP_DISABLE_PIP_VERSION_CHECK=1 ++exec python -m pytest -p no:cacheprovider /workspace/repo/usercase-test-coderl/test_agent_tools.py -v diff --git a/tasks/format-code-task-003023/tests/test.sh b/tasks/format-code-task-003023/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..b78f0e74ea42fa7c03dee4d9fff3c3b5be2bff05 --- /dev/null +++ b/tasks/format-code-task-003023/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/test_agent_tools.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-003023/tests/test_command.sh b/tasks/format-code-task-003023/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-003023/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-003024/environment/Dockerfile b/tasks/format-code-task-003024/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..1d05e6040c40228cebac4d64f2090bae21035efd --- /dev/null +++ b/tasks/format-code-task-003024/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:42e07319af98fd44aadce3a5ab9c6366c5b85a1c992c7236f992cb8b364887a6 diff --git a/tasks/format-code-task-003024/environment/setup/files/blocklist b/tasks/format-code-task-003024/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-003024/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-003024/environment/setup/setup.sh b/tasks/format-code-task-003024/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-003024/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-003024/tests/test.patch b/tasks/format-code-task-003024/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..04e5beda9c0ae7df1ff0938a8de0dea7b61a1c43 --- /dev/null +++ b/tasks/format-code-task-003024/tests/test.patch @@ -0,0 +1,180 @@ +diff --git a/usercase-test-coderl/runtime_registration.test.js b/usercase-test-coderl/runtime_registration.test.js +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/runtime_registration.test.js +@@ -0,0 +1,133 @@ ++import expect from 'expect'; ++import path from 'path'; ++ ++const srcRoot = path.resolve(__dirname, '..', 'src'); ++ ++function freshPublicApi() { ++ Object.keys(require.cache).forEach((filename) => { ++ if (filename.indexOf(srcRoot) === 0) { ++ delete require.cache[filename]; ++ } ++ }); ++ ++ const mod = require('../src'); ++ return mod.default || mod; ++} ++ ++describe('usercase runtime validator registration', () => { ++ it('adds a named validator factory to the same exported object', () => { ++ ++ ++ const V = freshPublicApi(); ++ ++ ++ expect(typeof V.alwaysValid).toBe('undefined'); ++ ++ const registrationResult = V.register('alwaysValid', () => true); ++ ++ expect(registrationResult).toBe(undefined); ++ ++ expect(typeof V.alwaysValid).toBe('function'); ++ expect(V.alwaysValid()('anything')).toBe(true); ++ }); ++ ++ it('forwards the validated value before factory arguments', () => { ++ ++ ++ const V = freshPublicApi(); ++ ++ expect(V.register('minLength', (value, min, message) => value.length >= min || message || 'too short')).toBe(undefined); ++ expect(typeof V.minLength).toBe('function'); ++ expect(V.minLength(3)('abcd')).toBe(true); ++ expect(V.minLength(3)('ab')).toBe('too short'); ++ expect(V.minLength(3, 'need three')('ab')).toBe('need three'); ++ expect(V.minLength(3, 'need three')('abcd')).toBe(true); ++ }); ++ ++ it('uses the same message wrapper convention as built-in validators', () => { ++ ++ ++ const V = freshPublicApi(); ++ ++ expect(V.register('isFoo', (value, message) => value === 'foo' || message || 'not foo')).toBe(undefined); ++ expect(V.isFoo()('foo')).toBe(true); ++ expect(V.isFoo()('bar')).toBe('not foo'); ++ expect(V.message(V.isFoo(), 'custom failure')('bar')).toBe('custom failure'); ++ }); ++ ++ it('rejects replacing an existing built-in validator by default', () => { ++ ++ ++ const V = freshPublicApi(); ++ let caught; ++ ++ try { ++ V.register('email', () => true); ++ } catch (err) { ++ caught = err; ++ } ++ ++ ++ expect(caught instanceof Error).toBe(true); ++ expect(caught.message.indexOf('Validator with this name already exists!')).toBe(0); ++ ++ expect(V.email()('not-an-email')).toNotBe(true); ++ }); ++ ++ it('intentionally replaces a custom validator when force is true', () => { ++ ++ ++ const V = freshPublicApi(); ++ ++ expect(V.register('customRule', () => true)).toBe(undefined); ++ expect(V.customRule()('x')).toBe(true); ++ expect(V.register('customRule', () => false, true)).toBe(undefined); ++ ++ expect(V.customRule()('x')).toBe(false); ++ }); ++ ++ it('adds registered validators to the same public API object', () => { ++ ++ ++ const V = freshPublicApi(); ++ const sameObject = V; ++ ++ expect(V.register('sameObjectRule', () => true)).toBe(undefined); ++ ++ ++ expect(typeof sameObject.sameObjectRule).toBe('function'); ++ expect(sameObject.sameObjectRule()('x')).toBe(true); ++ }); ++ ++ it('allows repeated forced replacement of the same name', () => { ++ ++ ++ const V = freshPublicApi(); ++ ++ expect(V.register('replaceAgain', () => true)).toBe(undefined); ++ expect(V.replaceAgain()('x')).toBe(true); ++ expect(V.register('replaceAgain', () => false, true)).toBe(undefined); ++ expect(V.replaceAgain()('x')).toBe(false); ++ expect(V.register('replaceAgain', () => true, true)).toBe(undefined); ++ ++ expect(V.replaceAgain()('x')).toBe(true); ++ }); ++ ++ it('keeps using the latest forced replacement across many cycles', () => { ++ ++ ++ const V = freshPublicApi(); ++ ++ ++ expect(V.register('boundedRule', () => true)).toBe(undefined); ++ expect(V.boundedRule()('x')).toBe(true); ++ ++ for (let i = 0; i < 150; i += 1) { ++ V.register('boundedRule', () => i === 149, true); ++ V.boundedRule()('x'); ++ } ++ ++ ++ expect(V.boundedRule()('x')).toBe(true); ++ }); ++}); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,37 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++ ++if [ ! -x ./node_modules/.bin/mocha ]; then ++ echo "Missing local mocha binary at ./node_modules/.bin/mocha; dependencies must be preinstalled in the image." >&2 ++ exit 1 ++fi ++ ++node - <<'NODE' ++const required = [ ++ 'babel-register', ++ 'expect', ++ 'babel-plugin-transform-es2015-modules-commonjs', ++ 'babel-plugin-transform-object-rest-spread' ++]; ++ ++for (const name of required) { ++ require.resolve(name); ++} ++NODE ++ ++exec env BABEL_ENV=commonjs ./node_modules/.bin/mocha \ ++ --compilers js:babel-register \ ++ /workspace/repo/usercase-test-coderl/runtime_registration.test.js \ ++ --reporter spec diff --git a/tasks/format-code-task-003024/tests/test.sh b/tasks/format-code-task-003024/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..2729a028bae2f63c38ee98b4a09a1fcaaac9f7b9 --- /dev/null +++ b/tasks/format-code-task-003024/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/runtime_registration.test.js +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-003024/tests/test_command.sh b/tasks/format-code-task-003024/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-003024/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-003041/environment/Dockerfile b/tasks/format-code-task-003041/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..9251b09e229888b32de3a59aa0ec71c4d3bd3285 --- /dev/null +++ b/tasks/format-code-task-003041/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:57326fbc372f5c55e43861f2f04f4ab8e29972516798f6b8494cca238901f37c diff --git a/tasks/format-code-task-003041/environment/setup/files/blocklist b/tasks/format-code-task-003041/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-003041/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-003041/environment/setup/setup.sh b/tasks/format-code-task-003041/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-003041/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-003041/tests/test.patch b/tasks/format-code-task-003041/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..92a6f6809aba78b1e177b95569cb4acb665d28db --- /dev/null +++ b/tasks/format-code-task-003041/tests/test.patch @@ -0,0 +1,382 @@ +diff --git a/src/test/java/usercase_test_coderl/ListBindAdapterTest.java b/src/test/java/usercase_test_coderl/ListBindAdapterTest.java +new file mode 100644 +--- /dev/null ++++ b/src/test/java/usercase_test_coderl/ListBindAdapterTest.java +@@ -0,0 +1,266 @@ ++package usercase_test_coderl; ++ ++import android.support.v7.widget.RecyclerView; ++import android.view.View; ++import android.view.ViewGroup; ++ ++import com.yqritc.recyclerviewmultipleviewtypesadapter.DataBindAdapter; ++import com.yqritc.recyclerviewmultipleviewtypesadapter.DataBinder; ++import com.yqritc.recyclerviewmultipleviewtypesadapter.EnumListBindAdapter; ++import com.yqritc.recyclerviewmultipleviewtypesadapter.ListBindAdapter; ++ ++import java.util.Arrays; ++import java.util.List; ++ ++public final class ListBindAdapterTest { ++ ++ ++ ++ ++ private interface ThrowingRunnable { ++ void run() throws Throwable; ++ } ++ ++ private static final class DummyHolder extends RecyclerView.ViewHolder { ++ DummyHolder() { ++ super(new View()); ++ } ++ } ++ ++ private static final class DummyBinder extends DataBinder { ++ private final int itemCount; ++ ++ DummyBinder(DataBindAdapter dataBindAdapter, int itemCount) { ++ super(dataBindAdapter); ++ this.itemCount = itemCount; ++ } ++ ++ @Override ++ public DummyHolder newViewHolder(ViewGroup parent) { ++ return new DummyHolder(); ++ } ++ ++ @Override ++ public void bindViewHolder(DummyHolder holder, int position) { ++ } ++ ++ @Override ++ public int getItemCount() { ++ return itemCount; ++ } ++ } ++ ++ private static final class RecordingListBindAdapter extends ListBindAdapter { ++ String lastNotifyMethod; ++ int lastNotifyPosition; ++ int lastNotifyCount; ++ ++ @Override ++ public void notifyItemRangeChanged(int positionStart, int itemCount) { ++ lastNotifyMethod = "notifyItemRangeChanged"; ++ lastNotifyPosition = positionStart; ++ lastNotifyCount = itemCount; ++ } ++ ++ @Override ++ public void notifyItemRangeInserted(int positionStart, int itemCount) { ++ lastNotifyMethod = "notifyItemRangeInserted"; ++ lastNotifyPosition = positionStart; ++ lastNotifyCount = itemCount; ++ } ++ ++ @Override ++ public void notifyItemRangeRemoved(int positionStart, int itemCount) { ++ lastNotifyMethod = "notifyItemRangeRemoved"; ++ lastNotifyPosition = positionStart; ++ lastNotifyCount = itemCount; ++ } ++ } ++ ++ private enum SampleViewType { ++ FIRST, ++ SECOND, ++ THIRD ++ } ++ ++ private static final class SampleEnumListAdapter extends EnumListBindAdapter { ++ } ++ ++ public static void main(String[] args) throws Throwable { ++ testAddBinderOrderingAndLookups(); ++ testAddAllBinderListAndInstanceIndependence(); ++ testAddAllBinderVarargsAndEnumLookup(); ++ testRangeNotificationTranslation(); ++ testInvalidCallsThrowSpecificTypes(); ++ } ++ ++ ++ ++ ++ ++ ++ ++ private static void testAddBinderOrderingAndLookups() { ++ ListBindAdapter adapter = new ListBindAdapter(); ++ DummyBinder first = new DummyBinder(adapter, 1); ++ DummyBinder second = new DummyBinder(adapter, 2); ++ DummyBinder third = new DummyBinder(adapter, 3); ++ ++ adapter.addBinder(first); ++ adapter.addBinder(second); ++ adapter.addBinder(third); ++ ++ assertEquals(Arrays.asList(first, second, third), adapter.getBinderList()); ++ assertEquals(Integer.valueOf(6), Integer.valueOf(adapter.getItemCount())); ++ ++ int[] expectedViewTypes = {0, 1, 1, 2, 2, 2}; ++ for (int i = 0; i < expectedViewTypes.length; i++) { ++ assertEquals(Integer.valueOf(expectedViewTypes[i]), Integer.valueOf(adapter.getItemViewType(i))); ++ } ++ ++ assertSame(second, adapter.getDataBinder(1)); ++ ++ int[] expectedBinderPositions = {0, 0, 1, 1}; ++ int[] positions = {0, 1, 2, 4}; ++ for (int i = 0; i < positions.length; i++) { ++ assertEquals(Integer.valueOf(expectedBinderPositions[i]), Integer.valueOf(adapter.getBinderPosition(positions[i]))); ++ } ++ ++ assertEquals(Integer.valueOf(1), Integer.valueOf(adapter.getPosition(second, 0))); ++ assertEquals(Integer.valueOf(2), Integer.valueOf(adapter.getPosition(second, 1))); ++ assertEquals(Integer.valueOf(5), Integer.valueOf(adapter.getPosition(third, 2))); ++ } ++ ++ ++ ++ ++ ++ ++ private static void testAddAllBinderListAndInstanceIndependence() { ++ ListBindAdapter a = new ListBindAdapter(); ++ DummyBinder a1 = new DummyBinder(a, 1); ++ DummyBinder a2 = new DummyBinder(a, 2); ++ DummyBinder a3 = new DummyBinder(a, 3); ++ a.addAllBinder(Arrays.asList(a1, a2, a3)); ++ ++ ListBindAdapter b = new ListBindAdapter(); ++ DummyBinder b1 = new DummyBinder(b, 4); ++ DummyBinder b2 = new DummyBinder(b, 5); ++ b.addAllBinder(Arrays.asList(b1, b2)); ++ ++ assertEquals(Arrays.asList(a1, a2, a3), a.getBinderList()); ++ assertEquals(Integer.valueOf(6), Integer.valueOf(a.getItemCount())); ++ assertEquals(Arrays.asList(b1, b2), b.getBinderList()); ++ assertEquals(Integer.valueOf(9), Integer.valueOf(b.getItemCount())); ++ assertEquals(Integer.valueOf(0), Integer.valueOf(b.getBinderPosition(4))); ++ assertEquals(Integer.valueOf(1), Integer.valueOf(b.getItemViewType(4))); ++ assertEquals(Integer.valueOf(6), Integer.valueOf(b.getPosition(b2, 2))); ++ } ++ ++ ++ ++ ++ ++ ++ private static void testAddAllBinderVarargsAndEnumLookup() { ++ ListBindAdapter adapter = new ListBindAdapter(); ++ DummyBinder first = new DummyBinder(adapter, 2); ++ DummyBinder second = new DummyBinder(adapter, 3); ++ DummyBinder third = new DummyBinder(adapter, 4); ++ adapter.addAllBinder(first, second, third); ++ ++ assertEquals(Arrays.asList(first, second, third), adapter.getBinderList()); ++ assertEquals(Integer.valueOf(9), Integer.valueOf(adapter.getItemCount())); ++ ++ SampleEnumListAdapter enumAdapter = new SampleEnumListAdapter(); ++ DummyBinder enumFirst = new DummyBinder(enumAdapter, 1); ++ DummyBinder enumSecond = new DummyBinder(enumAdapter, 2); ++ DummyBinder enumThird = new DummyBinder(enumAdapter, 3); ++ enumAdapter.addAllBinder(enumFirst, enumSecond, enumThird); ++ ++ assertEquals(Integer.valueOf(6), Integer.valueOf(enumAdapter.getItemCount())); ++ assertSame(enumSecond, enumAdapter.getDataBinder(SampleViewType.SECOND)); ++ } ++ ++ ++ ++ ++ ++ ++ private static void testRangeNotificationTranslation() { ++ RecordingListBindAdapter adapter = new RecordingListBindAdapter(); ++ DummyBinder first = new DummyBinder(adapter, 1); ++ DummyBinder second = new DummyBinder(adapter, 2); ++ DummyBinder third = new DummyBinder(adapter, 3); ++ adapter.addAllBinder(first, second, third); ++ ++ second.notifyBinderItemRangeChanged(1, 2); ++ assertEquals("notifyItemRangeChanged", adapter.lastNotifyMethod); ++ assertEquals(Integer.valueOf(2), Integer.valueOf(adapter.lastNotifyPosition)); ++ assertEquals(Integer.valueOf(2), Integer.valueOf(adapter.lastNotifyCount)); ++ ++ third.notifyBinderItemRangeInserted(0, 3); ++ assertEquals("notifyItemRangeInserted", adapter.lastNotifyMethod); ++ assertEquals(Integer.valueOf(3), Integer.valueOf(adapter.lastNotifyPosition)); ++ assertEquals(Integer.valueOf(3), Integer.valueOf(adapter.lastNotifyCount)); ++ ++ first.notifyBinderItemRangeRemoved(0, 1); ++ assertEquals("notifyItemRangeRemoved", adapter.lastNotifyMethod); ++ assertEquals(Integer.valueOf(0), Integer.valueOf(adapter.lastNotifyPosition)); ++ assertEquals(Integer.valueOf(1), Integer.valueOf(adapter.lastNotifyCount)); ++ } ++ ++ ++ ++ ++ ++ ++ private static void testInvalidCallsThrowSpecificTypes() throws Throwable { ++ final ListBindAdapter adapter = new ListBindAdapter(); ++ DummyBinder first = new DummyBinder(adapter, 1); ++ DummyBinder second = new DummyBinder(adapter, 2); ++ DummyBinder third = new DummyBinder(adapter, 3); ++ adapter.addAllBinder(first, second, third); ++ ++ assertThrows(IllegalArgumentException.class, new ThrowingRunnable() { ++ @Override ++ public void run() throws Throwable { ++ adapter.getItemViewType(6); ++ } ++ }); ++ ++ assertThrows(IllegalStateException.class, new ThrowingRunnable() { ++ @Override ++ public void run() throws Throwable { ++ adapter.getPosition(new DummyBinder(adapter, 1), 0); ++ } ++ }); ++ } ++ ++ private static void assertSame(Object expected, Object actual) { ++ if (expected != actual) { ++ throw new AssertionError("expected same instance but got different objects"); ++ } ++ } ++ ++ private static void assertEquals(Object expected, Object actual) { ++ if (expected == null ? actual != null : !expected.equals(actual)) { ++ throw new AssertionError("expected " + expected + " but was " + actual); ++ } ++ } ++ ++ private static void assertThrows(Class expectedType, ThrowingRunnable action) ++ throws Throwable { ++ try { ++ action.run(); ++ } catch (Throwable t) { ++ ++ if (!expectedType.isInstance(t)) { ++ throw new AssertionError("expected " + expectedType.getName() + " but was " ++ + t.getClass().getName()); ++ } ++ return; ++ } ++ throw new AssertionError("expected " + expectedType.getName() + " to be thrown"); ++ } ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,106 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++ ++tmp_dir="$(mktemp -d)" ++trap 'rm -rf "$tmp_dir"' EXIT ++ ++mkdir -p "$tmp_dir/src/android/support/v7/widget" \ ++ "$tmp_dir/src/android/view" \ ++ "$tmp_dir/classes" ++ ++cat > "$tmp_dir/src/android/view/View.java" <<'JAVA' ++package android.view; ++ ++public class View { ++} ++JAVA ++ ++cat > "$tmp_dir/src/android/view/ViewGroup.java" <<'JAVA' ++package android.view; ++ ++public class ViewGroup extends View { ++} ++JAVA ++ ++cat > "$tmp_dir/src/android/support/v7/widget/RecyclerView.java" <<'JAVA' ++package android.support.v7.widget; ++ ++import android.view.View; ++import android.view.ViewGroup; ++ ++public class RecyclerView { ++ public static abstract class ViewHolder { ++ private final View itemView; ++ ++ public ViewHolder(View itemView) { ++ this.itemView = itemView; ++ } ++ ++ public View getItemView() { ++ return itemView; ++ } ++ ++ public int getItemViewType() { ++ return 0; ++ } ++ } ++ ++ public abstract static class Adapter { ++ public abstract VH onCreateViewHolder(ViewGroup parent, int viewType); ++ ++ public abstract void onBindViewHolder(VH holder, int position); ++ ++ public abstract int getItemCount(); ++ ++ public int getItemViewType(int position) { ++ return 0; ++ } ++ ++ public void notifyDataSetChanged() { ++ } ++ ++ public void notifyItemChanged(int position) { ++ } ++ ++ public void notifyItemRangeChanged(int positionStart, int itemCount) { ++ } ++ ++ public void notifyItemInserted(int position) { ++ } ++ ++ public void notifyItemMoved(int fromPosition, int toPosition) { ++ } ++ ++ public void notifyItemRangeInserted(int positionStart, int itemCount) { ++ } ++ ++ public void notifyItemRemoved(int position) { ++ } ++ ++ public void notifyItemRangeRemoved(int positionStart, int itemCount) { ++ } ++ } ++} ++JAVA ++ ++ ++javac -d "$tmp_dir/classes" \ ++ "$tmp_dir/src/android/view/View.java" \ ++ "$tmp_dir/src/android/view/ViewGroup.java" \ ++ "$tmp_dir/src/android/support/v7/widget/RecyclerView.java" \ ++ library/src/main/java/com/yqritc/recyclerviewmultipleviewtypesadapter/*.java \ ++ src/test/java/usercase_test_coderl/ListBindAdapterTest.java ++ ++exec java -cp "$tmp_dir/classes" usercase_test_coderl.ListBindAdapterTest diff --git a/tasks/format-code-task-003041/tests/test.sh b/tasks/format-code-task-003041/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..36fe00e1e9e6214b3cb37e7a461671365bffc051 --- /dev/null +++ b/tasks/format-code-task-003041/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +src/test/java/usercase_test_coderl/ListBindAdapterTest.java +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-003041/tests/test_command.sh b/tasks/format-code-task-003041/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-003041/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-003046/environment/Dockerfile b/tasks/format-code-task-003046/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e029019334a2078af1c910091c59778568e4ffe7 --- /dev/null +++ b/tasks/format-code-task-003046/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:4881b45095daf239df89597f1eadee29e28a11684ca859cb71d8e509fef28e9c diff --git a/tasks/format-code-task-003046/environment/setup/files/blocklist b/tasks/format-code-task-003046/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-003046/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-003046/environment/setup/setup.sh b/tasks/format-code-task-003046/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-003046/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-003046/tests/test.patch b/tasks/format-code-task-003046/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..b3f8da7918a0840e602ee7e4fdd738dd4f49e6a1 --- /dev/null +++ b/tasks/format-code-task-003046/tests/test.patch @@ -0,0 +1,512 @@ +diff --git a/usercase-test-coderl/test_q3.py b/usercase-test-coderl/test_q3.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_q3.py +@@ -0,0 +1,484 @@ ++ ++ ++ ++from __future__ import annotations ++ ++import asyncio ++import copy ++import json ++import socket ++import subprocess ++import sys ++import textwrap ++from pathlib import Path ++ ++import numpy as np ++import pytest ++import xarray as xr ++import zarr ++from obspec_utils.registry import ObjectStoreRegistry ++from obstore.store import LocalStore ++ ++from virtualizarr.parsers import ZarrParser ++ ++ ++def _registry_for(path: Path) -> tuple[LocalStore, ObjectStoreRegistry]: ++ store = LocalStore(prefix=str(path)) ++ registry = ObjectStoreRegistry({path.as_uri(): store}) ++ return store, registry ++ ++ ++def _parse(path: Path, parser: ZarrParser | None = None): ++ _, registry = _registry_for(path) ++ return (parser or ZarrParser())(url=path.as_uri(), registry=registry) ++ ++ ++def _manifest_dict(manifest_store, variable: str) -> dict: ++ vds = manifest_store.to_virtual_dataset(loadable_variables=[]) ++ return vds[variable].data.manifest.dict() ++ ++ ++def _manifest_grid(manifest_store, variable: str) -> tuple[int, ...]: ++ vds = manifest_store.to_virtual_dataset(loadable_variables=[]) ++ return vds[variable].data.manifest.shape_chunk_grid ++ ++ ++def _query_dataset() -> xr.Dataset: ++ return xr.Dataset( ++ {"data": (("x", "y"), np.arange(36, dtype="float32").reshape(6, 6))} ++ ) ++ ++ ++def _write_dense_store(path: Path, zarr_format: int) -> xr.Dataset: ++ ds = _query_dataset() ++ ds.to_zarr( ++ path, ++ encoding={"data": {"chunks": (2, 2)}}, ++ consolidated=False, ++ zarr_format=zarr_format, ++ ) ++ return ds ++ ++ ++def _expected_v3_dense_manifest(path: Path) -> dict: ++ base = path.as_uri() ++ return { ++ f"{i}.{j}": { ++ "path": f"{base}/data/c/{i}/{j}", ++ "offset": 0, ++ "length": 25, ++ } ++ for i in range(3) ++ for j in range(3) ++ } ++ ++ ++def _expected_v2_dense_manifest(path: Path) -> dict: ++ base = path.as_uri() ++ return { ++ f"{i}.{j}": { ++ "path": f"{base}/data/{i}.{j}", ++ "offset": 0, ++ "length": 32, ++ } ++ for i in range(3) ++ for j in range(3) ++ } ++ ++ ++def _write_sparse_store(path: Path) -> None: ++ group = zarr.group(store=path, overwrite=True, zarr_format=3) ++ array = group.create_array( ++ "data", ++ shape=(30, 30), ++ chunks=(10, 10), ++ dtype="float32", ++ fill_value=np.nan, ++ dimension_names=("x", "y"), ++ ) ++ array[0:10, 0:10] = 1.0 ++ array[10:20, 10:20] = 2.0 ++ array[20:30, 20:30] = 3.0 ++ ++ ++def _expected_tree() -> xr.DataTree: ++ return xr.DataTree.from_dict( ++ { ++ "/": xr.Dataset( ++ { ++ "air": (("x",), np.arange(4, dtype="float32")), ++ "root_only": (("x",), np.arange(4, dtype="float32") + 10), ++ } ++ ), ++ "/group_a": xr.Dataset( ++ { ++ "air": (("y",), np.arange(6, dtype="float32") + 20), ++ "temp": (("y",), np.arange(6, dtype="float32") + 30), ++ } ++ ), ++ "/group_a/nested": xr.Dataset( ++ {"deep": (("z",), np.arange(8, dtype="float32") + 40)} ++ ), ++ } ++ ) ++ ++ ++def _write_tree_store(path: Path) -> xr.DataTree: ++ tree = _expected_tree() ++ tree.to_zarr(path, consolidated=False, zarr_format=3) ++ return tree ++ ++ ++def test_zarr_v3_dense_manifest_and_xarray_roundtrip(tmp_path: Path) -> None: ++ ++ ++ ++ path = tmp_path / "dense_v3.zarr" ++ expected_ds = _write_dense_store(path, zarr_format=3) ++ ++ manifest_store = _parse(path) ++ ++ assert _manifest_dict(manifest_store, "data") == _expected_v3_dense_manifest(path) ++ with xr.open_dataset( ++ manifest_store, engine="zarr", consolidated=False, zarr_format=3 ++ ) as actual: ++ xr.testing.assert_identical(actual, expected_ds) ++ ++ ++def test_zarr_v2_dense_manifest_uses_dot_keys_and_reads_as_v3(tmp_path: Path) -> None: ++ ++ ++ ++ path = tmp_path / "dense_v2.zarr" ++ expected_ds = _write_dense_store(path, zarr_format=2) ++ ++ manifest_store = _parse(path) ++ ++ assert _manifest_dict(manifest_store, "data") == _expected_v2_dense_manifest(path) ++ with xr.open_dataset( ++ manifest_store, engine="zarr", consolidated=False, zarr_format=3 ++ ) as actual: ++ xr.testing.assert_identical(actual, expected_ds) ++ ++ ++def test_parent_registry_prefix_preserves_nested_store_urls(tmp_path: Path) -> None: ++ ++ ++ ++ parent = tmp_path / "bucket_root" ++ path = parent / "foo" / "bar.zarr" ++ path.parent.mkdir(parents=True) ++ expected_ds = xr.Dataset( ++ {"temp": (("x", "y"), np.arange(12, dtype="float32").reshape(3, 4))} ++ ) ++ expected_ds.to_zarr(path, consolidated=False, zarr_format=3) ++ registry = ObjectStoreRegistry({parent.as_uri(): LocalStore(prefix=str(parent))}) ++ ++ manifest_store = ZarrParser()(url=path.as_uri(), registry=registry) ++ ++ assert _manifest_dict(manifest_store, "temp") == { ++ "0.0": { ++ "path": f"{path.as_uri()}/temp/c/0/0", ++ "offset": 0, ++ "length": 57, ++ } ++ } ++ with xr.open_dataset( ++ manifest_store, engine="zarr", consolidated=False, zarr_format=3 ++ ) as actual: ++ xr.testing.assert_identical(actual, expected_ds) ++ ++ ++def test_parser_recurses_from_root_into_nested_groups(tmp_path: Path) -> None: ++ ++ ++ ++ path = tmp_path / "tree.zarr" ++ expected = _write_tree_store(path) ++ ++ manifest_store = _parse(path) ++ ++ with xr.open_datatree( ++ manifest_store, engine="zarr", consolidated=False, zarr_format=3 ++ ) as actual: ++ xr.testing.assert_identical(actual, expected) ++ ++ ++def test_parser_group_argument_uses_nested_group_as_root(tmp_path: Path) -> None: ++ ++ ++ ++ path = tmp_path / "tree_group.zarr" ++ _write_tree_store(path) ++ expected = xr.Dataset({"deep": (("z",), np.arange(8, dtype="float32") + 40)}) ++ ++ manifest_store = _parse(path, parser=ZarrParser(group="group_a/nested")) ++ ++ with xr.open_dataset( ++ manifest_store, engine="zarr", consolidated=False, zarr_format=3 ++ ) as actual: ++ xr.testing.assert_identical(actual, expected) ++ ++ ++def test_skip_variables_removes_matching_arrays_across_hierarchy(tmp_path: Path) -> None: ++ ++ ++ ++ path = tmp_path / "tree_skip.zarr" ++ _write_tree_store(path) ++ expected = xr.DataTree.from_dict( ++ { ++ "/": xr.Dataset( ++ {"root_only": (("x",), np.arange(4, dtype="float32") + 10)} ++ ), ++ "/group_a": xr.Dataset( ++ {"temp": (("y",), np.arange(6, dtype="float32") + 30)} ++ ), ++ "/group_a/nested": xr.Dataset( ++ {"deep": (("z",), np.arange(8, dtype="float32") + 40)} ++ ), ++ } ++ ) ++ ++ manifest_store = _parse(path, parser=ZarrParser(skip_variables=["air"])) ++ ++ with xr.open_datatree( ++ manifest_store, engine="zarr", consolidated=False, zarr_format=3 ++ ) as actual: ++ xr.testing.assert_identical(actual, expected) ++ ++ ++def test_sparse_store_keeps_only_initialized_chunks_and_fill_values( ++ tmp_path: Path, ++) -> None: ++ ++ ++ ++ path = tmp_path / "sparse.zarr" ++ _write_sparse_store(path) ++ base = path.as_uri() ++ expected_manifest = { ++ "0.0": {"path": f"{base}/data/c/0/0", "offset": 0, "length": 21}, ++ "1.1": {"path": f"{base}/data/c/1/1", "offset": 0, "length": 21}, ++ "2.2": {"path": f"{base}/data/c/2/2", "offset": 0, "length": 21}, ++ } ++ expected_values = np.full((30, 30), np.nan, dtype="float32") ++ expected_values[0:10, 0:10] = 1.0 ++ expected_values[10:20, 10:20] = 2.0 ++ expected_values[20:30, 20:30] = 3.0 ++ ++ manifest_store = _parse(path) ++ ++ assert _manifest_dict(manifest_store, "data") == expected_manifest ++ assert _manifest_grid(manifest_store, "data") == (3, 3) ++ with xr.open_dataset( ++ manifest_store, engine="zarr", consolidated=False, zarr_format=3 ++ ) as actual: ++ np.testing.assert_equal(actual["data"].values, expected_values) ++ ++ ++def test_scalar_initialized_and_uninitialized_manifests(tmp_path: Path) -> None: ++ ++ ++ ++ initialized = tmp_path / "scalar_init.zarr" ++ group = zarr.group(store=initialized, overwrite=True, zarr_format=3) ++ array = group.create_array("scalar", shape=(), dtype="int8") ++ array[()] = 42 ++ ++ initialized_store = _parse(initialized) ++ initialized_manifest = _manifest_dict(initialized_store, "scalar") ++ ++ assert list(initialized_manifest.values()) == [ ++ { ++ "path": f"{initialized.as_uri()}/scalar/c", ++ "offset": 0, ++ "length": 10, ++ } ++ ] ++ assert _manifest_grid(initialized_store, "scalar") == () ++ ++ uninitialized = tmp_path / "scalar_uninit.zarr" ++ group = zarr.group(store=uninitialized, overwrite=True, zarr_format=3) ++ group.create_array("scalar", shape=(), dtype="int8") ++ ++ uninitialized_store = _parse(uninitialized) ++ assert _manifest_dict(uninitialized_store, "scalar") == {} ++ assert _manifest_grid(uninitialized_store, "scalar") == () ++ ++ ++def test_sharded_v3_arrays_use_shard_grid_and_roundtrip(tmp_path: Path) -> None: ++ ++ ++ ++ path = tmp_path / "sharded.zarr" ++ expected_ds = xr.Dataset( ++ { ++ "data": ( ++ ("x", "y"), ++ np.arange(12 * 12, dtype="float32").reshape(12, 12), ++ ) ++ } ++ ) ++ expected_ds.to_zarr( ++ path, ++ encoding={"data": {"chunks": (3, 3), "shards": (6, 6)}}, ++ consolidated=False, ++ zarr_format=3, ++ ) ++ base = path.as_uri() ++ expected_manifest = { ++ "0.0": {"path": f"{base}/data/c/0/0", "offset": 0, "length": 248}, ++ "0.1": {"path": f"{base}/data/c/0/1", "offset": 0, "length": 248}, ++ "1.0": {"path": f"{base}/data/c/1/0", "offset": 0, "length": 248}, ++ "1.1": {"path": f"{base}/data/c/1/1", "offset": 0, "length": 248}, ++ } ++ ++ manifest_store = _parse(path) ++ ++ assert _manifest_dict(manifest_store, "data") == expected_manifest ++ assert _manifest_grid(manifest_store, "data") == (2, 2) ++ with xr.open_dataset( ++ manifest_store, engine="zarr", consolidated=False, zarr_format=3 ++ ) as actual: ++ xr.testing.assert_identical(actual, expected_ds) ++ ++ ++def test_parser_call_inside_running_event_loop_returns_manifest( ++ tmp_path: Path, ++) -> None: ++ ++ ++ ++ path = tmp_path / "loop.zarr" ++ _write_dense_store(path, zarr_format=3) ++ _, registry = _registry_for(path) ++ expected = _expected_v3_dense_manifest(path) ++ ++ async def call_parser_inside_loop() -> dict: ++ manifest_store = ZarrParser()(url=path.as_uri(), registry=registry) ++ return _manifest_dict(manifest_store, "data") ++ ++ actual = asyncio.run(call_parser_inside_loop()) ++ ++ assert actual == expected ++ ++ ++def test_registry_miss_surfaces_specific_resolution_error(tmp_path: Path) -> None: ++ ++ ++ ++ path = tmp_path / "missing_registry.zarr" ++ _write_dense_store(path, zarr_format=3) ++ ++ ++ with pytest.raises(ValueError): ++ ZarrParser()(url=path.as_uri(), registry=ObjectStoreRegistry({})) ++ ++ ++def test_rectilinear_chunk_grid_raises_not_implemented(tmp_path: Path) -> None: ++ ++ ++ ++ path = tmp_path / "rectilinear.zarr" ++ with zarr.config.set({"array.rectilinear_chunks": True}): ++ group = zarr.group(store=path, overwrite=True, zarr_format=3) ++ group.create_array( ++ "data", ++ shape=(2, 3), ++ dtype="float32", ++ chunks=((2, 1), (3, 1)), ++ ) ++ ++ with pytest.raises(NotImplementedError): ++ _parse(path) ++ ++ ++def test_parser_is_referentially_transparent_for_same_input(tmp_path: Path) -> None: ++ path = tmp_path / "referential.zarr" ++ _write_dense_store(path, zarr_format=3) ++ expected = _expected_v3_dense_manifest(path) ++ ++ first = _manifest_dict(_parse(path), "data") ++ second = _manifest_dict(_parse(path), "data") ++ ++ assert first == expected ++ assert second == expected ++ assert first == second ++ ++ ++def test_parser_has_no_global_state_across_fresh_process(tmp_path: Path) -> None: ++ path = tmp_path / "fresh_process.zarr" ++ _write_dense_store(path, zarr_format=3) ++ expected = _expected_v3_dense_manifest(path) ++ ++ in_process = _manifest_dict(_parse(path), "data") ++ script = textwrap.dedent( ++ f""" ++ import json ++ import sys ++ from pathlib import Path ++ ++ sys.path.insert(0, "/workspace/repo") ++ from obspec_utils.registry import ObjectStoreRegistry ++ from obstore.store import LocalStore ++ from virtualizarr.parsers import ZarrParser ++ ++ path = Path({str(path)!r}) ++ registry = ObjectStoreRegistry({{path.as_uri(): LocalStore(prefix=str(path))}}) ++ manifest_store = ZarrParser()(url=path.as_uri(), registry=registry) ++ vds = manifest_store.to_virtual_dataset(loadable_variables=[]) ++ print(json.dumps(vds["data"].data.manifest.dict(), sort_keys=True)) ++ """ ++ ) ++ proc = subprocess.run( ++ [sys.executable, "-c", script], ++ check=True, ++ capture_output=True, ++ text=True, ++ ) ++ fresh_process = json.loads(proc.stdout) ++ ++ assert in_process == expected ++ assert fresh_process == expected ++ ++ ++def test_parser_does_not_mutate_registry_or_store_inputs(tmp_path: Path) -> None: ++ path = tmp_path / "no_mutation.zarr" ++ _write_dense_store(path, zarr_format=3) ++ store, registry = _registry_for(path) ++ before = copy.deepcopy( ++ { ++ "registry_keys": sorted((key.scheme, key.netloc) for key in registry.map), ++ "store_prefix": str(store.prefix), ++ } ++ ) ++ ++ _ = ZarrParser()(url=path.as_uri(), registry=registry) ++ ++ after = { ++ "registry_keys": sorted((key.scheme, key.netloc) for key in registry.map), ++ "store_prefix": str(store.prefix), ++ } ++ assert after == before ++ ++ ++def test_parser_only_reads_existing_local_objects( ++ tmp_path: Path, monkeypatch: pytest.MonkeyPatch ++) -> None: ++ path = tmp_path / "no_side_effects.zarr" ++ _write_dense_store(path, zarr_format=3) ++ _, registry = _registry_for(path) ++ monkeypatch.chdir(tmp_path) ++ ++ def fail_socket(*args, **kwargs): ++ raise AssertionError("ZarrParser must not open network sockets for a local store") ++ ++ monkeypatch.setattr(socket, "getaddrinfo", fail_socket) ++ monkeypatch.setattr(socket.socket, "connect", fail_socket) ++ before = sorted(str(p.relative_to(tmp_path)) for p in tmp_path.rglob("*")) ++ ++ _ = ZarrParser()(url=path.as_uri(), registry=registry) ++ ++ after = sorted(str(p.relative_to(tmp_path)) for p in tmp_path.rglob("*")) ++ assert after == before +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,18 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo ++ ++export PIP_NO_INDEX=1 ++export PIP_DISABLE_PIP_VERSION_CHECK=1 ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++exec python -m pytest -p pytest_asyncio.plugin -p pytest_timeout /workspace/repo/usercase-test-coderl/test_q3.py -v diff --git a/tasks/format-code-task-003046/tests/test.sh b/tasks/format-code-task-003046/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..779cd59d7f32918c70e83626b760d79b2e556d06 --- /dev/null +++ b/tasks/format-code-task-003046/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/test_q3.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-003046/tests/test_command.sh b/tasks/format-code-task-003046/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-003046/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-003048/environment/Dockerfile b/tasks/format-code-task-003048/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..50a221cbf0c83e047130a8f74005df331f43bfb3 --- /dev/null +++ b/tasks/format-code-task-003048/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:af0ed4a91b625784a1a0be6ed55dfe66fded5658e991bbdaee279df65526343f diff --git a/tasks/format-code-task-003048/environment/setup/files/blocklist b/tasks/format-code-task-003048/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-003048/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-003048/environment/setup/setup.sh b/tasks/format-code-task-003048/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-003048/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-003048/tests/test.patch b/tasks/format-code-task-003048/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..a40e5b7851ba17d4cb0b79cc94777e965d2501f4 --- /dev/null +++ b/tasks/format-code-task-003048/tests/test.patch @@ -0,0 +1,501 @@ +diff --git a/usercase-test-coderl/fixtures/mock_jira_server.py b/usercase-test-coderl/fixtures/mock_jira_server.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/mock_jira_server.py +@@ -0,0 +1,75 @@ ++from __future__ import annotations ++ ++import base64 ++import json ++import sys ++from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer ++from pathlib import Path ++ ++ ++port_file = Path(sys.argv[1]) ++log_file = Path(sys.argv[2]) ++mode = sys.argv[3] ++ ++ ++class Handler(BaseHTTPRequestHandler): ++ def log_message(self, fmt: str, *args: object) -> None: ++ return ++ ++ def do_POST(self) -> None: ++ length = int(self.headers.get("Content-Length", "0") or "0") ++ raw = self.rfile.read(length) ++ payload = json.loads(raw.decode("utf-8")) if raw else None ++ auth_header = self.headers.get("Authorization", "") ++ basic_user = "" ++ if auth_header.startswith("Basic "): ++ decoded = base64.b64decode(auth_header.split(" ", 1)[1]).decode("utf-8") ++ basic_user = decoded.split(":", 1)[0] ++ ++ record = { ++ "authorization": auth_header, ++ "basic_user": basic_user, ++ "content_type": self.headers.get("Content-Type", ""), ++ "path": self.path, ++ "payload": payload, ++ } ++ with log_file.open("a", encoding="utf-8") as f: ++ f.write(json.dumps(record, ensure_ascii=False, sort_keys=True) + "\n") ++ ++ if self.path == "/rest/api/2/issue": ++ if mode == "create_error": ++ self._send( ++ 418, ++ '{"errorMessages":["teapot create failure"],"errors":{"summary":"short"}}', ++ "application/json", ++ ) ++ return ++ self._send( ++ 201, ++ '{"key":"DORIS-4242","self":"https://jira.example/rest/api/2/issue/4242"}', ++ "application/json", ++ ) ++ return ++ ++ if self.path == "/rest/agile/1.0/epic/DORIS-24979/issue": ++ if mode == "epic_error": ++ self._send(409, "epic closed for linking", "text/plain") ++ return ++ self._send(204, "", "text/plain") ++ return ++ ++ self._send(404, "unexpected path", "text/plain") ++ ++ def _send(self, status: int, body: str, content_type: str) -> None: ++ data = body.encode("utf-8") ++ self.send_response(status) ++ self.send_header("Content-Type", content_type) ++ self.send_header("Content-Length", str(len(data))) ++ self.end_headers() ++ if data: ++ self.wfile.write(data) ++ ++ ++server = ThreadingHTTPServer(("127.0.0.1", 0), Handler) ++port_file.write_text(str(server.server_address[1]), encoding="utf-8") ++server.serve_forever() +diff --git a/usercase-test-coderl/fixtures/uv b/usercase-test-coderl/fixtures/uv +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/uv +@@ -0,0 +1,28 @@ ++#!/usr/bin/env bash ++set -e ++ ++if [ "${1:-}" != "run" ]; then ++ echo "fixture uv supports only: uv run --project " >&2 ++ exit 127 ++fi ++shift ++ ++while [ "$#" -gt 0 ]; do ++ case "$1" in ++ --project) ++ shift 2 ++ ;; ++ --project=*) ++ shift ++ ;; ++ --) ++ shift ++ break ++ ;; ++ *) ++ break ++ ;; ++ esac ++done ++ ++exec "$@" +diff --git a/usercase-test-coderl/usecase.sh b/usercase-test-coderl/usecase.sh +new file mode 100755 +--- /dev/null ++++ b/usercase-test-coderl/usecase.sh +@@ -0,0 +1,366 @@ ++#!/usr/bin/env bash ++ ++set -u ++export LANG=C.UTF-8 LC_ALL=C.UTF-8 TZ=UTC ++ ++REPO=/workspace/repo ++SKILL_DIR="$REPO/skills/jira-issue" ++FIXTURES="$REPO/usercase-test-coderl/fixtures" ++ ++TMP=$(mktemp -d) ++trap 'jobs -pr | xargs -r kill 2>/dev/null || true; rm -rf "$TMP"' EXIT ++fail() { echo "FAIL: $*" >&2; exit 1; } ++ ++ ++VENV=/opt/stage4a-coderl-venv ++[ -x "$VENV/bin/python" ] || fail "offline venv missing: $VENV" ++"$VENV/bin/python" - <<'PY' || fail "offline dependencies unavailable" ++import click ++import requests ++PY ++chmod +x "$FIXTURES/uv" ++export PATH="$FIXTURES:$VENV/bin:$PATH" ++ ++run_jira() { ++ ( cd "$SKILL_DIR" && uv run --project . python3 scripts/jira_create_issue.py "$@" ) ++} ++ ++clean_jira_env() { ++ unset JIRA_URL JIRA_TOKEN JIRA_USER JIRA_PROJECT JIRA_ISSUE_TYPE ++ unset MULTI_AGENT_TODO_JIRA_DRY_RUN ++} ++ ++assert_stdout_has_line() { ++ file="$1" ++ expected="$2" ++ grep -Fxq "$expected" "$file" || fail "missing stdout line '$expected': $(cat "$file")" ++} ++ ++start_server() { ++ mode="$1" ++ port_file="$TMP/server-$mode.port" ++ log_file="$TMP/server-$mode.log" ++ rm -f "$port_file" ++ : >"$log_file" ++ python3 "$FIXTURES/mock_jira_server.py" "$port_file" "$log_file" "$mode" & ++ server_pid=$! ++ for _ in $(seq 1 100); do ++ [ -s "$port_file" ] && break ++ sleep 0.05 ++ done ++ [ -s "$port_file" ] || fail "mock server did not start for $mode" ++ SERVER_PID="$server_pid" ++ SERVER_PORT=$(cat "$port_file") ++ SERVER_LOG="$log_file" ++} ++ ++stop_server() { ++ kill "$SERVER_PID" 2>/dev/null || true ++ wait "$SERVER_PID" 2>/dev/null || true ++} ++ ++ ++ ++ ++clean_jira_env ++run_jira --help >"$TMP/help.out" 2>"$TMP/help.err"; ec=$? ++[ "$ec" -eq 0 ] || fail "F_help exit $ec; want 0" ++[ ! -s "$TMP/help.err" ] || fail "F_help unexpected stderr: $(cat "$TMP/help.err")" ++ ++grep -Fiq "usage" "$TMP/help.out" || fail "F_help missing usage" ++for flag in --jira-url --jira-user --jira-token --auth --project-key --issue-type --summary --description-file --label --component --affects-version --fix-version --assignee --priority --epic --print-payload --dry-run --help; do ++ grep -Fq -- "$flag" "$TMP/help.out" || fail "F_help missing $flag" ++done ++ ++ ++ ++ ++clean_jira_env ++mkdir -p "$TMP/home-dry" ++printf 'Planner stalls when queue has two reviewers\nSecond line is trimmed.\n' >"$TMP/desc-full.txt" ++HOME="$TMP/home-dry" run_jira \ ++ --project-key DORIS \ ++ --issue-type Bug \ ++ --summary "Planner bug" \ ++ --description-file "$TMP/desc-full.txt" \ ++ --label DorisExplorer \ ++ --label PlannerTag \ ++ --component Planner \ ++ --component Reviewer \ ++ --affects-version 3.1.4 \ ++ --fix-version 3.1.5 \ ++ --assignee alice \ ++ --priority High \ ++ --dry-run >"$TMP/dry.out" 2>"$TMP/dry.err"; ec=$? ++[ "$ec" -eq 0 ] || fail "F_dry_full_payload exit $ec; want 0" ++ ++python3 - "$TMP/dry.out" "$TMP/desc-full.txt" <<'PY' || fail "F_dry_full_payload payload: $(cat "$TMP/dry.out")" ++import json ++import sys ++from pathlib import Path ++ ++payload = json.loads(Path(sys.argv[1]).read_text(encoding="utf-8")) ++desc = Path(sys.argv[2]).read_text(encoding="utf-8") ++fields = payload["fields"] ++assert fields["project"]["key"] == "DORIS" ++assert fields["summary"] == "Planner bug" ++assert fields["description"] in {desc, desc.rstrip("\n")} ++assert fields["issuetype"]["name"] == "Bug" ++assert set(fields["labels"]) == {"DorisExplorer", "PlannerTag"} ++assert {item["name"] for item in fields["components"]} == {"Planner", "Reviewer"} ++assert {item["name"] for item in fields["versions"]} == {"3.1.4"} ++assert {item["name"] for item in fields["fixVersions"]} == {"3.1.5"} ++assert fields["assignee"]["name"] == "alice" ++assert fields["priority"]["name"] == "High" ++PY ++[ ! -s "$TMP/dry.err" ] || fail "F_dry_full_payload unexpected stderr: $(cat "$TMP/dry.err")" ++ ++ ++ ++ ++clean_jira_env ++mkdir -p "$TMP/home-forced" ++printf 'JIRA_PROJECT=CFG\nJIRA_ISSUE_TYPE=Story\n' >"$TMP/home-forced/.env" ++printf 'Regression body\n' >"$TMP/desc-forced.md" ++HOME="$TMP/home-forced" MULTI_AGENT_TODO_JIRA_DRY_RUN=1 run_jira \ ++ --summary "Config default issue" \ ++ --description-file "$TMP/desc-forced.md" \ ++ --label DorisExplorer \ ++ --epic CFG-77 >"$TMP/forced.out" 2>"$TMP/forced.err"; ec=$? ++[ "$ec" -eq 0 ] || fail "F_forced_dry_config exit $ec; want 0" ++ ++python3 - "$TMP/forced.out" "$TMP/desc-forced.md" <<'PY' || fail "F_forced_dry_config stdout: $(cat "$TMP/forced.out")" ++import json ++import sys ++from pathlib import Path ++ ++text = Path(sys.argv[1]).read_text(encoding="utf-8") ++desc = Path(sys.argv[2]).read_text(encoding="utf-8") ++payload, idx = json.JSONDecoder().raw_decode(text) ++fields = payload["fields"] ++assert fields["project"]["key"] == "CFG" ++assert fields["summary"] == "Config default issue" ++assert fields["description"] in {desc, desc.rstrip("\n")} ++assert fields["issuetype"]["name"] == "Story" ++assert fields["labels"] == ["DorisExplorer"] ++records = text[idx:].lstrip("\n").splitlines() ++assert "key=DRYRUN-CFG-1" in records ++assert "self=https://dry-run.invalid/rest/api/2/issue/DRYRUN-CFG-1" in records ++assert "epic_linked=CFG-77" in records ++payload_lines = [line for line in records if line.startswith("payload=")] ++assert len(payload_lines) == 1 ++single_line_payload = json.loads(payload_lines[0].split("=", 1)[1]) ++assert single_line_payload == payload ++PY ++[ ! -s "$TMP/forced.err" ] || fail "F_forced_dry_config unexpected stderr: $(cat "$TMP/forced.err")" ++ ++ ++ ++ ++clean_jira_env ++start_server create_ok ++printf 'Real request body\n' >"$TMP/desc-real.txt" ++HOME="$TMP/home-real" JIRA_URL="http://127.0.0.1:$SERVER_PORT/" JIRA_TOKEN="bearer-token" run_jira \ ++ --project-key DORIS \ ++ --issue-type Bug \ ++ --summary "Real bearer" \ ++ --description-file "$TMP/desc-real.txt" \ ++ --label DorisExplorer \ ++ --component Planner \ ++ --priority High \ ++ --epic DORIS-24979 >"$TMP/real.out" 2>"$TMP/real.err"; ec=$? ++stop_server ++[ "$ec" -eq 0 ] || fail "F_real_bearer_epic exit $ec; want 0" ++ ++assert_stdout_has_line "$TMP/real.out" "key=DORIS-4242" ++assert_stdout_has_line "$TMP/real.out" "self=https://jira.example/rest/api/2/issue/4242" ++assert_stdout_has_line "$TMP/real.out" "epic_linked=DORIS-24979" ++[ ! -s "$TMP/real.err" ] || fail "F_real_bearer_epic unexpected stderr: $(cat "$TMP/real.err")" ++ ++python3 - "$SERVER_LOG" <<'PY' || fail "F_real_bearer_epic request log: $(cat "$SERVER_LOG")" ++import json ++import sys ++from pathlib import Path ++ ++records = [json.loads(line) for line in Path(sys.argv[1]).read_text(encoding="utf-8").splitlines()] ++assert len(records) == 2 ++create, epic = records ++assert create["path"] == "/rest/api/2/issue" ++assert create["authorization"] == "Bearer bearer-token" ++assert create["content_type"].startswith("application/json") ++fields = create["payload"]["fields"] ++assert fields["project"]["key"] == "DORIS" ++assert fields["summary"] == "Real bearer" ++assert fields["description"] in {"Real request body", "Real request body\n"} ++assert fields["issuetype"]["name"] == "Bug" ++assert fields["labels"] == ["DorisExplorer"] ++assert fields["components"] == [{"name": "Planner"}] ++assert fields["priority"]["name"] == "High" ++assert epic["path"] == "/rest/agile/1.0/epic/DORIS-24979/issue" ++assert epic["authorization"] == "Bearer bearer-token" ++assert epic["payload"] == {"issues": ["DORIS-4242"]} ++PY ++ ++ ++ ++ ++clean_jira_env ++start_server create_ok ++printf 'Basic body\n' >"$TMP/desc-basic.txt" ++HOME="$TMP/home-basic" \ ++JIRA_URL="http://127.0.0.1:$SERVER_PORT" \ ++JIRA_TOKEN="basic-token" \ ++JIRA_PROJECT="ENVPROJ" \ ++JIRA_ISSUE_TYPE="Task" \ ++JIRA_USER="bob" run_jira \ ++ --auth basic \ ++ --summary "Env basic" \ ++ --description-file "$TMP/desc-basic.txt" \ ++ --print-payload >"$TMP/basic.out" 2>"$TMP/basic.err"; ec=$? ++stop_server ++[ "$ec" -eq 0 ] || fail "F_basic_print_payload_env exit $ec; want 0" ++ ++python3 - "$TMP/basic.out" <<'PY' || fail "F_basic_print_payload_env stdout: $(cat "$TMP/basic.out")" ++import json ++import sys ++from pathlib import Path ++ ++text = Path(sys.argv[1]).read_text(encoding="utf-8") ++payload, idx = json.JSONDecoder().raw_decode(text) ++fields = payload["fields"] ++assert fields["project"]["key"] == "ENVPROJ" ++assert fields["summary"] == "Env basic" ++assert fields["description"] in {"Basic body", "Basic body\n"} ++assert fields["issuetype"]["name"] == "Task" ++records = text[idx:].lstrip("\n").splitlines() ++assert "key=DORIS-4242" in records ++assert "self=https://jira.example/rest/api/2/issue/4242" in records ++PY ++[ ! -s "$TMP/basic.err" ] || fail "F_basic_print_payload_env unexpected stderr: $(cat "$TMP/basic.err")" ++ ++python3 - "$SERVER_LOG" <<'PY' || fail "F_basic_print_payload_env request log: $(cat "$SERVER_LOG")" ++import json ++import sys ++from pathlib import Path ++ ++records = [json.loads(line) for line in Path(sys.argv[1]).read_text(encoding="utf-8").splitlines()] ++assert len(records) == 1 ++record = records[0] ++assert record["path"] == "/rest/api/2/issue" ++assert record["authorization"] == "Basic Ym9iOmJhc2ljLXRva2Vu" ++assert record["basic_user"] == "bob" ++assert record["content_type"].startswith("application/json") ++fields = record["payload"]["fields"] ++assert fields["project"]["key"] == "ENVPROJ" ++assert fields["summary"] == "Env basic" ++assert fields["description"] in {"Basic body", "Basic body\n"} ++assert fields["issuetype"]["name"] == "Task" ++PY ++ ++ ++ ++ ++clean_jira_env ++start_server epic_error ++printf 'Epic failure body\n' >"$TMP/desc-epic-fail.txt" ++HOME="$TMP/home-epic-fail" JIRA_URL="http://127.0.0.1:$SERVER_PORT" JIRA_TOKEN="bearer-token" run_jira \ ++ --project-key DORIS \ ++ --issue-type Bug \ ++ --summary "Epic warning" \ ++ --description-file "$TMP/desc-epic-fail.txt" \ ++ --epic DORIS-24979 >"$TMP/epic-fail.out" 2>"$TMP/epic-fail.err"; ec=$? ++stop_server ++[ "$ec" -eq 0 ] || fail "F_epic_warning exit $ec; want 0" ++ ++assert_stdout_has_line "$TMP/epic-fail.out" "key=DORIS-4242" ++assert_stdout_has_line "$TMP/epic-fail.out" "self=https://jira.example/rest/api/2/issue/4242" ++! grep -Fq "epic_linked=" "$TMP/epic-fail.out" || fail "F_epic_warning incorrectly reported epic success: $(cat "$TMP/epic-fail.out")" ++ ++grep -Fiq "warning" "$TMP/epic-fail.err" || fail "F_epic_warning missing warning: $(cat "$TMP/epic-fail.err")" ++grep -Fq "409" "$TMP/epic-fail.err" || fail "F_epic_warning missing status: $(cat "$TMP/epic-fail.err")" ++grep -Fq "epic closed for linking" "$TMP/epic-fail.err" || fail "F_epic_warning missing response body: $(cat "$TMP/epic-fail.err")" ++ ++ ++ ++ ++clean_jira_env ++start_server create_error ++printf 'Bad request body\n' >"$TMP/desc-http-error.txt" ++HOME="$TMP/home-http-error" JIRA_URL="http://127.0.0.1:$SERVER_PORT" JIRA_TOKEN="bearer-token" run_jira \ ++ --project-key DORIS \ ++ --issue-type Bug \ ++ --summary "HTTP failure" \ ++ --description-file "$TMP/desc-http-error.txt" >"$TMP/http-error.out" 2>"$TMP/http-error.err"; ec=$? ++stop_server ++[ "$ec" -eq 1 ] || fail "F_http_error exit $ec; want 1" ++[ ! -s "$TMP/http-error.out" ] || fail "F_http_error unexpected stdout: $(cat "$TMP/http-error.out")" ++ ++grep -Fq "Request failed: 418" "$TMP/http-error.err" || fail "F_http_error missing status: $(cat "$TMP/http-error.err")" ++grep -Fq '{"errorMessages":["teapot create failure"],"errors":{"summary":"short"}}' "$TMP/http-error.err" || fail "F_http_error missing body: $(cat "$TMP/http-error.err")" ++ ++ ++ ++ ++clean_jira_env ++printf 'Body\n' >"$TMP/desc-usage.txt" ++HOME="$TMP/home-usage" run_jira \ ++ --project-key DORIS \ ++ --issue-type Bug \ ++ --description-file "$TMP/desc-usage.txt" \ ++ --dry-run >"$TMP/missing-summary.out" 2>"$TMP/missing-summary.err"; ec=$? ++ ++[ "$ec" -ne 0 ] || fail "F_missing_summary exit $ec; want nonzero" ++[ ! -s "$TMP/missing-summary.out" ] || fail "F_missing_summary unexpected stdout: $(cat "$TMP/missing-summary.out")" ++grep -Fiq "usage" "$TMP/missing-summary.err" || fail "F_missing_summary missing usage: $(cat "$TMP/missing-summary.err")" ++grep -Fiq "error" "$TMP/missing-summary.err" || fail "F_missing_summary missing error: $(cat "$TMP/missing-summary.err")" ++grep -Fq -- "--summary" "$TMP/missing-summary.err" || fail "F_missing_summary missing flag: $(cat "$TMP/missing-summary.err")" ++ ++ ++ ++ ++clean_jira_env ++HOME="$TMP/home-usage" run_jira \ ++ --project-key DORIS \ ++ --issue-type Bug \ ++ --summary "Missing desc option" \ ++ --dry-run >"$TMP/missing-desc.out" 2>"$TMP/missing-desc.err"; ec=$? ++ ++[ "$ec" -ne 0 ] || fail "F_missing_description_option exit $ec; want nonzero" ++[ ! -s "$TMP/missing-desc.out" ] || fail "F_missing_description_option unexpected stdout: $(cat "$TMP/missing-desc.out")" ++grep -Fiq "usage" "$TMP/missing-desc.err" || fail "F_missing_description_option missing usage: $(cat "$TMP/missing-desc.err")" ++grep -Fiq "error" "$TMP/missing-desc.err" || fail "F_missing_description_option missing error: $(cat "$TMP/missing-desc.err")" ++grep -Fq -- "--description-file" "$TMP/missing-desc.err" || fail "F_missing_description_option missing flag: $(cat "$TMP/missing-desc.err")" ++ ++ ++ ++ ++clean_jira_env ++HOME="$TMP/home-usage" run_jira \ ++ --project-key DORIS \ ++ --issue-type Bug \ ++ --summary "Missing file" \ ++ --description-file no-such-desc.md \ ++ --dry-run >"$TMP/missing-file.out" 2>"$TMP/missing-file.err"; ec=$? ++ ++[ "$ec" -ne 0 ] || fail "F_missing_description_file exit $ec; want nonzero" ++[ ! -s "$TMP/missing-file.out" ] || fail "F_missing_description_file unexpected stdout: $(cat "$TMP/missing-file.out")" ++grep -Fq "Missing file for --description-file: no-such-desc.md" "$TMP/missing-file.err" || fail "F_missing_description_file stderr: $(cat "$TMP/missing-file.err")" ++ ++ ++ ++ ++clean_jira_env ++printf 'Body\n' >"$TMP/desc-basic-no-user.txt" ++HOME="$TMP/home-basic-no-user" JIRA_URL="http://127.0.0.1:1" JIRA_TOKEN="token" run_jira \ ++ --auth basic \ ++ --project-key DORIS \ ++ --issue-type Bug \ ++ --summary "No user" \ ++ --description-file "$TMP/desc-basic-no-user.txt" >"$TMP/basic-no-user.out" 2>"$TMP/basic-no-user.err"; ec=$? ++ ++[ "$ec" -ne 0 ] || fail "F_basic_missing_user exit $ec; want nonzero" ++[ ! -s "$TMP/basic-no-user.out" ] || fail "F_basic_missing_user unexpected stdout: $(cat "$TMP/basic-no-user.out")" ++grep -Fq "Basic auth requires --jira-user or JIRA_USER." "$TMP/basic-no-user.err" || fail "F_basic_missing_user stderr: $(cat "$TMP/basic-no-user.err")" ++ ++echo "PASS" ++exit 0 +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,12 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++exec bash /workspace/repo/usercase-test-coderl/usecase.sh diff --git a/tasks/format-code-task-003048/tests/test.sh b/tasks/format-code-task-003048/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..7054af782d481052be8fd9c3b63f2e168d9c51bc --- /dev/null +++ b/tasks/format-code-task-003048/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/fixtures/mock_jira_server.py +usercase-test-coderl/fixtures/uv +usercase-test-coderl/usecase.sh +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-003048/tests/test_command.sh b/tasks/format-code-task-003048/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-003048/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file