diff --git a/tasks/format-code-task-000103/environment/Dockerfile b/tasks/format-code-task-000103/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..df9321c0e187c9fcb6bcc04c6b899198a111d9c3 --- /dev/null +++ b/tasks/format-code-task-000103/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:ce6a14e8770b45cfe55150ae7fea639a567e6dbede5bf58e521398e72137e283 diff --git a/tasks/format-code-task-000103/environment/setup/files/blocklist b/tasks/format-code-task-000103/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000103/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-000103/environment/setup/setup.sh b/tasks/format-code-task-000103/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000103/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-000103/tests/test.patch b/tasks/format-code-task-000103/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..c3ea11dcb01349bfaa2fc7c06531cae6a126a873 --- /dev/null +++ b/tasks/format-code-task-000103/tests/test.patch @@ -0,0 +1,127 @@ +diff --git a/oracle/controllers/instancecontroller/instance_controller_parameters_test.go b/oracle/controllers/instancecontroller/instance_controller_parameters_test.go +index a63c794..9da307a 100644 +--- a/oracle/controllers/instancecontroller/instance_controller_parameters_test.go ++++ b/oracle/controllers/instancecontroller/instance_controller_parameters_test.go +@@ -8,7 +8,7 @@ import ( + commonv1alpha1 "github.com/GoogleCloudPlatform/elcarro-oracle-operator/common/api/v1alpha1" + "github.com/GoogleCloudPlatform/elcarro-oracle-operator/oracle/api/v1alpha1" + "github.com/GoogleCloudPlatform/elcarro-oracle-operator/oracle/controllers/testhelpers" +- pb "github.com/GoogleCloudPlatform/elcarro-oracle-operator/oracle/pkg/agents/config_agent/protos" ++ dbdpb "github.com/GoogleCloudPlatform/elcarro-oracle-operator/oracle/pkg/agents/oracle" + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + k8serrors "k8s.io/apimachinery/pkg/api/errors" +@@ -64,7 +64,11 @@ func TestSanityCheckForReservedParameters(t *testing.T) { + fakeClientFactory := &testhelpers.FakeClientFactory{} + fakeClientFactory.Reset() + fakeConfigAgentClient := fakeClientFactory.Caclient +- fakeConfigAgentClient.SetMethodToResp("FetchServiceImageMetaData", &pb.FetchServiceImageMetaDataResponse{ ++ ++ fakeDatabaseClientFactory := &testhelpers.FakeDatabaseClientFactory{} ++ fakeDatabaseClientFactory.Reset() ++ fakeDatabaseClient := fakeDatabaseClientFactory.Dbclient ++ fakeDatabaseClient.SetMethodToResp("FetchServiceImageMetaData", &dbdpb.FetchServiceImageMetaDataResponse{ + Version: "19.3", + CdbName: "GCLOUD", + OracleHome: "/u01/app/oracle/product/19.3/db", +diff --git a/oracle/controllers/instancecontroller/instance_controller_restore_test.go b/oracle/controllers/instancecontroller/instance_controller_restore_test.go +index 876a89f..1b34047 100644 +--- a/oracle/controllers/instancecontroller/instance_controller_restore_test.go ++++ b/oracle/controllers/instancecontroller/instance_controller_restore_test.go +@@ -10,7 +10,7 @@ import ( + commonv1alpha1 "github.com/GoogleCloudPlatform/elcarro-oracle-operator/common/api/v1alpha1" + "github.com/GoogleCloudPlatform/elcarro-oracle-operator/oracle/api/v1alpha1" + "github.com/GoogleCloudPlatform/elcarro-oracle-operator/oracle/controllers/testhelpers" +- pb "github.com/GoogleCloudPlatform/elcarro-oracle-operator/oracle/pkg/agents/config_agent/protos" ++ dbdpb "github.com/GoogleCloudPlatform/elcarro-oracle-operator/oracle/pkg/agents/oracle" + "github.com/GoogleCloudPlatform/elcarro-oracle-operator/oracle/pkg/k8s" + "github.com/go-logr/logr" + . "github.com/onsi/ginkgo" +@@ -40,8 +40,9 @@ func testInstanceRestore() { + fakeDatabaseClient = fakeDatabaseClientFactory.Dbclient + + fakeConfigAgentClient.SetAsyncPhysicalRestore(true) +- fakeClientFactory.Caclient.SetMethodToResp( +- "FetchServiceImageMetaData", &pb.FetchServiceImageMetaDataResponse{ ++ ++ fakeDatabaseClient.SetMethodToResp( ++ "FetchServiceImageMetaData", &dbdpb.FetchServiceImageMetaDataResponse{ + Version: "19.3", + CdbName: "", + OracleHome: "/u01/app/oracle/product/19.3/db", +@@ -176,7 +177,8 @@ func testInstanceRestore() { + + // reset method call counters used later + fakeConfigAgentClient.Reset() +- fakeConfigAgentClient.SetMethodToResp("FetchServiceImageMetaData", &pb.FetchServiceImageMetaDataResponse{ ++ ++ fakeDatabaseClient.SetMethodToResp("FetchServiceImageMetaData", &dbdpb.FetchServiceImageMetaDataResponse{ + Version: "12.2", + CdbName: "GCLOUD", + OracleHome: "/u01/app/oracle/product/12.2/db", +diff --git a/oracle/controllers/instancecontroller/instance_controller_test.go b/oracle/controllers/instancecontroller/instance_controller_test.go +index 32d2d21..2ac267f 100644 +--- a/oracle/controllers/instancecontroller/instance_controller_test.go ++++ b/oracle/controllers/instancecontroller/instance_controller_test.go +@@ -21,7 +21,6 @@ import ( + "testing" + "time" + +- pb "github.com/GoogleCloudPlatform/elcarro-oracle-operator/oracle/pkg/agents/config_agent/protos" + "github.com/go-logr/logr" + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +@@ -34,6 +33,7 @@ import ( + commonv1alpha1 "github.com/GoogleCloudPlatform/elcarro-oracle-operator/common/api/v1alpha1" + "github.com/GoogleCloudPlatform/elcarro-oracle-operator/oracle/api/v1alpha1" + "github.com/GoogleCloudPlatform/elcarro-oracle-operator/oracle/controllers/testhelpers" ++ dbdpb "github.com/GoogleCloudPlatform/elcarro-oracle-operator/oracle/pkg/agents/oracle" + "github.com/GoogleCloudPlatform/elcarro-oracle-operator/oracle/pkg/k8s" + ) + +@@ -84,15 +84,15 @@ var _ = Describe("Instance controller", func() { + + BeforeEach(func() { + fakeClientFactory.Reset() +- fakeClientFactory.Caclient.SetMethodToResp( +- "FetchServiceImageMetaData", &pb.FetchServiceImageMetaDataResponse{ ++ ++ fakeDatabaseClientFactory.Reset() ++ fakeDatabaseClientFactory.Dbclient.SetMethodToResp( ++ "FetchServiceImageMetaData", &dbdpb.FetchServiceImageMetaDataResponse{ + Version: "12.2", + CdbName: "GCLOUD", + OracleHome: "/u01/app/oracle/product/12.2/db", + SeededImage: true, + }) +- +- fakeDatabaseClientFactory.Reset() + }) + + Context("New instance", testInstanceProvision) +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+2TTY/TMBCGe86vmNVeQMh2km2CBOLECYkTcANU5WPaWOvYwR/d1Yofj+NKtF2J ++FtCuEDCPFDl2Zl5PPK95G6TqV6i3YvFY5JHnVZXGyP0xvRdVWZR5frXMy0VeFFVdL6B6tIoOCM43 ++FmBhjfGn4s59/0vh+/57dH7VmXFsdM/d8HB7nOl/UVVX3/tfVnXs/7IuqgXkD1fCj/nP+395IVqp ++Rdu4Iet6SCZosc+yS3ij49EoBdehxeQStDB/hpjQWIkOnqCPOc9SBGsm6dBu0T4FuQZtPEwWHWrP ++o9aHAVOug+AQOqO9NUqhZTZoL0eEaMCkfTPIbgCLX4KM2eCHKAGNBxGcFcp0jRIH9aTaeRb3+wgX ++wNanwlKtn1/OkjqDyHjdSwtsOpGU4rpgVdR279/C4P3kXgixkX4ILY+XJWVYjbF45uTGHSlYVNg4 ++dKI3N1qZphfbkl/x8jBolVZWSupwu2rGvl7yaEi+uYNPafeZrzB7lN3eAXsdWzROYlfYtJucVNv/ +++5mz+UXJ456fEj+O/I1tOq/O6ceQJGxHYHb9E+LZWs4efxf0bIj4WMT5lDfodyZfS4WOZxuzm7It ++sM5Es74qgM2ONcFDnecOuDC26RSKvaudkPPd0R3u10T2p686QRAEQRAEQRAEQRAEQRAEQRAEQRAE ++QRD/KN8A3NhOjAAoAAA= +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-000103/tests/test.sh b/tasks/format-code-task-000103/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..70bfe90d0b7eb780c4ef94a6779f13b6447a898c --- /dev/null +++ b/tasks/format-code-task-000103/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' +oracle/controllers/instancecontroller/instance_controller_parameters_test.go +oracle/controllers/instancecontroller/instance_controller_restore_test.go +oracle/controllers/instancecontroller/instance_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-000103/tests/test_command.sh b/tasks/format-code-task-000103/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000103/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-000104/environment/Dockerfile b/tasks/format-code-task-000104/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..076eddb96e76e35653ba9853c96377096432e481 --- /dev/null +++ b/tasks/format-code-task-000104/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:b54d400b21c23f77cfddb955fbdd191ed31af6803d0c37c21888bf556292d332 diff --git a/tasks/format-code-task-000104/environment/setup/files/blocklist b/tasks/format-code-task-000104/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000104/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-000104/environment/setup/setup.sh b/tasks/format-code-task-000104/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000104/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-000104/tests/test.patch b/tasks/format-code-task-000104/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ebe045eafc3c06cbe5e5c3f16ea4fd79250e51eb --- /dev/null +++ b/tasks/format-code-task-000104/tests/test.patch @@ -0,0 +1,247 @@ +diff --git a/internal/gcsx/append_object_creator_test.go b/internal/gcsx/append_object_creator_test.go +index b5fae06ba0..70cb5e9651 100644 +--- a/internal/gcsx/append_object_creator_test.go ++++ b/internal/gcsx/append_object_creator_test.go +@@ -201,6 +201,74 @@ func (t *AppendObjectCreatorTest) CallsComposeObjects() { + ExpectEq(tmpObject.Generation, src.Generation) + } + ++func (t *AppendObjectCreatorTest) CallsComposeObjectsWithObjectProperties() { ++ t.srcObject.Name = "foo" ++ t.srcObject.Generation = 17 ++ t.srcObject.MetaGeneration = 23 ++ t.srcObject.CacheControl = "testCacheControl" ++ t.srcObject.ContentDisposition = "inline" ++ t.srcObject.ContentEncoding = "gzip" ++ t.srcObject.ContentType = "text/plain" ++ t.srcObject.CustomTime = "2022-04-02T00:30:00Z" ++ t.srcObject.EventBasedHold = true ++ t.srcObject.StorageClass = "STANDARD" ++ t.srcObject.Metadata = map[string]string { ++ "test_key": "test_value", ++ } ++ t.mtime = time.Now().Add(123 * time.Second).UTC() ++ ++ ++ tmpObject := &gcs.Object{ ++ Name: "bar", ++ Generation: 19, ++ } ++ ++ ExpectCall(t.bucket, "CreateObject")(Any(), Any()). ++ WillOnce(Return(tmpObject, nil)) ++ ++ ++ var req *gcs.ComposeObjectsRequest ++ ExpectCall(t.bucket, "ComposeObjects")(Any(), Any()). ++ WillOnce(DoAll(SaveArg(1, &req), Return(nil, errors.New("")))) ++ ++ ++ ExpectCall(t.bucket, "DeleteObject")(Any(), deleteReqName(tmpObject.Name)). ++ WillOnce(Return(nil)) ++ ++ ++ t.call() ++ ++ AssertNe(nil, req) ++ ExpectEq(t.srcObject.Name, req.DstName) ++ ExpectThat( ++ req.DstGenerationPrecondition, ++ Pointee(Equals(t.srcObject.Generation))) ++ ExpectThat( ++ req.DstMetaGenerationPrecondition, ++ Pointee(Equals(t.srcObject.MetaGeneration))) ++ ExpectEq(t.srcObject.CacheControl, req.CacheControl) ++ ExpectEq(t.srcObject.ContentDisposition, req.ContentDisposition) ++ ExpectEq(t.srcObject.ContentEncoding, req.ContentEncoding) ++ ExpectEq(t.srcObject.ContentType, req.ContentType) ++ ExpectEq(t.srcObject.CustomTime, req.CustomTime) ++ ExpectEq(t.srcObject.EventBasedHold, req.EventBasedHold) ++ ++ ExpectEq(2, len(req.Metadata)) ++ ExpectEq(t.mtime.Format(time.RFC3339Nano), req.Metadata["gcsfuse_mtime"]) ++ ExpectEq("test_value", req.Metadata["test_key"]) ++ ++ AssertEq(2, len(req.Sources)) ++ var src gcs.ComposeSource ++ ++ src = req.Sources[0] ++ ExpectEq(t.srcObject.Name, src.Name) ++ ExpectEq(t.srcObject.Generation, src.Generation) ++ ++ src = req.Sources[1] ++ ExpectEq(tmpObject.Name, src.Name) ++ ExpectEq(tmpObject.Generation, src.Generation) ++} ++ + func (t *AppendObjectCreatorTest) ComposeObjectsFails() { + // CreateObject + tmpObject := &gcs.Object{ +diff --git a/internal/gcsx/syncer_test.go b/internal/gcsx/syncer_test.go +index 0f3e23e4bf..f8da2ca698 100644 +--- a/internal/gcsx/syncer_test.go ++++ b/internal/gcsx/syncer_test.go +@@ -25,6 +25,7 @@ import ( + "github.com/jacobsa/gcloud/gcs" + "github.com/jacobsa/gcloud/gcs/gcsfake" + . "github.com/jacobsa/oglematchers" ++ . "github.com/jacobsa/oglemock" + . "github.com/jacobsa/ogletest" + "github.com/jacobsa/timeutil" + "golang.org/x/net/context" +@@ -32,6 +33,134 @@ import ( + + func TestSyncer(t *testing.T) { RunTests(t) } + ++ ++ ++ ++ ++type FullObjectCreatorTest struct { ++ ctx context.Context ++ bucket gcs.MockBucket ++ creator objectCreator ++ ++ srcObject gcs.Object ++ srcContents string ++ mtime time.Time ++} ++ ++func init() { RegisterTestSuite(&FullObjectCreatorTest{}) } ++ ++func (t *FullObjectCreatorTest) SetUp(ti *TestInfo) { ++ t.ctx = ti.Ctx ++ ++ ++ t.bucket = gcs.NewMockBucket(ti.MockController, "bucket") ++ ++ ++ t.creator = &fullObjectCreator{ ++ bucket: t.bucket, ++ } ++} ++ ++func (t *FullObjectCreatorTest) call() (o *gcs.Object, err error) { ++ o, err = t.creator.Create( ++ t.ctx, ++ &t.srcObject, ++ t.mtime, ++ strings.NewReader(t.srcContents)) ++ ++ return ++} ++ ++ ++ ++ ++ ++func (t *FullObjectCreatorTest) CallsCreateObject() { ++ t.srcContents = "taco" ++ ++ ++ var req *gcs.CreateObjectRequest ++ ExpectCall(t.bucket, "CreateObject")(Any(), Any()). ++ WillOnce(DoAll(SaveArg(1, &req), Return(nil, errors.New("")))) ++ ++ ++ t.call() ++ ++ AssertNe(nil, req) ++ ExpectThat(req.GenerationPrecondition, Pointee(Equals(0))) ++ ++ b, err := ioutil.ReadAll(req.Contents) ++ AssertEq(nil, err) ++ ExpectEq(t.srcContents, string(b)) ++} ++ ++func (t *FullObjectCreatorTest) CreateObjectFails() { ++ var err error ++ ++ ++ ExpectCall(t.bucket, "CreateObject")(Any(), Any()). ++ WillOnce(Return(nil, errors.New("taco"))) ++ ++ ++ _, err = t.call() ++ ++ ExpectThat(err, Error(HasSubstr("CreateObject"))) ++ ExpectThat(err, Error(HasSubstr("taco"))) ++} ++ ++func (t *FullObjectCreatorTest) CreateObjectReturnsPreconditionError() { ++ var err error ++ ++ ++ ExpectCall(t.bucket, "CreateObject")(Any(), Any()). ++ WillOnce(Return(nil, &gcs.PreconditionError{Err: errors.New("taco")})) ++ ++ ++ _, err = t.call() ++ ++ var preconditionErr *gcs.PreconditionError ++ ExpectTrue(errors.As(err, &preconditionErr)) ++ ExpectThat(err, Error(HasSubstr("CreateObject"))) ++ ExpectThat(err, Error(HasSubstr("taco"))) ++} ++ ++func (t *FullObjectCreatorTest) CallsCreateObjectsWithObjectProperties() { ++ t.srcObject.Name = "foo" ++ t.srcObject.Generation = 17 ++ t.srcObject.MetaGeneration = 23 ++ t.srcObject.CacheControl = "testCacheControl" ++ t.srcObject.ContentDisposition = "inline" ++ t.srcObject.ContentEncoding = "gzip" ++ t.srcObject.ContentType = "text/plain" ++ t.srcObject.CustomTime = "2022-04-02T00:30:00Z" ++ t.srcObject.EventBasedHold = true ++ t.srcObject.StorageClass = "STANDARD" ++ t.srcObject.Metadata = map[string]string { ++ "test_key": "test_value", ++ } ++ t.mtime = time.Now().Add(123 * time.Second).UTC() ++ ++ var req *gcs.CreateObjectRequest ++ ExpectCall(t.bucket, "CreateObject")(Any(), Any()). ++ WillOnce(DoAll(SaveArg(1, &req), Return(nil, errors.New("")))) ++ ++ ++ t.call() ++ ++ AssertNe(nil, req) ++ ExpectEq(t.srcObject.Name, req.Name) ++ ExpectEq(t.srcObject.CacheControl, req.CacheControl) ++ ExpectEq(t.srcObject.ContentDisposition, req.ContentDisposition) ++ ExpectEq(t.srcObject.ContentEncoding, req.ContentEncoding) ++ ExpectEq(t.srcObject.ContentType, req.ContentType) ++ ExpectEq(t.srcObject.CustomTime, req.CustomTime) ++ ExpectEq(t.srcObject.EventBasedHold, req.EventBasedHold) ++ ++ ExpectEq(2, len(req.Metadata)) ++ ExpectEq(t.mtime.Format(time.RFC3339Nano), req.Metadata["gcsfuse_mtime"]) ++ ExpectEq("test_value", req.Metadata["test_key"]) ++} ++ + //////////////////////////////////////////////////////////////////////// + // fakeObjectCreator + //////////////////////////////////////////////////////////////////////// +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+3Rz4rCMBAG8Jx9ikH24B7aJrWpJw/iA3hYz0qbBP+giaSp7MI+/NZeFEG9KOL6 ++/S4zJAOZ8MVlvdroubH7hD0KbwykbGvjvLa9kClPc5mKPGNciJxnjOTDNjpRV6HwRMw7F67N3bp/ ++UfEx/2CqMFduuy2sjqvl/d64lb/oD87yz/JUMOL3W+GyN89faWqDL43uLBwdWor2FClX2zAUFCcr ++G4y3xSZZqOo7ocjXlrqz3rSZHO12xupJuTYqjL0pgvO/h/OvH6uM//zodp79PQAAAAAAAAAAAAAA ++AAAAAACAf+0P6UaZJwAoAAA= +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-000104/tests/test.sh b/tasks/format-code-task-000104/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..bc108566f9e679b99c728982c3cd432c547dfe2d --- /dev/null +++ b/tasks/format-code-task-000104/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/gcsx/append_object_creator_test.go +internal/gcsx/syncer_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-000104/tests/test_command.sh b/tasks/format-code-task-000104/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000104/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-000105/environment/Dockerfile b/tasks/format-code-task-000105/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8d40ea06708eda4ea96587dba2f476c772337e1f --- /dev/null +++ b/tasks/format-code-task-000105/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:13a78ffaf2a5084faeac5b58b0c54823c7f97427724b7b44f73a00b2c5f3937a diff --git a/tasks/format-code-task-000105/environment/setup/files/blocklist b/tasks/format-code-task-000105/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000105/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-000105/environment/setup/setup.sh b/tasks/format-code-task-000105/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000105/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-000105/tests/test.patch b/tasks/format-code-task-000105/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..f2eea2d3d9a9c9d9b17bf9eff8963682e9e16d24 --- /dev/null +++ b/tasks/format-code-task-000105/tests/test.patch @@ -0,0 +1,109 @@ +diff --git a/pkg/util/fs_util_test.go b/pkg/util/fs_util_test.go +index 20f80820..23badddf 100644 +--- a/pkg/util/fs_util_test.go ++++ b/pkg/util/fs_util_test.go +@@ -536,3 +536,82 @@ func TestExtractFile(t *testing.T) { + }) + } + } ++ ++func Test_CopySymlink(t *testing.T) { ++ type setup func(t *testing.T, dest string) ++ tests := []struct { ++ name string ++ linkTgt string ++ setupDest setup ++ }{ ++ { ++ name: "dest does not exist, relative target", ++ linkTgt: "the-target", ++ setupDest: func(t *testing.T, dest string) { ++ ++ }, ++ }, ++ { ++ name: "dest does not exist, absolute target", ++ linkTgt: "/usr/local/lib/libpython3.7m.so", ++ setupDest: func(t *testing.T, dest string) { ++ ++ }, ++ }, ++ { ++ name: "dest is existing symlink, relative target", ++ linkTgt: "the-target", ++ setupDest: func(t *testing.T, dest string) { ++ if err := os.Symlink("some-other-target", dest); err != nil { ++ t.Fatal(err) ++ } ++ }, ++ }, ++ { ++ name: "dest is existing symlink, absolute target", ++ linkTgt: "/usr/local/lib/libpython3.7m.so", ++ setupDest: func(t *testing.T, dest string) { ++ if err := os.Symlink("/some/other/path", dest); err != nil { ++ t.Fatal(err) ++ } ++ }, ++ }, ++ } ++ for _, tt := range tests { ++ t.Run(tt.name, func(t *testing.T) { ++ testDir, err := ioutil.TempDir("", "copysymlink") ++ if err != nil { ++ t.Fatalf("err creating tempdir: %v", err) ++ } ++ defer os.RemoveAll(testDir) ++ ++ src := filepath.Join(testDir, "src.link") ++ if err := os.Symlink(tt.linkTgt, src); err != nil { ++ t.Fatalf("err creating src symlink: %v", err) ++ } ++ ++ dest := filepath.Join(testDir, "dest.link") ++ tt.setupDest(t, dest) ++ ++ if err := CopySymlink(src, dest); err != nil { ++ t.Fatalf("CopySymlink returned error: %v", err) ++ } ++ ++ fi, err := os.Lstat(dest) ++ if err != nil { ++ t.Fatalf("Lstat(dest) failed: %v", err) ++ } ++ if fi.Mode()&os.ModeSymlink == 0 { ++ t.Fatalf("expected dest to be a symlink, mode=%v", fi.Mode()) ++ } ++ ++ got, err := os.Readlink(dest) ++ if err != nil { ++ t.Fatalf("Readlink(dest) failed: %v", err) ++ } ++ if got != tt.linkTgt { ++ t.Errorf("symlink target mismatch: got %q, want %q", got, tt.linkTgt) ++ } ++ }) ++ } ++} +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..1ad83dfd +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["ln -sfn $(pwd) /go/src/github.com/GoogleContainerTools/kaniko && cd /go/src/github.com/GoogleContainerTools/kaniko && GO111MODULE=off go test -run Test_CopySymlink -v ./pkg/util/"] ++} +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 ++ln -sfn $(pwd) /go/src/github.com/GoogleContainerTools/kaniko && cd /go/src/github.com/GoogleContainerTools/kaniko && GO111MODULE=off go test -run Test_CopySymlink -v ./pkg/util/ ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000105/tests/test.sh b/tasks/format-code-task-000105/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..a46c48f878d16bf63f7e3ce572e6f3edd05e32b1 --- /dev/null +++ b/tasks/format-code-task-000105/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/fs_util_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-000105/tests/test_command.sh b/tasks/format-code-task-000105/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000105/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-000156/environment/Dockerfile b/tasks/format-code-task-000156/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..3ae0afc4d356eab55181caf93fc12f4be6fd6f39 --- /dev/null +++ b/tasks/format-code-task-000156/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:0d3abf1cdb3cf0f0ba2304b4d07b0e7e3854b3c5cc4563843fde832a8e2c14bc diff --git a/tasks/format-code-task-000156/environment/setup/files/blocklist b/tasks/format-code-task-000156/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000156/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-000156/environment/setup/setup.sh b/tasks/format-code-task-000156/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000156/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-000156/tests/test.patch b/tasks/format-code-task-000156/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..a1dbb5a44ef06c6ef93b4d09311f601c2fb07609 --- /dev/null +++ b/tasks/format-code-task-000156/tests/test.patch @@ -0,0 +1,108 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..140d7c5 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest tests/atest/rules/errors/variables_import_with_args/ tests/atest/rules/duplications/duplicated_variables_import/"] ++} +diff --git a/tests/atest/rules/duplications/duplicated_variables_import/expected_output_args.txt b/tests/atest/rules/duplications/duplicated_variables_import/expected_output_args.txt +new file mode 100644 +index 0000000..098b9a6 +--- /dev/null ++++ b/tests/atest/rules/duplications/duplicated_variables_import/expected_output_args.txt +@@ -0,0 +1 @@ ++test_args.robot:3:1 [W] 0807 Duplicated variables import with path 'variables.robot' (first occurrence in line 2) +diff --git a/tests/atest/rules/duplications/duplicated_variables_import/test_args.robot b/tests/atest/rules/duplications/duplicated_variables_import/test_args.robot +new file mode 100644 +index 0000000..c7df222 +--- /dev/null ++++ b/tests/atest/rules/duplications/duplicated_variables_import/test_args.robot +@@ -0,0 +1,10 @@ ++*** Settings *** ++Variables variables.robot arg ++Variables variables.robot arg ++Variables vars.yaml arg1 ++Variables vars.yaml arg1 ++ ++ ++*** Test Cases *** ++Test ++ Log message +diff --git a/tests/atest/rules/duplications/duplicated_variables_import/test_rule.py b/tests/atest/rules/duplications/duplicated_variables_import/test_rule.py +index 6f32193..72ee026 100644 +--- a/tests/atest/rules/duplications/duplicated_variables_import/test_rule.py ++++ b/tests/atest/rules/duplications/duplicated_variables_import/test_rule.py +@@ -4,3 +4,6 @@ from tests.atest.utils import RuleAcceptance + class TestRuleAcceptance(RuleAcceptance): + def test_rule(self): + self.check_rule(src_files=["test.robot"], expected_file="expected_output.txt") ++ ++ def test_duplicated_with_args(self): ++ self.check_rule(src_files=["test_args.robot"], expected_file="expected_output_args.txt") +diff --git a/tests/atest/rules/errors/variables_import_with_args/expected_output.txt b/tests/atest/rules/errors/variables_import_with_args/expected_output.txt +index ab260a4..a62e5a0 100644 +--- a/tests/atest/rules/errors/variables_import_with_args/expected_output.txt ++++ b/tests/atest/rules/errors/variables_import_with_args/expected_output.txt +@@ -1,2 +1 @@ +-test.robot:11:1 [E] 0404 Robot and YAML variable files do not take arguments +-test.robot:16:1 [E] 0404 Robot and YAML variable files do not take arguments +\ No newline at end of file ++test.robot:11:1 [E] 0404 YAML variable files do not take arguments +diff --git a/tests/atest/rules/errors/variables_import_with_args/expected_output_module.txt b/tests/atest/rules/errors/variables_import_with_args/expected_output_module.txt +new file mode 100644 +index 0000000..6ac1dab +--- /dev/null ++++ b/tests/atest/rules/errors/variables_import_with_args/expected_output_module.txt +@@ -0,0 +1,2 @@ ++test_module.robot:4:1 [E] 0404 YAML variable files do not take arguments ++test_module.robot:5:1 [E] 0404 YAML variable files do not take arguments +diff --git a/tests/atest/rules/errors/variables_import_with_args/test_module.robot b/tests/atest/rules/errors/variables_import_with_args/test_module.robot +new file mode 100644 +index 0000000..240b7b8 +--- /dev/null ++++ b/tests/atest/rules/errors/variables_import_with_args/test_module.robot +@@ -0,0 +1,18 @@ ++*** Settings *** ++Variables variables ${ENVIRON} ++Variables other.py arg1 ++Variables vars.yaml arg1 ++Variables vars.yml arg2 ++Variables vars.json arg3 ++Variables variables.robot arg ++Variables no_args.yaml ++Variables no_args ++ ++ ++*** Variables *** ++${ENVIRON} dev ++ ++ ++*** Test Cases *** ++Test ++ Log message +diff --git a/tests/atest/rules/errors/variables_import_with_args/test_rule.py b/tests/atest/rules/errors/variables_import_with_args/test_rule.py +index 6f32193..cd26eec 100644 +--- a/tests/atest/rules/errors/variables_import_with_args/test_rule.py ++++ b/tests/atest/rules/errors/variables_import_with_args/test_rule.py +@@ -4,3 +4,6 @@ from tests.atest.utils import RuleAcceptance + class TestRuleAcceptance(RuleAcceptance): + def test_rule(self): + self.check_rule(src_files=["test.robot"], expected_file="expected_output.txt") ++ ++ def test_module_and_extensions(self): ++ self.check_rule(src_files=["test_module.robot"], expected_file="expected_output_module.txt") +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 tests/atest/rules/duplications/duplicated_variables_import/test_rule.py::TestRuleAcceptance::test_duplicated_with_args tests/atest/rules/errors/variables_import_with_args/test_rule.py::TestRuleAcceptance::test_module_and_extensions ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000156/tests/test.sh b/tasks/format-code-task-000156/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..564d652571bf6790652c01456b3a7c12e93301ed --- /dev/null +++ b/tasks/format-code-task-000156/tests/test.sh @@ -0,0 +1,45 @@ +#!/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/atest/rules/duplications/duplicated_variables_import/expected_output_args.txt +tests/atest/rules/duplications/duplicated_variables_import/test_args.robot +tests/atest/rules/duplications/duplicated_variables_import/test_rule.py +tests/atest/rules/errors/variables_import_with_args/expected_output.txt +tests/atest/rules/errors/variables_import_with_args/expected_output_module.txt +tests/atest/rules/errors/variables_import_with_args/test_module.robot +tests/atest/rules/errors/variables_import_with_args/test_rule.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-000156/tests/test_command.sh b/tasks/format-code-task-000156/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000156/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-000158/environment/Dockerfile b/tasks/format-code-task-000158/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..992c5e9f888a3509301de6bf2a98995e934e74a8 --- /dev/null +++ b/tasks/format-code-task-000158/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:b93f3a9056fc4647d911b2488423c78764f54f2209971d712c23e7546bc28880 diff --git a/tasks/format-code-task-000158/environment/setup/files/blocklist b/tasks/format-code-task-000158/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000158/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-000158/environment/setup/setup.sh b/tasks/format-code-task-000158/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000158/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-000158/tests/test.patch b/tasks/format-code-task-000158/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..7f6cf486a0214767ec73350be287bbebd1ac8ebb --- /dev/null +++ b/tasks/format-code-task-000158/tests/test.patch @@ -0,0 +1,114 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..48178e4 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest tests/test_simplify.py -k sim117 -v"] ++} +diff --git a/tests/test_simplify.py b/tests/test_simplify.py +index 006c4b0..981016c 100644 +--- a/tests/test_simplify.py ++++ b/tests/test_simplify.py +@@ -490,3 +490,87 @@ def test_sim300_int(): + assert ret == { + "1:0 SIM300 Use 'age == 42' instead of '42 == age' (Yoda-conditions)" + } ++ ++ ++def test_sim117_basic(): ++ ret = _results( ++ """with A() as a: ++ with B() as b: ++ print('hello')""" ++ ) ++ assert ret == { ++ "1:0 SIM117 Use 'with A() as a, B() as b:' " ++ "instead of multiple with statements" ++ } ++ ++ ++def test_sim117_not_triggered_single_with(): ++ ret = _results( ++ """with A() as a: ++ print('hello')""" ++ ) ++ assert ret == set() ++ ++ ++def test_sim117_not_triggered_extra_code_after(): ++ ret = _results( ++ """with A() as a: ++ with B() as b: ++ print('hello') ++ print('after')""" ++ ) ++ assert ret == set() ++ ++ ++def test_sim117_not_triggered_extra_code_before(): ++ ret = _results( ++ """with A() as a: ++ print('first') ++ with B() as b: ++ print('hello')""" ++ ) ++ assert ret == set() ++ ++ ++def test_sim117_triple_nesting(): ++ ret = _results( ++ """with A() as a: ++ with B() as b: ++ with C() as c: ++ print('hi')""" ++ ) ++ assert ret == { ++ ( ++ "1:0 SIM117 Use 'with A() as a, B() as b:' " ++ "instead of multiple with statements" ++ ), ++ ( ++ "2:4 SIM117 Use 'with B() as b, C() as c:' " ++ "instead of multiple with statements" ++ ), ++ } ++ ++ ++def test_sim117_multi_items_inner(): ++ ret = _results( ++ """with A() as a: ++ with B() as b, C() as c: ++ print('hi')""" ++ ) ++ assert ret == { ++ "1:0 SIM117 Use 'with A() as a, B() as b, C() as c:' " ++ "instead of multiple with statements" ++ } ++ ++ ++def test_sim117_long_line_still_reports(): ++ ret = _results( ++ """with SomeVeryLongContextManagerName() as long_alias_name_one: ++ with AnotherLongContextManagerName() as long_alias_name_two: ++ print('hi')""" ++ ) ++ assert ret == { ++ "1:0 SIM117 Use 'with SomeVeryLongContextManagerName() " ++ "as long_alias_name_one, AnotherLongContextManagerName() " ++ "as long_alias_name_two:' instead of multiple with statements" ++ } +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 tests/test_simplify.py::test_sim117_basic tests/test_simplify.py::test_sim117_not_triggered_single_with tests/test_simplify.py::test_sim117_not_triggered_extra_code_after tests/test_simplify.py::test_sim117_not_triggered_extra_code_before tests/test_simplify.py::test_sim117_triple_nesting tests/test_simplify.py::test_sim117_multi_items_inner tests/test_simplify.py::test_sim117_long_line_still_reports ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000158/tests/test.sh b/tasks/format-code-task-000158/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..ba29d39114a81b0001d540934d929655949f6f62 --- /dev/null +++ b/tasks/format-code-task-000158/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_simplify.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-000158/tests/test_command.sh b/tasks/format-code-task-000158/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000158/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-000160/environment/Dockerfile b/tasks/format-code-task-000160/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..613245b5e8d2c52c0e578c6678d51d9318ea5bdd --- /dev/null +++ b/tasks/format-code-task-000160/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:fda2ea380bd2b2f7bc4a8877cc070cdf2ce83aee588536c58e614460360ec13d diff --git a/tasks/format-code-task-000160/environment/setup/files/blocklist b/tasks/format-code-task-000160/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000160/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-000160/environment/setup/setup.sh b/tasks/format-code-task-000160/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000160/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-000160/tests/test.patch b/tasks/format-code-task-000160/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..9d12a2dd70e361a6eff4401fafb628443e0e6411 --- /dev/null +++ b/tasks/format-code-task-000160/tests/test.patch @@ -0,0 +1,101 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..5f27839 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest tests/test_simplify.py -k sim901 -v"] ++} +diff --git a/tests/test_simplify.py b/tests/test_simplify.py +index b61bc7c..3308fca 100644 +--- a/tests/test_simplify.py ++++ b/tests/test_simplify.py +@@ -878,3 +878,74 @@ else: + has_sim401 = True + assert msg == expected_proposal + assert has_sim401 ++ ++ ++import re as _re_sim901 ++ ++_SIM901_BOOL_RE = _re_sim901.compile( ++ r"^(\d+):(\d+) SIM\d+ Use '(?P.+)' instead of 'bool\((?P=inner)\)'$" ++) ++ ++ ++def _sim901_bool_warnings(ret): ++ """Return [(line, col, inner)] for any 'Use X instead of bool(X)' warning, ++ independent of the specific SIMxxx rule code chosen by the implementation. ++ The issue does not pin down a code, so any unique SIM code is acceptable. ++ """ ++ out = [] ++ for msg in ret: ++ m = _SIM901_BOOL_RE.match(msg) ++ if m: ++ out.append((int(m.group(1)), int(m.group(2)), m.group("inner"))) ++ return out ++ ++ ++def test_sim901_bool_eq(): ++ """Issue example: bool(a == b) should report a 'use comparison directly' warning.""" ++ ret = _results("bool(a == b)") ++ assert _sim901_bool_warnings(ret) == [(1, 0, "a == b")] ++ ++ ++def test_sim901_bool_lt(): ++ ret = _results("bool(a < b)") ++ assert _sim901_bool_warnings(ret) == [(1, 0, "a < b")] ++ ++ ++def test_sim901_bool_ne(): ++ ret = _results("bool(a != b)") ++ assert _sim901_bool_warnings(ret) == [(1, 0, "a != b")] ++ ++ ++def test_sim901_bool_in(): ++ ret = _results("bool(a in b)") ++ assert _sim901_bool_warnings(ret) == [(1, 0, "a in b")] ++ ++ ++def test_sim901_no_trigger_on_plain_compare(): ++ """A bare comparison (no bool wrap) must not trigger any bool() warning.""" ++ ret = _results("a == b") ++ assert _sim901_bool_warnings(ret) == [] ++ ++ ++def test_sim901_no_trigger_on_bool_of_name(): ++ """bool(x) where x isn't a comparison must not trigger.""" ++ ret = _results("bool(x)") ++ assert _sim901_bool_warnings(ret) == [] ++ ++ ++def test_sim901_no_trigger_on_bool_of_call(): ++ """bool(some_call()) must not trigger.""" ++ ret = _results("bool(foo())") ++ assert _sim901_bool_warnings(ret) == [] ++ ++ ++def test_sim901_no_trigger_on_bool_of_not(): ++ """bool(not x) must not trigger - issue scope is 'bool(comparison)' only.""" ++ ret = _results("bool(not x)") ++ assert _sim901_bool_warnings(ret) == [] ++ ++ ++def test_sim901_no_trigger_on_nested_bool(): ++ """bool(bool(x)) must not trigger - issue scope is 'bool(comparison)' only.""" ++ ret = _results("bool(bool(x))") ++ assert _sim901_bool_warnings(ret) == [] +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 tests/test_simplify.py::test_sim901_bool_eq tests/test_simplify.py::test_sim901_bool_lt tests/test_simplify.py::test_sim901_bool_ne tests/test_simplify.py::test_sim901_bool_in tests/test_simplify.py::test_sim901_no_trigger_on_plain_compare tests/test_simplify.py::test_sim901_no_trigger_on_bool_of_name tests/test_simplify.py::test_sim901_no_trigger_on_bool_of_call tests/test_simplify.py::test_sim901_no_trigger_on_bool_of_not tests/test_simplify.py::test_sim901_no_trigger_on_nested_bool ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000160/tests/test.sh b/tasks/format-code-task-000160/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..ba29d39114a81b0001d540934d929655949f6f62 --- /dev/null +++ b/tasks/format-code-task-000160/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_simplify.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-000160/tests/test_command.sh b/tasks/format-code-task-000160/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000160/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-000167/environment/Dockerfile b/tasks/format-code-task-000167/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..15ada21becd51ab4760ae9eef1baf84a1d69b4a7 --- /dev/null +++ b/tasks/format-code-task-000167/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:d466ad2b4e56ed8cdb07817c6185c8ebdfa949d4faeb96b0605a6996fc125de6 diff --git a/tasks/format-code-task-000167/environment/setup/files/blocklist b/tasks/format-code-task-000167/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000167/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-000167/environment/setup/setup.sh b/tasks/format-code-task-000167/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000167/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-000167/tests/test.patch b/tasks/format-code-task-000167/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..5ed7e6fbb9954b7729d02d875801eb32756d0cc1 --- /dev/null +++ b/tasks/format-code-task-000167/tests/test.patch @@ -0,0 +1,148 @@ +diff --git a/components/modal/modal.spec.ts b/components/modal/modal.spec.ts +index e8ffe1779..7d25f4abe 100644 +--- a/components/modal/modal.spec.ts ++++ b/components/modal/modal.spec.ts +@@ -552,8 +552,14 @@ describe('NzModal', () => { + fixture.detectChanges(); + + const modal = overlayContainerElement.querySelector('nz-modal-container') as HTMLElement; ++ const mask = overlayContainerElement.querySelector('.ant-modal-mask') as HTMLElement; ++ const readZIndex = (element: HTMLElement): string => { ++ const computed = getComputedStyle(element).zIndex; ++ return computed === 'auto' ? element.style.zIndex : computed; ++ }; + +- expect(modal.style.zIndex).toBe('1001'); ++ expect(readZIndex(modal)).toBe('1001'); ++ expect(readZIndex(mask)).toBe('1001'); + + modalRef.updateConfig({ + nzZIndex: 1100 +@@ -561,7 +567,79 @@ describe('NzModal', () => { + fixture.detectChanges(); + flushMicrotasks(); + +- expect(modal.style.zIndex).toBe('1100'); ++ expect(readZIndex(modal)).toBe('1100'); ++ expect(readZIndex(mask)).toBe('1100'); ++ ++ modalRef.close(); ++ fixture.detectChanges(); ++ flush(); ++ })); ++ ++ it('should apply z-index to the corresponding mask in stacked modals', fakeAsync(() => { ++ const firstModalRef = modalService.create({ ++ nzContent: 'first modal', ++ nzZIndex: 1001 ++ }); ++ fixture.detectChanges(); ++ flushMicrotasks(); ++ ++ const secondModalRef = modalService.create({ ++ nzContent: 'second modal', ++ nzZIndex: 1307 ++ }); ++ fixture.detectChanges(); ++ flushMicrotasks(); ++ ++ const modals = Array.from(overlayContainerElement.querySelectorAll('nz-modal-container')) as HTMLElement[]; ++ const masks = Array.from(overlayContainerElement.querySelectorAll('.ant-modal-mask')) as HTMLElement[]; ++ const readZIndex = (element: HTMLElement): string => { ++ const computed = getComputedStyle(element).zIndex; ++ return computed === 'auto' ? element.style.zIndex : computed; ++ }; ++ ++ expect(modals.length).toBe(2); ++ expect(masks.length).toBe(2); ++ expect(readZIndex(modals[0])).toBe('1001'); ++ expect(readZIndex(masks[0])).toBe('1001'); ++ expect(readZIndex(modals[1])).toBe('1307'); ++ expect(readZIndex(masks[1])).toBe('1307'); ++ expect(Number(readZIndex(masks[1]))).toBeGreaterThan(Number(readZIndex(modals[0]))); ++ ++ firstModalRef.close(); ++ secondModalRef.close(); ++ fixture.detectChanges(); ++ flush(); ++ })); ++ ++ it('should keep mask z-index when nzMaskStyle is applied or updated', fakeAsync(() => { ++ const modalRef = modalService.create({ ++ nzContent: 'modal with mask style', ++ nzZIndex: 1200, ++ nzMaskStyle: { ++ backgroundColor: 'rgba(0, 0, 0, 0.2)' ++ } ++ }); ++ fixture.detectChanges(); ++ flushMicrotasks(); ++ ++ const mask = overlayContainerElement.querySelector('.ant-modal-mask') as HTMLElement; ++ const readZIndex = (element: HTMLElement): string => { ++ const computed = getComputedStyle(element).zIndex; ++ return computed === 'auto' ? element.style.zIndex : computed; ++ }; ++ ++ expect(readZIndex(mask)).toBe('1200'); ++ ++ modalRef.updateConfig({ ++ nzMaskStyle: { ++ backgroundColor: 'rgba(0, 0, 0, 0.3)' ++ } ++ }); ++ fixture.detectChanges(); ++ flushMicrotasks(); ++ ++ expect(getComputedStyle(mask).backgroundColor).toBe('rgba(0, 0, 0, 0.3)'); ++ expect(readZIndex(mask)).toBe('1200'); + + modalRef.close(); + fixture.detectChanges(); +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 ++ ++ ++ ++dev-switch node 20 ++ ++ ++apt-get install -y -qq libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 libxkbcommon0 \ ++ libxcomposite1 libxdamage1 libxrandr2 libgbm1 libpango-1.0-0 libcairo2 \ ++ libasound2t64 libnspr4 libnss3 libxshmfence1 libxfixes3 libgtk-3-0 2>/dev/null || true ++ ++ ++npm install --legacy-peer-deps 2>&1 | tail -5 ++ ++ ++sed -i 's/statements.push.apply(statements, tslib_1.__spread(c.statements));/if (c.statements) { statements.push.apply(statements, tslib_1.__spread(c.statements)); }/' \ ++ node_modules/@angular/compiler-cli/ngcc/src/rendering/renderer.js ++ ++ ++npm install tslib@2.0.3 --legacy-peer-deps 2>&1 | tail -3 ++ ++ ++rm -rf node_modules/.cache ++npx ngcc --properties es2015 browser module main --first-only --create-ivy-entry-points 2>&1 | tail -5 ++ ++export NODE_OPTIONS=--openssl-legacy-provider ++ ++ ++case "${1:-}" in ++ base) ++ node node_modules/.bin/ng test --no-watch --no-progress --browsers=ChromeHeadlessCI --include='**/modal.spec.ts' ++ ;; ++ new) ++ node node_modules/.bin/ng test --no-watch --no-progress --browsers=ChromeHeadlessCI --include='**/modal.spec.ts' ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-000167/tests/test.sh b/tasks/format-code-task-000167/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..be897b7dbb826896134209949bfbeea32112fe5c --- /dev/null +++ b/tasks/format-code-task-000167/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' +components/modal/modal.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-000167/tests/test_command.sh b/tasks/format-code-task-000167/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-000167/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-000169/environment/Dockerfile b/tasks/format-code-task-000169/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..967a74d32c2bc8cc8d3819fb528289aab9cece9d --- /dev/null +++ b/tasks/format-code-task-000169/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:8f560c1b3bc6df40649ee985b85d04675f778f29cccfafe9ed725b16ab06c600 diff --git a/tasks/format-code-task-000169/environment/setup/files/blocklist b/tasks/format-code-task-000169/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000169/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-000169/environment/setup/setup.sh b/tasks/format-code-task-000169/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000169/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-000169/tests/test.patch b/tasks/format-code-task-000169/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..346504782a316efc91869994410e7c423e9f23bc --- /dev/null +++ b/tasks/format-code-task-000169/tests/test.patch @@ -0,0 +1,227 @@ +diff --git a/test/test_recipe.py b/test/test_recipe.py +index e28808c..dd0ed67 100644 +--- a/test/test_recipe.py ++++ b/test/test_recipe.py +@@ -21,8 +21,12 @@ from __future__ import print_function + + import logging # pylint: disable=unused-import + import os ++import shutil ++import tempfile ++import uuid + import unittest + ++import hpccm + from hpccm.common import container_type + from hpccm.recipe import recipe + +@@ -253,3 +257,181 @@ RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https:// + rm -rf /var/tmp/openmpi-2.1.2.tar.bz2 /var/tmp/openmpi-2.1.2 + ENV LD_LIBRARY_PATH=/usr/local/openmpi/lib:$LD_LIBRARY_PATH \ + PATH=/usr/local/openmpi/bin:$PATH''') ++ ++ ++ def _write_recipe(self, directory, filename, contents): ++ """Create a temporary recipe fixture and return its path.""" ++ path = os.path.join(directory, filename) ++ parent = os.path.dirname(path) ++ if not os.path.isdir(parent): ++ os.makedirs(parent) ++ with open(path, 'w') as f: ++ f.write(contents) ++ return path ++ ++ def test_include_stage0_and_shared_values(self): ++ """included recipes contribute Stage0 state and shared values""" ++ tmpdir = tempfile.mkdtemp() ++ try: ++ fragment_name = 'shared-{}.py'.format(uuid.uuid4().hex) ++ image = 'stage0-image-{}:latest'.format(uuid.uuid4().hex) ++ package = 'stage0-package-{}'.format(uuid.uuid4().hex) ++ self._write_recipe(tmpdir, fragment_name, ++ "Stage0 += baseimage(image={!r})\n" ++ "extra_package = {!r}\n".format(image, package)) ++ main = self._write_recipe( ++ tmpdir, 'main.py', ++ "hpccm.include({!r})\n" ++ "Stage0 += packages(ospackages=[extra_package])\n".format( ++ fragment_name)) ++ ++ result = recipe(main) ++ ++ self.assertIn('FROM {}'.format(image), result) ++ self.assertIn(package, result) ++ finally: ++ shutil.rmtree(tmpdir) ++ ++ def test_include_arbitrary_sibling_recipe_name(self): ++ """include works for ordinary sibling recipe names""" ++ tmpdir = tempfile.mkdtemp() ++ try: ++ fragment_name = 'common-build-{}.py'.format(uuid.uuid4().hex) ++ image = 'sibling-image-{}:latest'.format(uuid.uuid4().hex) ++ package = 'sibling-package-{}'.format(uuid.uuid4().hex) ++ self._write_recipe(tmpdir, fragment_name, ++ "Stage0 += baseimage(image={!r})\n" ++ "custom_package = {!r}\n".format( ++ image, package)) ++ main = self._write_recipe( ++ tmpdir, 'main.py', ++ "hpccm.include({!r})\n" ++ "Stage0 += packages(ospackages=[custom_package])\n".format( ++ fragment_name)) ++ ++ result = recipe(main) ++ ++ self.assertIn('FROM {}'.format(image), result) ++ self.assertIn(package, result) ++ finally: ++ shutil.rmtree(tmpdir) ++ ++ def test_include_stage1_singularity_output(self): ++ """included recipes contribute Stage1 content for Singularity""" ++ tmpdir = tempfile.mkdtemp() ++ try: ++ fragment_name = 'stage1-{}.py'.format(uuid.uuid4().hex) ++ image = 'stage1-image-{}:latest'.format(uuid.uuid4().hex) ++ package = 'stage1-package-{}'.format(uuid.uuid4().hex) ++ self._write_recipe(tmpdir, fragment_name, ++ "Stage1 += baseimage(image={!r})\n".format( ++ image)) ++ main = self._write_recipe( ++ tmpdir, 'main.py', ++ "hpccm.include({!r})\n" ++ "Stage1 += packages(ospackages=[{!r}])\n".format( ++ fragment_name, package)) ++ ++ result = recipe(main, ctype=container_type.SINGULARITY, ++ singularity_version='3.2') ++ ++ self.assertIn('From: {}'.format(image), result) ++ self.assertIn(package, result) ++ finally: ++ shutil.rmtree(tmpdir) ++ ++ def test_include_relative_to_main_recipe_from_different_cwd(self): ++ """relative includes are resolved from the recipe file location""" ++ tmpdir = tempfile.mkdtemp() ++ old_cwd = os.getcwd() ++ try: ++ recipe_dir = os.path.join(tmpdir, 'recipes') ++ other_cwd = os.path.join(tmpdir, 'elsewhere') ++ os.makedirs(other_cwd) ++ fragment_name = os.path.join( ++ 'fragments', 'toolchain-{}.py'.format(uuid.uuid4().hex)) ++ image = 'relative-image-{}:latest'.format(uuid.uuid4().hex) ++ package = 'relative-package-{}'.format(uuid.uuid4().hex) ++ self._write_recipe( ++ recipe_dir, fragment_name, ++ "Stage0 += baseimage(image={!r})\n".format(image)) ++ main = self._write_recipe( ++ recipe_dir, 'main.py', ++ "hpccm.include({!r})\n" ++ "Stage0 += packages(ospackages=[{!r}])\n".format( ++ fragment_name, package)) ++ ++ os.chdir(other_cwd) ++ result = recipe(main) ++ ++ self.assertIn('FROM {}'.format(image), result) ++ self.assertIn(package, result) ++ finally: ++ os.chdir(old_cwd) ++ shutil.rmtree(tmpdir) ++ ++ def test_include_absolute_path(self): ++ """absolute include paths are used as absolute paths""" ++ tmpdir = tempfile.mkdtemp() ++ try: ++ image = 'absolute-image-{}:latest'.format(uuid.uuid4().hex) ++ package = 'absolute-package-{}'.format(uuid.uuid4().hex) ++ fragment = self._write_recipe( ++ tmpdir, 'absolute-{}.py'.format(uuid.uuid4().hex), ++ "Stage0 += baseimage(image={!r})\n".format(image)) ++ main_dir = os.path.join(tmpdir, 'main-recipe') ++ main = self._write_recipe( ++ main_dir, 'main.py', ++ "hpccm.include({!r})\n" ++ "Stage0 += packages(ospackages=[{!r}])\n".format( ++ fragment, package)) ++ ++ result = recipe(main) ++ ++ self.assertIn('FROM {}'.format(image), result) ++ self.assertIn(package, result) ++ finally: ++ shutil.rmtree(tmpdir) ++ ++ def test_include_missing_default_exits(self): ++ """missing includes exit by default""" ++ tmpdir = tempfile.mkdtemp() ++ try: ++ missing = os.path.join( ++ tmpdir, 'missing-{}.py'.format(uuid.uuid4().hex)) ++ with self.assertRaises(SystemExit) as context: ++ hpccm.include(missing) ++ self.assertEqual(context.exception.code, 1) ++ finally: ++ shutil.rmtree(tmpdir) ++ ++ def test_include_raise_exceptions_propagates(self): ++ """raise_exceptions=True propagates included recipe errors""" ++ tmpdir = tempfile.mkdtemp() ++ try: ++ error_name = 'IncludeRaised{}'.format(uuid.uuid4().hex) ++ bad = self._write_recipe( ++ tmpdir, 'bad-{}.py'.format(uuid.uuid4().hex), ++ "class {0}(Exception):\n" ++ " pass\n" ++ "raise {0}\n".format(error_name)) ++ ++ with self.assertRaises(Exception) as context: ++ hpccm.include(bad, raise_exceptions=True) ++ self.assertEqual(type(context.exception).__name__, error_name) ++ finally: ++ shutil.rmtree(tmpdir) ++ ++ def test_include_runtime_error_default_exits(self): ++ """runtime errors in included recipes exit by default""" ++ tmpdir = tempfile.mkdtemp() ++ try: ++ bad = self._write_recipe( ++ tmpdir, 'runtime-{}.py'.format(uuid.uuid4().hex), ++ "raise RuntimeError()\n") ++ ++ with self.assertRaises(SystemExit) as context: ++ hpccm.include(bad) ++ self.assertEqual(context.exception.code, 1) ++ finally: ++ shutil.rmtree(tmpdir) +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 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++ ++dev-switch python3 3.11 ++python3 -m pip install -e . --no-input ++ ++ ++case "${1:-}" in ++ base) ++ python3 -m pytest test/test_recipe.py -v \ ++ -k 'not test_include_stage0_and_shared_values and not test_include_arbitrary_sibling_recipe_name and not test_include_stage1_singularity_output and not test_include_relative_to_main_recipe_from_different_cwd and not test_include_absolute_path and not test_include_missing_default_exits and not test_include_raise_exceptions_propagates and not test_include_runtime_error_default_exits' ++ ;; ++ new) ++ python3 -m pytest test/test_recipe.py -v \ ++ -k 'test_include_stage0_and_shared_values or test_include_arbitrary_sibling_recipe_name or test_include_stage1_singularity_output or test_include_relative_to_main_recipe_from_different_cwd or test_include_absolute_path or test_include_missing_default_exits or test_include_raise_exceptions_propagates or test_include_runtime_error_default_exits' ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-000169/tests/test.sh b/tasks/format-code-task-000169/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..50dd34f3cfc5f628a10d600c1c312d11ac708f0a --- /dev/null +++ b/tasks/format-code-task-000169/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_recipe.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-000169/tests/test_command.sh b/tasks/format-code-task-000169/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-000169/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-000193/environment/Dockerfile b/tasks/format-code-task-000193/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ac47dd088e65d5106a2a937c83d306808bb7a97d --- /dev/null +++ b/tasks/format-code-task-000193/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:617c2e22bfbf34176a2903b7906302840e40d37630ef5be5c3d1e80bbc1c0f4c diff --git a/tasks/format-code-task-000193/environment/setup/files/blocklist b/tasks/format-code-task-000193/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000193/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-000193/environment/setup/setup.sh b/tasks/format-code-task-000193/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000193/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-000193/tests/test.patch b/tasks/format-code-task-000193/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..c022452267ef9a8491e1786b8361af9fd0762b67 --- /dev/null +++ b/tasks/format-code-task-000193/tests/test.patch @@ -0,0 +1,48 @@ +diff --git a/test/test_job.js b/test/test_job.js +index a3ea12792..a3a96b762 100644 +--- a/test/test_job.js ++++ b/test/test_job.js +@@ -83,6 +83,20 @@ describe('Job', function(){ + }); + }); + ++ describe('.update', function(){ ++ it('should allow updating job data', function(){ ++ return Job.create(queue, {foo: 'bar'}).then(function(job){ ++ return job.update({baz: 'qux'}).then(function(){ ++ return job; ++ }); ++ }).then(function(job){ ++ return Job.fromId(queue, job.id).then(function(job){ ++ expect(job.data).to.be.eql({baz: 'qux'}); ++ }); ++ }); ++ }); ++ }); ++ + describe('.remove', function () { + it('removes the job from redis', function(){ + return Job.create(queue, {foo: 'bar'}) +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+3SQUvDMBQH8J37KZ4MvHVdZrud3MkdvEzYwetom+eW0b6Wph1T9uHNWkVRdCAb ++Iv5/FJK+PpLQfwZJYzK9ZNkGvXMZOpMoakfn49jOVTRSo5GK1OSqN1Rq7EoUne1E7zS2jiuiXlUU ++9Xd9x77/UYO3/Gu29TIt8jwWPbDr0+1xLP9Qqdf8w3E4dvmHYxX2aHi6I3ztn+ffvwgSI0ES27WX ++amovQcLa8/o0E9tUTAvWxpJ7qkbEyMqrDgU/zQyV7pWmFGjeBtJkGY2ml4r2e+paLFdbrsj3dcx5 ++IeaJ6ZHtYelbcX/d9WsuWTRLalxdypzMywffl8KPG23qbvrQiP6002GlRSNUr5lciCuu6XB8ejAZ ++e/O7m9lyNr+/bktS7igv0nXsluOd6Rq7G78pksHGer8dBAAAAAAAAAAAAAAAAAAAAADADzwDdupg ++vwAoAAA= +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-000193/tests/test.sh b/tasks/format-code-task-000193/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..1cc8b0a444e937f7e79f42e015fee1345317d6b6 --- /dev/null +++ b/tasks/format-code-task-000193/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_job.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-000193/tests/test_command.sh b/tasks/format-code-task-000193/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000193/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-000194/environment/Dockerfile b/tasks/format-code-task-000194/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e96800a94d4de772a5e465da900e9e08ea3a495a --- /dev/null +++ b/tasks/format-code-task-000194/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:52e14c0e94af48e5159246533026245b7f64fafa1a77056ab33ab814e2549bdf diff --git a/tasks/format-code-task-000194/environment/setup/files/blocklist b/tasks/format-code-task-000194/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000194/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-000194/environment/setup/setup.sh b/tasks/format-code-task-000194/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000194/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-000194/tests/test.patch b/tasks/format-code-task-000194/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..50b8d997abe72fe9028f6c5d87ba0bfde4c8ebf3 --- /dev/null +++ b/tasks/format-code-task-000194/tests/test.patch @@ -0,0 +1,237 @@ +diff --git a/infra/bridge/test/event-validators.test.js b/infra/bridge/test/event-validators.test.js +new file mode 100644 +index 000000000..d3fcfc4f1 +--- /dev/null ++++ b/infra/bridge/test/event-validators.test.js +@@ -0,0 +1,208 @@ ++'use strict' ++ ++const chai = require('chai') ++const expect = chai.expect ++ ++const EventValidators = require('../src/utils/event-validators') ++const validateTwitter = EventValidators.TWITTER ++ ++ ++ ++function expectShareContent(result, content) { ++ expect(result).to.be.a('string') ++ expect(result.trim()).to.equal(content) ++} ++ ++describe('Twitter event validation', () => { ++ describe('FOLLOW', () => { ++ it('always validates to true', () => { ++ expect(validateTwitter({ type: 'FOLLOW', event: {} })).to.equal(true) ++ }) ++ }) ++ ++ describe('SHARE - existing behavior', () => { ++ it('accepts an exact match and returns the content', () => { ++ const content = 'Hello world' ++ const event = { text: 'Hello world', entities: { urls: [] } } ++ expectShareContent(validateTwitter({ type: 'SHARE', content, event }), content) ++ }) ++ ++ it('ignores leading/trailing whitespace differences', () => { ++ const content = 'Hello world' ++ const event = { text: ' Hello world ', entities: { urls: [] } } ++ expectShareContent(validateTwitter({ type: 'SHARE', content, event }), content) ++ }) ++ ++ it('rejects content that does not match', () => { ++ const event = { text: 'Something else entirely', entities: { urls: [] } } ++ expect( ++ validateTwitter({ type: 'SHARE', content: 'Hello world', event }) ++ ).to.equal(false) ++ }) ++ ++ it('expands shortened t.co URLs before comparing', () => { ++ const content = 'Check out http://www.originprotocol.com now' ++ const event = { ++ text: 'Check out https://t.co/abc123 now', ++ entities: { ++ urls: [ ++ { url: 'https://t.co/abc123', expanded_url: 'http://www.originprotocol.com' } ++ ] ++ } ++ } ++ expectShareContent(validateTwitter({ type: 'SHARE', content, event }), content) ++ }) ++ ++ it('uses the extended payload full text for truncated tweets', () => { ++ const content = ++ 'This is a very long tweet body that got truncated by the API for sure' ++ const event = { ++ text: 'This is a very long tweet body that got truncated by the…', ++ extended_tweet: { ++ full_text: ++ 'This is a very long tweet body that got truncated by the API for sure', ++ entities: { urls: [] } ++ } ++ } ++ expectShareContent(validateTwitter({ type: 'SHARE', content, event }), content) ++ }) ++ ++ it('HTML-decodes the tweet text before comparing', () => { ++ const content = `Buy & sell on Origin's ` ++ const event = { ++ text: `Buy & sell on Origin's <marketplace>`, ++ entities: { urls: [] } ++ } ++ expectShareContent(validateTwitter({ type: 'SHARE', content, event }), content) ++ }) ++ }) ++ ++ describe('SHARE - attached media', () => { ++ it('strips a media link listed under entities.media', () => { ++ const content = 'Look at this listing on Origin' ++ const event = { ++ text: 'Look at this listing on Origin https://t.co/pic123', ++ entities: { ++ urls: [], ++ media: [{ url: 'https://t.co/pic123' }] ++ } ++ } ++ expectShareContent(validateTwitter({ type: 'SHARE', content, event }), content) ++ }) ++ ++ it('strips a media link listed only under extended_entities.media', () => { ++ const content = 'Look at this listing on Origin' ++ const event = { ++ text: 'Look at this listing on Origin https://t.co/pic456', ++ entities: { urls: [] }, ++ extended_entities: { ++ media: [{ url: 'https://t.co/pic456' }] ++ } ++ } ++ expectShareContent(validateTwitter({ type: 'SHARE', content, event }), content) ++ }) ++ ++ it('strips multiple media links', () => { ++ const content = 'Two photos here' ++ const event = { ++ text: 'Two photos here https://t.co/p1 https://t.co/p2', ++ entities: { ++ urls: [], ++ media: [{ url: 'https://t.co/p1' }, { url: 'https://t.co/p2' }] ++ } ++ } ++ expectShareContent(validateTwitter({ type: 'SHARE', content, event }), content) ++ }) ++ ++ it('handles media on a truncated tweet (extended payload)', () => { ++ const content = ++ 'A long tweet with an attached photo that gets truncated here ok' ++ const event = { ++ text: 'A long tweet with an attached photo…', ++ extended_tweet: { ++ full_text: ++ 'A long tweet with an attached photo that gets truncated here ok https://t.co/picXt', ++ entities: { urls: [] }, ++ extended_entities: { media: [{ url: 'https://t.co/picXt' }] } ++ } ++ } ++ expectShareContent(validateTwitter({ type: 'SHARE', content, event }), content) ++ }) ++ ++ it('still rejects a media share whose text does not match', () => { ++ const event = { ++ text: 'Completely different text https://t.co/picZ', ++ entities: { ++ urls: [], ++ media: [{ url: 'https://t.co/picZ' }] ++ } ++ } ++ expect( ++ validateTwitter({ type: 'SHARE', content: 'Look at this listing on Origin', event }) ++ ).to.equal(false) ++ }) ++ }) ++ ++ describe('SHARE - retweets', () => { ++ it('validates the original tweet, not the RT wrapper', () => { ++ const content = 'Original promoted content' ++ const event = { ++ text: 'RT @originprotocol: Original promoted content', ++ entities: { urls: [] }, ++ retweeted_status: { ++ text: 'Original promoted content', ++ entities: { urls: [] } ++ } ++ } ++ expectShareContent(validateTwitter({ type: 'SHARE', content, event }), content) ++ }) ++ ++ it('uses the original tweet full text when the original is truncated', () => { ++ const content = ++ 'Original promoted content that is quite long and was truncated here yes' ++ const event = { ++ text: 'RT @originprotocol: Original promoted content that is quite…', ++ entities: { urls: [] }, ++ retweeted_status: { ++ text: 'Original promoted content that is quite…', ++ extended_tweet: { ++ full_text: ++ 'Original promoted content that is quite long and was truncated here yes', ++ entities: { urls: [] } ++ } ++ } ++ } ++ expectShareContent(validateTwitter({ type: 'SHARE', content, event }), content) ++ }) ++ ++ it('applies URL expansion and media stripping to the retweeted tweet', () => { ++ const content = 'Promo http://www.originprotocol.com with pic' ++ const event = { ++ text: 'RT @originprotocol: Promo https://t.co/u1 with pic https://t.co/m1', ++ entities: { urls: [] }, ++ retweeted_status: { ++ text: 'Promo https://t.co/u1 with pic https://t.co/m1', ++ entities: { ++ urls: [{ url: 'https://t.co/u1', expanded_url: 'http://www.originprotocol.com' }], ++ media: [{ url: 'https://t.co/m1' }] ++ } ++ } ++ } ++ expectShareContent(validateTwitter({ type: 'SHARE', content, event }), content) ++ }) ++ ++ it('rejects a retweet whose original content does not match', () => { ++ const event = { ++ text: 'RT @someoneelse: Totally unrelated tweet', ++ entities: { urls: [] }, ++ retweeted_status: { ++ text: 'Totally unrelated tweet', ++ entities: { urls: [] } ++ } ++ } ++ expect( ++ validateTwitter({ type: 'SHARE', content: 'Original promoted content', event }) ++ ).to.equal(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,18 @@ ++#!/usr/bin/env bash ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++cd /testbed/infra/bridge ++ ++ ++ ++./node_modules/.bin/mocha --exit test/utils.js ++ ++ ++./node_modules/.bin/mocha --exit test/event-validators.test.js diff --git a/tasks/format-code-task-000194/tests/test.sh b/tasks/format-code-task-000194/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..2e3179eb4818c112da5fc7839059751ef06cb237 --- /dev/null +++ b/tasks/format-code-task-000194/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' +infra/bridge/test/event-validators.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-000194/tests/test_command.sh b/tasks/format-code-task-000194/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000194/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-000300/environment/Dockerfile b/tasks/format-code-task-000300/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e393b4fa4b22436535309141c1edceb3ae79c2c2 --- /dev/null +++ b/tasks/format-code-task-000300/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:b2993906c40fd1e447758c2b4852553ff69ffdfff7eb26f5413b0be279c4b2bb diff --git a/tasks/format-code-task-000300/environment/setup/files/blocklist b/tasks/format-code-task-000300/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000300/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-000300/environment/setup/setup.sh b/tasks/format-code-task-000300/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000300/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-000300/tests/test.patch b/tasks/format-code-task-000300/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..3fd63e84bbc01dc038a0305320c9e6720363b0dc --- /dev/null +++ b/tasks/format-code-task-000300/tests/test.patch @@ -0,0 +1,315 @@ +diff --git a/usercase-test-coderl/fixtures/taskfile_aliases.txt b/usercase-test-coderl/fixtures/taskfile_aliases.txt +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/taskfile_aliases.txt +@@ -0,0 +1,12 @@ ++@annually echo annually ++@yearly echo yearly ++@monthly echo monthly ++@weekly echo weekly ++@daily echo daily ++@hourly echo hourly ++@5minutes echo five ++@10minutes echo ten ++@15minutes echo fifteen ++@30minutes echo thirty ++@always echo '[task 3] @always' > test/task3.out ++@everysecond echo every second +diff --git a/usercase-test-coderl/fixtures/taskfile_basic.txt b/usercase-test-coderl/fixtures/taskfile_basic.txt +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/taskfile_basic.txt +@@ -0,0 +1,6 @@ ++ # leading-space comment is ignored ++ ++ */1 0/1 * * * echo '[task 1]' > test/task1.out ++ 0 12 * * mon-fri echo weekday noon ++ # tab-indented comment is ignored ++5 4 * * * printf 'last task' +diff --git a/usercase-test-coderl/fixtures/taskfile_extended.txt b/usercase-test-coderl/fixtures/taskfile_extended.txt +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/taskfile_extended.txt +@@ -0,0 +1,6 @@ ++*/3 * ? * ? 0 2000-2024/4 echo "run" ++*/12 * ? * ? mon echo "run" ++0,30 1-5/2 * * mon#2 echo hash list range step ++0 0 12 15W * ? echo nearest weekday ++0 0 9 ? * friL echo last friday ++0 0 9 ? * mon-wed echo day range +diff --git a/usercase-test-coderl/fixtures/taskfile_malformed.txt b/usercase-test-coderl/fixtures/taskfile_malformed.txt +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/taskfile_malformed.txt +@@ -0,0 +1,3 @@ ++@invalid echo nope ++* * * * * ++*/5 * * * * echo ok +diff --git a/usercase-test-coderl/taskfile_parser_test.go b/usercase-test-coderl/taskfile_parser_test.go +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/taskfile_parser_test.go +@@ -0,0 +1,240 @@ ++package usercase_test_coderl ++ ++import ( ++ "bytes" ++ "io/ioutil" ++ "log" ++ "os" ++ "os/exec" ++ "path/filepath" ++ "reflect" ++ "strings" ++ "testing" ++ ++ "github.com/adhocore/gronx/pkg/tasker" ++) ++ ++ ++ ++ ++ ++ ++const fixturesDir = "/workspace/repo/usercase-test-coderl/fixtures" ++ ++func fixturePath(name string) string { ++ return filepath.Join(fixturesDir, name) ++} ++ ++func captureParserLogs(t *testing.T) *bytes.Buffer { ++ t.Helper() ++ ++ var buf bytes.Buffer ++ oldWriter := log.Writer() ++ oldFlags := log.Flags() ++ oldPrefix := log.Prefix() ++ log.SetOutput(&buf) ++ log.SetFlags(0) ++ log.SetPrefix("") ++ t.Cleanup(func() { ++ log.SetOutput(oldWriter) ++ log.SetFlags(oldFlags) ++ log.SetPrefix(oldPrefix) ++ }) ++ ++ return &buf ++} ++ ++func TestParsesFiveFieldTasksFilteringAndOrder(t *testing.T) { ++ ++ ++ tasks := tasker.MustParseTaskfile(tasker.Option{File: fixturePath("taskfile_basic.txt")}) ++ ++ expected := []tasker.Task{ ++ {Expr: "*/1 0/1 * * *", Cmd: "echo '[task 1]' > test/task1.out"}, ++ {Expr: "0 12 * * mon-fri", Cmd: "echo weekday noon"}, ++ {Expr: "5 4 * * *", Cmd: "printf 'last task'"}, ++ } ++ if !reflect.DeepEqual(tasks, expected) { ++ t.Fatalf("parsed tasks mismatch:\nactual: %#v\nexpected: %#v", tasks, expected) ++ } ++} ++ ++func TestParsesEverySupportedAlias(t *testing.T) { ++ ++ ++ tasks := tasker.MustParseTaskfile(tasker.Option{File: fixturePath("taskfile_aliases.txt")}) ++ ++ expected := []tasker.Task{ ++ {Expr: "@annually", Cmd: "echo annually"}, ++ {Expr: "@yearly", Cmd: "echo yearly"}, ++ {Expr: "@monthly", Cmd: "echo monthly"}, ++ {Expr: "@weekly", Cmd: "echo weekly"}, ++ {Expr: "@daily", Cmd: "echo daily"}, ++ {Expr: "@hourly", Cmd: "echo hourly"}, ++ {Expr: "@5minutes", Cmd: "echo five"}, ++ {Expr: "@10minutes", Cmd: "echo ten"}, ++ {Expr: "@15minutes", Cmd: "echo fifteen"}, ++ {Expr: "@30minutes", Cmd: "echo thirty"}, ++ {Expr: "@always", Cmd: "echo '[task 3] @always' > test/task3.out"}, ++ {Expr: "@everysecond", Cmd: "echo every second"}, ++ } ++ if !reflect.DeepEqual(tasks, expected) { ++ t.Fatalf("parsed alias tasks mismatch:\nactual: %#v\nexpected: %#v", tasks, expected) ++ } ++} ++ ++func TestParsesExtendedCronPrefixes(t *testing.T) { ++ ++ ++ tasks := tasker.MustParseTaskfile(tasker.Option{File: fixturePath("taskfile_extended.txt")}) ++ ++ ++ expected := []struct { ++ exprFields []string ++ cmd string ++ }{ ++ {[]string{"*/3", "*", "?", "*", "?", "0", "2000-2024/4"}, "echo \"run\""}, ++ {[]string{"*/12", "*", "?", "*", "?", "mon"}, "echo \"run\""}, ++ {[]string{"0,30", "1-5/2", "*", "*", "mon#2"}, "echo hash list range step"}, ++ {[]string{"0", "0", "12", "15W", "*", "?"}, "echo nearest weekday"}, ++ {[]string{"0", "0", "9", "?", "*", "friL"}, "echo last friday"}, ++ {[]string{"0", "0", "9", "?", "*", "mon-wed"}, "echo day range"}, ++ } ++ if len(tasks) != len(expected) { ++ t.Fatalf("parsed extended task count mismatch:\nactual: %#v\nexpected count: %d", tasks, len(expected)) ++ } ++ for i, want := range expected { ++ if fields := strings.Fields(tasks[i].Expr); !reflect.DeepEqual(fields, want.exprFields) { ++ t.Fatalf("parsed extended expr fields mismatch at %d:\nactual: %#v\nexpected: %#v\nfull task: %#v", i, fields, want.exprFields, tasks[i]) ++ } ++ if tasks[i].Cmd != want.cmd { ++ t.Fatalf("parsed extended command mismatch at %d:\nactual: %q\nexpected: %q\nfull task: %#v", i, tasks[i].Cmd, want.cmd, tasks[i]) ++ } ++ } ++} ++ ++func TestSkipsMalformedLinesAndLogsParseMessages(t *testing.T) { ++ ++ ++ logs := captureParserLogs(t) ++ ++ tasks := tasker.MustParseTaskfile(tasker.Option{File: fixturePath("taskfile_malformed.txt")}) ++ ++ expectedTasks := []tasker.Task{ ++ {Expr: "*/5 * * * *", Cmd: "echo ok"}, ++ } ++ if !reflect.DeepEqual(tasks, expectedTasks) { ++ t.Fatalf("malformed fixture tasks mismatch:\nactual: %#v\nexpected: %#v", tasks, expectedTasks) ++ } ++ ++ expectedLogs := "[parser] can't parse cron expr: @invalid echo nope\n" + ++ "[parser] can't parse cron expr: * * * * *\n" ++ if logs.String() != expectedLogs { ++ t.Fatalf("parse logs mismatch:\nactual: %q\nexpected: %q", logs.String(), expectedLogs) ++ } ++} ++ ++func TestMissingTaskfileExitsWithStatusOne(t *testing.T) { ++ if os.Getenv("TST_MISSING_TASKFILE_CHILD") == "1" { ++ log.SetFlags(0) ++ log.SetPrefix("") ++ tasker.MustParseTaskfile(tasker.Option{File: fixturePath("definitely_missing_taskfile.txt")}) ++ return ++ } ++ ++ cmd := exec.Command(os.Args[0], "-test.run", "^TestMissingTaskfileExitsWithStatusOne$") ++ cmd.Env = append(os.Environ(), "TST_MISSING_TASKFILE_CHILD=1") ++ var stderr bytes.Buffer ++ cmd.Stderr = &stderr ++ ++ err := cmd.Run() ++ exitErr, ok := err.(*exec.ExitError) ++ if !ok { ++ t.Fatalf("expected child process to exit with status 1, got err=%v", err) ++ } ++ if exitErr.ExitCode() != 1 { ++ t.Fatalf("expected child process exit status 1, got %d", exitErr.ExitCode()) ++ } ++ ++ expected := "[parser] can't open file: " + fixturePath("definitely_missing_taskfile.txt") + "\n" ++ if stderr.String() != expected { ++ t.Fatalf("open failure log mismatch:\nactual: %q\nexpected: %q", stderr.String(), expected) ++ } ++} ++ ++func TestReferentialTransparencyForUnchangedTaskfile(t *testing.T) { ++ first := tasker.MustParseTaskfile(tasker.Option{File: fixturePath("taskfile_extended.txt")}) ++ second := tasker.MustParseTaskfile(tasker.Option{File: fixturePath("taskfile_extended.txt")}) ++ ++ if !reflect.DeepEqual(first, second) { ++ t.Fatalf("same taskfile parsed differently:\nfirst: %#v\nsecond: %#v", first, second) ++ } ++} ++ ++func TestDoesNotModifyTaskfile(t *testing.T) { ++ path := fixturePath("taskfile_basic.txt") ++ before, err := ioutil.ReadFile(path) ++ if err != nil { ++ t.Fatalf("read fixture before parse: %v", err) ++ } ++ ++ _ = tasker.MustParseTaskfile(tasker.Option{File: path}) ++ ++ after, err := ioutil.ReadFile(path) ++ if err != nil { ++ t.Fatalf("read fixture after parse: %v", err) ++ } ++ if !bytes.Equal(after, before) { ++ t.Fatalf("taskfile content changed:\nafter: %q\nbefore: %q", string(after), string(before)) ++ } ++} ++ ++func TestNoGlobalStateAcrossDifferentTaskfiles(t *testing.T) { ++ _ = captureParserLogs(t) ++ ++ baseline := tasker.MustParseTaskfile(tasker.Option{File: fixturePath("taskfile_basic.txt")}) ++ _ = tasker.MustParseTaskfile(tasker.Option{File: fixturePath("taskfile_aliases.txt")}) ++ _ = tasker.MustParseTaskfile(tasker.Option{File: fixturePath("taskfile_malformed.txt")}) ++ again := tasker.MustParseTaskfile(tasker.Option{File: fixturePath("taskfile_basic.txt")}) ++ ++ if !reflect.DeepEqual(again, baseline) { ++ t.Fatalf("basic taskfile changed after parsing other files:\nagain: %#v\nbaseline: %#v", again, baseline) ++ } ++} ++ ++func TestNoUndeclaredCwdSideEffects(t *testing.T) { ++ tmp, err := ioutil.TempDir("", "tasker-parser-cwd-*") ++ if err != nil { ++ t.Fatalf("create temp dir: %v", err) ++ } ++ defer os.RemoveAll(tmp) ++ ++ oldCwd, err := os.Getwd() ++ if err != nil { ++ t.Fatalf("get cwd: %v", err) ++ } ++ if err := os.Chdir(tmp); err != nil { ++ t.Fatalf("chdir temp cwd: %v", err) ++ } ++ defer os.Chdir(oldCwd) ++ ++ path := fixturePath("taskfile_aliases.txt") ++ before, err := ioutil.ReadFile(path) ++ if err != nil { ++ t.Fatalf("read fixture before parse: %v", err) ++ } ++ ++ tasks := tasker.MustParseTaskfile(tasker.Option{File: path}) ++ ++ after, err := ioutil.ReadFile(path) ++ if err != nil { ++ t.Fatalf("read fixture after parse: %v", err) ++ } ++ ++ if !bytes.Equal(after, before) { ++ t.Fatalf("taskfile content changed from different cwd:\nafter: %q\nbefore: %q", string(after), string(before)) ++ } ++ if len(tasks) != 12 || tasks[0].Expr != "@annually" || tasks[len(tasks)-1].Expr != "@everysecond" { ++ t.Fatalf("absolute taskfile parse from different cwd mismatch: %#v", tasks) ++ } ++} +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" ++export GOPROXY=off ++export GOSUMDB=off ++export GOTOOLCHAIN=local ++export GOVCS='*:off' ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo ++exec go test -v ./usercase-test-coderl/... diff --git a/tasks/format-code-task-000300/tests/test.sh b/tasks/format-code-task-000300/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..14c21503a638ce558ff7ba85cb4a4d9ebf810496 --- /dev/null +++ b/tasks/format-code-task-000300/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=/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/taskfile_aliases.txt +usercase-test-coderl/fixtures/taskfile_basic.txt +usercase-test-coderl/fixtures/taskfile_extended.txt +usercase-test-coderl/fixtures/taskfile_malformed.txt +usercase-test-coderl/taskfile_parser_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-000300/tests/test_command.sh b/tasks/format-code-task-000300/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000300/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-000309/environment/Dockerfile b/tasks/format-code-task-000309/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d7dd23f4b8e45cfdb22f99bf47f62c4a5bbe5ff2 --- /dev/null +++ b/tasks/format-code-task-000309/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:329445341db3c020e3ac20752dfa2b874b40f4cb4a8d8403443cd06bdb31977e diff --git a/tasks/format-code-task-000309/environment/setup/files/blocklist b/tasks/format-code-task-000309/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000309/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-000309/environment/setup/setup.sh b/tasks/format-code-task-000309/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000309/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-000309/tests/test.patch b/tasks/format-code-task-000309/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..502df732b3c12018577db79746a4c73bd474f14d --- /dev/null +++ b/tasks/format-code-task-000309/tests/test.patch @@ -0,0 +1,350 @@ +diff --git a/usercase-test-coderl/exp_operation_builders_test.go b/usercase-test-coderl/exp_operation_builders_test.go +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/exp_operation_builders_test.go +@@ -0,0 +1,322 @@ ++package usercase_test_coderl ++ ++import ( ++ "bytes" ++ "encoding/base64" ++ "os" ++ "path/filepath" ++ "reflect" ++ "sort" ++ "testing" ++ "unsafe" ++ ++ as "github.com/aerospike/aerospike-client-go/v8" ++) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++const ( ++ expReadOperationCode = 7 ++ expWriteOperationCode = 8 ++) ++ ++type operationSnapshot struct { ++ opCode uint64 ++ isWrite bool ++ hasCustomEncoder bool ++ binName string ++ payload []byte ++} ++ ++func unexportedInterface(v reflect.Value) any { ++ return reflect.NewAt(v.Type(), unsafe.Pointer(v.UnsafeAddr())).Elem().Interface() ++} ++ ++func operationFields(t *testing.T, op *as.Operation) operationSnapshot { ++ t.Helper() ++ if op == nil { ++ t.Fatal("operation builder returned nil") ++ } ++ ++ value := reflect.ValueOf(op).Elem() ++ opType := value.FieldByName("opType") ++ if !opType.IsValid() { ++ t.Fatal("operation missing opType field") ++ } ++ ++ binValueField := value.FieldByName("binValue") ++ if !binValueField.IsValid() { ++ t.Fatal("operation missing binValue field") ++ } ++ encoderField := value.FieldByName("encoder") ++ if !encoderField.IsValid() { ++ t.Fatal("operation missing encoder field") ++ } ++ binValue, ok := unexportedInterface(binValueField).(as.Value) ++ if !ok || binValue == nil { ++ t.Fatalf("operation value should be an Aerospike Value, got %T", unexportedInterface(binValueField)) ++ } ++ ++ payload, ok := binValue.GetObject().([]byte) ++ if !ok { ++ t.Fatalf("operation value should contain packed expression bytes, got %T", binValue.GetObject()) ++ } ++ ++ return operationSnapshot{ ++ opCode: opType.FieldByName("op").Uint(), ++ isWrite: opType.FieldByName("isWrite").Bool(), ++ hasCustomEncoder: !encoderField.IsNil(), ++ binName: value.FieldByName("binName").String(), ++ payload: append([]byte(nil), payload...), ++ } ++} ++ ++func expectedPayload(t *testing.T, exp *as.Expression, flags int) []byte { ++ t.Helper() ++ encoded, err := exp.Base64() ++ if err != nil { ++ t.Fatalf("Base64 expression encoding: %v", err) ++ } ++ packedExpression, decodeErr := base64.StdEncoding.DecodeString(encoded) ++ if decodeErr != nil { ++ t.Fatalf("decode expression Base64 %q: %v", encoded, decodeErr) ++ } ++ ++ payload := []byte{0x92} ++ payload = append(payload, packedExpression...) ++ payload = append(payload, packMsgpackInt(t, flags)...) ++ return payload ++} ++ ++func packMsgpackInt(t *testing.T, n int) []byte { ++ t.Helper() ++ if n < 0 { ++ t.Fatalf("negative flags are not used by the expression operation spec: %d", n) ++ } ++ switch { ++ case n <= 0x7f: ++ return []byte{byte(n)} ++ case n <= 0xff: ++ return []byte{0xcc, byte(n)} ++ case n <= 0xffff: ++ return []byte{0xcd, byte(n >> 8), byte(n)} ++ default: ++ t.Fatalf("test helper only supports compact positive flags, got %d", n) ++ return nil ++ } ++} ++ ++func assertExpressionOperation(t *testing.T, op *as.Operation, wantCode uint64, wantIsWrite bool, wantBinName string, wantPayload []byte) { ++ t.Helper() ++ actual := operationFields(t, op) ++ ++ ++ if actual.opCode != wantCode || actual.isWrite != wantIsWrite { ++ t.Fatalf("operation kind mismatch: expected code=%d isWrite=%v, got code=%d isWrite=%v", wantCode, wantIsWrite, actual.opCode, actual.isWrite) ++ } ++ if actual.binName != wantBinName { ++ t.Fatalf("operation bin name mismatch: expected %q, got %q", wantBinName, actual.binName) ++ } ++ ++ if actual.hasCustomEncoder { ++ t.Fatal("operation should store the expression payload as the operation value, not behind a custom encoder") ++ } ++ if !bytes.Equal(actual.payload, wantPayload) { ++ t.Fatalf("operation payload mismatch:\nexpected %#v\nactual %#v", wantPayload, actual.payload) ++ } ++} ++ ++func dirEntries(t *testing.T, dir string) []string { ++ t.Helper() ++ ++ entries, err := os.ReadDir(dir) ++ if err != nil { ++ t.Fatalf("ReadDir(%q): %v", dir, err) ++ } ++ ++ names := make([]string, len(entries)) ++ for i, entry := range entries { ++ names[i] = entry.Name() ++ } ++ sort.Strings(names) ++ return names ++} ++ ++func TestExpReadOpSumDefaultOperation(t *testing.T) { ++ ++ ++ exp := as.ExpNumAdd(as.ExpIntBin("a"), as.ExpIntVal(5)) ++ ++ assertExpressionOperation(t, as.ExpReadOp("sum", exp, as.ExpReadFlagDefault), expReadOperationCode, false, "sum", expectedPayload(t, exp, int(as.ExpReadFlagDefault))) ++} ++ ++func TestExpReadOpEvalNoFailOperation(t *testing.T) { ++ ++ ++ exp := as.ExpStringVal("guest") ++ ++ assertExpressionOperation(t, as.ExpReadOp("nickname", exp, as.ExpReadFlagEvalNoFail), expReadOperationCode, false, "nickname", expectedPayload(t, exp, int(as.ExpReadFlagEvalNoFail))) ++} ++ ++func TestExpWriteOpTotalDefaultOperation(t *testing.T) { ++ ++ ++ exp := as.ExpNumAdd(as.ExpIntBin("a"), as.ExpIntBin("b")) ++ ++ assertExpressionOperation(t, as.ExpWriteOp("total", exp, as.ExpWriteFlagDefault), expWriteOperationCode, true, "total", expectedPayload(t, exp, int(as.ExpWriteFlagDefault))) ++} ++ ++func TestExpWriteOpCreateAllowDeleteEvalNoFailOperation(t *testing.T) { ++ ++ ++ flags := as.ExpWriteFlagCreateOnly | as.ExpWriteFlagAllowDelete | as.ExpWriteFlagEvalNoFail ++ exp := as.ExpNilValue() ++ ++ assertExpressionOperation(t, as.ExpWriteOp("maybe", exp, flags), expWriteOperationCode, true, "maybe", expectedPayload(t, exp, int(flags))) ++} ++ ++func TestExpWriteOpUpdateOnlyPolicyNoFailOperation(t *testing.T) { ++ ++ ++ flags := as.ExpWriteFlagUpdateOnly | as.ExpWriteFlagPolicyNoFail ++ exp := as.ExpIntVal(42) ++ ++ assertExpressionOperation(t, as.ExpWriteOp("score", exp, flags), expWriteOperationCode, true, "score", expectedPayload(t, exp, int(flags))) ++} ++ ++func TestExpressionOperationFlagConstants(t *testing.T) { ++ ++ ++ actual := map[string]int{ ++ "ExpReadFlagDefault": int(as.ExpReadFlagDefault), ++ "ExpReadFlagEvalNoFail": int(as.ExpReadFlagEvalNoFail), ++ "ExpWriteFlagDefault": int(as.ExpWriteFlagDefault), ++ "ExpWriteFlagCreateOnly": int(as.ExpWriteFlagCreateOnly), ++ "ExpWriteFlagUpdateOnly": int(as.ExpWriteFlagUpdateOnly), ++ "ExpWriteFlagAllowDelete": int(as.ExpWriteFlagAllowDelete), ++ "ExpWriteFlagPolicyNoFail": int(as.ExpWriteFlagPolicyNoFail), ++ "ExpWriteFlagEvalNoFail": int(as.ExpWriteFlagEvalNoFail), ++ } ++ expected := map[string]int{ ++ "ExpReadFlagDefault": 0, ++ "ExpReadFlagEvalNoFail": 16, ++ "ExpWriteFlagDefault": 0, ++ "ExpWriteFlagCreateOnly": 1, ++ "ExpWriteFlagUpdateOnly": 2, ++ "ExpWriteFlagAllowDelete": 4, ++ "ExpWriteFlagPolicyNoFail": 8, ++ "ExpWriteFlagEvalNoFail": 16, ++ } ++ ++ if !reflect.DeepEqual(actual, expected) { ++ t.Fatalf("expression operation flag constants mismatch:\nexpected %#v\nactual %#v", expected, actual) ++ } ++} ++ ++func TestExpressionOperationBuilderPanicsWhenExpressionCannotBePacked(t *testing.T) { ++ ++ ++ cases := map[string]func(){ ++ "ExpReadOp": func() { _ = as.ExpReadOp("bad", &as.Expression{}, as.ExpReadFlagDefault) }, ++ "ExpWriteOp": func() { ++ _ = as.ExpWriteOp("bad", &as.Expression{}, as.ExpWriteFlagDefault) ++ }, ++ } ++ for name, call := range cases { ++ t.Run(name, func(t *testing.T) { ++ defer func() { ++ recovered := recover() ++ ++ if recovered == nil { ++ t.Fatalf("expected %s to panic for an unpackable empty Expression", name) ++ } ++ }() ++ call() ++ }) ++ } ++} ++ ++func TestExpressionOperationBuildersAreReferentiallyTransparent(t *testing.T) { ++ exp := as.ExpNumAdd(as.ExpIntBin("a"), as.ExpIntVal(5)) ++ expected := expectedPayload(t, exp, int(as.ExpReadFlagDefault)) ++ first := as.ExpReadOp("sum", exp, as.ExpReadFlagDefault) ++ second := as.ExpReadOp("sum", exp, as.ExpReadFlagDefault) ++ ++ assertExpressionOperation(t, first, expReadOperationCode, false, "sum", expected) ++ assertExpressionOperation(t, second, expReadOperationCode, false, "sum", expected) ++ ++ if !reflect.DeepEqual(operationFields(t, first), operationFields(t, second)) { ++ t.Fatalf("same ExpReadOp input should return equivalent operations:\nfirst %#v\nsecond %#v", operationFields(t, first), operationFields(t, second)) ++ } ++} ++ ++func TestExpressionOperationBuildersDoNotMutateExpressionInput(t *testing.T) { ++ exp := as.ExpNumAdd(as.ExpIntBin("a"), as.ExpIntVal(5)) ++ before, err := exp.Base64() ++ if err != nil { ++ t.Fatalf("Base64 before builder: %v", err) ++ } ++ ++ _ = as.ExpReadOp("sum", exp, as.ExpReadFlagDefault) ++ after, err := exp.Base64() ++ if err != nil { ++ t.Fatalf("Base64 after builder: %v", err) ++ } ++ ++ ++ if before == "" || after != before { ++ t.Fatalf("builder mutated expression encoding:\nbefore %q\nafter %q", before, after) ++ } ++} ++ ++func TestExpressionOperationBuildersDoNotUseGlobalStateAcrossOtherCalls(t *testing.T) { ++ exp := as.ExpNumAdd(as.ExpIntBin("a"), as.ExpIntVal(5)) ++ expected := expectedPayload(t, exp, int(as.ExpReadFlagDefault)) ++ first := as.ExpReadOp("sum", exp, as.ExpReadFlagDefault) ++ ++ _ = as.ExpWriteOp("total", as.ExpNumAdd(as.ExpIntBin("a"), as.ExpIntBin("b")), as.ExpWriteFlagDefault) ++ _ = as.ExpReadOp("nickname", as.ExpStringVal("guest"), as.ExpReadFlagEvalNoFail) ++ _ = as.ExpWriteOp("maybe", as.ExpNilValue(), as.ExpWriteFlagCreateOnly|as.ExpWriteFlagAllowDelete|as.ExpWriteFlagEvalNoFail) ++ ++ again := as.ExpReadOp("sum", exp, as.ExpReadFlagDefault) ++ ++ assertExpressionOperation(t, first, expReadOperationCode, false, "sum", expected) ++ assertExpressionOperation(t, again, expReadOperationCode, false, "sum", expected) ++ ++ if !reflect.DeepEqual(operationFields(t, first), operationFields(t, again)) { ++ t.Fatalf("operation builder result changed across intervening calls:\nfirst %#v\nagain %#v", operationFields(t, first), operationFields(t, again)) ++ } ++} ++ ++func TestExpressionOperationBuildersDoNotWriteInCurrentDirectory(t *testing.T) { ++ tmp := t.TempDir() ++ before := dirEntries(t, tmp) ++ ++ oldWd, err := os.Getwd() ++ if err != nil { ++ t.Fatalf("Getwd: %v", err) ++ } ++ if err := os.Chdir(tmp); err != nil { ++ t.Fatalf("Chdir(%q): %v", tmp, err) ++ } ++ defer func() { ++ if err := os.Chdir(oldWd); err != nil { ++ t.Fatalf("restore working directory %q: %v", oldWd, err) ++ } ++ }() ++ ++ _ = as.ExpReadOp("sum", as.ExpNumAdd(as.ExpIntBin("a"), as.ExpIntVal(5)), as.ExpReadFlagDefault) ++ _ = as.ExpWriteOp("total", as.ExpNumAdd(as.ExpIntBin("a"), as.ExpIntBin("b")), as.ExpWriteFlagDefault) ++ ++ after := dirEntries(t, tmp) ++ if !reflect.DeepEqual(after, before) { ++ t.Fatalf("operation builders wrote files in cwd %s:\nbefore %#v\nafter %#v", filepath.Clean(tmp), before, after) ++ } ++} +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 GOTOOLCHAIN=local ++export GOPROXY=off ++export GOSUMDB=off ++export GOFLAGS="${GOFLAGS:-} -mod=vendor" ++exec go test -v ./usercase-test-coderl/... diff --git a/tasks/format-code-task-000309/tests/test.sh b/tasks/format-code-task-000309/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..9c97babeb228bd796fb397ea4175240254d2e09c --- /dev/null +++ b/tasks/format-code-task-000309/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/exp_operation_builders_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-000309/tests/test_command.sh b/tasks/format-code-task-000309/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000309/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-000331/environment/Dockerfile b/tasks/format-code-task-000331/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..88cdf30b20b2aef28188b0ff69911c8de6b8fd0a --- /dev/null +++ b/tasks/format-code-task-000331/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:5b7a2764dd41b393a8fee385edce9796b091939a60356b6d57f197851c6c03e8 diff --git a/tasks/format-code-task-000331/environment/setup/files/blocklist b/tasks/format-code-task-000331/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000331/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-000331/environment/setup/setup.sh b/tasks/format-code-task-000331/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000331/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-000331/tests/test.patch b/tasks/format-code-task-000331/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..17f014babbad013bbbf104daf23c50a4db8072a5 --- /dev/null +++ b/tasks/format-code-task-000331/tests/test.patch @@ -0,0 +1,54 @@ +diff --git a/http-server/src/test/java/io/airlift/http/server/TestHttpServerConfig.java b/http-server/src/test/java/io/airlift/http/server/TestHttpServerConfig.java +index 4eba92c8ca..be9b0fbcd0 100644 +--- a/http-server/src/test/java/io/airlift/http/server/TestHttpServerConfig.java ++++ b/http-server/src/test/java/io/airlift/http/server/TestHttpServerConfig.java +@@ -70,7 +70,8 @@ public void testDefaults() + .setHttp2InitialSessionReceiveWindowSize(DataSize.of(16, MEGABYTE)) + .setHttp2InputBufferSize(DataSize.of(8, KILOBYTE)) + .setHttp2InitialStreamReceiveWindowSize(DataSize.of(16, MEGABYTE)) +- .setHttp2StreamIdleTimeout(new Duration(15, SECONDS))); ++ .setHttp2StreamIdleTimeout(new Duration(15, SECONDS)) ++ .setCompressionEnabled(true)); + } + + @Test +@@ -109,6 +110,7 @@ public void testExplicitPropertyMappings() + .put("http-server.http2.stream-receive-window-size", "4MB") + .put("http-server.http2.input-buffer-size", "4MB") + .put("http-server.http2.stream-idle-timeout", "23s") ++ .put("http-server.compression.enabled", "false") + .build(); + + HttpServerConfig expected = new HttpServerConfig() +@@ -143,7 +145,8 @@ public void testExplicitPropertyMappings() + .setHttp2InitialSessionReceiveWindowSize(DataSize.of(4, MEGABYTE)) + .setHttp2InitialStreamReceiveWindowSize(DataSize.of(4, MEGABYTE)) + .setHttp2InputBufferSize(DataSize.of(4, MEGABYTE)) +- .setHttp2StreamIdleTimeout(new Duration(23, SECONDS)); ++ .setHttp2StreamIdleTimeout(new Duration(23, SECONDS)) ++ .setCompressionEnabled(false); + + assertFullMapping(properties, 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,6 @@ ++H4sIAAAAAAAAA+3Su07DMBQG4Mx5iiOxwJCShCadOtGBLgzAXqXNSWOR2MF2wutjW4irgKUVQvyf ++FNny5bflk9l2FF29YTmdR8eSOouiCK3zsQ39rMjTvCzTRZZHaZaVaR5RcbQbvTEaW2miSCtlv1v3 ++0/wfNXutv2VjNzvV95WsZ6Y93Bk/1f9ikb3Uv5yXrv7zMi8iSg93ha/98/rvagqF33Idxye0lu45 ++uo78V/PAsma5E2yoUZpaa4fEsJ5Y06n7SUhYQ1ZX0ggrJvYbzBk9Ctuq0ZIepRRyTz7dxP0kSTyH ++J0P3LiupekpW5l4Md34tJQ/+KjejJNsyufLs2YaYkOI7nyNWfnjp91+54dsweqlkI/ZurqlEt26u ++VYhfNlVnOP7thwcAAAAAAAAAAAAAAAAAAAAAOIAn8lW3lQAoAAA= +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-000331/tests/test.sh b/tasks/format-code-task-000331/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..06e1f579bb9a0d71cf8047838bb930747b3dd16d --- /dev/null +++ b/tasks/format-code-task-000331/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' +http-server/src/test/java/io/airlift/http/server/TestHttpServerConfig.java +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-000331/tests/test_command.sh b/tasks/format-code-task-000331/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000331/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-000336/environment/Dockerfile b/tasks/format-code-task-000336/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..3c33e388ffc4a0a6ae0a2798412fe27281e03587 --- /dev/null +++ b/tasks/format-code-task-000336/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:0a8257400bf99379bcd332cfee94115a6948b5e4ed94c489e3f0088208754cc5 diff --git a/tasks/format-code-task-000336/environment/setup/files/blocklist b/tasks/format-code-task-000336/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000336/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-000336/environment/setup/setup.sh b/tasks/format-code-task-000336/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000336/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-000336/tests/test.patch b/tasks/format-code-task-000336/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..730b63c1a424e97eccd684f3cf094be8dc1b26cb --- /dev/null +++ b/tasks/format-code-task-000336/tests/test.patch @@ -0,0 +1,49 @@ +diff --git a/tests/test_select.py b/tests/test_select.py +index 177685d8..a4b095bb 100644 +--- a/tests/test_select.py ++++ b/tests/test_select.py +@@ -84,7 +84,7 @@ async def test_car_heated_seat_select(hass: HomeAssistant) -> None: + {ATTR_ENTITY_ID: "select.my_model_s_heated_seat_left", "option": "Auto"}, + blocking=True, + ) +- mock_remote_auto_seat_climate_request.assert_awaited_once_with(0, True) ++ mock_remote_auto_seat_climate_request.assert_awaited_once_with(1, True) + # Test from "Auto" selection + car_mock_data.VEHICLE_DATA["climate_state"]["auto_seat_climate_left"] = True + assert await hass.services.async_call( +@@ -93,7 +93,7 @@ async def test_car_heated_seat_select(hass: HomeAssistant) -> None: + {ATTR_ENTITY_ID: "select.my_model_s_heated_seat_left", "option": "Low"}, + blocking=True, + ) +- mock_remote_auto_seat_climate_request.assert_awaited_with(0, False) ++ mock_remote_auto_seat_climate_request.assert_awaited_with(1, False) + + with patch("teslajsonpy.car.TeslaCar.set_hvac_mode") as mock_set_hvac_mode: + # Test climate_on check +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+2US4/TQAzHe86n8Halsis00yR9BAl1L4gDN8QV0GqauM1AMpNmJoXw6XHS0gda ++qJB2hRD+HfIa2+O/7YlcNrrI7tFsx4OnIiSS2ay/Ez/f++doFodxEk4n02QQRtE8nA1g9mQZndA4 ++r2qAQW2t/53dpfV/FHnsv0fn71Nblspk0uWPt8eF/kfTKDn0P07ILprO4+kAwsdL4df85/2/vhov ++tRkvlcuDNIN+CJaYBcE1vDauqRHetj63BiYyCkE7UFulC7UsEG5q3DS6xgxWtobclqic01RO44Ga ++GcsoklN4Dkrb3PuKIryQ0W2gV3AF+zEDsYWqj9+HH92NM9yOTVMUL8HnaAIgVOXFGj00VaY8gths ++YDQ6fNWGdiwKEG2/chLt+Ci2NN+n77RLsNKdyFc1dkF7gy/a5+dyV6A9ZBadeeZBFWSbtYBfSWQn ++4z0JEatDzcayi9KXc7cVfDxRcZKYKHf7nTvuE3qz15NhhSZDk2p0cNM4um6xdtoaB6Xyaa7NuosO ++lUVft7Kw6efb4KFcdHUskmiqda0y8qKvYgPxseIXfTfwoVcyJClkKc46LlI6SLYU1NjKGjR+sQhl ++FMs4Gv5wI6dCfXLWVO1iMZEzeVzajwj9fWp3R46JDI9u36jtatjV5l1jesl0YrvWd1nAShf4YOq7 ++FlCtd+n21m73k3NYYOpl1XbzJ4TXJdrGL+Zh8LePI8MwDMMwDMMwDMMwDMMwDMMwDMMwDMMwzB/z ++HdGaVIkAKAAA +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-000336/tests/test.sh b/tasks/format-code-task-000336/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..76623479172fd8df5742101519e6bf00716a509e --- /dev/null +++ b/tasks/format-code-task-000336/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_select.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-000336/tests/test_command.sh b/tasks/format-code-task-000336/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000336/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-000337/environment/Dockerfile b/tasks/format-code-task-000337/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..39f684e7b59fdd1af5ee0e638c1c522efefdfa5d --- /dev/null +++ b/tasks/format-code-task-000337/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:19add4a7d8aa8b749e02f7b1a7adfdf3ad062efe8992879aab9d0afa14c45cb8 diff --git a/tasks/format-code-task-000337/environment/setup/files/blocklist b/tasks/format-code-task-000337/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000337/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-000337/environment/setup/setup.sh b/tasks/format-code-task-000337/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000337/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-000337/tests/test.patch b/tasks/format-code-task-000337/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..09bd9cbcbbc3891cc75cabdf7a8536a3d1d21d57 --- /dev/null +++ b/tasks/format-code-task-000337/tests/test.patch @@ -0,0 +1,155 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..2ff9878 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest tests/test_resize_2d_mask_additional_target.py -v"] ++} +diff --git a/tests/test_resize_2d_mask_additional_target.py b/tests/test_resize_2d_mask_additional_target.py +new file mode 100644 +index 0000000..7ee5690 +--- /dev/null ++++ b/tests/test_resize_2d_mask_additional_target.py +@@ -0,0 +1,127 @@ ++ ++ ++ ++ ++ ++ ++import numpy as np ++import pytest ++ ++import albumentations as A ++ ++ ++def test_issue_reproduction_compose_additional_target_2d_mask_no_crash(): ++ ++ image = np.zeros((256, 256, 3), dtype=np.uint8) ++ mask = np.ones((256, 256), dtype=np.uint8) ++ ++ transform = A.Compose( ++ [A.Resize(height=512, width=512)], ++ additional_targets={"semantic_mask": "mask"}, ++ ) ++ ++ augmented = transform(image=image, semantic_mask=mask) ++ ++ assert "semantic_mask" in augmented ++ assert augmented["semantic_mask"].shape == (512, 512) ++ ++ ++def test_issue_reproduction_values_preserved(): ++ ++ image = np.zeros((256, 256, 3), dtype=np.uint8) ++ mask = np.ones((256, 256), dtype=np.uint8) ++ ++ transform = A.Compose( ++ [A.Resize(height=512, width=512)], ++ additional_targets={"semantic_mask": "mask"}, ++ ) ++ ++ augmented = transform(image=image, semantic_mask=mask) ++ out = augmented["semantic_mask"] ++ assert out.dtype == np.uint8 ++ np.testing.assert_array_equal(out, np.ones((512, 512), dtype=np.uint8)) ++ ++ ++def test_resize_compose_standard_mask_2d_still_works(): ++ ++ image = np.zeros((256, 256, 3), dtype=np.uint8) ++ mask = np.ones((256, 256), dtype=np.uint8) ++ ++ transform = A.Compose([A.Resize(height=512, width=512)]) ++ out = transform(image=image, mask=mask) ++ assert out["mask"].shape == (512, 512) ++ assert out["image"].shape == (512, 512, 3) ++ ++ ++def test_resize_compose_additional_target_3d_mask_preserved(): ++ ++ image = np.zeros((256, 256, 3), dtype=np.uint8) ++ mask = np.ones((256, 256, 1), dtype=np.uint8) ++ ++ transform = A.Compose( ++ [A.Resize(height=128, width=128)], ++ additional_targets={"semantic_mask": "mask"}, ++ ) ++ out = transform(image=image, semantic_mask=mask) ++ assert out["semantic_mask"].shape == (128, 128, 1) ++ ++ ++def test_resize_direct_call_2d_mask_no_crash(): ++ ++ image = np.zeros((64, 64, 3), dtype=np.uint8) ++ mask = np.ones((64, 64), dtype=np.uint8) ++ ++ transform = A.Resize(height=128, width=128, p=1.0) ++ out = transform(image=image, mask=mask) ++ assert out["mask"].shape == (128, 128) ++ assert out["image"].shape == (128, 128, 3) ++ ++ ++def test_resize_compose_additional_target_2d_float32(): ++ ++ image = np.zeros((100, 100, 3), dtype=np.float32) ++ mask = np.full((100, 100), 0.5, dtype=np.float32) ++ ++ transform = A.Compose( ++ [A.Resize(height=200, width=200)], ++ additional_targets={"depth": "mask"}, ++ ) ++ out = transform(image=image, depth=mask) ++ assert out["depth"].shape == (200, 200) ++ assert out["depth"].dtype == np.float32 ++ ++ np.testing.assert_allclose(out["depth"], 0.5, atol=1e-5) ++ ++ ++def test_resize_compose_additional_target_2d_downscale(): ++ ++ image = np.zeros((400, 400, 3), dtype=np.uint8) ++ mask = np.ones((400, 400), dtype=np.uint8) ++ ++ transform = A.Compose( ++ [A.Resize(height=100, width=100)], ++ additional_targets={"sem_mask": "mask"}, ++ ) ++ out = transform(image=image, sem_mask=mask) ++ assert out["sem_mask"].shape == (100, 100) ++ np.testing.assert_array_equal( ++ out["sem_mask"], np.ones((100, 100), dtype=np.uint8) ++ ) ++ ++ ++def test_resize_compose_multiple_2d_additional_target_masks(): ++ ++ image = np.zeros((256, 256, 3), dtype=np.uint8) ++ mask_a = np.ones((256, 256), dtype=np.uint8) ++ mask_b = np.full((256, 256), 7, dtype=np.uint8) ++ ++ transform = A.Compose( ++ [A.Resize(height=128, width=128)], ++ additional_targets={"semantic_mask": "mask", "instance_mask": "mask"}, ++ ) ++ out = transform(image=image, semantic_mask=mask_a, instance_mask=mask_b) ++ assert out["semantic_mask"].shape == (128, 128) ++ assert out["instance_mask"].shape == (128, 128) ++ ++ assert out["semantic_mask"][0, 0] == 1 ++ assert out["instance_mask"][0, 0] == 7 +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_resize_2d_mask_additional_target.py -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000337/tests/test.sh b/tasks/format-code-task-000337/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..866552a65e1af4dc6d7df33edc517d32b479556c --- /dev/null +++ b/tasks/format-code-task-000337/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_resize_2d_mask_additional_target.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-000337/tests/test_command.sh b/tasks/format-code-task-000337/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000337/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-000352/environment/Dockerfile b/tasks/format-code-task-000352/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..99d7946d5c46e0accd744229dc19ca88c076a525 --- /dev/null +++ b/tasks/format-code-task-000352/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:e3cca81dac0140ab5000e945d52616f3cceb8ea6c08fa1481754cce344671292 diff --git a/tasks/format-code-task-000352/environment/setup/files/blocklist b/tasks/format-code-task-000352/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000352/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-000352/environment/setup/setup.sh b/tasks/format-code-task-000352/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000352/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-000352/tests/test.patch b/tasks/format-code-task-000352/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..d88c3a2751d1691c13b579458005b2d04def48b3 --- /dev/null +++ b/tasks/format-code-task-000352/tests/test.patch @@ -0,0 +1,163 @@ +diff --git a/src/ralph/data_center/tests/test_models.py b/src/ralph/data_center/tests/test_models.py +index b6fe9cac85..6e3f5c2c4a 100644 +--- a/src/ralph/data_center/tests/test_models.py ++++ b/src/ralph/data_center/tests/test_models.py +@@ -255,3 +255,47 @@ class DataCenterAssetTest(RalphTestCase): + self.dc_asset.rack = RackFactory(max_u_height=rack_max_height) + with self.assertRaises(ValidationError): + self.dc_asset._validate_position_in_rack() ++ ++ def test_direct_children_rack_follows_parent_when_parent_rack_changes(self): ++ old_rack = RackFactory() ++ new_rack = RackFactory() ++ self.dc_asset.rack = old_rack ++ self.dc_asset.save() ++ first_child = DataCenterAssetFactory( ++ parent=self.dc_asset, ++ rack=old_rack, ++ ) ++ second_child = DataCenterAssetFactory( ++ parent=self.dc_asset, ++ rack=old_rack, ++ ) ++ ++ self.dc_asset.rack = new_rack ++ self.dc_asset.save() ++ first_child.refresh_from_db() ++ second_child.refresh_from_db() ++ ++ self.assertEqual(first_child.rack_id, new_rack.id) ++ self.assertEqual(second_child.rack_id, new_rack.id) ++ ++ def test_rack_sync_is_limited_to_direct_children(self): ++ old_rack = RackFactory() ++ new_rack = RackFactory() ++ self.dc_asset.rack = old_rack ++ self.dc_asset.save() ++ direct_child = DataCenterAssetFactory(parent=self.dc_asset, rack=old_rack) ++ unrelated_asset = DataCenterAssetFactory(rack=old_rack) ++ ++ self.dc_asset.rack = new_rack ++ self.dc_asset.save() ++ direct_child.refresh_from_db() ++ unrelated_asset.refresh_from_db() ++ ++ self.assertEqual(direct_child.rack_id, new_rack.id) ++ self.assertEqual(unrelated_asset.rack_id, old_rack.id) ++ ++ def test_saving_parent_without_rack_change_does_not_change_child_rack(self): ++ parent_rack = RackFactory() ++ child_rack = RackFactory() ++ self.dc_asset.rack = parent_rack ++ self.dc_asset.save() ++ child = DataCenterAssetFactory(parent=self.dc_asset, rack=child_rack) ++ ++ self.dc_asset.save() ++ child.refresh_from_db() ++ ++ self.assertEqual(child.rack_id, child_rack.id) +diff --git a/mimo_test.patch b/mimo_test.patch +new file mode 100644 +--- /dev/null ++++ b/mimo_test.patch +@@ -0,0 +1,58 @@ ++diff --git a/src/ralph/data_center/tests/test_models.py b/src/ralph/data_center/tests/test_models.py ++index b6fe9cac85..6e3f5c2c4a 100644 ++--- a/src/ralph/data_center/tests/test_models.py +++++ b/src/ralph/data_center/tests/test_models.py ++@@ -255,3 +255,47 @@ class DataCenterAssetTest(RalphTestCase): ++ self.dc_asset.rack = RackFactory(max_u_height=rack_max_height) ++ with self.assertRaises(ValidationError): ++ self.dc_asset._validate_position_in_rack() +++ +++ def test_direct_children_rack_follows_parent_when_parent_rack_changes(self): +++ old_rack = RackFactory() +++ new_rack = RackFactory() +++ self.dc_asset.rack = old_rack +++ self.dc_asset.save() +++ first_child = DataCenterAssetFactory( +++ parent=self.dc_asset, +++ rack=old_rack, +++ ) +++ second_child = DataCenterAssetFactory( +++ parent=self.dc_asset, +++ rack=old_rack, +++ ) +++ +++ self.dc_asset.rack = new_rack +++ self.dc_asset.save() +++ first_child.refresh_from_db() +++ second_child.refresh_from_db() +++ +++ self.assertEqual(first_child.rack_id, new_rack.id) +++ self.assertEqual(second_child.rack_id, new_rack.id) +++ +++ def test_rack_sync_is_limited_to_direct_children(self): +++ old_rack = RackFactory() +++ new_rack = RackFactory() +++ self.dc_asset.rack = old_rack +++ self.dc_asset.save() +++ direct_child = DataCenterAssetFactory(parent=self.dc_asset, rack=old_rack) +++ unrelated_asset = DataCenterAssetFactory(rack=old_rack) +++ +++ self.dc_asset.rack = new_rack +++ self.dc_asset.save() +++ direct_child.refresh_from_db() +++ unrelated_asset.refresh_from_db() +++ +++ self.assertEqual(direct_child.rack_id, new_rack.id) +++ self.assertEqual(unrelated_asset.rack_id, old_rack.id) +++ +++ def test_saving_parent_without_rack_change_does_not_change_child_rack(self): +++ parent_rack = RackFactory() +++ child_rack = RackFactory() +++ self.dc_asset.rack = parent_rack +++ self.dc_asset.save() +++ child = DataCenterAssetFactory(parent=self.dc_asset, rack=child_rack) +++ +++ self.dc_asset.save() +++ child.refresh_from_db() +++ +++ self.assertEqual(child.rack_id, child_rack.id) +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 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++ ++export PATH="$HOME/.pyenv/bin:$PATH" ++eval "$(pyenv init -)" ++pyenv global 3.5.10 ++ ++ ++case "${1:-}" in ++ base) ++ git apply --reverse --check /testbed/mimo_test.patch >/tmp/fixture_reverse_check.log 2>&1 ++ reverse_available=$? ++ if [ "$reverse_available" -eq 0 ]; then ++ git apply --reverse --whitespace=nowarn /testbed/mimo_test.patch ++ fi ++ DJANGO_SETTINGS_MODULE=ralph.settings.test django-admin test \ ++ ralph.data_center.tests.test_models -v2 ++ test_exit=$? ++ if [ "$reverse_available" -eq 0 ]; then ++ git apply --whitespace=nowarn /testbed/mimo_test.patch ++ fi ++ exit "$test_exit" ++ ;; ++ new) ++ DJANGO_SETTINGS_MODULE=ralph.settings.test django-admin test \ ++ ralph.data_center.tests.test_models.DataCenterAssetTest.test_direct_children_rack_follows_parent_when_parent_rack_changes \ ++ ralph.data_center.tests.test_models.DataCenterAssetTest.test_rack_sync_is_limited_to_direct_children \ ++ ralph.data_center.tests.test_models.DataCenterAssetTest.test_saving_parent_without_rack_change_does_not_change_child_rack \ ++ -v2 ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-000352/tests/test.sh b/tasks/format-code-task-000352/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..57e03219bc47b0297f64ea660e726367dbb3cc07 --- /dev/null +++ b/tasks/format-code-task-000352/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/ralph/data_center/tests/test_models.py +mimo_test.patch +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-000352/tests/test_command.sh b/tasks/format-code-task-000352/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-000352/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-000363/environment/Dockerfile b/tasks/format-code-task-000363/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..57833c47ec6a80869ee524796ad0a665f0f0d95c --- /dev/null +++ b/tasks/format-code-task-000363/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:b3abb277933470c8f3e330ea2d52775f3eac689c45ec0b1b69e329a639e08fc7 diff --git a/tasks/format-code-task-000363/environment/setup/files/blocklist b/tasks/format-code-task-000363/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000363/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-000363/environment/setup/setup.sh b/tasks/format-code-task-000363/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000363/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-000363/tests/test.patch b/tasks/format-code-task-000363/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..f085ea1b99ccdba82ca5ca043bdacefa06b5ceb6 --- /dev/null +++ b/tasks/format-code-task-000363/tests/test.patch @@ -0,0 +1,122 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..9454a2e +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest tests/trading/trading_client/test_position_routes.py tests/broker/broker_client/test_trading_routes.py -v"] ++} +diff --git a/tests/broker/broker_client/test_trading_routes.py b/tests/broker/broker_client/test_trading_routes.py +index 321ff3e..245d596 100644 +--- a/tests/broker/broker_client/test_trading_routes.py ++++ b/tests/broker/broker_client/test_trading_routes.py +@@ -287,6 +287,44 @@ def test_close_all_positions_for_account(reqmock, client: BrokerClient): + assert isinstance(close_orders[0], ClosePositionResponse) + + ++def test_close_all_positions_for_account_partial_failed_body( ++ reqmock, client: BrokerClient ++): ++ """API returns failed-close body with only code/message — must parse successfully.""" ++ account_id = "2a87c088-ffb6-472b-a4a3-cd9305c8605c" ++ ++ reqmock.delete( ++ f"{BaseURL.BROKER_SANDBOX.value}/v1/trading/accounts/{account_id}/positions", ++ text=""" ++ [ ++ { ++ "symbol": "SQQQ", ++ "status": 403, ++ "body": { ++ "code": 40310000, ++ "message": "insufficient qty available for order (requested: 1000, available: 0)" ++ } ++ } ++ ] ++ """, ++ ) ++ ++ close_orders = client.close_all_positions_for_account( ++ account_id, cancel_orders=False ++ ) ++ ++ assert isinstance(close_orders, list) ++ assert len(close_orders) == 1 ++ assert isinstance(close_orders[0], ClosePositionResponse) ++ assert close_orders[0].status == 403 ++ assert close_orders[0].body is not None ++ assert close_orders[0].body.code == 40310000 ++ assert close_orders[0].body.available is None ++ assert close_orders[0].body.existing_qty is None ++ assert close_orders[0].body.held_for_orders is None ++ assert close_orders[0].body.symbol is None ++ ++ + def test_close_position_for_account_with_id(reqmock, client: BrokerClient): + account_id = "2a87c088-ffb6-472b-a4a3-cd9305c8605c" + asset_id = UUID("904837e3-3b76-47ec-b432-046db621571b") +diff --git a/tests/trading/trading_client/test_position_routes.py b/tests/trading/trading_client/test_position_routes.py +index 6eb37ba..a1eea3f 100644 +--- a/tests/trading/trading_client/test_position_routes.py ++++ b/tests/trading/trading_client/test_position_routes.py +@@ -219,6 +219,46 @@ def test_close_all_positions(reqmock, trading_client: TradingClient): + assert isinstance(close_orders[0], ClosePositionResponse) + + ++def test_close_all_positions_partial_failed_body( ++ reqmock, trading_client: TradingClient ++): ++ """Issue reproduction: API returns failed-close body with only code/message, ++ no available/existing_qty/held_for_orders/symbol — must parse successfully.""" ++ reqmock.delete( ++ f"{BaseURL.TRADING_PAPER.value}/v2/positions", ++ text=""" ++ [ ++ { ++ "symbol": "SQQQ", ++ "status": 403, ++ "body": { ++ "code": 40310000, ++ "message": "insufficient qty available for order (requested: 1000, available: 0)" ++ } ++ } ++ ] ++ """, ++ ) ++ ++ close_orders = trading_client.close_all_positions(cancel_orders=False) ++ ++ assert isinstance(close_orders, list) ++ assert len(close_orders) == 1 ++ assert isinstance(close_orders[0], ClosePositionResponse) ++ assert close_orders[0].status == 403 ++ assert close_orders[0].body is not None ++ assert close_orders[0].body.code == 40310000 ++ assert ( ++ close_orders[0].body.message ++ == "insufficient qty available for order (requested: 1000, available: 0)" ++ ) ++ ++ assert close_orders[0].body.available is None ++ assert close_orders[0].body.existing_qty is None ++ assert close_orders[0].body.held_for_orders is None ++ assert close_orders[0].body.symbol is None ++ ++ + def test_close_position_with_id(reqmock, trading_client: TradingClient): + asset_id = UUID("904837e3-3b76-47ec-b432-046db621571b") + +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 tests/broker/broker_client/test_trading_routes.py::test_close_all_positions_for_account_partial_failed_body tests/trading/trading_client/test_position_routes.py::test_close_all_positions_partial_failed_body ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000363/tests/test.sh b/tasks/format-code-task-000363/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..e3cddcc37cd78cf39047ca5a17cb9e101ddf9f8c --- /dev/null +++ b/tasks/format-code-task-000363/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/broker/broker_client/test_trading_routes.py +tests/trading/trading_client/test_position_routes.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-000363/tests/test_command.sh b/tasks/format-code-task-000363/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000363/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-000364/environment/Dockerfile b/tasks/format-code-task-000364/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d52093b2e9fcf1ab7958ccfd2bf78f007261d623 --- /dev/null +++ b/tasks/format-code-task-000364/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:5178eb2f2ee486812af1f21f9eaabf207cd0defdef4a491b1dac84eb179abe3d diff --git a/tasks/format-code-task-000364/environment/setup/files/blocklist b/tasks/format-code-task-000364/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000364/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-000364/environment/setup/setup.sh b/tasks/format-code-task-000364/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000364/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-000364/tests/test.patch b/tasks/format-code-task-000364/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ee61041b8f7cce88d8d48ca5fd645d4c0d327950 --- /dev/null +++ b/tasks/format-code-task-000364/tests/test.patch @@ -0,0 +1,402 @@ +diff --git a/tests/broker/broker_client/test_funding_routes.py b/tests/broker/broker_client/test_funding_routes.py +new file mode 100644 +index 0000000..56f7a3c +--- /dev/null ++++ b/tests/broker/broker_client/test_funding_routes.py +@@ -0,0 +1,367 @@ ++from typing import Iterator, List ++ ++import pytest ++import requests_mock ++from requests_mock import Mocker ++ ++from alpaca.broker.client import BrokerClient ++from alpaca.broker.enums import ( ++ ACHRelationshipStatus, ++ BankAccountType, ++ BankStatus, ++ IdentifierType, ++) ++from alpaca.broker.models import ( ++ ACHRelationship, ++ Bank, ++ CreateACHRelationshipRequest, ++ CreateBankRequest, ++ CreatePlaidRelationshipRequest, ++) ++from alpaca.common.enums import BaseURL ++ ++ ++@pytest.fixture ++def reqmock() -> Iterator[Mocker]: ++ with requests_mock.Mocker() as m: ++ yield m ++ ++ ++@pytest.fixture ++def client(): ++ client = BrokerClient( ++ "key-id", ++ "secret-key", ++ sandbox=True, ++ ) ++ return client ++ ++ ++ACCOUNT_ID = "0d18ae51-3c94-4511-b412-6664530b6243" ++ ++ ++ACH_RELATIONSHIP_JSON = """ ++{ ++ "id": "794c5dba-7d3f-4f0a-8e44-1a0b1d6f9a2b", ++ "account_id": "0d18ae51-3c94-4511-b412-6664530b6243", ++ "created_at": "2022-04-12T12:00:00Z", ++ "updated_at": "2022-04-12T12:00:00Z", ++ "status": "APPROVED", ++ "account_owner_name": "John Doe", ++ "bank_account_type": "CHECKING", ++ "bank_account_number": "123456789abc", ++ "bank_routing_number": "121000358", ++ "nickname": "Bank of America Checking" ++} ++""" ++ ++ ++BANK_JSON = """ ++{ ++ "id": "9b0f0a3a-4f6e-4a3c-9c64-1b5d51d6f9a2", ++ "account_id": "0d18ae51-3c94-4511-b412-6664530b6243", ++ "created_at": "2022-04-12T12:00:00Z", ++ "updated_at": "2022-04-12T12:00:00Z", ++ "name": "my checking bank", ++ "status": "QUEUED", ++ "country": "", ++ "state_province": "", ++ "postal_code": "", ++ "city": "", ++ "street_address": "", ++ "account_number": "123456789abc", ++ "bank_code": "123456789", ++ "bank_code_type": "ABA" ++} ++""" ++ ++ ++ ++ ++ ++def test_create_ach_relationship_for_account_with_raw_ach( ++ reqmock, client: BrokerClient ++): ++ reqmock.post( ++ BaseURL.BROKER_SANDBOX + f"/v1/accounts/{ACCOUNT_ID}/ach_relationships", ++ text=ACH_RELATIONSHIP_JSON, ++ ) ++ ++ result = client.create_ach_relationship_for_account( ++ account_id=ACCOUNT_ID, ++ ach_data=CreateACHRelationshipRequest( ++ account_owner_name="John Doe", ++ bank_account_type=BankAccountType.CHECKING, ++ bank_account_number="123456789abc", ++ bank_routing_number="121000358", ++ nickname="Bank of America Checking", ++ ), ++ ) ++ ++ assert reqmock.called_once ++ assert reqmock.request_history[0].method == "POST" ++ ++ body = reqmock.request_history[0].json() ++ assert body["account_owner_name"] == "John Doe" ++ assert body["bank_account_type"] == "CHECKING" ++ assert body["bank_account_number"] == "123456789abc" ++ assert body["bank_routing_number"] == "121000358" ++ ++ assert isinstance(result, ACHRelationship) ++ assert str(result.id) == "794c5dba-7d3f-4f0a-8e44-1a0b1d6f9a2b" ++ assert isinstance(result.status, ACHRelationshipStatus) ++ assert result.status == ACHRelationshipStatus.APPROVED ++ assert isinstance(result.bank_account_type, BankAccountType) ++ assert result.bank_account_type == BankAccountType.CHECKING ++ ++ ++def test_create_ach_relationship_for_account_with_plaid( ++ reqmock, client: BrokerClient ++): ++ reqmock.post( ++ BaseURL.BROKER_SANDBOX + f"/v1/accounts/{ACCOUNT_ID}/ach_relationships", ++ text=ACH_RELATIONSHIP_JSON, ++ ) ++ ++ result = client.create_ach_relationship_for_account( ++ account_id=ACCOUNT_ID, ++ ach_data=CreatePlaidRelationshipRequest(processor_token="processor-token-xyz"), ++ ) ++ ++ assert reqmock.called_once ++ assert reqmock.request_history[0].method == "POST" ++ assert reqmock.request_history[0].json()["processor_token"] == "processor-token-xyz" ++ assert isinstance(result, ACHRelationship) ++ ++ ++def test_create_ach_relationship_for_account_rejects_bad_data_type( ++ reqmock, client: BrokerClient ++): ++ with pytest.raises(ValueError): ++ client.create_ach_relationship_for_account( ++ account_id=ACCOUNT_ID, ++ ach_data={"account_owner_name": "John Doe"}, ++ ) ++ ++ assert not reqmock.called ++ ++ ++def test_create_ach_relationship_for_account_validates_account_id( ++ reqmock, client: BrokerClient ++): ++ with pytest.raises(ValueError): ++ client.create_ach_relationship_for_account( ++ account_id="not a uuid", ++ ach_data=CreatePlaidRelationshipRequest(processor_token="tok"), ++ ) ++ ++ assert not reqmock.called ++ ++ ++def test_get_ach_relationships_for_account_no_statuses(reqmock, client: BrokerClient): ++ reqmock.get( ++ BaseURL.BROKER_SANDBOX + f"/v1/accounts/{ACCOUNT_ID}/ach_relationships", ++ text=f"[{ACH_RELATIONSHIP_JSON}]", ++ ) ++ ++ result = client.get_ach_relationships_for_account(account_id=ACCOUNT_ID) ++ ++ assert reqmock.called_once ++ assert reqmock.request_history[0].method == "GET" ++ assert "statuses" not in reqmock.request_history[0].qs ++ assert isinstance(result, List) ++ assert len(result) == 1 ++ assert isinstance(result[0], ACHRelationship) ++ ++ ++def test_get_ach_relationships_for_account_with_statuses( ++ reqmock, client: BrokerClient ++): ++ reqmock.get( ++ BaseURL.BROKER_SANDBOX + f"/v1/accounts/{ACCOUNT_ID}/ach_relationships", ++ text=f"[{ACH_RELATIONSHIP_JSON}]", ++ ) ++ ++ client.get_ach_relationships_for_account( ++ account_id=ACCOUNT_ID, ++ statuses=[ACHRelationshipStatus.APPROVED, ACHRelationshipStatus.PENDING], ++ ) ++ ++ assert reqmock.called_once ++ ++ assert reqmock.request_history[0].qs == {"statuses": ["approved,pending"]} ++ ++ ++def test_get_ach_relationships_for_account_validates_account_id( ++ reqmock, client: BrokerClient ++): ++ with pytest.raises(ValueError): ++ client.get_ach_relationships_for_account(account_id="not a uuid") ++ ++ assert not reqmock.called ++ ++ ++def test_delete_ach_relationship_for_account(reqmock, client: BrokerClient): ++ relationship_id = "794c5dba-7d3f-4f0a-8e44-1a0b1d6f9a2b" ++ reqmock.delete( ++ BaseURL.BROKER_SANDBOX ++ + f"/v1/accounts/{ACCOUNT_ID}/ach_relationships/{relationship_id}", ++ status_code=204, ++ ) ++ ++ result = client.delete_ach_relationship_for_account( ++ account_id=ACCOUNT_ID, ++ ach_relationship_id=relationship_id, ++ ) ++ ++ assert reqmock.called_once ++ assert reqmock.request_history[0].method == "DELETE" ++ assert result is None ++ ++ ++def test_delete_ach_relationship_for_account_validates_uuids( ++ reqmock, client: BrokerClient ++): ++ valid = "794c5dba-7d3f-4f0a-8e44-1a0b1d6f9a2b" ++ ++ with pytest.raises(ValueError): ++ client.delete_ach_relationship_for_account( ++ account_id=ACCOUNT_ID, ach_relationship_id="not a uuid" ++ ) ++ ++ with pytest.raises(ValueError): ++ client.delete_ach_relationship_for_account( ++ account_id="not a uuid", ach_relationship_id=valid ++ ) ++ ++ assert not reqmock.called ++ ++ ++ ++ ++ ++def test_create_bank_for_account(reqmock, client: BrokerClient): ++ reqmock.post( ++ BaseURL.BROKER_SANDBOX + f"/v1/accounts/{ACCOUNT_ID}/recipient_banks", ++ text=BANK_JSON, ++ ) ++ ++ result = client.create_bank_for_account( ++ account_id=ACCOUNT_ID, ++ bank_data=CreateBankRequest( ++ name="my checking bank", ++ bank_code_type=IdentifierType.ABA, ++ bank_code="123456789", ++ account_number="123456789abc", ++ ), ++ ) ++ ++ assert reqmock.called_once ++ assert reqmock.request_history[0].method == "POST" ++ ++ body = reqmock.request_history[0].json() ++ assert body["name"] == "my checking bank" ++ assert body["bank_code_type"] == "ABA" ++ assert body["bank_code"] == "123456789" ++ assert body["account_number"] == "123456789abc" ++ ++ assert isinstance(result, Bank) ++ assert str(result.id) == "9b0f0a3a-4f6e-4a3c-9c64-1b5d51d6f9a2" ++ assert isinstance(result.status, BankStatus) ++ assert result.status == BankStatus.QUEUED ++ assert isinstance(result.bank_code_type, IdentifierType) ++ assert result.bank_code_type == IdentifierType.ABA ++ ++ ++def test_get_banks_for_account(reqmock, client: BrokerClient): ++ reqmock.get( ++ BaseURL.BROKER_SANDBOX + f"/v1/accounts/{ACCOUNT_ID}/recipient_banks", ++ text=f"[{BANK_JSON}]", ++ ) ++ ++ result = client.get_banks_for_account(account_id=ACCOUNT_ID) ++ ++ assert reqmock.called_once ++ assert reqmock.request_history[0].method == "GET" ++ assert isinstance(result, List) ++ assert len(result) == 1 ++ assert isinstance(result[0], Bank) ++ ++ ++def test_delete_bank_for_account(reqmock, client: BrokerClient): ++ bank_id = "9b0f0a3a-4f6e-4a3c-9c64-1b5d51d6f9a2" ++ reqmock.delete( ++ BaseURL.BROKER_SANDBOX + f"/v1/accounts/{ACCOUNT_ID}/recipient_banks/{bank_id}", ++ status_code=204, ++ ) ++ ++ result = client.delete_bank_for_account(account_id=ACCOUNT_ID, bank_id=bank_id) ++ ++ assert reqmock.called_once ++ assert reqmock.request_history[0].method == "DELETE" ++ assert result is None ++ ++ ++def test_delete_bank_for_account_validates_uuids(reqmock, client: BrokerClient): ++ valid = "9b0f0a3a-4f6e-4a3c-9c64-1b5d51d6f9a2" ++ ++ with pytest.raises(ValueError): ++ client.delete_bank_for_account(account_id=ACCOUNT_ID, bank_id="not a uuid") ++ ++ with pytest.raises(ValueError): ++ client.delete_bank_for_account(account_id="not a uuid", bank_id=valid) ++ ++ assert not reqmock.called ++ ++ ++ ++ ++ ++def test_create_bank_request_domestic_is_valid(): ++ request = CreateBankRequest( ++ name="my checking bank", ++ bank_code_type=IdentifierType.ABA, ++ bank_code="123456789", ++ account_number="123456789abc", ++ ) ++ ++ assert request.bank_code_type == IdentifierType.ABA ++ ++ ++def test_create_bank_request_domestic_rejects_international_fields(): ++ with pytest.raises(ValueError): ++ CreateBankRequest( ++ name="my checking bank", ++ bank_code_type=IdentifierType.ABA, ++ bank_code="123456789", ++ account_number="123456789abc", ++ country="USA", ++ ) ++ ++ ++def test_create_bank_request_international_is_valid(): ++ request = CreateBankRequest( ++ name="my international bank", ++ bank_code_type=IdentifierType.BIC, ++ bank_code="BUKBGB22", ++ account_number="123456789abc", ++ country="United Kingdom", ++ state_province="England", ++ postal_code="E14 5HP", ++ city="London", ++ street_address="1 Churchill Place", ++ ) ++ ++ assert request.bank_code_type == IdentifierType.BIC ++ ++ ++def test_create_bank_request_international_requires_location_fields(): ++ with pytest.raises(ValueError): ++ CreateBankRequest( ++ name="my international bank", ++ bank_code_type=IdentifierType.BIC, ++ bank_code="BUKBGB22", ++ account_number="123456789abc", ++ country="United Kingdom", ++ ++ ) +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 ++ ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++PYTEST="/testbed/.build_env/.venv/bin/python -m pytest" ++ ++ ++$PYTEST \ ++ tests/broker/broker_client/test_documents_routes.py \ ++ tests/broker/broker_client/test_accounts_routes.py \ ++ tests/broker/broker_client/test_account_activities_routes.py \ ++ tests/broker/test_models.py \ ++ tests/broker/test_enums.py \ ++ -q ++ ++ ++$PYTEST tests/broker/broker_client/test_funding_routes.py -q diff --git a/tasks/format-code-task-000364/tests/test.sh b/tasks/format-code-task-000364/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..2b5ddad8c2d18aef950c8ff5dfce135022a106ce --- /dev/null +++ b/tasks/format-code-task-000364/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/broker/broker_client/test_funding_routes.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-000364/tests/test_command.sh b/tasks/format-code-task-000364/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000364/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-000390/environment/Dockerfile b/tasks/format-code-task-000390/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..3c7e2faa236218dd466e35c9a457e014c075b905 --- /dev/null +++ b/tasks/format-code-task-000390/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:7f1fdcd1ee21e4912248d85058a72aef449ab406186e9aa9bbcb34bea10ca674 diff --git a/tasks/format-code-task-000390/environment/setup/files/blocklist b/tasks/format-code-task-000390/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000390/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-000390/environment/setup/setup.sh b/tasks/format-code-task-000390/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000390/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-000390/tests/test.patch b/tasks/format-code-task-000390/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..909151f9ffef0726c21555cf804f933b66a71763 --- /dev/null +++ b/tasks/format-code-task-000390/tests/test.patch @@ -0,0 +1,207 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..1eecc83 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest tests/test_url_path_preservation.py -v"] ++} +diff --git a/tests/test_url_path_preservation.py b/tests/test_url_path_preservation.py +new file mode 100644 +index 0000000..e305345 +--- /dev/null ++++ b/tests/test_url_path_preservation.py +@@ -0,0 +1,179 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++import json ++ ++import pytest ++from aioresponses import aioresponses ++ ++from ansible_rulebook.exception import ( ++ ControllerApiException, ++ JobTemplateNotFoundException, ++) ++from ansible_rulebook.job_template_runner import JobTemplateRunner ++ ++NO_RESULTS_PAGE = json.dumps( ++ dict(count=0, next=None, previous=None, results=[]) ++) ++ ++ ++def _make_runner(host: str) -> JobTemplateRunner: ++ runner = JobTemplateRunner() ++ runner.host = host ++ runner.token = "DUMMY" ++ runner.refresh_delay = 0.05 ++ return runner ++ ++ ++@pytest.mark.asyncio ++async def test_get_config_relative_path_with_trailing_slash(): ++ ++ runner = _make_runner("http://awx-demo-service.awx/awx/") ++ try: ++ with aioresponses() as m: ++ m.get( ++ "http://awx-demo-service.awx/awx/api/v2/config/", ++ status=200, ++ body=json.dumps({"version": "23.6.0"}), ++ ) ++ data = await runner.get_config() ++ assert data["version"] == "23.6.0" ++ finally: ++ await runner.close_session() ++ ++ ++@pytest.mark.asyncio ++async def test_get_config_relative_path_no_trailing_slash(): ++ ++ runner = _make_runner("http://awx-demo-service/awx") ++ try: ++ with aioresponses() as m: ++ m.get( ++ "http://awx-demo-service/awx/api/v2/config/", ++ status=200, ++ body=json.dumps({"version": "23.6.0"}), ++ ) ++ data = await runner.get_config() ++ assert data["version"] == "23.6.0" ++ finally: ++ await runner.close_session() ++ ++ ++@pytest.mark.asyncio ++async def test_get_config_no_relative_path_with_trailing_slash(): ++ ++ runner = _make_runner("http://example.com/") ++ try: ++ with aioresponses() as m: ++ m.get( ++ "http://example.com/api/v2/config/", ++ status=200, ++ body=json.dumps({"version": "1.0"}), ++ ) ++ data = await runner.get_config() ++ assert data["version"] == "1.0" ++ finally: ++ await runner.close_session() ++ ++ ++@pytest.mark.asyncio ++async def test_get_config_no_relative_path_no_trailing_slash(): ++ ++ runner = _make_runner("http://example.com") ++ try: ++ with aioresponses() as m: ++ m.get( ++ "http://example.com/api/v2/config/", ++ status=200, ++ body=json.dumps({"version": "1.0"}), ++ ) ++ data = await runner.get_config() ++ assert data["version"] == "1.0" ++ finally: ++ await runner.close_session() ++ ++ ++@pytest.mark.asyncio ++async def test_get_config_does_not_use_buggy_no_prefix_url(): ++ ++ ++ ++ ++ ++ ++ ++ runner = _make_runner("http://awx-demo-service.awx/awx/") ++ try: ++ with aioresponses() as m: ++ m.get( ++ "http://awx-demo-service.awx/api/v2/config/", ++ status=200, ++ body=json.dumps({"version": "WRONG"}), ++ ) ++ with pytest.raises(ControllerApiException): ++ await runner.get_config() ++ finally: ++ await runner.close_session() ++ ++ ++@pytest.mark.asyncio ++async def test_unified_template_slug_preserves_relative_path(): ++ ++ runner = _make_runner("http://awx-demo-service.awx/awx/") ++ try: ++ with aioresponses() as m: ++ m.get( ++ "http://awx-demo-service.awx/awx/api/v2/unified_job_templates/" ++ "?name=JT1", ++ status=200, ++ body=NO_RESULTS_PAGE, ++ ) ++ with pytest.raises(JobTemplateNotFoundException): ++ await runner.run_job_template("JT1", "Default", {}) ++ finally: ++ await runner.close_session() ++ ++ ++@pytest.mark.asyncio ++async def test_unified_template_slug_preserves_relative_path_no_trailing_slash(): ++ ++ ++ runner = _make_runner("http://awx-demo-service/awx") ++ try: ++ with aioresponses() as m: ++ m.get( ++ "http://awx-demo-service/awx/api/v2/unified_job_templates/" ++ "?name=JT1", ++ status=200, ++ body=NO_RESULTS_PAGE, ++ ) ++ with pytest.raises(JobTemplateNotFoundException): ++ await runner.run_job_template("JT1", "Default", {}) ++ finally: ++ await runner.close_session() ++ ++ ++@pytest.mark.asyncio ++async def test_unified_template_slug_does_not_use_buggy_no_prefix_url(): ++ ++ runner = _make_runner("http://awx-demo-service.awx/awx/") ++ try: ++ with aioresponses() as m: ++ ++ m.get( ++ "http://awx-demo-service.awx/api/v2/unified_job_templates/" ++ "?name=JT1", ++ status=200, ++ body=NO_RESULTS_PAGE, ++ ) ++ ++ ++ with pytest.raises(ControllerApiException): ++ await runner.run_job_template("JT1", "Default", {}) ++ finally: ++ await runner.close_session() +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 tests/test_url_path_preservation.py::test_get_config_relative_path_with_trailing_slash tests/test_url_path_preservation.py::test_get_config_relative_path_no_trailing_slash tests/test_url_path_preservation.py::test_get_config_no_relative_path_with_trailing_slash tests/test_url_path_preservation.py::test_get_config_no_relative_path_no_trailing_slash tests/test_url_path_preservation.py::test_get_config_does_not_use_buggy_no_prefix_url tests/test_url_path_preservation.py::test_unified_template_slug_preserves_relative_path tests/test_url_path_preservation.py::test_unified_template_slug_preserves_relative_path_no_trailing_slash tests/test_url_path_preservation.py::test_unified_template_slug_does_not_use_buggy_no_prefix_url ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000390/tests/test.sh b/tasks/format-code-task-000390/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..bdb74ea9b9f5658fcc8212f75859c377fe2e9b38 --- /dev/null +++ b/tasks/format-code-task-000390/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_url_path_preservation.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-000390/tests/test_command.sh b/tasks/format-code-task-000390/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000390/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-000399/environment/Dockerfile b/tasks/format-code-task-000399/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e54cf1b38727409b0875a067f505c3b201e1d885 --- /dev/null +++ b/tasks/format-code-task-000399/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:035116aa9b0cb53148646519cbdaed519b68f5e1aecc63468987486fd8f62072 diff --git a/tasks/format-code-task-000399/environment/setup/files/blocklist b/tasks/format-code-task-000399/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000399/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-000399/environment/setup/setup.sh b/tasks/format-code-task-000399/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000399/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-000399/tests/test.patch b/tasks/format-code-task-000399/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..02aaac85b1b800d06fd7b64f249e76f96e4d1284 --- /dev/null +++ b/tasks/format-code-task-000399/tests/test.patch @@ -0,0 +1,86 @@ +diff --git a/pkg/agent/config/traffic_encap_mode_test.go b/pkg/agent/config/traffic_encap_mode_test.go +index 119081164..fb1a04fd2 100644 +--- a/pkg/agent/config/traffic_encap_mode_test.go ++++ b/pkg/agent/config/traffic_encap_mode_test.go +@@ -15,6 +15,7 @@ + package config + + import ( ++ "strings" + "testing" + + "github.com/stretchr/testify/assert" +@@ -66,6 +67,20 @@ func TestTrafficEncapModeTypeString(t *testing.T) { + assert.Equal(t, tt.expMode, actualMode, "String did not return correct traffic type in string format") + }) + } ++ t.Run("invalid-mode", func(t *testing.T) { ++ var got string ++ assert.NotPanics(t, func() { ++ got = TrafficEncapModeType(TrafficEncapModeInvalid).String() ++ }, "TrafficEncapModeType.String for Invalid must not panic") ++ assert.True(t, strings.EqualFold("invalid", got) || got != "", ++ "TrafficEncapModeType.String for Invalid should return a non-empty representation, got %q", got) ++ }) ++} ++ ++func TestTrafficEncapModeInvalidStringDoesNotPanic(t *testing.T) { ++ assert.NotPanics(t, func() { ++ _ = TrafficEncapModeType(TrafficEncapModeInvalid).String() ++ }, "TrafficEncapModeInvalid.String() must not panic") + } + + func TestTrafficEncapModeTypeSupports(t *testing.T) { +diff --git a/pkg/agent/config/traffic_encryption_mode_test.go b/pkg/agent/config/traffic_encryption_mode_test.go +index 3aebda6cf..4d6d76914 100644 +--- a/pkg/agent/config/traffic_encryption_mode_test.go ++++ b/pkg/agent/config/traffic_encryption_mode_test.go +@@ -15,6 +15,7 @@ + package config + + import ( ++ "strings" + "testing" + + "github.com/stretchr/testify/assert" +@@ -63,4 +64,18 @@ func TestTrafficEncryptionModeType_String(t *testing.T) { + assert.Equal(t, tt.want, tt.m.String(), "TrafficEncryptionModeType.String did not return correct string representation") + }) + } ++ t.Run("Invalid", func(t *testing.T) { ++ var got string ++ assert.NotPanics(t, func() { ++ got = TrafficEncryptionModeType(TrafficEncryptionModeInvalid).String() ++ }, "TrafficEncryptionModeType.String for Invalid must not panic") ++ assert.True(t, strings.EqualFold("invalid", got) || got != "", ++ "TrafficEncryptionModeType.String for Invalid should return a non-empty representation, got %q", got) ++ }) ++} ++ ++func TestTrafficEncryptionModeInvalidStringDoesNotPanic(t *testing.T) { ++ assert.NotPanics(t, func() { ++ _ = TrafficEncryptionModeType(TrafficEncryptionModeInvalid).String() ++ }, "TrafficEncryptionModeInvalid.String() must not panic") + } +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..88c49dcab +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["go test ./pkg/agent/config/... -run 'TrafficEncap|TrafficEncryption'"] ++} +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/agent/config/... -run 'TrafficEncap|TrafficEncryption' ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000399/tests/test.sh b/tasks/format-code-task-000399/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..6b67d89b141321e23186f59c63059dc76fa31e85 --- /dev/null +++ b/tasks/format-code-task-000399/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' +pkg/agent/config/traffic_encap_mode_test.go +pkg/agent/config/traffic_encryption_mode_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-000399/tests/test_command.sh b/tasks/format-code-task-000399/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000399/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-000504/environment/Dockerfile b/tasks/format-code-task-000504/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d4d4c1c66eae700e74e89b058979514dbdad0897 --- /dev/null +++ b/tasks/format-code-task-000504/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:69ca5fd0dd89f0e62a441d59f203e3f985cca9e09ed7b82dd6e146558dae5098 diff --git a/tasks/format-code-task-000504/environment/setup/files/blocklist b/tasks/format-code-task-000504/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000504/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-000504/environment/setup/setup.sh b/tasks/format-code-task-000504/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000504/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-000504/tests/test.patch b/tasks/format-code-task-000504/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..a1f0f4837a90e4c2c126e85fe8807de2c7c62573 --- /dev/null +++ b/tasks/format-code-task-000504/tests/test.patch @@ -0,0 +1,57 @@ +diff --git a/events/apigw_test.go b/events/apigw_test.go +index 6615899e..89eab6ff 100644 +--- a/events/apigw_test.go ++++ b/events/apigw_test.go +@@ -209,3 +209,32 @@ func TestApiGatewayRestApiOpenApiRequestMarshaling(t *testing.T) { + + assert.JSONEq(t, string(inputJSON), string(outputJSON)) + } ++ ++func TestApiGatewayV2HTTPRequestMarshaling(t *testing.T) { ++ ++ ++ inputJSON, err := ioutil.ReadFile("./testdata/apigw-v2-request.json") ++ if err != nil { ++ t.Errorf("could not open test file. details: %v", err) ++ } ++ ++ ++ var inputEvent APIGatewayV2HTTPRequest ++ if err := json.Unmarshal(inputJSON, &inputEvent); err != nil { ++ t.Errorf("could not unmarshal event. details: %v", err) ++ } ++ ++ ++ authContext := inputEvent.RequestContext.Authorizer ++ if authContext.JWT.Claims["claim1"] != "value1" { ++ t.Errorf("could not extract authorizer claim from JWT: %v", authContext) ++ } ++ ++ ++ outputJSON, err := json.Marshal(inputEvent) ++ if err != nil { ++ t.Errorf("could not marshal event. details: %v", err) ++ } ++ ++ assert.JSONEq(t, string(inputJSON), string(outputJSON)) ++} +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+3RQQrCMBCF4aw9xVzANonGrDxLsW1QQRuwac9v7UJFUDcVEf9vMwMTyIOXld3+ ++UBeh6XP1KXrgnRvn4HGOu3HWWO390niljVlpr8R9LNGdrk2bk4g6xZhevXt3/1HZrf8U2lRU8Xjc ++NHXW7qb7423/zl77X3g79L9cWa1ETxfhuT/vv6plLL4M9Wwb5bJKloc+NKnNZd7LvIpdk9Zm9u2k ++AAAAAAAAAAAAAAAAAB6dAec2ZYMAKAAA +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-000504/tests/test.sh b/tasks/format-code-task-000504/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..5adddda26432cd9cfdfeedf5d88e746cb295992f --- /dev/null +++ b/tasks/format-code-task-000504/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' +events/apigw_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-000504/tests/test_command.sh b/tasks/format-code-task-000504/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000504/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-000532/environment/Dockerfile b/tasks/format-code-task-000532/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..9e32590ad8287922cf5cc778a793c15d3e9c2c5c --- /dev/null +++ b/tasks/format-code-task-000532/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:dd70c87597ef7a51cf7771899ac4c6a7b723c1c7ce842b14a8f9bf5adae09630 diff --git a/tasks/format-code-task-000532/environment/setup/files/blocklist b/tasks/format-code-task-000532/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000532/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-000532/environment/setup/setup.sh b/tasks/format-code-task-000532/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000532/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-000532/tests/test.patch b/tasks/format-code-task-000532/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..4fb9ee8629d11288f8500ef721e141d78aee9680 --- /dev/null +++ b/tasks/format-code-task-000532/tests/test.patch @@ -0,0 +1,194 @@ +diff --git a/tests/ConfirmTest.php b/tests/ConfirmTest.php +new file mode 100644 +index 00000000..f8e7e9bc +--- /dev/null ++++ b/tests/ConfirmTest.php +@@ -0,0 +1,158 @@ ++create(); ++ $this->assertEquals(0, $user->balance); ++ ++ $transaction = $user->deposit(100, null, false); ++ $this->assertFalse($transaction->confirmed); ++ $this->assertEquals(0, $user->balance); ++ ++ $wallet = $user->wallet; ++ $this->assertTrue($wallet->confirm($transaction)); ++ ++ $transaction->refresh(); ++ $this->assertTrue($transaction->confirmed); ++ $this->assertEquals(100, $user->balance); ++ $this->assertEquals(100, $wallet->balance); ++ } ++ ++ /** ++ * Confirming a pending withdrawal applies it to the balance. ++ */ ++ public function testConfirmWithdraw(): void ++ { ++ /** @var User $user */ ++ $user = factory(User::class)->create(); ++ $user->deposit(100); ++ $this->assertEquals(100, $user->balance); ++ ++ $transaction = $user->forceWithdraw(100, null, false); ++ $this->assertFalse($transaction->confirmed); ++ $this->assertEquals(100, $user->balance); ++ ++ $this->assertTrue($user->wallet->confirm($transaction)); ++ ++ $transaction->refresh(); ++ $this->assertTrue($transaction->confirmed); ++ $this->assertEquals(0, $user->balance); ++ } ++ ++ /** ++ * An already-confirmed transaction cannot be confirmed again. ++ */ ++ public function testConfirmAlreadyConfirmedIsRejected(): void ++ { ++ /** @var User $user */ ++ $user = factory(User::class)->create(); ++ $transaction = $user->deposit(100); ++ $this->assertTrue($transaction->confirmed); ++ $this->assertEquals(100, $user->balance); ++ ++ $this->assertFalse($user->wallet->safeConfirm($transaction)); ++ ++ $transaction->refresh(); ++ $this->assertTrue($transaction->confirmed); ++ $this->assertEquals(100, $user->balance); ++ } ++ ++ /** ++ * @see testConfirmAlreadyConfirmedIsRejected ++ */ ++ public function testConfirmAlreadyConfirmedThrows(): void ++ { ++ /** @var User $user */ ++ $user = factory(User::class)->create(); ++ $transaction = $user->deposit(100); ++ ++ $this->expectException(\Exception::class); ++ $user->wallet->confirm($transaction); ++ } ++ ++ /** ++ * A transaction can only be confirmed through its own wallet. ++ */ ++ public function testConfirmWrongOwnerIsRejected(): void ++ { ++ /** @var User $first */ ++ $first = factory(User::class)->create(); ++ /** @var User $second */ ++ $second = factory(User::class)->create(); ++ ++ $transaction = $first->deposit(100, null, false); ++ $this->assertEquals(0, $first->balance); ++ $this->assertEquals(0, $second->balance); ++ ++ $this->assertFalse($second->wallet->safeConfirm($transaction)); ++ ++ $transaction->refresh(); ++ $this->assertFalse($transaction->confirmed); ++ $this->assertEquals(0, $first->balance); ++ $this->assertEquals(0, $second->balance); ++ } ++ ++ /** ++ * @see testConfirmWrongOwnerIsRejected ++ */ ++ public function testConfirmWrongOwnerThrows(): void ++ { ++ /** @var User $first */ ++ $first = factory(User::class)->create(); ++ /** @var User $second */ ++ $second = factory(User::class)->create(); ++ ++ $transaction = $first->deposit(100, null, false); ++ ++ $this->expectException(\Exception::class); ++ $second->wallet->confirm($transaction); ++ } ++ ++ /** ++ * Confirming a withdrawal must respect available funds. ++ */ ++ public function testConfirmWithdrawInsufficientFundsIsRejected(): void ++ { ++ /** @var User $user */ ++ $user = factory(User::class)->create(); ++ $user->deposit(50); ++ $this->assertEquals(50, $user->balance); ++ ++ $transaction = $user->forceWithdraw(100, null, false); ++ $this->assertFalse($transaction->confirmed); ++ $this->assertEquals(50, $user->balance); ++ ++ $this->assertFalse($user->wallet->safeConfirm($transaction)); ++ ++ $transaction->refresh(); ++ $this->assertFalse($transaction->confirmed); ++ $this->assertEquals(50, $user->balance); ++ } ++ ++ /** ++ * The pending transaction itself does not change the balance until confirmed. ++ */ ++ public function testPendingDoesNotAffectBalance(): void ++ { ++ /** @var User $user */ ++ $user = factory(User::class)->create(); ++ ++ $deposit = $user->deposit(100, null, false); ++ $this->assertInstanceOf(Transaction::class, $deposit); ++ $this->assertFalse($deposit->confirmed); ++ $this->assertEquals(0, $user->balance); ++ } ++ ++} +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 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++for t in \ ++ tests/WalletTest.php \ ++ tests/WalletFloatTest.php \ ++ tests/MultiWalletTest.php \ ++ tests/BalanceTest.php \ ++ tests/TaxTest.php \ ++ tests/GiftTest.php \ ++ tests/CartTest.php; do ++ vendor/bin/phpunit "$t" ++done ++ ++ ++vendor/bin/phpunit tests/ConfirmTest.php diff --git a/tasks/format-code-task-000532/tests/test.sh b/tasks/format-code-task-000532/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..a4b41bf0ac249dc68c68ad37d207dae541a0143b --- /dev/null +++ b/tasks/format-code-task-000532/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/ConfirmTest.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-000532/tests/test_command.sh b/tasks/format-code-task-000532/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000532/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-000535/environment/Dockerfile b/tasks/format-code-task-000535/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..97a199c981d9517b198c17ad5ef6704b0e949fbb --- /dev/null +++ b/tasks/format-code-task-000535/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:7f64205a01c9ae65874b8c2dc0c2af0e405ac7085e68e52e8edea8eb1f6c2b13 diff --git a/tasks/format-code-task-000535/environment/setup/files/blocklist b/tasks/format-code-task-000535/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000535/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-000535/environment/setup/setup.sh b/tasks/format-code-task-000535/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000535/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-000535/tests/test.patch b/tasks/format-code-task-000535/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..c9f8ebe101ef8886802c2e260ac01e180fe0a385 --- /dev/null +++ b/tasks/format-code-task-000535/tests/test.patch @@ -0,0 +1,317 @@ +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,295 @@ ++#!/usr/bin/env bash ++ ++set -u ++export LANG=C LC_ALL=C TZ=UTC ++ ++BUILD_DIR=/tmp/audiowaveform-usecase-build ++rm -rf "$BUILD_DIR" ++( cd /workspace/repo && cmake -S . -B "$BUILD_DIR" -DENABLE_TESTS=0 >/tmp/audiowaveform-usecase-cmake.log && cmake --build "$BUILD_DIR" --target audiowaveform -j2 >/tmp/audiowaveform-usecase-build.log ) \ ++ || { echo "FAIL: build" >&2; cat /tmp/audiowaveform-usecase-cmake.log /tmp/audiowaveform-usecase-build.log >&2; exit 1; } ++BIN="$BUILD_DIR/audiowaveform" ++ ++TMP=$(mktemp -d) ++trap 'rm -rf "$TMP"' EXIT ++cd "$TMP" || exit 1 ++ ++fail() { echo "FAIL: $*" >&2; exit 1; } ++ ++DATA=/workspace/repo/test/data ++ ++python3 - "$TMP/synthetic_stereo.wav" <<'PY' ++import struct ++import sys ++import wave ++ ++path = sys.argv[1] ++with wave.open(path, "wb") as wav: ++ wav.setnchannels(2) ++ wav.setsampwidth(2) ++ wav.setframerate(16000) ++ frames = [] ++ for i in range(64): ++ frames.append((-10000 + i * 100, 20000 - i * 50)) ++ for i in range(64): ++ frames.append((12000 - i * 80, -8000 - i * 30)) ++ wav.writeframes(b"".join(struct.pack(" hi: ++ raise SystemExit(f"FAIL: {label} has min greater than max") ++PY ++} ++ ++assert_dat_payload_equals() { ++ local label=$1 ++ local path=$2 ++ local expected_csv=$3 ++ ++ ++ python3 - "$label" "$path" "$expected_csv" <<'PY' ++import struct ++import sys ++from pathlib import Path ++ ++label, path, expected_csv = sys.argv[1], Path(sys.argv[2]), sys.argv[3] ++expected = [int(value) for value in expected_csv.split(",")] ++data = path.read_bytes() ++version, flags, _sample_rate, _spp, length = struct.unpack_from(" limit for v in values): ++ raise SystemExit(f"FAIL: {label} data value outside {expected_bits}-bit range") ++if not any(values): ++ raise SystemExit(f"FAIL: {label} waveform data is all zero") ++if max(abs(v) for v in values) < min_abs_peak: ++ raise SystemExit(f"FAIL: {label} peak was not scaled as expected") ++for lo, hi in zip(values[0::2], values[1::2]): ++ if lo > hi: ++ raise SystemExit(f"FAIL: {label} has min greater than max") ++PY ++} ++ ++assert_outputs_differ() { ++ local label=$1 ++ local left=$2 ++ local right=$3 ++ ++ ++ cmp -s "$left" "$right" && fail "$label outputs should differ" ++} ++ ++ ++ ++"$BIN" -i "$TMP/synthetic_stereo.wav" -o synthetic_mono.dat -z 64 -b 8 >out 2>err; ec=$? ++assert_common_run F0 "$ec" out err synthetic_mono.dat ++assert_dat_waveform F0 synthetic_mono.dat 16000 64 8 1 2 ++assert_dat_payload_equals F0 synthetic_mono.dat "19,25,-5,7" ++ ++"$BIN" -i "$TMP/synthetic_stereo.wav" -o synthetic_split.dat -z 64 -b 8 --split-channels >out 2>err; ec=$? ++assert_common_run F0_split "$ec" out err synthetic_split.dat ++assert_dat_waveform F0_split synthetic_split.dat 16000 64 8 2 2 ++assert_dat_payload_equals F0_split synthetic_split.dat "-39,-14,65,78,27,46,-38,-31" ++ ++ ++ ++ ++"$BIN" -i "$DATA/test_file_stereo.wav" -o wav_dat.out.dat -z 64 -b 8 >out 2>err; ec=$? ++assert_common_run F1 "$ec" out err wav_dat.out.dat ++assert_dat_waveform F1 wav_dat.out.dat 16000 64 8 1 1774 ++ ++ ++ ++ ++"$BIN" -i "$DATA/test_file_stereo.mp3" -o mp3_json.out.json -z 64 -b 8 >out 2>err; ec=$? ++assert_common_run F2 "$ec" out err mp3_json.out.json ++assert_json_waveform F2 mp3_json.out.json 16000 64 8 1 1774 ++ ++ ++ ++ ++"$BIN" -i "$DATA/test_file_stereo.flac" -o flac_dat.out.dat -z 64 -b 8 >out 2>err; ec=$? ++assert_common_run F3 "$ec" out err flac_dat.out.dat ++assert_dat_waveform F3 flac_dat.out.dat 16000 64 8 1 1774 ++ ++ ++ ++ ++"$BIN" -i "$DATA/test_file_stereo.oga" -o ogg_json.out.json -z 64 -b 8 >out 2>err; ec=$? ++assert_common_run F4 "$ec" out err ogg_json.out.json ++assert_json_waveform F4 ogg_json.out.json 16000 64 8 1 1774 ++ ++ ++ ++ ++"$BIN" -i "$DATA/test_file_stereo.opus" -o opus_dat.out.dat -z 64 -b 8 >out 2>err; ec=$? ++assert_common_run F5 "$ec" out err opus_dat.out.dat ++assert_dat_waveform F5 opus_dat.out.dat 16000 64 8 1 1775 ++ ++ ++ ++ ++"$BIN" -i "$DATA/test_file_mono.raw" -o raw_dat.out.dat --input-format raw --raw-samplerate 16000 --raw-channels 1 --raw-format s16le -z 64 -b 8 >out 2>err; ec=$? ++assert_common_run F6 "$ec" out err raw_dat.out.dat ++assert_dat_waveform F6 raw_dat.out.dat 16000 64 8 1 1774 ++ ++ ++ ++ ++"$BIN" -i "$DATA/test_file_stereo.wav" -o split_dat.out.dat -z 64 -b 8 --split-channels >out 2>err; ec=$? ++assert_common_run F7 "$ec" out err split_dat.out.dat ++assert_dat_waveform F7 split_dat.out.dat 16000 64 8 2 1774 ++assert_outputs_differ F7 split_dat.out.dat wav_dat.out.dat ++ ++ ++ ++ ++"$BIN" -i "$DATA/test_file_stereo.wav" -o auto_json.out.json -z 64 -b 8 --amplitude-scale auto >out 2>err; ec=$? ++assert_common_run F8 "$ec" out err auto_json.out.json ++assert_json_waveform F8 auto_json.out.json 16000 64 8 1 1774 120 ++assert_outputs_differ F8 auto_json.out.json mp3_json.out.json ++ ++ ++ ++ ++"$BIN" -i "$TMP/no_such.wav" -o missing.out.dat -z 64 -b 8 >out 2>err; ec=$? ++[ "$ec" -ne 0 ] || fail "F9 exit $ec; want non-zero" ++[ ! -s out ] || fail "F9 stdout should be empty" ++ ++[ -s err ] || fail "F9 stderr should describe the failure" ++[ ! -e missing.out.dat ] || fail "F9 should not create output file" ++ ++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-000535/tests/test.sh b/tasks/format-code-task-000535/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d4d80bb634b14076ae561be99f395189577b7ac6 --- /dev/null +++ b/tasks/format-code-task-000535/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-000535/tests/test_command.sh b/tasks/format-code-task-000535/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000535/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-000556/environment/Dockerfile b/tasks/format-code-task-000556/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..08b1500045a5b8ba19c04ea6925bd2c4bba22455 --- /dev/null +++ b/tasks/format-code-task-000556/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:640c5397bdd25befddd9b94b410c0133d930f42281b38896bd522d2a28aca76b diff --git a/tasks/format-code-task-000556/environment/setup/files/blocklist b/tasks/format-code-task-000556/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000556/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-000556/environment/setup/setup.sh b/tasks/format-code-task-000556/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000556/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-000556/tests/test.patch b/tasks/format-code-task-000556/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..0e6171bc350c6d36df8fa4c1596a7b873bcdec10 --- /dev/null +++ b/tasks/format-code-task-000556/tests/test.patch @@ -0,0 +1,248 @@ +diff --git a/usercase-test-coderl/wacbeacon_test.go b/usercase-test-coderl/wacbeacon_test.go +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/wacbeacon_test.go +@@ -0,0 +1,215 @@ ++package usercase_test_coderl ++ ++import ( ++ "encoding/hex" ++ "os" ++ "reflect" ++ "runtime" ++ "testing" ++ ++ waclib "github.com/BertoldVdb/WACResearch/waclib" ++) ++ ++ ++ ++ ++ ++ ++func mustHex(t *testing.T, raw string) []byte { ++ t.Helper() ++ data, err := hex.DecodeString(raw) ++ if err != nil { ++ t.Fatalf("test fixture hex must decode: %v", err) ++ } ++ return data ++} ++ ++func assertHex(t *testing.T, got []byte, want string) { ++ t.Helper() ++ if hex.EncodeToString(got) != want { ++ t.Fatalf("hex output = %s, want %s", hex.EncodeToString(got), want) ++ } ++} ++ ++func assertBeaconFields(t *testing.T, got waclib.WACBeacon, mac [6]byte, flags []byte, name string, supplier string, typ string) { ++ t.Helper() ++ if got.MACAddress != mac { ++ t.Fatalf("MACAddress = %x, want %x", got.MACAddress, mac) ++ } ++ if !reflect.DeepEqual(got.Flags, flags) { ++ t.Fatalf("Flags = %x, want %x", got.Flags, flags) ++ } ++ if got.Name != name { ++ t.Fatalf("Name = %q, want %q", got.Name, name) ++ } ++ if got.Supplier != supplier { ++ t.Fatalf("Supplier = %q, want %q", got.Supplier, supplier) ++ } ++ if got.Type != typ { ++ t.Fatalf("Type = %q, want %q", got.Type, typ) ++ } ++} ++ ++func assertErrorMessage(t *testing.T, err error, message string) { ++ t.Helper() ++ if err == nil { ++ t.Fatalf("error = , want message %q", message) ++ } ++ ++ if err.Error() != message { ++ t.Fatalf("error message = %q, want %q", err.Error(), message) ++ } ++} ++ ++func openFDCount(t *testing.T) int { ++ t.Helper() ++ entries, err := os.ReadDir("/proc/self/fd") ++ if err != nil { ++ t.Fatalf("reading /proc/self/fd failed: %v", err) ++ } ++ return len(entries) ++} ++ ++func TestMarshalFullBeaconRepeatedlyStableAndDoesNotMutate(t *testing.T) { ++ ++ ++ ++ ++ beacon := waclib.WACBeacon{ ++ MACAddress: [6]byte{0x00, 0x11, 0x22, 0x33, 0x44, 0x55}, ++ Flags: []byte{0x70, 0x03}, ++ Name: "Name", ++ Supplier: "waclib", ++ Type: "Type", ++ } ++ ++ assertBeaconFields(t, beacon, [6]byte{0x00, 0x11, 0x22, 0x33, 0x44, 0x55}, []byte{0x70, 0x03}, "Name", "waclib", "Type") ++ assertHex(t, beacon.Marshal(), "dd2400a0400007060011223344550002700301044e616d6502067761636c6962030454797065") ++ assertBeaconFields(t, beacon, [6]byte{0x00, 0x11, 0x22, 0x33, 0x44, 0x55}, []byte{0x70, 0x03}, "Name", "waclib", "Type") ++ assertHex(t, beacon.Marshal(), "dd2400a0400007060011223344550002700301044e616d6502067761636c6962030454797065") ++ assertBeaconFields(t, beacon, [6]byte{0x00, 0x11, 0x22, 0x33, 0x44, 0x55}, []byte{0x70, 0x03}, "Name", "waclib", "Type") ++} ++ ++func TestMarshalMinimalBeaconOmitsEmptyTextFields(t *testing.T) { ++ ++ ++ ++ ++ beacon := waclib.WACBeacon{ ++ MACAddress: [6]byte{0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff}, ++ Flags: []byte{0xf0, 0x03}, ++ } ++ ++ assertBeaconFields(t, beacon, [6]byte{0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff}, []byte{0xf0, 0x03}, "", "", "") ++ assertHex(t, beacon.Marshal(), "dd1000a040000706aabbccddeeff0002f003") ++ assertBeaconFields(t, beacon, [6]byte{0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff}, []byte{0xf0, 0x03}, "", "", "") ++} ++ ++func TestUnmarshalFullBeaconSetsAllFields(t *testing.T) { ++ ++ ++ ++ ++ var beacon waclib.WACBeacon ++ ++ err := beacon.Unmarshal(mustHex(t, "dd2400a0400007060011223344550002700301044e616d6502067761636c6962030454797065")) ++ if err != nil { ++ t.Fatalf("Unmarshal error = %v, want ", err) ++ } ++ assertBeaconFields(t, beacon, [6]byte{0x00, 0x11, 0x22, 0x33, 0x44, 0x55}, []byte{0x70, 0x03}, "Name", "waclib", "Type") ++} ++ ++func TestUnmarshalMinimalBeaconLeavesTextFieldsEmpty(t *testing.T) { ++ ++ ++ ++ ++ var beacon waclib.WACBeacon ++ ++ err := beacon.Unmarshal(mustHex(t, "dd1000a040000706aabbccddeeff0002f003")) ++ if err != nil { ++ t.Fatalf("Unmarshal error = %v, want ", err) ++ } ++ assertBeaconFields(t, beacon, [6]byte{0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff}, []byte{0xf0, 0x03}, "", "", "") ++} ++ ++func TestUnmarshalMissingAppleWACRecordReturnsSpecificError(t *testing.T) { ++ ++ ++ ++ ++ var beacon waclib.WACBeacon ++ ++ err := beacon.Unmarshal([]byte{0x01, 0x02, 0xab, 0xcd}) ++ assertErrorMessage(t, err, "record not found") ++ ++} ++ ++func TestUnmarshalWrongMACLengthReturnsSpecificError(t *testing.T) { ++ ++ ++ ++ ++ var beacon waclib.WACBeacon ++ ++ err := beacon.Unmarshal(mustHex(t, "dd0b00a04000070500112233440002f003")) ++ assertErrorMessage(t, err, "MAC address has wrong length") ++ ++} ++ ++func TestTwoBeaconInstancesKeepIndependentReceiverState(t *testing.T) { ++ ++ ++ ++ ++ var a waclib.WACBeacon ++ var b waclib.WACBeacon ++ ++ err := a.Unmarshal(mustHex(t, "dd2400a0400007060011223344550002700301044e616d6502067761636c6962030454797065")) ++ if err != nil { ++ t.Fatalf("Unmarshal error = %v, want ", err) ++ } ++ assertBeaconFields(t, a, [6]byte{0x00, 0x11, 0x22, 0x33, 0x44, 0x55}, []byte{0x70, 0x03}, "Name", "waclib", "Type") ++ assertBeaconFields(t, b, [6]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, nil, "", "", "") ++ ++ err = b.Unmarshal(mustHex(t, "dd1000a040000706aabbccddeeff0002f003")) ++ if err != nil { ++ t.Fatalf("Unmarshal error = %v, want ", err) ++ } ++ assertBeaconFields(t, a, [6]byte{0x00, 0x11, 0x22, 0x33, 0x44, 0x55}, []byte{0x70, 0x03}, "Name", "waclib", "Type") ++ assertBeaconFields(t, b, [6]byte{0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff}, []byte{0xf0, 0x03}, "", "", "") ++} ++ ++func TestRepeatedMarshalUnmarshalCyclesDoNotCreateResourceSideEffects(t *testing.T) { ++ ++ ++ ++ ++ runtime.GC() ++ startFDs := openFDCount(t) ++ ++ for i := 0; i < 100; i++ { ++ beacon := waclib.WACBeacon{ ++ MACAddress: [6]byte{0x00, 0x11, 0x22, 0x33, 0x44, 0x55}, ++ Flags: []byte{0x70, 0x03}, ++ Name: "Name", ++ Supplier: "waclib", ++ Type: "Type", ++ } ++ assertHex(t, beacon.Marshal(), "dd2400a0400007060011223344550002700301044e616d6502067761636c6962030454797065") ++ ++ var parsed waclib.WACBeacon ++ err := parsed.Unmarshal(mustHex(t, "dd1000a040000706aabbccddeeff0002f003")) ++ if err != nil { ++ t.Fatalf("cycle %d Unmarshal error = %v, want ", i, err) ++ } ++ assertBeaconFields(t, parsed, [6]byte{0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff}, []byte{0xf0, 0x03}, "", "", "") ++ } ++ ++ runtime.GC() ++ endFDs := openFDCount(t) ++ if endFDs > startFDs+2 { ++ t.Fatalf("open fd count = %d after cycles, want at most %d", endFDs, startFDs+2) ++ } ++ ++} +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 ++ ++ ++ ++ ++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 GOPATH=/go ++export GOMODCACHE=/go/pkg/mod ++export GOCACHE=/opt/stage4a-go-build-cache ++export GOFLAGS="${GOFLAGS:-} -mod=readonly" ++export CGO_ENABLED=0 ++mkdir -p "$GOCACHE" ++exec go test -v -count=1 ./usercase-test-coderl/... diff --git a/tasks/format-code-task-000556/tests/test.sh b/tasks/format-code-task-000556/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..38473a23d2874ac3f393969c664f77010c97405a --- /dev/null +++ b/tasks/format-code-task-000556/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/wacbeacon_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-000556/tests/test_command.sh b/tasks/format-code-task-000556/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000556/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-000558/environment/Dockerfile b/tasks/format-code-task-000558/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f0f3bc6211771ae8f1f83fa6cff0bfb3f80230af --- /dev/null +++ b/tasks/format-code-task-000558/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:2ac45dd57bd79029cbb06471b4fcecaddaee3fceb0d81a22d47b8fb18890cb71 diff --git a/tasks/format-code-task-000558/environment/setup/files/blocklist b/tasks/format-code-task-000558/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000558/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-000558/environment/setup/setup.sh b/tasks/format-code-task-000558/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000558/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-000558/tests/test.patch b/tasks/format-code-task-000558/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..9daaaeb55337abf312bc821c5dfcd1c37a824f7e --- /dev/null +++ b/tasks/format-code-task-000558/tests/test.patch @@ -0,0 +1,69 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..c3262d2 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest tests/adapters/api/gsheets/fields_test.py::test_GSheetsString tests/adapters/api/gsheets/fields_test.py::test_GSheetsString_quote_empty_string_not_null tests/adapters/api/gsheets/fields_test.py::test_GSheetsString_build_sql_not_equal_empty_string --no-cov"] ++} +diff --git a/tests/adapters/api/gsheets/fields_test.py b/tests/adapters/api/gsheets/fields_test.py +index d6a041f..87c0604 100644 +--- a/tests/adapters/api/gsheets/fields_test.py ++++ b/tests/adapters/api/gsheets/fields_test.py +@@ -217,5 +217,41 @@ def test_GSheetsString() -> None: + assert GSheetsString().format("test") == "test" + + assert GSheetsString().quote(None) == "null" +- assert GSheetsString().quote("") == "null" ++ assert GSheetsString().quote("") == "''" + assert GSheetsString().quote("test") == "'test'" ++ ++ ++def test_GSheetsString_quote_empty_string_not_null() -> None: ++ """ ++ Empty strings must be quoted as ``''`` (the empty SQL literal), NOT as ++ ``null``. Previously, quoting ``""`` returned ``"null"`` which produced ++ invalid GSheets queries like ``WHERE country != null`` and triggered ++ ``Invalid query: NO_COLUMN: null``. ++ """ ++ assert GSheetsString().quote("") == "''" ++ ++ assert GSheetsString().quote(None) == "null" ++ ++ assert GSheetsString().quote("hello") == "'hello'" ++ ++ ++def test_GSheetsString_build_sql_not_equal_empty_string() -> None: ++ """ ++ ``WHERE country != ''`` must produce a SQL fragment that compares ++ against the empty string literal, not against ``null`` and not using ++ ``IS NOT NULL`` (which has different semantics). ++ """ ++ from shillelagh.filters import Equal, NotEqual ++ from shillelagh.lib import build_sql ++ ++ columns = {"country": GSheetsString()} ++ ++ sql = build_sql(columns, {"country": NotEqual("")}, []) ++ assert sql == "SELECT * WHERE country != ''" ++ ++ sql = build_sql(columns, {"country": Equal("")}, []) ++ assert sql == "SELECT * WHERE country = ''" ++ ++ ++ sql = build_sql(columns, {"country": NotEqual("BR")}, []) ++ assert sql == "SELECT * WHERE country != 'BR'" +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 --no-cov -rA tests/adapters/api/gsheets/fields_test.py::test_GSheetsString_quote_empty_string_not_null tests/adapters/api/gsheets/fields_test.py::test_GSheetsString_build_sql_not_equal_empty_string tests/adapters/api/gsheets/fields_test.py::test_GSheetsString ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000558/tests/test.sh b/tasks/format-code-task-000558/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..dbbf4941c62eaa8784aed13b6b321990ccdf56b2 --- /dev/null +++ b/tasks/format-code-task-000558/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/adapters/api/gsheets/fields_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-000558/tests/test_command.sh b/tasks/format-code-task-000558/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000558/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-000559/environment/Dockerfile b/tasks/format-code-task-000559/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a42737823035864c1c1088a1f39b4a453b9bc77d --- /dev/null +++ b/tasks/format-code-task-000559/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:0015ca9c9da53a8c09981d2b006d2dbf25292be02169b8514e7fbd20c8c4179a diff --git a/tasks/format-code-task-000559/environment/setup/files/blocklist b/tasks/format-code-task-000559/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000559/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-000559/environment/setup/setup.sh b/tasks/format-code-task-000559/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000559/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-000559/tests/test.patch b/tasks/format-code-task-000559/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..fb6bc8cdce6c85af3673a6060f180d984e9d56f4 --- /dev/null +++ b/tasks/format-code-task-000559/tests/test.patch @@ -0,0 +1,146 @@ +diff --git a/packages/cli/test/generate.test.ts b/packages/cli/test/generate.test.ts +index edeba4de0..8dc0c82b0 100644 +--- a/packages/cli/test/generate.test.ts ++++ b/packages/cli/test/generate.test.ts +@@ -173,4 +173,119 @@ describe("generate", async () => { + }); + expect(schema.code).toMatchFileSnapshot("./__snapshots__/migrations.sql"); + }); ++ ++ it("drizzle pg with useNumberId should not mark FK userId as primary key", async () => { ++ const schema = await generateDrizzleSchema({ ++ file: "test.drizzle", ++ adapter: drizzleAdapter( ++ {}, ++ { provider: "pg", schema: {} }, ++ )({} as BetterAuthOptions), ++ options: { ++ database: drizzleAdapter({}, { provider: "pg", schema: {} }), ++ plugins: [twoFactor(), username()], ++ advanced: { database: { useNumberId: true } }, ++ }, ++ }); ++ const code = schema.code; ++ ++ ++ ++ expect(code).toContain('integer("user_id")'); ++ expect(code).not.toMatch(/serial\(["']user_id["']\)/); ++ expect(code).not.toMatch(/userId:\s*serial/); ++ ++ const userIdBlocks = code.match(/userId:[\s\S]*?(?=,\s*\w+:|\n\s*\}\)|$)/g) || []; ++ expect(userIdBlocks.length).toBeGreaterThan(0); ++ for (const block of userIdBlocks) { ++ expect(block).not.toContain(".primaryKey()"); ++ expect(block).not.toContain(".autoIncrement()"); ++ } ++ ++ ++ const tableBlocks = code.match(/pgTable\([\s\S]*?\}\);/g) || []; ++ expect(tableBlocks.length).toBeGreaterThan(0); ++ for (const block of tableBlocks) { ++ const pkMatches = block.match(/\.primaryKey\(/g) || []; ++ expect(pkMatches.length).toBe(1); ++ } ++ }); ++ ++ it("drizzle mysql with useNumberId should not mark FK userId as primary key", async () => { ++ const schema = await generateDrizzleSchema({ ++ file: "test.drizzle", ++ adapter: drizzleAdapter( ++ {}, ++ { provider: "mysql", schema: {} }, ++ )({} as BetterAuthOptions), ++ options: { ++ database: drizzleAdapter({}, { provider: "mysql", schema: {} }), ++ plugins: [twoFactor(), username()], ++ advanced: { database: { useNumberId: true } }, ++ }, ++ }); ++ const code = schema.code; ++ ++ ++ ++ expect(code).toContain('int("user_id")'); ++ const userIdBlocks = code.match(/userId:[\s\S]*?(?=,\s*\w+:|\n\s*\}\)|$)/g) || []; ++ expect(userIdBlocks.length).toBeGreaterThan(0); ++ for (const block of userIdBlocks) { ++ expect(block).not.toContain(".primaryKey()"); ++ expect(block).not.toContain(".autoIncrement()"); ++ } ++ }); ++ ++ it("drizzle sqlite with useNumberId should emit named integer for FK userId without primary key", async () => { ++ const schema = await generateDrizzleSchema({ ++ file: "test.drizzle", ++ adapter: drizzleAdapter( ++ {}, ++ { provider: "sqlite", schema: {} }, ++ )({} as BetterAuthOptions), ++ options: { ++ database: drizzleAdapter({}, { provider: "sqlite", schema: {} }), ++ plugins: [twoFactor(), username()], ++ advanced: { database: { useNumberId: true } }, ++ }, ++ }); ++ const code = schema.code; ++ ++ ++ ++ expect(code).toContain('integer("user_id")'); ++ const userIdBlocks = code.match(/userId:[\s\S]*?(?=,\s*\w+:|\n\s*\}\)|$)/g) || []; ++ expect(userIdBlocks.length).toBeGreaterThan(0); ++ for (const block of userIdBlocks) { ++ expect(block).not.toContain(".primaryKey("); ++ expect(block).not.toContain("autoIncrement"); ++ expect(block).not.toContain("mode: 'number'"); ++ expect(block).not.toContain('mode: "number"'); ++ } ++ }); ++ ++ it("drizzle pg without useNumberId should still use text for FK userId", async () => { ++ const schema = await generateDrizzleSchema({ ++ file: "test.drizzle", ++ adapter: drizzleAdapter( ++ {}, ++ { provider: "pg", schema: {} }, ++ )({} as BetterAuthOptions), ++ options: { ++ database: drizzleAdapter({}, { provider: "pg", schema: {} }), ++ plugins: [twoFactor(), username()], ++ }, ++ }); ++ const code = schema.code; ++ ++ ++ ++ expect(code).toContain('text("user_id")'); ++ const userIdBlocks = code.match(/userId:[\s\S]*?(?=,\s*\w+:|\n\s*\}\)|$)/g) || []; ++ expect(userIdBlocks.length).toBeGreaterThan(0); ++ for (const block of userIdBlocks) { ++ expect(block).not.toContain(".primaryKey()"); ++ } ++ }); + }); +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..bc83b52f1 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["cd packages/cli && npx vitest run test/generate.test.ts -t 'FK userId'"] ++} +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 packages/cli && npx vitest run test/generate.test.ts -t 'FK userId' ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000559/tests/test.sh b/tasks/format-code-task-000559/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..354fd9e9650bc601c63a743455cf068f0b76c0cd --- /dev/null +++ b/tasks/format-code-task-000559/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/cli/test/generate.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-000559/tests/test_command.sh b/tasks/format-code-task-000559/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000559/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-000560/environment/Dockerfile b/tasks/format-code-task-000560/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..62c295fd3c21818ec388a2bfa68e4ba19c0881b0 --- /dev/null +++ b/tasks/format-code-task-000560/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:a6a0a56c7b75541c9587d7ae84e5cea9885904ea80e617b9703e1131384892e7 diff --git a/tasks/format-code-task-000560/environment/setup/files/blocklist b/tasks/format-code-task-000560/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000560/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-000560/environment/setup/setup.sh b/tasks/format-code-task-000560/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000560/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-000560/tests/test.patch b/tasks/format-code-task-000560/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..51ef886741d125b3050bb12859eac29ff68f1367 --- /dev/null +++ b/tasks/format-code-task-000560/tests/test.patch @@ -0,0 +1,53 @@ +diff --git a/bimmer_connected/tests/test_vehicle_status.py b/bimmer_connected/tests/test_vehicle_status.py +index 927efc16..d600e5f3 100644 +--- a/bimmer_connected/tests/test_vehicle_status.py ++++ b/bimmer_connected/tests/test_vehicle_status.py +@@ -1,6 +1,8 @@ + """Test for VehicleState.""" + + import datetime ++import os ++import time + + import pytest + import respx +@@ -180,13 +182,18 @@ async def test_charging_end_time(caplog, bmw_fixture: respx.Router): + @pytest.mark.asyncio + async def test_plugged_in_waiting_for_charge_window(caplog, bmw_fixture: respx.Router): + """I01_REX is plugged in but not charging, as its waiting for charging window.""" ++ ++ ++ os.environ["TZ"] = "Europe/Berlin" ++ time.tzset() ++ + account = await prepare_account_with_vehicles() + vehicle = account.get_vehicle(VIN_I01_REX) + + assert vehicle.fuel_and_battery.charging_end_time is None + assert vehicle.fuel_and_battery.charging_status == ChargingState.WAITING_FOR_CHARGING + assert vehicle.fuel_and_battery.is_charger_connected is True +- assert vehicle.fuel_and_battery.charging_start_time == datetime.datetime(2021, 11, 28, 18, 1, tzinfo=UTC) ++ assert vehicle.fuel_and_battery.charging_start_time == datetime.datetime(2021, 11, 29, 18, 1) + assert vehicle.fuel_and_battery.charging_target == 100 + + assert len(get_deprecation_warning_count(caplog)) == 0 +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+3SXYqDMBSGYa+7imyg0UjV5UjVgEITi4mCu++pwzBDYaY3LcO073OTQxLIz3d0 ++Mw+nrrZ+SZNnyURVFNsobsetNkVu8kNpyipPMmPKrEpU8bQbfTOHeJyUSqZxjL/tu7f+T+mv/KMN ++sW5H546+06F/3Bn38jcHc5O/FJJ/9rgr/OzN8287tQXf2G73WaR6ufZDM/j0vMZ+9GrvlFSyqprB ++OTtJm3hv2yh7r7Pho3cW2w/tydbyo3EO+ryq/bL76wcCAAAAAAAAAAAAAAAAL+wCHnq16AAoAAA= +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-000560/tests/test.sh b/tasks/format-code-task-000560/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..e6bf007ffd706ef267338b96238cf2dc33933e53 --- /dev/null +++ b/tasks/format-code-task-000560/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' +bimmer_connected/tests/test_vehicle_status.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-000560/tests/test_command.sh b/tasks/format-code-task-000560/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000560/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-000561/environment/Dockerfile b/tasks/format-code-task-000561/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6bcf136d978fcfa4a5ddc0c117e18896938c0a58 --- /dev/null +++ b/tasks/format-code-task-000561/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:8108a4b711bb2337134e3be02fc089039b6993de3d70148cbbba932ce455fb2e diff --git a/tasks/format-code-task-000561/environment/setup/files/blocklist b/tasks/format-code-task-000561/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000561/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-000561/environment/setup/setup.sh b/tasks/format-code-task-000561/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000561/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-000561/tests/test.patch b/tasks/format-code-task-000561/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..877f3e946fc856447e918deff5d6dbcae122a01d --- /dev/null +++ b/tasks/format-code-task-000561/tests/test.patch @@ -0,0 +1,134 @@ +diff --git a/tests/sequence/test_fasta.py b/tests/sequence/test_fasta.py +index 3f2802413..1b7103e30 100644 +--- a/tests/sequence/test_fasta.py ++++ b/tests/sequence/test_fasta.py +@@ -39,10 +39,11 @@ def test_access_low_level(): + } + + +-def test_access_high_level(): ++@pytest.mark.parametrize("seq_type", (None, seq.NucleotideSequence)) ++def test_access_high_level(seq_type): + path = os.path.join(data_dir("sequence"), "nuc.fasta") + file = fasta.FastaFile.read(path) +- sequences = fasta.get_sequences(file) ++ sequences = fasta.get_sequences(file, seq_type=seq_type) + assert sequences == { + "dna sequence" : seq.NucleotideSequence("ACGCTACGT", False), + "another dna sequence" : seq.NucleotideSequence("A", False), +@@ -52,34 +53,72 @@ def test_access_high_level(): + } + + +-def test_sequence_conversion(): ++@pytest.mark.parametrize( ++ "seq_type", (None, seq.NucleotideSequence, seq.ProteinSequence) ++) ++def test_sequence_conversion_ambiguous(seq_type): + path = os.path.join(data_dir("sequence"), "nuc.fasta") + file = fasta.FastaFile.read(path) +- assert seq.NucleotideSequence("ACGCTACGT") == fasta.get_sequence(file) ++ sequence = "ACGCTACGT" ++ ++ if seq_type is None: ++ ++ assert seq.NucleotideSequence(sequence) == fasta.get_sequence( ++ file, seq_type=None ++ ) ++ else: ++ assert seq_type(sequence) == fasta.get_sequence( ++ file, seq_type=seq_type ++ ) + + seq_dict = fasta.get_sequences(file) + file2 = fasta.FastaFile() + fasta.set_sequences(file2, seq_dict) +- seq_dict2 = fasta.get_sequences(file2) +- # Cannot compare dicts directly, since the original RNA sequence is +- # now guessed as protein sequence +- for seq1, seq2 in zip(seq_dict.values(), seq_dict2.values()): +- assert str(seq1) == str(seq2) +- +- file3 = fasta.FastaFile() +- fasta.set_sequence(file3, seq.NucleotideSequence("AACCTTGG")) +- assert file3["sequence"] == "AACCTTGG" ++ seq_dict2 = fasta.get_sequences(file2, seq_type=seq_type) ++ ++ if seq_type == seq.ProteinSequence: ++ ++ ++ assert seq_dict != seq_dict2 ++ for seq1, seq2 in zip(seq_dict.values(), seq_dict2.values()): ++ assert str(seq1) == str(seq2) ++ else: ++ assert seq_dict == seq_dict2 + ++ if seq_type is not None: ++ sequence = "AACCTTGG" ++ file3 = fasta.FastaFile() ++ fasta.set_sequence(file3, seq_type(sequence)) ++ assert file3["sequence"] == sequence ++ ++ ++@pytest.mark.parametrize( ++ "seq_type", (None, seq.NucleotideSequence, seq.ProteinSequence) ++) ++def test_sequence_conversion_protein(seq_type): + path = os.path.join(data_dir("sequence"), "prot.fasta") + file4 = fasta.FastaFile.read(path) +- # Expect a warning for selenocysteine conversion +- with pytest.warns(UserWarning): +- assert seq.ProteinSequence("YAHCGFRTGS") == fasta.get_sequence(file4) +- ++ ++ if seq_type != seq.NucleotideSequence: ++ ++ with pytest.warns(UserWarning): ++ assert seq.ProteinSequence("YAHCGFRTGS") == fasta.get_sequence( ++ file4, seq_type=seq_type ++ ) ++ else: ++ ++ with pytest.raises(seq.AlphabetError): ++ fasta.get_sequence(file4, seq_type=seq_type) ++ ++ ++@pytest.mark.parametrize( ++ "seq_type", (None, seq.NucleotideSequence, seq.ProteinSequence) ++) ++def test_sequence_conversion_invalid(seq_type): + path = os.path.join(data_dir("sequence"), "invalid.fasta") +- file5 = fasta.FastaFile.read(path) ++ file = fasta.FastaFile.read(path) + with pytest.raises(ValueError): +- seq.NucleotideSequence(fasta.get_sequence(file5)) ++ seq.NucleotideSequence(fasta.get_sequence(file), seq_type=seq_type) + + + def test_rna_conversion(): +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+2UwXLTMBCGc/ZT7IQLHGzHDnaHQw7QS7lABnrh1HHkJdbUloS0dpK3R5aTNoWB ++XtoBhv0OceJd7f6rX0qy6WVb36Aa0tlzsfBcFEV4en58hu9ZkWd5Xl5khX+fZeUin0HxbIrO6B1V ++FmBmtabf5T0W/0dJ7v0ndHQjdNdVqk5c83Q9HvE/y4v85H9ZLpbe/9dlvpjB4ukk/Jr/3H9RQzB+ ++g3UUvYDPO0miAdKwPlCjFSyTLIOX/lSYiuSmRfAJDVxOwUWSv0n24M8LUCMdCF3jpnL4KqpxiN1U ++y4TcZag0tri0WBHC4I8c6J6crPFOAjgNksD1dpADOqjAotH+wyFFp0JxNy1OtaF0IzVJwnh8Eznd ++W4E/B/wPlVaC5OA7jxreK+9620I4/FCjQVWjEtK3NFIpL8TvwNnQA1ontXKRkQbkcfFcBEGrVdiG ++ZTmHuW5rP0jsemO0Jaxj1XfmMAcvvzekdetg1yC2o4Z3ofdxJ3FPqEILXz42bSXwbt6wODEHOF7V ++PUEcSzUlnQ1je0Wyw4fjBG+8pjGq0D4YwOK33occdG5rKnELCmmn7e1+9MwHxuKfegX+gmyRQhk3 +++b/+cn318cP67fUVGC19W7Udd4waHOWTRYTJi+g+c3UyOXVWwJmZU7OpfOpGTUrg9G/0tfJKx9Hj ++IfrTN4VhGIZhGIZhGIZhGIZhGIZhGIZhGIZhGObv5DueLJ1jACgAAA== +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-000561/tests/test.sh b/tasks/format-code-task-000561/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..ee9586194c59c2d08eb8ef2795c5ea436be514be --- /dev/null +++ b/tasks/format-code-task-000561/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/sequence/test_fasta.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-000561/tests/test_command.sh b/tasks/format-code-task-000561/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000561/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-000567/environment/Dockerfile b/tasks/format-code-task-000567/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..592c1d557355d99f1393abe760abdba49eb28b0e --- /dev/null +++ b/tasks/format-code-task-000567/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:4ea076c193808753bd4aad9d650af062a0ece7be05e60cc6742fd81292900670 diff --git a/tasks/format-code-task-000567/environment/setup/files/blocklist b/tasks/format-code-task-000567/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000567/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-000567/environment/setup/setup.sh b/tasks/format-code-task-000567/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000567/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-000567/tests/test.patch b/tasks/format-code-task-000567/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..943ad91d063be0a0163895b7e0737673bcb22687 --- /dev/null +++ b/tasks/format-code-task-000567/tests/test.patch @@ -0,0 +1,61 @@ +diff --git a/bin-templater/tests/1/templates/etc/test.tmpl b/bin-templater/tests/1/templates/etc/test.tmpl +index c691193b..0ac02063 100644 +--- a/bin-templater/tests/1/templates/etc/test.tmpl ++++ b/bin-templater/tests/1/templates/etc/test.tmpl +@@ -1 +1,10 @@ +-{{template "config" .}} ++{{$data := .}} ++{{range $a,$b := $data -}} ++{{/*$indent := (HowDeep $data . )*/}} ++{{$indent := 0}} ++{{template "indent" $indent }}{{ $a }}: ++{{range $c,$d := $b -}} ++{{template "indent" (HowDeep $data $b )}}{{$c}}: {{template "config" $d}}{{/*(HowDeep $data . )*/}} ++{{end}} ++{{end}} ++{{/*template "config" .*/}} +diff --git a/bin-templater/tests/1/templates/test.partial b/bin-templater/tests/1/templates/test.partial +index 9338c505..adc9e78c 100644 +--- a/bin-templater/tests/1/templates/test.partial ++++ b/bin-templater/tests/1/templates/test.partial +@@ -12,10 +12,12 @@ + + + {{define "mapType"}} ++{{$deep := .}} + {{range $a,$b := . -}} +-{{template "indent" 2}}{{$a}}: {{template "config" $b}} +-{{end -}} +-{{end}} ++{{- if (IsMapFirst $deep $a )}} # First{{end}} ++{{$a}}: {{template "config" $b}} ++{{- end -}} ++{{- end -}} + + {{define "arrayType" -}} + [{{ range . }}{{ template "config" . }},{{ 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,9 @@ ++H4sIAAAAAAAAA+3TT2vbMBQA8Jz1Kd7oZTvYipY4gUEOGwvZYaWj685Btl4cEVsyktym336y2/wr ++dO2gpYy9Hwbbsqz3pCeleasrtURzzQevZRhNs6y/Rw/v/bPIPgqRTSdTEfsJMRGjAWSvltGR1gfp ++AAbO2vCnfk99/0elh/oH9GFZ2LqWRqV+/XIxnqi/GInxvv6TcVf/8WQ0HMDw5VJ43H9e/7N3PNeG ++59KvmccACTJWKOg3Q46KsTP4GZvbBhYXPz5ffYMbHdZwjUZZhwoUNvERTaHRM9w21oX7jrPdEHxh ++Yy/PlzfWbXwjC/zEQ93w0jYyrA8/CSHOL77++j6f2dWqizs3vnW4i+tv60qbDeBW++BZvVHaQdLA ++0Vjcu4KXMb82T+M+5nkl41VIxyoDiV/tZ/Wsn7gqXZfGl+6AQFgjBKybSgZ0EJdMutvjJO7nqmJy ++rLTQnypI7OkXfhjhsYhdNZJ9ty7+ZWv66LkMHrQJWDoZtI2NcWR4j1t0hfbo+/c0TqyCeIDv3hrp ++gpbVh+OSnkboWz27ml+ez1Rb53dh4pT2PdKuZZfIwkJrdOhH97Cy7mRhIFZ3I0tkf7UFHtYe4vr1 ++c3veGu0Xlb31WSKEEEIIIYQQQgghhBBCCCGEEEIIeQu/Af8E/AAAKAAA +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-000567/tests/test.sh b/tasks/format-code-task-000567/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..56c53fbf128ba0c28feb0d4ccafce618bd668ea0 --- /dev/null +++ b/tasks/format-code-task-000567/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' +bin-templater/tests/1/templates/etc/test.tmpl +bin-templater/tests/1/templates/test.partial +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-000567/tests/test_command.sh b/tasks/format-code-task-000567/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000567/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-000569/environment/Dockerfile b/tasks/format-code-task-000569/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..14906428222d2c097598a0b405ff04583bcd78c6 --- /dev/null +++ b/tasks/format-code-task-000569/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:3e85fe8494a23c7bcb5bc5d11b9a76c23d5c4346229cab1bc62fde4a4ab4c955 diff --git a/tasks/format-code-task-000569/environment/setup/files/blocklist b/tasks/format-code-task-000569/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000569/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-000569/environment/setup/setup.sh b/tasks/format-code-task-000569/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000569/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-000569/tests/test.patch b/tasks/format-code-task-000569/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..8720496e653da85970596e9381e8feca46592e72 --- /dev/null +++ b/tasks/format-code-task-000569/tests/test.patch @@ -0,0 +1,82 @@ +diff --git a/analysis/token/reverse/reverse_test.go b/analysis/token/reverse/reverse_test.go +index 6437ecdd3..8e84ab983 100644 +--- a/analysis/token/reverse/reverse_test.go ++++ b/analysis/token/reverse/reverse_test.go +@@ -23,6 +23,7 @@ import ( + + func TestReverseFilter(t *testing.T) { + inputTokenStream := analysis.TokenStream{ ++ &analysis.Token{}, + &analysis.Token{ + Term: []byte("one"), + }, +@@ -47,10 +48,19 @@ func TestReverseFilter(t *testing.T) { + &analysis.Token{ + Term: []byte("!@#$%^&*()"), + }, +- &analysis.Token{}, ++ &analysis.Token{ ++ Term: []byte("cafés"), ++ }, ++ &analysis.Token{ ++ Term: []byte("¿Dónde estás?"), ++ }, ++ &analysis.Token{ ++ Term: []byte("Me gustaría una cerveza."), ++ }, + } + + expectedTokenStream := analysis.TokenStream{ ++ &analysis.Token{}, + &analysis.Token{ + Term: []byte("eno"), + }, +@@ -75,7 +85,15 @@ func TestReverseFilter(t *testing.T) { + &analysis.Token{ + Term: []byte(")(*&^%$#@!"), + }, +- &analysis.Token{}, ++ &analysis.Token{ ++ Term: []byte("séfac"), ++ }, ++ &analysis.Token{ ++ Term: []byte("?sátse ednóD¿"), ++ }, ++ &analysis.Token{ ++ Term: []byte(".azevrec anu aíratsug eM"), ++ }, + } + + filter := NewReverseFilter() +@@ -153,6 +171,9 @@ func BenchmarkReverseFilter(b *testing.B) { + &analysis.Token{ + Term: []byte("İȺȾCAT"), + }, ++ &analysis.Token{ ++ Term: []byte("Me gustaría una cerveza."), ++ }, + } + filter := NewReverseFilter() + +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+3Sy0rEMBQG4K77FIfitk1jpzOrLgRlXCh1oeuhl/TCtE1J0qJvb+2AI4KO4gwi ++/t8mB3JyIX+8dKibfCO6kVmn4k9WYTiPk/fjXPPwnPOl7wfLqW+uLApPdqM3Bm0SRWQpKc1nfYfm ++/yhvn78R2mwy2bZJl3u6Ot4Zh/IPVsE+/2Ax5b9Y8sAi/3hX+Ng/zz/LaQ4+FbktHnupDK3ju4v7 ++64iZtmel7BNT2e02rxW5PTlnu1mmVcbK2lRD6k1fhqWNGIUWicoqx246cnXxuu9XFu1qx86+1b2O ++Oee38eXDzVUki4JKSS9nkseSLmmedK2ZkVvRMTW1Ky0YuSO5mRw6E3H7t58eAAAAAAAAAAAAAAAA ++AAAAAODHngG8zgUwACgAAA== +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-000569/tests/test.sh b/tasks/format-code-task-000569/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..3d03c5b2e849a901241c134157da12dd4c1db3d2 --- /dev/null +++ b/tasks/format-code-task-000569/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' +analysis/token/reverse/reverse_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-000569/tests/test_command.sh b/tasks/format-code-task-000569/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000569/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-000592/environment/Dockerfile b/tasks/format-code-task-000592/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e3a7a1a6b0c97b86391d8c96feea14c8433e2f5c --- /dev/null +++ b/tasks/format-code-task-000592/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:0268a66dc2ef4ca4eaa0bc36d95d39ee06ca8f1433faef9f2dd476276ff15cf0 diff --git a/tasks/format-code-task-000592/environment/setup/files/blocklist b/tasks/format-code-task-000592/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000592/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-000592/environment/setup/setup.sh b/tasks/format-code-task-000592/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000592/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-000592/tests/test.patch b/tasks/format-code-task-000592/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..572eab54c6263a0b781b081128eb08e0b14f799d --- /dev/null +++ b/tasks/format-code-task-000592/tests/test.patch @@ -0,0 +1,517 @@ +diff --git a/tests/terraform/runner/resources/plan_nested_child_modules/tfplan.json b/tests/terraform/runner/resources/plan_nested_child_modules/tfplan.json +new file mode 100644 +index 0000000000..f56da3c8c5 +--- /dev/null ++++ b/tests/terraform/runner/resources/plan_nested_child_modules/tfplan.json +@@ -0,0 +1,450 @@ ++{ ++ "format_version":"0.1", ++ "terraform_version":"0.13.4", ++ "planned_values":{ ++ "root_module":{ ++ "child_modules":[ ++ { ++ "address":"module.child_0", ++ "child_modules":[ ++ { ++ "resources":[ ++ { ++ "address":"module.child_0.module.child_1_c.aws_eks_cluster.cluster", ++ "mode":"managed", ++ "type":"aws_eks_cluster", ++ "name":"cluster", ++ "provider_name":"registry.terraform.io/hashicorp/aws", ++ "schema_version":0, ++ "values":{ ++ "enabled_cluster_log_types":[ ++ "api", ++ "audit" ++ ], ++ "encryption_config":[ ++ ++ ], ++ "name":"test", ++ "role_arn":"arn:aws:iam::12345678912:role/test", ++ "tags":null, ++ "timeouts":null, ++ "vpc_config":[ ++ { ++ "endpoint_private_access":false, ++ "endpoint_public_access":true, ++ "security_group_ids":null, ++ "subnet_ids":[ ++ "10.165.77.0/24" ++ ] ++ } ++ ] ++ } ++ } ++ ], ++ "address":"module.child_0.module.child_1_c" ++ }, ++ { ++ "resources":[ ++ { ++ "address":"module.child_0.module.child_1_b.aws_eks_cluster.cluster", ++ "mode":"managed", ++ "type":"aws_eks_cluster", ++ "name":"cluster", ++ "provider_name":"registry.terraform.io/hashicorp/aws", ++ "schema_version":0, ++ "values":{ ++ "enabled_cluster_log_types":[ ++ "api", ++ "audit" ++ ], ++ "encryption_config":[ ++ ++ ], ++ "name":"test", ++ "role_arn":"arn:aws:iam::12345678912:role/test", ++ "tags":null, ++ "timeouts":null, ++ "vpc_config":[ ++ { ++ "endpoint_private_access":false, ++ "endpoint_public_access":true, ++ "security_group_ids":null, ++ "subnet_ids":[ ++ "10.165.77.0/24" ++ ] ++ } ++ ] ++ } ++ } ++ ], ++ "address":"module.child_0.module.child_1_b" ++ }, ++ { ++ "resources":[ ++ { ++ "address":"module.child_0.module.child_1_a.aws_eks_cluster.cluster", ++ "mode":"managed", ++ "type":"aws_eks_cluster", ++ "name":"cluster", ++ "provider_name":"registry.terraform.io/hashicorp/aws", ++ "schema_version":0, ++ "values":{ ++ "enabled_cluster_log_types":[ ++ "api", ++ "audit" ++ ], ++ "encryption_config":[ ++ ++ ], ++ "name":"test", ++ "role_arn":"arn:aws:iam::12345678912:role/test", ++ "tags":null, ++ "timeouts":null, ++ "vpc_config":[ ++ { ++ "endpoint_private_access":false, ++ "endpoint_public_access":true, ++ "security_group_ids":null, ++ "subnet_ids":[ ++ "10.165.77.0/24" ++ ] ++ } ++ ] ++ } ++ } ++ ], ++ "address":"module.child_0.module.child_1_a" ++ } ++ ] ++ } ++ ] ++ } ++ }, ++ "resource_changes":[ ++ { ++ "address":"module.child_0.module.child_1_a.aws_eks_cluster.cluster", ++ "module_address":"module.child_0.module.child_1_a", ++ "mode":"managed", ++ "type":"aws_eks_cluster", ++ "name":"cluster", ++ "provider_name":"registry.terraform.io/hashicorp/aws", ++ "change":{ ++ "actions":[ ++ "create" ++ ], ++ "before":null, ++ "after":{ ++ "enabled_cluster_log_types":[ ++ "api", ++ "audit" ++ ], ++ "encryption_config":[ ++ ++ ], ++ "name":"test", ++ "role_arn":"arn:aws:iam::12345678912:role/test", ++ "tags":null, ++ "timeouts":null, ++ "vpc_config":[ ++ { ++ "endpoint_private_access":false, ++ "endpoint_public_access":true, ++ "security_group_ids":null, ++ "subnet_ids":[ ++ "10.165.77.0/24" ++ ] ++ } ++ ] ++ }, ++ "after_unknown":{ ++ "arn":true, ++ "certificate_authority":true, ++ "created_at":true, ++ "enabled_cluster_log_types":[ ++ false, ++ false ++ ], ++ "encryption_config":[ ++ ++ ], ++ "endpoint":true, ++ "id":true, ++ "identity":true, ++ "kubernetes_network_config":true, ++ "platform_version":true, ++ "status":true, ++ "version":true, ++ "vpc_config":[ ++ { ++ "cluster_security_group_id":true, ++ "public_access_cidrs":true, ++ "subnet_ids":[ ++ false ++ ], ++ "vpc_id":true ++ } ++ ] ++ } ++ } ++ }, ++ { ++ "address":"module.child_0.module.child_1_b.aws_eks_cluster.cluster", ++ "module_address":"module.child_0.module.child_1_b", ++ "mode":"managed", ++ "type":"aws_eks_cluster", ++ "name":"cluster", ++ "provider_name":"registry.terraform.io/hashicorp/aws", ++ "change":{ ++ "actions":[ ++ "create" ++ ], ++ "before":null, ++ "after":{ ++ "enabled_cluster_log_types":[ ++ "api", ++ "audit" ++ ], ++ "encryption_config":[ ++ ++ ], ++ "name":"test", ++ "role_arn":"arn:aws:iam::12345678912:role/test", ++ "tags":null, ++ "timeouts":null, ++ "vpc_config":[ ++ { ++ "endpoint_private_access":false, ++ "endpoint_public_access":true, ++ "security_group_ids":null, ++ "subnet_ids":[ ++ "10.165.77.0/24" ++ ] ++ } ++ ] ++ }, ++ "after_unknown":{ ++ "arn":true, ++ "certificate_authority":true, ++ "created_at":true, ++ "enabled_cluster_log_types":[ ++ false, ++ false ++ ], ++ "encryption_config":[ ++ ++ ], ++ "endpoint":true, ++ "id":true, ++ "identity":true, ++ "kubernetes_network_config":true, ++ "platform_version":true, ++ "status":true, ++ "version":true, ++ "vpc_config":[ ++ { ++ "cluster_security_group_id":true, ++ "public_access_cidrs":true, ++ "subnet_ids":[ ++ false ++ ], ++ "vpc_id":true ++ } ++ ] ++ } ++ } ++ }, ++ { ++ "address":"module.child_0.module.child_1_c.aws_eks_cluster.cluster", ++ "module_address":"module.child_0.module.child_1_c", ++ "mode":"managed", ++ "type":"aws_eks_cluster", ++ "name":"cluster", ++ "provider_name":"registry.terraform.io/hashicorp/aws", ++ "change":{ ++ "actions":[ ++ "create" ++ ], ++ "before":null, ++ "after":{ ++ "enabled_cluster_log_types":[ ++ "api", ++ "audit" ++ ], ++ "encryption_config":[ ++ ++ ], ++ "name":"test", ++ "role_arn":"arn:aws:iam::12345678912:role/test", ++ "tags":null, ++ "timeouts":null, ++ "vpc_config":[ ++ { ++ "endpoint_private_access":false, ++ "endpoint_public_access":true, ++ "security_group_ids":null, ++ "subnet_ids":[ ++ "10.165.77.0/24" ++ ] ++ } ++ ] ++ }, ++ "after_unknown":{ ++ "arn":true, ++ "certificate_authority":true, ++ "created_at":true, ++ "enabled_cluster_log_types":[ ++ false, ++ false ++ ], ++ "encryption_config":[ ++ ++ ], ++ "endpoint":true, ++ "id":true, ++ "identity":true, ++ "kubernetes_network_config":true, ++ "platform_version":true, ++ "status":true, ++ "version":true, ++ "vpc_config":[ ++ { ++ "cluster_security_group_id":true, ++ "public_access_cidrs":true, ++ "subnet_ids":[ ++ false ++ ], ++ "vpc_id":true ++ } ++ ] ++ } ++ } ++ } ++ ], ++ "configuration":{ ++ "root_module":{ ++ "module_calls":{ ++ "child_0":{ ++ "source":"./module", ++ "module":{ ++ "module_calls":{ ++ "child_1_a":{ ++ "source":"./module", ++ "module":{ ++ "resources":[ ++ { ++ "address":"aws_eks_cluster.cluster", ++ "mode":"managed", ++ "type":"aws_eks_cluster", ++ "name":"cluster", ++ "provider_config_key":"child_1_a:aws", ++ "expressions":{ ++ "enabled_cluster_log_types":{ ++ "constant_value":[ ++ "audit", ++ "api" ++ ] ++ }, ++ "name":{ ++ "constant_value":"test" ++ }, ++ "role_arn":{ ++ "constant_value":"arn:aws:iam::12345678912:role/test" ++ }, ++ "vpc_config":[ ++ { ++ "subnet_ids":{ ++ "constant_value":[ ++ "10.165.77.0/24" ++ ] ++ } ++ } ++ ] ++ }, ++ "schema_version":0 ++ } ++ ] ++ } ++ }, ++ "child_1_b":{ ++ "source":"./module", ++ "module":{ ++ "resources":[ ++ { ++ "address":"aws_eks_cluster.cluster", ++ "mode":"managed", ++ "type":"aws_eks_cluster", ++ "name":"cluster", ++ "provider_config_key":"child_1_b:aws", ++ "expressions":{ ++ "enabled_cluster_log_types":{ ++ "constant_value":[ ++ "audit", ++ "api" ++ ] ++ }, ++ "name":{ ++ "constant_value":"test" ++ }, ++ "role_arn":{ ++ "constant_value":"arn:aws:iam::12345678912:role/test" ++ }, ++ "vpc_config":[ ++ { ++ "subnet_ids":{ ++ "constant_value":[ ++ "10.165.77.0/24" ++ ] ++ } ++ } ++ ] ++ }, ++ "schema_version":0 ++ } ++ ] ++ } ++ }, ++ "child_1_c":{ ++ "source":"./module", ++ "module":{ ++ "resources":[ ++ { ++ "address":"aws_eks_cluster.cluster", ++ "mode":"managed", ++ "type":"aws_eks_cluster", ++ "name":"cluster", ++ "provider_config_key":"child_1_c:aws", ++ "expressions":{ ++ "enabled_cluster_log_types":{ ++ "constant_value":[ ++ "audit", ++ "api" ++ ] ++ }, ++ "name":{ ++ "constant_value":"test" ++ }, ++ "role_arn":{ ++ "constant_value":"arn:aws:iam::12345678912:role/test" ++ }, ++ "vpc_config":[ ++ { ++ "subnet_ids":{ ++ "constant_value":[ ++ "10.165.77.0/24" ++ ] ++ } ++ } ++ ] ++ }, ++ "schema_version":0 ++ } ++ ] ++ } ++ } ++ } ++ } ++ } ++ } ++ } ++ } ++} +diff --git a/tests/terraform/runner/test_plan_runner.py b/tests/terraform/runner/test_plan_runner.py +index 51254885f6..3200325a4b 100644 +--- a/tests/terraform/runner/test_plan_runner.py ++++ b/tests/terraform/runner/test_plan_runner.py +@@ -42,6 +42,22 @@ def test_runner_child_modules(self): + self.assertEqual(report.get_summary()["failed"], 3) + self.assertEqual(report.get_summary()["passed"], 4) + ++ def test_runner_nested_child_modules(self): ++ current_dir = os.path.dirname(os.path.realpath(__file__)) ++ valid_plan_path = current_dir + "/resources/plan_nested_child_modules/tfplan.json" ++ runner = Runner() ++ report = runner.run(root_folder=None, files=[valid_plan_path], external_checks_dir=None, ++ runner_filter=RunnerFilter(framework='all')) ++ report_json = report.get_json() ++ self.assertTrue(isinstance(report_json, str)) ++ self.assertIsNotNone(report_json) ++ self.assertIsNotNone(report.get_test_suites()) ++ self.assertEqual(report.get_exit_code(soft_fail=False), 1) ++ self.assertEqual(report.get_exit_code(soft_fail=True), 0) ++ ++ self.assertEqual(report.get_summary()["failed"], 12) ++ self.assertEqual(report.get_summary()["passed"], 0) ++ + def test_runner_root_module_resources_no_values(self): + current_dir = os.path.dirname(os.path.realpath(__file__)) + valid_plan_path = current_dir + "/resources/plan_root_module_resources_no_values/tfplan.json" +@@ -74,11 +90,11 @@ def test_runner_root_dir(self): + self.assertEqual(report.get_exit_code(soft_fail=False), 1) + self.assertEqual(report.get_exit_code(soft_fail=True), 0) + +- self.assertEqual(45, report.get_summary()["failed"]) ++ self.assertEqual(57, report.get_summary()["failed"]) + self.assertEqual(60, report.get_summary()["passed"]) + + files_scanned = list(set(map(lambda rec: rec.file_path, report.failed_checks))) +- self.assertGreaterEqual(3, len(files_scanned)) ++ self.assertGreaterEqual(4, len(files_scanned)) + + + if __name__ == '__main__': +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+3S0WrCMBTG8Vz7FOcFrDnatI9Tqu1wYJOSpoJvv6zCNgabN8oY/n8XSTgnkIQv ++xX5+PXVN788b8yg2q51b5uz7vKzVbXVrXV3tKmNVK7VG3MNu9MU8pTaKmBhC+m3frf4/VXzmn/op ++NYcwDK3viul4vzNu5a9afuTvyrxPy0prI/Z+V/jZk+d/6GQJft93q/GSjsHvZD1IXuaivA9T7sfY ++voQ4bOLsfR+vP2U8tb65ForxIuvz6q/fAgAAAAAAAAAAAAAAADybNzQdOnsAKAAA +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-000592/tests/test.sh b/tasks/format-code-task-000592/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..fbcb05ac080e9fd03aa5d44ea87cffca782c261e --- /dev/null +++ b/tasks/format-code-task-000592/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/terraform/runner/resources/plan_nested_child_modules/tfplan.json +tests/terraform/runner/test_plan_runner.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-000592/tests/test_command.sh b/tasks/format-code-task-000592/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000592/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-000593/environment/Dockerfile b/tasks/format-code-task-000593/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..5fafeb5ac3b336ad16c114c3c0476e37972ad744 --- /dev/null +++ b/tasks/format-code-task-000593/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:d9e45f6cf16588abd06a7a84b06f3ae11d11a0669e1a66e41423525e9446bc6e diff --git a/tasks/format-code-task-000593/environment/setup/files/blocklist b/tasks/format-code-task-000593/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000593/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-000593/environment/setup/setup.sh b/tasks/format-code-task-000593/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000593/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-000593/tests/test.patch b/tasks/format-code-task-000593/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..8b7b377cf73df259a2e0193f351f5ee33a438dd6 --- /dev/null +++ b/tasks/format-code-task-000593/tests/test.patch @@ -0,0 +1,228 @@ +diff --git a/usercase-test-coderl/fixtures/boto-empty.cfg b/usercase-test-coderl/fixtures/boto-empty.cfg +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/boto-empty.cfg +@@ -0,0 +1,1 @@ ++ +diff --git a/usercase-test-coderl/test_dynamize_value.py b/usercase-test-coderl/test_dynamize_value.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_dynamize_value.py +@@ -0,0 +1,192 @@ ++import collections ++import collections.abc ++import copy ++import json ++import os ++import socket ++import subprocess ++import sys ++import tempfile ++import unittest ++from decimal import Decimal ++from unittest import mock ++ ++ ++ ++if not hasattr(collections, "Mapping"): ++ collections.Mapping = collections.abc.Mapping ++ ++sys.path.insert(0, "/workspace/repo") ++ ++from boto.dynamodb.types import Binary, dynamize_value ++ ++ ++ ++ ++ ++ ++class TestDynamizeValueAcceptance(unittest.TestCase): ++ def test_string_scalar_is_encoded_as_s_attribute_value(self): ++ ++ ++ ++ ++ actual = dynamize_value("foo") ++ self.assertEqual(actual, {"S": "foo"}) ++ ++ def test_empty_string_boundary_still_uses_s_attribute_value(self): ++ ++ ++ ++ ++ actual = dynamize_value("") ++ self.assertEqual(actual, {"S": ""}) ++ ++ def test_integer_scalar_is_stringified_as_n_attribute_value(self): ++ ++ ++ ++ ++ actual = dynamize_value(54) ++ self.assertEqual(actual, {"N": "54"}) ++ ++ def test_decimal_scalar_preserves_decimal_string_in_n_attribute_value(self): ++ ++ ++ ++ ++ actual = dynamize_value(Decimal("1234567890.0123")) ++ self.assertEqual(actual, {"N": "1234567890.0123"}) ++ ++ def test_negative_float_scalar_is_stringified_as_n_attribute_value(self): ++ ++ ++ ++ ++ actual = dynamize_value(-3.5) ++ self.assertEqual(actual, {"N": "-3.5"}) ++ ++ def test_binary_wrapper_scalar_is_base64_encoded_as_b_attribute_value(self): ++ ++ ++ ++ ++ actual = dynamize_value(Binary(b"\x01")) ++ self.assertEqual(actual, {"B": "AQ=="}) ++ ++ def test_raw_bytes_scalar_is_base64_encoded_as_b_attribute_value(self): ++ ++ ++ ++ ++ actual = dynamize_value(b"\x00\xff") ++ self.assertEqual(actual, {"B": "AP8="}) ++ ++ def test_numeric_set_is_encoded_as_ns_attribute_value(self): ++ ++ ++ ++ ++ actual = dynamize_value({1, 2, 10}) ++ ++ self.assertEqual(set(actual.keys()), {"NS"}) ++ self.assertCountEqual(actual["NS"], ["1", "2", "10"]) ++ ++ def test_empty_set_boundary_is_encoded_as_empty_ns_attribute_value(self): ++ ++ ++ ++ ++ actual = dynamize_value(set()) ++ self.assertEqual(actual, {"NS": []}) ++ ++ def test_string_set_is_encoded_as_ss_attribute_value(self): ++ ++ ++ ++ ++ actual = dynamize_value({"red"}) ++ self.assertEqual(actual, {"SS": ["red"]}) ++ ++ def test_binary_set_is_encoded_as_bs_attribute_value(self): ++ ++ ++ ++ ++ actual = dynamize_value({Binary(b"\x01")}) ++ self.assertEqual(actual, {"BS": ["AQ=="]}) ++ ++ def test_mixed_set_rejects_with_type_error(self): ++ ++ ++ ++ ++ with self.assertRaises(TypeError): ++ dynamize_value({1, "a"}) ++ ++ def test_referential_transparency_for_same_supported_input(self): ++ first = dynamize_value(Decimal("7.25")) ++ second = dynamize_value(Decimal("7.25")) ++ self.assertEqual(first, {"N": "7.25"}) ++ self.assertEqual(second, {"N": "7.25"}) ++ self.assertEqual(first, second) ++ ++ def test_does_not_mutate_caller_owned_set_input(self): ++ original = {1, 2, 10} ++ before = copy.deepcopy(original) ++ actual = dynamize_value(original) ++ ++ self.assertEqual(set(actual.keys()), {"NS"}) ++ self.assertCountEqual(actual["NS"], ["1", "2", "10"]) ++ self.assertEqual(original, before) ++ self.assertEqual(original, {1, 2, 10}) ++ ++ def test_same_input_matches_fresh_process_result(self): ++ in_process = dynamize_value("cache-check") ++ script = """ ++import collections, collections.abc, json, sys ++if not hasattr(collections, 'Mapping'): ++ collections.Mapping = collections.abc.Mapping ++sys.path.insert(0, '/workspace/repo') ++from boto.dynamodb.types import dynamize_value ++sys.stdout.write(json.dumps(dynamize_value('cache-check'), sort_keys=True)) ++""" ++ completed = subprocess.run( ++ [sys.executable, "-c", script], ++ stdout=subprocess.PIPE, ++ stderr=subprocess.PIPE, ++ check=True, ++ text=True, ++ ) ++ fresh_process = json.loads(completed.stdout) ++ self.assertEqual(in_process, {"S": "cache-check"}) ++ self.assertEqual(fresh_process, {"S": "cache-check"}) ++ self.assertEqual(in_process, fresh_process) ++ ++ def test_does_not_touch_filesystem_or_network_for_pure_conversion(self): ++ def blocked_socket(*args, **kwargs): ++ raise AssertionError("dynamize_value must not open network sockets") ++ ++ def blocked_open(*args, **kwargs): ++ raise AssertionError("dynamize_value must not open files") ++ ++ old_cwd = os.getcwd() ++ with tempfile.TemporaryDirectory() as tmpdir: ++ try: ++ os.chdir(tmpdir) ++ before = sorted(os.listdir(".")) ++ with mock.patch.object(socket, "socket", blocked_socket), mock.patch( ++ "builtins.open", blocked_open ++ ): ++ actual = dynamize_value(Binary(b"\x01")) ++ after = sorted(os.listdir(".")) ++ finally: ++ os.chdir(old_cwd) ++ ++ self.assertEqual(actual, {"B": "AQ=="}) ++ self.assertEqual(before, []) ++ self.assertEqual(after, []) ++ ++ ++if __name__ == "__main__": ++ unittest.main(verbosity=2) +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 PYTHONPATH=/workspace/repo${PYTHONPATH:+:$PYTHONPATH} ++ ++ ++export BOTO_CONFIG=/workspace/repo/usercase-test-coderl/fixtures/boto-empty.cfg ++exec python /workspace/repo/usercase-test-coderl/test_dynamize_value.py -v diff --git a/tasks/format-code-task-000593/tests/test.sh b/tasks/format-code-task-000593/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..625af6cf528ed72ab2151aa5e108671fc215255d --- /dev/null +++ b/tasks/format-code-task-000593/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/boto-empty.cfg +usercase-test-coderl/test_dynamize_value.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-000593/tests/test_command.sh b/tasks/format-code-task-000593/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000593/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-000595/environment/Dockerfile b/tasks/format-code-task-000595/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..12f3ae791f2f9472031c9b409aa5ad325c0e3d46 --- /dev/null +++ b/tasks/format-code-task-000595/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:de1023dc7115aafb207bb6ae002b385e6d347dbaae695c3fc100cb3f4ee9e884 diff --git a/tasks/format-code-task-000595/environment/setup/files/blocklist b/tasks/format-code-task-000595/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000595/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-000595/environment/setup/setup.sh b/tasks/format-code-task-000595/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000595/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-000595/tests/test.patch b/tasks/format-code-task-000595/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..977cfead60135bc23155b395e14240fedff8d534 --- /dev/null +++ b/tasks/format-code-task-000595/tests/test.patch @@ -0,0 +1,51 @@ +diff --git a/test/basic.spec.js b/test/basic.spec.js +index 6e761d5..0cda0f7 100644 +--- a/test/basic.spec.js ++++ b/test/basic.spec.js +@@ -137,6 +137,26 @@ describe('writeGood', function () { + { index: 2, offset: 8, reason: '"there is" is unnecessary verbiage' } + ]); + }); ++ ++ it('should detect simple "to be" verb', function () { ++ expect(writeGood('NodeJs is awesome ;)', { eprime: true })).toEqual([ ++ { index: 7, offset: 2, reason: '"is" is a form of \'to be\'' } ++ ]); ++ }); ++ ++ it('should ignore "to be" verb with check disabled', function () { ++ expect(writeGood('NodeJs is awesome ;)', { eprime: false })).toEqual([]); ++ }); ++ ++ it('should detect "to be" verb contraction', function () { ++ expect(writeGood('There\'s no place like localhost', { eprime: true })).toEqual([ ++ { index: 0, offset: 7, reason: '"There\'s" is a form of \'to be\'' } ++ ]); ++ }); ++ ++ it('shouldn\'t flag words starting with "is" as an error', function () { ++ expect(writeGood('Isle of Man', { eprime: true })).toEqual([]); ++ }); + }); + + describe('annotate', function () { +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+3RTQ6DIBAFYNaeggsUEKXuehWjQlIafkxRz191Y9Ok7aZN0/i+zZAMgYHH2tE6 ++XZswcfItYlYptdbZY13XuZKiELIopSQiz1UlCVVfm+jOmIbmSim5xji82veu/6fYlv9g0lB30fsm ++aJbOn7vjXf55seVfVEv+5VGUhIrPjfDczvPvNF2Db43OQu+pDfN/OEfliWsz8TA6lzEeoja1j3p0 ++JnHW2sAvTfI2mMPSocsBvG2S7VjqTccuKfv1uwAAAAAAAAAAAAAAAAAAAAAA9uAGbYCL2QAoAAA= +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-000595/tests/test.sh b/tasks/format-code-task-000595/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..f5ae2159d4e001986cdc7e39c33bd4bd431da2c1 --- /dev/null +++ b/tasks/format-code-task-000595/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/basic.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-000595/tests/test_command.sh b/tasks/format-code-task-000595/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000595/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-000700/environment/Dockerfile b/tasks/format-code-task-000700/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..bfaf9a22ee686cc8928ba289673cbb94c36ad7a1 --- /dev/null +++ b/tasks/format-code-task-000700/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:554e37a1a15a78324365b226b4aff733274027c4603617a704490019d4bed8ea diff --git a/tasks/format-code-task-000700/environment/setup/files/blocklist b/tasks/format-code-task-000700/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000700/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-000700/environment/setup/setup.sh b/tasks/format-code-task-000700/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000700/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-000700/tests/test.patch b/tasks/format-code-task-000700/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..c51fa0c4ea8728388ad684371049ad7618d50038 --- /dev/null +++ b/tasks/format-code-task-000700/tests/test.patch @@ -0,0 +1,252 @@ +diff --git a/colour/difference/tests/test_delta_e.py b/colour/difference/tests/test_delta_e.py +index 99f97cc35..0a3d223d5 100644 +--- a/colour/difference/tests/test_delta_e.py ++++ b/colour/difference/tests/test_delta_e.py +@@ -16,10 +16,13 @@ import numpy as np + from colour.algebra import euclidean_distance + from colour.constants import TOLERANCE_ABSOLUTE_TESTS + from colour.difference import ( ++ DELTA_E_METHODS, ++ delta_E, + delta_E_CIE1976, + delta_E_CIE1994, + delta_E_CIE2000, + delta_E_CMC, ++ delta_E_HyAB, + delta_E_ITP, + ) + from colour.utilities import domain_range_scale, ignore_numpy_errors +@@ -37,6 +40,7 @@ __all__ = [ + "TestDelta_E_CIE2000", + "TestDelta_E_CMC", + "TestDelta_E_ITP", ++ "TestDelta_E_HyAB", + ] + + +@@ -745,3 +749,53 @@ class TestDelta_E_ITP: + cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] + cases = np.array(list(set(product(cases, repeat=3)))) + delta_E_ITP(cases, cases) ++ ++ ++class TestDelta_E_HyAB: ++ """ ++ Define :func:`colour.difference.delta_E_HyAB` definition unit tests ++ methods. ++ """ ++ ++ def test_delta_E_HyAB(self): ++ """Test :func:`colour.difference.delta_E_HyAB` definition.""" ++ ++ Lab_1 = np.array( ++ [ ++ [62.9, 28.3, 95.1], ++ [15.3, 3.8, 29.3], ++ ] ++ ) ++ Lab_2 = np.array( ++ [ ++ [15.3, 3.8, 29.3], ++ [62.9, 28.3, 95.1], ++ ] ++ ) ++ expected = np.abs(Lab_1[..., 0] - Lab_2[..., 0]) + euclidean_distance( ++ Lab_1[..., 1:], Lab_2[..., 1:] ++ ) ++ ++ np.testing.assert_allclose( ++ delta_E_HyAB(Lab_1, Lab_2), ++ expected, ++ atol=TOLERANCE_ABSOLUTE_TESTS, ++ ) ++ ++ def test_delta_E_HyAB_method_and_registry(self): ++ """ ++ Test :func:`colour.difference.delta_E` HyAB method selection and ++ public method discovery. ++ """ ++ ++ Lab_1 = np.array([10.0, -20.0, 30.0]) ++ Lab_2 = np.array([40.0, 5.0, -15.0]) ++ ++ assert "HyAB" in DELTA_E_METHODS ++ assert callable(DELTA_E_METHODS["HyAB"]) ++ ++ np.testing.assert_allclose( ++ delta_E(Lab_1, Lab_2, method="HyAB"), ++ delta_E_HyAB(Lab_1, Lab_2), ++ atol=TOLERANCE_ABSOLUTE_TESTS, ++ ) +diff --git a/docs/tests/test_colour_difference_docs.py b/docs/tests/test_colour_difference_docs.py +new file mode 100644 +index 000000000..12b358b6d +--- /dev/null ++++ b/docs/tests/test_colour_difference_docs.py +@@ -0,0 +1,12 @@ ++from pathlib import Path ++ ++ ++def test_hyab_documentation_entry(): ++ ++ ++ documentation = Path(__file__).parents[1] / "colour.difference.rst" ++ text = documentation.read_text(encoding="utf8") ++ ++ assert "HyAB" in text ++ assert "delta_E_HyAB" in text ++ assert text.index("HyAB") < text.index("delta_E_HyAB") +diff --git a/mimo_test.patch b/mimo_test.patch +new file mode 100644 +--- /dev/null ++++ b/mimo_test.patch +@@ -0,0 +1,98 @@ ++diff --git a/colour/difference/tests/test_delta_e.py b/colour/difference/tests/test_delta_e.py ++index 99f97cc35..0a3d223d5 100644 ++--- a/colour/difference/tests/test_delta_e.py +++++ b/colour/difference/tests/test_delta_e.py ++@@ -16,10 +16,13 @@ import numpy as np ++ from colour.algebra import euclidean_distance ++ from colour.constants import TOLERANCE_ABSOLUTE_TESTS ++ from colour.difference import ( +++ DELTA_E_METHODS, +++ delta_E, ++ delta_E_CIE1976, ++ delta_E_CIE1994, ++ delta_E_CIE2000, ++ delta_E_CMC, +++ delta_E_HyAB, ++ delta_E_ITP, ++ ) ++ from colour.utilities import domain_range_scale, ignore_numpy_errors ++@@ -37,6 +40,7 @@ __all__ = [ ++ "TestDelta_E_CIE2000", ++ "TestDelta_E_CMC", ++ "TestDelta_E_ITP", +++ "TestDelta_E_HyAB", ++ ] ++ ++ ++@@ -745,3 +749,53 @@ class TestDelta_E_ITP: ++ cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] ++ cases = np.array(list(set(product(cases, repeat=3)))) ++ delta_E_ITP(cases, cases) +++ +++ +++class TestDelta_E_HyAB: +++ """ +++ Define :func:`colour.difference.delta_E_HyAB` definition unit tests +++ methods. +++ """ +++ +++ def test_delta_E_HyAB(self): +++ """Test :func:`colour.difference.delta_E_HyAB` definition.""" +++ +++ Lab_1 = np.array( +++ [ +++ [62.9, 28.3, 95.1], +++ [15.3, 3.8, 29.3], +++ ] +++ ) +++ Lab_2 = np.array( +++ [ +++ [15.3, 3.8, 29.3], +++ [62.9, 28.3, 95.1], +++ ] +++ ) +++ expected = np.abs(Lab_1[..., 0] - Lab_2[..., 0]) + euclidean_distance( +++ Lab_1[..., 1:], Lab_2[..., 1:] +++ ) +++ +++ np.testing.assert_allclose( +++ delta_E_HyAB(Lab_1, Lab_2), +++ expected, +++ atol=TOLERANCE_ABSOLUTE_TESTS, +++ ) +++ +++ def test_delta_E_HyAB_method_and_registry(self): +++ """ +++ Test :func:`colour.difference.delta_E` HyAB method selection and +++ public method discovery. +++ """ +++ +++ Lab_1 = np.array([10.0, -20.0, 30.0]) +++ Lab_2 = np.array([40.0, 5.0, -15.0]) +++ +++ assert "HyAB" in DELTA_E_METHODS +++ assert callable(DELTA_E_METHODS["HyAB"]) +++ +++ np.testing.assert_allclose( +++ delta_E(Lab_1, Lab_2, method="HyAB"), +++ delta_E_HyAB(Lab_1, Lab_2), +++ atol=TOLERANCE_ABSOLUTE_TESTS, +++ ) ++diff --git a/docs/tests/test_colour_difference_docs.py b/docs/tests/test_colour_difference_docs.py ++new file mode 100644 ++index 000000000..12b358b6d ++--- /dev/null +++++ b/docs/tests/test_colour_difference_docs.py ++@@ -0,0 +1,12 @@ +++from pathlib import Path +++ +++ +++def test_hyab_documentation_entry(): +++ """Test that the colour difference documentation exposes HyAB.""" +++ +++ documentation = Path(__file__).parents[1] / "colour.difference.rst" +++ text = documentation.read_text(encoding="utf8") +++ +++ assert "HyAB" in text +++ assert "delta_E_HyAB" in text +++ assert text.index("HyAB") < text.index("delta_E_HyAB") +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 -uo pipefail ++cd /testbed ++ ++ ++set +u ++python3 -m venv /testbed/.venv ++source /testbed/.venv/bin/activate ++pip install --no-input -e ".[tests]" pytest pytest-xdist 2>/dev/null ++set -u ++ ++ ++TEST_PATCH=/testbed/mimo_test.patch ++ ++case "${1:-}" in ++ base) ++ tmpdir=$(mktemp -d) ++ cp colour/difference/tests/test_delta_e.py "$tmpdir/test_delta_e.py" ++ had_docs_test=0 ++ if [ -f docs/tests/test_colour_difference_docs.py ]; then ++ had_docs_test=1 ++ cp docs/tests/test_colour_difference_docs.py "$tmpdir/test_colour_difference_docs.py" ++ fi ++ git apply --reverse --whitespace=nowarn "$TEST_PATCH" ++ python -m pytest colour/difference/tests/test_delta_e.py -v ++ status=$? ++ cp "$tmpdir/test_delta_e.py" colour/difference/tests/test_delta_e.py ++ if [ "$had_docs_test" -eq 1 ]; then ++ mkdir -p docs/tests ++ cp "$tmpdir/test_colour_difference_docs.py" docs/tests/test_colour_difference_docs.py ++ fi ++ rm -rf "$tmpdir" ++ exit "$status" ++ ;; ++ new) ++ python -m pytest \ ++ colour/difference/tests/test_delta_e.py::TestDelta_E_HyAB::test_delta_E_HyAB \ ++ colour/difference/tests/test_delta_e.py::TestDelta_E_HyAB::test_delta_E_HyAB_method_and_registry \ ++ docs/tests/test_colour_difference_docs.py::test_hyab_documentation_entry \ ++ -v ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-000700/tests/test.sh b/tasks/format-code-task-000700/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..210d59c0d49be8019379a56d76107711bdc7f340 --- /dev/null +++ b/tasks/format-code-task-000700/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' +colour/difference/tests/test_delta_e.py +docs/tests/test_colour_difference_docs.py +mimo_test.patch +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-000700/tests/test_command.sh b/tasks/format-code-task-000700/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-000700/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-000707/environment/Dockerfile b/tasks/format-code-task-000707/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..5599b917c57da67a85ceb670d307292b386c2f92 --- /dev/null +++ b/tasks/format-code-task-000707/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:2952a0bbfb9958537d1be60c3bda4e6c7f2a0a5935c5e74951d60f93421acdaf diff --git a/tasks/format-code-task-000707/environment/setup/files/blocklist b/tasks/format-code-task-000707/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000707/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-000707/environment/setup/setup.sh b/tasks/format-code-task-000707/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000707/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-000707/tests/test.patch b/tasks/format-code-task-000707/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..165410335a10806f2fa93e0dbad4b5ccd5489373 --- /dev/null +++ b/tasks/format-code-task-000707/tests/test.patch @@ -0,0 +1,153 @@ +diff --git a/test/has-length.js b/test/has-length.js +new file mode 100644 +index 0000000..dd05e38 +--- /dev/null ++++ b/test/has-length.js +@@ -0,0 +1,125 @@ ++import test from 'ava' ++ ++import {describe, format, serialize} from '..' ++ ++ ++ ++ ++ ++ ++test('describe({length: 12345678}) does not treat plain object as a list', t => { ++ const descriptor = describe({length: 12345678}) ++ t.false(descriptor.isList) ++ t.false(descriptor.isArray) ++}) ++ ++test('serialize(describe({length: 12345678})) does not OOM and completes quickly', t => { ++ const start = Date.now() ++ const descriptor = describe({length: 12345678}) ++ const buffer = serialize(descriptor) ++ const elapsed = Date.now() - start ++ t.true(Buffer.isBuffer(buffer)) ++ ++ ++ t.true(elapsed < 2000, `serialize took ${elapsed}ms`) ++ ++ t.true(buffer.length < 1024, `buffer length ${buffer.length}`) ++}) ++ ++test('format({length: 5}) renders as plain object, not as a list with undefined entries', t => { ++ const out = format({length: 5}) ++ ++ ++ t.false(out.includes('undefined'), `unexpected undefined entries in output: ${out}`) ++ t.true(out.startsWith('{'), `expected plain object form, got: ${out}`) ++ t.true(out.includes('length: 5')) ++}) ++ ++test('format on issue example: array of recording objects with length field', t => { ++ const value = [ ++ {title: 'Airbag', length: 284400}, ++ {title: 'Paranoid Android', length: 383493} ++ ] ++ const start = Date.now() ++ const out = format(value) ++ const elapsed = Date.now() - start ++ t.true(elapsed < 2000, `format took ${elapsed}ms`) ++ t.true(out.includes('Airbag')) ++ t.true(out.includes('Paranoid Android')) ++ t.true(out.includes('284400')) ++ t.true(out.includes('383493')) ++ ++ t.false(out.includes('undefined'), `unexpected undefined entries in: ${out}`) ++}) ++ ++test('format({length: -1}) treats negative length as plain object (not a list)', t => { ++ const out = format({length: -1}) ++ t.true(out.startsWith('{'), `expected plain object form, got: ${out}`) ++ t.true(out.includes('length: -1')) ++}) ++ ++test('format({length: 1.5}) treats non-integer length as plain object (not a list)', t => { ++ const out = format({length: 1.5}) ++ t.true(out.startsWith('{'), `expected plain object form, got: ${out}`) ++ t.true(out.includes('length: 1.5')) ++}) ++ ++test('format({length: NaN}) treats NaN length as plain object (not a list)', t => { ++ const out = format({length: NaN}) ++ t.true(out.startsWith('{'), `expected plain object form, got: ${out}`) ++ t.true(out.includes('length: NaN')) ++}) ++ ++ ++ ++test('format([]) still works (real empty array)', t => { ++ const out = format([]) ++ t.is(out, '[]') ++}) ++ ++test('format([1, 2, 3]) still works (real array preserved)', t => { ++ const out = format([1, 2, 3]) ++ t.true(out.startsWith('[')) ++ t.true(out.includes('1,')) ++ t.true(out.includes('2,')) ++ t.true(out.includes('3,')) ++}) ++ ++test('describe of arguments object is still treated as a list', t => { ++ ;(function (a, b, c) { ++ const descriptor = describe(arguments) ++ t.true(descriptor.isList) ++ })('foo', 'bar', 'baz') ++}) ++ ++test('format of funky object with non-enumerable length and indexed entries still works as list', t => { ++ const funky = {0: 'first', 1: 'second', foo: 'bar'} ++ Object.defineProperty(funky, 'length', {value: 2}) ++ const descriptor = describe(funky) ++ t.true(descriptor.isList) ++ const out = format(funky) ++ t.true(out.startsWith('['), `expected list form, got: ${out}`) ++ t.true(out.includes("'first'")) ++ t.true(out.includes("'second'")) ++ t.true(out.includes("foo:")) ++}) ++ ++test('describe({length: 3, 0: a, 1: b, 2: c}) is treated as a list (own indexed entries)', t => { ++ const arrLike = {length: 3, 0: 'a', 1: 'b', 2: 'c'} ++ const descriptor = describe(arrLike) ++ t.true(descriptor.isList) ++ const out = format(arrLike) ++ t.true(out.startsWith('['), `expected list form, got: ${out}`) ++ t.true(out.includes("'a'")) ++ t.true(out.includes("'b'")) ++ t.true(out.includes("'c'")) ++ t.true(out.includes('length: 3')) ++}) ++ ++test('describe({length: 0}) is treated as an empty list', t => { ++ const descriptor = describe({length: 0}) ++ t.true(descriptor.isList) ++ const out = format({length: 0}) ++ t.true(out.startsWith('['), `expected list form, got: ${out}`) ++ t.true(out.includes('length: 0')) ++}) +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..ec70650 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["./node_modules/.bin/ava test/has-length.js --verbose"] ++} +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/ava test/has-length.js --verbose ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000707/tests/test.sh b/tasks/format-code-task-000707/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..3cae44cb4475608728b4dc69f688813b8dc7877c --- /dev/null +++ b/tasks/format-code-task-000707/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/has-length.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-000707/tests/test_command.sh b/tasks/format-code-task-000707/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000707/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-000736/environment/Dockerfile b/tasks/format-code-task-000736/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..de00185763c3d368570fa2dff8ec0f6948305944 --- /dev/null +++ b/tasks/format-code-task-000736/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:dc983040855ad4f5a9676504a906eb7b87ecac46ff812e615a2773f154292da9 diff --git a/tasks/format-code-task-000736/environment/setup/files/blocklist b/tasks/format-code-task-000736/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000736/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-000736/environment/setup/setup.sh b/tasks/format-code-task-000736/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000736/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-000736/tests/test.patch b/tasks/format-code-task-000736/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..89b54b6561db77fa52ceaf69fde40aa0f4adbaf1 --- /dev/null +++ b/tasks/format-code-task-000736/tests/test.patch @@ -0,0 +1,72 @@ +diff --git a/_examples/assert-godogs/godogs_test.go b/_examples/assert-godogs/godogs_test.go +index e974bfec..ea128836 100644 +--- a/_examples/assert-godogs/godogs_test.go ++++ b/_examples/assert-godogs/godogs_test.go +@@ -14,7 +14,7 @@ import ( + var opts = godog.Options{Output: colors.Colored(os.Stdout)} + + func init() { +- godog.BindCommandLineFlags("godog.", &opts) ++ godog.BindFlags("godog.", flag.CommandLine, &opts) + } + + func TestMain(m *testing.M) { +diff --git a/_examples/godogs/godogs_test.go b/_examples/godogs/godogs_test.go +index 90272b7f..b78e49ef 100644 +--- a/_examples/godogs/godogs_test.go ++++ b/_examples/godogs/godogs_test.go +@@ -13,7 +13,7 @@ import ( + var opts = godog.Options{Output: colors.Colored(os.Stdout)} + + func init() { +- godog.BindCommandLineFlags("godog.", &opts) ++ godog.BindFlags("godog.", flag.CommandLine, &opts) + } + + func TestMain(m *testing.M) { +diff --git a/run_progress_test.go b/run_progress_test.go +index 2095b809..5f67db5f 100644 +--- a/run_progress_test.go ++++ b/run_progress_test.go +@@ -145,10 +145,10 @@ func undef() error { + return godog.ErrPending + } + +-func FeatureContext(s *godog.Suite) { +- s.Step(` + "`^three$`" + `, three) +- s.Step(` + "`^unavailable \"([^\"]*)\" cost (\\d+)$`" + `, unavailableCost) +- s.Step(` + "`^undef$`" + `, undef) ++func InitializeScenario(ctx *godog.ScenarioContext) { ++ ctx.Step(` + "`^three$`" + `, three) ++ ctx.Step(` + "`^unavailable \"([^\"]*)\" cost (\\d+)$`" + `, unavailableCost) ++ ctx.Step(` + "`^undef$`" + `, undef) + } + + ` +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+2UP2/bMBDFPetTHNQO9qB/TmRPGQoUTbcGbXaDFs8SYYkUSEqOv31Pspu6gWsv ++CYoi91skSMfju/coxetO1XKFuk8mb0VKLPN8vBIvr+N9ls+zbLG8WabzSUp3aT6B/M0UndA5LyzA ++xBrjL9Vde/+fEv/O36Pzq8I0jdAydtXr7XEl/yzPFs/5L9Jbyv92Maf809eT8Hfeef6FhDH4Ncog +++AA/0EPXwr2BHq1TRsM0i+c3oBxoRIkSNsbCztita0WByf23h0+PX4FOTSu8Wqta+f0skNhHbqd8 ++UUFpYGhw2vuwxO2bWuktOAOUQLEFb6khUJvKgbAIjZFdjZHFmjr3SA2mttOr1prSonOrQXVM7fGp ++xcI7CEsjTZmcqwlB6dNd3CygVcb6o5i7ZEg3KU3QbKWyELUQfjy8SpwtklL5qlvHNGVSdEXXrNGG ++Qa0hcptn966uSEZ94eDEZ7PTtRHyOCNIbFFL1IVCF9BI9BjksWao/95p8BVZImgO8n0rSoRh3/OW ++zGBjTfPL6NoUZKDR1Ie89pXwfxi+UfWp696qpqFpvHkZwKEoGA7M0a3Lkw6DjBqjHqLCdNrfZRCR ++Xggfhz/Nw1H1F2Mb4T1ZCvHpsPgkmrY+zOlgSo/2UAnSQXeUEdlDhyserKL/1bNdMO4NfRpnaZzO ++gpPznayOLV0inEPro7HWnRVKUs4vvbjmX3/NDMMwDMMwDMMwDMMwDMMwDMMwDMMwDMO8R34CrQcH ++EgAoAAA= +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-000736/tests/test.sh b/tasks/format-code-task-000736/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..32063630cc07ce0e3e6e95d5755b82a93564563f --- /dev/null +++ b/tasks/format-code-task-000736/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' +_examples/assert-godogs/godogs_test.go +_examples/godogs/godogs_test.go +run_progress_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-000736/tests/test_command.sh b/tasks/format-code-task-000736/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000736/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-000738/environment/Dockerfile b/tasks/format-code-task-000738/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..afbd09a18f2389c1011abe7db494e21be1516055 --- /dev/null +++ b/tasks/format-code-task-000738/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:a2c225360a82d3b9e82c3bd5efe509a9e997e26e5a5665f8f1d98e700e00b57f diff --git a/tasks/format-code-task-000738/environment/setup/files/blocklist b/tasks/format-code-task-000738/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000738/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-000738/environment/setup/setup.sh b/tasks/format-code-task-000738/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000738/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-000738/tests/test.patch b/tasks/format-code-task-000738/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..014fd96eeaf86fd0fda5c3f63b4acc26a785868d --- /dev/null +++ b/tasks/format-code-task-000738/tests/test.patch @@ -0,0 +1,116 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..214cfe135 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m unittest tests.cupy_tests.core_tests.test_kernel_name -v"] ++} +diff --git a/tests/cupy_tests/core_tests/test_kernel_name.py b/tests/cupy_tests/core_tests/test_kernel_name.py +new file mode 100644 +index 000000000..31f8f07ea +--- /dev/null ++++ b/tests/cupy_tests/core_tests/test_kernel_name.py +@@ -0,0 +1,88 @@ ++import unittest ++ ++import cupy ++from cupy import core ++ ++ ++def _make_elementwise(name): ++ return cupy.ElementwiseKernel('T x', 'T y', 'y = x', name) ++ ++ ++def _make_reduction(name): ++ return core.ReductionKernel( ++ 'T x', 'T out', 'x', 'a + b', 'out = a', '0', name) ++ ++ ++class TestElementwiseKernelNameValidation(unittest.TestCase): ++ ++ ++ ++ def test_default_name(self): ++ ++ cupy.ElementwiseKernel('T x', 'T y', 'y = x') ++ ++ def test_valid_alpha_name(self): ++ _make_elementwise('my_kernel') ++ ++ def test_valid_underscore_prefix(self): ++ _make_elementwise('_kernel') ++ ++ def test_valid_alphanum_name(self): ++ _make_elementwise('kernel123') ++ ++ def test_valid_mixed_case_name(self): ++ _make_elementwise('MyKernel_2') ++ ++ ++ ++ def test_empty_name_raises(self): ++ with self.assertRaises(ValueError): ++ _make_elementwise('') ++ ++ def test_leading_digit_raises(self): ++ with self.assertRaises(ValueError): ++ _make_elementwise('1kernel') ++ ++ def test_space_in_name_raises(self): ++ with self.assertRaises(ValueError): ++ _make_elementwise('bad name') ++ ++ def test_hyphen_in_name_raises(self): ++ with self.assertRaises(ValueError): ++ _make_elementwise('bad-name') ++ ++ def test_special_char_raises(self): ++ with self.assertRaises(ValueError): ++ _make_elementwise('bad!name') ++ ++ ++class TestReductionKernelNameValidation(unittest.TestCase): ++ ++ def test_valid_alpha_name(self): ++ _make_reduction('my_sum') ++ ++ def test_valid_underscore_prefix(self): ++ _make_reduction('_my_sum') ++ ++ def test_valid_alphanum_name(self): ++ _make_reduction('sum123') ++ ++ def test_empty_name_raises(self): ++ with self.assertRaises(ValueError): ++ _make_reduction('') ++ ++ def test_leading_digit_raises(self): ++ with self.assertRaises(ValueError): ++ _make_reduction('1sum') ++ ++ def test_space_in_name_raises(self): ++ with self.assertRaises(ValueError): ++ _make_reduction('bad name') ++ ++ def test_hyphen_in_name_raises(self): ++ with self.assertRaises(ValueError): ++ _make_reduction('bad-name') ++ ++ ++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.cupy_tests.core_tests.test_kernel_name -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000738/tests/test.sh b/tasks/format-code-task-000738/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..edcc11e402d43dbe165104e7643f52dfc41270f7 --- /dev/null +++ b/tasks/format-code-task-000738/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/cupy_tests/core_tests/test_kernel_name.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-000738/tests/test_command.sh b/tasks/format-code-task-000738/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000738/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-000752/environment/Dockerfile b/tasks/format-code-task-000752/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..27707e2677190de30d6d9efcc230ce6beb65d8a3 --- /dev/null +++ b/tasks/format-code-task-000752/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:47ea975c0ee695295a139e8cde98209dc5003342d803b8a98399985150a1b426 diff --git a/tasks/format-code-task-000752/environment/setup/files/blocklist b/tasks/format-code-task-000752/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000752/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-000752/environment/setup/setup.sh b/tasks/format-code-task-000752/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000752/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-000752/tests/test.patch b/tasks/format-code-task-000752/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..88a6e9225d00574a9b1ecb90e27a39dc3714b304 --- /dev/null +++ b/tasks/format-code-task-000752/tests/test.patch @@ -0,0 +1,224 @@ +diff --git a/dask/tests/test_tokenize.py b/dask/tests/test_tokenize.py +index a7f6060bd..241f2c01b 100644 +--- a/dask/tests/test_tokenize.py ++++ b/dask/tests/test_tokenize.py +@@ -3,6 +3,7 @@ from __future__ import annotations + import dataclasses + import datetime + import decimal ++import os + import operator + import pathlib + import pickle +@@ -10,6 +11,7 @@ import random + import subprocess + import sys + import textwrap ++import uuid + from enum import Enum, Flag, IntEnum, IntFlag + from typing import Union + +@@ -229,8 +231,7 @@ def test_tokenize_numpy_memmap(): + z = check_tokenize(np.load(fn, mmap_mode="r")) + + assert check_tokenize(x1) == check_tokenize(x2) +- # Memory maps should behave similar to ordinary arrays +- assert y == z ++ assert y != z + + with tmpfile(".npy") as fn: + x = np.random.normal(size=(10, 10)) +@@ -246,6 +247,139 @@ def test_tokenize_numpy_memmap(): + assert check_tokenize(mm[1, :]) == check_tokenize(mm2[1, :]) + + ++class GuardedMemmap(np.memmap): ++ def __array__(self, dtype=None, copy=None): ++ raise AssertionError("tokenization attempted to materialize the memmap") ++ ++ def __reduce__(self): ++ raise AssertionError("tokenization attempted to pickle the memmap") ++ ++ def __reduce_ex__(self, protocol): ++ raise AssertionError("tokenization attempted to pickle the memmap") ++ ++ def tobytes(self, *args, **kwargs): ++ raise AssertionError("tokenization attempted to read the full memmap") ++ ++ def __iter__(self): ++ raise AssertionError("tokenization attempted to iterate over the memmap") ++ ++ ++def test_tokenize_memmap_does_not_hash_contents(tmp_path): ++ from dask.base import tokenize ++ ++ path = tmp_path / "large.dat" ++ data = np.arange(4096, dtype=np.int64) ++ data.tofile(os.fspath(path)) ++ mm = np.memmap(path, dtype=data.dtype, mode="r", shape=data.shape) ++ ++ token = tokenize(mm) ++ ++ assert token == tokenize(mm) ++ ++ ++def test_tokenize_writable_memmap_does_not_use_object_fallback(tmp_path): ++ from dask.base import tokenize ++ ++ path = tmp_path / "writable.dat" ++ data = np.arange(32, dtype=np.int64) ++ data.tofile(os.fspath(path)) ++ mm = np.memmap(path, dtype=data.dtype, mode="r+", shape=data.shape).view( ++ GuardedMemmap ++ ) ++ ++ token = tokenize(mm) ++ ++ assert token == tokenize(mm) ++ ++ ++def test_tokenize_larger_memmap_does_not_use_object_fallback(tmp_path): ++ from dask.base import tokenize ++ ++ path = tmp_path / "larger.dat" ++ data = np.arange(8192, dtype=np.int64) ++ data.tofile(os.fspath(path)) ++ mm = np.memmap(path, dtype=data.dtype, mode="r", shape=data.shape) ++ ++ token = tokenize(mm) ++ ++ assert token == tokenize(mm) ++ ++ ++def test_tokenize_non_tmp_memmap_does_not_use_object_fallback(tmp_path): ++ from dask.base import tokenize ++ ++ path = tmp_path / f"{uuid.uuid4().hex}.dat" ++ np.arange(64, dtype=np.int64).tofile(os.fspath(path)) ++ mm = np.memmap(path, dtype=np.int64, mode="r", shape=(64,)).view(GuardedMemmap) ++ ++ token = tokenize(mm) ++ ++ assert token == tokenize(mm) ++ ++ ++def test_from_array_memmap_graph_build_does_not_materialize_contents( ++ tmp_path ++): ++ import dask.array as da ++ ++ path = tmp_path / "array.dat" ++ data = np.arange(4096, dtype=np.int64).reshape(512, 8) ++ data.tofile(os.fspath(path)) ++ mm = np.memmap(path, dtype=data.dtype, mode="r", shape=data.shape) ++ ++ arr = da.from_array(mm, chunks=(128, 8)) ++ ++ assert arr.shape == mm.shape ++ assert arr.chunks == ((128, 128, 128, 128), (8,)) ++ ++ ++def test_memmap_token_uses_backing_metadata_and_is_stable(tmp_path): ++ from dask.base import tokenize ++ ++ path = tmp_path / "stable.npy" ++ data = np.arange(32, dtype=np.int64) ++ np.save(path, data) ++ ++ first = np.load(path, mmap_mode="r") ++ second = np.load(path, mmap_mode="r") ++ ++ assert tokenize(first) == tokenize(second) ++ ++ before = tokenize(first) ++ os.utime(path, (2_000_000_000, 2_000_000_000)) ++ after = tokenize(np.load(path, mmap_mode="r")) ++ ++ assert before != after ++ ++ ++def test_memmap_token_distinguishes_views_or_offsets(tmp_path): ++ from dask.base import tokenize ++ ++ path = tmp_path / "offsets.dat" ++ np.zeros(32, dtype=np.uint8).tofile(os.fspath(path)) ++ ++ first = np.memmap(path, dtype=np.uint8, mode="r", offset=0, shape=(8,)) ++ same_first = np.memmap(path, dtype=np.uint8, mode="r", offset=0, shape=(8,)) ++ shifted = np.memmap(path, dtype=np.uint8, mode="r", offset=8, shape=(8,)) ++ ++ assert tokenize(first) == tokenize(same_first) ++ assert tokenize(first) != tokenize(shifted) ++ ++ ++def test_memmap_token_distinguishes_dtype_metadata(tmp_path): ++ from dask.base import tokenize ++ ++ path = tmp_path / "dtype.dat" ++ np.zeros(16, dtype=np.uint8).tofile(os.fspath(path)) ++ ++ unsigned = np.memmap(path, dtype=np.uint8, mode="r", shape=(8,)) ++ signed = np.memmap(path, dtype=np.int8, mode="r", shape=(8,)) ++ ++ assert unsigned.shape == signed.shape ++ assert unsigned.strides == signed.strides ++ assert tokenize(unsigned) != tokenize(signed) ++ ++ + @pytest.mark.skipif("not np") + def test_tokenize_numpy_memmap_no_filename(): + # GH 1562: +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,49 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++if [ ! -x /testbed/.build_env/.venv/bin/python ]; then ++ rm -rf /testbed/.build_env/.venv ++ python3 -m venv /testbed/.build_env/.venv ++fi ++ ++set +u ++source /testbed/.build_env/.venv/bin/activate ++set -u ++ ++python -m pip install -U pip setuptools wheel ++python -m pip install \ ++ "numpy<2.0" \ ++ "pandas<2.3" \ ++ "dask-expr==1.1.2" \ ++ "pyarrow>=14" \ ++ pytest \ ++ pytest-cov \ ++ pytest-rerunfailures \ ++ pytest-timeout \ ++ pytest-xdist ++python -m pip install -e ".[array]" ++ ++case "${1:-}" in ++ base) ++ python -m pytest -q \ ++ dask/tests/test_tokenize.py::test_tokenize_numpy_array_consistent_on_values \ ++ dask/tests/test_tokenize.py::test_tokenize_numpy_memmap_offset ++ ;; ++ new) ++ python -m pytest -q \ ++ dask/tests/test_tokenize.py::test_tokenize_numpy_memmap \ ++ dask/tests/test_tokenize.py::test_tokenize_memmap_does_not_hash_contents \ ++ dask/tests/test_tokenize.py::test_tokenize_writable_memmap_does_not_use_object_fallback \ ++ dask/tests/test_tokenize.py::test_tokenize_larger_memmap_does_not_use_object_fallback \ ++ dask/tests/test_tokenize.py::test_tokenize_non_tmp_memmap_does_not_use_object_fallback \ ++ dask/tests/test_tokenize.py::test_from_array_memmap_graph_build_does_not_materialize_contents \ ++ dask/tests/test_tokenize.py::test_memmap_token_uses_backing_metadata_and_is_stable \ ++ dask/tests/test_tokenize.py::test_memmap_token_distinguishes_views_or_offsets \ ++ dask/tests/test_tokenize.py::test_memmap_token_distinguishes_dtype_metadata ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-000752/tests/test.sh b/tasks/format-code-task-000752/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..a5ea1b545ab2ac82ea7b9a510ef2da5240ee42a9 --- /dev/null +++ b/tasks/format-code-task-000752/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' +dask/tests/test_tokenize.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-000752/tests/test_command.sh b/tasks/format-code-task-000752/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-000752/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-000753/environment/Dockerfile b/tasks/format-code-task-000753/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..cae67ccc2562185ca2af544731d146086bd985bc --- /dev/null +++ b/tasks/format-code-task-000753/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:86b609ec073ed5f7c8701b6a0c7b835f3f95f6b0da4c9215d16ecebb7dc3a5c9 diff --git a/tasks/format-code-task-000753/environment/setup/files/blocklist b/tasks/format-code-task-000753/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000753/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-000753/environment/setup/setup.sh b/tasks/format-code-task-000753/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000753/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-000753/tests/test.patch b/tasks/format-code-task-000753/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..122497f144f95a7f96c7d61c6d58cba87f55b352 --- /dev/null +++ b/tasks/format-code-task-000753/tests/test.patch @@ -0,0 +1,167 @@ +diff --git a/dask/tests/test_fuse.py b/dask/tests/test_fuse.py +new file mode 100644 +index 000000000..b91d4ed94 +--- /dev/null ++++ b/dask/tests/test_fuse.py +@@ -0,0 +1,136 @@ ++from dask.core import fuse, subs ++ ++ ++def inc(x): ++ return x + 1 ++ ++ ++def add(x, y): ++ return x + y ++ ++ ++def test_subs_replaces_key_in_task(): ++ assert subs((inc, 'x'), 'x', 1) == (inc, 1) ++ assert subs((add, 'x', 'y'), 'x', 1) == (add, 1, 'y') ++ ++ ++def test_subs_recurses_into_nested_tasks(): ++ assert subs((add, (inc, 'x'), 'y'), 'x', 1) == (add, (inc, 1), 'y') ++ ++ ++def test_subs_recurses_into_lists(): ++ assert subs((sum, [1, 'x']), 'x', 2) == (sum, [1, 2]) ++ assert subs((sum, [1, ['x']]), 'x', 2) == (sum, [1, [2]]) ++ ++ ++def test_subs_leaves_callable_untouched(): ++ ++ assert subs((inc, 'y'), inc, 1) == (inc, 'y') ++ ++ ++def test_subs_on_bare_key(): ++ assert subs('x', 'x', 1) == 1 ++ assert subs('y', 'x', 1) == 'y' ++ ++ ++def test_subs_no_match_returns_unchanged(): ++ assert subs((inc, 'a'), 'x', 1) == (inc, 'a') ++ ++ ++def test_fuse_single_chain(): ++ assert fuse({ ++ 'w': (inc, 'x'), ++ 'x': (inc, 'y'), ++ 'y': (inc, 'z'), ++ 'z': (add, 'a', 'b'), ++ 'a': 1, ++ 'b': 2, ++ }) == { ++ 'w': (inc, (inc, (inc, (add, 'a', 'b')))), ++ 'a': 1, ++ 'b': 2, ++ } ++ ++ ++def test_fuse_chain_with_extra_dependent(): ++ assert fuse({ ++ 'NEW': (inc, 'y'), ++ 'w': (inc, 'x'), ++ 'x': (inc, 'y'), ++ 'y': (inc, 'z'), ++ 'z': (add, 'a', 'b'), ++ 'a': 1, ++ 'b': 2, ++ }) == { ++ 'NEW': (inc, 'y'), ++ 'w': (inc, (inc, 'y')), ++ 'y': (inc, (add, 'a', 'b')), ++ 'a': 1, ++ 'b': 2, ++ } ++ ++ ++def test_fuse_multiple_chains(): ++ assert fuse({ ++ 'v': (inc, 'y'), ++ 'u': (inc, 'w'), ++ 'w': (inc, 'x'), ++ 'x': (inc, 'y'), ++ 'y': (inc, 'z'), ++ 'z': (add, 'a', 'b'), ++ 'a': (inc, 'c'), ++ 'b': (inc, 'd'), ++ 'c': 1, ++ 'd': 2, ++ }) == { ++ 'u': (inc, (inc, (inc, 'y'))), ++ 'v': (inc, 'y'), ++ 'y': (inc, (add, 'a', 'b')), ++ 'a': (inc, 1), ++ 'b': (inc, 2), ++ } ++ ++ ++def test_fuse_shared_dependency_not_fused(): ++ assert fuse({ ++ 'a': (inc, 'x'), ++ 'b': (inc, 'x'), ++ 'c': (inc, 'x'), ++ 'd': (inc, 'c'), ++ 'x': (inc, 'y'), ++ 'y': 0, ++ }) == { ++ 'a': (inc, 'x'), ++ 'b': (inc, 'x'), ++ 'd': (inc, (inc, 'x')), ++ 'x': (inc, 0), ++ } ++ ++ ++def test_fuse_duplicate_reference_not_fused(): ++ ++ assert fuse({ ++ 'a': 1, ++ 'b': (inc, 'a'), ++ 'c': (add, 'b', 'b'), ++ }) == { ++ 'b': (inc, 1), ++ 'c': (add, 'b', 'b'), ++ } ++ ++ ++def test_fuse_does_not_mutate_input(): ++ dsk = { ++ 'a': 1, ++ 'b': (inc, 'a'), ++ 'c': (inc, 'b'), ++ } ++ original = dict(dsk) ++ fuse(dsk) ++ assert dsk == original ++ ++ ++def test_fuse_no_chain_returns_equal(): ++ assert fuse({}) == {} ++ assert fuse({'a': 1, 'b': 2}) == {'a': 1, 'b': 2} ++ assert fuse({'a': 1, 'b': (add, 'a', 'a')}) == {'a': 1, 'b': (add, 'a', 'a')} +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 dask/tests/test_core.py -q ++ ++ ++python -m pytest dask/tests/test_fuse.py -q diff --git a/tasks/format-code-task-000753/tests/test.sh b/tasks/format-code-task-000753/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..ed6eeb0122719d066048ea0b984c7f53f572a6de --- /dev/null +++ b/tasks/format-code-task-000753/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' +dask/tests/test_fuse.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-000753/tests/test_command.sh b/tasks/format-code-task-000753/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000753/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-000755/environment/Dockerfile b/tasks/format-code-task-000755/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8ace1bc1f09d7b84e8921bf53b7a8c4939e92bc4 --- /dev/null +++ b/tasks/format-code-task-000755/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:2db8ad32f4c4146aaa3553cfaf9042a40366cbcf0f175cc97c56ae06c6267e8a diff --git a/tasks/format-code-task-000755/environment/setup/files/blocklist b/tasks/format-code-task-000755/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000755/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-000755/environment/setup/setup.sh b/tasks/format-code-task-000755/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000755/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-000755/tests/test.patch b/tasks/format-code-task-000755/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..bf24e8e5367eef1b95aabc112a73c4a3b5ae93e4 --- /dev/null +++ b/tasks/format-code-task-000755/tests/test.patch @@ -0,0 +1,146 @@ +diff --git a/databricks/koalas/tests/test_dataframe.py b/databricks/koalas/tests/test_dataframe.py +index 4b4a1a3432..c3ff306d38 100644 +--- a/databricks/koalas/tests/test_dataframe.py ++++ b/databricks/koalas/tests/test_dataframe.py +@@ -1141,7 +1141,7 @@ def test_to_numpy(self): + + kdf = ks.from_pandas(pdf) + +- np.testing.assert_equal(kdf.to_numpy(), pdf.values) ++ self.assert_eq(kdf.to_numpy(), pdf.values) + + def test_to_pandas(self): + pdf, kdf = self.df_pair +@@ -3528,13 +3528,13 @@ def test_take(self): + def test_axes(self): + pdf = self.pdf + kdf = ks.from_pandas(pdf) +- self.assert_list_eq(pdf.axes, kdf.axes) ++ self.assert_eq(pdf.axes, kdf.axes) + + # multi-index columns + columns = pd.MultiIndex.from_tuples([("x", "a"), ("y", "b")]) + pdf.columns = columns + kdf.columns = columns +- self.assert_list_eq(pdf.axes, kdf.axes) ++ self.assert_eq(pdf.axes, kdf.axes) + + def test_udt(self): + sparse_values = {0: 0.1, 1: 1.1} +diff --git a/databricks/koalas/tests/test_dataframe_conversion.py b/databricks/koalas/tests/test_dataframe_conversion.py +index b14f7f0b59..278e2c0f1e 100644 +--- a/databricks/koalas/tests/test_dataframe_conversion.py ++++ b/databricks/koalas/tests/test_dataframe_conversion.py +@@ -208,11 +208,9 @@ def test_to_records(self): + + kdf = ks.from_pandas(pdf) + +- self.assert_array_eq(kdf.to_records(), pdf.to_records()) +- self.assert_array_eq(kdf.to_records(index=False), pdf.to_records(index=False)) +- self.assert_array_eq( +- kdf.to_records(index_dtypes="